@peopl-health/nexus 6.5.20 → 6.5.21
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.
|
@@ -42,9 +42,18 @@ function gradeFor(todayGrades, catalog, term) {
|
|
|
42
42
|
return key ? todayGrades.get(key) : null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const cardTerms = (element) => [...new Set([
|
|
46
|
+
...element.targetedCtcaeTerms, ...element.symptoms.map((symptom) => symptom.ctcaeTerm),
|
|
47
|
+
].filter(Boolean))];
|
|
48
|
+
|
|
49
|
+
function cardTodayGrade(element, { catalog, todayGrades }) {
|
|
50
|
+
const grades = cardTerms(element).map((term) => gradeFor(todayGrades, catalog, term)).filter((grade) => grade !== null);
|
|
51
|
+
return grades.length ? Math.max(...grades) : null;
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
// Every term on the card needs today's grade and a current anchor: on a mixed card the question may be about the other term.
|
|
46
55
|
function anchorsCover(element, { known, catalog, todayGrades }) {
|
|
47
|
-
const terms =
|
|
56
|
+
const terms = cardTerms(element);
|
|
48
57
|
if (!terms.length) return false;
|
|
49
58
|
return terms.every((term) => {
|
|
50
59
|
const todayGrade = gradeFor(todayGrades, catalog, term);
|
|
@@ -70,4 +79,4 @@ function dropKnownFunctionalAsks(elements, { known, catalog, todayGrades } = {},
|
|
|
70
79
|
return dropped;
|
|
71
80
|
}
|
|
72
81
|
|
|
73
|
-
module.exports = { asksFunctionalImpact, dropKnownFunctionalAsks, todayGradesByTerm };
|
|
82
|
+
module.exports = { asksFunctionalImpact, cardTodayGrade, dropKnownFunctionalAsks, todayGradesByTerm };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { recommendationId } = require('../../fhir/helpers/recommendationIds');
|
|
2
|
+
const { cardTodayGrade } = require('./knownCharacterizationHelper');
|
|
2
3
|
|
|
3
|
-
function buildLegacyRecommendations({ plan, gate = null }) {
|
|
4
|
+
function buildLegacyRecommendations({ plan, gate = null, grades = { todayGrades: new Map() } }) {
|
|
4
5
|
const ranked = [...plan.elements].sort((a, b) => a.rank - b.rank);
|
|
5
6
|
return ranked.map((element) => {
|
|
6
7
|
const { patient } = element.recommendation;
|
|
@@ -27,6 +28,8 @@ function buildLegacyRecommendations({ plan, gate = null }) {
|
|
|
27
28
|
urgent_under_24h: isUrgent,
|
|
28
29
|
// Gate enum only; element routes carry the palliative vocabulary.
|
|
29
30
|
escalation_route: isUrgent ? (gate?.escalationRoute ?? null) : null,
|
|
31
|
+
// The Airtable triage directive opens on the highest-grade card.
|
|
32
|
+
max_reported_grade: cardTodayGrade(element, grades),
|
|
30
33
|
};
|
|
31
34
|
});
|
|
32
35
|
}
|
|
@@ -85,7 +88,7 @@ function buildLegacyStep2(plan) {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
// The explode trigger REGEX_EXTRACTs `recommendations` end-anchored: it must stay the last key.
|
|
88
|
-
function buildLegacyStep3({ plan, gate = null }) {
|
|
91
|
+
function buildLegacyStep3({ plan, gate = null, grades }) {
|
|
89
92
|
return {
|
|
90
93
|
step3_careplan: {
|
|
91
94
|
careplan_takeaways: {
|
|
@@ -94,7 +97,7 @@ function buildLegacyStep3({ plan, gate = null }) {
|
|
|
94
97
|
careplan_summary_patient_facing: plan.takeaways.summaryPatientFacing,
|
|
95
98
|
careplan_summary_internal: plan.takeaways.summaryInternal,
|
|
96
99
|
},
|
|
97
|
-
recommendations: buildLegacyRecommendations({ plan, gate }),
|
|
100
|
+
recommendations: buildLegacyRecommendations({ plan, gate, grades }),
|
|
98
101
|
},
|
|
99
102
|
};
|
|
100
103
|
}
|
|
@@ -694,7 +694,7 @@ async function generateTriageRecommendations({ payload, provider, runId = null,
|
|
|
694
694
|
triageRecordId: payload.triageRecordId,
|
|
695
695
|
step1: buildLegacyStep1(gate),
|
|
696
696
|
step2: buildLegacyStep2(plan),
|
|
697
|
-
step3: buildLegacyStep3({ plan, gate }),
|
|
697
|
+
step3: buildLegacyStep3({ plan, gate, grades: { catalog, todayGrades: boundary.todayGrades } }),
|
|
698
698
|
};
|
|
699
699
|
return finish({ status: 'success', reason: null }, mirrorPayload);
|
|
700
700
|
} catch (err) {
|