c2-clinical 1.0.119 → 1.0.121

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.
@@ -2,7 +2,6 @@ import { IFormUnit, IRow } from "../../../models/form/FormUnit";
2
2
  declare class BuildTreeFlowItem {
3
3
  private bank;
4
4
  execute(questions: IFormUnit[]): IRow[];
5
- private iterate;
6
5
  private buildRows;
7
6
  }
8
7
  declare const _default: BuildTreeFlowItem;
@@ -8,61 +8,15 @@ class BuildTreeFlowItem {
8
8
  bank = [];
9
9
  execute(questions) {
10
10
  this.bank = questions;
11
- //extrai os elements raiz (sem parent)
12
- // const rootFormUnit: IFormUnit[] = questions
13
- // .filter((q: IFormUnit) => !q.parent)
14
- // .map((q: IFormUnit) => {
15
- // return {
16
- // ...q,
17
- // children: []
18
- // };
19
- // });
20
- // rootFormUnit.sort((a, b) => a.line - b.line);
21
- // //extrai os elements que tem algum parent
22
- // const children: IFormUnit[] = questions.filter((q: IFormUnit) => !!q.parent);
23
- // rootFormUnit?.forEach((q: IFormUnit) => {
24
- // this.iterate(q, children);
25
- // });
26
- // return rootFormUnit;
27
11
  const rootFormUnit = questions.filter((q) => !q.parent);
28
12
  return this.buildRows({ parent: undefined, children: rootFormUnit });
29
13
  }
30
- iterate(parent, children) {
31
- parent.children = children.filter((child) => child.parent?._id?.toString() === parent?._id?.toString());
32
- parent.children.sort((a, b) => a.line - b.line);
33
- const lines = parent.children.reduce((acc, item) => {
34
- if (!acc.some((a) => a.line === item.line)) {
35
- acc.push({
36
- id: GenerateUUIDFlowItem_1.default.execute(),
37
- line: item.line,
38
- collumns: []
39
- });
40
- }
41
- acc.find((a) => a.line === item.line)?.collumns.push(item);
42
- return acc;
43
- }, []);
44
- parent.lines?.forEach((line, index) => {
45
- line.collumns?.sort((a, b) => a.column - b.column);
46
- });
47
- if (parent.children.length > 0) {
48
- parent.children.forEach((parentPossible) => {
49
- this.iterate(parentPossible, children);
50
- });
51
- }
52
- }
53
- // private iterate2(config: { parent?: IFormUnit; children: IFormUnit[] }): IRow[] {
54
- // config.children.sort((a, b) => a.line - b.line);
55
- // if (!config.parent) {
56
- // return this.buildRows(config);
57
- // }
58
- // return this.buildRows(config);
59
- // }
60
14
  buildRows(config) {
61
15
  config.children.sort((a, b) => a.line - b.line);
62
16
  const lines = config.children.reduce((acc, item) => {
63
17
  if (!acc.some((a) => a.line === item.line)) {
64
18
  acc.push({
65
- id: GenerateUUIDFlowItem_1.default.execute(),
19
+ id: item.lineId ?? GenerateUUIDFlowItem_1.default.execute(),
66
20
  line: item.line,
67
21
  collumns: []
68
22
  });
@@ -11,7 +11,7 @@ class ConvertRowToFormUnitsFlowItem {
11
11
  iterate(row) {
12
12
  let formUnits = [];
13
13
  row.collumns?.forEach((collumn) => {
14
- formUnits.push({ ...collumn, lines: undefined });
14
+ formUnits.push({ ...collumn, lineId: row.id });
15
15
  if (collumn.lines?.length) {
16
16
  collumn.lines.forEach((line) => {
17
17
  formUnits = [...formUnits, ...this.iterate(line)];
@@ -95,6 +95,7 @@ export interface IFormUnit extends IDefault {
95
95
  }[];
96
96
  };
97
97
  isAnalyticalResult: boolean;
98
+ lineId?: string;
98
99
  }
99
100
  export interface IQuestionOption {
100
101
  sequence: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-clinical",
3
- "version": "1.0.119",
3
+ "version": "1.0.121",
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>",