@integraciones_doc24/sdk 0.39.5 → 0.39.7
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/diagnostica.d.ts +54 -0
- package/lib/baseSdk/diagnostica.js +82 -0
- package/lib/baseSdk/external.d.ts +177 -0
- package/lib/baseSdk/external.js +96 -0
- package/lib/baseSdk/index.d.ts +2 -0
- package/lib/baseSdk/index.js +74 -0
- package/lib/baseSdk/user.d.ts +91 -0
- package/lib/baseSdk/user.js +136 -0
- package/lib/index.d.ts +365 -0
- package/lib/index.js +22 -0
- package/lib/request/index.d.ts +3 -0
- package/lib/request/index.js +26 -0
- package/lib/request/token.d.ts +2 -0
- package/lib/request/token.js +34 -0
- package/lib/request/validation.d.ts +10 -0
- package/lib/request/validation.js +28 -0
- package/lib/schemas.d.ts +1816 -0
- package/lib/schemas.js +420 -0
- package/lib/types.d.ts +146 -0
- package/lib/types.js +2 -0
- package/lib/userSdk/chat.d.ts +57 -0
- package/lib/userSdk/chat.js +98 -0
- package/lib/userSdk/external.d.ts +34 -0
- package/lib/userSdk/external.js +72 -0
- package/lib/userSdk/index.d.ts +2 -0
- package/lib/userSdk/index.js +30 -0
- package/lib/userSdk/patients.d.ts +38 -0
- package/lib/userSdk/patients.js +67 -0
- package/lib/userSdk/schedule.d.ts +47 -0
- package/lib/userSdk/schedule.js +81 -0
- package/lib/userSdk/specialties.d.ts +7 -0
- package/lib/userSdk/specialties.js +19 -0
- package/lib/userSdk/videoVisit.d.ts +113 -0
- package/lib/userSdk/videoVisit.js +154 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +16 -0
- package/lib/webhook/index.d.ts +2 -0
- package/lib/webhook/index.js +56 -0
- package/lib/webhook/responses.d.ts +35 -0
- package/lib/webhook/responses.js +42 -0
- package/lib/webhook/token.d.ts +2 -0
- package/lib/webhook/token.js +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChatMethods = 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 getChatMethods = (makeRequest) => {
|
|
9
|
+
const getAvailableChatrooms = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.chatroomAvailabilityFilter]), zod_1.array(schemas_1.doc24Schemas.availableChatroom), async (patientId, specialtyId, filter) => {
|
|
10
|
+
const path = `/chatroom/availability/${patientId}/${specialtyId}/${JSON.stringify(filter)}`;
|
|
11
|
+
const response = await makeRequest('GET', path);
|
|
12
|
+
return response.data.available_chatrooms.map((r) => ({
|
|
13
|
+
id: r.chatroom_id,
|
|
14
|
+
professional: {
|
|
15
|
+
id: r.professional_id,
|
|
16
|
+
fullName: r.professional,
|
|
17
|
+
logoUrl: r.logo,
|
|
18
|
+
},
|
|
19
|
+
specialty: {
|
|
20
|
+
id: r.specialty_id,
|
|
21
|
+
description: r.specialty,
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
const createNewChat = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.chatParameters]), zod_1.number(), async (parameters) => {
|
|
26
|
+
const path = `/chatroom/visit`;
|
|
27
|
+
const response = await makeRequest('POST', path, {
|
|
28
|
+
chatroom_data: {
|
|
29
|
+
patient_id: parameters.patientId,
|
|
30
|
+
chatroom_id: parameters.chatroomId,
|
|
31
|
+
language: parameters.language.toLocaleUpperCase(),
|
|
32
|
+
specialty_id: parameters.specialtyId,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return response.data.chat_id;
|
|
36
|
+
});
|
|
37
|
+
const getPatientChats = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.chatDetails), async (patientId) => {
|
|
38
|
+
const path = `/chatroom/visits/${patientId}`;
|
|
39
|
+
const response = await makeRequest('GET', path);
|
|
40
|
+
return response.data.chatroom_visits.map((c) => ({
|
|
41
|
+
id: c.chat_id,
|
|
42
|
+
chatRoomId: c.chatroom_id,
|
|
43
|
+
status: c.status,
|
|
44
|
+
paymentStatus: c.payment_status,
|
|
45
|
+
startDate: utils_1.parseDateTime(c.start_date),
|
|
46
|
+
lastEventDate: utils_1.parseDateTime(c.fecha_ultimo_evento),
|
|
47
|
+
closureDate: c.closure_date && utils_1.parseDateTime(c.closure_date),
|
|
48
|
+
patient: {
|
|
49
|
+
id: c.patient_id,
|
|
50
|
+
firstName: c.patient_name,
|
|
51
|
+
lastName: c.patient_lastname,
|
|
52
|
+
},
|
|
53
|
+
patientLastPost: c.patient_last_post && utils_1.parseDateTime(c.patient_last_post),
|
|
54
|
+
professional: {
|
|
55
|
+
id: c.professional_id,
|
|
56
|
+
fullName: c.professional,
|
|
57
|
+
logoUrl: c.logo,
|
|
58
|
+
},
|
|
59
|
+
professionalLastPost: c.professional_last_post && utils_1.parseDateTime(c.professional_last_post),
|
|
60
|
+
specialty: {
|
|
61
|
+
id: c.specialty_id,
|
|
62
|
+
description: c.specialty,
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
const getChatPosts = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.chatPost), async (chatId) => {
|
|
67
|
+
const path = `/chatroom/visit/${chatId}`;
|
|
68
|
+
const response = await makeRequest('GET', path);
|
|
69
|
+
return JSON.parse(response.data.posts).map((p) => ({
|
|
70
|
+
id: p.post_id,
|
|
71
|
+
message: p.post,
|
|
72
|
+
date: utils_1.parseDateTime(p.post_date),
|
|
73
|
+
userType: p.user_type === 'P' ? 'patient' : 'professional',
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
const cancelChat = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.void(), async (chatId) => {
|
|
77
|
+
const path = `/chatroom/visit/${chatId}`;
|
|
78
|
+
await makeRequest('DELETE', path);
|
|
79
|
+
return;
|
|
80
|
+
});
|
|
81
|
+
const sendChatMessage = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.string()]), zod_1.number(), async (chatId, message) => {
|
|
82
|
+
const path = `/chatroom/post`;
|
|
83
|
+
const response = await makeRequest('POST', path, {
|
|
84
|
+
chat_id: chatId,
|
|
85
|
+
message,
|
|
86
|
+
});
|
|
87
|
+
return response.data.post_id;
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
getAvailableChatrooms,
|
|
91
|
+
createNewChat,
|
|
92
|
+
getPatientChats,
|
|
93
|
+
getChatPosts,
|
|
94
|
+
cancelChat,
|
|
95
|
+
sendChatMessage,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.getChatMethods = getChatMethods;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare const getExternalMethods: (makeRequest: RequestMaker) => {
|
|
3
|
+
getExternalStudiesHistoryLink: (patient: {
|
|
4
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
5
|
+
identificationType: "DNI";
|
|
6
|
+
identificationValue: string;
|
|
7
|
+
birthdate: Date;
|
|
8
|
+
}) => Promise<string | null>;
|
|
9
|
+
getExternalAppointmentsLink: (identificationValue: string, birthdate: Date) => Promise<string | null>;
|
|
10
|
+
getExternalAppointments: () => Promise<{
|
|
11
|
+
patientIdentification?: string | undefined;
|
|
12
|
+
date: Date;
|
|
13
|
+
birthdate: Date;
|
|
14
|
+
appointment: string;
|
|
15
|
+
id: number;
|
|
16
|
+
specialty: string;
|
|
17
|
+
patientName: string;
|
|
18
|
+
clinic: string;
|
|
19
|
+
professionalName: string;
|
|
20
|
+
modality: string;
|
|
21
|
+
}[]>;
|
|
22
|
+
cancelExternalAppointment: (appointmentId: {
|
|
23
|
+
patientIdentification?: string | undefined;
|
|
24
|
+
date: Date;
|
|
25
|
+
birthdate: Date;
|
|
26
|
+
appointment: string;
|
|
27
|
+
id: number;
|
|
28
|
+
specialty: string;
|
|
29
|
+
patientName: string;
|
|
30
|
+
clinic: string;
|
|
31
|
+
professionalName: string;
|
|
32
|
+
modality: string;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExternalMethods = 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 getExternalMethods = (makeRequest) => {
|
|
10
|
+
const getExternalStudiesHistoryLink = async (patient) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const path = '/history-external-studies';
|
|
13
|
+
const response = await makeRequest('POST', path, {
|
|
14
|
+
patient: mapPatientData(patient),
|
|
15
|
+
});
|
|
16
|
+
return (_b = (_a = response.data.info) === null || _a === void 0 ? void 0 : _a.link) !== null && _b !== void 0 ? _b : null;
|
|
17
|
+
};
|
|
18
|
+
const getExternalAppointmentsLink = async (identificationValue, birthdate) => {
|
|
19
|
+
const path = `/external-appointments-link/${identificationValue}/${date_fns_1.format(birthdate, 'yyyy-MM-dd')}`;
|
|
20
|
+
const response = await makeRequest('GET', path);
|
|
21
|
+
return response.data.link;
|
|
22
|
+
};
|
|
23
|
+
const getExternalAppointments = async () => {
|
|
24
|
+
const path = '/external-appointments';
|
|
25
|
+
const response = await makeRequest('GET', path);
|
|
26
|
+
return response.data.appointments.map((a) => ({
|
|
27
|
+
id: a.appointment_id,
|
|
28
|
+
patientIdentification: a.patient_id,
|
|
29
|
+
patientName: a.patient_name,
|
|
30
|
+
birthdate: utils_1.parseDate(a.birthdate),
|
|
31
|
+
appointment: a.appointment,
|
|
32
|
+
clinic: a.clinic,
|
|
33
|
+
professionalName: a.professional,
|
|
34
|
+
date: utils_1.parseDateTime(`${a.day} ${a.hour}:00`),
|
|
35
|
+
specialty: a.specialty,
|
|
36
|
+
modality: a.modality,
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
const cancelExternalAppointment = async (appointment) => {
|
|
40
|
+
const path = `/cancel-external-appointment`;
|
|
41
|
+
await makeRequest('POST', path, {
|
|
42
|
+
appointment_id: appointment.id,
|
|
43
|
+
patient_id: appointment.patientIdentification,
|
|
44
|
+
patient_name: appointment.patientName,
|
|
45
|
+
birthdate: date_fns_1.format(appointment.birthdate, 'yyyy-MM-dd'),
|
|
46
|
+
appointment: appointment.appointment,
|
|
47
|
+
clinic: appointment.clinic,
|
|
48
|
+
professional: appointment.professionalName,
|
|
49
|
+
day: date_fns_1.format(appointment.date, 'yyyy-MM-dd'),
|
|
50
|
+
hour: date_fns_1.format(appointment.date, 'HH:mm'),
|
|
51
|
+
specialty: appointment.specialty,
|
|
52
|
+
modality: appointment.modality,
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
getExternalStudiesHistoryLink: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalPatient]), zod_1.string().nullable(), getExternalStudiesHistoryLink),
|
|
58
|
+
getExternalAppointmentsLink: validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.date()]), zod_1.string().nullable(), getExternalAppointmentsLink),
|
|
59
|
+
getExternalAppointments: validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.externalAppointment), getExternalAppointments),
|
|
60
|
+
cancelExternalAppointment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalAppointment]), zod_1.void(), cancelExternalAppointment),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.getExternalMethods = getExternalMethods;
|
|
64
|
+
const mapPatientData = (patient) => {
|
|
65
|
+
var _a;
|
|
66
|
+
return {
|
|
67
|
+
birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
|
|
68
|
+
id_type: 'dni',
|
|
69
|
+
id_value: patient.identificationValue,
|
|
70
|
+
gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase(),
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 external_1 = require("./external");
|
|
7
|
+
const patients_1 = require("./patients");
|
|
8
|
+
const schedule_1 = require("./schedule");
|
|
9
|
+
const specialties_1 = require("./specialties");
|
|
10
|
+
const videoVisit_1 = require("./videoVisit");
|
|
11
|
+
const userSdk = async (url, credentials, userId) => {
|
|
12
|
+
const makeRequest = await request_1.getRequestFactory(url, credentials, userId);
|
|
13
|
+
const patientMethods = patients_1.getPatientMethods(makeRequest);
|
|
14
|
+
const specialtyMethods = specialties_1.getSpecialtiesMethods(makeRequest);
|
|
15
|
+
const scheduleMethods = schedule_1.getScheduleMethods(makeRequest);
|
|
16
|
+
const videoVisitMethods = videoVisit_1.getVideoVisitMethods(makeRequest);
|
|
17
|
+
const chatMethods = chat_1.getChatMethods(makeRequest);
|
|
18
|
+
const externalMethods = external_1.getExternalMethods(makeRequest);
|
|
19
|
+
const sdk = {
|
|
20
|
+
...patientMethods,
|
|
21
|
+
...specialtyMethods,
|
|
22
|
+
...scheduleMethods,
|
|
23
|
+
...videoVisitMethods,
|
|
24
|
+
...chatMethods,
|
|
25
|
+
...externalMethods,
|
|
26
|
+
userId,
|
|
27
|
+
};
|
|
28
|
+
return sdk;
|
|
29
|
+
};
|
|
30
|
+
exports.userSdk = userSdk;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare const getPatientMethods: (makeRequest: RequestMaker) => {
|
|
3
|
+
declarePatient: (params: {
|
|
4
|
+
patient: {
|
|
5
|
+
identificationType?: number | undefined;
|
|
6
|
+
identificationValue?: string | undefined;
|
|
7
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
8
|
+
firstName: string;
|
|
9
|
+
lastName: string;
|
|
10
|
+
countryId: string;
|
|
11
|
+
birthdate: Date;
|
|
12
|
+
};
|
|
13
|
+
} & {
|
|
14
|
+
code?: string | undefined;
|
|
15
|
+
channel?: "1" | "2" | undefined;
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
askCode: true;
|
|
18
|
+
userInfo: {
|
|
19
|
+
firstName: string;
|
|
20
|
+
lastName: string;
|
|
21
|
+
phone: string;
|
|
22
|
+
email: string;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
patientId: number | null;
|
|
26
|
+
askCode: false;
|
|
27
|
+
}>;
|
|
28
|
+
getPatientId: (patient: {
|
|
29
|
+
identificationType?: number | undefined;
|
|
30
|
+
identificationValue?: string | undefined;
|
|
31
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
32
|
+
firstName: string;
|
|
33
|
+
lastName: string;
|
|
34
|
+
countryId: string;
|
|
35
|
+
birthdate: Date;
|
|
36
|
+
}) => Promise<number>;
|
|
37
|
+
deletePatient: (patientId: number) => Promise<void>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
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 getPatientMethods = (makeRequest) => {
|
|
9
|
+
const declarePatient = async ({ patient, channel, code, }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const path = '/patient';
|
|
12
|
+
const mappedPatient = {
|
|
13
|
+
lastname: patient.lastName,
|
|
14
|
+
firstname: patient.firstName,
|
|
15
|
+
identification_type: patient.identificationType,
|
|
16
|
+
identification_value: patient.identificationValue,
|
|
17
|
+
birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
|
|
18
|
+
gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
19
|
+
country_id: patient.countryId,
|
|
20
|
+
};
|
|
21
|
+
const parsedChannel = channel ? parseInt(channel) : channel;
|
|
22
|
+
const response = await makeRequest('POST', path, {
|
|
23
|
+
user_data: mappedPatient,
|
|
24
|
+
channel: parsedChannel,
|
|
25
|
+
code,
|
|
26
|
+
});
|
|
27
|
+
const data = response.data;
|
|
28
|
+
if (data.ask_code)
|
|
29
|
+
return {
|
|
30
|
+
userInfo: {
|
|
31
|
+
firstName: data.user_info.firstname,
|
|
32
|
+
lastName: data.user_info.lastname,
|
|
33
|
+
phone: data.user_info.phone,
|
|
34
|
+
email: data.user_info.email,
|
|
35
|
+
},
|
|
36
|
+
askCode: true,
|
|
37
|
+
};
|
|
38
|
+
return { askCode: false, patientId: data.patient_id };
|
|
39
|
+
};
|
|
40
|
+
const getPatientId = async (patient) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const path = '/search-patient';
|
|
43
|
+
const mappedPatient = {
|
|
44
|
+
lastname: patient.lastName,
|
|
45
|
+
firstname: patient.firstName,
|
|
46
|
+
identification_type: patient.identificationType,
|
|
47
|
+
identification_value: patient.identificationValue,
|
|
48
|
+
birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
|
|
49
|
+
gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
50
|
+
country_id: patient.countryId,
|
|
51
|
+
};
|
|
52
|
+
const response = await makeRequest('POST', path, {
|
|
53
|
+
user_data: mappedPatient,
|
|
54
|
+
});
|
|
55
|
+
return response.data.patient_id;
|
|
56
|
+
};
|
|
57
|
+
const deletePatient = async (patientId) => {
|
|
58
|
+
const path = `/patient/${patientId}`;
|
|
59
|
+
await makeRequest('DELETE', path);
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
declarePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declarePatientParams]), schemas_1.doc24Schemas.declarePatientResponse, declarePatient),
|
|
63
|
+
getPatientId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.patient]), zod_1.number(), getPatientId),
|
|
64
|
+
deletePatient: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.void(), deletePatient),
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.getPatientMethods = getPatientMethods;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
|
|
3
|
+
getSchedule: (patientId: number, specialtyId: number, filter?: {
|
|
4
|
+
date?: Date | undefined;
|
|
5
|
+
language?: string | undefined;
|
|
6
|
+
professionalId?: number | undefined;
|
|
7
|
+
offset?: number | undefined;
|
|
8
|
+
limit?: number | undefined;
|
|
9
|
+
weekDay?: number | undefined;
|
|
10
|
+
startHour?: string | undefined;
|
|
11
|
+
finishHour?: string | undefined;
|
|
12
|
+
} | undefined) => Promise<{
|
|
13
|
+
length?: number | null | undefined;
|
|
14
|
+
ranking?: unknown;
|
|
15
|
+
consultation_value?: string | null | undefined;
|
|
16
|
+
date: Date;
|
|
17
|
+
type: "appointment" | "chat" | "instant";
|
|
18
|
+
id: string | number;
|
|
19
|
+
professional: {
|
|
20
|
+
id: number;
|
|
21
|
+
fullName: string;
|
|
22
|
+
logoUrl: string;
|
|
23
|
+
};
|
|
24
|
+
specialty: {
|
|
25
|
+
id: number;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
clinicId: number;
|
|
29
|
+
cost: string;
|
|
30
|
+
atentions: number;
|
|
31
|
+
}[]>;
|
|
32
|
+
getScheduleDates: (patientId: number, filter?: {
|
|
33
|
+
specialtyId?: number | undefined;
|
|
34
|
+
language?: string | undefined;
|
|
35
|
+
professionalId?: number | undefined;
|
|
36
|
+
} | undefined) => Promise<Date[]>;
|
|
37
|
+
getAppointment: (appointmentId: number) => Promise<{
|
|
38
|
+
date: Date;
|
|
39
|
+
id: number;
|
|
40
|
+
professionalId: number;
|
|
41
|
+
}>;
|
|
42
|
+
getAppointmentByVcToken: (vcToken: string) => Promise<{
|
|
43
|
+
date: Date;
|
|
44
|
+
id: number;
|
|
45
|
+
professionalId: number;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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 = async (patientId, filter = {}) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const mappedFilter = {
|
|
13
|
+
specialty_id: filter.specialtyId,
|
|
14
|
+
professional_id: filter.professionalId,
|
|
15
|
+
language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
|
|
16
|
+
};
|
|
17
|
+
const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
|
|
18
|
+
const response = await makeRequest('GET', path);
|
|
19
|
+
return response.data.available_dates.map((o) => utils_1.parseDate(o.date, o.time_zone));
|
|
20
|
+
};
|
|
21
|
+
const getSchedule = async (patientId, specialtyId, filter = {}) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const mappedFilter = {
|
|
24
|
+
id_professional: filter.professionalId,
|
|
25
|
+
offset: filter.offset,
|
|
26
|
+
limit: filter.limit,
|
|
27
|
+
week_day: filter.weekDay,
|
|
28
|
+
date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
|
|
29
|
+
start_hour: filter.startHour,
|
|
30
|
+
finish_hour: filter.finishHour,
|
|
31
|
+
language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
|
|
32
|
+
};
|
|
33
|
+
const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
|
|
34
|
+
const response = await makeRequest('GET', path);
|
|
35
|
+
return response.data.available_appointments.map((a) => ({
|
|
36
|
+
id: a.id,
|
|
37
|
+
date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
|
|
38
|
+
clinicId: a.clinic,
|
|
39
|
+
professional: {
|
|
40
|
+
id: a.professional_id,
|
|
41
|
+
fullName: a.professional,
|
|
42
|
+
logoUrl: a.logo,
|
|
43
|
+
},
|
|
44
|
+
cost: a.cost,
|
|
45
|
+
specialty: {
|
|
46
|
+
id: a.specialty_id,
|
|
47
|
+
description: a.specialty,
|
|
48
|
+
},
|
|
49
|
+
type: a.type === 'P' ? 'appointment' : a.type === 'T' ? 'chat' : 'instant',
|
|
50
|
+
atentions: a.atentions,
|
|
51
|
+
ranking: a.ranking,
|
|
52
|
+
length: a.length,
|
|
53
|
+
consultation_value: a.consultation_value,
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
const getAppointment = async (appointmentId) => {
|
|
57
|
+
const path = `/appointment/${appointmentId}`;
|
|
58
|
+
const response = await makeRequest('GET', path);
|
|
59
|
+
return {
|
|
60
|
+
id: response.data.id,
|
|
61
|
+
professionalId: response.data.professional_id,
|
|
62
|
+
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const getAppointmentByVcToken = async (vcToken) => {
|
|
66
|
+
const path = `/appointmentByToken/${vcToken}`;
|
|
67
|
+
const response = await makeRequest('GET', path);
|
|
68
|
+
return {
|
|
69
|
+
id: response.data.id,
|
|
70
|
+
professionalId: response.data.professional_id,
|
|
71
|
+
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
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), getSchedule),
|
|
76
|
+
getScheduleDates: validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), getScheduleDates),
|
|
77
|
+
getAppointment: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, getAppointment),
|
|
78
|
+
getAppointmentByVcToken: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, getAppointmentByVcToken),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.getScheduleMethods = getScheduleMethods;
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
phone: string | null;
|
|
36
|
+
email: string | null;
|
|
37
|
+
id: number;
|
|
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
|
+
professional: string;
|
|
55
|
+
creationDate: Date;
|
|
56
|
+
user: {
|
|
57
|
+
phone: string | null;
|
|
58
|
+
email: string | null;
|
|
59
|
+
id: number;
|
|
60
|
+
};
|
|
61
|
+
vcToken: string;
|
|
62
|
+
specialty: string;
|
|
63
|
+
}[]>;
|
|
64
|
+
getVideoVisitDetails: (vcId: number) => Promise<{
|
|
65
|
+
professional?: {
|
|
66
|
+
id: number;
|
|
67
|
+
fullName: string;
|
|
68
|
+
} | undefined;
|
|
69
|
+
appointment: {
|
|
70
|
+
date: Date;
|
|
71
|
+
id: number;
|
|
72
|
+
} | null;
|
|
73
|
+
id: number;
|
|
74
|
+
language: string;
|
|
75
|
+
patient: {
|
|
76
|
+
fullName: string;
|
|
77
|
+
firstAccessDate: Date;
|
|
78
|
+
lastAccessDate: Date;
|
|
79
|
+
};
|
|
80
|
+
status: string;
|
|
81
|
+
paymentStatus: string;
|
|
82
|
+
finishDate: Date | null;
|
|
83
|
+
retries: number;
|
|
84
|
+
report: {
|
|
85
|
+
motive: string | null;
|
|
86
|
+
actualDesease: string | null;
|
|
87
|
+
indications: string | null;
|
|
88
|
+
alertSigns: string | null;
|
|
89
|
+
extendedMotive: string | null;
|
|
90
|
+
diagnose: {
|
|
91
|
+
code: string;
|
|
92
|
+
description: string;
|
|
93
|
+
}[];
|
|
94
|
+
};
|
|
95
|
+
pdf: {
|
|
96
|
+
atention?: string | undefined;
|
|
97
|
+
labs?: string | undefined;
|
|
98
|
+
otherExams?: string | undefined;
|
|
99
|
+
images?: string | undefined;
|
|
100
|
+
medication: any[];
|
|
101
|
+
};
|
|
102
|
+
files: {
|
|
103
|
+
name: string;
|
|
104
|
+
url: string;
|
|
105
|
+
}[];
|
|
106
|
+
}>;
|
|
107
|
+
getVideoVisitLink: (vcToken: string, patientId: number) => Promise<string | null>;
|
|
108
|
+
getActiveVideoVisits: () => Promise<{
|
|
109
|
+
patientId: number;
|
|
110
|
+
vcToken: string;
|
|
111
|
+
consultationId: number;
|
|
112
|
+
}[]>;
|
|
113
|
+
};
|