@integraciones_doc24/sdk 1.4.0 → 1.4.2

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 CHANGED
@@ -79,7 +79,7 @@ type BaseSdk = {
79
79
  getProfessional: (professionalId: number) => Promise<Professional>;
80
80
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
81
81
  enroll: (params: EnrollmentParams) => Promise<void>;
82
- getConverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
82
+ getCoverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
83
83
  getVerificationCode: (params: getVerificationCodeParams) => Promise<void>;
84
84
  getDiagnosticaHistory: (
85
85
  patient: DiagnosticaPatientFilter,
@@ -17,12 +17,14 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
17
17
  code?: string | undefined;
18
18
  channel?: "1" | "2" | undefined;
19
19
  }) => Promise<{
20
- patientId: number | null;
20
+ askCode: true;
21
21
  userInfo: {
22
22
  phone: string;
23
23
  email: string;
24
- } | null;
25
- askCode: boolean;
24
+ };
25
+ } | {
26
+ patientId: number | null;
27
+ askCode: false;
26
28
  userId: number;
27
29
  }>;
28
30
  getUserId: (user: {
@@ -40,7 +42,7 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
40
42
  identificationType: "ndi" | "passport" | "credential";
41
43
  identificationValue: string;
42
44
  channel: "1" | "2";
43
- }) => Promise<any>;
45
+ }) => Promise<void>;
44
46
  getUserInstance: (user: number | {
45
47
  firstName: string;
46
48
  lastName: string;
@@ -62,7 +64,7 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
62
64
  identificationNumber: string;
63
65
  plan: string;
64
66
  }) => Promise<void>;
65
- getConverageInfo: (identificationValue: string) => Promise<{
67
+ getCoverageInfo: (identificationValue: string) => Promise<{
66
68
  firstName: string | null;
67
69
  lastName: string | null;
68
70
  birthdate: Date;
@@ -27,13 +27,14 @@ const getUserMethods = (makeRequest, url, credentials) => {
27
27
  channel: parsedChannel,
28
28
  code,
29
29
  });
30
- const mappedResponse = {
30
+ const data = response.data;
31
+ if (data.ask_code)
32
+ return { askCode: true, userInfo: data.user_info };
33
+ return {
34
+ askCode: false,
31
35
  userId: response.data.user_id,
32
36
  patientId: response.data.patient_id,
33
- userInfo: response.data.user_info,
34
- askCode: response.data.ask_code,
35
37
  };
36
- return mappedResponse;
37
38
  };
38
39
  const getUserId = async (user) => {
39
40
  const path = '/search-user';
@@ -82,7 +83,7 @@ const getUserMethods = (makeRequest, url, credentials) => {
82
83
  user_data: mappedUser,
83
84
  });
84
85
  };
85
- const getConverageInfo = async (identificationValue) => {
86
+ const getCoverageInfo = async (identificationValue) => {
86
87
  const path = `/info-coverage/${identificationValue}`;
87
88
  const response = await makeRequest('GET', path);
88
89
  const raw = response.data.info;
@@ -124,7 +125,7 @@ const getUserMethods = (makeRequest, url, credentials) => {
124
125
  // TODO: validate?
125
126
  zod_1.any(), getUserInstance),
126
127
  enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
127
- getConverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getConverageInfo),
128
+ getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
128
129
  };
129
130
  };
130
131
  exports.getUserMethods = getUserMethods;
package/lib/index.d.ts CHANGED
@@ -21,12 +21,14 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
21
21
  code?: string | undefined;
22
22
  channel?: "1" | "2" | undefined;
23
23
  }) => Promise<{
24
- patientId: number | null;
24
+ askCode: true;
25
25
  userInfo: {
26
26
  phone: string;
27
27
  email: string;
28
- } | null;
29
- askCode: boolean;
28
+ };
29
+ } | {
30
+ patientId: number | null;
31
+ askCode: false;
30
32
  userId: number;
31
33
  }>;
32
34
  getUserId: (user: {
@@ -104,7 +106,7 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
104
106
  identificationNumber: string;
105
107
  plan: string;
106
108
  }) => Promise<void>;
