VIVAMEN

Enter password to continue

Incorrect password

VIVAMEN Developer

Pharmacy Backend — Full Flow Overview

Full Flow Overview

Bird's-eye view of the entire backend — every phase shown. Green = happy path. Red = exit/rejection. Purple = instalment path. Dashed = external API. Side labels show which APIs are used at each stage.

Scroll to pan
flowchart TD
  START["▶ Patient on product page"]:::startNode
  START --> P1["Phase 1
Product Selection &
Consultation Entry"] P1 --> P2["Phase 2
Consultation Form
(multi-step wizard)"] P2 --> DENY{"Auto-deny?"} DENY -->|YES| AD["✖ Denied
Advised to see GP"]:::redNode DENY -->|NO| P3 P3["Phase 3
Payment & Plan Selection"] P3 --> TYPE{"One-off or
Instalment?"} TYPE -->|ONE-OFF| PAY_A["Pay in full"]:::pathA TYPE -->|INSTALMENT| PAY_B["Pay 1st month"]:::pathB PAY_A --> P4 PAY_B --> P4 P4["Phase 4
ID Verification"]:::apiNode P4 --> ID{"Pass?"} ID -->|YES| P5 ID -->|FAIL| IDX["✖ Rejected + Refund"]:::redNode P5["Phase 5
Clinical Review Queue
& Notification"] P5 --> P6["Phase 6
Prescriber / Pharmacist
Reviews Case"] P6 --> DEC{"Decision?"} DEC -->|APPROVE| P7_SPLIT{"Order type?"} DEC -->|MORE INFO| P6 DEC -->|DENY| DENR["✖ Denied + Refund"]:::redNode P7_SPLIT -->|ONE-OFF| P7A["Phase 7A
Single Rx
(one order)"]:::pathA P7_SPLIT -->|INSTALMENT| P7B["Phase 7B
Single Rx covering
full plan period"]:::pathB P7A --> SIGN P7B --> SIGN SIGN["Prescriber signs in
SignatureRx (FINAL)"]:::apiNode SIGN --> P8["Phase 8
Post-Approval Triggers
Fires immediately on decision:
GP Letter | Patient Msg |
Pharmacy Team Notified"]:::greenNode P8 --> P9["Phase 9
PMR Sync &
Print Slip"]:::supportNode P9 --> P10["Phase 10
Repeat Submission
Detection"]:::supportNode P10 --> P11["Phase 11
Dispatch"]:::apiNode P11 --> P12["Phase 12
Delivery & Tracking"] P12 -->|DELIVERED| DONE["✅ Complete"]:::greenEnd P12 -->|FAILED| DELFAIL["Team action"]:::orangeNode DONE --> NEXT{"Order type?"} NEXT -->|ONE-OFF| REORDER{"Within grace
period?"} REORDER -->|YES| REORD["Re-confirm → reorder"]:::pathA REORD --> P11 REORDER -->|NO| EXPIRED["Fresh consultation"]:::orangeNode NEXT -->|INSTALMENT| P13["Phase 13
Instalment Renewal"]:::pathB P13 -->|"Next month"| P11 P13 -->|"Plan ends &
within 12mo"| RECON["Re-confirm →
new plan"]:::pathB RECON --> P13 P13 -->|"12mo limit /
grace expired"| FRESH["Fresh consultation"]:::orangeNode %% API annotations — side labels connected with dotted lines API_STRIPE["⚡ Stripe
Payment + Refunds"]:::apiLabel API_LEXIS["⚡ LexisNexis
ID Verification"]:::apiLabel API_SRX["⚡ SignatureRx
E-Prescribing"]:::apiLabel API_TITAN["⚡ TitanPMR
Patient Data Sync"]:::apiLabel API_RM["⚡ Royal Mail
Shipping + Tracking"]:::apiLabel API_STRIPE -.-> P3 API_LEXIS -.-> P4 API_SRX -.-> SIGN API_TITAN -.-> P9 API_RM -.-> P11 classDef startNode fill:#1e3a5f,stroke:#60a5fa,color:#fff,stroke-width:2px classDef greenNode fill:#065f46,stroke:#34d399,color:#fff,stroke-width:2px classDef greenEnd fill:#065f46,stroke:#34d399,color:#fff,stroke-width:2px classDef redNode fill:#7f1d1d,stroke:#f87171,color:#fff,stroke-width:2px classDef orangeNode fill:#78350f,stroke:#fbbf24,color:#fff,stroke-width:2px classDef apiNode fill:#eef2ff,stroke:#818cf8,color:#3730a3,stroke-width:2px,stroke-dasharray: 5 5 classDef supportNode fill:#f0f4ff,stroke:#93c5fd,color:#1e3a5f,stroke-width:1px,stroke-dasharray: 5 5 classDef pathA fill:#1e3a5f,stroke:#60a5fa,color:#fff,stroke-width:2px classDef pathB fill:#3b1f5e,stroke:#a78bfa,color:#fff,stroke-width:2px classDef apiLabel fill:#f5f3ff,stroke:#a78bfa,color:#5b21b6,stroke-width:1px,stroke-dasharray: 3 3,font-size:11px

Key Architecture Decisions


Error / Exception Paths

All rejection and error scenarios with refund status.

ScenarioWhat happensRefund?Terminal state
Auto-denial from form logicPatient told treatment not suitable, advised to see GPNo — before paymentAuto-Denied
Payment fails at checkoutPatient shown error, can retryN/A — never capturedAwaiting Payment
ID check failsUpload requested → manual review → if still fails, rejectedYes — via StripeRejected → Refunded
Clinician requests more infoPatient messaged, consultation pausedNo — still activeAwaiting Response
Clinician denies treatmentReason logged, patient notified after refund confirmedYes — via StripeRejected → Refunded
Repeat submission detectedFlag shown to clinician during Phase 6 reviewNo — informationalFlagged for Review
Consultation abandonedReminder email sent. Flagged at 7 days, abandonable at 30 days.N/A — before paymentAbandoned (Draft)
Patient requests cancellationMessage to pharmacy team. Manual cancel + refund.Yes — manualCancelled → Refunded
Consultation timeout (30 days)Team can reject/refund after 30 days.Yes — manualAbandoned → Refunded
Delivery failed / returnedDelivery Failed screen. Team re-dispatches, contacts, or refunds.Depends on actionDelivery Failed
API unavailable (any)Order tagged "Pending (API Unavailable)". Auto-retry: 5min → 30min → 2hr → flag manual.No — still activePending (API Down)
Instalment payment fails (month 2+)Pharmacy notified. Patient contacted. Dispatch paused.May cancel remainingInstalment Paused
12-month hard limit reachedPatient cannot renew. Must complete full new consultation.No — not an errorConsultation Required

API Integrations

All external system integrations with direction and timing.

SystemAPIDirectionWhen
LexisNexis IDUIdentity verificationWebsite → LexisNexisPhase 4 — after payment
SignatureRxCreate PrescriptionWebsite → SignatureRxPhase 7 — prescriber approves POM
SignatureRxSigned Rx webhookSignatureRx → WebsitePhase 7 → triggers Phase 8 (GP letter + patient msg + pharmacy queue)
Royal MailCreate ShipmentWebsite → Royal MailPhase 11 — after order packed
Royal MailTracking webhookRoyal Mail → WebsitePhase 12 — delivery updates
TitanPMRPatient data pushWebsite → TitanPMRPhase 9 — after order confirmed
StripeFull capture / first instalmentWebsite → StripePhase 3 — after plan selection
StripeRecurring instalment chargeStripe → auto-chargePhase 13 — monthly for instalment plans
StripeRefund confirmation webhookStripe → WebsiteAfter team issues refund

Optional Extras

Features we ideally want but can be deferred. These are not blockers — the core flow works without them.

PriorityFeatureWhat it doesWhereFallback
HighStock managementTrack stock levels, block dispatch if out of stockPhase 11Manual tracking
HighTitanPMR APIAuto-push patient data to PMRPhase 9Manual export
MediumRoyal Mail tracking webhookAuto-update delivery statusPhase 12Manual status update
MediumNotification batchingDigest emails for prescribersPhase 5Immediate per case
MediumAnswer-diff detectionCompare repeat submission answersPhase 10Manual comparison
LowLow-stock alertsEmail when stock is lowPhase 11Depends on stock mgmt