@peopl-health/nexus 6.0.12 → 6.0.13
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,4 +1,5 @@
|
|
|
1
1
|
const { Monitoreo_ID } = require('../config/airtableConfig');
|
|
2
|
+
const { programSourceFormula } = require('../config/programConfig');
|
|
2
3
|
|
|
3
4
|
const { escapeFormulaValue } = require('../helpers/airtableFormulaHelper');
|
|
4
5
|
|
|
@@ -16,15 +17,16 @@ async function getEscalationApprover(email) {
|
|
|
16
17
|
const normalized = String(email ?? '').trim().toLowerCase();
|
|
17
18
|
if (!normalized) return null;
|
|
18
19
|
|
|
19
|
-
const formula = `AND(LOWER({email}) = '${escapeFormulaValue(normalized)}', {aprueba_vaiven})`;
|
|
20
|
+
const formula = `AND(LOWER({email}) = '${escapeFormulaValue(normalized)}', {aprueba_vaiven}, ${programSourceFormula()})`;
|
|
20
21
|
const [physician] = await getRecordByFilter(Monitoreo_ID, 'physicians', formula, null, APPROVER_FIELDS, true) || [];
|
|
21
22
|
if (!physician) return null;
|
|
22
23
|
|
|
23
24
|
return approverOf(physician, normalized);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
// A physician approves escalations only for the programs ticked on their row.
|
|
26
28
|
async function listEscalationApprovers() {
|
|
27
|
-
const physicians = await getRecordByFilter(Monitoreo_ID, 'physicians',
|
|
29
|
+
const physicians = await getRecordByFilter(Monitoreo_ID, 'physicians', `AND({aprueba_vaiven}, ${programSourceFormula()})`, null, APPROVER_FIELDS, true) || [];
|
|
28
30
|
return physicians.filter((physician) => physician.email).map((physician) => approverOf(physician));
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -2,6 +2,7 @@ const axios = require('axios');
|
|
|
2
2
|
|
|
3
3
|
const runtimeConfig = require('../config/runtimeConfig');
|
|
4
4
|
const { Monitoreo_ID } = require('../config/airtableConfig');
|
|
5
|
+
const { programSourceFormula } = require('../config/programConfig');
|
|
5
6
|
const { logger } = require('../utils/logger');
|
|
6
7
|
const { PATIENT_CODE, redactDirectIdentifiers } = require('../utils/sanitizerUtils');
|
|
7
8
|
const { withTimeout } = require('../utils/timeoutUtils');
|
|
@@ -38,8 +39,9 @@ function configuredPhones() {
|
|
|
38
39
|
.filter((code) => PATIENT_CODE.test(code));
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
// Only the members on call for this program; a member with no program gets no alert.
|
|
41
43
|
async function readRoster() {
|
|
42
|
-
const rows = await airtableService.getRecordByFilter(Monitoreo_ID, ROSTER_TABLE,
|
|
44
|
+
const rows = await airtableService.getRecordByFilter(Monitoreo_ID, ROSTER_TABLE, `AND({activo}, ${programSourceFormula()})`, null, ROSTER_FIELDS);
|
|
43
45
|
if (!Array.isArray(rows)) throw new Error('The on-call roster could not be read');
|
|
44
46
|
return rows
|
|
45
47
|
.map((row) => ({ code: whatsAppCodeOf(row.whatsapp), levels: Array.isArray(row.sin_tomar) ? row.sin_tomar : [] }))
|