@integraciones_doc24/sdk 0.35.0 → 0.35.1

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.
Files changed (192) hide show
  1. package/lib/baseSdk/index.js +5 -1
  2. package/lib/lib/baseSdk/index.d.ts +57 -10
  3. package/lib/lib/baseSdk/user.d.ts +16 -5
  4. package/lib/lib/baseSdk/user.js +67 -25
  5. package/lib/lib/index.d.ts +44 -16
  6. package/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
  7. package/lib/lib/lib/baseSdk/diagnostica.js +79 -0
  8. package/lib/lib/lib/baseSdk/index.d.ts +51 -0
  9. package/lib/lib/lib/baseSdk/index.js +66 -0
  10. package/lib/lib/lib/baseSdk/user.d.ts +9 -0
  11. package/lib/lib/lib/baseSdk/user.js +130 -0
  12. package/lib/lib/lib/index.d.ts +168 -0
  13. package/lib/lib/lib/index.js +22 -0
  14. package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
  15. package/lib/lib/lib/lib/baseSdk/diagnostica.js +79 -0
  16. package/lib/lib/lib/lib/baseSdk/index.d.ts +14 -0
  17. package/lib/lib/lib/lib/baseSdk/index.js +66 -0
  18. package/lib/lib/lib/lib/baseSdk/user.d.ts +9 -0
  19. package/lib/lib/lib/lib/baseSdk/user.js +130 -0
  20. package/lib/lib/lib/lib/index.d.ts +58 -0
  21. package/lib/lib/lib/lib/index.js +22 -0
  22. package/lib/lib/lib/lib/request/index.d.ts +2 -0
  23. package/lib/lib/lib/lib/request/index.js +26 -0
  24. package/lib/lib/lib/lib/request/token.d.ts +2 -0
  25. package/lib/lib/lib/lib/request/token.js +34 -0
  26. package/lib/lib/lib/lib/request/validation.d.ts +10 -0
  27. package/lib/lib/lib/lib/request/validation.js +28 -0
  28. package/lib/lib/lib/lib/schemas.d.ts +1334 -0
  29. package/lib/lib/lib/lib/schemas.js +325 -0
  30. package/lib/lib/lib/lib/test.d.ts +1 -0
  31. package/lib/lib/lib/lib/test.js +55 -0
  32. package/lib/lib/lib/lib/types.d.ts +1 -0
  33. package/lib/lib/lib/lib/types.js +2 -0
  34. package/lib/lib/lib/lib/userSdk/chat.d.ts +9 -0
  35. package/lib/lib/lib/lib/userSdk/chat.js +98 -0
  36. package/lib/lib/lib/lib/userSdk/index.d.ts +24 -0
  37. package/lib/lib/lib/lib/userSdk/index.js +27 -0
  38. package/lib/lib/lib/lib/userSdk/patients.d.ts +5 -0
  39. package/lib/lib/lib/lib/userSdk/patients.js +55 -0
  40. package/lib/lib/lib/lib/userSdk/schedule.d.ts +7 -0
  41. package/lib/lib/lib/lib/userSdk/schedule.js +76 -0
  42. package/lib/lib/lib/lib/userSdk/specialties.d.ts +4 -0
  43. package/lib/lib/lib/lib/userSdk/specialties.js +19 -0
  44. package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
  45. package/lib/lib/lib/lib/userSdk/videoVisit.js +147 -0
  46. package/lib/lib/lib/lib/utils.d.ts +4 -0
  47. package/lib/lib/lib/lib/utils.js +19 -0
  48. package/lib/lib/lib/lib/webhook/index.d.ts +8 -0
  49. package/lib/lib/lib/lib/webhook/index.js +55 -0
  50. package/lib/lib/lib/lib/webhook/responses.d.ts +36 -0
  51. package/lib/lib/lib/lib/webhook/responses.js +42 -0
  52. package/lib/lib/lib/lib/webhook/token.d.ts +2 -0
  53. package/lib/lib/lib/lib/webhook/token.js +23 -0
  54. package/lib/lib/lib/request/index.d.ts +2 -0
  55. package/lib/lib/lib/request/index.js +26 -0
  56. package/lib/lib/lib/request/token.d.ts +2 -0
  57. package/lib/lib/lib/request/token.js +34 -0
  58. package/lib/lib/lib/request/validation.d.ts +10 -0
  59. package/lib/lib/lib/request/validation.js +28 -0
  60. package/lib/lib/lib/schemas.d.ts +1334 -0
  61. package/lib/lib/lib/schemas.js +325 -0
  62. package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +6 -0
  63. package/lib/lib/lib/src/baseSdk/diagnostica.js +79 -0
  64. package/lib/lib/lib/src/baseSdk/index.d.ts +51 -0
  65. package/lib/lib/lib/src/baseSdk/index.js +66 -0
  66. package/lib/lib/lib/src/baseSdk/user.d.ts +9 -0
  67. package/lib/lib/lib/src/baseSdk/user.js +130 -0
  68. package/lib/lib/lib/src/index.d.ts +169 -0
  69. package/lib/lib/lib/src/index.js +22 -0
  70. package/lib/lib/lib/src/request/index.d.ts +2 -0
  71. package/lib/lib/lib/src/request/index.js +26 -0
  72. package/lib/lib/lib/src/request/token.d.ts +2 -0
  73. package/lib/lib/lib/src/request/token.js +34 -0
  74. package/lib/lib/lib/src/request/validation.d.ts +10 -0
  75. package/lib/lib/lib/src/request/validation.js +28 -0
  76. package/lib/lib/lib/src/schemas.d.ts +1340 -0
  77. package/lib/lib/lib/src/schemas.js +325 -0
  78. package/lib/lib/lib/src/types.d.ts +1 -0
  79. package/lib/lib/lib/src/types.js +2 -0
  80. package/lib/lib/lib/src/userSdk/chat.d.ts +9 -0
  81. package/lib/lib/lib/src/userSdk/chat.js +98 -0
  82. package/lib/lib/lib/src/userSdk/index.d.ts +102 -0
  83. package/lib/lib/lib/src/userSdk/index.js +27 -0
  84. package/lib/lib/lib/src/userSdk/patients.d.ts +5 -0
  85. package/lib/lib/lib/src/userSdk/patients.js +55 -0
  86. package/lib/lib/lib/src/userSdk/schedule.d.ts +7 -0
  87. package/lib/lib/lib/src/userSdk/schedule.js +76 -0
  88. package/lib/lib/lib/src/userSdk/specialties.d.ts +4 -0
  89. package/lib/lib/lib/src/userSdk/specialties.js +19 -0
  90. package/lib/lib/lib/src/userSdk/videoVisit.d.ts +10 -0
  91. package/lib/lib/lib/src/userSdk/videoVisit.js +147 -0
  92. package/lib/lib/lib/src/utils.d.ts +4 -0
  93. package/lib/lib/lib/src/utils.js +19 -0
  94. package/lib/lib/lib/src/webhook/index.d.ts +8 -0
  95. package/lib/lib/lib/src/webhook/index.js +55 -0
  96. package/lib/lib/lib/src/webhook/responses.d.ts +36 -0
  97. package/lib/lib/lib/src/webhook/responses.js +42 -0
  98. package/lib/lib/lib/src/webhook/token.d.ts +2 -0
  99. package/lib/lib/lib/src/webhook/token.js +23 -0
  100. package/lib/lib/lib/test.d.ts +1 -0
  101. package/lib/lib/lib/test.js +55 -0
  102. package/lib/lib/lib/types.d.ts +1 -0
  103. package/lib/lib/lib/types.js +2 -0
  104. package/lib/lib/lib/userSdk/chat.d.ts +9 -0
  105. package/lib/lib/lib/userSdk/chat.js +98 -0
  106. package/lib/lib/lib/userSdk/index.d.ts +102 -0
  107. package/lib/lib/lib/userSdk/index.js +27 -0
  108. package/lib/lib/lib/userSdk/patients.d.ts +5 -0
  109. package/lib/lib/lib/userSdk/patients.js +55 -0
  110. package/lib/lib/lib/userSdk/schedule.d.ts +7 -0
  111. package/lib/lib/lib/userSdk/schedule.js +76 -0
  112. package/lib/lib/lib/userSdk/specialties.d.ts +4 -0
  113. package/lib/lib/lib/userSdk/specialties.js +19 -0
  114. package/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
  115. package/lib/lib/lib/userSdk/videoVisit.js +147 -0
  116. package/lib/lib/lib/utils.d.ts +4 -0
  117. package/lib/lib/lib/utils.js +19 -0
  118. package/lib/lib/lib/webhook/index.d.ts +8 -0
  119. package/lib/lib/lib/webhook/index.js +55 -0
  120. package/lib/lib/lib/webhook/responses.d.ts +36 -0
  121. package/lib/lib/lib/webhook/responses.js +42 -0
  122. package/lib/lib/lib/webhook/token.d.ts +2 -0
  123. package/lib/lib/lib/webhook/token.js +23 -0
  124. package/lib/lib/schemas.d.ts +256 -60
  125. package/lib/lib/schemas.js +33 -2
  126. package/lib/lib/src/baseSdk/diagnostica.d.ts +11 -0
  127. package/lib/lib/src/baseSdk/diagnostica.js +79 -0
  128. package/lib/lib/src/baseSdk/index.d.ts +162 -0
  129. package/lib/lib/src/baseSdk/index.js +66 -0
  130. package/lib/lib/src/baseSdk/user.d.ts +41 -0
  131. package/lib/lib/src/baseSdk/user.js +130 -0
  132. package/lib/lib/src/index.d.ts +183 -0
  133. package/lib/lib/src/index.js +22 -0
  134. package/lib/lib/src/request/index.d.ts +2 -0
  135. package/lib/lib/src/request/index.js +26 -0
  136. package/lib/lib/src/request/token.d.ts +2 -0
  137. package/lib/lib/src/request/token.js +34 -0
  138. package/lib/lib/src/request/validation.d.ts +10 -0
  139. package/lib/lib/src/request/validation.js +28 -0
  140. package/lib/lib/src/schemas.d.ts +1340 -0
  141. package/lib/lib/src/schemas.js +325 -0
  142. package/lib/lib/src/types.d.ts +1 -0
  143. package/lib/lib/src/types.js +2 -0
  144. package/lib/lib/src/userSdk/chat.d.ts +9 -0
  145. package/lib/lib/src/userSdk/chat.js +98 -0
  146. package/lib/lib/src/userSdk/index.d.ts +241 -0
  147. package/lib/lib/src/userSdk/index.js +27 -0
  148. package/lib/lib/src/userSdk/patients.d.ts +13 -0
  149. package/lib/lib/src/userSdk/patients.js +55 -0
  150. package/lib/lib/src/userSdk/schedule.d.ts +15 -0
  151. package/lib/lib/src/userSdk/schedule.js +76 -0
  152. package/lib/lib/src/userSdk/specialties.d.ts +4 -0
  153. package/lib/lib/src/userSdk/specialties.js +19 -0
  154. package/lib/lib/src/userSdk/videoVisit.d.ts +72 -0
  155. package/lib/lib/src/userSdk/videoVisit.js +147 -0
  156. package/lib/lib/src/utils.d.ts +4 -0
  157. package/lib/lib/src/utils.js +19 -0
  158. package/lib/lib/src/webhook/index.d.ts +8 -0
  159. package/lib/lib/src/webhook/index.js +55 -0
  160. package/lib/lib/src/webhook/responses.d.ts +36 -0
  161. package/lib/lib/src/webhook/responses.js +42 -0
  162. package/lib/lib/src/webhook/token.d.ts +2 -0
  163. package/lib/lib/src/webhook/token.js +23 -0
  164. package/lib/lib/userSdk/index.d.ts +25 -5
  165. package/lib/lib/userSdk/patients.d.ts +10 -1
  166. package/lib/lib/userSdk/patients.js +34 -6
  167. package/lib/lib/userSdk/videoVisit.d.ts +1 -1
  168. package/lib/lib/utils.d.ts +1 -1
  169. package/lib/lib/utils.js +3 -3
  170. package/lib/src/baseSdk/diagnostica.d.ts +6 -6
  171. package/lib/src/baseSdk/user.d.ts +52 -4
  172. package/lib/src/baseSdk/user.js +67 -25
  173. package/lib/src/index.d.ts +45 -16
  174. package/lib/src/schemas.d.ts +226 -30
  175. package/lib/src/schemas.js +33 -2
  176. package/lib/src/types.d.ts +10 -2
  177. package/lib/src/userSdk/chat.d.ts +1 -1
  178. package/lib/src/userSdk/patients.d.ts +23 -2
  179. package/lib/src/userSdk/patients.js +34 -6
  180. package/lib/src/userSdk/videoVisit.d.ts +2 -2
  181. package/lib/src/utils.d.ts +1 -1
  182. package/lib/src/utils.js +3 -3
  183. package/lib/test.js +2 -36
  184. package/package.json +4 -1
  185. package/lib/baseSdk/external.d.ts +0 -28
  186. package/lib/baseSdk/external.js +0 -73
  187. package/lib/lib/baseSdk/external.d.ts +0 -15
  188. package/lib/lib/baseSdk/external.js +0 -73
  189. package/lib/lib/userSdk/sarasas.d.ts +0 -6
  190. package/lib/lib/userSdk/sarasas.js +0 -13
  191. package/lib/userSdk/sarasas.d.ts +0 -6
  192. package/lib/userSdk/sarasas.js +0 -13
