@integraciones_doc24/sdk 0.32.0 → 0.33.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.
@@ -4,14 +4,51 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
4
4
  identificationType: "ndi" | "passport" | "credential";
5
5
  identificationValue: string;
6
6
  gender: "m" | "f";
7
- }, user: {
8
- identificationType: "ndi" | "passport" | "credential";
9
- identificationValue: string;
10
- gender: "m" | "f";
11
7
  }, from: Date, to: Date) => Promise<{
12
8
  date: Date;
13
9
  location: string;
14
10
  exams: string[];
15
11
  deepLink: string;
16
12
  }[]>;
13
+ getDiagnosticaDeepLink: (kiosk: string, user: {
14
+ language: string;
15
+ firstName: string;
16
+ lastName: string;
17
+ birthday: Date;
18
+ identificationType: "dni";
19
+ identificationValue: string;
20
+ gender: "m" | "f";
21
+ phone: string;
22
+ email: string;
23
+ }, patient: {
24
+ firstName: string;
25
+ lastName: string;
26
+ birthday: Date;
27
+ identificationType: "dni";
28
+ identificationValue: string;
29
+ gender: "m" | "f";
30
+ }) => Promise<{
31
+ forwardingRequired: true;
32
+ deepLink: string;
33
+ } | {
34
+ forwardingRequired: false;
35
+ }>;
36
+ getDiagnosticaAccess: (kiosk: string, user: {
37
+ language: string;
38
+ firstName: string;
39
+ lastName: string;
40
+ birthday: Date;
41
+ identificationType: "dni";
42
+ identificationValue: string;
43
+ gender: "m" | "f";
44
+ phone: string;
45
+ email: string;
46
+ }, patient: {
47
+ firstName: string;
48
+ lastName: string;
49
+ birthday: Date;
50
+ identificationType: "dni";
51
+ identificationValue: string;
52
+ gender: "m" | "f";
53
+ }) => Promise<void>;
17
54
  };
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDiagnosticaMethods = void 0;
4
+ const date_fns_1 = require("date-fns");
4
5
  const zod_1 = require("zod");
5
6
  const validation_1 = require("../request/validation");
6
7
  const schemas_1 = require("../schemas");
7
8
  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) => {
9
+ const getDiagnosticaHistory = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.diagnosticaPatientFilter, zod_1.date(), zod_1.date()]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), async (patient, from, to) => {
14
10
  const path = '/history-diagnostica';
15
11
  const response = await makeRequest('POST', path, {
16
12
  patient: {
@@ -20,13 +16,6 @@ const getDiagnosticaMethods = (makeRequest) => {
20
16
  : patient.identificationType,
21
17
  id_value: patient.identificationValue,
22
18
  },
23
- user: {
24
- gender: user.gender,
25
- id_type: user.identificationType === 'ndi'
26
- ? 'DNI'
27
- : user.identificationType,
28
- id_value: user.identificationValue,
29
- },
30
19
  dateFrom: from.toISOString(),
31
20
  dateTo: to.toISOString(),
32
21
  });
@@ -38,6 +27,53 @@ const getDiagnosticaMethods = (makeRequest) => {
38
27
  deepLink: i.deeplink,
39
28
  }));
40
29
  });
