Skip to content

Commit

Permalink
Fixes issue preventing from administering down titration prescriptions (
Browse files Browse the repository at this point in the history
#7743)

* Fixes issues with administering down titration prescriptions

* fix for create prescription form
  • Loading branch information
rithviknishad committed Apr 30, 2024
1 parent 1ae0f33 commit 4568e5f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Components/Medicine/CreatePrescriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function CreatePrescriptionForm(props: {
optionValue={(key) => key}
/>
{field("dosage_type").value === "TITRATED" ? (
<div className="flex w-full gap-4">
<div className="flex w-full flex-[2] gap-4">
<DosageFormField
className="flex-1"
label={t("start_dosage")}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Medicine/EditPrescriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function EditPrescriptionForm(props: Props) {
optionValue={(key) => key}
/>
{field("dosage_type").value === "TITRATED" ? (
<div className="flex w-full gap-4">
<div className="flex w-full flex-[2] gap-4">
<DosageFormField
className="flex-1"
label={t("start_dosage")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function MedicineAdministrationTableRow({
<span>{t("edit_caution_note")}</span>
</div>
}
className="w-full max-w-3xl lg:min-w-[600px]"
className="w-full max-w-4xl lg:min-w-[768px]"
>
<EditPrescriptionForm
initial={prescription}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Medicine/PrescriptionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function PrescriptionBuilder({
<span>{t("modification_caution_note")}</span>
</div>
}
className="w-full max-w-3xl lg:min-w-[600px]"
className="w-full max-w-4xl lg:min-w-[768px]"
>
<CreatePrescriptionForm
prescription={
Expand Down
14 changes: 8 additions & 6 deletions src/Components/Medicine/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const PRESCRIPTION_COMPARE_FIELDS: (keyof Prescription)[] = [
"medicine",
"days",
"discontinued",
"target_dosage",
"base_dosage",
"frequency",
"indicator",
Expand Down Expand Up @@ -77,11 +78,12 @@ export const AdministrationDosageValidator = (
if (value?.split(" ")[1] !== base_dosage?.split(" ")[1])
return "Unit must be the same as start and target dosage's unit";

if (
baseDosage &&
targetDosage &&
(valueDosage < baseDosage || valueDosage > 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";
}
}
};
};

0 comments on commit 4568e5f

Please sign in to comment.