Skip to content

Commit

Permalink
O3-2551 Make hard-coded maximum duration of dispense in medications a… (
Browse files Browse the repository at this point in the history
#1455)

* 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 <[email protected]>

---------

Co-authored-by: Pius Rubangakene <[email protected]>
  • Loading branch information
CynthiaKamau and pirupius authored Nov 7, 2023
1 parent 31634d8 commit 2390fa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}
/>
) : (
Expand Down Expand Up @@ -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 },
Expand All @@ -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 = () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/esm-patient-medications-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,4 +39,5 @@ export interface ConfigObject {
};
drugOrderTypeUUID: string;
showPrintButton: boolean;
maxDispenseDurationInDays: number;
}

0 comments on commit 2390fa9

Please sign in to comment.