diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 6a6b8c48ead..7b170379066 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -165,12 +165,12 @@ const DischargeModal = ({ } }; - const handleFacilitySelect = (selected: FacilityModel) => { + const handleFacilitySelect = (selected?: FacilityModel) => { setFacility(selected); setPreDischargeForm((prev) => ({ ...prev, - referred_to: selected.id ?? null, - referred_to_external: !selected.id ? selected.name : null, + referred_to: selected?.id ?? null, + referred_to_external: !selected?.id ? selected?.name : null, })); }; @@ -215,7 +215,7 @@ const DischargeModal = ({ - handleFacilitySelect(selected as FacilityModel) + handleFacilitySelect(selected as FacilityModel | undefined) } selected={facility ?? null} showAll diff --git a/src/Components/Medicine/CreatePrescriptionForm.tsx b/src/Components/Medicine/CreatePrescriptionForm.tsx index 07e8ec208d6..fcc9443eaa3 100644 --- a/src/Components/Medicine/CreatePrescriptionForm.tsx +++ b/src/Components/Medicine/CreatePrescriptionForm.tsx @@ -61,26 +61,27 @@ export default function CreatePrescriptionForm(props: { {...field("medicine_object", RequiredFieldValidator())} required /> - {props.prescription.dosage_type !== "PRN" && ( - { - if (e.value) { - field("dosage_type").onChange({ - name: "dosage_type", - value: "TITRATED", - }); - } else { - field("dosage_type").onChange({ - name: "dosage_type", - value: "REGULAR", - }); - } - }} - /> - )} + {props.prescription.dosage_type !== "PRN" && + props.prescription.prescription_type !== "DISCHARGE" && ( + { + if (e.value) { + field("dosage_type").onChange({ + name: "dosage_type", + value: "TITRATED", + }); + } else { + field("dosage_type").onChange({ + name: "dosage_type", + value: "REGULAR", + }); + } + }} + /> + )}
void; + readonly?: boolean; } export default function AdministrationEventCell({ @@ -19,6 +20,7 @@ export default function AdministrationEventCell({ interval: { start, end }, prescription, refetch, + readonly, }: Props) { const [showTimeline, setShowTimeline] = useState(false); // Check if cell belongs to an administered prescription (including start and excluding end) @@ -56,6 +58,7 @@ export default function AdministrationEventCell({ prescription={prescription} showPrescriptionDetails onRefetch={refetch} + readonly={readonly} />
@@ -166,93 +166,104 @@ export default function MedicineAdministrationTableRow({ /> )} - setShowDetails(true)} + -
-
- setShowDetails(true)} + > +
+
+ + {prescription.medicine_object?.name ?? + prescription.medicine_old} + + + {prescription.discontinued && ( + + {t("discontinued")} + )} - > - {prescription.medicine_object?.name ?? prescription.medicine_old} - - {prescription.discontinued && ( - - {t("discontinued")} - - )} + {prescription.route && ( + + {t(prescription.route)} + + )} +
- {prescription.route && ( - - {t(prescription.route)} - - )} -
+
+ {prescription.dosage_type !== "TITRATED" ? ( +

{prescription.base_dosage}

+ ) : ( +

+ {prescription.base_dosage} - {prescription.target_dosage} +

+ )} -
- {prescription.dosage_type !== "TITRATED" ? ( -

{prescription.base_dosage}

- ) : (

- {prescription.base_dosage} - {prescription.target_dosage} + {prescription.dosage_type !== "PRN" + ? t("PRESCRIPTION_FREQUENCY_" + prescription.frequency) + : prescription.indicator}

- )} - -

- {prescription.dosage_type !== "PRN" - ? t("PRESCRIPTION_FREQUENCY_" + prescription.frequency) - : prescription.indicator} -

+
-
- + - + - {/* Administration Cells */} - {props.intervals.map(({ start, end }, index) => ( - <> - - - + {/* Administration Cells */} + {props.intervals.map(({ start, end }, index) => ( + <> + + + - - {!data?.results ? ( - - ) : ( - - )} - - - ))} - + + {!data?.results ? ( + + ) : ( + + )} + + + ))} + - {/* Action Buttons */} - - setShowAdminister(true)} - > - {t("administer")} - - - + {/* Action Buttons */} + + {!props.readonly && ( + setShowAdminister(true)} + > + {t("administer")} + + )} + + + ); } diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index 41a681f26b0..4c054edcaf3 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -140,6 +140,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { refetch(); discontinuedPrescriptions.refetch(); }} + readonly={readonly || false} /> )} diff --git a/src/Components/Medicine/PrescrpitionTimeline.tsx b/src/Components/Medicine/PrescrpitionTimeline.tsx index 12cf3fd4998..9422d349b3a 100644 --- a/src/Components/Medicine/PrescrpitionTimeline.tsx +++ b/src/Components/Medicine/PrescrpitionTimeline.tsx @@ -29,12 +29,14 @@ interface Props { prescription: Prescription; showPrescriptionDetails?: boolean; onRefetch?: () => void; + readonly?: boolean; } export default function PrescrpitionTimeline({ prescription, interval, onRefetch, + readonly, }: Props) { const consultation = useSlug("consultation"); const { data, refetch, loading } = useQuery( @@ -89,7 +91,7 @@ export default function PrescrpitionTimeline({ refetch(); }} isLastNode={index === events.length - 1} - hideArchive={prescription.discontinued} + hideArchive={prescription.discontinued || readonly} /> ); } diff --git a/src/Locale/en/Medicine.json b/src/Locale/en/Medicine.json index 95ddda7c1fd..36adc259514 100644 --- a/src/Locale/en/Medicine.json +++ b/src/Locale/en/Medicine.json @@ -2,6 +2,7 @@ "medicine": "Medicine", "route": "Route", "dosage": "Dosage", + "base_dosage": "Dosage", "start_dosage": "Start Dosage", "target_dosage": "Target Dosage", "instruction_on_titration": "Instruction on titration", @@ -58,4 +59,4 @@ "PRESCRIPTION_FREQUENCY_Q4H": "4th hourly", "PRESCRIPTION_FREQUENCY_QOD": "Alternate day", "PRESCRIPTION_FREQUENCY_QWK": "Once a week" -} +} \ No newline at end of file