Skip to content

Commit

Permalink
(fix) Fix reverseal of autochange quantity commit and removed unused …
Browse files Browse the repository at this point in the history
…code (#112)

* Improved Dispensing module- Selectable items must have quantities greater or equal to the dispensing quantity

* camelcase naming fix

* fixed count condition to be greater than 0 only

* enabled autopick batch quantity in cases where it is less than prescribed quantity

* Corrected and simplified date calculation

* Fixed updatequantity when stock is diabled in dispensing module

* (fix) O3-3557: Ensure selectable batches have sufficient quantities for dispensing

* Added a comment for the isValiBatch function which checks the expiry of the drugs

* reverted back quantity dispense component

* removed unused functions in the  Fix the auto change of dispensing quantity when a batch is selected #110 PR

---------

Co-authored-by: Mark Goodrich <[email protected]>
  • Loading branch information
FelixKiprotich350 and mogoodrich authored Jul 18, 2024
1 parent dcb6ce1 commit 2cbd523
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
12 changes: 1 addition & 11 deletions src/forms/dispense-form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ const DispenseForm: React.FC<DispenseFormProps> = ({
// to prevent duplicate submits
const [isSubmitting, setIsSubmitting] = useState(false);

//track quantity to dispense
const [currentQuantity, setCurrentQuantity] = useState(
quantityRemaining ? quantityRemaining : medicationDispense?.quantity?.value,
);

// Submit medication dispense form
const handleSubmit = () => {
if (!isSubmitting) {
Expand Down Expand Up @@ -170,10 +165,6 @@ const DispenseForm: React.FC<DispenseFormProps> = ({
}
};

const setAvailableQuantity = (batch) => {
setCurrentQuantity(Number(batch.quantity));
};

// initialize the internal dispense payload with the dispenses passed in as props
useEffect(() => setMedicationDispensePayload(medicationDispense), [medicationDispense]);

Expand Down Expand Up @@ -218,14 +209,13 @@ const DispenseForm: React.FC<DispenseFormProps> = ({
<MedicationDispenseReview
medicationDispense={medicationDispensePayload}
updateMedicationDispense={setMedicationDispensePayload}
quantityRemaining={currentQuantity}
quantityRemaining={quantityRemaining}
/>
{config.enableStockDispense && (
<StockDispense
inventoryItem={inventoryItem}
medicationDispense={medicationDispense}
updateInventoryItem={setInventoryItem}
updateAvailableQuantityToMedicationDispenseQuantity={setAvailableQuantity}
/>
)}
</div>
Expand Down
7 changes: 1 addition & 6 deletions src/forms/stock-dispense/stock-dispense.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ type StockDispenseProps = {
medicationDispense: MedicationDispense;
updateInventoryItem: (inventoryItem: InventoryItem) => void;
inventoryItem: InventoryItem;
updateAvailableQuantityToMedicationDispenseQuantity: (inventoryItem: InventoryItem) => void;
};

const StockDispense: React.FC<StockDispenseProps> = ({
medicationDispense,
updateInventoryItem,
updateAvailableQuantityToMedicationDispenseQuantity,
}) => {
const StockDispense: React.FC<StockDispenseProps> = ({ medicationDispense, updateInventoryItem }) => {
const { t } = useTranslation();
const drugUuid = medicationDispense?.medicationReference?.reference?.split('/')[1];
const { inventoryItems, error, isLoading } = useDispenseStock(drugUuid);
Expand Down

0 comments on commit 2cbd523

Please sign in to comment.