From 4568e5ffcf60b28d64e7f938bfd0e60ebba1337f Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 1 May 2024 00:01:36 +0530 Subject: [PATCH] Fixes issue preventing from administering down titration prescriptions (#7743) * Fixes issues with administering down titration prescriptions * fix for create prescription form --- src/Components/Medicine/CreatePrescriptionForm.tsx | 2 +- src/Components/Medicine/EditPrescriptionForm.tsx | 2 +- .../AdministrationTableRow.tsx | 2 +- src/Components/Medicine/PrescriptionBuilder.tsx | 2 +- src/Components/Medicine/validators.ts | 14 ++++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Components/Medicine/CreatePrescriptionForm.tsx b/src/Components/Medicine/CreatePrescriptionForm.tsx index fcc9443eaa3..b918d5781fe 100644 --- a/src/Components/Medicine/CreatePrescriptionForm.tsx +++ b/src/Components/Medicine/CreatePrescriptionForm.tsx @@ -92,7 +92,7 @@ export default function CreatePrescriptionForm(props: { optionValue={(key) => key} /> {field("dosage_type").value === "TITRATED" ? ( -
+
key} /> {field("dosage_type").value === "TITRATED" ? ( -
+
{t("edit_caution_note")}
} - className="w-full max-w-3xl lg:min-w-[600px]" + className="w-full max-w-4xl lg:min-w-[768px]" > {t("modification_caution_note")}
} - className="w-full max-w-3xl lg:min-w-[600px]" + className="w-full max-w-4xl lg:min-w-[768px]" > targetDosage) - ) - return "Dosage should be between start and target dosage"; + if (baseDosage && targetDosage) { + const [min, max] = [baseDosage, targetDosage].sort((a, b) => a - b); + + if (!(min <= valueDosage && valueDosage <= max)) { + return "Dosage should be between start and target dosage"; + } + } }; };