⚠️ This is a backend issue — work is done inside the backend/ folder
Description
PrescriptionsService imports and injects DrugInteractionService from backend/src/modules/prescriptions/services/drug-interaction.service.ts, but this file contains only a stub. When a new prescription is created, no interaction check is performed, meaning dangerous drug combinations can be silently saved.
Current State
backend/src/modules/prescriptions/services/drug-interaction.service.ts — stub/empty
PrescriptionsService.create() calls this.drugInteractionService.check() but receives no real result
- No interaction data source is defined
What Needs to Be Built
1. Interaction Data Source
- Define a static JSON dataset of known drug interactions (common veterinary medications)
- Or integrate with an external API (e.g. RxNorm / custom vet drug DB) via HTTP
- Store interaction rules in a
drug_interactions DB table with severity levels: MILD, MODERATE, SEVERE, CONTRAINDICATED
2. DrugInteractionService
@Injectable()
export class DrugInteractionService {
async check(
newMedication: string,
existingMedications: string[],
): Promise<InteractionResult[]>
}
export interface InteractionResult {
drug1: string;
drug2: string;
severity: 'MILD' | 'MODERATE' | 'SEVERE' | 'CONTRAINDICATED';
description: string;
}
3. Integration in PrescriptionsService
- On
create(), fetch all active prescriptions for the pet
- Run interaction check against new medication
- If
CONTRAINDICATED or SEVERE: throw BadRequestException with interaction details
- If
MODERATE: save prescription but attach a warning in the response
- If
MILD: save silently, log warning
4. New Endpoint
POST /prescriptions/check-interactions
Body: { petId, medication }
- Allows frontend to check interactions before submitting a prescription form
Acceptance Criteria
Files to Create / Modify
backend/src/modules/prescriptions/services/drug-interaction.service.ts (implement)
backend/src/modules/prescriptions/prescriptions.service.ts (integrate check)
backend/src/modules/prescriptions/prescriptions.controller.ts (add check endpoint)
backend/src/modules/prescriptions/dto/check-interaction.dto.ts (new)
backend/src/modules/prescriptions/services/drug-interaction.service.spec.ts (new)
Priority
High — patient safety feature
Estimated Effort
2–3 days
backend/folderDescription
PrescriptionsServiceimports and injectsDrugInteractionServicefrombackend/src/modules/prescriptions/services/drug-interaction.service.ts, but this file contains only a stub. When a new prescription is created, no interaction check is performed, meaning dangerous drug combinations can be silently saved.Current State
backend/src/modules/prescriptions/services/drug-interaction.service.ts— stub/emptyPrescriptionsService.create()callsthis.drugInteractionService.check()but receives no real resultWhat Needs to Be Built
1. Interaction Data Source
drug_interactionsDB table with severity levels:MILD,MODERATE,SEVERE,CONTRAINDICATED2. DrugInteractionService
3. Integration in PrescriptionsService
create(), fetch all active prescriptions for the petCONTRAINDICATEDorSEVERE: throwBadRequestExceptionwith interaction detailsMODERATE: save prescription but attach a warning in the responseMILD: save silently, log warning4. New Endpoint
Acceptance Criteria
CONTRAINDICATEDcombinations are blocked with a descriptive errorMODERATEinteractions return a warning alongside the saved prescriptionPOST /prescriptions/check-interactionsreturns interaction results without savingFiles to Create / Modify
backend/src/modules/prescriptions/services/drug-interaction.service.ts(implement)backend/src/modules/prescriptions/prescriptions.service.ts(integrate check)backend/src/modules/prescriptions/prescriptions.controller.ts(add check endpoint)backend/src/modules/prescriptions/dto/check-interaction.dto.ts(new)backend/src/modules/prescriptions/services/drug-interaction.service.spec.ts(new)Priority
High — patient safety feature
Estimated Effort
2–3 days