@peopl-health/nexus 5.57.0-dev.9240 → 5.57.0-dev.9261
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,5 +1,7 @@
|
|
|
1
1
|
const { ladderFor, renderLadder } = require('../services/ctcaeLadderService');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
itemForQuestionId, affirmative, sentinelKind, dimensionsFor, isItemDimension,
|
|
4
|
+
} = require('../../fhir/helpers/terminologyHelper');
|
|
3
5
|
const { daysSince } = require('../../utils/dateUtils');
|
|
4
6
|
const { detectSafetyFlags } = require('./safetyFlagsHelper');
|
|
5
7
|
|
|
@@ -108,8 +110,15 @@ function reportedSymptomEvidence(symptom, catalog) {
|
|
|
108
110
|
.map((dimension) => `${DIMENSION_ES[dimension] || dimension}: ${answers[dimension]}`)
|
|
109
111
|
.join(' · ')}`);
|
|
110
112
|
}
|
|
113
|
+
const setAside = Object.entries(symptom.supplementaryAnswers || {});
|
|
114
|
+
if (setAside.length) {
|
|
115
|
+
lines.push(` Preguntas complementarias de PEOPL, fuera del grado: ${setAside
|
|
116
|
+
.map(([dimension, answer]) => `${DIMENSION_ES[dimension] || dimension}: ${answer}`)
|
|
117
|
+
.join(' · ')}. Miden otra cosa que el ítem del PRO-CTCAE; no confirman ni descartan el síntoma.`);
|
|
118
|
+
}
|
|
111
119
|
if (Array.isArray(catalog?.symptoms?.[symptom.term]?.dimensions)) {
|
|
112
|
-
const missing = dimensionsFor(catalog, symptom.term)
|
|
120
|
+
const missing = dimensionsFor(catalog, symptom.term)
|
|
121
|
+
.filter((dimension) => isItemDimension(catalog, symptom.term, dimension) && !answered.includes(dimension));
|
|
113
122
|
if (missing.length) {
|
|
114
123
|
lines.push(` Atributos que este ítem del PRO-CTCAE no preguntó: ${missing
|
|
115
124
|
.map((dimension) => DIMENSION_ES[dimension] || dimension).join(', ')}. No preguntado no es `
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const { logger } = require('../../utils/logger');
|
|
2
2
|
const {
|
|
3
3
|
itemForQuestionId,
|
|
4
|
+
isSupplementaryQuestion,
|
|
5
|
+
isItemDimension,
|
|
4
6
|
canonicalAnswer,
|
|
5
7
|
affirmative,
|
|
6
8
|
standardOrdinal,
|
|
@@ -18,15 +20,19 @@ function gradeComposites(catalog, input) {
|
|
|
18
20
|
const item = itemForQuestionId(catalog, questionId);
|
|
19
21
|
if (!item) continue;
|
|
20
22
|
const [term, dimension] = item;
|
|
21
|
-
if (!answersByTerm.has(term)) answersByTerm.set(term, {});
|
|
22
|
-
|
|
23
|
+
if (!answersByTerm.has(term)) answersByTerm.set(term, { own: {}, supplementary: {} });
|
|
24
|
+
const lane = isSupplementaryQuestion(catalog, questionId) ? 'supplementary' : 'own';
|
|
25
|
+
answersByTerm.get(term)[lane][dimension] = { label: String(canonicalAnswer(catalog, questionId, label)), raw: String(label) };
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
const pain = painDimensionAnswers(catalog, input.pain, input.triageId);
|
|
26
|
-
|
|
29
|
+
const lanes = [...answersByTerm]
|
|
30
|
+
.filter(([term]) => !(pain && term === PAIN_TERM))
|
|
31
|
+
.map(([term, answers]) => [term, splitSupplementary(catalog, term, answers)]);
|
|
32
|
+
if (pain) lanes.push([PAIN_TERM, { dimensionAnswers: pain, setAside: {} }]);
|
|
27
33
|
|
|
28
34
|
const graded = [];
|
|
29
|
-
for (const [term, dimensionAnswers] of
|
|
35
|
+
for (const [term, { dimensionAnswers, setAside }] of lanes) {
|
|
30
36
|
const ordinals = {};
|
|
31
37
|
for (const [dimension, label] of Object.entries(dimensionAnswers)) {
|
|
32
38
|
const ordinal = dimension === 'presence' ? presenceOrdinal(catalog, label) : standardOrdinal(catalog, dimension, label);
|
|
@@ -73,12 +79,27 @@ function gradeComposites(catalog, input) {
|
|
|
73
79
|
effective: input.authored || null,
|
|
74
80
|
triageId: input.triageId,
|
|
75
81
|
dimensionAnswers: dimensionAnswers,
|
|
82
|
+
...(Object.keys(setAside).length ? { supplementaryAnswers: setAside } : {}),
|
|
76
83
|
source: 'triage',
|
|
77
84
|
});
|
|
78
85
|
}
|
|
79
86
|
return graded;
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
function splitSupplementary(catalog, term, { own, supplementary }) {
|
|
90
|
+
const dimensionAnswers = Object.fromEntries(Object.entries(own).map(([dimension, { label }]) => [dimension, label]));
|
|
91
|
+
const hasOwn = Object.keys(own).length > 0;
|
|
92
|
+
const setAside = {};
|
|
93
|
+
for (const [dimension, { label, raw }] of Object.entries(supplementary)) {
|
|
94
|
+
if (dimensionAnswers[dimension] == null && (isItemDimension(catalog, term, dimension) || !hasOwn)) {
|
|
95
|
+
dimensionAnswers[dimension] = label;
|
|
96
|
+
} else {
|
|
97
|
+
setAside[dimension] = raw;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { dimensionAnswers, setAside };
|
|
101
|
+
}
|
|
102
|
+
|
|
82
103
|
function presenceOrdinal(catalog, label) {
|
|
83
104
|
const ordinal = standardOrdinal(catalog, 'presence', label);
|
|
84
105
|
if (ordinal !== null) return ordinal;
|
|
@@ -18,10 +18,12 @@ const DIMENSION_SCALES = {
|
|
|
18
18
|
const DIMENSION_ORDER = ['presence', 'frequency', 'intensity', 'interference', 'amount'];
|
|
19
19
|
|
|
20
20
|
const CANONICAL_SOURCE = 'original';
|
|
21
|
+
const SUPPLEMENTARY_SOURCE = 'extra-question';
|
|
21
22
|
|
|
22
23
|
function buildCatalog(items, composites = [], source = null) {
|
|
23
24
|
const symptoms = {};
|
|
24
25
|
const questionIndex = {};
|
|
26
|
+
const questionSource = {};
|
|
25
27
|
const answerMap = {};
|
|
26
28
|
const itemIndex = {};
|
|
27
29
|
|
|
@@ -57,6 +59,7 @@ function buildCatalog(items, composites = [], source = null) {
|
|
|
57
59
|
if (questionId != null && dimension) {
|
|
58
60
|
if (gradeableOnScale(dimension, options, map)) {
|
|
59
61
|
questionIndex[String(questionId)] = [term, dimension];
|
|
62
|
+
questionSource[String(questionId)] = row.source ?? null;
|
|
60
63
|
} else {
|
|
61
64
|
logger.warn('[buildCatalog] question not indexed: no answer option grades on its dimension scale', {
|
|
62
65
|
questionId,
|
|
@@ -86,6 +89,7 @@ function buildCatalog(items, composites = [], source = null) {
|
|
|
86
89
|
},
|
|
87
90
|
symptoms,
|
|
88
91
|
question_index: questionIndex,
|
|
92
|
+
question_source: questionSource,
|
|
89
93
|
item_index: itemIndex,
|
|
90
94
|
answer_map: answerMap,
|
|
91
95
|
composite_grades: compositeGrades,
|
|
@@ -169,6 +173,16 @@ function itemForQuestionId(catalog, questionId) {
|
|
|
169
173
|
return Array.isArray(entry) && entry.length >= 2 ? [entry[0], entry[1]] : null;
|
|
170
174
|
}
|
|
171
175
|
|
|
176
|
+
function isSupplementaryQuestion(catalog, questionId) {
|
|
177
|
+
return (catalog.question_source || {})[String(questionId).trim()] === SUPPLEMENTARY_SOURCE;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function isItemDimension(catalog, term, dimension) {
|
|
181
|
+
const rec = getSymptom(catalog, term);
|
|
182
|
+
return (rec ? rec.dimensions : [])
|
|
183
|
+
.some((d) => d.dimension === dimension && d.source !== SUPPLEMENTARY_SOURCE);
|
|
184
|
+
}
|
|
185
|
+
|
|
172
186
|
function termForItem(catalog, item) {
|
|
173
187
|
return catalog.item_index[String(item ?? '').trim()] || null;
|
|
174
188
|
}
|
|
@@ -313,6 +327,8 @@ module.exports = {
|
|
|
313
327
|
allTerms,
|
|
314
328
|
compositeTableHash,
|
|
315
329
|
itemForQuestionId,
|
|
330
|
+
isSupplementaryQuestion,
|
|
331
|
+
isItemDimension,
|
|
316
332
|
termForItem,
|
|
317
333
|
getSymptom,
|
|
318
334
|
canonicalAnswer,
|
|
@@ -14,6 +14,7 @@ const schema = z.strictObject({
|
|
|
14
14
|
effective: dateTime.nullable().default(null),
|
|
15
15
|
triageId: z.string(),
|
|
16
16
|
dimensionAnswers: z.record(z.string(), z.string()).default({}),
|
|
17
|
+
supplementaryAnswers: z.record(z.string(), z.string()).optional(),
|
|
17
18
|
source: z.string().default('triage'),
|
|
18
19
|
});
|
|
19
20
|
|