From 8ae6d4345039f125ceef040adc70027552bcf424 Mon Sep 17 00:00:00 2001 From: vivek Date: Wed, 13 Dec 2023 12:25:24 +0530 Subject: [PATCH] refactor consultation route --- .../Facility/ConsultationDetails/index.tsx | 32 +++++++++++-------- .../Consultations/DailyRoundsList.tsx | 8 ++--- src/Components/Patient/ManagePatients.tsx | 2 +- src/Routers/routes/ConsultationRoutes.tsx | 3 ++ 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 2f6ca03ef06..ee4d3c27f82 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; } @@ -68,7 +66,7 @@ const TABS = { }; export const ConsultationDetails = (props: any) => { - const { facilityId, patientId, consultationId } = props; + const { consultationId } = props; const tab = props.tab.toUpperCase() as keyof typeof TABS; const dispatch: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); @@ -149,6 +147,9 @@ export const ConsultationDetails = (props: any) => { : "No", is_vaccinated: patientData.is_vaccinated ? "Yes" : "No", }; + navigate( + `/facility/${data.facility_object?.id}/patient/${data.id}/consultation/${data?.last_consultation?.id}` + ); setPatientData(data); } @@ -172,7 +173,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 +181,7 @@ export const ConsultationDetails = (props: any) => { const consultationTabProps: ConsultationTabProps = { consultationId, - facilityId, - patientId, + consultationData, patientData, }; @@ -256,8 +256,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 +314,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 +454,11 @@ export const ConsultationDetails = (props: any) => { {p.desc} @@ -467,15 +473,15 @@ export const ConsultationDetails = (props: any) => { {showPatientNotesPopup && ( )} diff --git a/src/Components/Facility/Consultations/DailyRoundsList.tsx b/src/Components/Facility/Consultations/DailyRoundsList.tsx index 2060d8657e7..cc4c0f5fbb8 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 = `/consultation/${consultationId}`; return ( { patient.last_consultation?.facility === patient.facility && !(patient.last_consultation?.discharge_date && patient.is_active) ) { - patientUrl = `/facility/${patient.facility}/patient/${patient.id}/consultation/${patient.last_consultation.id}`; + patientUrl = `/consultation/${patient.last_consultation.id}`; } else if (patient.facility) { patientUrl = `/facility/${patient.facility}/patient/${patient.id}`; } else { diff --git a/src/Routers/routes/ConsultationRoutes.tsx b/src/Routers/routes/ConsultationRoutes.tsx index 4f1d6e7d75d..b11e38aa2b5 100644 --- a/src/Routers/routes/ConsultationRoutes.tsx +++ b/src/Routers/routes/ConsultationRoutes.tsx @@ -138,4 +138,7 @@ export default { tab={tab} /> ), + "/consultation/:consultationId": ({ consultationId }: any) => ( + + ), };