41
- return { getDiagnosticaHistory };
30
+ const getDiagnosticaDeepLink = validation_1.validateFunction(zod_1.tuple([
31
+ zod_1.string(),
32
+ schemas_1.doc24Schemas.diagnosticaUser,
33
+ schemas_1.doc24Schemas.diagnosticaPatient,
34
+ ]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, async (kiosk, user, patient) => {
35
+ const path = 'deeplink-diagnostica';
36
+ const response = await makeRequest('POST', path, {
37
+ kiosk,
38
+ user: mapUserData(user),
39
+ patient: mapPatientData(patient),
40
+ });
41
+ const data = response.data.data.info.data;
42
+ if (data.forwarding_required)
43
+ return { forwardingRequired: true, deepLink: data.deeplink };
44
+ return { forwardingRequired: false };
45
+ });
46
+ const getDiagnosticaAccess = validation_1.validateFunction(zod_1.tuple([
47
+ zod_1.string(),
48
+ schemas_1.doc24Schemas.diagnosticaUser,
49
+ schemas_1.doc24Schemas.diagnosticaPatient,
50
+ ]), zod_1.void(), async (kiosk, user, patient) => {
51
+ const path = 'access-diagnostica';
52
+ await makeRequest('POST', path, {
53
+ kiosk,
54
+ user: mapUserData(user),
55
+ patient: mapPatientData(patient),
56
+ });
57
+ return;
58
+ });
59
+ return { getDiagnosticaHistory, getDiagnosticaDeepLink, getDiagnosticaAccess };
42
60
  };
43
61
  exports.getDiagnosticaMethods = getDiagnosticaMethods;
62
+ const mapPatientData = (patient) => {
63
+ return {
64
+ name: patient.firstName,
65
+ surname: patient.lastName,
66
+ birthday: date_fns_1.format(patient.birthday, 'yyyy-MM-dd'),
67
+ id_type: 'DNI',
68
+ id_value: patient.identificationValue,
69
+ gender: patient.gender.toLocaleUpperCase(),
70
+ };
71
+ };
72
+ const mapUserData = (user) => {
73
+ return {
74
+ ...mapPatientData(user),
75
+ phone: user.phone,
76
+ email: user.email,
77
+ language: user.language,
78
+ };
79
+ };
package/lib/index.d.ts CHANGED
@@ -10,32 +10,32 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
10
10
  lastName: string;
11
11
  identificationType: "ndi" | "passport" | "credential";
12
12
  identificationValue: string;
13
- countryId: string;
14
- birthdate: Date;
15
13
  gender: "m" | "f";
16
14
  phone: string;
17
15
  email: string;
16
+ countryId: string;
17
+ birthdate: Date;
18
18
  }) => Promise<number>;
19
19
  getUserInstance: (user: number | {
20
20
  firstName: string;
21
21
  lastName: string;
22
22
  identificationType: "ndi" | "passport" | "credential";
23
23
  identificationValue: string;
24
- countryId: string;
25
- birthdate: Date;
26
24
  gender: "m" | "f";
27
25
  phone: string;
28
26
  email: string;
27
+ countryId: string;
28
+ birthdate: Date;
29
29
  }) => Promise<Doc24.UserSdk>;
