@integraciones_doc24/sdk 1.16.40 → 1.16.42
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/README.md +21 -0
- package/lib/baseSdk/diagnostica.d.ts +54 -54
- package/lib/baseSdk/diagnostica.js +82 -82
- package/lib/baseSdk/external.d.ts +177 -177
- package/lib/baseSdk/external.js +96 -96
- package/lib/baseSdk/index.d.ts +2 -2
- package/lib/baseSdk/index.js +80 -80
- package/lib/baseSdk/integrationError.d.ts +16 -16
- package/lib/baseSdk/integrationError.js +33 -33
- package/lib/baseSdk/user.d.ts +115 -115
- package/lib/baseSdk/user.js +136 -136
- package/lib/index.d.ts +417 -416
- package/lib/index.js +24 -22
- package/lib/request/index.d.ts +4 -4
- package/lib/request/index.js +32 -32
- package/lib/request/token.d.ts +2 -2
- package/lib/request/token.js +34 -34
- package/lib/request/validation.d.ts +10 -10
- package/lib/request/validation.js +28 -28
- package/lib/schemas.d.ts +2930 -2813
- package/lib/schemas.js +640 -601
- package/lib/types.d.ts +183 -178
- package/lib/types.js +2 -2
- package/lib/userSdk/binah.d.ts +21 -21
- package/lib/userSdk/binah.js +20 -20
- package/lib/userSdk/chat.d.ts +57 -57
- package/lib/userSdk/chat.js +98 -98
- package/lib/userSdk/eligibility.d.ts +29 -0
- package/lib/userSdk/eligibility.js +81 -0
- package/lib/userSdk/external.d.ts +34 -34
- package/lib/userSdk/external.js +72 -72
- package/lib/userSdk/index.d.ts +2 -2
- package/lib/userSdk/index.js +36 -33
- package/lib/userSdk/patients.d.ts +62 -62
- package/lib/userSdk/patients.js +93 -93
- package/lib/userSdk/schedule.d.ts +59 -59
- package/lib/userSdk/schedule.js +90 -90
- package/lib/userSdk/specialties.d.ts +19 -19
- package/lib/userSdk/specialties.js +48 -48
- package/lib/userSdk/videoVisit.d.ts +229 -225
- package/lib/userSdk/videoVisit.js +288 -283
- package/lib/utils.d.ts +4 -4
- package/lib/utils.js +68 -68
- package/lib/webhook/index.d.ts +2 -2
- package/lib/webhook/index.js +67 -67
- package/lib/webhook/responses.d.ts +35 -35
- package/lib/webhook/responses.js +42 -42
- package/lib/webhook/token.d.ts +2 -2
- package/lib/webhook/token.js +23 -23
- package/package.json +37 -37
package/lib/userSdk/chat.js
CHANGED
|
@@ -1,98 +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;
|
|
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,29 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare class ResponseSignatureError extends Error {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare const signResponseData: (data: unknown, key: string) => string;
|
|
6
|
+
export declare const isValidResponseSignature: (data: unknown, signature: unknown, key: string) => boolean;
|
|
7
|
+
export declare const getEligibilityMethods: (makeRequest: RequestMaker, key: string) => {
|
|
8
|
+
checkEligibility: (params: {
|
|
9
|
+
credential?: string | undefined;
|
|
10
|
+
credentialToken?: string | undefined;
|
|
11
|
+
identificationType: "3" | "8";
|
|
12
|
+
identificationValue: string;
|
|
13
|
+
patientId: number;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
eligible: boolean;
|
|
19
|
+
affiliate: {
|
|
20
|
+
gender?: string | undefined;
|
|
21
|
+
plan?: string | undefined;
|
|
22
|
+
name?: string | undefined;
|
|
23
|
+
holder?: string | undefined;
|
|
24
|
+
age?: string | undefined;
|
|
25
|
+
affiliateNumber?: string | undefined;
|
|
26
|
+
} | null;
|
|
27
|
+
notices: string[];
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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.getEligibilityMethods = exports.isValidResponseSignature = exports.signResponseData = exports.ResponseSignatureError = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const validation_1 = require("../request/validation");
|
|
10
|
+
const schemas_1 = require("../schemas");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
class ResponseSignatureError extends Error {
|
|
13
|
+
constructor() {
|
|
14
|
+
super('Invalid signature in Doc24 response');
|
|
15
|
+
this.name = 'ResponseSignatureError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ResponseSignatureError = ResponseSignatureError;
|
|
19
|
+
// Doc24 signs `data` as serialized by PHP's json_encode: compact, `/` escaped
|
|
20
|
+
// as `\/` and non-ASCII characters as `\uXXXX`. Key order is the one received.
|
|
21
|
+
const phpJsonEncode = (value) => JSON.stringify(value)
|
|
22
|
+
.replace(/\//g, '\\/')
|
|
23
|
+
.replace(/[\u0080-]/g, (char) => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
24
|
+
// base64(HMAC-SHA256(json(data), key)) with `+` → `-`, `/` → `_`, `=` → `,`
|
|
25
|
+
const signResponseData = (data, key) => crypto_1.default
|
|
26
|
+
.createHmac('sha256', key)
|
|
27
|
+
.update(phpJsonEncode(data))
|
|
28
|
+
.digest('base64')
|
|
29
|
+
.replace(/\+/g, '-')
|
|
30
|
+
.replace(/\//g, '_')
|
|
31
|
+
.replace(/=/g, ',');
|
|
32
|
+
exports.signResponseData = signResponseData;
|
|
33
|
+
const isValidResponseSignature = (data, signature, key) => {
|
|
34
|
+
if (typeof signature !== 'string')
|
|
35
|
+
return false;
|
|
36
|
+
const expected = Buffer.from(exports.signResponseData(data, key));
|
|
37
|
+
const received = Buffer.from(signature);
|
|
38
|
+
return (expected.length === received.length &&
|
|
39
|
+
crypto_1.default.timingSafeEqual(expected, received));
|
|
40
|
+
};
|
|
41
|
+
exports.isValidResponseSignature = isValidResponseSignature;
|
|
42
|
+
const getEligibilityMethods = (makeRequest, key) => {
|
|
43
|
+
// Errors (4xx) are thrown by axios; `error.response.data.mensaje` carries
|
|
44
|
+
// INVALID PARAMS, INVALID PATIENT, SERVICE DISABLED or INSSSEP_UNAVAILABLE.
|
|
45
|
+
const checkEligibility = async (params) => {
|
|
46
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
|
+
const response = await makeRequest('POST', '/eligibility', {
|
|
48
|
+
patient_id: params.patientId,
|
|
49
|
+
identification_type: params.identificationType,
|
|
50
|
+
identification_value: params.identificationValue,
|
|
51
|
+
credential_token: params.credentialToken,
|
|
52
|
+
credential: params.credential,
|
|
53
|
+
});
|
|
54
|
+
if (!exports.isValidResponseSignature(response.data, response.signature, key))
|
|
55
|
+
throw new ResponseSignatureError();
|
|
56
|
+
const data = response.data;
|
|
57
|
+
const affiliate = data.affiliate;
|
|
58
|
+
return {
|
|
59
|
+
eligible: data.eligible,
|
|
60
|
+
code: data.code,
|
|
61
|
+
message: data.message,
|
|
62
|
+
affiliate: affiliate
|
|
63
|
+
? {
|
|
64
|
+
name: (_a = affiliate.name) !== null && _a !== void 0 ? _a : undefined,
|
|
65
|
+
holder: (_b = affiliate.holder) !== null && _b !== void 0 ? _b : undefined,
|
|
66
|
+
gender: (_c = affiliate.gender) !== null && _c !== void 0 ? _c : undefined,
|
|
67
|
+
age: (_d = affiliate.age) !== null && _d !== void 0 ? _d : undefined,
|
|
68
|
+
affiliateNumber: (_e = affiliate.affiliate_number) !== null && _e !== void 0 ? _e : undefined,
|
|
69
|
+
plan: (_f = affiliate.plan) !== null && _f !== void 0 ? _f : undefined,
|
|
70
|
+
}
|
|
71
|
+
: null,
|
|
72
|
+
notices: (_g = data.notices) !== null && _g !== void 0 ? _g : [],
|
|
73
|
+
// UTC
|
|
74
|
+
timestamp: utils_1.parseDateTime(data.timestamp, '+00'),
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
checkEligibility: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.eligibilityParams]), schemas_1.doc24Schemas.eligibilityResponse, checkEligibility),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.getEligibilityMethods = getEligibilityMethods;
|
|
@@ -1,34 +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
|
-
modality: string;
|
|
17
|
-
specialty: string;
|
|
18
|
-
patientName: string;
|
|
19
|
-
clinic: string;
|
|
20
|
-
professionalName: string;
|
|
21
|
-
}[]>;
|
|
22
|
-
cancelExternalAppointment: (appointmentId: {
|
|
23
|
-
patientIdentification?: string | undefined;
|
|
24
|
-
date: Date;
|
|
25
|
-
birthdate: Date;
|
|
26
|
-
appointment: string;
|
|
27
|
-
id: number;
|
|
28
|
-
modality: string;
|
|
29
|
-
specialty: string;
|
|
30
|
-
patientName: string;
|
|
31
|
-
clinic: string;
|
|
32
|
-
professionalName: string;
|
|
33
|
-
}) => Promise<void>;
|
|
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
|
+
modality: string;
|
|
17
|
+
specialty: string;
|
|
18
|
+
patientName: string;
|
|
19
|
+
clinic: string;
|
|
20
|
+
professionalName: string;
|
|
21
|
+
}[]>;
|
|
22
|
+
cancelExternalAppointment: (appointmentId: {
|
|
23
|
+
patientIdentification?: string | undefined;
|
|
24
|
+
date: Date;
|
|
25
|
+
birthdate: Date;
|
|
26
|
+
appointment: string;
|
|
27
|
+
id: number;
|
|
28
|
+
modality: string;
|
|
29
|
+
specialty: string;
|
|
30
|
+
patientName: string;
|
|
31
|
+
clinic: string;
|
|
32
|
+
professionalName: string;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
};
|
package/lib/userSdk/external.js
CHANGED
|
@@ -1,72 +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
|
-
};
|
|
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
|
+
};
|
package/lib/userSdk/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Doc24 } from '../types';
|
|
2
|
-
export declare const userSdk: (url: string, credentials: Doc24.SdkCredentials, userId: number) => Promise<Doc24.UserSdk>;
|
|
1
|
+
import { Doc24 } from '../types';
|
|
2
|
+
export declare const userSdk: (url: string, credentials: Doc24.SdkCredentials, userId: number) => Promise<Doc24.UserSdk>;
|
package/lib/userSdk/index.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.userSdk = void 0;
|
|
4
|
-
const request_1 = require("../request");
|
|
5
|
-
const binah_1 = require("./binah");
|
|
6
|
-
const chat_1 = require("./chat");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
...
|
|
25
|
-
...
|
|
26
|
-
...
|
|
27
|
-
...
|
|
28
|
-
...
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userSdk = void 0;
|
|
4
|
+
const request_1 = require("../request");
|
|
5
|
+
const binah_1 = require("./binah");
|
|
6
|
+
const chat_1 = require("./chat");
|
|
7
|
+
const eligibility_1 = require("./eligibility");
|
|
8
|
+
const external_1 = require("./external");
|
|
9
|
+
const patients_1 = require("./patients");
|
|
10
|
+
const schedule_1 = require("./schedule");
|
|
11
|
+
const specialties_1 = require("./specialties");
|
|
12
|
+
const videoVisit_1 = require("./videoVisit");
|
|
13
|
+
const userSdk = async (url, credentials, userId) => {
|
|
14
|
+
const makeRequest = await request_1.getRequestFactory(url, credentials, userId);
|
|
15
|
+
const patientMethods = patients_1.getPatientMethods(makeRequest);
|
|
16
|
+
const specialtyMethods = specialties_1.getSpecialtiesMethods(makeRequest);
|
|
17
|
+
const scheduleMethods = schedule_1.getScheduleMethods(makeRequest);
|
|
18
|
+
const videoVisitMethods = videoVisit_1.getVideoVisitMethods(makeRequest);
|
|
19
|
+
const chatMethods = chat_1.getChatMethods(makeRequest);
|
|
20
|
+
const externalMethods = external_1.getExternalMethods(makeRequest);
|
|
21
|
+
const binahWellnessMethods = binah_1.getBinahWellnessMethods(makeRequest);
|
|
22
|
+
const eligibilityMethods = eligibility_1.getEligibilityMethods(makeRequest, credentials.key);
|
|
23
|
+
const sdk = {
|
|
24
|
+
...patientMethods,
|
|
25
|
+
...specialtyMethods,
|
|
26
|
+
...scheduleMethods,
|
|
27
|
+
...videoVisitMethods,
|
|
28
|
+
...chatMethods,
|
|
29
|
+
...externalMethods,
|
|
30
|
+
...binahWellnessMethods,
|
|
31
|
+
...eligibilityMethods,
|
|
32
|
+
userId,
|
|
33
|
+
};
|
|
34
|
+
return sdk;
|
|
35
|
+
};
|
|
36
|
+
exports.userSdk = userSdk;
|