diff --git a/src/components/Common/QuantityInput.tsx b/src/components/Common/QuantityInput.tsx index c109558c773..4413707ca02 100644 --- a/src/components/Common/QuantityInput.tsx +++ b/src/components/Common/QuantityInput.tsx @@ -19,6 +19,7 @@ interface Props { disabled?: boolean; placeholder?: string; autoFocus?: boolean; + unitLabels?: Record; } const QuantityInput = ({ @@ -28,6 +29,7 @@ const QuantityInput = ({ disabled, placeholder, autoFocus, + unitLabels, }: Props) => { const handleChange = (update: Partial>) => { onChange({ ...quantity, ...update }); @@ -60,7 +62,7 @@ const QuantityInput = ({ {units.map((unit) => ( - {unit} + {unitLabels?.[unit] ?? unit} ))} diff --git a/src/components/Questionnaire/QuestionTypes/MedicationRequestQuestion.tsx b/src/components/Questionnaire/QuestionTypes/MedicationRequestQuestion.tsx index 3a505569b09..ce7b580737f 100644 --- a/src/components/Questionnaire/QuestionTypes/MedicationRequestQuestion.tsx +++ b/src/components/Questionnaire/QuestionTypes/MedicationRequestQuestion.tsx @@ -3,7 +3,6 @@ import { t } from "i18next"; import React from "react"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, @@ -17,6 +16,7 @@ import { QuantityInput } from "@/components/Common/QuantityInput"; import ValueSetSelect from "@/components/Questionnaire/ValueSetSelect"; import { + BOUNDS_DURATION_UNITS, DOSAGE_UNITS, MEDICATION_REQUEST_INTENT, MedicationRequest, @@ -103,9 +103,9 @@ export function MedicationRequestQuestion({
{medications.length > 0 && (
-
+
{/* Header */} -
+
{t("medicine")}
@@ -116,7 +116,7 @@ export function MedicationRequestQuestion({ {t("frequency")}
- {t("days")} + {t("duration")}
{t("instructions")} @@ -186,7 +186,7 @@ const MedicationRequestGridRow: React.FC<{ }; return ( -
+
{/* Medicine Name and Controls */}
@@ -269,19 +269,26 @@ const MedicationRequestGridRow: React.FC<{
- {/* Days */} + {/* Duration */}
- - + {t("duration")} + + } - onChange={(e) => + quantity={{ + value: + medication.dosage_instruction[0]?.timing?.repeat + ?.bounds_duration?.value, + unit: + medication.dosage_instruction[0]?.timing?.repeat + ?.bounds_duration?.unit ?? "d", + }} + onChange={(value) => handleUpdateDosageInstruction({ timing: { ...dosageInstruction?.timing, @@ -292,15 +299,23 @@ const MedicationRequestGridRow: React.FC<{ period_unit: dosageInstruction?.timing?.repeat?.period_unit ?? "d", bounds_duration: { - value: e.target.value - ? parseInt(e.target.value) - : undefined, - unit: "d", + value: value?.value, + unit: value?.unit as keyof typeof BOUNDS_DURATION_UNITS, }, }, }, }) } + disabled={ + disabled || medication.dosage_instruction[0]?.as_needed_boolean + } + unitLabels={ + Object.fromEntries( + Object.entries(BOUNDS_DURATION_UNITS).map( + ([key, { label }]) => [key, label], + ), + ) as Record + } />
@@ -441,41 +456,73 @@ const reverseFrequencyOption = ( // TODO: verify period_unit is correct const FREQUENCY_OPTIONS = { - BD: { - display: "Twice daily", + BID: { + display: "Two times a day", timing: { repeat: { frequency: 2, period: 1, period_unit: "d" } }, }, - HS: { - display: "Night only", + TID: { + display: "Three times a day", + timing: { repeat: { frequency: 3, period: 1, period_unit: "d" } }, + }, + QID: { + display: "Four times a day", + timing: { repeat: { frequency: 4, period: 1, period_unit: "d" } }, + }, + AM: { + display: "Every morning", + timing: { repeat: { frequency: 1, period: 1, period_unit: "d" } }, + }, + PM: { + display: "Every afternoon", timing: { repeat: { frequency: 1, period: 1, period_unit: "d" } }, }, - OD: { - display: "Once daily", + QD: { + display: "Every day", timing: { repeat: { frequency: 1, period: 1, period_unit: "d" } }, }, + QOD: { + display: "Every other day", + timing: { repeat: { frequency: 1, period: 2, period_unit: "d" } }, + }, + Q1H: { + display: "Every hour", + timing: { repeat: { frequency: 24, period: 1, period_unit: "d" } }, + }, + Q2H: { + display: "Every 2 hours", + timing: { repeat: { frequency: 12, period: 1, period_unit: "d" } }, + }, + Q3H: { + display: "Every 3 hours", + timing: { repeat: { frequency: 8, period: 1, period_unit: "d" } }, + }, Q4H: { - display: "4th hourly", - timing: { repeat: { frequency: 4, period: 1, period_unit: "h" } }, + display: "Every 4 hours", + timing: { repeat: { frequency: 6, period: 1, period_unit: "d" } }, }, - QID: { - display: "6th hourly", - timing: { repeat: { frequency: 6, period: 1, period_unit: "h" } }, + Q6H: { + display: "Every 6 hours", + timing: { repeat: { frequency: 4, period: 1, period_unit: "d" } }, }, - QOD: { - display: "Alternate day", - timing: { repeat: { frequency: 2, period: 1, period_unit: "d" } }, + Q8H: { + display: "Every 8 hours", + timing: { repeat: { frequency: 3, period: 1, period_unit: "d" } }, + }, + BED: { + display: "At bedtime", + timing: { repeat: { frequency: 1, period: 1, period_unit: "d" } }, }, - QWK: { - display: "Once a week", + WK: { + display: "Weekly", timing: { repeat: { frequency: 1, period: 1, period_unit: "wk" } }, }, - STAT: { - display: "Imediately", - timing: { repeat: { frequency: 1, period: 1, period_unit: "s" } }, + MO: { + display: "Monthly", + timing: { repeat: { frequency: 1, period: 1, period_unit: "mo" } }, }, - TID: { - display: "8th hourly", - timing: { repeat: { frequency: 8, period: 1, period_unit: "h" } }, + STAT: { + display: "Immediately", + timing: { repeat: { frequency: 1, period: 1, period_unit: "s" } }, // One-time }, } as const satisfies Record< string, diff --git a/src/types/emr/medicationRequest.ts b/src/types/emr/medicationRequest.ts index 68482839f0e..739664f1b93 100644 --- a/src/types/emr/medicationRequest.ts +++ b/src/types/emr/medicationRequest.ts @@ -14,9 +14,10 @@ export const DOSAGE_UNITS = [ ] as const; export const BOUNDS_DURATION_UNITS = { - ms: { label: "Milliseconds" }, - s: { label: "Seconds" }, - min: { label: "Minutes" }, + // TODO: Are these smaller units required? + // ms: { label: "Milliseconds" }, + // s: { label: "Seconds" }, + // min: { label: "Minutes" }, h: { label: "Hours" }, d: { label: "Days" }, wk: { label: "Weeks" },