107
- getConverageInfo: (identificationValue: string) => Promise<{
109
+ getCoverageInfo: (identificationValue: string) => Promise<{
108
110
  firstName: string | null;
109
111
  lastName: string | null;
110
112
  birthdate: Date;
@@ -132,7 +134,7 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
132
134
  identificationType: "ndi" | "passport" | "credential";
133
135
  identificationValue: string;
134
136
  channel: "1" | "2";
135
- }) => Promise<any>;
137
+ }) => Promise<void>;
136
138
  getDiagnosticaHistory: (patient: {
137
139
  identificationType: "ndi" | "passport" | "credential";
138
140
  identificationValue: string;
package/lib/schemas.d.ts CHANGED
@@ -1192,9 +1192,8 @@ export declare const doc24Schemas: {
1192
1192
  code?: string | undefined;
1193
1193
  channel?: "1" | "2" | undefined;
1194
1194
  }>>;
1195
- declareUserResponse: import("zod").ZodObject<import("zod").extendShape<{
1196
- patientId: import("zod").ZodNullable<import("zod").ZodNumber>;
1197
- userInfo: import("zod").ZodNullable<import("zod").ZodObject<{
1195
+ declareUserResponse: import("zod").ZodUnion<[import("zod").ZodObject<{
1196
+ userInfo: import("zod").ZodObject<{
1198
1197
  email: import("zod").ZodString;
1199
1198
  phone: import("zod").ZodString;
1200
1199
  }, "strip", import("zod").ZodTypeAny, {
@@ -1203,27 +1202,33 @@ export declare const doc24Schemas: {
1203
1202
  }, {
1204
1203
  phone: string;
1205
1204
  email: string;
1206
- }>>;
1207
- askCode: import("zod").ZodBoolean;
1208
- }, {
1209
- userId: import("zod").ZodNumber;
1210
- }>, "strip", import("zod").ZodTypeAny, {
1211
- patientId: number | null;
1205
+ }>;
1206
+ askCode: import("zod").ZodLiteral<true>;
1207
+ }, "strip", import("zod").ZodTypeAny, {
1208
+ askCode: true;
1212
1209
  userInfo: {
1213
1210
  phone: string;
1214
1211
  email: string;
1215
- } | null;
1216
- askCode: boolean;
1217
- userId: number;
1212
+ };
1218
1213
  }, {
1219
- patientId: number | null;
1214
+ askCode: true;
1220
1215
  userInfo: {
1221
1216
  phone: string;
1222
1217
  email: string;
1223
- } | null;
1224
- askCode: boolean;
1218
+ };
1219
+ }>, import("zod").ZodObject<{
1220
+ askCode: import("zod").ZodLiteral<false>;
1221
+ patientId: import("zod").ZodNullable<import("zod").ZodNumber>;
1222
+ userId: import("zod").ZodNumber;
1223
+ }, "strip", import("zod").ZodTypeAny, {
1224
+ patientId: number | null;
1225
+ askCode: false;
1225
1226
  userId: number;
1226
- }>;
1227
+ }, {
1228
+ patientId: number | null;
1229
+ askCode: false;
1230
+ userId: number;
1231
+ }>]>;
1227
1232
  declarePatientParams: import("zod").ZodIntersection<import("zod").ZodObject<{
1228
1233
  patient: import("zod").ZodObject<{
1229
1234
  firstName: import("zod").ZodString;
@@ -1280,9 +1285,8 @@ export declare const doc24Schemas: {
1280
1285
  code?: string | undefined;
1281
1286
  channel?: "1" | "2" | undefined;
1282
1287
  }>>;
1283
- declarePatientResponse: import("zod").ZodObject<{
1284
- patientId: import("zod").ZodNullable<import("zod").ZodNumber>;
1285
- userInfo: import("zod").ZodNullable<import("zod").ZodObject<{
1288
+ declarePatientResponse: import("zod").ZodUnion<[import("zod").ZodObject<{
1289
+ userInfo: import("zod").ZodObject<{
1286
1290
  email: import("zod").ZodString;
1287
1291
  phone: import("zod").ZodString;
1288
1292
  }, "strip", import("zod").ZodTypeAny, {
@@ -1291,23 +1295,30 @@ export declare const doc24Schemas: {
1291
1295
  }, {
1292
1296
  phone: string;
1293
1297
  email: string;
1294
- }>>;
1295
- askCode: import("zod").ZodBoolean;
1298
+ }>;
1299
+ askCode: import("zod").ZodLiteral<true>;
1296
1300
  }, "strip", import("zod").ZodTypeAny, {
1297
- patientId: number | null;
1301
+ askCode: true;
1298
1302
  userInfo: {
1299
1303
  phone: string;
1300
1304
  email: string;
1301
- } | null;
1302
- askCode: boolean;
1305
+ };
1303
1306
  }, {
1304
- patientId: number | null;
1307
+ askCode: true;
1305
1308
  userInfo: {
1306
1309
  phone: string;
1307
1310
  email: string;
1308
- } | null;
1309
- askCode: boolean;
1310
- }>;
1311
+ };
1312
+ }>, import("zod").ZodObject<{
1313
+ askCode: import("zod").ZodLiteral<false>;
1314
+ patientId: import("zod").ZodNullable<import("zod").ZodNumber>;
1315
+ }, "strip", import("zod").ZodTypeAny, {
1316
+ patientId: number | null;
1317
+ askCode: false;
1318
+ }, {
1319
+ patientId: number | null;
1320
+ askCode: false;
1321
+ }>]>;
1311
1322
  verificationParams: import("zod").ZodObject<{
1312
1323
  channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
1313
1324
  code: import("zod").ZodOptional<import("zod").ZodString>;
package/lib/schemas.js CHANGED
@@ -190,14 +190,26 @@ const declarePatientParams = zod_1.object({
190
190
  patient,
191
191
  }).and(verificationParams);
192
192
  const declarePatientResponse = zod_1.object({
193
+ userInfo: zod_1.object({
194
+ email: zod_1.string(),
195
+ phone: zod_1.string(),
196
+ }),
197
+ askCode: zod_1.literal(true),
198
+ }).or(zod_1.object({
199
+ askCode: zod_1.literal(false),
193
200
  patientId: zod_1.number().nullable(),
201
+ }));
202
+ const declareUserResponse = zod_1.object({
194
203
  userInfo: zod_1.object({
195
204
  email: zod_1.string(),
196
205
  phone: zod_1.string(),
197
- }).nullable(),
198
- askCode: zod_1.boolean(),
199
- });
200
- const declareUserResponse = declarePatientResponse.extend({ userId: zod_1.number() });
206
+ }),
207
+ askCode: zod_1.literal(true),
208
+ }).or(zod_1.object({
209
+ askCode: zod_1.literal(false),
210
+ patientId: zod_1.number().nullable(),
211
+ userId: zod_1.number(),
212
+ }));
201
213
  exports.doc24Schemas = {
202
214
  identificationType,
203
215
  sdkCredentials,
package/lib/types.d.ts CHANGED
@@ -43,8 +43,8 @@ export declare namespace Doc24 {
43
43
  getProfessional: (professionalId: number) => Promise<Professional>;
44
44
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
45
45
  enroll: (params: EnrollmentParams) => Promise<void>;
46
- getConverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
47
- getVerificationCode: (params: getVerificationCodeParams) => Promise<any>;
46
+ getCoverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
47
+ getVerificationCode: (params: getVerificationCodeParams) => Promise<void>;
48
48
  getDiagnosticaHistory: (patient: DiagnosticaPatientFilter, from: Date, to: Date) => Promise<DiagnosticaHistoryAppointment[]>;
49
49
  getDiagnosticaDeepLink: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<DiagnosticaDeepLinkResponse>;
50
50
  getDiagnosticaAccess: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<void>;
@@ -14,12 +14,14 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
14
14
  code?: string | undefined;
15
15
  channel?: "1" | "2" | undefined;
16
16
  }) => Promise<{
17
- patientId: number | null;
17
+ askCode: true;
18
18
  userInfo: {
19
19
  phone: string;
20
20
  email: string;
21
- } | null;
22
- askCode: boolean;
21
+ };
22
+ } | {
23
+ patientId: number | null;
24
+ askCode: false;
23
25
  }>;
24
26
  getPatientId: (patient: {
25
27
  firstName: string;
@@ -24,12 +24,13 @@ const getPatientMethods = (makeRequest) => {
24
24
  channel: parsedChannel,
25
25
  code,
26
26
  });
27
- const mappedResponse = {
28
- patientId: response.data.patient_id,
29
- userInfo: response.data.user_info,
30
- askCode: response.data.ask_code,
31
- };
32
- return mappedResponse;
27
+ const data = response.data;
28
+ if (data.ask_code)
29
+ return {
30
+ userInfo: data.user_info,
31
+ askCode: true,
32
+ };
33
+ return { askCode: false, patientId: data.patient_id };
33
34
  };
34
35
  const getPatientId = async (patient) => {
35
36
  const path = '/search-patient';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },