c2-clinical 1.0.123 → 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.
@@ -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,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, [])
@@ -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
- for (const row of rows) {
7
- this.formUnits = [...this.formUnits, ...this.iterate(row)];
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.collumns?.forEach((collumn) => {
14
- formUnits.push({ ...collumn, lineId: row.id });
15
- if (collumn.lines?.length) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-clinical",
3
- "version": "1.0.123",
3
+ "version": "1.0.125",
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>",