@peopl-health/nexus 5.68.4 → 5.69.0-dev.12295
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.
|
@@ -62,6 +62,7 @@ const CONTACT_SENT = {
|
|
|
62
62
|
const RECENT_OUTBOUND_HOURS = 24;
|
|
63
63
|
const COLLIDING_REMINDER_MINUTES = 24 * 60;
|
|
64
64
|
const INACTIVITY_DAYS = 7;
|
|
65
|
+
const MAX_SILENCE_DAYS = 30;
|
|
65
66
|
const TRIAGE_PROTECTION_START_MINUTE = (7 * 60) + 30;
|
|
66
67
|
const TRIAGE_PROTECTION_END_MINUTE = 11 * 60;
|
|
67
68
|
|
|
@@ -269,11 +270,13 @@ async function rejectionReason(candidate, {
|
|
|
269
270
|
if (!await mondayTriageStillPending(candidate)) return 'triage_no_longer_pending';
|
|
270
271
|
} else if (cadence === 'daily') {
|
|
271
272
|
const inactiveSince = moment.tz(now, DEFAULT_TIMEZONE).subtract(INACTIVITY_DAYS, 'days').toDate();
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
{
|
|
273
|
+
const silentSince = moment.tz(now, DEFAULT_TIMEZONE).subtract(MAX_SILENCE_DAYS, 'days').toDate();
|
|
274
|
+
const [lastInbound] = await getMessages(
|
|
275
|
+
{ numero: candidate.code, from_me: false, createdAt: { $gte: silentSince } },
|
|
276
|
+
{ select: { createdAt: 1 }, sort: { createdAt: -1 }, limit: 1 },
|
|
275
277
|
);
|
|
276
|
-
if (
|
|
278
|
+
if (!lastInbound) return 'patient_silent_beyond_max_window';
|
|
279
|
+
if (new Date(lastInbound.createdAt) >= inactiveSince) return 'patient_active_within_inactivity_window';
|
|
277
280
|
|
|
278
281
|
const lastTriageAt = candidate?.brief?.lastTriageAt;
|
|
279
282
|
if (lastTriageAt && moment.tz(lastTriageAt, DEFAULT_TIMEZONE).isSameOrAfter(inactiveSince)) {
|