From a04c02af35b8a7cdac9ac550c0cf90f5a080ac27 Mon Sep 17 00:00:00 2001 From: vivek Date: Thu, 21 Dec 2023 21:59:46 +0530 Subject: [PATCH 1/4] added newRoute consultation/:id --- .../Facility/ConsultationDetails/index.tsx | 34 ++++++++++++------- .../Consultations/DailyRoundsList.tsx | 8 ++--- src/Routers/routes/ConsultationRoutes.tsx | 3 ++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index c0af068d66c..0f8efa18f69 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -45,8 +45,6 @@ const symptomChoices = [...SYMPTOM_CHOICES]; export interface ConsultationTabProps { consultationId: string; - facilityId: string; - patientId: string; consultationData: ConsultationModel; patientData: PatientModel; } @@ -149,6 +147,14 @@ export const ConsultationDetails = (props: any) => { : "No", is_vaccinated: patientData.is_vaccinated ? "Yes" : "No", }; + if ( + facilityId != data.facility_object?.id || + patientId != data.id + ) { + navigate( + `/facility/${data.facility_object?.id}/patient/${data.id}/consultation/${data?.last_consultation?.id}` + ); + } setPatientData(data); } @@ -172,7 +178,7 @@ export const ConsultationDetails = (props: any) => { useAbortableEffect((status: statusType) => { fetchData(status); triggerGoal("Patient Consultation Viewed", { - facilityId: facilityId, + facilityId: patientData?.facility_object?.id, consultationId: consultationId, userId: authUser.id, }); @@ -180,8 +186,6 @@ export const ConsultationDetails = (props: any) => { const consultationTabProps: ConsultationTabProps = { consultationId, - facilityId, - patientId, consultationData, patientData, }; @@ -256,8 +260,10 @@ export const ConsultationDetails = (props: any) => { title="Patient Dashboard" className="sm:m-0 sm:p-0" crumbsReplacements={{ - [facilityId]: { name: patientData?.facility_object?.name }, - [patientId]: { name: patientData?.name }, + [patientData?.facility_object?.id || ""]: { + name: patientData?.facility_object?.name, + }, + [patientData?.id || ""]: { name: patientData?.name }, [consultationId]: { name: consultationData.suggestion === "A" @@ -312,7 +318,7 @@ export const ConsultationDetails = (props: any) => { onClick={() => showPatientNotesPopup ? navigate( - `/facility/${facilityId}/patient/${patientId}/notes` + `/facility/${patientData?.facility_object?.id}/patient/${patientData?.id}/notes` ) : setShowPatientNotesPopup(true) } @@ -452,7 +458,11 @@ export const ConsultationDetails = (props: any) => { {p.desc} @@ -466,15 +476,15 @@ export const ConsultationDetails = (props: any) => { {showPatientNotesPopup && ( diff --git a/src/Components/Facility/Consultations/DailyRoundsList.tsx b/src/Components/Facility/Consultations/DailyRoundsList.tsx index 46072c16dd8..3b63b60a427 100644 --- a/src/Components/Facility/Consultations/DailyRoundsList.tsx +++ b/src/Components/Facility/Consultations/DailyRoundsList.tsx @@ -16,14 +16,10 @@ interface Props { } export default function DailyRoundsList({ consultation }: Props) { - const [facilityId, patientId, consultationId] = useSlugs( - "facility", - "patient", - "consultation" - ); + const [consultationId] = useSlugs("consultation"); const { t } = useTranslation(); - const consultationUrl = `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`; + const consultationUrl = `/facility/${consultation.facility}/patient/${consultation.patient}/consultation/${consultation.id}`; return ( ), + "/consultation/:consultationId": ({ consultationId }: any) => ( + + ), "/facility/:facilityId/patient/:patientId/consultation/:consultationId/treatment-summary": ({ facilityId, patientId, consultationId }: any) => ( Date: Fri, 22 Dec 2023 14:24:03 +0530 Subject: [PATCH 2/4] fix based on review --- .../Facility/ConsultationDetails/index.tsx | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 0f8efa18f69..d404e071cc8 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -117,6 +117,11 @@ export const ConsultationDetails = (props: any) => { }); data.symptoms_text = symptoms.join(", "); } + if (facilityId != data.facility || patientId != data.patient) { + navigate( + `/facility/${data.facility}/patient/${data.patient}/consultation/${data?.id}` + ); + } setConsultationData(data); const assetRes = await dispatch( listAssetBeds({ @@ -147,14 +152,7 @@ export const ConsultationDetails = (props: any) => { : "No", is_vaccinated: patientData.is_vaccinated ? "Yes" : "No", }; - if ( - facilityId != data.facility_object?.id || - patientId != data.id - ) { - navigate( - `/facility/${data.facility_object?.id}/patient/${data.id}/consultation/${data?.last_consultation?.id}` - ); - } + setPatientData(data); } @@ -458,11 +456,7 @@ export const ConsultationDetails = (props: any) => { {p.desc} @@ -476,15 +470,15 @@ export const ConsultationDetails = (props: any) => { {showPatientNotesPopup && ( From bd417fc8236c690fd19c4c7c04c5c32c9aa90e02 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 22 Dec 2023 14:29:41 +0530 Subject: [PATCH 3/4] minor fix --- src/Components/Facility/ConsultationDetails/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index d404e071cc8..f5b79efdb86 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -176,7 +176,7 @@ export const ConsultationDetails = (props: any) => { useAbortableEffect((status: statusType) => { fetchData(status); triggerGoal("Patient Consultation Viewed", { - facilityId: patientData?.facility_object?.id, + facilityId: consultationData.facility, consultationId: consultationId, userId: authUser.id, }); @@ -258,8 +258,8 @@ export const ConsultationDetails = (props: any) => { title="Patient Dashboard" className="sm:m-0 sm:p-0" crumbsReplacements={{ - [patientData?.facility_object?.id || ""]: { - name: patientData?.facility_object?.name, + [consultationData.facility || ""]: { + name: consultationData.facility_name, }, [patientData?.id || ""]: { name: patientData?.name }, [consultationId]: { @@ -316,7 +316,7 @@ export const ConsultationDetails = (props: any) => { onClick={() => showPatientNotesPopup ? navigate( - `/facility/${patientData?.facility_object?.id}/patient/${patientData?.id}/notes` + `/facility/${facilityId}/patient/${patientId}/notes` ) : setShowPatientNotesPopup(true) } From 67496cc6c6bf1f41d51e3c9ece3f94a6ed17f1b2 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 22 Dec 2023 14:31:56 +0530 Subject: [PATCH 4/4] minor fix --- src/Components/Facility/ConsultationDetails/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index f5b79efdb86..eace53c18af 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -176,7 +176,7 @@ export const ConsultationDetails = (props: any) => { useAbortableEffect((status: statusType) => { fetchData(status); triggerGoal("Patient Consultation Viewed", { - facilityId: consultationData.facility, + facilityId: facilityId, consultationId: consultationId, userId: authUser.id, }); @@ -258,10 +258,8 @@ export const ConsultationDetails = (props: any) => { title="Patient Dashboard" className="sm:m-0 sm:p-0" crumbsReplacements={{ - [consultationData.facility || ""]: { - name: consultationData.facility_name, - }, - [patientData?.id || ""]: { name: patientData?.name }, + [facilityId]: { name: patientData?.facility_object?.name }, + [patientId]: { name: patientData?.name }, [consultationId]: { name: consultationData.suggestion === "A"