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) => (