@peopl-health/nexus 5.57.0-dev.9201 → 5.57.0-dev.9222
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.
|
@@ -5,6 +5,7 @@ const { createLLMProvider } = require('../providers/createLLMProvider');
|
|
|
5
5
|
|
|
6
6
|
const { getEscalationContext } = require('../../services/escalationContextService');
|
|
7
7
|
|
|
8
|
+
const { mexicoDay } = require('../../utils/dateUtils');
|
|
8
9
|
const { logger } = require('../../utils/logger');
|
|
9
10
|
const { safeParse } = require('../../utils/jsonUtils');
|
|
10
11
|
const { withTiming } = require('../../utils/tracingDecorator');
|
|
@@ -17,10 +18,9 @@ const MAX_RED_FLAGS = 4;
|
|
|
17
18
|
const GRADED_FROM = 2;
|
|
18
19
|
|
|
19
20
|
const trimmed = (value) => String(value ?? '').trim();
|
|
20
|
-
const dayOf = (value) => (value ? String(value).slice(0, 10) : null);
|
|
21
21
|
|
|
22
22
|
function gradedSymptoms(triages, now) {
|
|
23
|
-
const today =
|
|
23
|
+
const today = mexicoDay(now);
|
|
24
24
|
return (Array.isArray(triages) ? triages : [])
|
|
25
25
|
.flatMap((triage) => (triage?.symptoms ?? []).map((symptom) => {
|
|
26
26
|
const grade = Math.max(symptom?.gradeNum ?? 0, symptom?.compositeGrade ?? 0);
|
|
@@ -31,7 +31,7 @@ function gradedSymptoms(triages, now) {
|
|
|
31
31
|
attributes: symptom?.attributes ?? null,
|
|
32
32
|
patientNote: symptom?.patientNote ?? null,
|
|
33
33
|
triagedAt: triage?.created ?? null,
|
|
34
|
-
isToday:
|
|
34
|
+
isToday: today !== null && mexicoDay(triage?.created) === today,
|
|
35
35
|
};
|
|
36
36
|
}))
|
|
37
37
|
.filter((symptom) => symptom.grade >= GRADED_FROM)
|
|
@@ -74,7 +74,8 @@ function questionsProvider() {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const shortList = (value, limit) => (Array.isArray(value) ? value : [])
|
|
77
|
-
.
|
|
77
|
+
.filter((entry) => typeof entry === 'string')
|
|
78
|
+
.map((entry) => entry.trim())
|
|
78
79
|
.filter(Boolean)
|
|
79
80
|
.slice(0, limit);
|
|
80
81
|
|
|
@@ -740,6 +740,9 @@ async function suggestKeyQuestions({ id, requestedBy, requestId = null } = {}) {
|
|
|
740
740
|
}
|
|
741
741
|
if (!generated.completed) throw httpError(generated.configured === false ? 503 : 502, generated.reason);
|
|
742
742
|
|
|
743
|
+
const settled = await loadReview(reviewId);
|
|
744
|
+
if (!DOCUMENTING_STATUSES.includes(settled.status)) throw httpError(409, STATUS_CONFLICT);
|
|
745
|
+
|
|
743
746
|
return generated;
|
|
744
747
|
}
|
|
745
748
|
|
package/lib/utils/dateUtils.js
CHANGED
|
@@ -36,6 +36,12 @@ const ageInYears = (birthDate) => {
|
|
|
36
36
|
|
|
37
37
|
const isoDay = (value) => (typeof value === 'string' && value.length >= 10 ? value.slice(0, 10) : null);
|
|
38
38
|
|
|
39
|
+
const mexicoDay = (value) => {
|
|
40
|
+
if (value === null || value === undefined || value === '') return null;
|
|
41
|
+
const at = moment.tz(value, MEXICO_TZ);
|
|
42
|
+
return at.isValid() ? at.format('YYYY-MM-DD') : null;
|
|
43
|
+
};
|
|
44
|
+
|
|
39
45
|
const daysSince = (from, now = Date.now()) => {
|
|
40
46
|
const at = Date.parse(from);
|
|
41
47
|
return Number.isNaN(at) ? null : Math.max(0, Math.floor((now - at) / 86400000));
|
|
@@ -48,5 +54,6 @@ module.exports = {
|
|
|
48
54
|
toIsoInstant,
|
|
49
55
|
ageInYears,
|
|
50
56
|
isoDay,
|
|
57
|
+
mexicoDay,
|
|
51
58
|
daysSince
|
|
52
59
|
};
|