From 6f2217f53c08ed890e005f6bd058a3ecea8fc3be Mon Sep 17 00:00:00 2001 From: JOSHIK Date: Thu, 22 Aug 2024 08:18:35 +0100 Subject: [PATCH 01/13] diagnosis at discharge field added --- src/Components/Facility/DischargeModal.tsx | 65 +++++++++++++++------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index fe99b4ddd53..e1cf74871e2 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -28,6 +28,10 @@ import { FieldError } from "../Form/FieldValidators"; import { useTranslation } from "react-i18next"; import useConfirmedAction from "../../Common/hooks/useConfirmedAction"; import ConfirmDialog from "../Common/ConfirmDialog"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; +import { EditDiagnosesBuilder } from "../Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder"; +import { ConsultationDiagnosis } from "../Diagnosis/types"; interface PreDischargeFormInterface { new_discharge_reason: number | null; @@ -81,6 +85,7 @@ const DischargeModal = ({ const [isSendingDischargeApi, setIsSendingDischargeApi] = useState(false); const [facility, setFacility] = useState(referred_to); const [errors, setErrors] = useState({}); + console.log(preDischargeForm); useEffect(() => { setPreDischargeForm((prev) => ({ @@ -95,6 +100,15 @@ const DischargeModal = ({ setFacility(referred_to); }, [referred_to]); + const { data } = useQuery(routes.getConsultation, { + pathParams: { + id: consultationData.id, + }, + }); + + const ConsultationDiagnosisList: ConsultationDiagnosis[] = + data?.diagnoses?.map((diagnosis) => diagnosis) || []; + const discharge_reason = new_discharge_reason ?? preDischargeForm.new_discharge_reason; @@ -288,27 +302,6 @@ const DischargeModal = ({ /> )} - i.text == "Expired")?.id - } - label={ - { - "3": "Cause of death", - "1": "Discharged Advice", - }[discharge_reason ?? 0] ?? "Notes" - } - name="discharge_notes" - value={preDischargeForm.discharge_notes} - onChange={(e) => - setPreDischargeForm((prev) => ({ - ...prev, - discharge_notes: e.value, - })) - } - error={errors?.discharge_notes} - /> + + {discharge_reason !== + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && ( +
+ Diagnosis at discharge + +
+ )} + {discharge_reason === DISCHARGE_REASONS.find((i) => i.text == "Recovered")?.id && ( <> @@ -384,6 +386,27 @@ const DischargeModal = ({ /> )} + i.text == "Expired")?.id + } + label={ + { + "3": "Cause of death", + "1": "Discharged Advice", + }[discharge_reason ?? 0] ?? "Notes" + } + name="discharge_notes" + value={preDischargeForm.discharge_notes} + onChange={(e) => + setPreDischargeForm((prev) => ({ + ...prev, + discharge_notes: e.value, + })) + } + error={errors?.discharge_notes} + /> {enable_hcx && ( // TODO: if policy and approved pre-auth exists From e992525dbd7c5e23caab3401851c4a505311836e Mon Sep 17 00:00:00 2001 From: JOSHIK Date: Thu, 22 Aug 2024 08:20:38 +0100 Subject: [PATCH 02/13] erased console logs --- src/Components/Facility/DischargeModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index e1cf74871e2..003719dedcd 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -85,7 +85,6 @@ const DischargeModal = ({ const [isSendingDischargeApi, setIsSendingDischargeApi] = useState(false); const [facility, setFacility] = useState(referred_to); const [errors, setErrors] = useState({}); - console.log(preDischargeForm); useEffect(() => { setPreDischargeForm((prev) => ({ From 6d3a5f9c1d15434feadedeb3b5fb2de18d3d429e Mon Sep 17 00:00:00 2001 From: JOSHIK Date: Thu, 22 Aug 2024 08:23:37 +0100 Subject: [PATCH 03/13] minor fix --- src/Components/Facility/DischargeModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 003719dedcd..7e083083a73 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -347,7 +347,7 @@ const DischargeModal = ({ {discharge_reason !== DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
- Diagnosis at discharge + Diagnosis at Discharge
)} From 627d02ee1fd3484b40bc61cb89f95c229b5b8795 Mon Sep 17 00:00:00 2001 From: JOSHIK ROSHAN <96165631+JOSHIK27@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:05:56 +0100 Subject: [PATCH 04/13] Update src/Components/Facility/DischargeModal.tsx Co-authored-by: Rithvik Nishad --- src/Components/Facility/DischargeModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 7e083083a73..cb8aee25037 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -105,7 +105,7 @@ const DischargeModal = ({ }, }); - const ConsultationDiagnosisList: ConsultationDiagnosis[] = + const diagnoses = data?.diagnoses?.map((diagnosis) => diagnosis) || []; const discharge_reason = From 9f2f9d64c231229ac2207fbc1a8acf920bd0d269 Mon Sep 17 00:00:00 2001 From: JOSHIK ROSHAN <96165631+JOSHIK27@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:06:18 +0100 Subject: [PATCH 05/13] Update src/Components/Facility/DischargeModal.tsx Co-authored-by: Rithvik Nishad --- src/Components/Facility/DischargeModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index cb8aee25037..80f2fdd7340 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -106,7 +106,7 @@ const DischargeModal = ({ }); const diagnoses = - data?.diagnoses?.map((diagnosis) => diagnosis) || []; + data?.diagnoses ?? []; const discharge_reason = new_discharge_reason ?? preDischargeForm.new_discharge_reason; From 755c4bcb78f5a4c4a4819bca9e6c08920122a611 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 22 Aug 2024 14:18:35 +0530 Subject: [PATCH 06/13] Add loading state, fix lint errors and improve code quality --- src/Components/Facility/DischargeModal.tsx | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 80f2fdd7340..dd3e2784ab6 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -31,7 +31,7 @@ import ConfirmDialog from "../Common/ConfirmDialog"; import routes from "../../Redux/api"; import useQuery from "../../Utils/request/useQuery"; import { EditDiagnosesBuilder } from "../Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder"; -import { ConsultationDiagnosis } from "../Diagnosis/types"; +import Loading from "../Common/Loading"; interface PreDischargeFormInterface { new_discharge_reason: number | null; @@ -99,14 +99,9 @@ const DischargeModal = ({ setFacility(referred_to); }, [referred_to]); - const { data } = useQuery(routes.getConsultation, { - pathParams: { - id: consultationData.id, - }, - }); - - const diagnoses = - data?.diagnoses ?? []; + const initialDiagnoses = useQuery(routes.getConsultation, { + pathParams: { id: consultationData.id }, + }).data?.diagnoses; const discharge_reason = new_discharge_reason ?? preDischargeForm.new_discharge_reason; @@ -218,6 +213,10 @@ const DischargeModal = ({ const confirmationRequired = encounterDuration.asDays() >= 30; + if (initialDiagnoses == null) { + return ; + } + return ( <> i.text == "Expired")?.id && ( -
- Diagnosis at Discharge - +
+ Diagnoses +
)} From 92623339aa8e79a570bbe7c3990e50e4fe48af2c Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 2 Sep 2024 12:31:40 +0530 Subject: [PATCH 07/13] Update label to Diagnosis at Discharge --- src/Components/Facility/DischargeModal.tsx | 2 +- src/Locale/en/Consultation.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index dd3e2784ab6..5c58c189d7f 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -346,7 +346,7 @@ const DischargeModal = ({ {discharge_reason !== DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
- Diagnoses + {t("diagnosis_at_discharge")}
)} diff --git a/src/Locale/en/Consultation.json b/src/Locale/en/Consultation.json index d3b24781f50..2d8852d155b 100644 --- a/src/Locale/en/Consultation.json +++ b/src/Locale/en/Consultation.json @@ -54,5 +54,6 @@ "encounter_date_field_label__R": "Date & Time of Consultation", "back_dated_encounter_date_caution": "You are creating an encounter for", "encounter_duration_confirmation": "The duration of this encounter would be", - "consultation_notes": "General Instructions (Advice)" -} + "consultation_notes": "General Instructions (Advice)", + "diagnosis_at_discharge": "Diagnosis at Discharge" +} \ No newline at end of file From 0e5fe0cc4ade1b22a30cf5eeeef5013554f596bc Mon Sep 17 00:00:00 2001 From: JOSHIK Date: Sat, 7 Sep 2024 14:41:22 +0100 Subject: [PATCH 08/13] fixed by keeping a check on consultatio data --- src/Components/Facility/DischargeModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 5c58c189d7f..20604928a83 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -100,7 +100,7 @@ const DischargeModal = ({ }, [referred_to]); const initialDiagnoses = useQuery(routes.getConsultation, { - pathParams: { id: consultationData.id }, + pathParams: { id: consultationData.id ?? "" }, }).data?.diagnoses; const discharge_reason = From 72f03caf5eccae62cf2b47c86f3474bebfbb9125 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:16:25 +0530 Subject: [PATCH 09/13] fix the merge conflict --- src/Locale/en/Consultation.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Locale/en/Consultation.json b/src/Locale/en/Consultation.json index 6b96252c1b0..c6817c9ea69 100644 --- a/src/Locale/en/Consultation.json +++ b/src/Locale/en/Consultation.json @@ -58,7 +58,7 @@ "back_dated_encounter_date_caution": "You are creating an encounter for", "encounter_duration_confirmation": "The duration of this encounter would be", "consultation_notes": "General Instructions (Advice)", - "diagnosis_at_discharge": "Diagnosis at Discharge" + "diagnosis_at_discharge": "Diagnosis at Discharge", "procedure_suggestions": "Procedure Suggestions", "patient_notes_thread__Doctors": "Doctor's Discussions", "patient_notes_thread__Nurses": "Nurse's Discussions" From 1cee48e3efae32ca991e279a540fda3cdba127dd Mon Sep 17 00:00:00 2001 From: JOSHIK Date: Mon, 23 Sep 2024 17:19:35 +0100 Subject: [PATCH 10/13] removed duplicate imports --- src/Components/Facility/DischargeModal.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index ba6ca14316a..4e27f52cc0a 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -28,11 +28,9 @@ import { useTranslation } from "react-i18next"; import useConfirmedAction from "../../Common/hooks/useConfirmedAction"; import ConfirmDialog from "../Common/ConfirmDialog"; import routes from "../../Redux/api"; -import useQuery from "../../Utils/request/useQuery"; import { EditDiagnosesBuilder } from "../Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder"; import Loading from "../Common/Loading"; import careConfig from "@careConfig"; -import routes from "../../Redux/api"; interface PreDischargeFormInterface { new_discharge_reason: number | null; From 4568e8574dd742617d139bc146fc0da4287dcedf Mon Sep 17 00:00:00 2001 From: JOSHIK Date: Mon, 23 Sep 2024 19:10:21 +0100 Subject: [PATCH 11/13] fixed something went wrong error by setting prefetch to trigger only when cons id is present --- src/Components/Facility/DischargeModal.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 4e27f52cc0a..9c3b69a6ac9 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -127,6 +127,7 @@ const DischargeModal = ({ const initialDiagnoses = useQuery(routes.getConsultation, { pathParams: { id: consultationData.id ?? "" }, + prefetch: !!consultationData.id, }).data?.diagnoses; const discharge_reason = From 4a86ea147b412021db867d146a81d6e5f4caf3ed Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 30 Sep 2024 19:12:43 +0530 Subject: [PATCH 12/13] fixes discharge modal crashing in shifting completion --- .../ConsultationDiagnosisBuilder.tsx | 3 ++- src/Components/Facility/DischargeModal.tsx | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx b/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx index 043654929a8..1e77a1d7c79 100644 --- a/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx +++ b/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx @@ -80,11 +80,12 @@ interface EditDiagnosesProps { className?: string; value: ConsultationDiagnosis[]; suggestions?: ICD11DiagnosisModel[]; + consultationId?: string; onUpdate?: (diagnoses: ConsultationDiagnosis[]) => void; } export const EditDiagnosesBuilder = (props: EditDiagnosesProps) => { - const consultation = useSlug("consultation"); + const consultation = useSlug("consultation", props.consultationId); const [diagnoses, setDiagnoses] = useState(props.value); const [prefill, setPrefill] = useState(); diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 9c3b69a6ac9..5573fe883d0 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -349,7 +349,10 @@ const DischargeModal = ({ DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
{t("diagnosis_at_discharge")} - +
)} From f334814fb2b03708d70f09d7c208854efa06be93 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 30 Sep 2024 19:48:43 +0530 Subject: [PATCH 13/13] update findSlug logic to use fallback --- src/Common/hooks/useSlug.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Common/hooks/useSlug.ts b/src/Common/hooks/useSlug.ts index 78d2a567e37..a92407e73e5 100644 --- a/src/Common/hooks/useSlug.ts +++ b/src/Common/hooks/useSlug.ts @@ -31,6 +31,9 @@ export const useSlugs = (...prefix: string[]) => { const findSlug = (segments: string[], prefix: string, fallback?: string) => { const index = segments.findIndex((segment) => segment === prefix); if (index === -1) { + if (fallback) { + return fallback; + } throw new Error( `Prefix "${prefix}" not found in path "${segments.join("/")}"`, );