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
- Payment model: Full payment upfront. If rejected at any stage → automatic full refund.
- One-off vs Instalment: Patient selects after consultation, before checkout. The flow splits at Phase 7: 7A = single Rx for one order. 7B = single Rx covering full instalment plan (max 3 months per plan, 12-month hard limit total).
- Rx is final: Once the prescriber signs in SignatureRx, the prescription is locked. No void/replacement process.
- Post-approval triggers (Phase 8): SignatureRx webhook fires THREE actions simultaneously: GP letter, patient notification, pharmacy queue entry. Pharmacy team is notified immediately — no manual handoff. GP notified before dispatch.
- Instalment renewal: Pharmacy auto-dispatches monthly (no prescriber re-review). At plan end, patient re-confirms. After 12 months total → fresh consultation required.
- Renewal overlap flag: If a patient triggers a renewal while a previous plan is still active, this is prominently flagged to both the prescriber (Phase 6) and pharmacy team (dispatch) so they can assess whether overlapping supply is appropriate.
- Answer expiry (grace period): After a plan or order ends, the patient has a grace period of plan duration + 1 month to reorder. If that window passes, all consultation answers are cleared and they must start a fresh consultation. (e.g. 3-month plan = 4-month grace, 6-month plan = 7-month grace, one-off = 1 month grace). Configurable per product.
- POM vs P: POM requires prescriber + SignatureRx Rx. P requires pharmacist approval (logged, no Rx). Both support instalments.
Error / Exception Paths
All rejection and error scenarios with refund status.
| Scenario | What happens | Refund? | Terminal state |
|---|---|---|---|
| Auto-denial from form logic | Patient told treatment not suitable, advised to see GP | No — before payment | Auto-Denied |
| Payment fails at checkout | Patient shown error, can retry | N/A — never captured | Awaiting Payment |
| ID check fails | Upload requested → manual review → if still fails, rejected | Yes — via Stripe | Rejected → Refunded |
| Clinician requests more info | Patient messaged, consultation paused | No — still active | Awaiting Response |
| Clinician denies treatment | Reason logged, patient notified after refund confirmed | Yes — via Stripe | Rejected → Refunded |
| Repeat submission detected | Flag shown to clinician during Phase 6 review | No — informational | Flagged for Review |
| Consultation abandoned | Reminder email sent. Flagged at 7 days, abandonable at 30 days. | N/A — before payment | Abandoned (Draft) |
| Patient requests cancellation | Message to pharmacy team. Manual cancel + refund. | Yes — manual | Cancelled → Refunded |
| Consultation timeout (30 days) | Team can reject/refund after 30 days. | Yes — manual | Abandoned → Refunded |
| Delivery failed / returned | Delivery Failed screen. Team re-dispatches, contacts, or refunds. | Depends on action | Delivery Failed |
| API unavailable (any) | Order tagged "Pending (API Unavailable)". Auto-retry: 5min → 30min → 2hr → flag manual. | No — still active | Pending (API Down) |
| Instalment payment fails (month 2+) | Pharmacy notified. Patient contacted. Dispatch paused. | May cancel remaining | Instalment Paused |
| 12-month hard limit reached | Patient cannot renew. Must complete full new consultation. | No — not an error | Consultation Required |
API Integrations
All external system integrations with direction and timing.
| System | API | Direction | When |
|---|---|---|---|
| LexisNexis IDU | Identity verification | Website → LexisNexis | Phase 4 — after payment |
| SignatureRx | Create Prescription | Website → SignatureRx | Phase 7 — prescriber approves POM |
| SignatureRx | Signed Rx webhook | SignatureRx → Website | Phase 7 → triggers Phase 8 (GP letter + patient msg + pharmacy queue) |
| Royal Mail | Create Shipment | Website → Royal Mail | Phase 11 — after order packed |
| Royal Mail | Tracking webhook | Royal Mail → Website | Phase 12 — delivery updates |
| TitanPMR | Patient data push | Website → TitanPMR | Phase 9 — after order confirmed |
| Stripe | Full capture / first instalment | Website → Stripe | Phase 3 — after plan selection |
| Stripe | Recurring instalment charge | Stripe → auto-charge | Phase 13 — monthly for instalment plans |
| Stripe | Refund confirmation webhook | Stripe → Website | After team issues refund |
Optional Extras
Features we ideally want but can be deferred. These are not blockers — the core flow works without them.
| Priority | Feature | What it does | Where | Fallback |
|---|---|---|---|---|
| High | Stock management | Track stock levels, block dispatch if out of stock | Phase 11 | Manual tracking |
| High | TitanPMR API | Auto-push patient data to PMR | Phase 9 | Manual export |
| Medium | Royal Mail tracking webhook | Auto-update delivery status | Phase 12 | Manual status update |
| Medium | Notification batching | Digest emails for prescribers | Phase 5 | Immediate per case |
| Medium | Answer-diff detection | Compare repeat submission answers | Phase 10 | Manual comparison |
| Low | Low-stock alerts | Email when stock is low | Phase 11 | Depends on stock mgmt |