From aba7685c8ba4b35967ba892e0a6c1036e9ed6259 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Thu, 11 Apr 2024 15:45:13 +0530 Subject: [PATCH 01/11] Add Medicine Summary Section --- .../ConsultationMedicineLogs/index.tsx | 125 ++++++++++++++++++ .../ConsultationMedicinesTab.tsx | 72 ++++++++++ src/Routers/routes/ConsultationRoutes.tsx | 10 ++ 3 files changed, 207 insertions(+) create mode 100644 src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx diff --git a/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx b/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx new file mode 100644 index 00000000000..8c132f3d914 --- /dev/null +++ b/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx @@ -0,0 +1,125 @@ +import { lazy } from "react"; +import { useTranslation } from "react-i18next"; +import routes from "../../../../Redux/api"; +import useQuery from "../../../../Utils/request/useQuery"; +import PageTitle from "../../../Common/PageTitle"; +import MedicineRoutes from "../../../Medicine/routes"; +import { formatDateTime } from "../../../../Utils/utils"; + +const Loading = lazy(() => import("../../../Common/Loading")); + +export default function ConsultationMedicineLogs(props: any) { + const { t } = useTranslation(); + const { consultationId, patientId, facilityId, medicineId } = props; + + const { data, loading } = useQuery(MedicineRoutes.listPrescriptions, { + pathParams: { consultation: consultationId }, + query: { + medicine: medicineId, + }, + }); + + const { data: patientData, loading: patientLoading } = useQuery( + routes.getPatient, + { + pathParams: { id: patientId }, + } + ); + + const medicineName = data?.results[0]?.medicine_object?.name; + + if (patientLoading || loading) { + return ; + } + + return ( +
+ +
+ +
+
+ ); +} + +const MedicineLogsTable = (prescriptionList: any) => { + return ( +
+ + + + {[ + "Discontinued", + "Frequency", + "Base Dosage", + "Max Dosage", + "Prescription Type", + "Prescribed By", + "Date", + ].map((heading) => ( + + ))} + + + + {prescriptionList?.prescriptionList?.length > 0 ? ( + prescriptionList?.prescriptionList + ?.reverse() + .map((t: any, i: any) => { + return ; + }) + ) : ( + + No prescriptions found + + )} + +
+ {heading} +
+
+ ); +}; + +const PrescriptionRow = ({ data, i }: any) => { + return ( + + + {data?.discontinued ? "Yes" : "No"} + + + {data?.frequency} + + + {data?.base_dosage} + + + {data?.max_dosage} + + + {data?.prescription_type} + + + {data?.prescribed_by?.first_name} {data?.prescribed_by?.last_name} + + + {formatDateTime(data?.created_date)} + + + ); +}; diff --git a/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx index e1e72c2f936..fbfcab180bb 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx @@ -1,8 +1,17 @@ import { ConsultationTabProps } from "./index"; import PageTitle from "../../Common/PageHeadTitle"; import MedicineAdministrationSheet from "../../Medicine/MedicineAdministrationSheet"; +import MedicineRoutes from "../../Medicine/routes"; +import { navigate } from "raviger"; +import useQuery from "../../../Utils/request/useQuery"; +import useSlug from "../../../Common/hooks/useSlug"; +import { MedibaseMedicine } from "../../Medicine/models"; export const ConsultationMedicinesTab = (props: ConsultationTabProps) => { + const facility = useSlug("facility"); + const patient = useSlug("patient"); + const consultation = useSlug("consultation"); + return (
{/* eslint-disable-next-line i18next/no-literal-string */} @@ -15,6 +24,69 @@ export const ConsultationMedicinesTab = (props: ConsultationTabProps) => { is_prn={true} readonly={!!props.consultationData.discharge_date} /> + +
+ ); +}; + +const MedicinePrescriptionSummary = ({ + facility, + patient, + consultation, +}: any) => { + const { data } = useQuery(MedicineRoutes.listPrescriptions, { + pathParams: { consultation }, + query: { limit: 100 }, + }); + + function extractUniqueMedicineObjects(prescriptions: any): any[] { + const uniqueMedicineObjects: Set = new Set(); + const uniqueMedicines: MedibaseMedicine[] = []; + + prescriptions.forEach((prescription: any) => { + const { medicine_object } = prescription; + const medicineId = medicine_object.id; + + if (!uniqueMedicineObjects.has(medicineId)) { + uniqueMedicineObjects.add(medicineId); + uniqueMedicines.push(medicine_object); + } + }); + + return uniqueMedicines; + } + + const medicinesList = extractUniqueMedicineObjects(data?.results ?? []); + + return ( +
+

Summary

+
+ {medicinesList && + medicinesList.length > 0 && + medicinesList?.map((med: any) => ( +
+
{med.name}
+ +
+ ))} +
); }; diff --git a/src/Routers/routes/ConsultationRoutes.tsx b/src/Routers/routes/ConsultationRoutes.tsx index 6dc5fa9c05d..ee5be497506 100644 --- a/src/Routers/routes/ConsultationRoutes.tsx +++ b/src/Routers/routes/ConsultationRoutes.tsx @@ -9,6 +9,7 @@ import { make as CriticalCareRecording } from "../../Components/CriticalCareReco import { ConsultationDetails } from "../../Components/Facility/ConsultationDetails"; import TreatmentSummary from "../../Components/Facility/TreatmentSummary"; import ConsultationDoctorNotes from "../../Components/Facility/ConsultationDoctorNotes"; +import ConsultationMedicineLogs from "../../Components/Facility/ConsultationDetails/ConsultationMedicineLogs"; export default { "/facility/:facilityId/patient/:patientId/consultation": ({ @@ -59,6 +60,15 @@ export default { sessionId={sessionId} /> ), + "/facility/:facilityId/patient/:patientId/consultation/:id/medicine/:medicineId": + ({ facilityId, patientId, id, medicineId }: any) => ( + + ), "/facility/:facilityId/patient/:patientId/consultation/:id/daily-rounds": ({ facilityId, patientId, From 2f5948762f541c30f63e7f8a14903a30fc61afe6 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Sun, 14 Apr 2024 23:09:11 +0530 Subject: [PATCH 02/11] add timeline view and show only changes --- .../ConsultationMedicineLogs/index.tsx | 197 ++++++++++++++++++ 1 file changed, 197 insertions(+) diff --git a/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx b/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx index 8c132f3d914..789c62a9d6c 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx @@ -5,6 +5,8 @@ import useQuery from "../../../../Utils/request/useQuery"; import PageTitle from "../../../Common/PageTitle"; import MedicineRoutes from "../../../Medicine/routes"; import { formatDateTime } from "../../../../Utils/utils"; +import Timeline, { TimelineNode } from "../../../../CAREUI/display/Timeline"; +import { Prescription } from "../../../Medicine/models"; const Loading = lazy(() => import("../../../Common/Loading")); @@ -32,6 +34,180 @@ export default function ConsultationMedicineLogs(props: any) { return ; } + const calculateChanges = (prescriptions: Prescription[]) => { + const changes = []; + + // first prescription + const message = `Details: Base Dosage: ${ + prescriptions[0].base_dosage ?? "Not specified" + }, Route: ${prescriptions[0].route ?? "Not specified"}, Dosage Type: ${ + prescriptions[0].dosage_type ?? "Not specified" + }, Target Dosage: ${ + prescriptions[0].target_dosage ?? "Not specified" + }, Instruction on Titration: ${ + prescriptions[0].instruction_on_titration ?? "Not specified" + }, Frequency: ${prescriptions[0].frequency ?? "Not specified"}, Days: ${ + prescriptions[0].days ?? "Not specified" + }, Indicator: ${ + prescriptions[0].indicator ?? "Not specified" + }, Max Dosage: ${ + prescriptions[0].max_dosage ?? "Not specified" + }, Min Hours Between Doses: ${ + prescriptions[0].min_hours_between_doses ?? "Not specified" + }`; + changes.push({ + prescriptionId: prescriptions[0].id, + changeMessage: message, + prescribed_by: prescriptions[0].prescribed_by, + created_date: prescriptions[0].created_date, + }); + + for (let i = 1; i < prescriptions.length; i++) { + const prevPrescription = prescriptions[i - 1]; + const currentPrescription = prescriptions[i]; + + const changesForPrescription: string[] = []; + + // Check for changes in base dosage + if (prevPrescription.base_dosage !== currentPrescription.base_dosage) { + changesForPrescription.push( + `Base dosage changed to ${currentPrescription.base_dosage} mg from ${prevPrescription.base_dosage} mg` + ); + } + + // Check for changes in route + if (prevPrescription.route !== currentPrescription.route) { + changesForPrescription.push( + `Route changed to ${ + currentPrescription.route ?? "Not specified" + } from ${prevPrescription.route ?? "Not specified"}` + ); + } + + // Check for changes in dosage type + if (prevPrescription.dosage_type !== currentPrescription.dosage_type) { + changesForPrescription.push( + `Dosage type changed to ${ + currentPrescription.dosage_type ?? "Not specified" + } from ${prevPrescription.dosage_type ?? "Not specified"}` + ); + } + + // Check for changes in target dosage + if ( + prevPrescription.target_dosage !== currentPrescription.target_dosage + ) { + changesForPrescription.push( + `Target dosage changed to ${ + currentPrescription.target_dosage ?? "Not specified" + } from ${prevPrescription.target_dosage ?? "Not specified"}` + ); + } + + // Check for changes in instruction on titration + if ( + prevPrescription.instruction_on_titration !== + currentPrescription.instruction_on_titration + ) { + changesForPrescription.push( + `Instruction on titration changed to ${ + currentPrescription.instruction_on_titration ?? "Not specified" + } from ${ + prevPrescription.instruction_on_titration ?? "Not specified" + }` + ); + } + + // Check for changes in frequency + if (prevPrescription.frequency !== currentPrescription.frequency) { + changesForPrescription.push( + `Frequency changed to ${ + currentPrescription.frequency ?? "Not specified" + } from ${prevPrescription.frequency ?? "Not specified"}` + ); + } + + // Check for changes in days + if (prevPrescription.days !== currentPrescription.days) { + changesForPrescription.push( + `Days changed to ${ + currentPrescription.days ?? "Not specified" + } from ${prevPrescription.days ?? "Not specified"}` + ); + } + + // Check for changes in indicator + if (prevPrescription.indicator !== currentPrescription.indicator) { + changesForPrescription.push( + `Indicator changed to ${ + currentPrescription.indicator ?? "Not specified" + } from ${prevPrescription.indicator ?? "Not specified"}` + ); + } + + // Check for changes in max dosage + if (prevPrescription.max_dosage !== currentPrescription.max_dosage) { + changesForPrescription.push( + `Max dosage changed to ${ + currentPrescription.max_dosage ?? "Not specified" + } from ${prevPrescription.max_dosage ?? "Not specified"}` + ); + } + + // Check for changes in min hours between doses + if ( + prevPrescription.min_hours_between_doses !== + currentPrescription.min_hours_between_doses + ) { + changesForPrescription.push( + `Min hours between doses changed to ${ + currentPrescription.min_hours_between_doses ?? "Not specified" + } from ${prevPrescription.min_hours_between_doses ?? "Not specified"}` + ); + } + + // If there are changes, add them to the changes array + if (changesForPrescription.length > 0) { + const message = `Changes: ${changesForPrescription.join(", ")}`; + changes.push({ + prescriptionId: currentPrescription.id, + changeMessage: message, + prescribed_by: currentPrescription.prescribed_by, + created_date: currentPrescription.created_date, + }); + } else { + // If no changes, just list out the details of the prescription + const message = `Details: Base Dosage: ${ + currentPrescription.base_dosage ?? "Not specified" + }, Route: ${ + currentPrescription.route ?? "Not specified" + }, Dosage Type: ${ + currentPrescription.dosage_type ?? "Not specified" + }, Target Dosage: ${ + currentPrescription.target_dosage ?? "Not specified" + }, Instruction on Titration: ${ + currentPrescription.instruction_on_titration ?? "Not specified" + }, Frequency: ${ + currentPrescription.frequency ?? "Not specified" + }, Days: ${currentPrescription.days ?? "Not specified"}, Indicator: ${ + currentPrescription.indicator ?? "Not specified" + }, Max Dosage: ${ + currentPrescription.max_dosage ?? "Not specified" + }, Min Hours Between Doses: ${ + currentPrescription.min_hours_between_doses ?? "Not specified" + }`; + changes.push({ + prescriptionId: currentPrescription.id, + changeMessage: message, + prescribed_by: currentPrescription.prescribed_by, + created_date: currentPrescription.created_date, + }); + } + } + + return changes.reverse(); + }; + return (
+ + {data?.results && + calculateChanges(data?.results).map((changes, index) => ( + +

{changes?.changeMessage}

+
+ ))} +
+
+
From 3f19d1e534d3648e76014330b9e0c851557e45d4 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Wed, 17 Apr 2024 20:29:59 +0530 Subject: [PATCH 03/11] switch to modal and use timeline view --- .../ConsultationMedicineLogs/index.tsx | 322 ------------------ .../ConsultationMedicinesTab.tsx | 266 ++++++++++++++- src/Routers/routes/ConsultationRoutes.tsx | 10 - 3 files changed, 250 insertions(+), 348 deletions(-) delete mode 100644 src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx diff --git a/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx b/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx deleted file mode 100644 index 789c62a9d6c..00000000000 --- a/src/Components/Facility/ConsultationDetails/ConsultationMedicineLogs/index.tsx +++ /dev/null @@ -1,322 +0,0 @@ -import { lazy } from "react"; -import { useTranslation } from "react-i18next"; -import routes from "../../../../Redux/api"; -import useQuery from "../../../../Utils/request/useQuery"; -import PageTitle from "../../../Common/PageTitle"; -import MedicineRoutes from "../../../Medicine/routes"; -import { formatDateTime } from "../../../../Utils/utils"; -import Timeline, { TimelineNode } from "../../../../CAREUI/display/Timeline"; -import { Prescription } from "../../../Medicine/models"; - -const Loading = lazy(() => import("../../../Common/Loading")); - -export default function ConsultationMedicineLogs(props: any) { - const { t } = useTranslation(); - const { consultationId, patientId, facilityId, medicineId } = props; - - const { data, loading } = useQuery(MedicineRoutes.listPrescriptions, { - pathParams: { consultation: consultationId }, - query: { - medicine: medicineId, - }, - }); - - const { data: patientData, loading: patientLoading } = useQuery( - routes.getPatient, - { - pathParams: { id: patientId }, - } - ); - - const medicineName = data?.results[0]?.medicine_object?.name; - - if (patientLoading || loading) { - return ; - } - - const calculateChanges = (prescriptions: Prescription[]) => { - const changes = []; - - // first prescription - const message = `Details: Base Dosage: ${ - prescriptions[0].base_dosage ?? "Not specified" - }, Route: ${prescriptions[0].route ?? "Not specified"}, Dosage Type: ${ - prescriptions[0].dosage_type ?? "Not specified" - }, Target Dosage: ${ - prescriptions[0].target_dosage ?? "Not specified" - }, Instruction on Titration: ${ - prescriptions[0].instruction_on_titration ?? "Not specified" - }, Frequency: ${prescriptions[0].frequency ?? "Not specified"}, Days: ${ - prescriptions[0].days ?? "Not specified" - }, Indicator: ${ - prescriptions[0].indicator ?? "Not specified" - }, Max Dosage: ${ - prescriptions[0].max_dosage ?? "Not specified" - }, Min Hours Between Doses: ${ - prescriptions[0].min_hours_between_doses ?? "Not specified" - }`; - changes.push({ - prescriptionId: prescriptions[0].id, - changeMessage: message, - prescribed_by: prescriptions[0].prescribed_by, - created_date: prescriptions[0].created_date, - }); - - for (let i = 1; i < prescriptions.length; i++) { - const prevPrescription = prescriptions[i - 1]; - const currentPrescription = prescriptions[i]; - - const changesForPrescription: string[] = []; - - // Check for changes in base dosage - if (prevPrescription.base_dosage !== currentPrescription.base_dosage) { - changesForPrescription.push( - `Base dosage changed to ${currentPrescription.base_dosage} mg from ${prevPrescription.base_dosage} mg` - ); - } - - // Check for changes in route - if (prevPrescription.route !== currentPrescription.route) { - changesForPrescription.push( - `Route changed to ${ - currentPrescription.route ?? "Not specified" - } from ${prevPrescription.route ?? "Not specified"}` - ); - } - - // Check for changes in dosage type - if (prevPrescription.dosage_type !== currentPrescription.dosage_type) { - changesForPrescription.push( - `Dosage type changed to ${ - currentPrescription.dosage_type ?? "Not specified" - } from ${prevPrescription.dosage_type ?? "Not specified"}` - ); - } - - // Check for changes in target dosage - if ( - prevPrescription.target_dosage !== currentPrescription.target_dosage - ) { - changesForPrescription.push( - `Target dosage changed to ${ - currentPrescription.target_dosage ?? "Not specified" - } from ${prevPrescription.target_dosage ?? "Not specified"}` - ); - } - - // Check for changes in instruction on titration - if ( - prevPrescription.instruction_on_titration !== - currentPrescription.instruction_on_titration - ) { - changesForPrescription.push( - `Instruction on titration changed to ${ - currentPrescription.instruction_on_titration ?? "Not specified" - } from ${ - prevPrescription.instruction_on_titration ?? "Not specified" - }` - ); - } - - // Check for changes in frequency - if (prevPrescription.frequency !== currentPrescription.frequency) { - changesForPrescription.push( - `Frequency changed to ${ - currentPrescription.frequency ?? "Not specified" - } from ${prevPrescription.frequency ?? "Not specified"}` - ); - } - - // Check for changes in days - if (prevPrescription.days !== currentPrescription.days) { - changesForPrescription.push( - `Days changed to ${ - currentPrescription.days ?? "Not specified" - } from ${prevPrescription.days ?? "Not specified"}` - ); - } - - // Check for changes in indicator - if (prevPrescription.indicator !== currentPrescription.indicator) { - changesForPrescription.push( - `Indicator changed to ${ - currentPrescription.indicator ?? "Not specified" - } from ${prevPrescription.indicator ?? "Not specified"}` - ); - } - - // Check for changes in max dosage - if (prevPrescription.max_dosage !== currentPrescription.max_dosage) { - changesForPrescription.push( - `Max dosage changed to ${ - currentPrescription.max_dosage ?? "Not specified" - } from ${prevPrescription.max_dosage ?? "Not specified"}` - ); - } - - // Check for changes in min hours between doses - if ( - prevPrescription.min_hours_between_doses !== - currentPrescription.min_hours_between_doses - ) { - changesForPrescription.push( - `Min hours between doses changed to ${ - currentPrescription.min_hours_between_doses ?? "Not specified" - } from ${prevPrescription.min_hours_between_doses ?? "Not specified"}` - ); - } - - // If there are changes, add them to the changes array - if (changesForPrescription.length > 0) { - const message = `Changes: ${changesForPrescription.join(", ")}`; - changes.push({ - prescriptionId: currentPrescription.id, - changeMessage: message, - prescribed_by: currentPrescription.prescribed_by, - created_date: currentPrescription.created_date, - }); - } else { - // If no changes, just list out the details of the prescription - const message = `Details: Base Dosage: ${ - currentPrescription.base_dosage ?? "Not specified" - }, Route: ${ - currentPrescription.route ?? "Not specified" - }, Dosage Type: ${ - currentPrescription.dosage_type ?? "Not specified" - }, Target Dosage: ${ - currentPrescription.target_dosage ?? "Not specified" - }, Instruction on Titration: ${ - currentPrescription.instruction_on_titration ?? "Not specified" - }, Frequency: ${ - currentPrescription.frequency ?? "Not specified" - }, Days: ${currentPrescription.days ?? "Not specified"}, Indicator: ${ - currentPrescription.indicator ?? "Not specified" - }, Max Dosage: ${ - currentPrescription.max_dosage ?? "Not specified" - }, Min Hours Between Doses: ${ - currentPrescription.min_hours_between_doses ?? "Not specified" - }`; - changes.push({ - prescriptionId: currentPrescription.id, - changeMessage: message, - prescribed_by: currentPrescription.prescribed_by, - created_date: currentPrescription.created_date, - }); - } - } - - return changes.reverse(); - }; - - return ( -
- -
- - {data?.results && - calculateChanges(data?.results).map((changes, index) => ( - -

{changes?.changeMessage}

-
- ))} -
-
-
- -
-
- ); -} - -const MedicineLogsTable = (prescriptionList: any) => { - return ( -
- - - - {[ - "Discontinued", - "Frequency", - "Base Dosage", - "Max Dosage", - "Prescription Type", - "Prescribed By", - "Date", - ].map((heading) => ( - - ))} - - - - {prescriptionList?.prescriptionList?.length > 0 ? ( - prescriptionList?.prescriptionList - ?.reverse() - .map((t: any, i: any) => { - return ; - }) - ) : ( - - No prescriptions found - - )} - -
- {heading} -
-
- ); -}; - -const PrescriptionRow = ({ data, i }: any) => { - return ( - - - {data?.discontinued ? "Yes" : "No"} - - - {data?.frequency} - - - {data?.base_dosage} - - - {data?.max_dosage} - - - {data?.prescription_type} - - - {data?.prescribed_by?.first_name} {data?.prescribed_by?.last_name} - - - {formatDateTime(data?.created_date)} - - - ); -}; diff --git a/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx index fbfcab180bb..6a7e8023342 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationMedicinesTab.tsx @@ -2,14 +2,18 @@ import { ConsultationTabProps } from "./index"; import PageTitle from "../../Common/PageHeadTitle"; import MedicineAdministrationSheet from "../../Medicine/MedicineAdministrationSheet"; import MedicineRoutes from "../../Medicine/routes"; -import { navigate } from "raviger"; import useQuery from "../../../Utils/request/useQuery"; import useSlug from "../../../Common/hooks/useSlug"; import { MedibaseMedicine } from "../../Medicine/models"; +import DialogModal from "../../Common/Dialog"; +import { useState } from "react"; +import { lazy } from "react"; +import Timeline, { TimelineNode } from "../../../CAREUI/display/Timeline"; +import { Prescription } from "../../Medicine/models"; + +const Loading = lazy(() => import("../../Common/Loading")); export const ConsultationMedicinesTab = (props: ConsultationTabProps) => { - const facility = useSlug("facility"); - const patient = useSlug("patient"); const consultation = useSlug("consultation"); return ( @@ -24,25 +28,26 @@ export const ConsultationMedicinesTab = (props: ConsultationTabProps) => { is_prn={true} readonly={!!props.consultationData.discharge_date} /> - + ); }; -const MedicinePrescriptionSummary = ({ - facility, - patient, - consultation, -}: any) => { +const MedicinePrescriptionSummary = ({ consultation }: any) => { + const [showMedicineModal, setShowMedicineModal] = useState({ + open: false, + name: "", + medicineId: "", + }); const { data } = useQuery(MedicineRoutes.listPrescriptions, { pathParams: { consultation }, query: { limit: 100 }, }); + const closeMedicineModal = () => { + setShowMedicineModal({ ...showMedicineModal, open: false }); + }; + function extractUniqueMedicineObjects(prescriptions: any): any[] { const uniqueMedicineObjects: Set = new Set(); const uniqueMedicines: MedibaseMedicine[] = []; @@ -76,9 +81,11 @@ const MedicinePrescriptionSummary = ({
{med.name}
- - ))} - - - {showMedicineModal.name} Prescription Logs

} - show={showMedicineModal.open} - onClose={closeMedicineModal} - fixedWidth={false} - className="md:w-3/4" - > - -
+ ); }; - -export default function ConsultationMedicineLogs(props: any) { - const { consultationId, medicineId } = props; - - const { data, loading } = useQuery(MedicineRoutes.listPrescriptions, { - pathParams: { consultation: consultationId }, - query: { - medicine: medicineId, - }, - }); - - if (loading) { - return ; - } - - const calculateChanges = (prescriptions: Prescription[]) => { - const changes = []; - - const message = `Details: ${ - prescriptions[0].base_dosage != null - ? `Base Dosage: ${prescriptions[0].base_dosage} mg, ` - : "" - }${ - prescriptions[0].route != null ? `Route: ${prescriptions[0].route}, ` : "" - }${ - prescriptions[0].dosage_type != null - ? `Dosage Type: ${prescriptions[0].dosage_type}, ` - : "" - }${ - prescriptions[0].target_dosage != null - ? `Target Dosage: ${prescriptions[0].target_dosage} mg, ` - : "" - }${ - prescriptions[0].instruction_on_titration != null - ? `Instruction on Titration: ${prescriptions[0].instruction_on_titration}, ` - : "" - }${ - prescriptions[0].frequency != null - ? `Frequency: ${prescriptions[0].frequency}, ` - : "" - }${ - prescriptions[0].days != null ? `Days: ${prescriptions[0].days}, ` : "" - }${ - prescriptions[0].indicator != null - ? `Indicator: ${prescriptions[0].indicator}, ` - : "" - }${ - prescriptions[0].max_dosage != null - ? `Max Dosage: ${prescriptions[0].max_dosage} mg, ` - : "" - }${ - prescriptions[0].min_hours_between_doses != null - ? `Min Hours Between Doses: ${prescriptions[0].min_hours_between_doses}, ` - : "" - }`.replace(/, $/, ""); // Remove trailing comma and space if any - - changes.push({ - prescriptionId: prescriptions[0].id, - changeMessage: message, - prescribed_by: prescriptions[0].prescribed_by, - created_date: prescriptions[0].created_date, - }); - - for (let i = 1; i < prescriptions.length; i++) { - const prevPrescription = prescriptions[i - 1]; - const currentPrescription = prescriptions[i]; - - const changesForPrescription: string[] = []; - - // Check for changes in base dosage - if (prevPrescription.base_dosage !== currentPrescription.base_dosage) { - changesForPrescription.push( - `Base dosage changed to ${currentPrescription.base_dosage} mg from ${prevPrescription.base_dosage} mg`, - ); - } - - // Check for changes in route - if (prevPrescription.route !== currentPrescription.route) { - changesForPrescription.push( - `Route changed to ${ - currentPrescription.route ?? "Not specified" - } from ${prevPrescription.route ?? "Not specified"}`, - ); - } - - // Check for changes in dosage type - if (prevPrescription.dosage_type !== currentPrescription.dosage_type) { - changesForPrescription.push( - `Dosage type changed to ${ - currentPrescription.dosage_type ?? "Not specified" - } from ${prevPrescription.dosage_type ?? "Not specified"}`, - ); - } - - // Check for changes in target dosage - if ( - prevPrescription.target_dosage !== currentPrescription.target_dosage - ) { - changesForPrescription.push( - `Target dosage changed to ${ - currentPrescription.target_dosage ?? "Not specified" - } from ${prevPrescription.target_dosage ?? "Not specified"}`, - ); - } - - // Check for changes in instruction on titration - if ( - prevPrescription.instruction_on_titration !== - currentPrescription.instruction_on_titration - ) { - changesForPrescription.push( - `Instruction on titration changed to ${ - currentPrescription.instruction_on_titration ?? "Not specified" - } from ${ - prevPrescription.instruction_on_titration ?? "Not specified" - }`, - ); - } - - // Check for changes in frequency - if (prevPrescription.frequency !== currentPrescription.frequency) { - changesForPrescription.push( - `Frequency changed to ${ - currentPrescription.frequency ?? "Not specified" - } from ${prevPrescription.frequency ?? "Not specified"}`, - ); - } - - // Check for changes in days - if (prevPrescription.days !== currentPrescription.days) { - changesForPrescription.push( - `Days changed to ${ - currentPrescription.days ?? "Not specified" - } from ${prevPrescription.days ?? "Not specified"}`, - ); - } - - // Check for changes in indicator - if (prevPrescription.indicator !== currentPrescription.indicator) { - changesForPrescription.push( - `Indicator changed to ${ - currentPrescription.indicator ?? "Not specified" - } from ${prevPrescription.indicator ?? "Not specified"}`, - ); - } - - // Check for changes in max dosage - if (prevPrescription.max_dosage !== currentPrescription.max_dosage) { - changesForPrescription.push( - `Max dosage changed to ${ - currentPrescription.max_dosage ?? "Not specified" - } from ${prevPrescription.max_dosage ?? "Not specified"}`, - ); - } - - // Check for changes in min hours between doses - if ( - prevPrescription.min_hours_between_doses !== - currentPrescription.min_hours_between_doses - ) { - changesForPrescription.push( - `Min hours between doses changed to ${ - currentPrescription.min_hours_between_doses ?? "Not specified" - } from ${prevPrescription.min_hours_between_doses ?? "Not specified"}`, - ); - } - - // If there are changes, add them to the changes array - if (changesForPrescription.length > 0) { - const message = `Changes: ${changesForPrescription.join(", ")}`; - changes.push({ - prescriptionId: currentPrescription.id, - changeMessage: message, - prescribed_by: currentPrescription.prescribed_by, - created_date: currentPrescription.created_date, - }); - } else { - // If no changes, just list out the details of the prescription - const message = `Details: ${ - currentPrescription.base_dosage != null - ? `Base Dosage: ${currentPrescription.base_dosage} mg, ` - : "" - }${ - currentPrescription.route != null - ? `Route: ${currentPrescription.route}, ` - : "" - }${ - currentPrescription.dosage_type != null - ? `Dosage Type: ${currentPrescription.dosage_type}, ` - : "" - }${ - currentPrescription.target_dosage != null - ? `Target Dosage: ${currentPrescription.target_dosage} mg, ` - : "" - }${ - currentPrescription.instruction_on_titration != null - ? `Instruction on Titration: ${currentPrescription.instruction_on_titration}, ` - : "" - }${ - currentPrescription.frequency != null - ? `Frequency: ${currentPrescription.frequency}, ` - : "" - }${ - currentPrescription.days != null - ? `Days: ${currentPrescription.days}, ` - : "" - }${ - currentPrescription.indicator != null - ? `Indicator: ${currentPrescription.indicator}, ` - : "" - }${ - currentPrescription.max_dosage != null - ? `Max Dosage: ${currentPrescription.max_dosage} mg, ` - : "" - }${ - currentPrescription.min_hours_between_doses != null - ? `Min Hours Between Doses: ${currentPrescription.min_hours_between_doses}, ` - : "" - }`.replace(/, $/, ""); // Remove trailing comma and space if any - - changes.push({ - prescriptionId: currentPrescription.id, - changeMessage: message, - prescribed_by: currentPrescription.prescribed_by, - created_date: currentPrescription.created_date, - }); - } - } - - return changes; - }; - - return ( -
- - {data?.results && - calculateChanges(data?.results.reverse()).map((changes, index) => ( - -

{changes?.changeMessage}

-
- ))} -
-
- ); -} diff --git a/src/Components/Medicine/MedicinePrescriptionSummary.tsx b/src/Components/Medicine/MedicinePrescriptionSummary.tsx new file mode 100644 index 00000000000..f0ed17c254d --- /dev/null +++ b/src/Components/Medicine/MedicinePrescriptionSummary.tsx @@ -0,0 +1,329 @@ +import MedicineRoutes from "../Medicine/routes"; +import useQuery from "../../Utils/request/useQuery"; +import DialogModal from "../Common/Dialog"; +import { useState } from "react"; +import { lazy } from "react"; +import Timeline, { TimelineNode } from "../../CAREUI/display/Timeline"; +import { MedibaseMedicine, Prescription } from "../Medicine/models"; +import { useTranslation } from "react-i18next"; + +const Loading = lazy(() => import("../Common/Loading")); + +interface MedicinePrescriptionSummaryProps { + consultation: string; +} + +export const MedicinePrescriptionSummary = ({ + consultation, +}: MedicinePrescriptionSummaryProps) => { + const { t } = useTranslation(); + const [showMedicineModal, setShowMedicineModal] = useState({ + open: false, + name: "", + medicineId: "", + }); + const { data } = useQuery(MedicineRoutes.listPrescriptions, { + pathParams: { consultation }, + query: { limit: 100 }, + }); + + const closeMedicineModal = () => { + setShowMedicineModal({ ...showMedicineModal, open: false }); + }; + + function extractUniqueMedicineObjects( + prescriptions: Prescription[], + ): MedibaseMedicine[] { + const uniqueMedicineObjects: Set = new Set(); + const uniqueMedicines: MedibaseMedicine[] = []; + + prescriptions.forEach((prescription: Prescription) => { + if (prescription?.medicine_object) { + const medicineId = prescription?.medicine_object.id; + + if (!uniqueMedicineObjects.has(medicineId)) { + uniqueMedicineObjects.add(medicineId); + uniqueMedicines.push(prescription?.medicine_object); + } + } + }); + + return uniqueMedicines; + } + + const medicinesList: MedibaseMedicine[] = extractUniqueMedicineObjects( + data?.results ?? [], + ); + + return ( +
+

{t("summary")}

+
+ {medicinesList && + medicinesList.length > 0 && + medicinesList?.map((med: MedibaseMedicine) => ( +
+
{med.name}
+ +
+ ))} +
+ + + {showMedicineModal.name}: {t("prescription_logs")} +

+ } + show={showMedicineModal.open} + onClose={closeMedicineModal} + fixedWidth={false} + className="md:w-3/4" + > + +
+
+ ); +}; + +interface ConsultationMedicineLogsProps { + consultationId: string; + medicineId: string; +} + +export default function ConsultationMedicineLogs({ + consultationId, + medicineId, +}: ConsultationMedicineLogsProps) { + const { data, loading } = useQuery(MedicineRoutes.listPrescriptions, { + pathParams: { consultation: consultationId }, + query: { + medicine: medicineId, + }, + }); + + if (loading) { + return ; + } + + const getDetailsMessage = (prescription: Prescription) => { + const message = `Details: ${ + prescription.base_dosage != null + ? `Base Dosage: ${prescription.base_dosage} mg, ` + : "" + }${prescription.route != null ? `Route: ${prescription.route}, ` : ""}${ + prescription.dosage_type != null + ? `Dosage Type: ${prescription.dosage_type}, ` + : "" + }${ + prescription.target_dosage != null + ? `Target Dosage: ${prescription.target_dosage} mg, ` + : "" + }${ + prescription.instruction_on_titration != null + ? `Instruction on Titration: ${prescription.instruction_on_titration}, ` + : "" + }${ + prescription.frequency != null + ? `Frequency: ${prescription.frequency}, ` + : "" + }${prescription.days != null ? `Days: ${prescription.days}, ` : ""}${ + prescription.indicator != null + ? `Indicator: ${prescription.indicator}, ` + : "" + }${ + prescription.max_dosage != null + ? `Max Dosage: ${prescription.max_dosage} mg, ` + : "" + }${ + prescription.min_hours_between_doses != null + ? `Min Hours Between Doses: ${prescription.min_hours_between_doses}, ` + : "" + }`.replace(/, $/, ""); + + return message; + }; + + const calculateChanges = (prescriptions: Prescription[]) => { + prescriptions = prescriptions.reverse(); + const changes = []; + + const message = getDetailsMessage(prescriptions[0]); + + changes.push({ + prescriptionId: prescriptions[0].id, + changeMessage: message, + prescribed_by: prescriptions[0].prescribed_by, + created_date: prescriptions[0].created_date, + }); + + for (let i = 1; i < prescriptions.length; i++) { + const prevPrescription = prescriptions[i - 1]; + const currentPrescription = prescriptions[i]; + + const changesForPrescription: string[] = []; + + // Check for changes in base dosage + if (prevPrescription.base_dosage !== currentPrescription.base_dosage) { + changesForPrescription.push( + `Base dosage changed to ${currentPrescription.base_dosage} mg from ${prevPrescription.base_dosage} mg`, + ); + } + + // Check for changes in route + if (prevPrescription.route !== currentPrescription.route) { + changesForPrescription.push( + `Route changed to ${ + currentPrescription.route ?? "Not specified" + } from ${prevPrescription.route ?? "Not specified"}`, + ); + } + + // Check for changes in dosage type + if (prevPrescription.dosage_type !== currentPrescription.dosage_type) { + changesForPrescription.push( + `Dosage type changed to ${ + currentPrescription.dosage_type ?? "Not specified" + } from ${prevPrescription.dosage_type ?? "Not specified"}`, + ); + } + + // Check for changes in target dosage + if ( + prevPrescription.target_dosage !== currentPrescription.target_dosage + ) { + changesForPrescription.push( + `Target dosage changed to ${ + currentPrescription.target_dosage ?? "Not specified" + } from ${prevPrescription.target_dosage ?? "Not specified"}`, + ); + } + + // Check for changes in instruction on titration + if ( + prevPrescription.instruction_on_titration !== + currentPrescription.instruction_on_titration + ) { + changesForPrescription.push( + `Instruction on titration changed to ${ + currentPrescription.instruction_on_titration ?? "Not specified" + } from ${ + prevPrescription.instruction_on_titration ?? "Not specified" + }`, + ); + } + + // Check for changes in frequency + if (prevPrescription.frequency !== currentPrescription.frequency) { + changesForPrescription.push( + `Frequency changed to ${ + currentPrescription.frequency ?? "Not specified" + } from ${prevPrescription.frequency ?? "Not specified"}`, + ); + } + + // Check for changes in days + if (prevPrescription.days !== currentPrescription.days) { + changesForPrescription.push( + `Days changed to ${ + currentPrescription.days ?? "Not specified" + } from ${prevPrescription.days ?? "Not specified"}`, + ); + } + + // Check for changes in indicator + if (prevPrescription.indicator !== currentPrescription.indicator) { + changesForPrescription.push( + `Indicator changed to ${ + currentPrescription.indicator ?? "Not specified" + } from ${prevPrescription.indicator ?? "Not specified"}`, + ); + } + + // Check for changes in max dosage + if (prevPrescription.max_dosage !== currentPrescription.max_dosage) { + changesForPrescription.push( + `Max dosage changed to ${ + currentPrescription.max_dosage ?? "Not specified" + } from ${prevPrescription.max_dosage ?? "Not specified"}`, + ); + } + + // Check for changes in min hours between doses + if ( + prevPrescription.min_hours_between_doses !== + currentPrescription.min_hours_between_doses + ) { + changesForPrescription.push( + `Min hours between doses changed to ${ + currentPrescription.min_hours_between_doses ?? "Not specified" + } from ${prevPrescription.min_hours_between_doses ?? "Not specified"}`, + ); + } + + // If there are changes, add them to the changes array + if (changesForPrescription.length > 0) { + const message = `Changes: ${changesForPrescription.join(", ")}`; + changes.push({ + prescriptionId: currentPrescription.id, + changeMessage: message, + prescribed_by: currentPrescription.prescribed_by, + created_date: currentPrescription.created_date, + }); + } else { + // If no changes, just list out the details of the prescription + const message = getDetailsMessage(currentPrescription); + + changes.push({ + prescriptionId: currentPrescription.id, + changeMessage: message, + prescribed_by: currentPrescription.prescribed_by, + created_date: currentPrescription.created_date, + }); + } + } + + return changes.reverse(); + }; + + return ( +
+ + {data?.results && + calculateChanges(data?.results).map((changes, index) => ( + +

{changes?.changeMessage}

+
+ ))} +
+
+ ); +} diff --git a/src/Locale/en/Medicine.json b/src/Locale/en/Medicine.json index 95ddda7c1fd..4670ca679d3 100644 --- a/src/Locale/en/Medicine.json +++ b/src/Locale/en/Medicine.json @@ -35,6 +35,7 @@ "prescription_discontinued": "Prescription discontinued", "administration_notes": "Administration Notes", "last_administered": "Last administered", + "prescription_logs": "Prescription Logs", "modification_caution_note": "No modifications possible once added", "discontinue_caution_note": "Are you sure you want to discontinue this prescription?", "edit_caution_note": "A new prescription will be added to the consultation with the edited details and the current prescription will be discontinued.", From 51d1339bfacac698a086a4b40de4ced7d6763bba Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Mon, 29 Apr 2024 21:05:05 +0530 Subject: [PATCH 07/11] dont show mg twice and show discontinued --- .../Medicine/MedicinePrescriptionSummary.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Components/Medicine/MedicinePrescriptionSummary.tsx b/src/Components/Medicine/MedicinePrescriptionSummary.tsx index f0ed17c254d..e6827d4b7a8 100644 --- a/src/Components/Medicine/MedicinePrescriptionSummary.tsx +++ b/src/Components/Medicine/MedicinePrescriptionSummary.tsx @@ -126,7 +126,7 @@ export default function ConsultationMedicineLogs({ const getDetailsMessage = (prescription: Prescription) => { const message = `Details: ${ prescription.base_dosage != null - ? `Base Dosage: ${prescription.base_dosage} mg, ` + ? `Base Dosage: ${prescription.base_dosage}, ` : "" }${prescription.route != null ? `Route: ${prescription.route}, ` : ""}${ prescription.dosage_type != null @@ -134,7 +134,7 @@ export default function ConsultationMedicineLogs({ : "" }${ prescription.target_dosage != null - ? `Target Dosage: ${prescription.target_dosage} mg, ` + ? `Target Dosage: ${prescription.target_dosage}, ` : "" }${ prescription.instruction_on_titration != null @@ -150,13 +150,16 @@ export default function ConsultationMedicineLogs({ : "" }${ prescription.max_dosage != null - ? `Max Dosage: ${prescription.max_dosage} mg, ` + ? `Max Dosage: ${prescription.max_dosage}, ` : "" }${ prescription.min_hours_between_doses != null ? `Min Hours Between Doses: ${prescription.min_hours_between_doses}, ` : "" - }`.replace(/, $/, ""); + }${prescription.discontinued ? "Discontinued: Yes, " : ""}`.replace( + /, $/, + "", + ); return message; }; @@ -183,7 +186,7 @@ export default function ConsultationMedicineLogs({ // Check for changes in base dosage if (prevPrescription.base_dosage !== currentPrescription.base_dosage) { changesForPrescription.push( - `Base dosage changed to ${currentPrescription.base_dosage} mg from ${prevPrescription.base_dosage} mg`, + `Base dosage changed to ${currentPrescription.base_dosage} from ${prevPrescription.base_dosage}`, ); } @@ -278,6 +281,11 @@ export default function ConsultationMedicineLogs({ ); } + // Check if discontinued + if (currentPrescription.discontinued && !prevPrescription.discontinued) { + changesForPrescription.push("Prescription was discontinued"); + } + // If there are changes, add them to the changes array if (changesForPrescription.length > 0) { const message = `Changes: ${changesForPrescription.join(", ")}`; From 447c8672bb765ab4372450bfc76a36fc9d9262ba Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Tue, 30 Apr 2024 16:26:06 +0530 Subject: [PATCH 08/11] show prescription type --- .../Medicine/MedicinePrescriptionSummary.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Components/Medicine/MedicinePrescriptionSummary.tsx b/src/Components/Medicine/MedicinePrescriptionSummary.tsx index e6827d4b7a8..344832d41c2 100644 --- a/src/Components/Medicine/MedicinePrescriptionSummary.tsx +++ b/src/Components/Medicine/MedicinePrescriptionSummary.tsx @@ -156,10 +156,11 @@ export default function ConsultationMedicineLogs({ prescription.min_hours_between_doses != null ? `Min Hours Between Doses: ${prescription.min_hours_between_doses}, ` : "" - }${prescription.discontinued ? "Discontinued: Yes, " : ""}`.replace( - /, $/, - "", - ); + }${prescription.discontinued ? "Discontinued: Yes, " : ""}${ + prescription.prescription_type + ? `Prescription Type: ${prescription.prescription_type}, ` + : "" + }`.replace(/, $/, ""); return message; }; @@ -286,6 +287,16 @@ export default function ConsultationMedicineLogs({ changesForPrescription.push("Prescription was discontinued"); } + // Check if prescription type is changed + if ( + prevPrescription.prescription_type !== + currentPrescription.prescription_type + ) { + changesForPrescription.push( + `Prescription Type changed from ${prevPrescription.prescription_type} to ${currentPrescription.prescription_type}`, + ); + } + // If there are changes, add them to the changes array if (changesForPrescription.length > 0) { const message = `Changes: ${changesForPrescription.join(", ")}`; From 8aee752708ebdb0d6b7b6860481e4712fa0cfe6f Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Wed, 8 May 2024 19:05:51 +0530 Subject: [PATCH 09/11] add disconitnue and no medicine card --- .../Medicine/MedicinePrescriptionSummary.tsx | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Components/Medicine/MedicinePrescriptionSummary.tsx b/src/Components/Medicine/MedicinePrescriptionSummary.tsx index 344832d41c2..cc0d17ccf24 100644 --- a/src/Components/Medicine/MedicinePrescriptionSummary.tsx +++ b/src/Components/Medicine/MedicinePrescriptionSummary.tsx @@ -59,8 +59,7 @@ export const MedicinePrescriptionSummary = ({

{t("summary")}

- {medicinesList && - medicinesList.length > 0 && + {medicinesList && medicinesList.length > 0 ? ( medicinesList?.map((med: MedibaseMedicine) => (
- ))} + )) + ) : ( +
+
+

{"No Medicine Summary"}

+
+
+ )}
Date: Mon, 13 May 2024 15:19:01 +0530 Subject: [PATCH 10/11] show discontinued in the summary --- .../Medicine/MedicinePrescriptionSummary.tsx | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Components/Medicine/MedicinePrescriptionSummary.tsx b/src/Components/Medicine/MedicinePrescriptionSummary.tsx index cc0d17ccf24..c539ba73029 100644 --- a/src/Components/Medicine/MedicinePrescriptionSummary.tsx +++ b/src/Components/Medicine/MedicinePrescriptionSummary.tsx @@ -313,7 +313,7 @@ export default function ConsultationMedicineLogs({ } // If there are changes, add them to the changes array - if (changesForPrescription.length > 0) { + if (changesForPrescription.length > 0 && !prevPrescription.discontinued) { const message = `Changes: ${changesForPrescription.join(", ")}`; changes.push({ prescriptionId: currentPrescription.id, @@ -353,19 +353,23 @@ export default function ConsultationMedicineLogs({ name={data?.results[0].medicine_object?.name ?? ""} > {data?.results && - calculateChanges(data?.results).map((changes, index) => ( - -

{changes?.changeMessage}

-
- ))} + (() => { + const changesArray = calculateChanges(data?.results); + return changesArray.map((changes, index) => ( + +

{changes?.changeMessage}

+
+ )); + })()}
); From 87588fd716a07b1305e28f07bcd42f81c234e574 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Sun, 26 May 2024 00:20:50 +0530 Subject: [PATCH 11/11] update changes --- .../Medicine/MedicinePrescriptionSummary.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Components/Medicine/MedicinePrescriptionSummary.tsx b/src/Components/Medicine/MedicinePrescriptionSummary.tsx index c539ba73029..b77acc090c4 100644 --- a/src/Components/Medicine/MedicinePrescriptionSummary.tsx +++ b/src/Components/Medicine/MedicinePrescriptionSummary.tsx @@ -132,13 +132,9 @@ export default function ConsultationMedicineLogs({ const getDetailsMessage = (prescription: Prescription) => { const message = `Details: ${ prescription.base_dosage != null - ? `Base Dosage: ${prescription.base_dosage}, ` + ? `${prescription.dosage_type === "TITRATED" ? "Start Dosage" : "Dosage"}: ${prescription.base_dosage}, ` : "" }${prescription.route != null ? `Route: ${prescription.route}, ` : ""}${ - prescription.dosage_type != null - ? `Dosage Type: ${prescription.dosage_type}, ` - : "" - }${ prescription.target_dosage != null ? `Target Dosage: ${prescription.target_dosage}, ` : "" @@ -163,8 +159,8 @@ export default function ConsultationMedicineLogs({ ? `Min Hours Between Doses: ${prescription.min_hours_between_doses}, ` : "" }${prescription.discontinued ? "Discontinued: Yes, " : ""}${ - prescription.prescription_type - ? `Prescription Type: ${prescription.prescription_type}, ` + prescription.dosage_type + ? `Prescription Type: ${prescription.dosage_type}, ` : "" }`.replace(/, $/, "");