c2-clinical 1.0.39 → 1.0.41

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,11 +1,19 @@
1
+ export declare enum QAStatusEnum {
2
+ ANSWERED = "ANSWERED",
3
+ DUED = "DUED",
4
+ SCHEDULED = "SCHEDULED",
5
+ AWAITING_SEND = "AWAITING_SEND",
6
+ NOT_ANSWERED = "NOT_ANSWERED",
7
+ UNDEFINED = "UNDEFINED"
8
+ }
1
9
  export declare enum ChannelNotificationEnum {
2
- "EMAIL" = "EMAIL",
3
- "WHATSAPP" = "WHATSAPP",
4
- "APP" = "APP"
10
+ EMAIL = "EMAIL",
11
+ WHATSAPP = "WHATSAPP",
12
+ APP = "APP"
5
13
  }
6
14
  export declare enum GenreEnum {
7
- "MALE" = "MALE",
8
- "FEMALE" = "FEMALE"
15
+ MALE = "MALE",
16
+ FEMALE = "FEMALE"
9
17
  }
10
18
  export declare enum StatusQPCEnum {
11
19
  AWAITING_IMPORT = "AWAITING_IMPORT",
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeMessageEnum = exports.TypeOutputValidationEnum = exports.TypeValidationEnum = exports.TypeAnswerEnum = exports.TypeFormUnitEnum = exports.OwnerEnum = exports.TypeFormEnum = exports.CategoryFormEnum = exports.MetTargetConditionEnum = exports.StatusQPCEnum = exports.GenreEnum = exports.ChannelNotificationEnum = void 0;
3
+ exports.TypeMessageEnum = exports.TypeOutputValidationEnum = exports.TypeValidationEnum = exports.TypeAnswerEnum = exports.TypeFormUnitEnum = exports.OwnerEnum = exports.TypeFormEnum = exports.CategoryFormEnum = exports.MetTargetConditionEnum = exports.StatusQPCEnum = exports.GenreEnum = exports.ChannelNotificationEnum = exports.QAStatusEnum = void 0;
4
+ var QAStatusEnum;
5
+ (function (QAStatusEnum) {
6
+ QAStatusEnum["ANSWERED"] = "ANSWERED";
7
+ QAStatusEnum["DUED"] = "DUED";
8
+ QAStatusEnum["SCHEDULED"] = "SCHEDULED";
9
+ QAStatusEnum["AWAITING_SEND"] = "AWAITING_SEND";
10
+ QAStatusEnum["NOT_ANSWERED"] = "NOT_ANSWERED";
11
+ QAStatusEnum["UNDEFINED"] = "UNDEFINED";
12
+ })(QAStatusEnum || (exports.QAStatusEnum = QAStatusEnum = {}));
4
13
  var ChannelNotificationEnum;
5
14
  (function (ChannelNotificationEnum) {
6
15
  ChannelNotificationEnum["EMAIL"] = "EMAIL";
@@ -8,7 +8,9 @@ export interface IQA extends IDefault {
8
8
  programming: Types.ObjectId | IQAProgramming;
9
9
  form: Types.ObjectId | IForm;
10
10
  answeredDateTime: Date;
11
+ sendAppointmentDateTime: Date;
11
12
  dueDate: Date;
13
+ sent: boolean;
12
14
  code: string;
13
15
  }
14
16
  export declare const QASchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
@@ -16,11 +18,19 @@ export declare const QASchema: Schema<any, import("mongoose").Model<any, any, an
16
18
  createdAt: string;
17
19
  updatedAt: string;
18
20
  };
21
+ toJSON: {
22
+ virtuals: true;
23
+ };
24
+ toObject: {
25
+ virtuals: true;
26
+ };
19
27
  }, {} & {
20
28
  account: any;
21
29
  form: any;
22
30
  patient: any;
23
31
  programming: any;
32
+ sendAppointmentDateTime: NativeDate;
33
+ sent: string;
24
34
  code?: string | null | undefined;
25
35
  answeredDateTime?: NativeDate | null | undefined;
26
36
  dueDate?: NativeDate | null | undefined;
@@ -29,6 +39,8 @@ export declare const QASchema: Schema<any, import("mongoose").Model<any, any, an
29
39
  form: any;
30
40
  patient: any;
31
41
  programming: any;
42
+ sendAppointmentDateTime: NativeDate;
43
+ sent: string;
32
44
  code?: string | null | undefined;
33
45
  answeredDateTime?: NativeDate | null | undefined;
34
46
  dueDate?: NativeDate | null | undefined;
@@ -37,6 +49,8 @@ export declare const QASchema: Schema<any, import("mongoose").Model<any, any, an
37
49
  form: any;
38
50
  patient: any;
39
51
  programming: any;
52
+ sendAppointmentDateTime: NativeDate;
53
+ sent: string;
40
54
  code?: string | null | undefined;
41
55
  answeredDateTime?: NativeDate | null | undefined;
42
56
  dueDate?: NativeDate | null | undefined;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QASchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
+ const enum_1 = require("../enum");
5
6
  exports.QASchema = new mongoose_1.Schema({
6
7
  account: { type: mongoose_1.Types.ObjectId, ref: "account", required: true },
7
8
  patient: { type: mongoose_1.Types.ObjectId, ref: "patient", required: true },
@@ -9,7 +10,48 @@ exports.QASchema = new mongoose_1.Schema({
9
10
  form: { type: mongoose_1.Types.ObjectId, ref: "form", required: true },
10
11
  dueDate: { type: Date },
11
12
  answeredDateTime: { type: Date },
13
+ sendAppointmentDateTime: { type: Date, required: true },
14
+ sent: { type: String, default: false },
12
15
  code: { type: String }
13
16
  }, {
14
- timestamps: { createdAt: "createdAtDateTime", updatedAt: "updatedAtDateTime" }
17
+ timestamps: { createdAt: "createdAtDateTime", updatedAt: "updatedAtDateTime" },
18
+ toJSON: { virtuals: true },
19
+ toObject: { virtuals: true }
15
20
  });
21
+ exports.QASchema.virtual("status").get(function () {
22
+ const now = new Date();
23
+ const sent = this.sent === true;
24
+ const answered = !!this.answeredDateTime;
25
+ const sendAppointmentPast = this.sendAppointmentDateTime < now;
26
+ const dueDatePast = this.dueDate < now;
27
+ if (answered) {
28
+ return enum_1.QAStatusEnum.ANSWERED;
29
+ }
30
+ if (dueDatePast) {
31
+ return enum_1.QAStatusEnum.DUED;
32
+ }
33
+ if (!sent && sendAppointmentPast) {
34
+ return enum_1.QAStatusEnum.AWAITING_SEND;
35
+ }
36
+ if (sent && !answered) {
37
+ return enum_1.QAStatusEnum.NOT_ANSWERED;
38
+ }
39
+ return enum_1.QAStatusEnum.SCHEDULED;
40
+ });
41
+ // sent | pasou a data de sendAppointDate | answeredDate exists | passou a data de duedDate | status
42
+ // 0 0 0 0 SCHEDULED
43
+ // 0 0 0 1 DUED
44
+ // 0 0 1 0 ANSWERED
45
+ // 0 0 1 1 ANSWERED
46
+ // 0 1 0 0 AWAITING_SEND
47
+ // 0 1 0 1 DUED
48
+ // 0 1 1 0 ANSWERED
49
+ // 0 1 1 1 ANSWERED
50
+ // 1 0 0 0 NOT_ANSWERED
51
+ // 1 0 0 1 DUED
52
+ // 1 0 1 0 ANSWERED
53
+ // 1 0 1 1 ANSWERED
54
+ // 1 1 0 0 NOT_ANSWERED
55
+ // 1 1 0 1 DUED
56
+ // 1 1 1 0 ANSWERED
57
+ // 1 1 1 1 ANSWERED
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-clinical",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
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>",