c2-clinical 1.0.124 → 1.0.126

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,7 +1,6 @@
1
1
  import { IFormUnit, IRow } from "../../models/form/FormUnit";
2
- import { IAnswer } from "../../models/Answer";
3
2
  declare class GroupFormUnitsFlow {
4
- execute(formUnits: IFormUnit[], answers: IAnswer[]): IRow[];
3
+ execute(formUnits: IFormUnit[]): IRow[];
5
4
  }
6
5
  declare const _default: GroupFormUnitsFlow;
7
6
  export default _default;
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const BuildTreeFlowItem_1 = __importDefault(require("./item/BuildTreeFlowItem"));
7
7
  const GetEnablesFormUnitsFlowItem_1 = __importDefault(require("./item/GetEnablesFormUnitsFlowItem"));
8
8
  class GroupFormUnitsFlow {
9
- execute(formUnits, answers) {
10
- const questionsEnableds = GetEnablesFormUnitsFlowItem_1.default.execute(formUnits, answers);
9
+ execute(formUnits) {
10
+ const questionsEnableds = GetEnablesFormUnitsFlowItem_1.default.execute(formUnits);
11
11
  const questionsWithOrganizedChilds = BuildTreeFlowItem_1.default.execute(questionsEnableds);
12
12
  return questionsWithOrganizedChilds;
13
13
  }
@@ -1,8 +1,6 @@
1
1
  import { IFormUnit, IRow } from "../../../models/form/FormUnit";
2
2
  declare class BuildTreeFlowItem {
3
- private bank;
4
3
  execute(questions: IFormUnit[]): IRow[];
5
- private buildRows;
6
4
  }
7
5
  declare const _default: BuildTreeFlowItem;
8
6
  export default _default;
@@ -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
- this.bank = questions;
11
- const rootFormUnit = questions.filter((q) => !q.parent);
12
- return this.buildRows({ parent: undefined, children: rootFormUnit });
13
- }
14
- buildRows(config) {
15
- config.children.sort((a, b) => a.line - b.line);
16
- const lines = config.children.reduce((acc, item) => {
17
- if (!acc.some((a) => a.line === item.line)) {
18
- acc.push({
19
- id: item.lineId ?? GenerateUUIDFlowItem_1.default.execute(),
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
- return lines;
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,7 +1,6 @@
1
1
  import { IFormUnit } from "../../../models/form/FormUnit";
2
- import { IAnswer } from "../../../models/Answer";
3
2
  declare class GetEnablesFormUnitsFlowItem {
4
- execute(formUnits: IFormUnit[], answers: IAnswer[]): IFormUnit[];
3
+ execute(formUnits: IFormUnit[]): IFormUnit[];
5
4
  }
6
5
  declare const _default: GetEnablesFormUnitsFlowItem;
7
6
  export default _default;
@@ -6,12 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const BuildFormulaFlowItem_1 = __importDefault(require("../../item/BuildFormulaFlowItem"));
7
7
  const ExecFormulaFlowItem_1 = __importDefault(require("../../item/ExecFormulaFlowItem"));
8
8
  class GetEnablesFormUnitsFlowItem {
9
- execute(formUnits, answers) {
9
+ execute(formUnits) {
10
+ const answers = formUnits.filter((unit) => !!unit.answer);
10
11
  return formUnits?.filter((unit) => {
11
- if (unit._id.toString() === "68efa8f2fbcea8e6b466aed4") {
12
- console.log("DEBUG ENABLED");
13
- }
14
- // if (!unit.show) return false;
15
12
  if (!unit.active)
16
13
  return false;
17
14
  if (!unit.formulaToEnable)
@@ -18,12 +18,10 @@ 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
- lines: GroupFormUnitsFlow_1.default.execute(bank, [])
24
+ lines: GroupFormUnitsFlow_1.default.execute(bank)
27
25
  };
28
26
  }
29
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-clinical",
3
- "version": "1.0.124",
3
+ "version": "1.0.126",
4
4
  "description": "Biblioteca Typescript para API NodeJS",
5
5
  "repository": "https://github.com/cabralsilva/c2-clinical.git",
6
6
  "author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",