Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Improper Error handling on shifting patient #9561

Closed
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import TextAreaFormField from "@/components/Form/FormFields/TextAreaFormField";
import TextFormField from "@/components/Form/FormFields/TextFormField";
import PrescriptionBuilder from "@/components/Medicine/PrescriptionBuilder";

import useAppHistory from "@/hooks/useAppHistory";
import useConfirmedAction from "@/hooks/useConfirmedAction";

import { DISCHARGE_REASONS } from "@/common/constants";
Expand Down Expand Up @@ -92,10 +93,22 @@ const DischargeModal = ({
setFacility(referred_to);
}, [referred_to]);

const initialDiagnoses = useTanStackQueryInstead(routes.getConsultation, {
const { goBack } = useAppHistory();

const { data } = useTanStackQueryInstead(routes.getConsultation, {
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
pathParams: { id: consultationData.id ?? "" },
prefetch: !!consultationData.id,
}).data?.diagnoses;
silent: true,
onResponse: ({ error }) => {
if (error) {
goBack();
Notification.Error({ msg: "Error in fetching consultation data" });
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
return;
}
},
});

const initialDiagnoses = data?.diagnoses ?? [];
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved

const discharge_reason =
new_discharge_reason ?? preDischargeForm.new_discharge_reason;
Expand Down
Loading