Dispense Service
Pipeline-Managed Service
This service is deployed and managed by its CI/CD pipeline.
For current deployment status, configurations, and code:
- Repository:
https://repo.local/healthflow/ndp-dispense-service - CI/CD Status: Check pipeline dashboard
- API Docs: See repository
/docs/api
Overview
The Dispense Service tracks medication dispensing at pharmacies, validates prescriptions before dispensing, and maintains a complete dispensing history.
Purpose
- Validate prescriptions before dispensing
- Record medication dispensing events
- Track partial dispensing
- Prevent duplicate dispensing
- Maintain dispensing history
- Generate dispensing reports
- Publish dispensing events
Architecture
Key Features
1. Prescription Validation
- Verify prescription authenticity
- Check prescription status (not expired, not fully dispensed)
- Validate pharmacy authorization
- Check dispensing limits
- Verify pharmacist credentials
2. Dispensing Recording
- Record full or partial dispensing
- Track dispensed quantity vs prescribed
- Generate dispense ID
- Update prescription status
- Link to pharmacy and pharmacist
3. Dispensing History
- Query dispense records
- Search by prescription ID
- Search by patient ID
- Search by pharmacy
- Audit trail of all dispenses
API Endpoints
POST /api/v1/dispenses # Record dispensing
GET /api/v1/dispenses/:id # Get dispense record
GET /api/v1/dispenses # Search dispenses
GET /api/v1/prescriptions/:id/dispenses # Get prescription dispenses
POST /api/v1/dispenses/:id/verify # Verify dispensing
# Health & Monitoring
GET /health/live
GET /health/ready
GET /metricsData Model
typescript
interface Dispense {
id: string;
prescriptionId: string;
dispensedAt: Date;
// Pharmacy Info
pharmacyId: string;
pharmacyName: string;
pharmacistId: string;
pharmacistName: string;
// Dispensed Items
items: DispensedItem[];
// Payment
totalAmount: number;
copayment: number;
insuranceCoverage: number;
// Status
status: "COMPLETED" | "CANCELLED";
// Metadata
createdAt: Date;
version: number;
}
interface DispensedItem {
medicineCode: string;
medicineName: string;
quantityDispensed: number;
quantityPrescribed: number;
batchNumber: string;
expiryDate: Date;
unitPrice: number;
totalPrice: number;
}Business Rules
- Prescription must be active and valid
- Pharmacy must be accredited
- Pharmacist must be authorized
- Cannot dispense more than prescribed
- Cannot dispense expired medications
- Partial dispensing allowed
- Full audit trail required
Kafka Events
yaml
# Dispense Recorded
ndp.events.dispense.recorded:
dispenseId: uuid
prescriptionId: uuid
pharmacyId: string
timestamp: datetime
# Prescription Fully Dispensed
ndp.events.prescription.fully_dispensed:
prescriptionId: uuid
completedAt: datetime