c2-clinical 1.0.149 → 1.0.151
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/dist/__tests__/flow/on-answer/OnAnswerQuestionsFlowTester.test.js +11287 -2715
- package/dist/flow/group/item/BuildTreeFlowItem.js +3 -0
- package/dist/flow/on-answer/OnAnswerQuestionsFlowTester.d.ts +5 -0
- package/dist/flow/on-answer/OnAnswerQuestionsFlowTester.js +33 -0
- package/dist/flow/on-answer/ProcessAnswerFlowTester.js +4 -1
- package/dist/flow/on-answer/item/GetAnswerRelationedsFlowItemTester.js +1 -1
- package/package.json +1 -1
|
@@ -36,6 +36,9 @@ class BuildTreeFlowItem {
|
|
|
36
36
|
return lines;
|
|
37
37
|
}
|
|
38
38
|
const rootFormUnit = questions.filter((q) => !q.parent);
|
|
39
|
+
if (!rootFormUnit?.length) {
|
|
40
|
+
return buildRows({ parent: undefined, children: questions });
|
|
41
|
+
}
|
|
39
42
|
return buildRows({ parent: undefined, children: rootFormUnit });
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -9,6 +9,11 @@ declare class OnAnswerQuestionsFlowTester {
|
|
|
9
9
|
bank: IFormUnit[];
|
|
10
10
|
lines: IRow[];
|
|
11
11
|
};
|
|
12
|
+
executeByModal(answered: IFormUnit | IRow[], modalLines: IRow[], allLines: IRow[], metActivitiesPatient?: IMetActivityPatient[]): {
|
|
13
|
+
bank: IFormUnit[];
|
|
14
|
+
allLines: IRow[];
|
|
15
|
+
modalLines: IRow[];
|
|
16
|
+
};
|
|
12
17
|
}
|
|
13
18
|
declare const _default: OnAnswerQuestionsFlowTester;
|
|
14
19
|
export default _default;
|
|
@@ -34,5 +34,38 @@ class OnAnswerQuestionsFlowTester {
|
|
|
34
34
|
lines: GroupFormUnitsFlow_1.default.execute(bankAnswer)
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
executeByModal(answered, modalLines, allLines, metActivitiesPatient) {
|
|
38
|
+
let allQuestions = ConvertRowToFormUnitsFlowItem_1.default.execute(allLines);
|
|
39
|
+
let modalQuestions = ConvertRowToFormUnitsFlowItem_1.default.execute(modalLines);
|
|
40
|
+
allQuestions.forEach((q) => {
|
|
41
|
+
const mq = modalQuestions.find((m) => m._id.toString() === q._id.toString());
|
|
42
|
+
if (mq) {
|
|
43
|
+
q.answer = mq.answer;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (Array.isArray(answered)) {
|
|
47
|
+
const answersConverted = ConvertRowToFormUnitsFlowItem_1.default.execute(answered);
|
|
48
|
+
answersConverted.forEach((answer) => {
|
|
49
|
+
const ret = this.execute(answer, allQuestions, metActivitiesPatient);
|
|
50
|
+
allQuestions = ret.bank;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const ret = this.execute(answered, allQuestions, metActivitiesPatient);
|
|
55
|
+
allQuestions = ret.bank;
|
|
56
|
+
}
|
|
57
|
+
const modalQuestionsUpdateds = [];
|
|
58
|
+
modalQuestions.forEach((mq) => {
|
|
59
|
+
const updatedQuestion = allQuestions.find((aq) => aq._id.toString() === mq._id.toString());
|
|
60
|
+
if (updatedQuestion) {
|
|
61
|
+
modalQuestionsUpdateds.push(updatedQuestion);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
bank: allQuestions,
|
|
66
|
+
allLines: GroupFormUnitsFlow_1.default.execute(allQuestions),
|
|
67
|
+
modalLines: GroupFormUnitsFlow_1.default.execute(modalQuestionsUpdateds)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
37
70
|
}
|
|
38
71
|
exports.default = new OnAnswerQuestionsFlowTester();
|
|
@@ -8,12 +8,15 @@ const GetAnswerRelationedsFlowItemTester_1 = __importDefault(require("./item/Get
|
|
|
8
8
|
class ProcessAnswerFlowTester {
|
|
9
9
|
execute(questionAnswered, bankAnswer, attendanceMetActivities) {
|
|
10
10
|
if (questionAnswered.code === "CURRENT_IMC_TABLE_RESULT") {
|
|
11
|
-
console.log("debug");
|
|
11
|
+
// console.log("debug");
|
|
12
12
|
}
|
|
13
13
|
const answerRelacioneds = GetAnswerRelationedsFlowItemTester_1.default.execute(questionAnswered, bankAnswer);
|
|
14
14
|
const autoAnswereds = [];
|
|
15
15
|
const allQuestionsAnswereds = bankAnswer?.filter((q) => q.answer !== "" && q.answer !== undefined);
|
|
16
16
|
answerRelacioneds.forEach((relationed) => {
|
|
17
|
+
if (questionAnswered.code === "IMC") {
|
|
18
|
+
// console.log("debug");
|
|
19
|
+
}
|
|
17
20
|
//executa fórmula para answer
|
|
18
21
|
if (relationed.code !== questionAnswered.code && relationed.formulaToAnswer) {
|
|
19
22
|
const answerCalculated = ExecFormulaFlowTester_1.default.execute(relationed.formulaToAnswer, allQuestionsAnswereds, attendanceMetActivities);
|
|
@@ -5,7 +5,7 @@ class GetAnswerRelationedsFlowItemTester {
|
|
|
5
5
|
const regex = new RegExp(`\\$\{${questionAnswered.code}\}`, "i");
|
|
6
6
|
const questionsRelationeds = bankAnswer?.filter((fu) => {
|
|
7
7
|
if (fu.code === "CURRENT_HEIGHT_TABLE_RESULT") {
|
|
8
|
-
console.log("debug");
|
|
8
|
+
// console.log("debug");
|
|
9
9
|
}
|
|
10
10
|
return (regex.test(fu.formulaToAnswer) ||
|
|
11
11
|
regex.test(fu.formulaToReferenceValue) ||
|
package/package.json
CHANGED