@@ -48,9 +48,13 @@ const getBaseSdk = async (url, credentials) => {
48
48
  id: s.id_especialidad,
49
49
  description: s.especialidad,
50
50
  });
51
+ const mapSpecialityER = (s) => ({
52
+ id: s.specialty_id,
53
+ description: s.specialty,
54
+ });
51
55
  const mapped = {
52
56
  specialties: response.data.specialties.map(mapSpeciality),
53
- specialtiesER: response.data.specialties_er.map(mapSpeciality),
57
+ specialtiesER: response.data.specialties_er.map(mapSpecialityER),
54
58
  professionals: response.data.professionals.map((p) => ({
55
59
  id: p.id_profesional,
56
60
  fullName: p.denominacion,
@@ -23,25 +23,72 @@ export function getBaseSdk(url: any, credentials: any): Promise<{
23
23
  specialtiesER: any;
24
24
  professionals: any;
25
25
  }>;
26
- declareUser: (user: {
26
+ declareUser: (params: {
27
+ code?: string | undefined;
28
+ channel?: "1" | "2" | undefined;
29
+ user: {
30
+ firstName: string;
31
+ lastName: string;
32
+ identificationType: "ndi" | "passport" | "credential";
33
+ identificationValue: string;
34
+ countryId: string;
35
+ birthdate: Date;
36
+ gender: "m" | "f";
37
+ phone: string;
38
+ email: string;
39
+ };
40
+ }) => Promise<{
41
+ patientId: number | null;
42
+ userInfo: {
43
+ phone: string;
44
+ email: string;
45
+ };
46
+ askCode: boolean;
47
+ userId: number;
48
+ }>;
49
+ getUserId: (user: {
27
50
  firstName: string;
28
51
  lastName: string;
29
52
  identificationType: "ndi" | "passport" | "credential";
30
53
  identificationValue: string;
54
+ countryId: string;
55
+ birthdate: Date;
31
56
  gender: "m" | "f";
32
57
  phone: string;
33
58
  email: string;
59
+ }) => Promise<number>;
60
+ sendVerificationCode: (params: {
61
+ identificationType: "ndi" | "passport" | "credential";
62
+ identificationValue: string;
63
+ channel: "1" | "2";
64
+ }) => Promise<any>;
65
+ getUserInstance: (user: number | {
66
+ firstName: string;
67
+ lastName: string;
68
+ identificationType: "ndi" | "passport" | "credential";
69
+ identificationValue: string;
34
70
  countryId: string;
35
71
  birthdate: Date;
72
+ gender: "m" | "f";
73
+ phone: string;
74
+ email: string;
36
75
  }) => Promise<any>;
37
- getUserInstance: (...params: any) => Promise<any>;
38
- enroll: (...params: any) => Promise<void>;
76
+ enroll: (params: {
77
+ firstName: string;
78
+ lastName: string;
79
+ birthdate: Date;
80
+ gender: "m" | "f";
81
+ email: string;
82
+ startDate: Date;
83
+ identificationNumber: string;
84
+ plan: string;
85
+ }) => Promise<void>;
39
86
  getConverageInfo: (identificationValue: string) => Promise<{
40
87
  firstName: string | null;
41
88
  lastName: string | null;
89
+ birthdate: Date;
42
90
  gender: "m" | "f";
43
91
  email: string | null;
44
- birthdate: Date;
45
92
  identificationNumber: string;
46
93
  plan: string | null;
47
94
  financerId: number | null;
@@ -71,22 +118,22 @@ export function getBaseSdk(url: any, credentials: any): Promise<{
71
118
  deepLink: string;
72
119
  }[]>;
73
120
  getDiagnosticaDeepLink: (kiosk: string, user: {
74
- language: string;
75
121
  firstName: string;
76
122
  lastName: string;
77
- birthday: Date;
78
123
  identificationType: "dni";
79
124
  identificationValue: string;
80
125
  gender: "m" | "f";
81
126
  phone: string;
82
127
  email: string;
128
+ language: string;
129
+ birthday: Date;
83
130
  }, patient: {
84
131
  firstName: string;
85
132
  lastName: string;
86
- birthday: Date;
87
133
  identificationType: "dni";
88
134
  identificationValue: string;
89
135
  gender: "m" | "f";
136
+ birthday: Date;
90
137
  }) => Promise<{
91
138
  forwardingRequired: true;
92
139
  deepLink: string;
@@ -94,21 +141,21 @@ export function getBaseSdk(url: any, credentials: any): Promise<{
94
141
  forwardingRequired: false;
95
142
  }>;
96
143
  getDiagnosticaAccess: (kiosk: string, user: {
97
- language: string;
98
144
  firstName: string;
99
145
  lastName: string;
100
- birthday: Date;
101
146
  identificationType: "dni";
102
147
  identificationValue: string;
103
148
  gender: "m" | "f";
104
149
  phone: string;
105
150
  email: string;
151
+ language: string;
152
+ birthday: Date;
106
153
  }, patient: {
107
154
  firstName: string;
108
155
  lastName: string;
109
- birthday: Date;
110
156
  identificationType: "dni";
111
157
  identificationValue: string;
112
158
  gender: "m" | "f";
159
+ birthday: Date;
113
160
  }) => Promise<void>;
114
161
  }>;
@@ -1,14 +1,25 @@
1
1
  export var __esModule: boolean;
2
2
  export function getUserMethods(makeRequest: any, url: any, credentials: any): {
3
- declareUser: (user?: any) => Promise<any>;
4
- getUserInstance: (...params: any) => Promise<any>;
5
- enroll: (...params: any) => Promise<void>;
6
- getConverageInfo: (...params: any) => Promise<{
3
+ declareUser: (params_0?: {
4
+ user: any;
5
+ channel: any;
6
+ code: any;
7
+ }) => Promise<{
8
+ userId: any;
9
+ patientId: any;
10
+ userInfo: any;
11
+ askCode: any;
12
+ }>;
13
+ getUserId: (user?: any) => Promise<any>;
14
+ sendVerificationCode: (params?: any) => Promise<void>;
15
+ getUserInstance: (user?: any) => Promise<any>;
16
+ enroll: (params?: any) => Promise<void>;
17
+ getConverageInfo: (identificationValue?: any) => Promise<{
7
18
  firstName: string | null;
8
19
  lastName: string | null;
20
+ birthdate: Date;
9
21
  gender: "m" | "f";
10
22
  email: string | null;
11
- birthdate: Date;
12
23
  identificationNumber: string;
13
24
  plan: string | null;
14
25
  financerId: number | null;
@@ -8,11 +8,39 @@ const schemas_1 = require("../schemas");
8
8
  const userSdk_1 = require("../userSdk");
9
9
  const utils_1 = require("../utils");
10
10
  const getUserMethods = (makeRequest, url, credentials) => {
11
+ const declareUser = async ({ user, channel, code, }) => {
12
+ const path = '/user';
13
+ const mappedUser = {
14
+ lastname: user.lastName,
15
+ firstname: user.firstName,
16
+ identification_type: utils_1.getIdetificationTypeId(user.identificationType),
17
+ identification_value: user.identificationValue,
18
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
19
+ gender: user.gender.toUpperCase(),
20
+ phone: user.phone,
21
+ email: user.email,
22
+ country_id: user.countryId,
23
+ };
24
+ const parsedChannel = channel ? parseInt(channel) : channel;
25
+ const response = await makeRequest('POST', path, {
26
+ user_data: mappedUser,
27
+ channel: parsedChannel,
28
+ code,
29
+ });
30
+ const mappedResponse = {
31
+ userId: response.data.user_id,
32
+ patientId: response.data.patient_id,
33
+ userInfo: response.data.user_info,
34
+ askCode: response.data.ask_code,
35
+ };
36
+ return mappedResponse;
37
+ };
11
38
  const getUserId = async (user) => {
39
+ const path = '/user';
12
40
  const mappedUser = {
13
41
  lastname: user.lastName,
14
42
  firstname: user.firstName,
15
- identification_type: utils_1.getIndetificationTypeId(user.identificationType),
43
+ identification_type: utils_1.getIdetificationTypeId(user.identificationType),
16
44
  identification_value: user.identificationValue,
17
45
  birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
18
46
  gender: user.gender.toUpperCase(),
@@ -20,12 +48,41 @@ const getUserMethods = (makeRequest, url, credentials) => {
20
48
  email: user.email,
21
49
  country_id: user.countryId,
22
50
  };
23
- const response = await makeRequest('POST', '/user', {
51
+ const response = await makeRequest('POST', path, {
24
52
  user_data: mappedUser,
25
53
  });
26
54
  return response.data.user_id;
27
55
  };
28
- const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
56
+ const sendVerificationCode = async (params) => {
57
+ const path = '/send-verification-code';
58
+ const mappedParams = {
59
+ identification_type: utils_1.getIdetificationTypeId(params.identificationType),
60
+ identification_value: params.identificationValue,
61
+ channel: parseInt(params.channel),
62
+ };
63
+ await makeRequest('POST', path, mappedParams);
64
+ };
65
+ const getUserInstance = async (user) => {
66
+ const userId = typeof user === 'number' ? user : await getUserId(user);
67
+ return userSdk_1.userSdk(url, credentials, userId);
68
+ };
69
+ const enroll = async (params) => {
70
+ const path = `/enrollment`;
71
+ const mappedUser = {
72
+ firstname: params.firstName,
73
+ lastname: params.lastName,
74
+ gender: params.gender.toUpperCase(),
75
+ identification_number: params.identificationNumber,
76
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
77
+ email: params.email,
78
+ plan: params.plan,
79
+ start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
80
+ };
81
+ await makeRequest('POST', path, {
82
+ user_data: mappedUser,
83
+ });
84
+ };
85
+ const getConverageInfo = async (identificationValue) => {
29
86
  const path = `/info-coverage/${identificationValue}`;
30
87
  const response = await makeRequest('GET', path);
31
88
  const raw = response.data.info;
@@ -58,31 +115,16 @@ const getUserMethods = (makeRequest, url, credentials) => {
58
115
  : null,
59
116
  };
60
117
  return mappedCoverageInfo;
61
- });
118
+ };
62
119
  return {
63
- declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
120
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
121
+ getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
122
+ sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
64
123
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
65
124
  // TODO: validate?
66
- zod_1.any(), async (user) => {
67
- const userId = typeof user === 'number' ? user : await getUserId(user);
68
- return userSdk_1.userSdk(url, credentials, userId);
69
- }),
70
- enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), async (params) => {
71
- const path = `/enrollment`;
72
- await makeRequest('POST', path, {
73
- user_data: {
74
- firstname: params.firstName,
75
- lastname: params.lastName,
76
- gender: params.gender.toUpperCase(),
77
- identification_number: params.identificationNumber,
78
- birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
79
- email: params.email,
80
- plan: params.plan,
81
- start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
82
- },
83
- });
84
- }),
85
- getConverageInfo,
125
+ zod_1.any(), getUserInstance),
126
+ 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),
86
128
  };
87
129
  };
88
130
  exports.getUserMethods = getUserMethods;
@@ -1,37 +1,60 @@
1
1
  export var __esModule: boolean;
2
2
  export function doc24Sdk(params: any): Promise<{
3
3
  getRequestHandler: (params: any) => Promise<import("./types").Doc24.Webhook.Handler>;
4
- declareUser: (user: {
4
+ declareUser: (params: {
5
+ code?: string | undefined;
6
+ channel?: "1" | "2" | undefined;
7
+ user: {
8
+ firstName: string;
9
+ lastName: string;
10
+ identificationType: "ndi" | "passport" | "credential";
11
+ identificationValue: string;
12
+ countryId: string;
13
+ birthdate: Date;
14
+ gender: "m" | "f";
15
+ phone: string;
16
+ email: string;
17
+ };
18
+ }) => Promise<{
19
+ patientId: number | null;
20
+ userInfo: {
21
+ phone: string;
22
+ email: string;
23
+ };
24
+ askCode: boolean;
25
+ userId: number;
26
+ }>;
27
+ getUserId: (user: {
5
28
  firstName: string;
6
29
  lastName: string;
7
30
  identificationType: "ndi" | "passport" | "credential";
8
31
  identificationValue: string;
32
+ countryId: string;
33
+ birthdate: Date;
9
34
  gender: "m" | "f";
10
35
  phone: string;
11
36
  email: string;
12
- countryId: string;
13
- birthdate: Date;
14
37
  }) => Promise<number>;
15
38
  getUserInstance: (user: number | {
16
39
  firstName: string;
17
40
  lastName: string;
18
41
  identificationType: "ndi" | "passport" | "credential";
19
42
  identificationValue: string;
43
+ countryId: string;
44
+ birthdate: Date;
20
45
  gender: "m" | "f";
21
46
  phone: string;
22
47
  email: string;
23
- countryId: string;
24
- birthdate: Date;
25
48
  }) => Promise<import("./types").Doc24.UserSdk>;
26
49
  getProfessional: (professionalId: number) => Promise<{
27
- id: number;
28
- logoUrl: string;
29
50
  firstName: string;
30
51
  lastName: string;
52
+ birthdate: Date;
31
53
  gender: "m" | "f";
32
54
  phone: string | null;
33
55
  email: string;
34
- birthdate: Date;
56
+ id: number;
57
+ logoUrl: string;
35
58
  specialties: {
36
59
  id: number;
37
60
  description: string;
@@ -69,9 +92,9 @@ export function doc24Sdk(params: any): Promise<{
69
92
  enroll: (params: {
70
93
  firstName: string;
71
94
  lastName: string;
95
+ birthdate: Date;
72
96
  gender: "m" | "f";
73
97
  email: string;
74
- birthdate: Date;
75
98
  startDate: Date;
76
99
  identificationNumber: string;
77
100
  plan: string;
@@ -79,9 +102,9 @@ export function doc24Sdk(params: any): Promise<{
79
102
  getConverageInfo: (identificationValue: string) => Promise<{
80
103
  firstName: string | null;
81
104
  lastName: string | null;
105
+ birthdate: Date;
82
106
  gender: "m" | "f";
83
107
  email: string | null;
84
- birthdate: Date;
85
108
  identificationNumber: string;
86
109
  plan: string | null;
87
110
  financerId: number | null;
@@ -100,6 +123,11 @@ export function doc24Sdk(params: any): Promise<{
100
123
  authorizationCode: string | null;
101
124
  authorizationCodeExpiration: Date | null;
102
125
  } | null>;
126
+ sendVerificationCode: (params: {
127
+ identificationType: "ndi" | "passport" | "credential";
128
+ identificationValue: string;
129
+ channel: "1" | "2";
130
+ }) => Promise<any>;
103
131
  getDiagnosticaHistory: (patient: {
104
132
  identificationType: "ndi" | "passport" | "credential";
105
133
  identificationValue: string;
@@ -111,22 +139,22 @@ export function doc24Sdk(params: any): Promise<{
111
139
  deepLink: string;
112
140
  }[]>;
113
141
  getDiagnosticaDeepLink: (kiosk: string, user: {
114
- language: string;
115
142
  firstName: string;
116
143
  lastName: string;
117
- birthday: Date;
118
144
  identificationType: "dni";
119
145
  identificationValue: string;
120
146
  gender: "m" | "f";
121
147
  phone: string;
122
148
  email: string;
149
+ language: string;
150
+ birthday: Date;
123
151
  }, patient: {
124
152
  firstName: string;
125
153
  lastName: string;
126
- birthday: Date;
127
154
  identificationType: "dni";
128
155
  identificationValue: string;
129
156
  gender: "m" | "f";
157
+ birthday: Date;
130
158
  }) => Promise<{
131
159
  forwardingRequired: true;
132
160
  deepLink: string;
@@ -134,21 +162,21 @@ export function doc24Sdk(params: any): Promise<{
134
162
  forwardingRequired: false;
135
163
  }>;
136
164
  getDiagnosticaAccess: (kiosk: string, user: {
137
- language: string;
138
165
  firstName: string;
139
166
  lastName: string;
140
- birthday: Date;
141
167
  identificationType: "dni";
142
168
  identificationValue: string;
143
169
  gender: "m" | "f";
144
170
  phone: string;
145
171
  email: string;
172
+ language: string;
173
+ birthday: Date;
146
174
  }, patient: {
147
175
  firstName: string;
148
176
  lastName: string;
149
- birthday: Date;
150
177
  identificationType: "dni";
151
178
  identificationValue: string;
152
179
  gender: "m" | "f";
180
+ birthday: Date;
153
181
  }) => Promise<void>;
154
182
  }>;
@@ -0,0 +1,6 @@
1
+ export var __esModule: boolean;
2
+ export function getDiagnosticaMethods(makeRequest: any): {
3
+ getDiagnosticaHistory: (...params: any[]) => Promise<any>;
4
+ getDiagnosticaDeepLink: (...params: any[]) => Promise<any>;
5
+ getDiagnosticaAccess: (...params: any[]) => Promise<any>;
6
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDiagnosticaMethods = 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 getDiagnosticaMethods = (makeRequest) => {
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) => {
10
+ const path = '/history-diagnostica';
11
+ const response = await makeRequest('POST', path, {
12
+ patient: {
13
+ gender: patient.gender,
14
+ id_type: patient.identificationType === 'ndi'
15
+ ? 'DNI'
16
+ : patient.identificationType,
17
+ id_value: patient.identificationValue,
18
+ },
19
+ dateFrom: from.toISOString(),
20
+ dateTo: to.toISOString(),
21
+ });
22
+ const list = response.data.info;
23
+ return list.map((i) => ({
24
+ date: new Date(Date.parse(i.date)),
25
+ location: i.location,
26
+ exams: i.exams,
27
+ deepLink: i.deeplink,
28
+ }));
29
+ });
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.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 };
60
+ };
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
+ };
@@ -0,0 +1,51 @@
1
+ export var __esModule: boolean;
2
+ export function getBaseSdk(url: any, credentials: any): Promise<{
3
+ getProfessional: (...params: any[]) => Promise<any>;
4
+ getAvailableScheduleClinics: (...params: any[]) => Promise<any>;
5
+ declareUser: (params_0?: {
6
+ user: any;
7
+ channel: any;
8
+ code: any;
9
+ } | undefined) => Promise<{
10
+ userId: any;
11
+ patientId: any;
12
+ userInfo: any;
13
+ askCode: any;
14
+ }>;
15
+ getUserId: (user?: any) => Promise<any>;
16
+ sendVerificationCode: (params?: any) => Promise<void>;
17
+ getUserInstance: (user?: any) => Promise<any>;
18
+ enroll: (params?: any) => Promise<void>;
19
+ getConverageInfo: (identificationValue?: any) => Promise<{
20
+ firstName: string | null;
21
+ lastName: string | null;
22
+ birthdate: Date;
23
+ gender: "m" | "f";
24
+ email: string | null;
25
+ identificationNumber: string;
26
+ plan: string | null;
27
+ financerId: number | null;
28
+ defaultAffiliationId: number | null;
29
+ credentialNumber: string | null;
30
+ financerPlanId: number | null;
31
+ brand: number | null;
32
+ holderIdentificationNumber: string | null;
33
+ copaymentValue: number | null;
34
+ mobilePhone: string | null;
35
+ company: string | null;
36
+ dischargeDate: Date | null;
37
+ leavingDate: Date | null;
38
+ identificacion_tributaria: string | null;
39
+ deregistrationDate: Date | null;
40
+ authorizationCode: string | null;
41
+ authorizationCodeExpiration: Date | null;
42
+ } | null>;
43
+ getDiagnosticaHistory: (...params: any) => Promise<any>;
44
+ getDiagnosticaDeepLink: (...params: any) => Promise<{
45
+ forwardingRequired: true;
46
+ deepLink: string;
47
+ } | {
48
+ forwardingRequired: false;
49
+ }>;
50
+ getDiagnosticaAccess: (...params: any) => Promise<void>;
51
+ }>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBaseSdk = void 0;
4
+ const zod_1 = require("zod");
5
+ const request_1 = require("../request");
6
+ const validation_1 = require("../request/validation");
7
+ const schemas_1 = require("../schemas");
8
+ const utils_1 = require("../utils");
9
+ const diagnostica_1 = require("./diagnostica");
10
+ const user_1 = require("./user");
11
+ const getBaseSdk = async (url, credentials) => {
12
+ const makeRequest = await request_1.getRequestFactory(url, credentials);
13
+ const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
14
+ const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
15
+ const baseSdk = {
16
+ ...diagnosticaMethods,
17
+ ...userMethods,
18
+ getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
19
+ const path = `/professional/${professionalId}`;
20
+ const response = await makeRequest('GET', path);
21
+ const raw = response.data;
22
+ return {
23
+ id: raw.professional_id,
24
+ firstName: raw.name,
25
+ lastName: raw.lastname,
26
+ birthdate: utils_1.parseDate(raw.birthdate),
27
+ gender: raw.gender.toLowerCase(),
28
+ email: raw.email,
29
+ phone: raw.phone,
30
+ logoUrl: raw.image,
31
+ matriculation: raw.matriculation,
32
+ specialties: raw.specialties.map((s) => ({
33
+ id: s.specialty_id,
34
+ description: s.specialty,
35
+ })),
36
+ degree: raw.degree,
37
+ languages: raw.languages.map((l) => l.languages),
38
+ resume: {
39
+ link: raw.resume_link,
40
+ brief: raw.resume_brief,
41
+ },
42
+ };
43
+ }),
44
+ getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
45
+ const path = `/schedule/clinics`;
46
+ const response = await makeRequest('GET', path);
47
+ const mapSpeciality = (s) => ({
48
+ id: s.id_especialidad,
49
+ description: s.especialidad,
50
+ });
51
+ const mapped = {
52
+ specialties: response.data.specialties.map(mapSpeciality),
53
+ specialtiesER: response.data.specialties_er.map(mapSpeciality),
54
+ professionals: response.data.professionals.map((p) => ({
55
+ id: p.id_profesional,
56
+ fullName: p.denominacion,
57
+ clinicId: p.id_consultorio,
58
+ specialties: p.especialidades.map(mapSpeciality),
59
+ })),
60
+ };
61
+ return mapped;
62
+ }),
63
+ };
64
+ return baseSdk;
65
+ };
66
+ exports.getBaseSdk = getBaseSdk;
@@ -0,0 +1,9 @@
1
+ export var __esModule: boolean;
2
+ export function getUserMethods(makeRequest: any, url: any, credentials: any): {
3
+ declareUser: (...params: any[]) => Promise<any>;
4
+ getUserId: (...params: any[]) => Promise<any>;
5
+ sendVerificationCode: (...params: any[]) => Promise<any>;
6
+ getUserInstance: (...params: any[]) => Promise<any>;
7
+ enroll: (...params: any[]) => Promise<any>;
8
+ getConverageInfo: (...params: any[]) => Promise<any>;
9
+ };