Operational Flows (A-H)
These eight sequences define the core transactional logic of the PharmaNet ecosystem, orchestrated by the Mediator.
A: Practitioner Onboarding & Council Verification
sequenceDiagram
participant A as Admin (App)
participant M as Mediator
participant H as Worker Registry
participant NMC as Nepal Medical Council
participant NPC as Nepal Pharmacy Council
alt Visiting Doctor
A->>M: POST /Practitioner (Name, NMC ID)
M->>NMC: GET /verify?id=...
NMC-->>M: Status: Active
else Pharmacy Professional
A->>M: POST /Practitioner (Name, NPC ID)
M->>NPC: GET /verify?id=...
NPC-->>M: Status: Active
end
M->>H: Create Practitioner (Verified)
M-->>A: Verified & Logged Successfully
B: Clinical Encounter & IPS Record Creation
sequenceDiagram
participant A as Android App
participant M as Mediator
participant C as Client Registry
participant T as Terminology Svc
participant S as SHR Vault
A->>M: POST /Bundle (Patient + Encounter)
M->>C: Match Patient (NID lookup)
C-->>M: Patient UUID
M->>T: Validate Diagnosis (ICD-10)
T-->>M: Code Valid
M->>S: Store Transactional FHIR Bundle
S-->>M: 201 Created
M-->>A: Record Sync Success
C: POS Checkout: NID Linking & Stock Deduction
sequenceDiagram
participant A as Android POS
participant M as Mediator
participant C as Client Reg
participant INV as Inventory Svc
participant S as SHR Vault
A->>M: GET /Patient (NID lookup)
M->>C: Match Patient
C-->>M: Patient Data
A->>M: POST /Bundle (Dispense + Stock Deduction)
M->>INV: Deduct Pharmacy Inventory
INV-->>M: Local Stock Updated
M->>S: Store MedicationDispense
M-->>A: Print Receipt / QR
D: Chronic Care Subscription & Last-Mile Delivery
sequenceDiagram
participant P as Patient Mobile
participant M as Mediator
participant SUB as Subscription Svc
participant INV as Inventory Svc
participant LOG as Logistics Svc
participant 3PL as Delivery Rider
Note over SUB: Day 27 of 30: Refill Due
SUB->>M: Trigger Refill Alert
M->>INV: Check Stock at Local Pharmacy
INV-->>M: Stock Reserved (Batch Locked)
M->>P: SMS: "Refill ready! Confirm delivery?"
P-->>M: "Yes, deliver today"
M->>LOG: Request Dispatch (Pick up: Pharm Y)
LOG->>3PL: POST /Task (Dispatch Courier)
3PL-->>LOG: Rider Assigned & En Route
LOG-->>M: Status: In-Transit
M-->>P: "Rider is bringing your medicines!"
E: GPO Procurement: Multi-Distributor Reordering
sequenceDiagram
participant A as Android POS
participant M as Mediator
participant DR as Distributor Reg
participant FIS as Finance Svc
participant D as Distributor API
Note over A: Stock threshold reached
M->>DR: Fetch Suppliers for Facility
DR-->>M: List: [Dist-A, Dist-B, Dist-C]
M->>FIS: Cross-reference GPO Prices
FIS-->>M: Suggest Dist-B (Best Price + Delivery)
M-->>A: "One-Tap Approve: Order Napa from Dist-B?"
A->>M: POST /Order (Approved)
M->>FIS: Log Transaction & Platform Margin
M->>D: POST /DigitalPO to Dist-B API
D-->>M: 202 Accepted (Tracking: #X9)
M-->>A: Procurement Successful
F: Inbound Stock & Expiry Management
sequenceDiagram
participant A as Android POS
participant M as Mediator
participant P as Product Reg
participant INV as Inventory Svc
A->>M: GET /Product (Scan Barcode)
M->>P: Map local ID to GPO Master SKU
P-->>M: Global SKU Details
A->>M: POST /Inventory (Batch + Expiry)
M->>INV: Log Batch: #B2026, Exp: 2027-01
INV-->>M: Central Stock Record Updated
M-->>A: Push Alert: Batch #B2026 expires soon!
G: Insurance Verification & Digital Payment
sequenceDiagram
participant A as Android POS
participant M as Mediator
participant FIS as Finance Svc
participant I as openIMIS
participant P as connectIPS
A->>M: GET /Coverage (Eligibility Check)
M->>FIS: Verify Insurance Status
FIS->>I: GET /Patient/$check-eligibility
I-->>FIS: 200 OK (Limit remaining)
FIS-->>A: Cashless Claim Eligible
A->>M: POST /Invoice (Request QR)
M->>FIS: Request Payment Intent
FIS->>P: Generate Dynamic QR
P-->>A: Display QR Code on Tablet
H: Patient Appointment Booking
sequenceDiagram
participant P as Patient App
participant M as Mediator
participant SCH as Scheduling Svc
participant H as Worker Registry
participant A as Android POS
P->>M: GET /Slot (facility_id=Y)
M->>SCH: Query Available Appointments
SCH->>H: Validate Doctor Credential Status
SCH-->>M: Available Slots: [14:00, 15:30]
M-->>P: Display Slots
P->>M: POST /Appointment (Book 14:00)
M->>SCH: Create FHIR Appointment
SCH-->>M: 201 Created (Reserved)
M->>A: Push Notification: "New Booking @ 14:00"
M-->>P: Confirmation: Booked!