@peopl-health/nexus 5.72.10 → 5.72.12
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.
- package/lib/clinical/helpers/triageCaseBaseHelper.js +1 -1
- package/lib/clinical/services/outreachSweepService.js +2 -1
- package/lib/controllers/assistantController.js +5 -0
- package/lib/controllers/messageController.js +2 -2
- package/lib/helpers/caregiverHelper.js +2 -2
- package/lib/helpers/twilioHelper.js +4 -1
- package/package.json +1 -1
|
@@ -301,7 +301,7 @@ function buildSymptomChangeBlock(symptomsChange = []) {
|
|
|
301
301
|
.map((entry) => {
|
|
302
302
|
const absent = ABSENT_CHANGE_RX.exec(entry);
|
|
303
303
|
if (!absent) return `- ${entry}`;
|
|
304
|
-
return `- ${entry} → el paciente marcó «Nunca tuve este síntoma» para "${absent[1]}". Si este triaje le da grado a ese síntoma, la respuesta se contradice y
|
|
304
|
+
return `- ${entry} → el paciente marcó «Nunca tuve este síntoma» para "${absent[1]}". Si este triaje le da grado a ese síntoma, la respuesta se contradice: vale el grado (no lo bajes ni lo descartes), pero en el resumen interno escribe «respuesta contradictoria: marcó Nunca tuve y el cuestionario le da grado N», pide caracterización y que lo primero sea confirmar si lo tuvo estos días. Al paciente no se lo presentes como un hecho («reportas náusea»): dile que en el cuestionario lo marcó y pídele que te confirme si lo tuvo`;
|
|
305
305
|
})
|
|
306
306
|
.join('\n');
|
|
307
307
|
}
|
|
@@ -6,6 +6,7 @@ const { getMessages } = require('../../services/messageService');
|
|
|
6
6
|
const { DEFAULT_TIMEZONE, isWithinHourWindow } = require('../../utils/scheduleUtils');
|
|
7
7
|
const { logger } = require('../../utils/logger');
|
|
8
8
|
const { botIsPaused } = require('../../helpers/pausedThreadHelper');
|
|
9
|
+
const { isArchivedPatientCode } = require('../../helpers/twilioHelper');
|
|
9
10
|
const { Thread } = require('../../models/threadModel');
|
|
10
11
|
const { PATIENT_CONTACT_WINDOW } = require('./contingencyDispatchService');
|
|
11
12
|
const { hasPendingReminderForPatient } = require('./clinicalAirtableService');
|
|
@@ -175,7 +176,7 @@ function buildCandidates(rows, { now, cadence = 'daily', mode = 'continuity' })
|
|
|
175
176
|
// store, and stops the thread resolving at all.
|
|
176
177
|
const code = String(first(row[F.whatsapp]) || '').trim();
|
|
177
178
|
const name = String(first(row[F.firstName]) || '').trim();
|
|
178
|
-
if (!code || !name) {
|
|
179
|
+
if (!code || !name || isArchivedPatientCode(code)) {
|
|
179
180
|
logger.info('[outreachSweep] candidate skipped — missing code or name', { recordId: row._recordId });
|
|
180
181
|
continue;
|
|
181
182
|
}
|
|
@@ -2,6 +2,7 @@ const { Config_ID } = require('../config/airtableConfig');
|
|
|
2
2
|
const runtimeConfig = require('../config/runtimeConfig');
|
|
3
3
|
|
|
4
4
|
const { logger } = require('../utils/logger');
|
|
5
|
+
const { isArchivedPatientCode } = require('../helpers/twilioHelper');
|
|
5
6
|
const { AssistantMessageError, injectAssistantMessages } = require('../services/assistantMessageService');
|
|
6
7
|
|
|
7
8
|
const { getThreadInfo, setThreadDoNotAlert, switchThreadStoppedStatus } = require('../services/threadService');
|
|
@@ -89,6 +90,10 @@ const createAssistantController = async (req, res) => {
|
|
|
89
90
|
|
|
90
91
|
try {
|
|
91
92
|
for (const code of codes) {
|
|
93
|
+
if (isArchivedPatientCode(code)) {
|
|
94
|
+
logger.warn('[AssistantController] Skipped an archived patient code', { code });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
92
97
|
await createAssistant(code, assistant_id, [...instrucciones, ...messages], force);
|
|
93
98
|
for (const message of messages) {
|
|
94
99
|
await sendMessage({ code, body: message, fileType: 'text' });
|
|
@@ -8,7 +8,7 @@ const { ScheduledMessage } = require('../models/agendaMessageModel.js');
|
|
|
8
8
|
const { DeliveryAttempt, DELIVERY_ATTEMPT_LANDED_STATUSES } = require('../models/deliveryAttemptModel.js');
|
|
9
9
|
const { FlowRouting } = require('../models/flowRoutingModel.js');
|
|
10
10
|
|
|
11
|
-
const { ensureWhatsAppFormat, stripWhatsAppFormat } = require('../helpers/twilioHelper');
|
|
11
|
+
const { ensureWhatsAppFormat, stripWhatsAppFormat, isArchivedPatientCode } = require('../helpers/twilioHelper');
|
|
12
12
|
const { ensureFlowTokenInVariables } = require('../helpers/templateFlowControllerHelper');
|
|
13
13
|
const { CAREGIVER_ROLE, resolveCaregiver } = require('../helpers/caregiverHelper');
|
|
14
14
|
|
|
@@ -223,7 +223,7 @@ const sendBulkMessageAirtableController = async (req, res) => {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
let code = Array.isArray(row[columnPhone]) ? row[columnPhone][0] : row[columnPhone];
|
|
226
|
-
if (!code) continue;
|
|
226
|
+
if (!code || isArchivedPatientCode(code)) continue;
|
|
227
227
|
code = ensureWhatsAppFormat(code);
|
|
228
228
|
if (sentPhones.has(code)) continue;
|
|
229
229
|
sentPhones.add(code);
|
|
@@ -6,7 +6,7 @@ const { MapCache } = require('../utils/MapCache');
|
|
|
6
6
|
const { getRecordByFilter } = require('../services/airtableService');
|
|
7
7
|
const { getMessages } = require('../services/messageService');
|
|
8
8
|
|
|
9
|
-
const { ensureWhatsAppFormat, stripWhatsAppFormat } = require('./twilioHelper');
|
|
9
|
+
const { ensureWhatsAppFormat, stripWhatsAppFormat, isArchivedPatientCode } = require('./twilioHelper');
|
|
10
10
|
const { escapeFormulaValue } = require('./airtableFormulaHelper');
|
|
11
11
|
|
|
12
12
|
const CAREGIVERS_FIELD = 'cuidadores_whatsapp';
|
|
@@ -46,7 +46,7 @@ async function lookupCaregiver(code) {
|
|
|
46
46
|
if (records.some((row) => row.whatsapp_id === code)) return null;
|
|
47
47
|
|
|
48
48
|
const matches = records
|
|
49
|
-
.filter((row) => row.whatsapp_id)
|
|
49
|
+
.filter((row) => row.whatsapp_id && !isArchivedPatientCode(row.whatsapp_id))
|
|
50
50
|
.map((row) => ({ row, caregiver: listedCaregivers(row[CAREGIVERS_FIELD]).find((entry) => entry.digits === digits) }))
|
|
51
51
|
.filter(({ caregiver }) => caregiver);
|
|
52
52
|
if (matches.length > 1) {
|
|
@@ -54,10 +54,13 @@ const stripWhatsAppFormat = (code) => {
|
|
|
54
54
|
return beforeAt.replace(/^\+/, '');
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
const isArchivedPatientCode = (code) => typeof code === 'string' && code.trim().startsWith('archived:');
|
|
58
|
+
|
|
57
59
|
module.exports = {
|
|
58
60
|
convertTwilioToInternalFormat,
|
|
59
61
|
getMediaTypeFromContentType,
|
|
60
62
|
extractTitle,
|
|
61
63
|
ensureWhatsAppFormat,
|
|
62
|
-
stripWhatsAppFormat
|
|
64
|
+
stripWhatsAppFormat,
|
|
65
|
+
isArchivedPatientCode
|
|
63
66
|
};
|