@peopl-health/nexus 6.1.0-dev.18187 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -425,6 +425,17 @@ async function recordReminder({ code, trace, actionType, reminderId, reminderDat
|
|
|
425
425
|
});
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
async function isReminderPending({ code, reminderId }) {
|
|
429
|
+
const rows = await airtableService.getRecordByFilter(
|
|
430
|
+
Monitoreo_ID,
|
|
431
|
+
'reminder',
|
|
432
|
+
`AND(${fieldEquals('whatsapp_id', code)}, ${fieldEquals('schedule_id', reminderId)}, ${PENDING_ROW_FILTER})`,
|
|
433
|
+
null,
|
|
434
|
+
['schedule_id'],
|
|
435
|
+
);
|
|
436
|
+
return rows.length > 0;
|
|
437
|
+
}
|
|
438
|
+
|
|
428
439
|
async function hasPendingContingencyRow({ planId }) {
|
|
429
440
|
const rows = await airtableService.getRecordByFilter(
|
|
430
441
|
Monitoreo_ID,
|
|
@@ -759,6 +770,7 @@ module.exports = {
|
|
|
759
770
|
recordClinicalIntake,
|
|
760
771
|
recordReminder,
|
|
761
772
|
hasPendingContingencyRow,
|
|
773
|
+
isReminderPending,
|
|
762
774
|
hasPendingReminderForPatient,
|
|
763
775
|
readPendingFollowUpsForPatient,
|
|
764
776
|
readPendingReminderForPatient,
|
|
@@ -2,7 +2,7 @@ const moment = require('moment-timezone');
|
|
|
2
2
|
|
|
3
3
|
const { isShadowRun } = require('../helpers/shadowHelper');
|
|
4
4
|
const { dispatchReminder } = require('../services/reminderDispatchService');
|
|
5
|
-
const { recordReminder, readPendingFollowUpsForPatient, cancelFollowUp, cancelPendingFollowUps } = require('../services/clinicalAirtableService');
|
|
5
|
+
const { recordReminder, readPendingFollowUpsForPatient, cancelFollowUp, cancelPendingFollowUps, isReminderPending } = require('../services/clinicalAirtableService');
|
|
6
6
|
const { isWithinTriageProtectionWindow } = require('../services/outreachSweepService');
|
|
7
7
|
const { UTILITY_BASES, sanitizeVariable } = require('../services/outreachCarrierService');
|
|
8
8
|
const { logger } = require('../../utils/logger');
|
|
@@ -149,6 +149,9 @@ async function handler(args = {}, context = {}) {
|
|
|
149
149
|
return JSON.stringify({ success: false, error: 'checkins_paused — the patient asked for fewer messages; do not schedule a seguimiento before the pause ends.', data: { paused_until: moment(pausedUntil).tz(timeZone).format('YYYY-MM-DDTHH:mm') } });
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
+
if (actionType === 'update' && targetId && runtime.patientCode && !await isReminderPending({ code: runtime.patientCode, reminderId: targetId })) {
|
|
153
|
+
return JSON.stringify({ success: false, error: 'reminder_not_active — that reminder already went out or was stood down, so it cannot be updated. If a check is still needed, create a new one.', data: { reminder_id: targetId } });
|
|
154
|
+
}
|
|
152
155
|
if (isRoutineOutreach && actionType === 'create' && runtime.patientCode) {
|
|
153
156
|
if (await botIsPaused(runtime.patientCode, { label: '[schedulePatientReminder]' })) {
|
|
154
157
|
return JSON.stringify({ success: false, error: PAUSED_ERROR, data: {} });
|