@peopl-health/nexus 5.57.0-dev.9698 → 5.57.0-dev.9718
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { firstOf } = require('../../utils/coercionUtils');
|
|
2
2
|
const { toIsoInstant } = require('../../utils/dateUtils');
|
|
3
3
|
const { foldAccents } = require('../../utils/formatUtils');
|
|
4
|
-
const { sanitizeInlineText } = require('../../utils/sanitizerUtils');
|
|
4
|
+
const { WHATSAPP_PATIENT_CODE, sanitizeInlineText } = require('../../utils/sanitizerUtils');
|
|
5
5
|
|
|
6
6
|
const PROVENANCE = {
|
|
7
7
|
auna: { source: 'legacy-clinician', trust: 0.5 },
|
|
@@ -40,15 +40,13 @@ const SENTINELS = [
|
|
|
40
40
|
/^no (he recibido|tengo) (alguno|ningun[oa])( mas)?$/,
|
|
41
41
|
];
|
|
42
42
|
|
|
43
|
-
const VALID_ID = /^whatsapp:\+\d{10,15}$/;
|
|
44
|
-
|
|
45
43
|
const clean = (s) => sanitizeInlineText(s, Infinity);
|
|
46
44
|
const fold = (s) => foldAccents(clean(s)).toLowerCase().replace(/[.;,]+$/, '');
|
|
47
45
|
const isSentinel = (s) => SENTINELS.some((re) => re.test(fold(s)));
|
|
48
46
|
|
|
49
47
|
const patientIdFrom = (record) => {
|
|
50
48
|
const id = clean(firstOf(record?.whatsapp_id));
|
|
51
|
-
return
|
|
49
|
+
return WHATSAPP_PATIENT_CODE.test(id) ? id : null;
|
|
52
50
|
};
|
|
53
51
|
|
|
54
52
|
function candidatesFor(record) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { Monitoreo_ID } = require('../config/airtableConfig');
|
|
2
2
|
|
|
3
3
|
const { httpError } = require('../utils/httpErrorUtils');
|
|
4
|
+
const { WHATSAPP_PATIENT_CODE } = require('../utils/sanitizerUtils');
|
|
4
5
|
|
|
5
6
|
const { escapeFormulaValue, fieldEquals, recordIdIn } = require('../helpers/airtableFormulaHelper');
|
|
6
7
|
const {
|
|
@@ -19,7 +20,6 @@ const { clearOpenTaskSummary } = require('../services/patientTaskSummaryService'
|
|
|
19
20
|
|
|
20
21
|
const MAX_ROWS = 50;
|
|
21
22
|
const MAX_NOTE_LENGTH = 5000;
|
|
22
|
-
const WHATSAPP_ID_RX = /^whatsapp:\+\d{10,15}$/;
|
|
23
23
|
const RECORD_ID_RX = /^rec[A-Za-z0-9]{14}$/;
|
|
24
24
|
|
|
25
25
|
const REQUEST_STATUSES = [
|
|
@@ -130,7 +130,7 @@ const TASK_KINDS = {
|
|
|
130
130
|
|
|
131
131
|
const validWhatsappId = (code) => {
|
|
132
132
|
const whatsappId = String(code || '').trim();
|
|
133
|
-
if (!
|
|
133
|
+
if (!WHATSAPP_PATIENT_CODE.test(whatsappId)) throw httpError(400, 'A whatsapp:+<digits> patient code is required');
|
|
134
134
|
return whatsappId;
|
|
135
135
|
};
|
|
136
136
|
|