⚠️ This is a backend issue — work is done inside the backend/ folder
Description
backend/src/modules/conditions/conditions.service.ts has full CRUD for pet health conditions and sorts by severity DESC, but there is no alerting when a critical condition is created or when a condition's severity is escalated. Vets and owners are not notified when a pet is diagnosed with a critical condition.
Current State
ConditionsService — CRUD only, no notification logic
Condition entity has a severity field (assumed enum: LOW, MEDIUM, HIGH, CRITICAL)
NotificationsService is not injected into ConditionsModule
- No severity escalation detection on
update()
What Needs to Be Built
1. Inject NotificationsService
- Add
NotificationsModule to ConditionsModule imports
- Inject
NotificationsService into ConditionsService
2. Alert on Critical Condition Creation
In ConditionsService.create():
if (dto.severity === ConditionSeverity.CRITICAL) {
await this.notificationsService.create({
userId: pet.ownerId,
title: 'Critical Condition Diagnosed',
body: `${pet.name} has been diagnosed with a critical condition: ${dto.name}`,
category: NotificationCategory.ALERT,
});
}
3. Alert on Severity Escalation
In ConditionsService.update():
- Load the existing condition before updating
- If
severity changes from non-critical to CRITICAL: send alert
- If
severity changes from CRITICAL to lower: send a resolution notification
4. Vet Notification
- Also notify the assigned vet (if
vetId is present on the condition) for CRITICAL and HIGH severity
5. Audit Logging
- Log severity changes via
AuditService with action: UPDATE and metadata containing old/new severity
Acceptance Criteria
Files to Modify
backend/src/modules/conditions/conditions.service.ts
backend/src/modules/conditions/conditions.module.ts
backend/src/modules/conditions/conditions.service.spec.ts (new)
Priority
High — critical diagnoses must trigger immediate owner notification
Estimated Effort
1–2 days
backend/folderDescription
backend/src/modules/conditions/conditions.service.tshas full CRUD for pet health conditions and sorts byseverity DESC, but there is no alerting when a critical condition is created or when a condition's severity is escalated. Vets and owners are not notified when a pet is diagnosed with a critical condition.Current State
ConditionsService— CRUD only, no notification logicConditionentity has aseverityfield (assumed enum:LOW,MEDIUM,HIGH,CRITICAL)NotificationsServiceis not injected intoConditionsModuleupdate()What Needs to Be Built
1. Inject NotificationsService
NotificationsModuletoConditionsModuleimportsNotificationsServiceintoConditionsService2. Alert on Critical Condition Creation
In
ConditionsService.create():3. Alert on Severity Escalation
In
ConditionsService.update():severitychanges from non-critical toCRITICAL: send alertseveritychanges fromCRITICALto lower: send a resolution notification4. Vet Notification
vetIdis present on the condition) forCRITICALandHIGHseverity5. Audit Logging
AuditServicewithaction: UPDATEand metadata containing old/new severityAcceptance Criteria
CRITICALcondition sends an immediate alert to the pet ownerCRITICALsends an alertCRITICALcondition sends a resolution notificationCRITICALandHIGHseverity conditionsFiles to Modify
backend/src/modules/conditions/conditions.service.tsbackend/src/modules/conditions/conditions.module.tsbackend/src/modules/conditions/conditions.service.spec.ts(new)Priority
High — critical diagnoses must trigger immediate owner notification
Estimated Effort
1–2 days