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

Support for self-healing Consultation URL #6857

Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
32 changes: 19 additions & 13 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const symptomChoices = [...SYMPTOM_CHOICES];

export interface ConsultationTabProps {
consultationId: string;
facilityId: string;
patientId: string;
consultationData: ConsultationModel;
patientData: PatientModel;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -172,16 +173,15 @@ 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,
});
}, []);

const consultationTabProps: ConsultationTabProps = {
consultationId,
facilityId,
patientId,

consultationData,
patientData,
};
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -452,7 +454,11 @@ export const ConsultationDetails = (props: any) => {
<Link
key={p.text}
className={tabButtonClasses(tab === p.text)}
href={`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/${p.text.toLocaleLowerCase()}`}
href={`/facility/${
patientData?.facility_object?.id
}/patient/${
patientData?.id
}/consultation/${consultationId}/${p.text.toLocaleLowerCase()}`}
>
{p.desc}
</Link>
Expand All @@ -467,15 +473,15 @@ export const ConsultationDetails = (props: any) => {
</div>

<DoctorVideoSlideover
facilityId={facilityId}
facilityId={String(patientData?.facility_object?.id)}
show={showDoctors}
setShow={setShowDoctors}
/>

{showPatientNotesPopup && (
<PatientNotesSlideover
patientId={patientId}
facilityId={facilityId}
patientId={String(patientData?.id)}
facilityId={String(patientData?.facility_object?.id)}
setShowPatientNotesPopup={setShowPatientNotesPopup}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function DailyRoundsList({ consultation }: Props) {
const { t } = useTranslation();

const consultationUrl = `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`;

return (
<PaginatedList
route={routes.getDailyReports}
Expand Down
4 changes: 4 additions & 0 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FileUpload } from "../../Components/Patient/FileUpload";
import { make as CriticalCareRecording } from "../../Components/CriticalCareRecording/CriticalCareRecording.bs";
import { ConsultationDetails } from "../../Components/Facility/ConsultationDetails";
import TreatmentSummary from "../../Components/Facility/TreatmentSummary";
import { Redirect } from "raviger";

export default {
"/facility/:facilityId/patient/:patientId/consultation": ({
Expand Down Expand Up @@ -138,4 +139,7 @@ export default {
tab={tab}
/>
),
"/consultation/:consultationId": ({ consultationId }: any) => (
<Redirect to={`/facility/id/patient/id/consultation/${consultationId}/`} />
Copy link
Contributor Author

@konavivekramakrishna konavivekramakrishna Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id is placeholder as we don't know the facility id and patient id

Copy link
Member

@rithviknishad rithviknishad Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? We could keep it as <ConsultationDetails consultationId={consultationId} tab={"updates"} /> itself right? ConsultationDetails component would correct the URL for us right? (correct me if I am wrong)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes two redirects now:

  • /consultation/<valid_id> goes to
  • /facility/id/patient/id/consultation/<valid_id> goes to
  • /facility/<valid_id>/patient/<valid_id>/consultation/<valid_id>

AppHistory stack would have unnecessary redirects + Back Button no longer works properly this way

),
};
Loading