@integraciones_doc24/sdk 0.42.2 → 0.42.4

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.
@@ -0,0 +1,177 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
3
+ externalLogin: (params: {
4
+ user: string;
5
+ password: string;
6
+ }) => Promise<{
7
+ gender?: "m" | "f" | "o" | undefined;
8
+ firstName: string;
9
+ lastName: string;
10
+ countryId: string;
11
+ phone: string;
12
+ email: string;
13
+ birthday: Date;
14
+ identificationNumber: string;
15
+ }>;
16
+ preExternalEnrollment: (params: ({
17
+ birthdate: Date;
18
+ identificationNumber: string;
19
+ } & {
20
+ phone: string;
21
+ email: string;
22
+ }) | ({
23
+ birthdate: Date;
24
+ identificationNumber: string;
25
+ } & {
26
+ phone?: undefined;
27
+ email: string;
28
+ }) | ({
29
+ birthdate: Date;
30
+ identificationNumber: string;
31
+ } & {
32
+ email?: undefined;
33
+ phone: string;
34
+ })) => Promise<void>;
35
+ externalEnrollment: (params: ({
36
+ birthdate: Date;
37
+ identificationNumber: string;
38
+ } & {
39
+ phone: string;
40
+ email: string;
41
+ } & {
42
+ password: string;
43
+ } & {
44
+ emailCode: string;
45
+ phoneCode: string;
46
+ }) | ({
47
+ birthdate: Date;
48
+ identificationNumber: string;
49
+ } & {
50
+ phone: string;
51
+ email: string;
52
+ } & {
53
+ password: string;
54
+ } & {
55
+ phoneCode?: undefined;
56
+ emailCode: string;
57
+ }) | ({
58
+ birthdate: Date;
59
+ identificationNumber: string;
60
+ } & {
61
+ phone: string;
62
+ email: string;
63
+ } & {
64
+ password: string;
65
+ } & {
66
+ emailCode?: undefined;
67
+ phoneCode: string;
68
+ }) | ({
69
+ birthdate: Date;
70
+ identificationNumber: string;
71
+ } & {
72
+ phone?: undefined;
73
+ email: string;
74
+ } & {
75
+ password: string;
76
+ } & {
77
+ emailCode: string;
78
+ phoneCode: string;
79
+ }) | ({
80
+ birthdate: Date;
81
+ identificationNumber: string;
82
+ } & {
83
+ phone?: undefined;
84
+ email: string;
85
+ } & {
86
+ password: string;
87
+ } & {
88
+ phoneCode?: undefined;
89
+ emailCode: string;
90
+ }) | ({
91
+ birthdate: Date;
92
+ identificationNumber: string;
93
+ } & {
94
+ phone?: undefined;
95
+ email: string;
96
+ } & {
97
+ password: string;
98
+ } & {
99
+ emailCode?: undefined;
100
+ phoneCode: string;
101
+ }) | ({
102
+ birthdate: Date;
103
+ identificationNumber: string;
104
+ } & {
105
+ email?: undefined;
106
+ phone: string;
107
+ } & {
108
+ password: string;
109
+ } & {
110
+ emailCode: string;
111
+ phoneCode: string;
112
+ }) | ({
113
+ birthdate: Date;
114
+ identificationNumber: string;
115
+ } & {
116
+ email?: undefined;
117
+ phone: string;
118
+ } & {
119
+ password: string;
120
+ } & {
121
+ phoneCode?: undefined;
122
+ emailCode: string;
123
+ }) | ({
124
+ birthdate: Date;
125
+ identificationNumber: string;
126
+ } & {
127
+ email?: undefined;
128
+ phone: string;
129
+ } & {
130
+ password: string;
131
+ } & {
132
+ emailCode?: undefined;
133
+ phoneCode: string;
134
+ })) => Promise<{
135
+ gender?: "m" | "f" | "o" | undefined;
136
+ firstName: string;
137
+ lastName: string;
138
+ countryId: string;
139
+ phone: string;
140
+ email: string;
141
+ birthday: Date;
142
+ identificationNumber: string;
143
+ }>;
144
+ sendExternalVerificationCode: (params: {
145
+ birthdate: Date;
146
+ channel: "1" | "2";
147
+ identificationNumber: string;
148
+ }) => Promise<void>;
149
+ verifyExternalVerificationCode: (params: {
150
+ code: string;
151
+ birthdate: Date;
152
+ channel: "1" | "2";
153
+ identificationNumber: string;
154
+ }) => Promise<any>;
155
+ externalResetPassword: (params: ({
156
+ birthdate: Date;
157
+ password: string;
158
+ identificationNumber: string;
159
+ } & {
160
+ emailCode: string;
161
+ phoneCode: string;
162
+ }) | ({
163
+ birthdate: Date;
164
+ password: string;
165
+ identificationNumber: string;
166
+ } & {
167
+ phoneCode?: undefined;
168
+ emailCode: string;
169
+ }) | ({
170
+ birthdate: Date;
171
+ password: string;
172
+ identificationNumber: string;
173
+ } & {
174
+ emailCode?: undefined;
175
+ phoneCode: string;
176
+ })) => Promise<any>;
177
+ };
@@ -0,0 +1,96 @@
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 = async ({ user, password, }) => {
10
+ const path = '/external-login';
11
+ const response = await makeRequest('POST', path, { user, password });
12
+ const info = response.data.login_info;
13
+ return {
14
+ firstName: info.firstname,
15
+ lastName: info.lastname,
16
+ countryId: info.country_id,
17
+ birthday: new Date(Date.parse(info.birthdate)),
18
+ identificationNumber: info.identification_number,
19
+ gender: info.gender.toLowerCase(),
20
+ email: info.email,
21
+ phone: info.telephone,
22
+ };
23
+ };
24
+ const preExternalEnrollment = async (params) => {
25
+ const path = '/pre-external-enrollment';
26
+ await makeRequest('POST', path, {
27
+ identification_number: params.identificationNumber,
28
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
29
+ email: params.email,
30
+ telephone: params.phone,
31
+ });
32
+ return;
33
+ };
34
+ const externalEnrollment = async (params) => {
35
+ const path = '/external-enrollment';
36
+ const response = await makeRequest('POST', path, {
37
+ identification_number: params.identificationNumber,
38
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
39
+ email: params.email,
40
+ telephone: params.phone,
41
+ password: params.password,
42
+ email_code: params.emailCode,
43
+ telephone_code: params.phoneCode,
44
+ });
45
+ const info = response.data.info;
46
+ return {
47
+ firstName: info.firstname,
48
+ lastName: info.lastname,
49
+ countryId: info.country_id,
50
+ birthday: new Date(Date.parse(info.birthdate)),
51
+ identificationNumber: info.identification_number,
52
+ gender: info.gender.toLowerCase(),
53
+ email: info.email,
54
+ phone: info.telephone,
55
+ };
56
+ };
57
+ const sendExternalVerificationCode = async (params) => {
58
+ const path = '/send-external-verification-code';
59
+ await makeRequest('POST', path, {
60
+ identification_number: params.identificationNumber,
61
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
62
+ channel: params.channel,
63
+ });
64
+ return;
65
+ };
66
+ const verifyExternalVerificationCode = async (params) => {
67
+ const path = '/verify-external-verification-code';
68
+ const response = await makeRequest('POST', path, {
69
+ identification_number: params.identificationNumber,
70
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
71
+ channel: params.channel,
72
+ code: params.code,
73
+ });
74
+ return response.data;
75
+ };
76
+ const externalResetPassword = async (params) => {
77
+ const path = '/external-reset';
78
+ const response = await makeRequest('POST', path, {
79
+ identification_number: params.identificationNumber,
80
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
81
+ password: params.password,
82
+ email_code: params.emailCode,
83
+ telephone_code: params.phoneCode,
84
+ });
85
+ return response.data;
86
+ };
87
+ return {
88
+ externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
89
+ preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), preExternalEnrollment),
90
+ externalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), schemas_1.doc24Schemas.externalLoginResponse, externalEnrollment),
91
+ sendExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendExternalVerificationCodeParams]), zod_1.void(), sendExternalVerificationCode),
92
+ verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
93
+ externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
94
+ };
95
+ };
96
+ exports.getExternalMethods = getExternalMethods;
package/lib/schemas.d.ts CHANGED
@@ -43,6 +43,8 @@ export declare const doc24Schemas: {
43
43
  countryId: import("zod").ZodString;
44
44
  birthdate: import("zod").ZodDate;
45
45
  gender: import("zod").ZodEnum<["m", "f"]>;
46
+ email: import("zod").ZodString;
47
+ phone: import("zod").ZodString;
46
48
  }, {
47
49
  phone: import("zod").ZodString;
48
50
  email: import("zod").ZodString;
@@ -75,12 +77,16 @@ export declare const doc24Schemas: {
75
77
  countryId: import("zod").ZodString;
76
78
  birthdate: import("zod").ZodDate;
77
79
  gender: import("zod").ZodEnum<["m", "f"]>;
80
+ email: import("zod").ZodString;
81
+ phone: import("zod").ZodString;
78
82
  }, "strip", import("zod").ZodTypeAny, {
79
83
  firstName: string;
80
84
  lastName: string;
81
85
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
82
86
  identificationValue: string;
83
87
  gender: "m" | "f";
88
+ phone: string;
89
+ email: string;
84
90
  countryId: string;
85
91
  birthdate: Date;
86
92
  }, {
@@ -89,6 +95,8 @@ export declare const doc24Schemas: {
89
95
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
90
96
  identificationValue: string;
91
97
  gender: "m" | "f";
98
+ phone: string;
99
+ email: string;
92
100
  countryId: string;
93
101
  birthdate: Date;
94
102
  }>;
@@ -120,15 +128,15 @@ export declare const doc24Schemas: {
120
128
  professional: import("zod").ZodObject<{
121
129
  id: import("zod").ZodNumber;
122
130
  fullName: import("zod").ZodString;
123
- logoUrl: import("zod").ZodString;
131
+ logoUrl: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
124
132
  }, "strip", import("zod").ZodTypeAny, {
133
+ logoUrl?: string | null | undefined;
125
134
  id: number;
126
135
  fullName: string;
127
- logoUrl: string;
128
136
  }, {
137
+ logoUrl?: string | null | undefined;
129
138
  id: number;
130
139
  fullName: string;
131
- logoUrl: string;
132
140
  }>;
133
141
  cost: import("zod").ZodString;
134
142
  specialty: import("zod").ZodObject<{
@@ -152,9 +160,9 @@ export declare const doc24Schemas: {
152
160
  type: "appointment" | "chat" | "instant";
153
161
  id: string | number;
154
162
  professional: {
163
+ logoUrl?: string | null | undefined;
155
164
  id: number;
156
165
  fullName: string;
157
- logoUrl: string;
158
166
  };
159
167
  clinicId: number;
160
168
  cost: string;
@@ -170,9 +178,9 @@ export declare const doc24Schemas: {
170
178
  type: "appointment" | "chat" | "instant";
171
179
  id: string | number;
172
180
  professional: {
181
+ logoUrl?: string | null | undefined;
173
182
  id: number;
174
183
  fullName: string;
175
- logoUrl: string;
176
184
  };
177
185
  clinicId: number;
178
186
  cost: string;
package/lib/schemas.js CHANGED
@@ -23,6 +23,8 @@ const basePersonData = zod_1.object({
23
23
  countryId: zod_1.string(),
24
24
  birthdate: zod_1.date(),
25
25
  gender,
26
+ email: zod_1.string().email(),
27
+ phone: zod_1.string(),
26
28
  });
27
29
  const specialtyMode = zod_1.enum(['appointment', 'chat', 'instant']);
28
30
  const specialty = zod_1.object({
@@ -40,7 +42,7 @@ const availableAppointment = zod_1.object({
40
42
  professional: zod_1.object({
41
43
  id: zod_1.number(),
42
44
  fullName: zod_1.string(),
43
- logoUrl: zod_1.string(),
45
+ logoUrl: zod_1.string().nullish(),
44
46
  }),
45
47
  cost: zod_1.string(),
46
48
  specialty: specialty,
@@ -0,0 +1,21 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getBinahWellnessMethods: (makeRequest: RequestMaker) => {
3
+ getBinahWellnessLink: (body: {
4
+ patientId: number;
5
+ socket: {
6
+ device: string;
7
+ provider: string;
8
+ socketUrl: string;
9
+ callbackUrl: string;
10
+ socketAuthToken: string;
11
+ };
12
+ }) => Promise<{
13
+ data: {
14
+ info: {
15
+ link: string;
16
+ };
17
+ timestamp: string;
18
+ };
19
+ signature: string;
20
+ }>;
21
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBinahWellnessMethods = void 0;
4
+ const zod_1 = require("zod");
5
+ const schemas_1 = require("../schemas");
6
+ const validation_1 = require("../request/validation");
7
+ const getBinahWellnessMethods = (makeRequest) => {
8
+ const getBinahWellnessLink = async (body) => {
9
+ const path = `/wellness-test`;
10
+ const response = await makeRequest('POST', path, {
11
+ patient_id: body.patientId,
12
+ socket: body.socket,
13
+ });
14
+ return response;
15
+ };
16
+ return {
17
+ getBinahWellnessLink: validation_1.validateFunction(zod_1.tuple([zod_1.any()]), schemas_1.doc24Schemas.binahWellnessResponse, getBinahWellnessLink),
18
+ };
19
+ };
20
+ exports.getBinahWellnessMethods = getBinahWellnessMethods;
@@ -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
+ };
@@ -6,6 +6,8 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
6
6
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
7
7
  identificationValue: string;
8
8
  gender: "m" | "f";
9
+ phone: string;
10
+ email: string;
9
11
  countryId: string;
10
12
  birthdate: Date;
11
13
  }) => Promise<number>;
@@ -18,6 +20,8 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
18
20
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
19
21
  identificationValue: string;
20
22
  gender: "m" | "f";
23
+ phone: string;
24
+ email: string;
21
25
  countryId: string;
22
26
  birthdate: Date;
23
27
  }) => Promise<number>;
@@ -30,6 +30,8 @@ const getPatientMethods = (makeRequest) => {
30
30
  identification_value: patient.identificationValue,
31
31
  birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
32
32
  gender: patient.gender.toUpperCase(),
33
+ email: patient.email,
34
+ phone: patient.phone,
33
35
  };
34
36
  const response = await makeRequest('POST', '/update-patient', {
35
37
  old_identification_type: utils_1.getIndetificationTypeId(oldIdentificaiton.identificationType),
@@ -16,9 +16,9 @@ export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
16
16
  type: "appointment" | "chat" | "instant";
17
17
  id: string | number;
18
18
  professional: {
19
+ logoUrl?: string | null | undefined;
19
20
  id: number;
20
21
  fullName: string;
21
- logoUrl: string;
22
22
  };
23
23
  clinicId: number;
24
24
  cost: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.42.2",
3
+ "version": "0.42.4",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },