@integraciones_doc24/sdk 0.39.4 → 0.39.5

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.
Files changed (44) hide show
  1. package/README.md +93 -83
  2. package/package.json +1 -1
  3. package/lib/baseSdk/diagnostica.d.ts +0 -54
  4. package/lib/baseSdk/diagnostica.js +0 -79
  5. package/lib/baseSdk/external.d.ts +0 -177
  6. package/lib/baseSdk/external.js +0 -96
  7. package/lib/baseSdk/index.d.ts +0 -2
  8. package/lib/baseSdk/index.js +0 -70
  9. package/lib/baseSdk/user.d.ts +0 -41
  10. package/lib/baseSdk/user.js +0 -88
  11. package/lib/index.d.ts +0 -159
  12. package/lib/index.js +0 -22
  13. package/lib/request/index.d.ts +0 -3
  14. package/lib/request/index.js +0 -26
  15. package/lib/request/token.d.ts +0 -2
  16. package/lib/request/token.js +0 -34
  17. package/lib/request/validation.d.ts +0 -10
  18. package/lib/request/validation.js +0 -28
  19. package/lib/schemas.d.ts +0 -1125
  20. package/lib/schemas.js +0 -307
  21. package/lib/types.d.ts +0 -118
  22. package/lib/types.js +0 -2
  23. package/lib/userSdk/chat.d.ts +0 -57
  24. package/lib/userSdk/chat.js +0 -98
  25. package/lib/userSdk/external.d.ts +0 -34
  26. package/lib/userSdk/external.js +0 -71
  27. package/lib/userSdk/index.d.ts +0 -2
  28. package/lib/userSdk/index.js +0 -27
  29. package/lib/userSdk/patients.d.ts +0 -24
  30. package/lib/userSdk/patients.js +0 -46
  31. package/lib/userSdk/schedule.d.ts +0 -44
  32. package/lib/userSdk/schedule.js +0 -76
  33. package/lib/userSdk/specialties.d.ts +0 -7
  34. package/lib/userSdk/specialties.js +0 -19
  35. package/lib/userSdk/videoVisit.d.ts +0 -111
  36. package/lib/userSdk/videoVisit.js +0 -147
  37. package/lib/utils.d.ts +0 -4
  38. package/lib/utils.js +0 -27
  39. package/lib/webhook/index.d.ts +0 -2
  40. package/lib/webhook/index.js +0 -55
  41. package/lib/webhook/responses.d.ts +0 -35
  42. package/lib/webhook/responses.js +0 -42
  43. package/lib/webhook/token.d.ts +0 -2
  44. package/lib/webhook/token.js +0 -23
