diff --git a/src/forms/stock-dispense/stock-dispense.component.tsx b/src/forms/stock-dispense/stock-dispense.component.tsx index aab8783..3e1d0fa 100644 --- a/src/forms/stock-dispense/stock-dispense.component.tsx +++ b/src/forms/stock-dispense/stock-dispense.component.tsx @@ -16,6 +16,14 @@ const StockDispense: React.FC = ({ medicationDispense, updat const drugUuid = medicationDispense?.medicationReference?.reference?.split('/')[1]; const { inventoryItems, error, isLoading } = useDispenseStock(drugUuid); const validInventoryItems = inventoryItems.filter((item) => isValidBatch(medicationDispense, item)); + const validInventoryItemss = inventoryItems + .filter((item) => isValidBatch(medicationDispense, item)) + .sort((a, b) => { + const dateA = new Date(a.expiration); + const dateB = new Date(b.expiration); + + return dateA.getDate() - dateB.getDate(); + }); function parseDate(dateString) { return new Date(dateString);