diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx
index e75eec5b80a..e719e859a4b 100644
--- a/src/Components/Facility/TreatmentSummary.tsx
+++ b/src/Components/Facility/TreatmentSummary.tsx
@@ -4,16 +4,34 @@ import {
formatDateTime,
formatPatientAge,
} from "../../Utils/utils";
-import useSlug from "../../Common/hooks/useSlug";
import useAppHistory from "../../Common/hooks/useAppHistory";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import CareIcon from "../../CAREUI/icons/CareIcon";
+import { ConsultationModel } from "./models";
+import { useMemo } from "react";
+import {
+ ActiveConditionVerificationStatuses,
+ ConsultationDiagnosis,
+} from "../Diagnosis/types";
+import PageHeadTitle from "../Common/PageHeadTitle";
+import { useTranslation } from "react-i18next";
+import { PatientModel } from "../Patient/models";
+import MedicineRoutes from "../Medicine/routes";
+
+export interface ITreatmentSummaryProps {
+ consultationId: string;
+ patientId: string;
+ facilityId: string;
+}
-const TreatmentSummary = (props: any) => {
- const { consultationId, patientId } = props;
+export default function TreatmentSummary({
+ consultationId,
+ patientId,
+ facilityId,
+}: ITreatmentSummaryProps) {
+ const { t } = useTranslation();
const date = new Date();
- const facilityId = useSlug("facility");
const { goBack } = useAppHistory();
const url = `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`;
@@ -22,11 +40,6 @@ const TreatmentSummary = (props: any) => {
prefetch: patientId !== undefined,
});
- const { data: investigations } = useQuery(routes.getInvestigation, {
- pathParams: { consultation_external_id: consultationId },
- prefetch: consultationId !== undefined,
- });
-
const { data: consultationData } = useQuery(routes.getConsultation, {
pathParams: { id: consultationId },
prefetch: consultationId !== undefined,
@@ -34,16 +47,19 @@ const TreatmentSummary = (props: any) => {
return (
+
@@ -52,290 +68,463 @@ const TreatmentSummary = (props: any) => {
{consultationData?.facility_name ?? ""}
-
INTERIM TREATMENT SUMMARY
+
+ {t("treatment_summary__heading")}
+
{formatDate(date)}
-
-
-
- Name : {patientData?.name ?? ""}
-
-
- Address : {patientData?.address ?? ""}
-
-
-
-
-
-
- Age :{" "}
- {patientData ? formatPatientAge(patientData, true) : ""}
-
-
- OP : {consultationData?.patient_no ?? ""}
-
-
+
+
-
- {consultationData?.suggestion === "DC" ? (
- Date of domiciliary care commenced :
- ) : (
- Date of admission :
- )}
-
- {consultationData?.encounter_date
- ? formatDateTime(consultationData.encounter_date)
- : " --/--/----"}
-
-
-
+
-
-
- Gender :
- {GENDER_TYPES.find((i) => i.id === patientData?.gender)?.text}
-
+
-
- Contact person :
-
- {" "}
- {patientData?.emergency_phone_number
- ? patientData.emergency_phone_number
- : " -"}
-
-
-
-
-
-
Comorbidities :
-
-
-
-
- Disease |
- Details |
-
-
-
- {patientData?.medical_history &&
- patientData.medical_history.length > 0 ? (
- patientData.medical_history.map(
- (obj: any, index: number) => {
- return (
-
-
- {obj["disease"]}
- |
-
- {obj["details"] ? obj["details"] : "---"}
- |
-
- );
- },
- )
- ) : (
-
-
- ---
- |
-
- ---
- |
-
- )}
-
-
-
-
-
-
-
Diagnosis :
-
-
- History of present illness :
- {consultationData?.history_of_present_illness
- ? consultationData.history_of_present_illness
- : " ---"}
-
-
-
- Examination details and clinical conditions :
- {consultationData?.examination_details
- ? consultationData.examination_details
- : " ---"}
-
-
-
- Physical Examination info :
- {consultationData?.last_daily_round?.physical_examination_info
- ? consultationData.last_daily_round
- ?.physical_examination_info
- : " ---"}
-
-
-
-
-
-
General Instructions :
- {patientData?.last_consultation?.consultation_notes ? (
-
- {patientData.last_consultation.consultation_notes}
-
- ) : (
- " ---"
- )}
-
-
-
-
Relevant investigations :
-
-
-
-
-
-
- Date
- |
-
- Name
- |
-
- Result
- |
-
- Ideal value
- |
-
- values range
- |
-
- unit
- |
-
-
-
-
- {investigations && investigations.results.length > 0 ? (
- investigations.results.map(
- (value: any, index: number) => {
- return (
-
-
- {formatDate(
- value["session_object"][
- "session_created_date"
- ],
- )}
- |
-
- {value["investigation_object"]["name"]}
- |
-
- {value["notes"] || value["value"]}
- |
-
- {value["investigation_object"]["ideal_value"] ||
- "-"}
- |
-
- {value["investigation_object"]["min_value"]} -{" "}
- {value["investigation_object"]["max_value"]}
- |
-
- {value["investigation_object"]["unit"] || "-"}
- |
-
- );
- },
- )
- ) : (
-
-
- ---
- |
-
- ---
- |
-
- ---
- |
-
- ---
- |
-
- ---
- |
-
- ---
- |
-
- )}
-
-
-
-
-
-
-
Treatment :
- {consultationData?.treatment_plan ? (
-
{consultationData.treatment_plan}
- ) : (
-
---
- )}
-
Treatment summary/Treament Plan :
-
-
-
-
-
- Date |
- Spo2 |
-
- Temperature
- |
-
-
-
-
- {consultationData?.last_daily_round ? (
-
-
- {formatDateTime(
- consultationData.last_daily_round.modified_date,
- )}
- |
-
- {consultationData.last_daily_round.ventilator_spo2 ||
- "-"}
- |
-
- {consultationData.last_daily_round.temperature || "-"}
- |
-
- ) : (
-
-
- ---
- |
-
- ---
- |
-
- ---
- |
-
- )}
-
-
-
-
+
+
+
+
+
+
+
);
-};
+}
+
+interface IBasicDetailsSection {
+ patientData?: PatientModel;
+ consultationData?: ConsultationModel;
+}
+
+function BasicDetailsSection({
+ patientData,
+ consultationData,
+}: IBasicDetailsSection) {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+
+ {t("patient_registration__name")} : {patientData?.name ?? ""}
+
+
+ {t("patient_registration__address")} :{" "}
+ {patientData?.address ?? ""}
+
+
+
+
+
+
+ {t("patient_registration__age")} :{" "}
+ {patientData ? formatPatientAge(patientData, true) : ""}
+
+
+
+ {consultationData?.suggestion === "A"
+ ? t("patient_consultation__ip")
+ : t("patient_consultation__op")}{" "}
+ :
+ {" "}
+ {consultationData?.patient_no ?? ""}
+
+
+
+
+ {consultationData?.suggestion === "DC" ? (
+ {t("patient_consultation__dc_admission")} :
+ ) : (
+ {t("patient_consultation__admission")} :
+ )}{" "}
+
+ {consultationData?.encounter_date
+ ? formatDateTime(consultationData.encounter_date)
+ : t("empty_date_time")}
+
+
+
+
+
+
+ {t("patient_registration__gender")} :{" "}
+ {GENDER_TYPES.find((i) => i.id === patientData?.gender)?.text}
+
+
+
+ {t("patient_registration__contact")} :{" "}
+ {patientData?.emergency_phone_number ?? ""}
+
+
+ >
+ );
+}
+
+interface IComorbiditiesSection {
+ patientData?: PatientModel;
+}
+
+function ComorbiditiesSection({ patientData }: IComorbiditiesSection) {
+ const { t } = useTranslation();
+
+ return patientData?.medical_history?.filter(
+ (comorbidities) => comorbidities.disease !== "NO",
+ ).length ? (
+
+
{t("patient_registration__comorbidities")}
+
+
+
+
+
+ {t("patient_registration__comorbidities__disease")}
+ |
+
+ {t("patient_registration__comorbidities__details")}
+ |
+
+
+
+ {patientData.medical_history.map((obj, index) => {
+ return (
+
+
+ {obj["disease"]}
+ |
+
+ {obj["details"] || "---"}
+ |
+
+ );
+ })}
+
+
+
+
+ ) : null;
+}
+
+interface IDiagnosisSection {
+ consultationData?: ConsultationModel;
+}
+
+type DiagnosisType =
+ | (typeof ActiveConditionVerificationStatuses)[number]
+ | "principal";
+
+function DiagnosisSection({ consultationData }: IDiagnosisSection) {
+ const { t } = useTranslation();
+
+ const diagnoses = useMemo(() => {
+ return consultationData?.diagnoses?.reduce(
+ (acc, curr) => {
+ if (curr.is_principal) {
+ acc.principal.push(curr);
+ } else if (
+ ActiveConditionVerificationStatuses.includes(
+ curr.verification_status as (typeof ActiveConditionVerificationStatuses)[number],
+ )
+ ) {
+ acc[curr.verification_status as keyof typeof acc].push(curr);
+ }
+
+ return acc;
+ },
+ {
+ principal: [],
+ confirmed: [],
+ provisional: [],
+ unconfirmed: [],
+ differential: [],
+ } as Record,
+ );
+ }, [consultationData?.diagnoses]);
+
+ if (!diagnoses) {
+ return null;
+ }
+
+ return (
+
+
{t("diagnosis")}
+
+ {(
+ [
+ "principal",
+ "confirmed",
+ "provisional",
+ "unconfirmed",
+ "differential",
+ ] as DiagnosisType[]
+ ).map(
+ (type) =>
+ !!diagnoses[type].length && (
+
+
+ {t(`diagnosis__${type}`)} {t("diagnosis")}
+
+
+ {diagnoses[type].map((d) => (
+ -
+ {d.diagnosis_object.label}
+ {d.is_principal && (
+
+ {t(`diagnosis__${d.verification_status}`)}
+
+ )}
+
+ ))}
+
+
+ ),
+ )}
+
+
+ );
+}
+
+interface IInvestigationsSection {
+ consultationId: string;
+}
+
+function InvestigationsSection({ consultationId }: IInvestigationsSection) {
+ const { t } = useTranslation();
+
+ const { data: investigations } = useQuery(routes.getInvestigation, {
+ pathParams: { consultation_external_id: consultationId },
+ prefetch: consultationId !== undefined,
+ });
+
+ return investigations?.results.length ? (
+
+
{t("suggested_investigations")}
+
+
+
+
+
+
+ {t("investigations__date")}
+ |
+
+ {t("investigations__name")}
+ |
+
+ {t("investigations__result")}
+ |
+
+ {t("investigations__ideal_value")}
+ |
+
+ {t("investigations__range")}
+ |
+
+ {t("investigations__unit")}
+ |
+
+
+
+
+ {investigations?.results.map((value, index) => (
+
+
+ {formatDate(value["session_object"]["session_created_date"])}
+ |
+
+ {value["investigation_object"]["name"]}
+ |
+
+ {value["notes"] || value["value"]}
+ |
+
+ {value["investigation_object"]["ideal_value"] || "-"}
+ |
+
+ {value["investigation_object"]["min_value"]} -{" "}
+ {value["investigation_object"]["max_value"]}
+ |
+
+ {value["investigation_object"]["unit"] || "-"}
+ |
+
+ ))}
+
+
+
+
+ ) : null;
+}
+
+interface ITreatmentSection {
+ consultationData?: ConsultationModel;
+}
+
+function TreatmentSection({ consultationData }: ITreatmentSection) {
+ const { t } = useTranslation();
+
+ const isTreatmentSummaryAvailable = useMemo(() => {
+ return (
+ consultationData?.last_daily_round &&
+ (consultationData.last_daily_round.ventilator_spo2 ||
+ consultationData.last_daily_round.temperature)
+ );
+ }, [consultationData]);
-export default TreatmentSummary;
+ return consultationData?.treatment_plan || isTreatmentSummaryAvailable ? (
+
+ {consultationData?.treatment_plan && (
+ <>
+
{t("patient_consultation__treatment__plan")}
+
{consultationData.treatment_plan}
+ >
+ )}
+
+ {isTreatmentSummaryAvailable && (
+ <>
+
+ {t("patient_consultation__treatment__summary")}
+
+
+
+
+
+
+ {t("patient_consultation__treatment__summary__date")}
+ |
+
+ {t("patient_consultation__treatment__summary__spo2")}
+ |
+
+ {t("patient_consultation__treatment__summary__temperature")}
+ |
+
+
+
+
+
+
+ {formatDateTime(
+ consultationData?.last_daily_round?.modified_date,
+ )}
+ |
+
+ {consultationData?.last_daily_round?.ventilator_spo2 || "-"}
+ |
+
+ {consultationData?.last_daily_round?.temperature || "-"}
+ |
+
+
+
+
+ >
+ )}
+
+ ) : null;
+}
+
+interface IPrescriptionsSection {
+ consultationId: string;
+}
+
+function PrescriptionsSection({ consultationId }: IPrescriptionsSection) {
+ const { t } = useTranslation();
+
+ const { data: prescriptions } = useQuery(MedicineRoutes.listPrescriptions, {
+ pathParams: { consultation: consultationId },
+ query: { discontinued: false },
+ });
+
+ return prescriptions?.results.length ? (
+
+
{t("active_prescriptions")}
+
+
+
+
+
+
+ {t("prescriptions__medicine")}
+ |
+
+ {t("prescriptions__route")}
+ |
+
+ {t("prescriptions__dosage_frequency")}
+ |
+
+ {t("prescriptions__start_date")}
+ |
+
+
+
+
+ {prescriptions?.results.map((prescription, index) => (
+
+
+ {prescription.medicine_object?.name ?? "-"}
+ |
+
+ {prescription.route ?? "-"}
+ |
+
+ {prescription.dosage_type !== "TITRATED" ? (
+ {prescription.base_dosage}
+ ) : (
+
+ {prescription.base_dosage} - {prescription.target_dosage}
+
+ )}
+
+
+ {prescription.dosage_type !== "PRN"
+ ? t("PRESCRIPTION_FREQUENCY_" + prescription.frequency)
+ : prescription.indicator}
+
+ |
+
+ {formatDate(prescription.created_date)}
+ |
+
+ ))}
+
+
+
+
+ ) : null;
+}
+
+interface IInstructionsSection {
+ consultationData?: ConsultationModel;
+}
+
+function InstructionsSection({ consultationData }: IInstructionsSection) {
+ const { t } = useTranslation();
+
+ return (
+ <>
+ {consultationData?.consultation_notes && (
+
+
{t("patient_consultation__consultation_notes")}
+
+
{consultationData.consultation_notes}
+
+ )}
+
+ {consultationData?.special_instruction && (
+
+
{t("patient_consultation__special_instruction")}
+
+
{consultationData.special_instruction}
+
+ )}
+ >
+ );
+}
diff --git a/src/Locale/en/Common.json b/src/Locale/en/Common.json
index 8b421d58e8f..88fc42391bc 100644
--- a/src/Locale/en/Common.json
+++ b/src/Locale/en/Common.json
@@ -176,6 +176,7 @@
"ration_card__NO_CARD": "Non-card holder",
"ration_card__BPL": "BPL",
"ration_card__APL": "APL",
+ "empty_date_time": "--:-- --; --/--/----",
"caution": "Caution",
"feed_optimal_experience_for_phones": "For optimal viewing experience, consider rotating your device.",
"feed_optimal_experience_for_apple_phones": "For optimal viewing experience, consider rotating your device. Ensure auto-rotate is enabled in your device settings.",
diff --git a/src/Locale/en/Facility.json b/src/Locale/en/Facility.json
index 16bc6610631..856faca4384 100644
--- a/src/Locale/en/Facility.json
+++ b/src/Locale/en/Facility.json
@@ -55,6 +55,46 @@
"discharged_patients": "Discharged Patients",
"discharged_patients_empty": "No discharged patients present in this facility",
"update_facility_middleware_success": "Facility middleware updated successfully",
+ "treatment_summary__head_title": "Treatment Summary",
+ "treatment_summary__print": "Print Treatment Summary",
+ "treatment_summary__heading": "INTERIM TREATMENT SUMMARY",
+ "patient_registration__name": "Name",
+ "patient_registration__address": "Address",
+ "patient_registration__age": "Age",
+ "patient_consultation__op": "OP",
+ "patient_consultation__ip": "IP",
+ "patient_consultation__dc_admission": "Date of domiciliary care commenced",
+ "patient_consultation__admission": "Date of admission",
+ "patient_registration__gender": "Gender",
+ "patient_registration__contact": "Emergency Contact",
+ "patient_registration__comorbidities": "Comorbidities",
+ "patient_registration__comorbidities__disease": "Disease",
+ "patient_registration__comorbidities__details": "Details",
+ "patient_consultation__consultation_notes": "General Instructions",
+ "patient_consultation__special_instruction": "Special Instructions",
+ "suggested_investigations": "Suggested Investigations",
+ "investigations__date": "Date",
+ "investigations__name": "Name",
+ "investigations__result": "Result",
+ "investigations__ideal_value": "Ideal Value",
+ "investigations__range": "Value Range",
+ "investigations__unit": "Unit",
+ "patient_consultation__treatment__plan": "Plan",
+ "patient_consultation__treatment__summary": "Summary",
+ "patient_consultation__treatment__summary__date": "Date",
+ "patient_consultation__treatment__summary__spo2": "SpO2",
+ "patient_consultation__treatment__summary__temperature": "Temperature",
+ "diagnosis": "Diagnosis",
+ "diagnosis__principal": "Principal",
+ "diagnosis__confirmed": "Confirmed",
+ "diagnosis__provisional": "Provisional",
+ "diagnosis__unconfirmed": "Unconfirmed",
+ "diagnosis__differential": "Differential",
+ "active_prescriptions": "Active Prescriptions",
+ "prescriptions__medicine": "Medicine",
+ "prescriptions__route": "Route",
+ "prescriptions__dosage_frequency": "Dosage & Frequency",
+ "prescriptions__start_date": "Prescribed On",
"select_facility_for_discharged_patients_warning": "Facility needs to be selected to view discharged patients.",
"duplicate_patient_record_confirmation": "Admit the patient record to your facility by adding the year of birth",
"duplicate_patient_record_rejection": "I confirm that the suspect / patient I want to create is not on the list.",
diff --git a/src/Routers/routes/ConsultationRoutes.tsx b/src/Routers/routes/ConsultationRoutes.tsx
index 9209b50e97e..598fd06adc3 100644
--- a/src/Routers/routes/ConsultationRoutes.tsx
+++ b/src/Routers/routes/ConsultationRoutes.tsx
@@ -5,7 +5,9 @@ import ManagePrescriptions from "../../Components/Medicine/ManagePrescriptions";
import { DailyRoundListDetails } from "../../Components/Patient/DailyRoundListDetails";
import { DailyRounds } from "../../Components/Patient/DailyRounds";
import { ConsultationDetails } from "../../Components/Facility/ConsultationDetails";
-import TreatmentSummary from "../../Components/Facility/TreatmentSummary";
+import TreatmentSummary, {
+ ITreatmentSummaryProps,
+} from "../../Components/Facility/TreatmentSummary";
import ConsultationDoctorNotes from "../../Components/Facility/ConsultationDoctorNotes";
import PatientConsentRecords from "../../Components/Patient/PatientConsentRecords";
import CriticalCareEditor from "../../Components/LogUpdate/CriticalCareEditor";
@@ -129,12 +131,11 @@ export default {
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/treatment-summary":
- ({ facilityId, patientId, consultationId }: any) => (
+ ({ facilityId, patientId, consultationId }: ITreatmentSummaryProps) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/notes":