Pharmacy Inventory Management

Architecture for Pharmacy Inventory Management:

DrugPurchaseOrders are sent from a dispense location to a stock location. DrugPurchaseOrder has a one-to-many relationship with DrugInventory. When a DPO is created, it has:

StateDrugPurchaseOrderDrugInventory locationDrugInventory status
DPO is createdreceived: falsePharmacy dispensary Xrequested
DPO is receivedreceived: truePharmacy stock centerreceived
DPO is filledreceived: truePharmacy stock centerfilled
DPO is sent to Pharmacy dispensaryreceived: falsePharmacy stock centersent
DPO drugs are received by dispensaryreceived: truePharmacy dispensary Xavailable

Notes on filling:

-Each DrugInventory is converted to a specific batch with expiryDate, etc.

-DrugInventories are split if necessary, new DrugInventories added

-The existing batches of DrugInventories that are being used to fill are decremented as needed (the user will choose which batch to fill the purchase order with)

Other use cases:

Issuing stock to dispensary: same as last two steps above. Stock Center creates the DrugPurchaseOrder but system acts as if the dispensary requested.

StateDrugPurchaseOrderDrugInventory locationDrugInventory status
Stock sentreceived: falsePharmacy stock centersent
Stock receivedreceived: truePharmacy dispensary Yavailable

Issuing stock to outside of system/offline dispensaries: existing inventories are decremented, and DrugInventories immediately available at some location:

StateDrugPurchaseOrderDrugInventory locationDrugInventory status
Stock Issuedreceived: trueDispensary Z/Unknown Locationavailable