c2-clinical 1.0.95 → 1.0.97
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/flow/on-answer/OnAnswerQuestionsFlowTester.d.ts +4 -4
- package/dist/flow/on-answer/OnAnswerQuestionsFlowTester.js +1 -1
- package/dist/flow/on-answer/ProcessAnswerFlowTester.d.ts +2 -2
- package/dist/flow/on-answer/ProcessAnswerFlowTester.js +18 -9
- package/dist/flow/on-answer/item/GetAnswerRelationedsFlowItemTester.d.ts +6 -0
- package/dist/flow/on-answer/item/GetAnswerRelationedsFlowItemTester.js +18 -0
- package/dist/models/form/FormUnit.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFormUnit } from "../../models/form/FormUnit";
|
|
2
2
|
import { IMetActivityPatient } from "../../models/met-activity/MetActivityPatient";
|
|
3
3
|
declare class OnAnswerQuestionsFlowTester {
|
|
4
|
-
execute(answered:
|
|
5
|
-
bank:
|
|
6
|
-
autoAnswereds:
|
|
4
|
+
execute(answered: IFormUnit, answersBank: IFormUnit[], metActivitiesPatient?: IMetActivityPatient[]): {
|
|
5
|
+
bank: IFormUnit[];
|
|
6
|
+
autoAnswereds: IFormUnit[];
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
declare const _default: OnAnswerQuestionsFlowTester;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const ProcessAnswerFlowTester_1 = __importDefault(require("./ProcessAnswerFlowTester"));
|
|
7
7
|
class OnAnswerQuestionsFlowTester {
|
|
8
8
|
execute(answered, answersBank, metActivitiesPatient = []) {
|
|
9
|
-
const questionAnswered = answersBank.find((q) => q.
|
|
9
|
+
const questionAnswered = answersBank.find((q) => q._id.toString() === answered._id.toString());
|
|
10
10
|
if (!questionAnswered) {
|
|
11
11
|
throw new Error("invalid question");
|
|
12
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFormUnit } from "../../models/form/FormUnit";
|
|
2
2
|
import { IMetActivityPatient } from "../../models/met-activity/MetActivityPatient";
|
|
3
3
|
declare class ProcessAnswerFlow {
|
|
4
|
-
execute(questionAnswered:
|
|
4
|
+
execute(questionAnswered: IFormUnit, bankAnswer: IFormUnit[], attendanceMetActivities: IMetActivityPatient[]): IFormUnit[];
|
|
5
5
|
}
|
|
6
6
|
declare const _default: ProcessAnswerFlow;
|
|
7
7
|
export default _default;
|
|
@@ -4,31 +4,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ExecFormulaFlow_1 = __importDefault(require("./ExecFormulaFlow"));
|
|
7
|
-
const
|
|
7
|
+
const GetAnswerRelationedsFlowItemTester_1 = __importDefault(require("./item/GetAnswerRelationedsFlowItemTester"));
|
|
8
8
|
class ProcessAnswerFlow {
|
|
9
9
|
execute(questionAnswered, bankAnswer, attendanceMetActivities) {
|
|
10
|
-
const answerRelacioneds =
|
|
10
|
+
const answerRelacioneds = GetAnswerRelationedsFlowItemTester_1.default.execute(questionAnswered, bankAnswer);
|
|
11
11
|
const autoAnswereds = [];
|
|
12
12
|
const allQuestionsAnswereds = bankAnswer?.filter((q) => q.answer !== "" && q.answer !== undefined);
|
|
13
13
|
answerRelacioneds.forEach((relationed) => {
|
|
14
14
|
//executa fórmula para answer
|
|
15
|
-
const answerCalculated = ExecFormulaFlow_1.default.execute(relationed.
|
|
15
|
+
const answerCalculated = ExecFormulaFlow_1.default.execute(relationed.formulaToAnswer, allQuestionsAnswereds, attendanceMetActivities);
|
|
16
16
|
if (relationed.answer !== answerCalculated) {
|
|
17
17
|
relationed.answer = answerCalculated;
|
|
18
18
|
allQuestionsAnswereds.push(relationed);
|
|
19
19
|
autoAnswereds.push(relationed);
|
|
20
20
|
}
|
|
21
21
|
// formulaToReferenceValue
|
|
22
|
-
if (relationed
|
|
23
|
-
relationed.referenceValue = ExecFormulaFlow_1.default.execute(relationed.
|
|
22
|
+
if (relationed?.formulaToReferenceValue) {
|
|
23
|
+
relationed.referenceValue = ExecFormulaFlow_1.default.execute(relationed.formulaToReferenceValue, allQuestionsAnswereds, attendanceMetActivities);
|
|
24
24
|
}
|
|
25
25
|
// formulaToClassificationLabel: string;
|
|
26
|
-
if (relationed
|
|
27
|
-
relationed.classificationLabel = ExecFormulaFlow_1.default.execute(relationed.
|
|
26
|
+
if (relationed?.formulaToClassificationLabel) {
|
|
27
|
+
relationed.classificationLabel = ExecFormulaFlow_1.default.execute(relationed.formulaToClassificationLabel, allQuestionsAnswereds, attendanceMetActivities);
|
|
28
28
|
}
|
|
29
29
|
// formulaToClassificationColor: string;
|
|
30
|
-
if (relationed
|
|
31
|
-
relationed.classificationColor = ExecFormulaFlow_1.default.execute(relationed.
|
|
30
|
+
if (relationed?.formulaToClassificationColor) {
|
|
31
|
+
relationed.classificationColor = ExecFormulaFlow_1.default.execute(relationed.formulaToClassificationColor, allQuestionsAnswereds, attendanceMetActivities);
|
|
32
|
+
}
|
|
33
|
+
// check options is enables
|
|
34
|
+
if (relationed?.options?.length) {
|
|
35
|
+
relationed.options
|
|
36
|
+
.filter((option) => option.formulaToEnable?.length > 0)
|
|
37
|
+
?.forEach((option) => {
|
|
38
|
+
option.enable =
|
|
39
|
+
ExecFormulaFlow_1.default.execute(option.formulaToEnable, allQuestionsAnswereds, attendanceMetActivities) ?? false;
|
|
40
|
+
});
|
|
32
41
|
}
|
|
33
42
|
});
|
|
34
43
|
let questionsRelacionedsAnsweredsRet = [...autoAnswereds];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IFormUnit } from "../../../models/form/FormUnit";
|
|
2
|
+
declare class GetAnswerRelationedsFlowItemTester {
|
|
3
|
+
execute(questionAnswered: IFormUnit, bankAnswer: IFormUnit[]): IFormUnit[];
|
|
4
|
+
}
|
|
5
|
+
declare const _default: GetAnswerRelationedsFlowItemTester;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class GetAnswerRelationedsFlowItemTester {
|
|
4
|
+
execute(questionAnswered, bankAnswer) {
|
|
5
|
+
const regex = new RegExp(`\\$\{${questionAnswered.code}\}`, "i");
|
|
6
|
+
const questionsRelationeds = bankAnswer?.filter((fu) => {
|
|
7
|
+
return (regex.test(fu.formulaToAnswer) ||
|
|
8
|
+
regex.test(fu.formulaToReferenceValue) ||
|
|
9
|
+
regex.test(fu.formulaToClassificationLabel) ||
|
|
10
|
+
regex.test(fu.formulaToClassificationColor) ||
|
|
11
|
+
regex.test(fu.formulaToEnable) ||
|
|
12
|
+
fu.validations?.some((v) => regex.test(v.formulaToMessage)) ||
|
|
13
|
+
fu.options?.some((v) => regex.test(v.formulaToEnable)));
|
|
14
|
+
});
|
|
15
|
+
return questionsRelationeds;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = new GetAnswerRelationedsFlowItemTester();
|
|
@@ -56,10 +56,15 @@ export interface IFormUnit extends IDefault {
|
|
|
56
56
|
measurementUnit: string;
|
|
57
57
|
options: IQuestionOption[];
|
|
58
58
|
formulaToAnswer: string;
|
|
59
|
+
answer: any;
|
|
59
60
|
formulaToReferenceValue: string;
|
|
61
|
+
referenceValue: any;
|
|
60
62
|
formulaToClassificationLabel: string;
|
|
63
|
+
classificationLabel: any;
|
|
61
64
|
formulaToClassificationColor: string;
|
|
65
|
+
classificationColor: any;
|
|
62
66
|
formulaToEnable: string;
|
|
67
|
+
enable: boolean;
|
|
63
68
|
validations: IValidationQuestion[];
|
|
64
69
|
active: boolean;
|
|
65
70
|
show: boolean;
|
package/package.json
CHANGED