graph TD
A[Patient Arrives] --> B{Care Location}
B -->|Theatre| C[Operating Theatre]
B -->|Ward| D[Ward Care]
B -->|Recovery| E[Recovery Unit]
C --> F[Surgeon Preference List]
F --> G[Pre-loaded Items Bundle]
G --> H[Surgery Performed]
H --> I{Additional Items Needed?}
I -->|Yes| J[Staff Select from 20+ Options]
I -->|No| K[Record Usage in TrakCare]
J --> L{Correct Item Selected?}
L -->|No| M[ERROR: Wrong Item Recorded]
L -->|Yes| K
M --> K
D --> N[Staff Collect Items]
N --> O{Recording Method}
O -->|Paper Notes| P[Write on Paper]
O -->|Memory| Q[ERROR: Remember for Later]
O -->|Real-time| R[Direct Entry]
P --> S[End of Shift Entry]
Q --> T[ERROR: Memory-based Entry]
S --> K
T --> K
R --> K
E --> U[Patient Movement Issues]
U --> V[ERROR: Location Mismatch]
V --> K
K --> W[TrakCare System]
W --> X{Item Search Results}
X --> Y[ERROR: Staff Pick First Match]
Y --> Z[Usage Recorded - May be Wrong]
Z --> AA[1AM Daily Extract]
AA --> AB[Order Items Extract]
AA --> AC[Billing Data Extract]
AB --> AD[Admin Team Review 6AM]
AC --> AD
AD --> AE{Error Logs Present?}
AE -->|Yes| AF[Manual Corrections]
AE -->|No| AG[Import to Sage]
AF --> AH{Quantity Over 20 Alert?}
AH -->|Yes| AI[Alert Investigation]
AH -->|No| AG
AI --> AJ{Typo Confirmed?}
AJ -->|Yes| AK[Correction Made]
AJ -->|No| AL[Escalate Issue]
AK --> AG
AL --> AG
AG --> AM[Sage Inventory System]
AM --> AN[Theoretical Stock Levels]
AN --> AO{Database Anomalies?}
AO -->|Yes| AP[ERROR: Quantity Jumps]
AO -->|No| AQ[Stock Level Updates]
AP --> AR[ERROR: Data Integrity Issues]
AQ --> AS[Perpetual Inventory Record]
AR --> AS
AS --> AT{Physical Stock Check}
AT -->|Daily| AU[Visual Assessment 🤖]
AT -->|Annual| AV[15+ Staff Stocktake]
AU --> AW[Order by Observation 🤖]
AV --> AX[Manual Counting Sheets]
AX --> AY[Excel Data Entry]
AY --> AZ{Discrepancies Found?}
AZ -->|Yes| BA[ERROR: Six-Figure Write-offs]
AZ -->|No| BB[Records Aligned]
BA --> BC[Annual Adjustment]
BB --> BC
H --> BD[High-Value Items Used]
BD --> BE{Item Type}
BE -->|Prostheses| BF[ERROR: Paper-based Only]
BE -->|Regular| K
BF --> BG[Manual Labels]
BG --> BH{Label Available?}
BH -->|No| BI[ERROR: Hand-written Info]
BH -->|Yes| BJ[Stick Label to Paper]
BI --> BK[Data Entry Issues]
BJ --> BK
BK --> BL[ERROR: Missing from Analysis]
AG --> BM[Billing Team Validation 🤖]
BM --> BN{Bill Complete?}
BN -->|Missing| BO[Manual Addition]
BN -->|Too Many| BP[Send Back]
BN -->|Correct| BQ[Final Bill]
BO --> BR{Revenue Impact}
BP --> BS[Manual Re-check]
BQ --> BR
BS --> BQ
BR -->|Time and Materials| BT[ERROR: Revenue Loss]
BR -->|Fixed Fee| BU[Cost Absorbed]
BT --> BV[ERROR: 400K Annual Impact]
BU --> BW[No Revenue Impact]
classDef errorNode fill:#ffebee,stroke:#f44336,stroke-width:2px
classDef systemNode fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
classDef processNode fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px
classDef impactNode fill:#fff3e0,stroke:#ff9800,stroke-width:3px
class M,Q,T,V,Y,AP,AR,BA,BF,BI,BL,BT,BV errorNode
class W,AM,AS systemNode
class AA,AB,AC,AD,AG,BM processNode
class BV impactNode