@@ -1,2 +0,0 @@
1
- import { Doc24 } from '../types';
2
- export declare const userSdk: (url: string, credentials: Doc24.SdkCredentials, userId: number) => Promise<Doc24.UserSdk>;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.userSdk = void 0;
4
- const request_1 = require("../request");
5
- const chat_1 = require("./chat");
6
- const patients_1 = require("./patients");
7
- const schedule_1 = require("./schedule");
8
- const specialties_1 = require("./specialties");
9
- const videoVisit_1 = require("./videoVisit");
10
- const userSdk = async (url, credentials, userId) => {
11
- const makeRequest = await request_1.getRequestFactory(url, credentials, userId);
12
- const patientMethods = patients_1.getPatientMethods(makeRequest);
13
- const specialtyMethods = specialties_1.getSpecialtiesMethods(makeRequest);
14
- const scheduleMethods = schedule_1.getScheduleMethods(makeRequest);
15
- const videoVisitMethods = videoVisit_1.getVideoVisitMethods(makeRequest);
16
- const chatMethods = chat_1.getChatMethods(makeRequest);
17
- const sdk = {
18
- ...patientMethods,
19
- ...specialtyMethods,
20
- ...scheduleMethods,
21
- ...videoVisitMethods,
22
- ...chatMethods,
23
- userId,
24
- };
25
- return sdk;
26
- };
27
- exports.userSdk = userSdk;
@@ -1,24 +0,0 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getPatientMethods: (makeRequest: RequestMaker) => {
3
- declarePatient: (patient: {
4
- firstName: string;
5
- lastName: string;
6
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
7
- identificationValue: string;
8
- gender: "m" | "f";
9
- countryId: string;
10
- birthdate: Date;
11
- }) => Promise<number>;
12
- updatePatient: (oldIdentification: {
13
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
14
- identificationValue: string;
15
- }, patient: {
16
- firstName: string;
17
- lastName: string;
18
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
19
- identificationValue: string;
20
- gender: "m" | "f";
21
- countryId: string;
22
- birthdate: Date;
23
- }) => Promise<number>;
24
- };
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPatientMethods = void 0;
4
- const date_fns_1 = require("date-fns");
5
- const zod_1 = require("zod");
6
- const validation_1 = require("../request/validation");
7
- const schemas_1 = require("../schemas");
8
- const utils_1 = require("../utils");
9
- const getPatientMethods = (makeRequest) => {
10
- const declarePatient = async (patient) => {
11
- const mappedPatient = {
12
- lastname: patient.lastName,
13
- firstname: patient.firstName,
14
- identification_type: utils_1.getIndetificationTypeId(patient.identificationType),
15
- identification_value: patient.identificationValue,
16
- birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
17
- gender: patient.gender.toUpperCase(),
18
- country_id: patient.countryId,
19
- };
20
- const response = await makeRequest('POST', '/patient', {
21
- user_data: mappedPatient,
22
- });
23
- return response.data.patient_id;
24
- };
25
- const updatePatient = async (oldIdentificaiton, patient) => {
26
- const mappedPatient = {
27
- lastname: patient.lastName,
28
- firstname: patient.firstName,
29
- identification_type: utils_1.getIndetificationTypeId(patient.identificationType),
30
- identification_value: patient.identificationValue,
31
- birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
32
- gender: patient.gender.toUpperCase(),
33
- };
34
- const response = await makeRequest('POST', '/update-patient', {
35
- old_identification_type: utils_1.getIndetificationTypeId(oldIdentificaiton.identificationType),
36
- old_identification_value: oldIdentificaiton.identificationValue,
37
- user_data: mappedPatient,
38
- });
39
- return response.data.patient_id;
40
- };
41
- return {
42
- declarePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.patient]), zod_1.number(), declarePatient),
43
- updatePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.oldIdentificaiton, schemas_1.doc24Schemas.patient]), zod_1.number(), updatePatient),
44
- };
45
- };
46
- exports.getPatientMethods = getPatientMethods;
@@ -1,44 +0,0 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
3
- getSchedule: (patientId: number, specialtyId: number, filter?: {
4
- date?: Date | undefined;
5
- professionalId?: number | undefined;
6
- offset?: number | undefined;
7
- limit?: number | undefined;
8
- weekDay?: number | undefined;
9
- startHour?: string | undefined;
10
- finishHour?: string | undefined;
11
- } | undefined) => Promise<{
12
- length?: number | null | undefined;
13
- ranking?: unknown;
14
- date: Date;
15
- type: "appointment" | "chat" | "instant";
16
- id: string | number;
17
- professional: {
18
- id: number;
19
- fullName: string;
20
- logoUrl: string;
21
- };
22
- clinicId: number;
23
- cost: string;
24
- specialty: {
25
- id: number;
26
- description: string;
27
- };
28
- atentions: number;
29
- }[]>;
30
- getScheduleDates: (patientId: number, filter?: {
31
- specialtyId?: number | undefined;
32
- professionalId?: number | undefined;
33
- } | undefined) => Promise<Date[]>;
34
- getAppointment: (appointmentId: number) => Promise<{
35
- date: Date;
36
- id: number;
37
- professionalId: number;
38
- }>;
39
- getAppointmentByVcToken: (vcToken: string) => Promise<{
40
- date: Date;
41
- id: number;
42
- professionalId: number;
43
- }>;
44
- };
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getScheduleMethods = void 0;
4
- const date_fns_1 = require("date-fns");
5
- const zod_1 = require("zod");
6
- const validation_1 = require("../request/validation");
7
- const schemas_1 = require("../schemas");
8
- const utils_1 = require("../utils");
9
- const getScheduleMethods = (makeRequest) => {
10
- const getScheduleDates = validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), async (patientId, filter = {}) => {
11
- const mappedFilter = {
12
- specialty_id: filter.specialtyId,
13
- professional_id: filter.professionalId,
14
- };
15
- const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
16
- const response = await makeRequest('GET', path);
17
- return response.data.available_dates.map((o) => utils_1.parseDate(o.date));
18
- });
19
- const getSchedule = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.scheduleFilter.optional()]), zod_1.array(schemas_1.doc24Schemas.availableAppointment), async (patientId, specialtyId, filter = {}) => {
20
- const mappedFilter = {
21
- id_professional: filter.professionalId,
22
- offset: filter.offset,
23
- limit: filter.limit,
24
- week_day: filter.weekDay,
25
- date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
26
- start_hour: filter.startHour,
27
- finish_hour: filter.finishHour,
28
- };
29
- const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
30
- const response = await makeRequest('GET', path);
31
- return response.data.available_appointments.map((a) => ({
32
- id: a.id,
33
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`),
34
- clinicId: a.clinic,
35
- professional: {
36
- id: a.professional_id,
37
- fullName: a.professional,
38
- logoUrl: a.logo,
39
- },
40
- cost: a.cost,
41
- specialty: {
42
- id: a.specialty_id,
43
- description: a.specialty,
44
- },
45
- type: a.type === 'P' ? 'appointment' : a.type === 'T' ? 'chat' : 'instant',
46
- atentions: a.atentions,
47
- ranking: a.ranking,
48
- length: a.length,
49
- }));
50
- });
51
- const getAppointment = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, async (appointmentId) => {
52
- const path = `/appointment/${appointmentId}`;
53
- const response = await makeRequest('GET', path);
54
- return {
55
- id: response.data.id,
56
- professionalId: response.data.professional_id,
57
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
58
- };
59
- });
60
- const getAppointmentByVcToken = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, async (vcToken) => {
61
- const path = `/appointmentByToken/${vcToken}`;
62
- const response = await makeRequest('GET', path);
63
- return {
64
- id: response.data.id,
65
- professionalId: response.data.professional_id,
66
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
67
- };
68
- });
69
- return {
70
- getSchedule,
71
- getScheduleDates,
72
- getAppointment,
73
- getAppointmentByVcToken,
74
- };
75
- };
76
- exports.getScheduleMethods = getScheduleMethods;
@@ -1,7 +0,0 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getSpecialtiesMethods: (makeRequest: RequestMaker) => {
3
- getSpecialties: (mode: "appointment" | "chat" | "instant", language: string) => Promise<{
4
- id: number;
5
- description: string;
6
- }[]>;
7
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpecialtiesMethods = void 0;
4
- const zod_1 = require("zod");
5
- const validation_1 = require("../request/validation");
6
- const schemas_1 = require("../schemas");
7
- const getSpecialtiesMethods = (makeRequest) => {
8
- const getSpecialties = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.specialtyMode, zod_1.string()]), zod_1.array(schemas_1.doc24Schemas.specialty), async (mode, language) => {
9
- const type = mode === 'appointment' ? 'P' : mode === 'chat' ? 'T' : 'E';
10
- const path = `/specialties/${type}/${language.toUpperCase()}`;
11
- const response = await makeRequest('GET', path);
12
- return response.data.specialties.map((s) => ({
13
- id: s.specialty_id,
14
- description: s.specialty,
15
- }));
16
- });
17
- return { getSpecialties };
18
- };
19
- exports.getSpecialtiesMethods = getSpecialtiesMethods;
@@ -1,111 +0,0 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
3
- scheduleVideoVisit: (params: {
4
- extraInfo?: any;
5
- type: "appointment";
6
- patientId: number;
7
- specialtyId: number;
8
- language: string;
9
- details: string;
10
- appointmentId: string | number;
11
- } | {
12
- extraInfo?: any;
13
- type: "instant";
14
- patientId: number;
15
- specialtyId: number;
16
- language: string;
17
- details: string;
18
- }) => Promise<string>;
19
- cancelVideoVisit: (vcToken: string) => Promise<void>;
20
- getVideoVisit: (vcToken: string, patientId: number) => Promise<{
21
- appointment?: {
22
- date: Date;
23
- id: number;
24
- } | undefined;
25
- videoVisit?: {
26
- id: number;
27
- status: string;
28
- } | undefined;
29
- paymentStatus?: string | undefined;
30
- atentionId?: number | undefined;
31
- id: number | null;
32
- patientId: number;
33
- creationDate: Date;
34
- user: {
35
- id: number;
36
- phone: string | null;
37
- email: string | null;
38
- };
39
- vcToken: string;
40
- }>;
41
- getPatientVideoVisitHistory: (patientId: number) => Promise<{
42
- appointment?: {
43
- date: Date;
44
- id: number;
45
- } | undefined;
46
- videoVisit?: {
47
- id: number;
48
- status: string;
49
- } | undefined;
50
- paymentStatus?: string | undefined;
51
- atentionId?: number | undefined;
52
- id: number | null;
53
- patientId: number;
54
- creationDate: Date;
55
- user: {
56
- id: number;
57
- phone: string | null;
58
- email: string | null;
59
- };
60
- vcToken: string;
61
- }[]>;
62
- getVideoVisitDetails: (vcId: number) => Promise<{
63
- professional?: {
64
- id: number;
65
- fullName: string;
66
- } | undefined;
67
- appointment: {
68
- date: Date;
69
- id: number;
70
- } | null;
71
- id: number;
72
- language: string;
73
- patient: {
74
- fullName: string;
75
- firstAccessDate: Date;
76
- lastAccessDate: Date;
77
- };
78
- status: string;
79
- paymentStatus: string;
80
- finishDate: Date | null;
81
- retries: number;
82
- report: {
83
- motive: string | null;
84
- actualDesease: string | null;
85
- indications: string | null;
86
- alertSigns: string | null;
87
- extendedMotive: string | null;
88
- diagnose: {
89
- code: string;
90
- description: string;
91
- }[];
92
- };
93
- pdf: {
94
- atention?: string | undefined;
95
- labs?: string | undefined;
96
- otherExams?: string | undefined;
97
- images?: string | undefined;
98
- medication: any[];
99
- };
100
- files: {
101
- name: string;
102
- url: string;
103
- }[];
104
- }>;
105
- getVideoVisitLink: (vcToken: string, patientId: number) => Promise<string | null>;
106
- getActiveVideoVisits: () => Promise<{
107
- patientId: number;
108
- vcToken: string;
109
- consultationId: number;
110
- }[]>;
111
- };
@@ -1,147 +0,0 @@
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/utils.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { Doc24 } from '.';
2
- export declare const parseDate: (str: string) => Date;
3
- export declare const parseDateTime: (str: string) => Date;
4
- export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => 1 | 6 | 5 | 999 | 1000 | 9 | 7;
package/lib/utils.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIndetificationTypeId = 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 getIndetificationTypeId = (type) => {
11
- if (type === 'dni')
12
- return 1;
13
- if (type === 'ndi')
14
- return 6;
15
- if (type === 'passport')
16
- return 5;
17
- if (type === 'credential')
18
- return 999;
19
- if (type === 'nn')
20
- return 1000;
21
- if (type === 'cpf')
22
- return 9;
23
- if (type === 'rg')
24
- return 7;
25
- throw new Error('Invalid identificationType');
26
- };
27
- exports.getIndetificationTypeId = getIndetificationTypeId;
@@ -1,2 +0,0 @@
1
- import { Doc24 } from '../types';
2
- export declare const getRequestHandler: (credentials: Doc24.SdkCredentials, baseSdk: Doc24.BaseSdk, eventHandlers: Doc24.Webhook.Events) => Doc24.Webhook.Handler;
@@ -1,55 +0,0 @@
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
- };
@@ -1,35 +0,0 @@
1
- export declare const notFoundErrorResponse: () => {
2
- status: {
3
- code: number;
4
- message: string;
5
- };
6
- data: {
7
- error: string;
8
- };
9
- };
10
- export declare const unauthorizedErrorResponse: () => {
11
- status: {
12
- code: number;
13
- message: string;
14
- };
15
- data: {
16
- error: string;
17
- };
18
- };
19
- export declare const unexpectedErrorResponse: (details?: unknown) => {
20
- status: {
21
- code: number;
22
- message: string;
23
- };
24
- data: {
25
- error: string;
26
- details: unknown;
27
- };
28
- };
29
- export declare const successResponse: (data?: unknown) => {
30
- status: {
31
- code: number;
32
- message: string;
33
- };
34
- data: unknown;
35
- };