Inventory
GS1 EPCIS 2.0 compliant inventory management
Overview
The Inventory API implements GS1 EPCIS 2.0 (Electronic Product Code Information Services) for healthcare supply chain management.
Base URL: https://rkyywwxpkzzkvopnobvt.supabase.co/functions/v1/inventory-api/v1
Products
Create Product
Locations
Storage locations (warehouses, shelves, dispensing areas):
Location Types
warehouse— Main storageshelf— Storage shelf/bindispensing— Dispensing areareceiving— Receiving dock
Stock
Current stock levels:
Stock Item Fields
| Field | Description |
|---|---|
product_id | Product reference |
location_id | Location reference |
lot_number | Batch/lot number |
expiry_date | Expiration date |
quantity_on_hand | Total quantity |
quantity_reserved | Reserved quantity |
quantity_available | GENERATED (on_hand - reserved) |
Note: quantity_available is a generated column — never INSERT/UPDATE it directly.
EPCIS Events
Record supply chain events:
Record Event
EPCIS Business Steps
| biz_step | Action | Effect |
|---|---|---|
commissioning | ADD | Create new stock item |
receiving | ADD | Add to stock on receipt |
shipping | DELETE | Remove from stock on shipment |
dispensing | DELETE | Remove on patient dispensing |
destroying | DELETE | Remove on disposal |
transforming | DELETE + ADD | Convert between items |
The record_epcis_event function inserts the event AND automatically updates stock quantities based on the biz_step + action combination.
Purchase Orders
PO Status Values
draft— Being preparedsubmitted— Sent to supplierreceived— Goods receivedcancelled— Cancelled
Dashboard
Stock metrics and analytics:
Returns: total products, low stock alerts, expiring items, recent events.
Required Privileges
| Privilege | Description |
|---|---|
manage_inventory | Full CRUD access |
view_inventory | Read-only access |
dispense_medication | Dispensing operations |
Notes
- Served by the
inventory-apiservice; every route is scoped to the organization in your token. - Stock levels are derived from recorded EPCIS events rather than written directly, so the event log and the quantities on hand cannot disagree.