c2-clinical 1.0.209 → 1.0.211

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.
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const enum_1 = require("../../models/enum");
6
7
  const ExecFormulaFlowTester_1 = __importDefault(require("./ExecFormulaFlowTester"));
7
8
  const GetAnswerRelationedsFlowItemTester_1 = __importDefault(require("./item/GetAnswerRelationedsFlowItemTester"));
8
9
  class ProcessAnswerFlowTester {
@@ -50,11 +51,40 @@ class ProcessAnswerFlowTester {
50
51
  // formulaToMessage para validations
51
52
  if (relationed?.validations?.length) {
52
53
  relationed.validations
53
- .filter((v) => v.formulaToMessage)
54
+ .filter((v) => v.formulaToMessage && !v.auto)
54
55
  .forEach((v) => {
55
56
  v.message = ExecFormulaFlowTester_1.default.execute(v.formulaToMessage, allQuestionsAnswereds, attendanceMetActivities);
56
57
  });
57
58
  }
59
+ // check minValue e maxValue
60
+ if (relationed.typeAnswer === enum_1.TypeAnswerEnum.OPEN_NUMBER) {
61
+ const validations = [
62
+ ...(relationed.validations?.filter((v) => !v.auto) ?? [])
63
+ ];
64
+ if (!isNaN(Number(relationed.minValue)) &&
65
+ Number(relationed.answer) < Number(relationed.minValue)) {
66
+ validations.push({
67
+ type: enum_1.TypeValidationEnum.REQUIRED,
68
+ typeOutput: enum_1.TypeOutputValidationEnum.TEXT,
69
+ message: "O valor mínimo é " + relationed.minValue,
70
+ formulaToMessage: "'O valor mínimo é " + relationed.minValue + "'",
71
+ auto: true
72
+ });
73
+ }
74
+ if (!isNaN(Number(relationed.maxValue)) &&
75
+ Number(relationed.answer) > Number(relationed.maxValue)) {
76
+ validations.push({
77
+ type: enum_1.TypeValidationEnum.REQUIRED,
78
+ typeOutput: enum_1.TypeOutputValidationEnum.TEXT,
79
+ message: "O valor máximo é " + relationed.maxValue,
80
+ formulaToMessage: "'O valor máximo é " + relationed.maxValue + "'",
81
+ auto: true
82
+ });
83
+ }
84
+ if (validations.length) {
85
+ relationed.validations = [...validations];
86
+ }
87
+ }
58
88
  // check options is enables
59
89
  if (relationed?.options?.length) {
60
90
  relationed.options
@@ -44,6 +44,7 @@ export interface IValidationQuestion {
44
44
  typeOutput: TypeOutputValidationEnum;
45
45
  formulaToMessage: string;
46
46
  message?: string;
47
+ auto?: boolean;
47
48
  }
48
49
  export interface IRow {
49
50
  id: string;
@@ -61,6 +62,10 @@ export interface IFormUnit extends IDefault {
61
62
  parent: Types.ObjectId | IFormUnit;
62
63
  line: number;
63
64
  column: number;
65
+ width: number;
66
+ height: "large" | "medium" | "small";
67
+ minValue: number;
68
+ maxValue: number;
64
69
  type: TypeFormUnitEnum;
65
70
  typeAnswer: TypeAnswerEnum;
66
71
  defaultAnswer: any;
@@ -252,6 +257,7 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
252
257
  code: string;
253
258
  active: boolean;
254
259
  form: Types.ObjectId;
260
+ height: "large" | "medium" | "small";
255
261
  isDefault: boolean;
256
262
  options: Types.DocumentArray<{
257
263
  description: string;
@@ -337,6 +343,9 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
337
343
  column?: number | null | undefined;
338
344
  typeAnswer?: string | null | undefined;
339
345
  defaultAnswer?: any;
346
+ width?: number | null | undefined;
347
+ minValue?: number | null | undefined;
348
+ maxValue?: number | null | undefined;
340
349
  variantView?: string | null | undefined;
341
350
  typeButtonAction?: string | null | undefined;
342
351
  externalFlowCode?: string | null | undefined;
@@ -400,6 +409,7 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
400
409
  code: string;
401
410
  active: boolean;
402
411
  form: Types.ObjectId;
412
+ height: "large" | "medium" | "small";
403
413
  isDefault: boolean;
404
414
  options: Types.DocumentArray<{
405
415
  description: string;
@@ -485,6 +495,9 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
485
495
  column?: number | null | undefined;
486
496
  typeAnswer?: string | null | undefined;
487
497
  defaultAnswer?: any;
498
+ width?: number | null | undefined;
499
+ minValue?: number | null | undefined;
500
+ maxValue?: number | null | undefined;
488
501
  variantView?: string | null | undefined;
489
502
  typeButtonAction?: string | null | undefined;
490
503
  externalFlowCode?: string | null | undefined;
@@ -548,6 +561,7 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
548
561
  code: string;
549
562
  active: boolean;
550
563
  form: Types.ObjectId;
564
+ height: "large" | "medium" | "small";
551
565
  isDefault: boolean;
552
566
  options: Types.DocumentArray<{
553
567
  description: string;
@@ -633,6 +647,9 @@ export declare const FormUnitSchema: Schema<any, import("mongoose").Model<any, a
633
647
  column?: number | null | undefined;
634
648
  typeAnswer?: string | null | undefined;
635
649
  defaultAnswer?: any;
650
+ width?: number | null | undefined;
651
+ minValue?: number | null | undefined;
652
+ maxValue?: number | null | undefined;
636
653
  variantView?: string | null | undefined;
637
654
  typeButtonAction?: string | null | undefined;
638
655
  externalFlowCode?: string | null | undefined;
@@ -52,6 +52,10 @@ exports.FormUnitSchema = new mongoose_1.Schema({
52
52
  },
53
53
  typeAnswer: { type: String, enum: enum_1.TypeAnswerEnum },
54
54
  defaultAnswer: { type: mongoose_1.Schema.Types.Mixed },
55
+ width: { type: Number },
56
+ height: { type: String, enum: ["large", "medium", "small"], default: "medium" },
57
+ minValue: { type: Number },
58
+ maxValue: { type: Number },
55
59
  // PERGUNTAS DEFAULT SAO AS CALCULADAS COM BASE NO PERFIL DO PACIENTE E CALCULADAS AO CARREGAR O FORMULARIO
56
60
  isDefault: { type: Boolean, default: false },
57
61
  category: { type: String, enum: enum_1.CategoryFormEnum, required: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-clinical",
3
- "version": "1.0.209",
3
+ "version": "1.0.211",
4
4
  "description": "Biblioteca Typescript para API NodeJS",
5
5
  "repository": {
6
6
  "type": "git",