c2-clinical 1.0.124 → 1.0.125
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/group/item/BuildTreeFlowItem.d.ts +0 -2
- package/dist/flow/group/item/BuildTreeFlowItem.js +29 -30
- package/dist/flow/group/item/GetEnablesFormUnitsFlowItem.d.ts +1 -1
- package/dist/flow/group/item/GetEnablesFormUnitsFlowItem.js +0 -4
- package/dist/flow/on-answer/OnAnswerQuestionsFlowTester.js +0 -2
- package/package.json +1 -1
|
@@ -5,39 +5,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const GenerateUUIDFlowItem_1 = __importDefault(require("./GenerateUUIDFlowItem"));
|
|
7
7
|
class BuildTreeFlowItem {
|
|
8
|
-
bank = [];
|
|
9
8
|
execute(questions) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
line: item.line,
|
|
21
|
-
collumns: []
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
acc.find((a) => a.line === item.line)?.collumns.push(item);
|
|
25
|
-
return acc;
|
|
26
|
-
}, []);
|
|
27
|
-
lines?.forEach((line, index) => {
|
|
28
|
-
line.collumns?.sort((a, b) => a.column - b.column);
|
|
29
|
-
line.collumns?.forEach((collumn) => {
|
|
30
|
-
const newChildren = this.bank.filter((child) => {
|
|
31
|
-
const parentId = child.parent?._id?.toString() ?? child.parent;
|
|
32
|
-
const _id = collumn?._id?.toString() ?? collumn._id;
|
|
33
|
-
return parentId === _id;
|
|
34
|
-
});
|
|
35
|
-
if (newChildren?.length) {
|
|
36
|
-
collumn.lines = this.buildRows({ parent: collumn, children: newChildren });
|
|
9
|
+
let bank = questions;
|
|
10
|
+
function buildRows(config) {
|
|
11
|
+
config.children.sort((a, b) => a.line - b.line);
|
|
12
|
+
const lines = config.children.reduce((acc, item) => {
|
|
13
|
+
if (!acc.some((a) => a.line === item.line)) {
|
|
14
|
+
acc.push({
|
|
15
|
+
id: item.lineId ?? GenerateUUIDFlowItem_1.default.execute(),
|
|
16
|
+
line: item.line,
|
|
17
|
+
collumns: []
|
|
18
|
+
});
|
|
37
19
|
}
|
|
20
|
+
acc.find((a) => a.line === item.line)?.collumns.push(item);
|
|
21
|
+
return acc;
|
|
22
|
+
}, []);
|
|
23
|
+
lines?.forEach((line, index) => {
|
|
24
|
+
line.collumns?.sort((a, b) => a.column - b.column);
|
|
25
|
+
line.collumns?.forEach((collumn) => {
|
|
26
|
+
const newChildren = bank.filter((child) => {
|
|
27
|
+
const parentId = child.parent?._id?.toString() ?? child.parent;
|
|
28
|
+
const _id = collumn?._id?.toString() ?? collumn._id;
|
|
29
|
+
return parentId === _id;
|
|
30
|
+
});
|
|
31
|
+
if (newChildren?.length) {
|
|
32
|
+
collumn.lines = buildRows({ parent: collumn, children: newChildren });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
38
35
|
});
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
return lines;
|
|
37
|
+
}
|
|
38
|
+
const rootFormUnit = questions.filter((q) => !q.parent);
|
|
39
|
+
return buildRows({ parent: undefined, children: rootFormUnit });
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
exports.default = new BuildTreeFlowItem();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IFormUnit } from "../../../models/form/FormUnit";
|
|
2
1
|
import { IAnswer } from "../../../models/Answer";
|
|
2
|
+
import { IFormUnit } from "../../../models/form/FormUnit";
|
|
3
3
|
declare class GetEnablesFormUnitsFlowItem {
|
|
4
4
|
execute(formUnits: IFormUnit[], answers: IAnswer[]): IFormUnit[];
|
|
5
5
|
}
|
|
@@ -8,10 +8,6 @@ const ExecFormulaFlowItem_1 = __importDefault(require("../../item/ExecFormulaFlo
|
|
|
8
8
|
class GetEnablesFormUnitsFlowItem {
|
|
9
9
|
execute(formUnits, answers) {
|
|
10
10
|
return formUnits?.filter((unit) => {
|
|
11
|
-
if (unit._id.toString() === "68efa8f2fbcea8e6b466aed4") {
|
|
12
|
-
console.log("DEBUG ENABLED");
|
|
13
|
-
}
|
|
14
|
-
// if (!unit.show) return false;
|
|
15
11
|
if (!unit.active)
|
|
16
12
|
return false;
|
|
17
13
|
if (!unit.formulaToEnable)
|
|
@@ -18,9 +18,7 @@ class OnAnswerQuestionsFlowTester {
|
|
|
18
18
|
}
|
|
19
19
|
executeByRows(answered, lines, metActivitiesPatient) {
|
|
20
20
|
const bankAnswer = ConvertRowToFormUnitsFlowItem_1.default.execute(lines);
|
|
21
|
-
console.log("bankAnswerConverted", bankAnswer);
|
|
22
21
|
const { bank } = this.execute(answered, bankAnswer, metActivitiesPatient);
|
|
23
|
-
console.log("bankAnswerReturned", bankAnswer);
|
|
24
22
|
return {
|
|
25
23
|
bank,
|
|
26
24
|
lines: GroupFormUnitsFlow_1.default.execute(bank, [])
|
package/package.json
CHANGED