@integraciones_doc24/sdk 1.1.1 → 1.2.0
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.
- package/lib/baseSdk/user.d.ts +3 -2
- package/lib/index.d.ts +3 -2
- package/lib/lib/baseSdk/diagnostica.d.ts +11 -0
- package/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/baseSdk/index.d.ts +161 -0
- package/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/baseSdk/user.d.ts +41 -0
- package/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/index.d.ts +182 -0
- package/lib/lib/index.js +22 -0
- package/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/baseSdk/index.d.ts +51 -0
- package/lib/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/lib/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/lib/index.d.ts +168 -0
- package/lib/lib/lib/index.js +22 -0
- package/lib/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/lib/request/index.js +26 -0
- package/lib/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/lib/request/token.js +34 -0
- package/lib/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/lib/request/validation.js +28 -0
- package/lib/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/lib/schemas.js +325 -0
- package/lib/lib/lib/test.d.ts +1 -0
- package/lib/lib/lib/test.js +55 -0
- package/lib/lib/lib/types.d.ts +1 -0
- package/lib/lib/lib/types.js +2 -0
- package/lib/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/lib/userSdk/index.d.ts +102 -0
- package/lib/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/lib/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/lib/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/utils.d.ts +4 -0
- package/lib/lib/lib/utils.js +19 -0
- package/lib/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/lib/webhook/index.js +55 -0
- package/lib/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/lib/webhook/token.js +23 -0
- package/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/request/index.js +26 -0
- package/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/request/token.js +34 -0
- package/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/request/validation.js +28 -0
- package/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/schemas.js +325 -0
- package/lib/lib/src/baseSdk/diagnostica.d.ts +11 -0
- package/lib/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/lib/src/baseSdk/index.d.ts +162 -0
- package/lib/lib/src/baseSdk/index.js +66 -0
- package/lib/lib/src/baseSdk/user.d.ts +41 -0
- package/lib/lib/src/baseSdk/user.js +130 -0
- package/lib/lib/src/index.d.ts +183 -0
- package/lib/lib/src/index.js +22 -0
- package/lib/lib/src/request/index.d.ts +2 -0
- package/lib/lib/src/request/index.js +26 -0
- package/lib/lib/src/request/token.d.ts +2 -0
- package/lib/lib/src/request/token.js +34 -0
- package/lib/lib/src/request/validation.d.ts +10 -0
- package/lib/lib/src/request/validation.js +28 -0
- package/lib/lib/src/schemas.d.ts +1340 -0
- package/lib/lib/src/schemas.js +325 -0
- package/lib/lib/src/types.d.ts +1 -0
- package/lib/lib/src/types.js +2 -0
- package/lib/lib/src/userSdk/chat.d.ts +9 -0
- package/lib/lib/src/userSdk/chat.js +98 -0
- package/lib/lib/src/userSdk/index.d.ts +241 -0
- package/lib/lib/src/userSdk/index.js +27 -0
- package/lib/lib/src/userSdk/patients.d.ts +13 -0
- package/lib/lib/src/userSdk/patients.js +55 -0
- package/lib/lib/src/userSdk/schedule.d.ts +15 -0
- package/lib/lib/src/userSdk/schedule.js +76 -0
- package/lib/lib/src/userSdk/specialties.d.ts +4 -0
- package/lib/lib/src/userSdk/specialties.js +19 -0
- package/lib/lib/src/userSdk/videoVisit.d.ts +72 -0
- package/lib/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/lib/src/utils.d.ts +4 -0
- package/lib/lib/src/utils.js +19 -0
- package/lib/lib/src/webhook/index.d.ts +8 -0
- package/lib/lib/src/webhook/index.js +55 -0
- package/lib/lib/src/webhook/responses.d.ts +36 -0
- package/lib/lib/src/webhook/responses.js +42 -0
- package/lib/lib/src/webhook/token.d.ts +2 -0
- package/lib/lib/src/webhook/token.js +23 -0
- package/lib/lib/test.d.ts +1 -0
- package/lib/lib/test.js +55 -0
- package/lib/lib/types.d.ts +1 -0
- package/lib/lib/types.js +2 -0
- package/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/userSdk/index.d.ts +240 -0
- package/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/userSdk/patients.d.ts +13 -0
- package/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/userSdk/schedule.d.ts +15 -0
- package/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/userSdk/videoVisit.d.ts +72 -0
- package/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/utils.d.ts +4 -0
- package/lib/lib/utils.js +19 -0
- package/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/webhook/index.js +55 -0
- package/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/webhook/token.js +23 -0
- package/lib/schemas.d.ts +32 -16
- package/lib/schemas.js +6 -5
- package/lib/src/baseSdk/diagnostica.d.ts +54 -0
- package/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/src/baseSdk/index.d.ts +2 -0
- package/lib/src/baseSdk/index.js +66 -0
- package/lib/src/baseSdk/user.d.ts +89 -0
- package/lib/src/baseSdk/user.js +130 -0
- package/lib/src/index.d.ts +188 -0
- package/lib/src/index.js +22 -0
- package/lib/src/request/index.d.ts +3 -0
- package/lib/src/request/index.js +26 -0
- package/lib/src/request/token.d.ts +2 -0
- package/lib/src/request/token.js +34 -0
- package/lib/src/request/validation.d.ts +10 -0
- package/lib/src/request/validation.js +28 -0
- package/lib/src/schemas.d.ts +1311 -0
- package/lib/src/schemas.js +325 -0
- package/lib/src/types.d.ts +124 -0
- package/lib/src/types.js +2 -0
- package/lib/src/userSdk/chat.d.ts +57 -0
- package/lib/src/userSdk/chat.js +98 -0
- package/lib/src/userSdk/index.d.ts +2 -0
- package/lib/src/userSdk/index.js +27 -0
- package/lib/src/userSdk/patients.d.ts +33 -0
- package/lib/src/userSdk/patients.js +55 -0
- package/lib/src/userSdk/schedule.d.ts +44 -0
- package/lib/src/userSdk/schedule.js +76 -0
- package/lib/src/userSdk/specialties.d.ts +7 -0
- package/lib/src/userSdk/specialties.js +19 -0
- package/lib/src/userSdk/videoVisit.d.ts +111 -0
- package/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/src/utils.d.ts +4 -0
- package/lib/src/utils.js +19 -0
- package/lib/src/webhook/index.d.ts +2 -0
- package/lib/src/webhook/index.js +55 -0
- package/lib/src/webhook/responses.d.ts +35 -0
- package/lib/src/webhook/responses.js +42 -0
- package/lib/src/webhook/token.d.ts +2 -0
- package/lib/src/webhook/token.js +23 -0
- package/lib/types.d.ts +1 -0
- package/lib/userSdk/patients.d.ts +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function getVideoVisitMethods(makeRequest: any): {
|
|
3
|
+
scheduleVideoVisit: (...params: any) => Promise<any>;
|
|
4
|
+
cancelVideoVisit: (...params: any) => Promise<void | undefined>;
|
|
5
|
+
getVideoVisit: (...params: any) => Promise<{
|
|
6
|
+
appointment?: {
|
|
7
|
+
date: Date;
|
|
8
|
+
id: number;
|
|
9
|
+
} | undefined;
|
|
10
|
+
videoVisit?: {
|
|
11
|
+
id: number;
|
|
12
|
+
status: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
paymentStatus?: string | undefined;
|
|
15
|
+
atentionId?: number | undefined;
|
|
16
|
+
id: number | null;
|
|
17
|
+
patientId: number;
|
|
18
|
+
creationDate: Date;
|
|
19
|
+
user: {
|
|
20
|
+
phone: string | null;
|
|
21
|
+
email: string | null;
|
|
22
|
+
id: number;
|
|
23
|
+
};
|
|
24
|
+
vcToken: string;
|
|
25
|
+
}>;
|
|
26
|
+
getPatientVideoVisitHistory: (...params: any) => Promise<any>;
|
|
27
|
+
getVideoVisitDetails: (...params: any) => Promise<{
|
|
28
|
+
professional?: {
|
|
29
|
+
id: number;
|
|
30
|
+
fullName: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
appointment: {
|
|
33
|
+
date: Date;
|
|
34
|
+
id: number;
|
|
35
|
+
} | null;
|
|
36
|
+
id: number;
|
|
37
|
+
language: string;
|
|
38
|
+
patient: {
|
|
39
|
+
fullName: string;
|
|
40
|
+
firstAccessDate: Date;
|
|
41
|
+
lastAccessDate: Date;
|
|
42
|
+
};
|
|
43
|
+
status: string;
|
|
44
|
+
paymentStatus: string;
|
|
45
|
+
finishDate: Date | null;
|
|
46
|
+
retries: number;
|
|
47
|
+
report: {
|
|
48
|
+
motive: string | null;
|
|
49
|
+
actualDesease: string | null;
|
|
50
|
+
indications: string | null;
|
|
51
|
+
alertSigns: string | null;
|
|
52
|
+
extendedMotive: string | null;
|
|
53
|
+
diagnose: {
|
|
54
|
+
code: string;
|
|
55
|
+
description: string;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
pdf: {
|
|
59
|
+
atention?: string | undefined;
|
|
60
|
+
labs?: string | undefined;
|
|
61
|
+
otherExams?: string | undefined;
|
|
62
|
+
images?: string | undefined;
|
|
63
|
+
medication: any[];
|
|
64
|
+
};
|
|
65
|
+
files: {
|
|
66
|
+
name: string;
|
|
67
|
+
url: string;
|
|
68
|
+
}[];
|
|
69
|
+
}>;
|
|
70
|
+
getVideoVisitLink: (...params: any) => Promise<any>;
|
|
71
|
+
getActiveVideoVisits: () => Promise<any>;
|
|
72
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVideoVisitMethods = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const validation_1 = require("../request/validation");
|
|
6
|
+
const schemas_1 = require("../schemas");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const getVideoVisitMethods = (makeRequest) => {
|
|
9
|
+
const scheduleVideoVisit = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.scheduleParameters]), zod_1.string(), async (params) => {
|
|
10
|
+
const specificParams = params.type === 'appointment'
|
|
11
|
+
? {
|
|
12
|
+
type: 'P',
|
|
13
|
+
appointment_id: params.appointmentId,
|
|
14
|
+
}
|
|
15
|
+
: { type: 'E' };
|
|
16
|
+
const mappedParams = {
|
|
17
|
+
...specificParams,
|
|
18
|
+
patient_id: params.patientId,
|
|
19
|
+
specialty_id: params.specialtyId,
|
|
20
|
+
language: params.language.toUpperCase(),
|
|
21
|
+
details: params.details,
|
|
22
|
+
extra_info: params.extraInfo,
|
|
23
|
+
};
|
|
24
|
+
const response = await makeRequest('POST', '/video-visit', mappedParams);
|
|
25
|
+
return response.data.vc_token;
|
|
26
|
+
});
|
|
27
|
+
const cancelVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), zod_1.undefined(), async (vcToken) => {
|
|
28
|
+
const path = `/video-visit/${vcToken}`;
|
|
29
|
+
await makeRequest('DELETE', path);
|
|
30
|
+
});
|
|
31
|
+
const getVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), schemas_1.doc24Schemas.videoVisit, async (vcToken, patientId) => {
|
|
32
|
+
const path = `/video-visit/${vcToken}/${patientId}`;
|
|
33
|
+
const response = await makeRequest('GET', path);
|
|
34
|
+
return mapVideoVisit(response.data);
|
|
35
|
+
});
|
|
36
|
+
const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.videoVisit), async (patientId) => {
|
|
37
|
+
const path = `/video-visit-history/${patientId}`;
|
|
38
|
+
const response = await makeRequest('GET', path);
|
|
39
|
+
return response.data.map((raw) => mapVideoVisit(raw));
|
|
40
|
+
});
|
|
41
|
+
const getVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.videoVisitDetails, async (vcId) => {
|
|
42
|
+
const path = `/video-visit-records/${vcId}`;
|
|
43
|
+
const response = await makeRequest('GET', path);
|
|
44
|
+
return {
|
|
45
|
+
id: response.data.consultation_id,
|
|
46
|
+
status: response.data.status,
|
|
47
|
+
paymentStatus: response.data.payment_status,
|
|
48
|
+
professional: response.data.professional_id
|
|
49
|
+
? {
|
|
50
|
+
id: response.data.professional_id,
|
|
51
|
+
fullName: response.data.professional,
|
|
52
|
+
}
|
|
53
|
+
: undefined,
|
|
54
|
+
patient: {
|
|
55
|
+
fullName: response.data.patient,
|
|
56
|
+
firstAccessDate: response.data.patient_first_access_date &&
|
|
57
|
+
utils_1.parseDateTime(response.data.patient_first_access_date),
|
|
58
|
+
lastAccessDate: response.data.patient_last_access_date &&
|
|
59
|
+
utils_1.parseDateTime(response.data.patient_last_access_date),
|
|
60
|
+
},
|
|
61
|
+
finishDate: response.data.finish_date &&
|
|
62
|
+
utils_1.parseDateTime(response.data.finish_date),
|
|
63
|
+
retries: response.data.retries,
|
|
64
|
+
language: response.data.language,
|
|
65
|
+
appointment: response.data.appointment_id
|
|
66
|
+
? {
|
|
67
|
+
id: response.data.appointment_id,
|
|
68
|
+
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`),
|
|
69
|
+
}
|
|
70
|
+
: null,
|
|
71
|
+
report: {
|
|
72
|
+
motive: response.data.motive,
|
|
73
|
+
actualDesease: response.data.actual_desease,
|
|
74
|
+
indications: response.data.indications,
|
|
75
|
+
alertSigns: response.data.alert_signs,
|
|
76
|
+
extendedMotive: response.data.extended_motive,
|
|
77
|
+
diagnose: response.data.diagnose.map((d) => ({
|
|
78
|
+
description: d.diagnostico,
|
|
79
|
+
code: d.codificacion,
|
|
80
|
+
})),
|
|
81
|
+
},
|
|
82
|
+
pdf: {
|
|
83
|
+
atention: response.data.pdf_atention
|
|
84
|
+
? response.data.pdf_atention
|
|
85
|
+
: undefined,
|
|
86
|
+
medication: response.data.pdf_medication,
|
|
87
|
+
images: response.data.pdf_images
|
|
88
|
+
? response.data.pdf_images
|
|
89
|
+
: undefined,
|
|
90
|
+
otherExams: response.data.pdf_other_exams
|
|
91
|
+
? response.data.pdf_other_exams
|
|
92
|
+
: undefined,
|
|
93
|
+
labs: response.data.pdf_labs ? response.data.pdf_labs : undefined,
|
|
94
|
+
},
|
|
95
|
+
files: response.data.files.map((f) => ({
|
|
96
|
+
name: f.nombre_file,
|
|
97
|
+
url: f.file,
|
|
98
|
+
})),
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
const getActiveVideoVisits = validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.activeVideoVisitData), async () => {
|
|
102
|
+
const path = '/active-video-visits';
|
|
103
|
+
const response = await makeRequest('GET', path);
|
|
104
|
+
const consultations = response.data['active-consultations'];
|
|
105
|
+
return consultations.map((s) => ({
|
|
106
|
+
patientId: s.patient_id,
|
|
107
|
+
consultationId: s.consultation_id,
|
|
108
|
+
vcToken: s.vc_token,
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
const getVideoVisitLink = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), zod_1.string().nullable(), async (vcToken, patientId) => {
|
|
112
|
+
const path = `/video-visit-link/${vcToken}/${patientId}`;
|
|
113
|
+
const response = await makeRequest('GET', path);
|
|
114
|
+
return response.data.link;
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
scheduleVideoVisit,
|
|
118
|
+
cancelVideoVisit,
|
|
119
|
+
getVideoVisit,
|
|
120
|
+
getPatientVideoVisitHistory,
|
|
121
|
+
getVideoVisitDetails,
|
|
122
|
+
getVideoVisitLink,
|
|
123
|
+
getActiveVideoVisits,
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
exports.getVideoVisitMethods = getVideoVisitMethods;
|
|
127
|
+
const mapVideoVisit = (raw) => {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
return {
|
|
130
|
+
id: raw.vc_id,
|
|
131
|
+
creationDate: utils_1.parseDateTime(raw.creation_date),
|
|
132
|
+
patientId: raw.patient_id,
|
|
133
|
+
user: { id: raw.user_id, email: raw.email, phone: raw.phone },
|
|
134
|
+
vcToken: raw.vc_token,
|
|
135
|
+
appointment: raw.appointment_id
|
|
136
|
+
? {
|
|
137
|
+
id: raw.appointment_id,
|
|
138
|
+
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`),
|
|
139
|
+
}
|
|
140
|
+
: undefined,
|
|
141
|
+
videoVisit: raw.video_visit_id
|
|
142
|
+
? { id: raw.video_visit_id, status: raw.video_visit_status }
|
|
143
|
+
: undefined,
|
|
144
|
+
paymentStatus: (_a = raw.payment_status) !== null && _a !== void 0 ? _a : undefined,
|
|
145
|
+
atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
|
|
146
|
+
};
|
|
147
|
+
};
|
package/lib/lib/utils.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIdetificationTypeId = exports.parseDateTime = exports.parseDate = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const timeZone = '-03';
|
|
6
|
+
const parseDate = (str) => exports.parseDateTime(`${str} 00:00:00`);
|
|
7
|
+
exports.parseDate = parseDate;
|
|
8
|
+
const parseDateTime = (str) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
|
|
9
|
+
exports.parseDateTime = parseDateTime;
|
|
10
|
+
const getIdetificationTypeId = (type) => {
|
|
11
|
+
if (type === 'ndi')
|
|
12
|
+
return 6;
|
|
13
|
+
if (type === 'passport')
|
|
14
|
+
return 5;
|
|
15
|
+
if (type === 'credential')
|
|
16
|
+
return 999;
|
|
17
|
+
throw new Error('Invalid identificationType');
|
|
18
|
+
};
|
|
19
|
+
exports.getIdetificationTypeId = getIdetificationTypeId;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRequestHandler = void 0;
|
|
4
|
+
const token_1 = require("./token");
|
|
5
|
+
const responses_1 = require("./responses");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const getRequestHandler = (credentials, baseSdk, eventHandlers) => async (request) => {
|
|
8
|
+
const tokenPayload = await token_1.getWebhookToken(request, credentials);
|
|
9
|
+
if (!tokenPayload)
|
|
10
|
+
return responses_1.unauthorizedErrorResponse();
|
|
11
|
+
const body = request.body;
|
|
12
|
+
const error = await handleEvent(body, baseSdk, eventHandlers);
|
|
13
|
+
if (error)
|
|
14
|
+
return responses_1.unexpectedErrorResponse(error);
|
|
15
|
+
return responses_1.successResponse();
|
|
16
|
+
return responses_1.notFoundErrorResponse();
|
|
17
|
+
};
|
|
18
|
+
exports.getRequestHandler = getRequestHandler;
|
|
19
|
+
const handleEvent = async (body, _baseSdk, eventHandlers) => {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
|
+
const date = utils_1.parseDateTime(body.fecha_estado);
|
|
22
|
+
if (body.tipo === 'consulta')
|
|
23
|
+
return (_a = eventHandlers.onConsultationStatusChange) === null || _a === void 0 ? void 0 : _a.call(eventHandlers, {
|
|
24
|
+
id: Number(body.id_consulta_virtual),
|
|
25
|
+
invitationId: Number(body.id_invitacion),
|
|
26
|
+
status: body.id_estado,
|
|
27
|
+
changeDate: date,
|
|
28
|
+
vcToken: body.vc_token,
|
|
29
|
+
patientId: body.id_paciente !== undefined ? Number(body.id_paciente) : undefined,
|
|
30
|
+
});
|
|
31
|
+
if (body.tipo === 'invitacion')
|
|
32
|
+
return (_b = eventHandlers.onInvitationStatusChange) === null || _b === void 0 ? void 0 : _b.call(eventHandlers, {
|
|
33
|
+
status: body.id_estado,
|
|
34
|
+
changeDate: date,
|
|
35
|
+
vcToken: body.vc_token,
|
|
36
|
+
appointmentId: Number(body.id_turno),
|
|
37
|
+
patientId: Number(body.id_persona),
|
|
38
|
+
professionalId: Number(body.id_profesional),
|
|
39
|
+
});
|
|
40
|
+
if (body.tipo === 'turno')
|
|
41
|
+
return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
|
|
42
|
+
id: Number(body.id_turno),
|
|
43
|
+
status: body.id_estado,
|
|
44
|
+
changeDate: date,
|
|
45
|
+
});
|
|
46
|
+
if (body.tipo === 'chat')
|
|
47
|
+
return (_d = eventHandlers.onChatUpdate) === null || _d === void 0 ? void 0 : _d.call(eventHandlers, {
|
|
48
|
+
id: Number(body.id_consulta_chat),
|
|
49
|
+
status: body.estado_chat === 'A' ? 'active' : 'ended',
|
|
50
|
+
patientId: Number(body.id_paciente),
|
|
51
|
+
professionalId: Number(body.id_profesional),
|
|
52
|
+
date,
|
|
53
|
+
});
|
|
54
|
+
return 'message_not_understood';
|
|
55
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function notFoundErrorResponse(): {
|
|
3
|
+
status: {
|
|
4
|
+
code: number;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
data: {
|
|
8
|
+
error: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export function unauthorizedErrorResponse(): {
|
|
12
|
+
status: {
|
|
13
|
+
code: number;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
data: {
|
|
17
|
+
error: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export function unexpectedErrorResponse(details: any): {
|
|
21
|
+
status: {
|
|
22
|
+
code: number;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
data: {
|
|
26
|
+
error: string;
|
|
27
|
+
details: any;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export function successResponse(data: any): {
|
|
31
|
+
status: {
|
|
32
|
+
code: number;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
data: any;
|
|
36
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.successResponse = exports.unexpectedErrorResponse = exports.unauthorizedErrorResponse = exports.notFoundErrorResponse = void 0;
|
|
4
|
+
const notFoundErrorResponse = () => ({
|
|
5
|
+
status: {
|
|
6
|
+
code: 404,
|
|
7
|
+
message: 'Not Found',
|
|
8
|
+
},
|
|
9
|
+
data: {
|
|
10
|
+
error: 'not_found',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
exports.notFoundErrorResponse = notFoundErrorResponse;
|
|
14
|
+
const unauthorizedErrorResponse = () => ({
|
|
15
|
+
status: {
|
|
16
|
+
code: 401,
|
|
17
|
+
message: 'Unauthorized',
|
|
18
|
+
},
|
|
19
|
+
data: {
|
|
20
|
+
error: 'unauthorized',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
exports.unauthorizedErrorResponse = unauthorizedErrorResponse;
|
|
24
|
+
const unexpectedErrorResponse = (details) => ({
|
|
25
|
+
status: {
|
|
26
|
+
code: 500,
|
|
27
|
+
message: 'Unhandled Error',
|
|
28
|
+
},
|
|
29
|
+
data: {
|
|
30
|
+
error: 'unhandled_error',
|
|
31
|
+
details,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
exports.unexpectedErrorResponse = unexpectedErrorResponse;
|
|
35
|
+
const successResponse = (data) => ({
|
|
36
|
+
status: {
|
|
37
|
+
code: 200,
|
|
38
|
+
message: 'Success',
|
|
39
|
+
},
|
|
40
|
+
data,
|
|
41
|
+
});
|
|
42
|
+
exports.successResponse = successResponse;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWebhookToken = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const getWebhookToken = async (request, credentials) => {
|
|
9
|
+
if (request.headers.authentication === undefined)
|
|
10
|
+
return;
|
|
11
|
+
const decoded = await decodeJwt(request.headers.authentication, credentials.key);
|
|
12
|
+
if (!decoded || decoded.iss !== credentials.iss)
|
|
13
|
+
return;
|
|
14
|
+
return decoded;
|
|
15
|
+
};
|
|
16
|
+
exports.getWebhookToken = getWebhookToken;
|
|
17
|
+
const decodeJwt = (token, key) => new Promise((resolve, reject) => {
|
|
18
|
+
jsonwebtoken_1.default.verify(token, key, (err, result) => {
|
|
19
|
+
if (!result || err)
|
|
20
|
+
return reject(err);
|
|
21
|
+
resolve(result);
|
|
22
|
+
});
|
|
23
|
+
});
|
package/lib/schemas.d.ts
CHANGED
|
@@ -1125,7 +1125,7 @@ export declare const doc24Schemas: {
|
|
|
1125
1125
|
identificationValue: string;
|
|
1126
1126
|
channel: "1" | "2";
|
|
1127
1127
|
}>;
|
|
1128
|
-
declareUserParams: import("zod").ZodObject<{
|
|
1128
|
+
declareUserParams: import("zod").ZodIntersection<import("zod").ZodObject<{
|
|
1129
1129
|
user: import("zod").ZodObject<import("zod").extendShape<{
|
|
1130
1130
|
firstName: import("zod").ZodString;
|
|
1131
1131
|
lastName: import("zod").ZodString;
|
|
@@ -1158,11 +1158,7 @@ export declare const doc24Schemas: {
|
|
|
1158
1158
|
phone: string;
|
|
1159
1159
|
email: string;
|
|
1160
1160
|
}>;
|
|
1161
|
-
channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
|
|
1162
|
-
code: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1163
1161
|
}, "strip", import("zod").ZodTypeAny, {
|
|
1164
|
-
code?: string | undefined;
|
|
1165
|
-
channel?: "1" | "2" | undefined;
|
|
1166
1162
|
user: {
|
|
1167
1163
|
firstName: string;
|
|
1168
1164
|
lastName: string;
|
|
@@ -1175,8 +1171,6 @@ export declare const doc24Schemas: {
|
|
|
1175
1171
|
email: string;
|
|
1176
1172
|
};
|
|
1177
1173
|
}, {
|
|
1178
|
-
code?: string | undefined;
|
|
1179
|
-
channel?: "1" | "2" | undefined;
|
|
1180
1174
|
user: {
|
|
1181
1175
|
firstName: string;
|
|
1182
1176
|
lastName: string;
|
|
@@ -1188,7 +1182,16 @@ export declare const doc24Schemas: {
|
|
|
1188
1182
|
phone: string;
|
|
1189
1183
|
email: string;
|
|
1190
1184
|
};
|
|
1191
|
-
}
|
|
1185
|
+
}>, import("zod").ZodObject<{
|
|
1186
|
+
channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
|
|
1187
|
+
code: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1188
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
1189
|
+
code?: string | undefined;
|
|
1190
|
+
channel?: "1" | "2" | undefined;
|
|
1191
|
+
}, {
|
|
1192
|
+
code?: string | undefined;
|
|
1193
|
+
channel?: "1" | "2" | undefined;
|
|
1194
|
+
}>>;
|
|
1192
1195
|
declareUserResponse: import("zod").ZodObject<import("zod").extendShape<{
|
|
1193
1196
|
patientId: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
1194
1197
|
userInfo: import("zod").ZodObject<{
|
|
@@ -1221,7 +1224,7 @@ export declare const doc24Schemas: {
|
|
|
1221
1224
|
askCode: boolean;
|
|
1222
1225
|
userId: number;
|
|
1223
1226
|
}>;
|
|
1224
|
-
declarePatientParams: import("zod").ZodObject<{
|
|
1227
|
+
declarePatientParams: import("zod").ZodIntersection<import("zod").ZodObject<{
|
|
1225
1228
|
patient: import("zod").ZodObject<{
|
|
1226
1229
|
firstName: import("zod").ZodString;
|
|
1227
1230
|
lastName: import("zod").ZodString;
|
|
@@ -1247,11 +1250,7 @@ export declare const doc24Schemas: {
|
|
|
1247
1250
|
birthdate: Date;
|
|
1248
1251
|
gender: "m" | "f";
|
|
1249
1252
|
}>;
|
|
1250
|
-
channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
|
|
1251
|
-
code: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1252
1253
|
}, "strip", import("zod").ZodTypeAny, {
|
|
1253
|
-
code?: string | undefined;
|
|
1254
|
-
channel?: "1" | "2" | undefined;
|
|
1255
1254
|
patient: {
|
|
1256
1255
|
firstName: string;
|
|
1257
1256
|
lastName: string;
|
|
@@ -1262,8 +1261,6 @@ export declare const doc24Schemas: {
|
|
|
1262
1261
|
gender: "m" | "f";
|
|
1263
1262
|
};
|
|
1264
1263
|
}, {
|
|
1265
|
-
code?: string | undefined;
|
|
1266
|
-
channel?: "1" | "2" | undefined;
|
|
1267
1264
|
patient: {
|
|
1268
1265
|
firstName: string;
|
|
1269
1266
|
lastName: string;
|
|
@@ -1273,7 +1270,16 @@ export declare const doc24Schemas: {
|
|
|
1273
1270
|
birthdate: Date;
|
|
1274
1271
|
gender: "m" | "f";
|
|
1275
1272
|
};
|
|
1276
|
-
}
|
|
1273
|
+
}>, import("zod").ZodObject<{
|
|
1274
|
+
channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
|
|
1275
|
+
code: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1276
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
1277
|
+
code?: string | undefined;
|
|
1278
|
+
channel?: "1" | "2" | undefined;
|
|
1279
|
+
}, {
|
|
1280
|
+
code?: string | undefined;
|
|
1281
|
+
channel?: "1" | "2" | undefined;
|
|
1282
|
+
}>>;
|
|
1277
1283
|
declarePatientResponse: import("zod").ZodObject<{
|
|
1278
1284
|
patientId: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
1279
1285
|
userInfo: import("zod").ZodObject<{
|
|
@@ -1302,4 +1308,14 @@ export declare const doc24Schemas: {
|
|
|
1302
1308
|
};
|
|
1303
1309
|
askCode: boolean;
|
|
1304
1310
|
}>;
|
|
1311
|
+
verificationParams: import("zod").ZodObject<{
|
|
1312
|
+
channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
|
|
1313
|
+
code: import("zod").ZodOptional<import("zod").ZodString>;
|
|
1314
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
1315
|
+
code?: string | undefined;
|
|
1316
|
+
channel?: "1" | "2" | undefined;
|
|
1317
|
+
}, {
|
|
1318
|
+
code?: string | undefined;
|
|
1319
|
+
channel?: "1" | "2" | undefined;
|
|
1320
|
+
}>;
|
|
1305
1321
|
};
|
package/lib/schemas.js
CHANGED
|
@@ -179,16 +179,16 @@ const sendVerificationCodeParams = zod_1.object({
|
|
|
179
179
|
identificationValue: zod_1.string(),
|
|
180
180
|
channel: zod_1.enum(['1', '2']),
|
|
181
181
|
});
|
|
182
|
-
const
|
|
183
|
-
user,
|
|
182
|
+
const verificationParams = zod_1.object({
|
|
184
183
|
channel: zod_1.enum(['1', '2']).optional(),
|
|
185
184
|
code: zod_1.string().optional(),
|
|
186
185
|
});
|
|
186
|
+
const declareUserParams = zod_1.object({
|
|
187
|
+
user,
|
|
188
|
+
}).and(verificationParams);
|
|
187
189
|
const declarePatientParams = zod_1.object({
|
|
188
190
|
patient,
|
|
189
|
-
|
|
190
|
-
code: zod_1.string().optional(),
|
|
191
|
-
});
|
|
191
|
+
}).and(verificationParams);
|
|
192
192
|
const declarePatientResponse = zod_1.object({
|
|
193
193
|
patientId: zod_1.number().nullable(),
|
|
194
194
|
userInfo: zod_1.object({
|
|
@@ -322,4 +322,5 @@ exports.doc24Schemas = {
|
|
|
322
322
|
declareUserResponse,
|
|
323
323
|
declarePatientParams,
|
|
324
324
|
declarePatientResponse,
|
|
325
|
+
verificationParams,
|
|
325
326
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
3
|
+
getDiagnosticaHistory: (patient: {
|
|
4
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
5
|
+
identificationValue: string;
|
|
6
|
+
gender: "m" | "f";
|
|
7
|
+
}, from: Date, to: Date) => Promise<{
|
|
8
|
+
date: Date;
|
|
9
|
+
location: string;
|
|
10
|
+
exams: string[];
|
|
11
|
+
deepLink: string;
|
|
12
|
+
}[]>;
|
|
13
|
+
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
14
|
+
firstName: string;
|
|
15
|
+
lastName: string;
|
|
16
|
+
identificationType: "dni";
|
|
17
|
+
identificationValue: string;
|
|
18
|
+
gender: "m" | "f";
|
|
19
|
+
phone: string;
|
|
20
|
+
email: string;
|
|
21
|
+
language: string;
|
|
22
|
+
birthday: Date;
|
|
23
|
+
}, patient: {
|
|
24
|
+
firstName: string;
|
|
25
|
+
lastName: string;
|
|
26
|
+
identificationType: "dni";
|
|
27
|
+
identificationValue: string;
|
|
28
|
+
gender: "m" | "f";
|
|
29
|
+
birthday: Date;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
forwardingRequired: true;
|
|
32
|
+
deepLink: string;
|
|
33
|
+
} | {
|
|
34
|
+
forwardingRequired: false;
|
|
35
|
+
}>;
|
|
36
|
+
getDiagnosticaAccess: (kiosk: string, user: {
|
|
37
|
+
firstName: string;
|
|
38
|
+
lastName: string;
|
|
39
|
+
identificationType: "dni";
|
|
40
|
+
identificationValue: string;
|
|
41
|
+
gender: "m" | "f";
|
|
42
|
+
phone: string;
|
|
43
|
+
email: string;
|
|
44
|
+
language: string;
|
|
45
|
+
birthday: Date;
|
|
46
|
+
}, patient: {
|
|
47
|
+
firstName: string;
|
|
48
|
+
lastName: string;
|
|
49
|
+
identificationType: "dni";
|
|
50
|
+
identificationValue: string;
|
|
51
|
+
gender: "m" | "f";
|
|
52
|
+
birthday: Date;
|
|
53
|
+
}) => Promise<void>;
|
|
54
|
+
};
|