@peopl-health/nexus 5.56.0-dev.8568 → 5.56.0-dev.8569
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/services/clinicalAirtableService.js +2 -2
- package/lib/clinical/services/safetyNetPledgeService.js +6 -5
- package/lib/clinical/tools/reportMedicalEscalationTool.js +4 -2
- package/lib/clinical/tools/reportResultsReceivedTool.js +4 -2
- package/lib/clinical/tools/reportUnresolvedRequestv2Tool.js +4 -2
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ const runtimeConfig = require('../../config/runtimeConfig');
|
|
|
7
7
|
const airtableService = require('../../services/airtableService');
|
|
8
8
|
const { logger } = require('../../utils/logger');
|
|
9
9
|
const { fieldEquals, recordIdIn } = require('../../helpers/airtableFormulaHelper');
|
|
10
|
-
const {
|
|
10
|
+
const { CLOSED_REQUEST_STATUSES, needsRequestAttention } = require('../../helpers/patientTaskRulesHelper');
|
|
11
11
|
const { phoneDigits } = require('../../helpers/whatsappHelper');
|
|
12
12
|
const { WriteClaimStore } = require('./writeClaimStore');
|
|
13
13
|
|
|
@@ -167,7 +167,7 @@ async function isTaskAttended(recordId) {
|
|
|
167
167
|
const [task] = await airtableService.getRecordByFilter(Monitoreo_ID, 'unresolved_questions', recordIdIn([recordId]), null, ['status']);
|
|
168
168
|
if (!task) return true;
|
|
169
169
|
const status = String(task.status || '').trim();
|
|
170
|
-
return status !== '' && status
|
|
170
|
+
return status !== '' && !needsRequestAttention(status);
|
|
171
171
|
} catch (error) {
|
|
172
172
|
logger.warn('[clinicalAirtableService] Could not read whether the ops task was attended', { recordId, error: error.message });
|
|
173
173
|
return null;
|
|
@@ -119,6 +119,12 @@ async function sweepSafetyNetPledges() {
|
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
if (await humanRepliedSince(pledge.code, pledge.pledgedAt)) {
|
|
123
|
+
await returnToPending(pledge._id);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Last, so the least time passes between reading the task and alarming about it.
|
|
122
128
|
if (pledge.kind === 'onboarding' && pledge.taskRecordId) {
|
|
123
129
|
const attended = await isTaskAttended(pledge.taskRecordId);
|
|
124
130
|
if (attended) {
|
|
@@ -131,11 +137,6 @@ async function sweepSafetyNetPledges() {
|
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
|
|
134
|
-
if (await humanRepliedSince(pledge.code, pledge.pledgedAt)) {
|
|
135
|
-
await returnToPending(pledge._id);
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
140
|
if (!await reportBreach(pledge)) {
|
|
140
141
|
await returnToPending(pledge._id);
|
|
141
142
|
logger.error('[SafetyNetPledge] Breach was not recorded, pledge returns to pending for the next sweep', { code: pledge.code });
|
|
@@ -3,7 +3,7 @@ const { auditReasoningSchema } = require('../helpers/auditReasoningHelper');
|
|
|
3
3
|
const { dispatcherService } = require('../services/dispatcherService');
|
|
4
4
|
const { armEscalationNet } = require('../services/contingencyDispatchService');
|
|
5
5
|
const { evidenceQuoteAnchoring } = require('../helpers/evidenceAnchorHelper');
|
|
6
|
-
const { recordEmergency,
|
|
6
|
+
const { recordEmergency, writeUnresolvedRequest } = require('../services/clinicalAirtableService');
|
|
7
7
|
const { objectArg, safeParse, isPlainObject } = require('../../utils/jsonUtils');
|
|
8
8
|
const { logger } = require('../../utils/logger');
|
|
9
9
|
|
|
@@ -219,7 +219,8 @@ async function handler(args, context = {}) {
|
|
|
219
219
|
|
|
220
220
|
if (runtime.patientCode) {
|
|
221
221
|
if (urgencyLevel === 'routine') {
|
|
222
|
-
|
|
222
|
+
// A repeat the writer suppressed means the team already has this escalation, not that it was lost.
|
|
223
|
+
const { written, duplicate } = await writeUnresolvedRequest({
|
|
223
224
|
code: runtime.patientCode,
|
|
224
225
|
trace,
|
|
225
226
|
question: details.symptom || '',
|
|
@@ -227,6 +228,7 @@ async function handler(args, context = {}) {
|
|
|
227
228
|
category: 'medical_routine',
|
|
228
229
|
urgency: 'routine',
|
|
229
230
|
});
|
|
231
|
+
queued = written || duplicate;
|
|
230
232
|
} else {
|
|
231
233
|
queued = await recordEmergency({
|
|
232
234
|
code: runtime.patientCode,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { DEGRADED_NUMERIC_REASON, DEGRADED_SUPPRESSED_REASON, VERBATIM_SOURCES, patientVerbatimHasNumericValues, resolveVerbatimSource, slugify, stampProvenance } = require('../helpers/resultsHelper');
|
|
2
|
-
const {
|
|
2
|
+
const { writeUnresolvedRequest } = require('../services/clinicalAirtableService');
|
|
3
3
|
const { storeResultObservations } = require('../../fhir');
|
|
4
4
|
const { logger } = require('../../utils/logger');
|
|
5
5
|
|
|
@@ -120,7 +120,8 @@ async function handler(args = {}, context = {}) {
|
|
|
120
120
|
logger.warn('[reportResultsReceived] no trace on runtime context; results-received signal not recorded', { turnId: runtime.turnId });
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
// A repeat the writer suppressed means the team already has this review, not that it was lost.
|
|
124
|
+
const { written, duplicate } = await writeUnresolvedRequest({
|
|
124
125
|
code: runtime.patientCode,
|
|
125
126
|
trace,
|
|
126
127
|
question: ['Resultados recibidos:', resultType, studyName].filter(Boolean).join(' '),
|
|
@@ -128,6 +129,7 @@ async function handler(args = {}, context = {}) {
|
|
|
128
129
|
category: 'results_review',
|
|
129
130
|
urgency: 'soon',
|
|
130
131
|
});
|
|
132
|
+
const queued = written || duplicate;
|
|
131
133
|
|
|
132
134
|
const data = { result_id: resultId, result_slug: resultSlug };
|
|
133
135
|
if (resultType !== rawType) data.result_type = resultType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { auditReasoningSchema } = require('../helpers/auditReasoningHelper');
|
|
2
|
-
const {
|
|
2
|
+
const { writeUnresolvedRequest } = require('../services/clinicalAirtableService');
|
|
3
3
|
const { logger } = require('../../utils/logger');
|
|
4
4
|
|
|
5
5
|
const definition = {
|
|
@@ -111,7 +111,8 @@ async function handler(args = {}, context = {}) {
|
|
|
111
111
|
const patientCode = context?.toolRuntimeContext?.patientCode;
|
|
112
112
|
let isQueued = false;
|
|
113
113
|
if (patientCode) {
|
|
114
|
-
|
|
114
|
+
// A repeat the writer suppressed means the team already has this request, not that it was lost.
|
|
115
|
+
const { written, duplicate } = await writeUnresolvedRequest({
|
|
115
116
|
code: patientCode,
|
|
116
117
|
trace,
|
|
117
118
|
question,
|
|
@@ -121,6 +122,7 @@ async function handler(args = {}, context = {}) {
|
|
|
121
122
|
category,
|
|
122
123
|
urgency,
|
|
123
124
|
});
|
|
125
|
+
isQueued = written || duplicate;
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
if (isQueued) {
|