From 2390fa930348db682d6cb6185c20b46b194fe7d8 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Tue, 7 Nov 2023 11:02:10 +0300 Subject: [PATCH] =?UTF-8?q?O3-2551=20Make=20hard-coded=20maximum=20duratio?= =?UTF-8?q?n=20of=20dispense=20in=20medications=20a=E2=80=A6=20(#1455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * O3-2551 Make hard-coded maximum duration of dispense in medications app configurable * code review * Update packages/esm-patient-medications-app/src/config-schema.ts Co-authored-by: Pius Rubangakene --------- Co-authored-by: Pius Rubangakene --- .../src/add-drug-order/drug-order-form.component.tsx | 6 ++++-- packages/esm-patient-medications-app/src/config-schema.ts | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx b/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx index 306c491476..5e44eaefa5 100644 --- a/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx +++ b/packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx @@ -236,6 +236,7 @@ export function DrugOrderForm({ initialOrderBasketItem, onSave, onCancel }: Drug const [showStickyMedicationHeader, setShowMedicationHeader] = useState(false); const { patient, isLoading: isLoadingPatientDetails } = usePatient(); const patientName = `${patient?.name?.[0]?.given?.join(' ')} ${patient?.name?.[0].family}`; + const { maxDispenseDurationInDays } = useConfig(); const observer = useRef(null); const medicationInfoHeaderRef = useCallback( @@ -506,7 +507,7 @@ export function DrugOrderForm({ initialOrderBasketItem, onSave, onCancel }: Drug label={t('duration', 'Duration')} min={0} step={1} - max={99} + max={maxDispenseDurationInDays} allowEmpty={true} /> ) : ( @@ -632,6 +633,7 @@ export function DrugOrderForm({ initialOrderBasketItem, onSave, onCancel }: Drug const CustomNumberInput = ({ setValue, control, name, labelText, ...inputProps }) => { const { t } = useTranslation(); + const { maxDispenseDurationInDays } = useConfig(); const { field: { onBlur, onChange, value, ref }, @@ -643,7 +645,7 @@ const CustomNumberInput = ({ setValue, control, name, labelText, ...inputProps } }; const increment = () => { - setValue(name, Math.min(Number(value) + 1, 99)); + setValue(name, Math.min(Number(value) + 1, maxDispenseDurationInDays)); }; const decrement = () => { diff --git a/packages/esm-patient-medications-app/src/config-schema.ts b/packages/esm-patient-medications-app/src/config-schema.ts index c1ad946147..b268b977ce 100644 --- a/packages/esm-patient-medications-app/src/config-schema.ts +++ b/packages/esm-patient-medications-app/src/config-schema.ts @@ -25,6 +25,11 @@ export const configSchema = { _description: 'Determines whether or not to display the Print button in both the active and past medications datatable headers. If set to true, a Print button gets shown in both the active and past medications table headers. When clicked, this button enables the user to print out the contents of the table', }, + maxDispenseDurationInDays: { + _type: Type.Number, + _default: 99, + _description: 'The maximum number of days for medication dispensing.', + }, }; export interface ConfigObject { @@ -34,4 +39,5 @@ export interface ConfigObject { }; drugOrderTypeUUID: string; showPrintButton: boolean; + maxDispenseDurationInDays: number; }