@integraciones_doc24/sdk 0.31.1 → 0.32.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/diagnostica.d.ts +17 -0
- package/lib/baseSdk/diagnostica.js +43 -0
- package/lib/baseSdk/external.d.ts +6 -0
- package/lib/baseSdk/external.js +73 -0
- package/lib/{baseSdk.d.ts → baseSdk/index.d.ts} +1 -1
- package/lib/{baseSdk.js → baseSdk/index.js} +8 -5
- package/lib/index.d.ts +14 -0
- package/lib/request/index.js +3 -0
- package/lib/schemas.d.ts +42 -0
- package/lib/schemas.js +17 -0
- package/lib/types.d.ts +4 -0
- package/package.json +3 -2
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}, user: {
|
|
8
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
9
|
+
identificationValue: string;
|
|
10
|
+
gender: "m" | "f";
|
|
11
|
+
}, from: Date, to: Date) => Promise<{
|
|
12
|
+
date: Date;
|
|
13
|
+
location: string;
|
|
14
|
+
exams: string[];
|
|
15
|
+
deepLink: string;
|
|
16
|
+
}[]>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDiagnosticaMethods = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const validation_1 = require("../request/validation");
|
|
6
|
+
const schemas_1 = require("../schemas");
|
|
7
|
+
const getDiagnosticaMethods = (makeRequest) => {
|
|
8
|
+
const getDiagnosticaHistory = validation_1.validateFunction(zod_1.tuple([
|
|
9
|
+
schemas_1.doc24Schemas.diagnosticaPatientFilter,
|
|
10
|
+
schemas_1.doc24Schemas.diagnosticaUserFilter,
|
|
11
|
+
zod_1.date(),
|
|
12
|
+
zod_1.date(),
|
|
13
|
+
]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), async (patient, user, from, to) => {
|
|
14
|
+
const path = '/history-diagnostica';
|
|
15
|
+
const response = await makeRequest('POST', path, {
|
|
16
|
+
patient: {
|
|
17
|
+
gender: patient.gender,
|
|
18
|
+
id_type: patient.identificationType === 'ndi'
|
|
19
|
+
? 'DNI'
|
|
20
|
+
: patient.identificationType,
|
|
21
|
+
id_value: patient.identificationValue,
|
|
22
|
+
},
|
|
23
|
+
user: {
|
|
24
|
+
gender: user.gender,
|
|
25
|
+
id_type: user.identificationType === 'ndi'
|
|
26
|
+
? 'DNI'
|
|
27
|
+
: user.identificationType,
|
|
28
|
+
id_value: user.identificationValue,
|
|
29
|
+
},
|
|
30
|
+
dateFrom: from.toISOString(),
|
|
31
|
+
dateTo: to.toISOString(),
|
|
32
|
+
});
|
|
33
|
+
const list = response.data.info;
|
|
34
|
+
return list.map((i) => ({
|
|
35
|
+
date: new Date(Date.parse(i.date)),
|
|
36
|
+
location: i.location,
|
|
37
|
+
exams: i.exams,
|
|
38
|
+
deepLink: i.deeplink,
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
return { getDiagnosticaHistory };
|
|
42
|
+
};
|
|
43
|
+
exports.getDiagnosticaMethods = getDiagnosticaMethods;
|
|
@@ -0,0 +1,73 @@
|
|
|
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 getExternalMethods = (makeRequest) => {
|
|
9
|
+
const externalLogin = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.string()]), schemas_1.doc24Schemas.externalLoginResponse, async (user, password) => {
|
|
10
|
+
const path = '/external-login';
|
|
11
|
+
const response = await makeRequest('POST', path, { user, password });
|
|
12
|
+
/* {
|
|
13
|
+
data: {
|
|
14
|
+
login_info: {
|
|
15
|
+
firstname: 'Nieves Iris',
|
|
16
|
+
lastname: 'Veiga',
|
|
17
|
+
birthdate: '1964-03-18T00:00:00',
|
|
18
|
+
identification_number: '16766094',
|
|
19
|
+
identification_type: 1,
|
|
20
|
+
country_id: 'AR',
|
|
21
|
+
gender: 'F',
|
|
22
|
+
address: 'Av. Pte Illia 13267',
|
|
23
|
+
city: 'Buenos Aires',
|
|
24
|
+
province: 'José C. Paz',
|
|
25
|
+
email: 'carlosiosella@gmail.com',
|
|
26
|
+
email_validated: true,
|
|
27
|
+
telephone: '3426310240',
|
|
28
|
+
cellphoneValidated: true,
|
|
29
|
+
external_id: null,
|
|
30
|
+
external_uid: 'srfoTzzYcE9',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}; */
|
|
34
|
+
console.log(response);
|
|
35
|
+
const info = response.data.login_info;
|
|
36
|
+
return {
|
|
37
|
+
firstName: info.firstname,
|
|
38
|
+
lastName: info.lastname,
|
|
39
|
+
countryId: info.country_id,
|
|
40
|
+
birthday: new Date(Date.parse(info.birthdate)),
|
|
41
|
+
identificationNumber: info.identification_number,
|
|
42
|
+
gender: info.gender === 'F' ? 'f' : 'm',
|
|
43
|
+
email: info.email,
|
|
44
|
+
phone: info.telephone,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const preExternalEnroll = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), async (params) => {
|
|
48
|
+
const path = '/pre-external-enrollment';
|
|
49
|
+
await makeRequest('POST', path, {
|
|
50
|
+
identification_number: params.identificationNumber,
|
|
51
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
52
|
+
email: params.email,
|
|
53
|
+
telephone: params.phone,
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
});
|
|
57
|
+
const externalEnroll = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), zod_1.void(), async (params) => {
|
|
58
|
+
const path = '/external-enrollment';
|
|
59
|
+
const response = await makeRequest('POST', path, {
|
|
60
|
+
identification_number: params.identificationNumber,
|
|
61
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
62
|
+
email: params.email,
|
|
63
|
+
telephone: params.phone,
|
|
64
|
+
email_code: params.emailCode,
|
|
65
|
+
telephone_code: params.phoneCode,
|
|
66
|
+
password: params.password,
|
|
67
|
+
});
|
|
68
|
+
console.log(response);
|
|
69
|
+
return;
|
|
70
|
+
});
|
|
71
|
+
return { externalLogin, preExternalEnroll, externalEnroll };
|
|
72
|
+
};
|
|
73
|
+
exports.getExternalMethods = getExternalMethods;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Doc24 } from '
|
|
1
|
+
import { Doc24 } from '../types';
|
|
2
2
|
export declare const getBaseSdk: (url: string, credentials: Doc24.SdkCredentials) => Promise<Doc24.BaseSdk>;
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getBaseSdk = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
|
-
const request_1 = require("
|
|
7
|
-
const validation_1 = require("
|
|
8
|
-
const schemas_1 = require("
|
|
9
|
-
const userSdk_1 = require("
|
|
10
|
-
const utils_1 = require("
|
|
6
|
+
const request_1 = require("../request");
|
|
7
|
+
const validation_1 = require("../request/validation");
|
|
8
|
+
const schemas_1 = require("../schemas");
|
|
9
|
+
const userSdk_1 = require("../userSdk");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const diagnostica_1 = require("./diagnostica");
|
|
11
12
|
const getBaseSdk = async (url, credentials) => {
|
|
12
13
|
const makeRequest = await request_1.getRequestFactory(url, credentials);
|
|
13
14
|
const getUserId = async (user) => {
|
|
@@ -27,7 +28,9 @@ const getBaseSdk = async (url, credentials) => {
|
|
|
27
28
|
});
|
|
28
29
|
return response.data.user_id;
|
|
29
30
|
};
|
|
31
|
+
const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
|
|
30
32
|
const baseSdk = {
|
|
33
|
+
...diagnosticaMethods,
|
|
31
34
|
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
|
|
32
35
|
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
33
36
|
// TODO: validate?
|
package/lib/index.d.ts
CHANGED
|
@@ -76,5 +76,19 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
76
76
|
identificationNumber: string;
|
|
77
77
|
plan: string;
|
|
78
78
|
}) => Promise<void>;
|
|
79
|
+
getDiagnosticaHistory: (patient: {
|
|
80
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
81
|
+
identificationValue: string;
|
|
82
|
+
gender: "m" | "f";
|
|
83
|
+
}, user: {
|
|
84
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
85
|
+
identificationValue: string;
|
|
86
|
+
gender: "m" | "f";
|
|
87
|
+
}, from: Date, to: Date) => Promise<{
|
|
88
|
+
date: Date;
|
|
89
|
+
location: string;
|
|
90
|
+
exams: string[];
|
|
91
|
+
deepLink: string;
|
|
92
|
+
}[]>;
|
|
79
93
|
}>;
|
|
80
94
|
export type { Doc24 } from './types';
|
package/lib/request/index.js
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getRequestFactory = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const token_1 = require("./token");
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const debugRequest = debug_1.default('doc24Sdk:request');
|
|
9
11
|
const getRequestFactory = async (url, credentials, userId) => {
|
|
10
12
|
const makeRequest = async (method, path, body) => {
|
|
11
13
|
const token = await token_1.getToken(credentials, body ? JSON.stringify(body) : undefined, userId);
|
|
@@ -16,6 +18,7 @@ const getRequestFactory = async (url, credentials, userId) => {
|
|
|
16
18
|
headers: { Authentication: token },
|
|
17
19
|
data: body,
|
|
18
20
|
});
|
|
21
|
+
debugRequest({ url: fullUrl, response: result.data, body });
|
|
19
22
|
return result.data;
|
|
20
23
|
};
|
|
21
24
|
return makeRequest;
|
package/lib/schemas.d.ts
CHANGED
|
@@ -925,4 +925,46 @@ export declare const doc24Schemas: {
|
|
|
925
925
|
identificationNumber: string;
|
|
926
926
|
plan: string;
|
|
927
927
|
}>;
|
|
928
|
+
diagnosticaPatientFilter: import("zod").ZodObject<{
|
|
929
|
+
gender: import("zod").ZodEnum<["m", "f"]>;
|
|
930
|
+
identificationType: import("zod").ZodEnum<["ndi", "passport", "credential"]>;
|
|
931
|
+
identificationValue: import("zod").ZodString;
|
|
932
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
933
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
934
|
+
identificationValue: string;
|
|
935
|
+
gender: "m" | "f";
|
|
936
|
+
}, {
|
|
937
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
938
|
+
identificationValue: string;
|
|
939
|
+
gender: "m" | "f";
|
|
940
|
+
}>;
|
|
941
|
+
diagnosticaUserFilter: import("zod").ZodObject<{
|
|
942
|
+
gender: import("zod").ZodEnum<["m", "f"]>;
|
|
943
|
+
identificationType: import("zod").ZodEnum<["ndi", "passport", "credential"]>;
|
|
944
|
+
identificationValue: import("zod").ZodString;
|
|
945
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
946
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
947
|
+
identificationValue: string;
|
|
948
|
+
gender: "m" | "f";
|
|
949
|
+
}, {
|
|
950
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
951
|
+
identificationValue: string;
|
|
952
|
+
gender: "m" | "f";
|
|
953
|
+
}>;
|
|
954
|
+
diagnosticaHistoryAppointment: import("zod").ZodObject<{
|
|
955
|
+
date: import("zod").ZodDate;
|
|
956
|
+
location: import("zod").ZodString;
|
|
957
|
+
exams: import("zod").ZodArray<import("zod").ZodString, "many">;
|
|
958
|
+
deepLink: import("zod").ZodString;
|
|
959
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
960
|
+
date: Date;
|
|
961
|
+
location: string;
|
|
962
|
+
exams: string[];
|
|
963
|
+
deepLink: string;
|
|
964
|
+
}, {
|
|
965
|
+
date: Date;
|
|
966
|
+
location: string;
|
|
967
|
+
exams: string[];
|
|
968
|
+
deepLink: string;
|
|
969
|
+
}>;
|
|
928
970
|
};
|
package/lib/schemas.js
CHANGED
|
@@ -124,6 +124,12 @@ const enrollmentParams = zod_1.object({
|
|
|
124
124
|
plan: zod_1.string(),
|
|
125
125
|
startDate: zod_1.date(),
|
|
126
126
|
});
|
|
127
|
+
const diagnosticaHistoryAppointment = zod_1.object({
|
|
128
|
+
date: zod_1.date(),
|
|
129
|
+
location: zod_1.string(),
|
|
130
|
+
exams: zod_1.string().array(),
|
|
131
|
+
deepLink: zod_1.string().url(),
|
|
132
|
+
});
|
|
127
133
|
exports.doc24Schemas = {
|
|
128
134
|
identificationType,
|
|
129
135
|
sdkCredentials,
|
|
@@ -233,4 +239,15 @@ exports.doc24Schemas = {
|
|
|
233
239
|
chatDetails,
|
|
234
240
|
chatPost,
|
|
235
241
|
enrollmentParams,
|
|
242
|
+
diagnosticaPatientFilter: zod_1.object({
|
|
243
|
+
gender,
|
|
244
|
+
identificationType,
|
|
245
|
+
identificationValue: zod_1.string(),
|
|
246
|
+
}),
|
|
247
|
+
diagnosticaUserFilter: zod_1.object({
|
|
248
|
+
gender,
|
|
249
|
+
identificationType,
|
|
250
|
+
identificationValue: zod_1.string(),
|
|
251
|
+
}),
|
|
252
|
+
diagnosticaHistoryAppointment,
|
|
236
253
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -24,12 +24,16 @@ export declare namespace Doc24 {
|
|
|
24
24
|
type ChatDetails = TypeOf<typeof doc24Schemas.chatDetails>;
|
|
25
25
|
type ChatPost = TypeOf<typeof doc24Schemas.chatPost>;
|
|
26
26
|
type EnrollmentParams = TypeOf<typeof doc24Schemas.enrollmentParams>;
|
|
27
|
+
type DiagnosticaUserFilter = TypeOf<typeof doc24Schemas.diagnosticaUserFilter>;
|
|
28
|
+
type DiagnosticaPatientFilter = TypeOf<typeof doc24Schemas.diagnosticaPatientFilter>;
|
|
29
|
+
type DiagnosticaHistoryAppointment = TypeOf<typeof doc24Schemas.diagnosticaHistoryAppointment>;
|
|
27
30
|
type BaseSdk = {
|
|
28
31
|
declareUser: (user: User) => Promise<number>;
|
|
29
32
|
getUserInstance: (user: User | number) => Promise<UserSdk>;
|
|
30
33
|
getProfessional: (professionalId: number) => Promise<Professional>;
|
|
31
34
|
getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
|
|
32
35
|
enroll: (params: EnrollmentParams) => Promise<void>;
|
|
36
|
+
getDiagnosticaHistory: (patient: DiagnosticaPatientFilter, user: DiagnosticaUserFilter, from: Date, to: Date) => Promise<DiagnosticaHistoryAppointment[]>;
|
|
33
37
|
};
|
|
34
38
|
type UserSdk = {
|
|
35
39
|
declarePatient: (patient: Patient) => Promise<number>;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@integraciones_doc24/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "tsc"
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"prepublish": "npm run build"
|
|
8
9
|
},
|
|
9
10
|
"keywords": [],
|
|
10
11
|
"author": "",
|