Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue preventing from administering down titration prescriptions #7743

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
}
}
};
};
Loading