diff --git a/src/components/Patient/EncounterQuestionnaire.tsx b/src/components/Patient/EncounterQuestionnaire.tsx index 90de3924f2c..10799afe296 100644 --- a/src/components/Patient/EncounterQuestionnaire.tsx +++ b/src/components/Patient/EncounterQuestionnaire.tsx @@ -1,13 +1,19 @@ +import { useQuery } from "@tanstack/react-query"; import { t } from "i18next"; import { navigate } from "raviger"; import { Card, CardContent } from "@/components/ui/card"; import Page from "@/components/Common/Page"; +import PatientInfoCard from "@/components/Patient/PatientInfoCard"; import { QuestionnaireForm } from "@/components/Questionnaire/QuestionnaireForm"; import useAppHistory from "@/hooks/useAppHistory"; +import routes from "@/Utils/request/api"; +import query from "@/Utils/request/query"; +import { formatDateTime } from "@/Utils/utils"; + interface Props { facilityId: string; patientId: string; @@ -24,29 +30,61 @@ export default function EncounterQuestionnaire({ subjectType, }: Props) { const { goBack } = useAppHistory(); + const { data: encounter } = useQuery({ + queryKey: ["encounter", encounterId], + queryFn: query(routes.encounter.get, { + pathParams: { id: encounterId ?? "" }, + queryParams: { facility: facilityId }, + }), + enabled: !!encounterId, + }); return ( - - - { - if (encounterId) { - navigate( - `/facility/${facilityId}/patient/${patientId}/encounter/${encounterId}/updates`, - ); - } else { - navigate(`/patient/${patientId}/updates`); - } - }} - onCancel={() => goBack()} - /> - - +
+ {encounter && ( +
+ {}} + disableButtons={true} + /> + +
+
+
+ + {t("last_modified")}:{" "} + +   + {formatDateTime(encounter.modified_date)} +
+
+
+
+ )} + + + { + if (encounterId) { + navigate( + `/facility/${facilityId}/patient/${patientId}/encounter/${encounterId}/updates`, + ); + } else { + navigate(`/patient/${patientId}/updates`); + } + }} + onCancel={() => goBack()} + /> + + +
); } diff --git a/src/components/Patient/PatientInfoCard.tsx b/src/components/Patient/PatientInfoCard.tsx index 1212a95300d..1e9b2922126 100644 --- a/src/components/Patient/PatientInfoCard.tsx +++ b/src/components/Patient/PatientInfoCard.tsx @@ -45,6 +45,7 @@ import { import { Avatar } from "@/components/Common/Avatar"; import { LocationHistorySheet } from "@/components/Location/LocationHistorySheet"; import { LocationTree } from "@/components/Location/LocationTree"; +import LinkDepartmentsSheet from "@/components/Patient/LinkDepartmentsSheet"; import { PLUGIN_Component } from "@/PluginEngine"; import routes from "@/Utils/request/api"; @@ -52,17 +53,17 @@ import mutate from "@/Utils/request/mutate"; import { formatDateTime, formatPatientAge } from "@/Utils/utils"; import { Encounter, completedEncounterStatus } from "@/types/emr/encounter"; import { Patient } from "@/types/emr/newPatient"; - -import LinkDepartmentsSheet from "./LinkDepartmentsSheet"; +import { FacilityOrganization } from "@/types/facilityOrganization/facilityOrganization"; export interface PatientInfoCardProps { patient: Patient; encounter: Encounter; fetchPatientData?: (state: { aborted: boolean }) => void; + disableButtons?: boolean; } export default function PatientInfoCard(props: PatientInfoCardProps) { - const { patient, encounter } = props; + const { patient, encounter, disableButtons = false } = props; const { t } = useTranslation(); const queryClient = useQueryClient(); @@ -331,17 +332,9 @@ export default function PatientInfoCard(props: PatientInfoCardProps) { facilityId={encounter.facility.id} trigger={
- {encounter.organizations.map((org) => ( - - - {org.name} - - ))} + {encounter.organizations.map((org) => + organizationBadge(org), + )} {encounter.organizations.length === 0 && ( -
- + {!disableButtons && ( + <> +
+ + + )}
) : ( - - - - {t("add_location")} - - + encounter.status !== "completed" && + !disableButtons && ( + + + + {t("add_location")} + + + ) )}
@@ -439,78 +439,98 @@ export default function PatientInfoCard(props: PatientInfoCardProps) { className="flex flex-col items-center justify-end gap-4 px-4 py-1 2xl:flex-row" id="consultation-buttons" > - {!completedEncounterStatus.includes(encounter.status) && ( -
- - - - - - - {t("actions")} - - - {t("treatment_summary")} - - - - - {t("discharge_summary")} - - - - e.preventDefault()}> - {t("mark_as_complete")} + {!completedEncounterStatus.includes(encounter.status) && + !disableButtons && ( +
+ + + + + + + {t("actions")} + + + {t("treatment_summary")} + - + + + {t("discharge_summary")} + + + + e.preventDefault()}> + {t("mark_as_complete")} + + + + + + + + + {t("mark_as_complete")} + + + {t("mark_encounter_as_complete_confirmation")} + + + - - - - - {t("mark_as_complete")} - - {t("mark_encounter_as_complete_confirmation")} - - - - - - {t("cancel")} + + {t("cancel")} - - {t("mark_as_complete")} - - - - -
- )} + + {t("mark_as_complete")} + + + +
+
+ )} ); + + function organizationBadge(org: FacilityOrganization) { + return ( + + + {org.name} + + ); + } }