30
30
  getProfessional: (professionalId: number) => Promise<{
31
31
  id: number;
32
32
  logoUrl: string;
33
33
  firstName: string;
34
34
  lastName: string;
35
- birthdate: Date;
36
35
  gender: "m" | "f";
37
36
  phone: string | null;
38
37
  email: string;
38
+ birthdate: Date;
39
39
  specialties: {
40
40
  id: number;
41
41
  description: string;
@@ -69,9 +69,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
69
69
  enroll: (params: {
70
70
  firstName: string;
71
71
  lastName: string;
72
- birthdate: Date;
73
72
  gender: "m" | "f";
74
73
  email: string;
74
+ birthdate: Date;
75
75
  startDate: Date;
76
76
  identificationNumber: string;
77
77
  plan: string;
@@ -80,15 +80,52 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
80
80
  identificationType: "ndi" | "passport" | "credential";
81
81
  identificationValue: string;
82
82
  gender: "m" | "f";
83
- }, user: {
84
- identificationType: "ndi" | "passport" | "credential";
85
- identificationValue: string;
86
- gender: "m" | "f";
87
83
  }, from: Date, to: Date) => Promise<{
88
84
  date: Date;
89
85
  location: string;
90
86
  exams: string[];
91
87
  deepLink: string;
92
88
  }[]>;
89
+ getDiagnosticaDeepLink: (kiosk: string, user: {
90
+ language: string;
91
+ firstName: string;
92
+ lastName: string;
93
+ birthday: Date;
94
+ identificationType: "dni";
95
+ identificationValue: string;
96
+ gender: "m" | "f";
97
+ phone: string;
98
+ email: string;
99
+ }, patient: {
100
+ firstName: string;
101
+ lastName: string;
102
+ birthday: Date;
103
+ identificationType: "dni";
104
+ identificationValue: string;
105
+ gender: "m" | "f";
106
+ }) => Promise<{
107
+ forwardingRequired: true;
108
+ deepLink: string;
109
+ } | {
110
+ forwardingRequired: false;
111
+ }>;
112
+ getDiagnosticaAccess: (kiosk: string, user: {
113
+ language: string;
114
+ firstName: string;
115
+ lastName: string;
116
+ birthday: Date;
117
+ identificationType: "dni";
118
+ identificationValue: string;
119
+ gender: "m" | "f";
120
+ phone: string;
121
+ email: string;
122
+ }, patient: {
123
+ firstName: string;
124
+ lastName: string;
125
+ birthday: Date;
126
+ identificationType: "dni";
127
+ identificationValue: string;
128
+ gender: "m" | "f";
129
+ }) => Promise<void>;
93
130
  }>;
94
131
  export type { Doc24 } from './types';
package/lib/schemas.d.ts CHANGED
@@ -51,21 +51,21 @@ export declare const doc24Schemas: {
51
51
  lastName: string;
52
52
  identificationType: "ndi" | "passport" | "credential";
53
53
  identificationValue: string;
54
- countryId: string;
55
- birthdate: Date;
56
54
  gender: "m" | "f";
57
55
  phone: string;
58
56
  email: string;
57
+ countryId: string;
58
+ birthdate: Date;
59
59
  }, {
60
60
  firstName: string;
61
61
  lastName: string;
62
62
  identificationType: "ndi" | "passport" | "credential";
63
63
  identificationValue: string;
64
- countryId: string;
65
- birthdate: Date;
66
64
  gender: "m" | "f";
67
65
  phone: string;
68
66
  email: string;
67
+ countryId: string;
68
+ birthdate: Date;
69
69
  }>;
70
70
  patient: import("zod").ZodObject<{
71
71
  firstName: import("zod").ZodString;
@@ -80,17 +80,17 @@ export declare const doc24Schemas: {
80
80
  lastName: string;
81
81
  identificationType: "ndi" | "passport" | "credential";
82
82
  identificationValue: string;
83
+ gender: "m" | "f";
83
84
  countryId: string;
84
85
  birthdate: Date;
85
- gender: "m" | "f";
86
86
  }, {
87
87
  firstName: string;
88
88
  lastName: string;
89
89
  identificationType: "ndi" | "passport" | "credential";
90
90
  identificationValue: string;
91
+ gender: "m" | "f";
91
92
  countryId: string;
92
93
  birthdate: Date;
93
- gender: "m" | "f";
94
94
  }>;
95
95
  specialtyMode: import("zod").ZodEnum<["appointment", "chat", "instant"]>;
96
96
  specialty: import("zod").ZodObject<{
@@ -657,10 +657,10 @@ export declare const doc24Schemas: {
657
657
  logoUrl: string;
658
658
  firstName: string;
659
659
  lastName: string;
660
- birthdate: Date;
661
660
  gender: "m" | "f";
662
661
  phone: string | null;
663
662
  email: string;
663
+ birthdate: Date;
664
664
  specialties: {
665
665
  id: number;
666
666
  description: string;
@@ -680,10 +680,10 @@ export declare const doc24Schemas: {
680
680
  logoUrl: string;
681
681
  firstName: string;
682
682
  lastName: string;
683
- birthdate: Date;
684
683
  gender: "m" | "f";
685
684
  phone: string | null;
686
685
  email: string;
686
+ birthdate: Date;
687
687
  specialties: {
688
688
  id: number;
689
689
  description: string;
@@ -909,18 +909,18 @@ export declare const doc24Schemas: {
909
909
  }, "strip", import("zod").ZodTypeAny, {
910
910
  firstName: string;
911
911
  lastName: string;
912
- birthdate: Date;
913
912
  gender: "m" | "f";
914
913
  email: string;
914
+ birthdate: Date;
915
915
  startDate: Date;
916
916
  identificationNumber: string;
917
917
  plan: string;
918
918
  }, {
919
919
  firstName: string;
920
920
  lastName: string;
921
- birthdate: Date;
922
921
  gender: "m" | "f";
923
922
  email: string;
923
+ birthdate: Date;
924
924
  startDate: Date;
925
925
  identificationNumber: string;
926
926
  plan: string;
@@ -938,19 +938,6 @@ export declare const doc24Schemas: {
938
938
  identificationValue: string;
939
939
  gender: "m" | "f";
940
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
941
  diagnosticaHistoryAppointment: import("zod").ZodObject<{
955
942
  date: import("zod").ZodDate;
956
943
  location: import("zod").ZodString;
@@ -967,4 +954,74 @@ export declare const doc24Schemas: {
967
954
  exams: string[];
968
955
  deepLink: string;
969
956
  }>;
957
+ diagnosticaUser: import("zod").ZodObject<import("zod").extendShape<{
958
+ firstName: import("zod").ZodString;
959
+ lastName: import("zod").ZodString;
960
+ birthday: import("zod").ZodDate;
961
+ identificationType: import("zod").ZodLiteral<"dni">;
962
+ identificationValue: import("zod").ZodString;
963
+ gender: import("zod").ZodEnum<["m", "f"]>;
964
+ }, {
965
+ phone: import("zod").ZodString;
966
+ email: import("zod").ZodString;
967
+ language: import("zod").ZodString;
968
+ }>, "strip", import("zod").ZodTypeAny, {
969
+ language: string;
970
+ firstName: string;
971
+ lastName: string;
972
+ birthday: Date;
973
+ identificationType: "dni";
974
+ identificationValue: string;
975
+ gender: "m" | "f";
976
+ phone: string;
977
+ email: string;
978
+ }, {
979
+ language: string;
980
+ firstName: string;
981
+ lastName: string;
982
+ birthday: Date;
983
+ identificationType: "dni";
984
+ identificationValue: string;
985
+ gender: "m" | "f";
986
+ phone: string;
987
+ email: string;
988
+ }>;
989
+ diagnosticaPatient: import("zod").ZodObject<{
990
+ firstName: import("zod").ZodString;
991
+ lastName: import("zod").ZodString;
992
+ birthday: import("zod").ZodDate;
993
+ identificationType: import("zod").ZodLiteral<"dni">;
994
+ identificationValue: import("zod").ZodString;
995
+ gender: import("zod").ZodEnum<["m", "f"]>;
996
+ }, "strip", import("zod").ZodTypeAny, {
997
+ firstName: string;
998
+ lastName: string;
999
+ birthday: Date;
1000
+ identificationType: "dni";
1001
+ identificationValue: string;
1002
+ gender: "m" | "f";
1003
+ }, {
1004
+ firstName: string;
1005
+ lastName: string;
1006
+ birthday: Date;
1007
+ identificationType: "dni";
1008
+ identificationValue: string;
1009
+ gender: "m" | "f";
1010
+ }>;
1011
+ diagnosticaDeepLinkResponse: import("zod").ZodUnion<[import("zod").ZodObject<{
1012
+ forwardingRequired: import("zod").ZodLiteral<true>;
1013
+ deepLink: import("zod").ZodString;
1014
+ }, "strip", import("zod").ZodTypeAny, {
1015
+ forwardingRequired: true;
1016
+ deepLink: string;
1017
+ }, {
1018
+ forwardingRequired: true;
1019
+ deepLink: string;
1020
+ }>, import("zod").ZodObject<{
1021
+ forwardingRequired: import("zod").ZodLiteral<false>;
1022
+ }, "strip", import("zod").ZodTypeAny, {
1023
+ forwardingRequired: false;
1024
+ }, {
1025
+ forwardingRequired: false;
1026
+ }>]>;
970
1027
  };
package/lib/schemas.js CHANGED
@@ -130,6 +130,23 @@ const diagnosticaHistoryAppointment = zod_1.object({
130
130
  exams: zod_1.string().array(),
131
131
  deepLink: zod_1.string().url(),
132
132
  });
133
+ const diagnosticaPatient = zod_1.object({
134
+ firstName: zod_1.string(),
135
+ lastName: zod_1.string(),
136
+ birthday: zod_1.date(),
137
+ identificationType: zod_1.literal('dni'),
138
+ identificationValue: zod_1.string(),
139
+ gender: gender,
140
+ });
141
+ const diagnosticaUser = diagnosticaPatient.merge(zod_1.object({
142
+ phone: zod_1.string(),
143
+ email: zod_1.string().email(),
144
+ language: zod_1.string(),
145
+ }));
146
+ const diagnosticaDeepLinkResponse = zod_1.object({
147
+ forwardingRequired: zod_1.literal(true),
148
+ deepLink: zod_1.string().url(),
149
+ }).or(zod_1.object({ forwardingRequired: zod_1.literal(false) }));
133
150
  exports.doc24Schemas = {
134
151
  identificationType,
135
152
  sdkCredentials,
@@ -244,10 +261,8 @@ exports.doc24Schemas = {
244
261
  identificationType,
245
262
  identificationValue: zod_1.string(),
246
263
  }),
247
- diagnosticaUserFilter: zod_1.object({
248
- gender,
249
- identificationType,
250
- identificationValue: zod_1.string(),
251
- }),
252
264
  diagnosticaHistoryAppointment,
265
+ diagnosticaUser,
266
+ diagnosticaPatient,
267
+ diagnosticaDeepLinkResponse,
253
268
  };
package/lib/types.d.ts CHANGED
@@ -24,16 +24,20 @@ 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
27
  type DiagnosticaPatientFilter = TypeOf<typeof doc24Schemas.diagnosticaPatientFilter>;
28
+ type DiagnosticaUser = TypeOf<typeof doc24Schemas.diagnosticaUser>;
29
+ type DiagnosticaPatient = TypeOf<typeof doc24Schemas.diagnosticaPatient>;
29
30
  type DiagnosticaHistoryAppointment = TypeOf<typeof doc24Schemas.diagnosticaHistoryAppointment>;
31
+ type DiagnosticaDeepLinkResponse = TypeOf<typeof doc24Schemas.diagnosticaDeepLinkResponse>;
30
32
  type BaseSdk = {
31
33
  declareUser: (user: User) => Promise<number>;
32
34
  getUserInstance: (user: User | number) => Promise<UserSdk>;
33
35
  getProfessional: (professionalId: number) => Promise<Professional>;
34
36
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
35
37
  enroll: (params: EnrollmentParams) => Promise<void>;
36
- getDiagnosticaHistory: (patient: DiagnosticaPatientFilter, user: DiagnosticaUserFilter, from: Date, to: Date) => Promise<DiagnosticaHistoryAppointment[]>;
38
+ getDiagnosticaHistory: (patient: DiagnosticaPatientFilter, from: Date, to: Date) => Promise<DiagnosticaHistoryAppointment[]>;
39
+ getDiagnosticaDeepLink: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<DiagnosticaDeepLinkResponse>;
40
+ getDiagnosticaAccess: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<void>;
37
41
  };
38
42
  type UserSdk = {
39
43
  declarePatient: (patient: Patient) => Promise<number>;
@@ -5,8 +5,8 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
5
5
  lastName: string;
6
6
  identificationType: "ndi" | "passport" | "credential";
7
7
  identificationValue: string;
8
+ gender: "m" | "f";
8
9
  countryId: string;
9
10
  birthdate: Date;
10
- gender: "m" | "f";
11
11
  }) => Promise<number>;
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {