Overview
Prescriptions are shipped from clinics to pharmacies using DHL Express. The system pre-generates tracking numbers and automatically schedules pickups.How It Works
Basic Flow
- Doctor creates prescription and selects “Send via ADHD Simple”
- System creates shipment with pre-generated DHL tracking number
- DHL pickup is automatically scheduled via API
- DHL collects from clinic and delivers to pharmacy
- Pharmacy processes and ships to patients
Bulk Shipments
Clinics can create up to 10 pre-labeled shipments at once for busy periods.Code Examples
Create Single Shipment
List Shipments
DHL Integration
Pickup Scheduling
- Automatic scheduling via DHL Express API
- Pre-generated tracking numbers (no waiting for collection)
- Van pickup confirmation emails sent automatically
Tracking
- Real-time tracking updates from DHL
- Delivery notifications to pharmacies
- Patient delivery confirmation
Pharmacy Processing
Arrival Verification
- Package arrives at pharmacy
- Pharmacist marks as arrived in system
- Contents verified against manifest
- Discrepancies logged if found
Patient Shipping
- Pharmacist reviews individual prescriptions
- Creates DHL Express labels for patients
- Packages medication with labels
- Hands to DHL courier with scan out
Edge Functions
The system uses these Supabase Edge Functions:clinical-shipment-operations- Consolidated shipment management for doctors and pharmaciesdhl-tracking-webhook- Receive DHL tracking updates
Database Tables
Key tables involved:shipments- Main shipment records with DHL trackingshipment_prescriptions- Links prescriptions to shipmentsshipment_tracking_events- Tracking history from DHLpatient_shipments- Individual patient deliveries from pharmacy
Error Handling
Common issues and handling:- DHL API failures - Fallback to manual scheduling
- Missing tracking updates - Retry mechanism with exponential backoff
- Content discrepancies - Pharmacy notification and clinic contact system
This is a simplified overview. The actual implementation includes additional error handling, validation, and edge cases for production use.