⚠️ This is a backend issue — work is done inside the backend/ folder
Description
PrescriptionsService has a getRefillReminders() method that calculates which prescriptions are due for refill, and a RefillReminder interface is defined. However, this method is never called automatically — reminders are only returned if the frontend explicitly polls the endpoint. Pet owners miss refill windows because no proactive notification is sent.
Current State
backend/src/modules/prescriptions/prescriptions.service.ts — getRefillReminders() exists
RefillReminder interface is defined with daysUntilRefill and estimatedRefillDate
- No cron job or BullMQ scheduler calls
getRefillReminders()
NotificationsService is not injected into PrescriptionsService
What Needs to Be Built
1. Inject NotificationsService into PrescriptionsService
- Add
NotificationsService to PrescriptionsModule imports and constructor
2. Refill Reminder Scheduler (prescriptions/prescription-reminder.scheduler.ts)
@Injectable()
export class PrescriptionReminderScheduler {
@Cron('0 9 * * *') // Daily at 9am
async sendRefillReminders() {
const reminders = await this.prescriptionsService.getRefillReminders();
for (const reminder of reminders) {
if (reminder.daysUntilRefill <= 3) {
await this.notificationsService.create({ ... });
}
}
}
}
3. Notification Content
- Title:
Refill Reminder: {medication}
- Body:
{petName}'s {medication} needs a refill in {daysUntilRefill} days (est. {estimatedRefillDate})
- Category:
MEDICATION
- Deep link to prescription detail page
4. Deduplication
- Track sent reminders in Redis with key
refill_reminder:{prescriptionId}:{date} TTL 24h
- Skip if reminder already sent today for this prescription
Acceptance Criteria
Files to Create / Modify
backend/src/modules/prescriptions/prescription-reminder.scheduler.ts (new)
backend/src/modules/prescriptions/prescriptions.module.ts (register scheduler)
backend/src/modules/prescriptions/prescriptions.service.ts (inject NotificationsService)
backend/src/modules/prescriptions/prescription-reminder.scheduler.spec.ts (new)
Priority
High — refill reminders are calculated but never delivered
Estimated Effort
1–2 days
backend/folderDescription
PrescriptionsServicehas agetRefillReminders()method that calculates which prescriptions are due for refill, and aRefillReminderinterface is defined. However, this method is never called automatically — reminders are only returned if the frontend explicitly polls the endpoint. Pet owners miss refill windows because no proactive notification is sent.Current State
backend/src/modules/prescriptions/prescriptions.service.ts—getRefillReminders()existsRefillReminderinterface is defined withdaysUntilRefillandestimatedRefillDategetRefillReminders()NotificationsServiceis not injected intoPrescriptionsServiceWhat Needs to Be Built
1. Inject NotificationsService into PrescriptionsService
NotificationsServicetoPrescriptionsModuleimports and constructor2. Refill Reminder Scheduler (
prescriptions/prescription-reminder.scheduler.ts)3. Notification Content
Refill Reminder: {medication}{petName}'s {medication} needs a refill in {daysUntilRefill} days (est. {estimatedRefillDate})MEDICATION4. Deduplication
refill_reminder:{prescriptionId}:{date}TTL 24hAcceptance Criteria
PrescriptionsModuleFiles to Create / Modify
backend/src/modules/prescriptions/prescription-reminder.scheduler.ts(new)backend/src/modules/prescriptions/prescriptions.module.ts(register scheduler)backend/src/modules/prescriptions/prescriptions.service.ts(inject NotificationsService)backend/src/modules/prescriptions/prescription-reminder.scheduler.spec.ts(new)Priority
High — refill reminders are calculated but never delivered
Estimated Effort
1–2 days