@peopl-health/nexus 6.0.0-dev.16560 → 6.0.0-dev.16614

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,9 +1,11 @@
1
1
  const runtimeConfig = require('../../config/runtimeConfig');
2
2
 
3
3
  const flagOn = (key) => String(runtimeConfig.get(key, 'false')).trim().toLowerCase() === 'true';
4
+ // Launched behaviour stays on unless the variable is set to 'false'.
5
+ const flagNotOff = (key) => String(runtimeConfig.get(key, 'true')).trim().toLowerCase() !== 'false';
4
6
 
5
7
  function escalationUpdateModeLive() {
6
- return String(runtimeConfig.get('ESCALATION_UPDATE_MODE_LIVE', 'true')).trim().toLowerCase() !== 'false';
8
+ return flagNotOff('ESCALATION_UPDATE_MODE_LIVE');
7
9
  }
8
10
 
9
11
  function escalationAssessmentLive() {
@@ -11,7 +13,7 @@ function escalationAssessmentLive() {
11
13
  }
12
14
 
13
15
  function feverPatientTimerLive() {
14
- return flagOn('FEVER_PATIENT_TIMER_LIVE');
16
+ return flagNotOff('FEVER_PATIENT_TIMER_LIVE');
15
17
  }
16
18
 
17
19
  function escalationApproverAlertLive() {
@@ -19,15 +21,15 @@ function escalationApproverAlertLive() {
19
21
  }
20
22
 
21
23
  function escalationPatientTimerLive() {
22
- return flagOn('ESCALATION_PATIENT_TIMER_LIVE');
24
+ return flagNotOff('ESCALATION_PATIENT_TIMER_LIVE');
23
25
  }
24
26
 
25
27
  function escalationAutoHandoffLive() {
26
- return flagOn('ESCALATION_AUTO_HANDOFF_LIVE');
28
+ return flagNotOff('ESCALATION_AUTO_HANDOFF_LIVE');
27
29
  }
28
30
 
29
31
  function escalationUntakenAlertsLive() {
30
- return flagOn('ESCALATION_UNTAKEN_ALERTS_LIVE');
32
+ return flagNotOff('ESCALATION_UNTAKEN_ALERTS_LIVE');
31
33
  }
32
34
 
33
35
  module.exports = {
@@ -44,6 +44,7 @@ const { buildTriageResponse } = require('../../fhir/helpers/triagePayloadHelper'
44
44
  const { keyOf } = require('../../fhir/helpers/symptomAliasHelper');
45
45
  const { getCatalog } = require('../../fhir/services/terminologyService');
46
46
  const { getRecordByFilter } = require('../../services/airtableService');
47
+ const { findArchivedByRecordIds } = require('../../services/airtableArchiveReadService');
47
48
  const { RecommendationPlan } = require('../../shared/dtos/RecommendationPlan');
48
49
  const { recommendationId } = require('../../fhir/helpers/recommendationIds');
49
50
  const { RecommendationSafetyGate } = require('../../shared/dtos/RecommendationSafetyGate');
@@ -1130,8 +1131,9 @@ async function readPriorResolutions(adherence = [], patientRecordId = null) {
1130
1131
  .filter((id) => /^rec[A-Za-z0-9]+$/.test(id || ''));
1131
1132
  if (!ids.length) return [];
1132
1133
  const formula = `OR(${ids.map((id) => `{recordID}='${id}'`).join(',')})`;
1133
- const rows = await getRecordByFilter(Symptoms_ID, 'cluster_resolutions', formula).catch(() => null);
1134
- if (!rows) return [];
1134
+ const live = await getRecordByFilter(Symptoms_ID, 'cluster_resolutions', formula).catch(() => null);
1135
+ if (!live) return [];
1136
+ const rows = [...live, ...await readArchivedResolutions(ids.filter((id) => !live.some((row) => row.recordID === id)))];
1135
1137
  if (!patientRecordId && rows.length) {
1136
1138
  logger.warn('[triageRecommendation] prior resolutions unverified: payload carries no patientRecordId', { count: rows.length });
1137
1139
  }
@@ -1145,6 +1147,17 @@ async function readPriorResolutions(adherence = [], patientRecordId = null) {
1145
1147
  .filter(Boolean);
1146
1148
  }
1147
1149
 
1150
+ // A resolution deleted from Airtable is read from its archived copy; an unreadable archive only loses that context.
1151
+ async function readArchivedResolutions(ids) {
1152
+ if (!ids.length) return [];
1153
+ try {
1154
+ return await findArchivedByRecordIds({ baseId: Symptoms_ID, tableName: 'cluster_resolutions', recordIds: ids });
1155
+ } catch (error) {
1156
+ logger.warn('[triageRecommendation] archived prior resolutions unreadable', { count: ids.length, error: error?.message });
1157
+ return [];
1158
+ }
1159
+ }
1160
+
1148
1161
  function ownedByPatient(row, patientRecordId) {
1149
1162
  const owners = Array.isArray(row[PATIENT_LOOKUP_FIELD]) ? row[PATIENT_LOOKUP_FIELD] : [];
1150
1163
  if (owners.includes(patientRecordId)) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "6.0.0-dev.16560",
3
+ "version": "6.0.0-dev.16614",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",