FHIR Complete

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

GET /products?search={name}&code={code}&_count={limit}&_offset={offset}
POST /products
GET /products/{id}
PUT /products/{id}

Create Product

{
  "name": "Amoxicillin 500mg Capsules",
  "code": "05012345678900",
  "codeType": "GTIN",
  "category": "medication",
  "unit": "box",
  "reorderLevel": 50,
  "reorderQuantity": 200
}

Locations

Storage locations (warehouses, shelves, dispensing areas):

GET /locations?search={name}&type={type}&_count={limit}&_offset={offset}
POST /locations
GET /locations/{id}
PUT /locations/{id}

Location Types

  • warehouse — Main storage
  • shelf — Storage shelf/bin
  • dispensing — Dispensing area
  • receiving — Receiving dock

Stock

Current stock levels:

GET /stock?product={id}&location={id}&_count={limit}&_offset={offset}
GET /stock/{id}

Stock Item Fields

FieldDescription
product_idProduct reference
location_idLocation reference
lot_numberBatch/lot number
expiry_dateExpiration date
quantity_on_handTotal quantity
quantity_reservedReserved quantity
quantity_availableGENERATED (on_hand - reserved)

Note: quantity_available is a generated column — never INSERT/UPDATE it directly.

EPCIS Events

Record supply chain events:

GET /epcis-events?product={id}&biz_step={step}&_count={limit}&_offset={offset}
POST /epcis-events

Record Event

{
  "eventType": "ObjectEvent",
  "action": "ADD",
  "bizStep": "receiving",
  "productId": "product-uuid",
  "locationId": "location-uuid",
  "quantity": 100,
  "lotNumber": "LOT-2026-001",
  "expiryDate": "2027-03-01"
}

EPCIS Business Steps

biz_stepActionEffect
commissioningADDCreate new stock item
receivingADDAdd to stock on receipt
shippingDELETERemove from stock on shipment
dispensingDELETERemove on patient dispensing
destroyingDELETERemove on disposal
transformingDELETE + ADDConvert between items

The record_epcis_event function inserts the event AND automatically updates stock quantities based on the biz_step + action combination.

Purchase Orders

GET /purchase-orders?status={status}&_count={limit}&_offset={offset}
POST /purchase-orders
GET /purchase-orders/{id}
PUT /purchase-orders/{id}

PO Status Values

  • draft — Being prepared
  • submitted — Sent to supplier
  • received — Goods received
  • cancelled — Cancelled

Dashboard

Stock metrics and analytics:

GET /dashboard

Returns: total products, low stock alerts, expiring items, recent events.

Required Privileges

PrivilegeDescription
manage_inventoryFull CRUD access
view_inventoryRead-only access
dispense_medicationDispensing operations

Notes

  • Served by the inventory-api service; 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.