c2-clinical 1.0.122 → 1.0.124
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__/OnAnswerQuestionsFlowTester.test.js +5276 -736
- package/dist/flow/on-answer/OnAnswerQuestionsFlowTester.js +2 -0
- package/dist/flow/on-answer/ProcessAnswerFlowTester.js +11 -5
- package/dist/flow/on-answer/item/ConvertRowToFormUnitsFlowItem.d.ts +0 -2
- package/dist/flow/on-answer/item/ConvertRowToFormUnitsFlowItem.js +14 -14
- package/dist/flow/on-answer/item/GetAnswerRelationedsFlowItemTester.js +1 -0
- package/dist/models/form/FormUnit.d.ts +4 -0
- package/dist/models/form/FormUnit.js +1 -0
- package/package.json +1 -1
|
@@ -18,7 +18,9 @@ class OnAnswerQuestionsFlowTester {
|
|
|
18
18
|
}
|
|
19
19
|
executeByRows(answered, lines, metActivitiesPatient) {
|
|
20
20
|
const bankAnswer = ConvertRowToFormUnitsFlowItem_1.default.execute(lines);
|
|
21
|
+
console.log("bankAnswerConverted", bankAnswer);
|
|
21
22
|
const { bank } = this.execute(answered, bankAnswer, metActivitiesPatient);
|
|
23
|
+
console.log("bankAnswerReturned", bankAnswer);
|
|
22
24
|
return {
|
|
23
25
|
bank,
|
|
24
26
|
lines: GroupFormUnitsFlow_1.default.execute(bank, [])
|
|
@@ -12,11 +12,17 @@ class ProcessAnswerFlowTester {
|
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
relationed.answer
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (relationed.code !== questionAnswered.code) {
|
|
16
|
+
const answerCalculated = ExecFormulaFlowTester_1.default.execute(relationed.formulaToAnswer, allQuestionsAnswereds, attendanceMetActivities);
|
|
17
|
+
if (relationed.answer !== answerCalculated) {
|
|
18
|
+
relationed.answer = answerCalculated;
|
|
19
|
+
allQuestionsAnswereds.push(relationed);
|
|
20
|
+
autoAnswereds.push(relationed);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// formulaToDescription
|
|
24
|
+
if (relationed.formulaToDescription) {
|
|
25
|
+
relationed.description = ExecFormulaFlowTester_1.default.execute(relationed.formulaToDescription, allQuestionsAnswereds, attendanceMetActivities);
|
|
20
26
|
}
|
|
21
27
|
// formulaToReferenceValue
|
|
22
28
|
if (relationed?.formulaToReferenceValue) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { IFormUnit, IRow } from "../../../models/form/FormUnit";
|
|
2
2
|
declare class ConvertRowToFormUnitsFlowItem {
|
|
3
|
-
private formUnits;
|
|
4
3
|
execute(rows: IRow[]): IFormUnit[];
|
|
5
|
-
private iterate;
|
|
6
4
|
}
|
|
7
5
|
declare const _default: ConvertRowToFormUnitsFlowItem;
|
|
8
6
|
export default _default;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class ConvertRowToFormUnitsFlowItem {
|
|
4
|
-
formUnits = [];
|
|
5
4
|
execute(rows) {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function iterate(row) {
|
|
6
|
+
let formUnits = [];
|
|
7
|
+
row.collumns?.forEach((collumn) => {
|
|
8
|
+
formUnits.push({ ...collumn, lineId: row.id });
|
|
9
|
+
if (collumn.lines?.length) {
|
|
10
|
+
collumn.lines.forEach((line) => {
|
|
11
|
+
formUnits = [...formUnits, ...iterate(line)];
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return formUnits;
|
|
8
16
|
}
|
|
9
|
-
return this.formUnits;
|
|
10
|
-
}
|
|
11
|
-
iterate(row) {
|
|
12
17
|
let formUnits = [];
|
|
13
|
-
row
|
|
14
|
-
formUnits
|
|
15
|
-
|
|
16
|
-
collumn.lines.forEach((line) => {
|
|
17
|
-
formUnits = [...formUnits, ...this.iterate(line)];
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
18
|
+
for (const row of rows) {
|
|
19
|
+
formUnits = [...formUnits, ...iterate(row)];
|
|
20
|
+
}
|
|
21
21
|
return formUnits;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -9,6 +9,7 @@ class GetAnswerRelationedsFlowItemTester {
|
|
|
9
9
|
regex.test(fu.formulaToClassificationLabel) ||
|
|
10
10
|
regex.test(fu.formulaToClassificationColor) ||
|
|
11
11
|
regex.test(fu.formulaToEnable) ||
|
|
12
|
+
regex.test(fu.formulaToDescription) ||
|
|
12
13
|
fu.validations?.some((v) => regex.test(v.formulaToMessage)) ||
|
|
13
14
|
fu.options?.some((v) => regex.test(v.formulaToEnable)));
|
|
14
15
|
});
|
|
@@ -50,6 +50,7 @@ export interface IFormUnit extends IDefault {
|
|
|
50
50
|
sequence: number;
|
|
51
51
|
code: string;
|
|
52
52
|
description: string;
|
|
53
|
+
formulaToDescription: string;
|
|
53
54
|
example: string;
|
|
54
55
|
parent: Types.ObjectId | IFormUnit;
|
|
55
56
|
line: number;
|
|
@@ -302,6 +303,7 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
|
|
|
302
303
|
account?: Types.ObjectId | null | undefined;
|
|
303
304
|
description?: string | null | undefined;
|
|
304
305
|
reference?: Types.ObjectId | null | undefined;
|
|
306
|
+
formulaToDescription?: string | null | undefined;
|
|
305
307
|
example?: string | null | undefined;
|
|
306
308
|
parent?: Types.ObjectId | null | undefined;
|
|
307
309
|
line?: number | null | undefined;
|
|
@@ -452,6 +454,7 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
|
|
|
452
454
|
account?: Types.ObjectId | null | undefined;
|
|
453
455
|
description?: string | null | undefined;
|
|
454
456
|
reference?: Types.ObjectId | null | undefined;
|
|
457
|
+
formulaToDescription?: string | null | undefined;
|
|
455
458
|
example?: string | null | undefined;
|
|
456
459
|
parent?: Types.ObjectId | null | undefined;
|
|
457
460
|
line?: number | null | undefined;
|
|
@@ -602,6 +605,7 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
|
|
|
602
605
|
account?: Types.ObjectId | null | undefined;
|
|
603
606
|
description?: string | null | undefined;
|
|
604
607
|
reference?: Types.ObjectId | null | undefined;
|
|
608
|
+
formulaToDescription?: string | null | undefined;
|
|
605
609
|
example?: string | null | undefined;
|
|
606
610
|
parent?: Types.ObjectId | null | undefined;
|
|
607
611
|
line?: number | null | undefined;
|
|
@@ -37,6 +37,7 @@ exports.FormUnitSchema = new mongoose_1.Schema({
|
|
|
37
37
|
form: { type: mongoose_1.Schema.Types.ObjectId, ref: "form", required: true },
|
|
38
38
|
sequence: { type: Number, required: true },
|
|
39
39
|
code: { type: String, required: true },
|
|
40
|
+
formulaToDescription: { type: String },
|
|
40
41
|
description: { type: String },
|
|
41
42
|
example: { type: String },
|
|
42
43
|
parent: { type: mongoose_1.Schema.Types.ObjectId, ref: "form-unit" },
|
package/package.json
CHANGED