@integraciones_doc24/sdk 0.26.2 → 0.28.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/README.md CHANGED
@@ -68,6 +68,7 @@ type SdkParams = {
68
68
  type BaseSdk = {
69
69
  getUserInstance: (user: User) => Promise<UserSdk>;
70
70
  getProfessional: (professionalId: number) => Promise<Professional>;
71
+ getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>
71
72
  }
72
73
 
73
74
  type RequestHandlerParams = {
package/lib/baseSdk.js CHANGED
@@ -61,6 +61,24 @@ const getBaseSdk = async (url, credentials) => {
61
61
  },
62
62
  };
63
63
  }),
64
+ getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
65
+ const path = `/schedule/clinics`;
66
+ const response = await makeRequest('GET', path);
67
+ const mapSpeciality = (s) => ({
68
+ id: s.id_especialidad,
69
+ description: s.especialidad,
70
+ });
71
+ const mapped = {
72
+ specialties: response.data.specialties.map(mapSpeciality),
73
+ professionals: response.data.professionals.map((p) => ({
74
+ id: p.id_profesional,
75
+ fullName: p.denominacion,
76
+ clinicId: p.id_consultorio,
77
+ specialties: p.especialidades.map(mapSpeciality),
78
+ })),
79
+ };
80
+ return mapped;
81
+ }),
64
82
  };
65
83
  return baseSdk;
66
84
  };
package/lib/index.d.ts CHANGED
@@ -36,14 +36,14 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
36
36
  gender: "m" | "f";
37
37
  phone: string;
38
38
  email: string;
39
- matriculation: {
40
- number: string;
41
- type: string;
42
- }[];
43
39
  specialties: {
44
40
  id: number;
45
41
  description: string;
46
42
  }[];
43
+ matriculation: {
44
+ number: string;
45
+ type: string;
46
+ }[];
47
47
  degree: string;
48
48
  languages: string[];
49
49
  resume: {
@@ -51,5 +51,20 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
51
51
  brief: string;
52
52
  };
53
53
  }>;
54
+ getAvailableScheduleClinics: () => Promise<{
55
+ specialties: {
56
+ id: number;
57
+ description: string;
58
+ }[];
59
+ professionals: {
60
+ id: number;
61
+ fullName: string;
62
+ clinicId: number;
63
+ specialties: {
64
+ id: number;
65
+ description: string;
66
+ }[];
67
+ }[];
68
+ }>;
54
69
  }>;
55
70
  export type { Doc24 } from './types';
package/lib/schemas.d.ts CHANGED
@@ -144,9 +144,11 @@ export declare const doc24Schemas: {
144
144
  type: import("zod").ZodEnum<["appointment", "chat", "instant"]>;
145
145
  atentions: import("zod").ZodNumber;
146
146
  ranking: import("zod").ZodUnknown;
147
+ length: import("zod").ZodNullable<import("zod").ZodNumber>;
147
148
  }, "strip", import("zod").ZodTypeAny, {
148
149
  ranking?: unknown;
149
150
  date: Date;
151
+ length: number | null;
150
152
  type: "appointment" | "chat" | "instant";
151
153
  id: string | number;
152
154
  professional: {
@@ -164,6 +166,7 @@ export declare const doc24Schemas: {
164
166
  }, {
165
167
  ranking?: unknown;
166
168
  date: Date;
169
+ length: number | null;
167
170
  type: "appointment" | "chat" | "instant";
168
171
  id: string | number;
169
172
  professional: {
@@ -179,6 +182,77 @@ export declare const doc24Schemas: {
179
182
  };
180
183
  atentions: number;
181
184
  }>;
185
+ availableScheduleClinics: import("zod").ZodObject<{
186
+ specialties: import("zod").ZodArray<import("zod").ZodObject<{
187
+ id: import("zod").ZodNumber;
188
+ description: import("zod").ZodString;
189
+ }, "strip", import("zod").ZodTypeAny, {
190
+ id: number;
191
+ description: string;
192
+ }, {
193
+ id: number;
194
+ description: string;
195
+ }>, "many">;
196
+ professionals: import("zod").ZodArray<import("zod").ZodObject<{
197
+ id: import("zod").ZodNumber;
198
+ fullName: import("zod").ZodString;
199
+ clinicId: import("zod").ZodNumber;
200
+ specialties: import("zod").ZodArray<import("zod").ZodObject<{
201
+ id: import("zod").ZodNumber;
202
+ description: import("zod").ZodString;
203
+ }, "strip", import("zod").ZodTypeAny, {
204
+ id: number;
205
+ description: string;
206
+ }, {
207
+ id: number;
208
+ description: string;
209
+ }>, "many">;
210
+ }, "strip", import("zod").ZodTypeAny, {
211
+ id: number;
212
+ fullName: string;
213
+ clinicId: number;
214
+ specialties: {
215
+ id: number;
216
+ description: string;
217
+ }[];
218
+ }, {
219
+ id: number;
220
+ fullName: string;
221
+ clinicId: number;
222
+ specialties: {
223
+ id: number;
224
+ description: string;
225
+ }[];
226
+ }>, "many">;
227
+ }, "strip", import("zod").ZodTypeAny, {
228
+ specialties: {
229
+ id: number;
230
+ description: string;
231
+ }[];
232
+ professionals: {
233
+ id: number;
234
+ fullName: string;
235
+ clinicId: number;
236
+ specialties: {
237
+ id: number;
238
+ description: string;
239
+ }[];
240
+ }[];
241
+ }, {
242
+ specialties: {
243
+ id: number;
244
+ description: string;
245
+ }[];
246
+ professionals: {
247
+ id: number;
248
+ fullName: string;
249
+ clinicId: number;
250
+ specialties: {
251
+ id: number;
252
+ description: string;
253
+ }[];
254
+ }[];
255
+ }>;
182
256
  scheduleFilter: import("zod").ZodObject<{
183
257
  professionalId: import("zod").ZodOptional<import("zod").ZodNumber>;
184
258
  offset: import("zod").ZodOptional<import("zod").ZodNumber>;
@@ -587,14 +661,14 @@ export declare const doc24Schemas: {
587
661
  gender: "m" | "f";
588
662
  phone: string;
589
663
  email: string;
590
- matriculation: {
591
- number: string;
592
- type: string;
593
- }[];
594
664
  specialties: {
595
665
  id: number;
596
666
  description: string;
597
667
  }[];
668
+ matriculation: {
669
+ number: string;
670
+ type: string;
671
+ }[];
598
672
  degree: string;
599
673
  languages: string[];
600
674
  resume: {
@@ -610,14 +684,14 @@ export declare const doc24Schemas: {
610
684
  gender: "m" | "f";
611
685
  phone: string;
612
686
  email: string;
613
- matriculation: {
614
- number: string;
615
- type: string;
616
- }[];
617
687
  specialties: {
618
688
  id: number;
619
689
  description: string;
620
690
  }[];
691
+ matriculation: {
692
+ number: string;
693
+ type: string;
694
+ }[];
621
695
  degree: string;
622
696
  languages: string[];
623
697
  resume: {
package/lib/schemas.js CHANGED
@@ -37,24 +37,34 @@ const availableAppointment = zod_1.object({
37
37
  type: specialtyMode,
38
38
  atentions: zod_1.number(),
39
39
  ranking: zod_1.unknown(),
40
+ length: zod_1.number().nullable(),
40
41
  });
41
42
  const appointment = zod_1.object({
42
43
  id: zod_1.number(),
43
44
  professionalId: zod_1.number(),
44
45
  date: zod_1.date(),
45
46
  });
46
- const baseScheduleParamters = zod_1.object({
47
+ const availableScheduleClinics = zod_1.object({
48
+ specialties: specialty.array(),
49
+ professionals: zod_1.object({
50
+ id: zod_1.number(),
51
+ fullName: zod_1.string(),
52
+ clinicId: zod_1.number(),
53
+ specialties: specialty.array(),
54
+ }).array(),
55
+ });
56
+ const baseScheduleParameters = zod_1.object({
47
57
  patientId: zod_1.number(),
48
58
  specialtyId: zod_1.number(),
49
59
  language: zod_1.string(),
50
60
  details: zod_1.string(),
51
61
  extraInfo: zod_1.any(),
52
62
  });
53
- const appointmentScheduleParameters = baseScheduleParamters.extend({
63
+ const appointmentScheduleParameters = baseScheduleParameters.extend({
54
64
  type: zod_1.literal('appointment'),
55
65
  appointmentId: zod_1.number().or(zod_1.string()),
56
66
  });
57
- const instantScheduleParameters = baseScheduleParamters.extend({
67
+ const instantScheduleParameters = baseScheduleParameters.extend({
58
68
  type: zod_1.literal('instant'),
59
69
  });
60
70
  const chatroomAvailabilityFilter = zod_1.object({
@@ -114,6 +124,7 @@ exports.doc24Schemas = {
114
124
  specialty,
115
125
  scheduleAvailabilityFilter,
116
126
  availableAppointment,
127
+ availableScheduleClinics,
117
128
  scheduleFilter: zod_1.object({
118
129
  professionalId: zod_1.number().optional(),
119
130
  offset: zod_1.number().optional(),
package/lib/types.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare namespace Doc24 {
9
9
  type Specialty = TypeOf<typeof doc24Schemas.specialty>;
10
10
  type ScheduleAvailabilityFilter = TypeOf<typeof doc24Schemas.scheduleAvailabilityFilter>;
11
11
  type AvailableAppointment = TypeOf<typeof doc24Schemas.availableAppointment>;
12
+ type AvailableScheduleClinics = TypeOf<typeof doc24Schemas.availableScheduleClinics>;
12
13
  type ScheduleFilter = TypeOf<typeof doc24Schemas.scheduleFilter>;
13
14
  type ScheduleParameters = TypeOf<typeof doc24Schemas.scheduleParameters>;
14
15
  type VideoVisit = TypeOf<typeof doc24Schemas.videoVisit>;
@@ -26,6 +27,7 @@ export declare namespace Doc24 {
26
27
  declareUser: (user: User) => Promise<number>;
27
28
  getUserInstance: (user: User | number) => Promise<UserSdk>;
28
29
  getProfessional: (professionalId: number) => Promise<Professional>;
30
+ getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
29
31
  };
30
32
  type UserSdk = {
31
33
  declarePatient: (patient: Patient) => Promise<number>;
@@ -11,6 +11,7 @@ export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
11
11
  } | undefined) => Promise<{
12
12
  ranking?: unknown;
13
13
  date: Date;
14
+ length: number | null;
14
15
  type: "appointment" | "chat" | "instant";
15
16
  id: string | number;
16
17
  professional: {
@@ -18,7 +18,7 @@ const getScheduleMethods = (makeRequest) => {
18
18
  });
19
19
  const getSchedule = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.scheduleFilter.optional()]), zod_1.array(schemas_1.doc24Schemas.availableAppointment), async (patientId, specialtyId, filter = {}) => {
20
20
  const mappedFilter = {
21
- professional_id: filter.professionalId,
21
+ id_professional: filter.professionalId,
22
22
  offset: filter.offset,
23
23
  limit: filter.limit,
24
24
  week_day: filter.weekDay,
@@ -45,6 +45,7 @@ const getScheduleMethods = (makeRequest) => {
45
45
  type: a.type === 'P' ? 'appointment' : a.type === 'T' ? 'chat' : 'instant',
46
46
  atentions: a.atentions,
47
47
  ranking: a.ranking,
48
+ length: a.length,
48
49
  }));
49
50
  });
50
51
  const getAppointment = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, async (appointmentId) => {
@@ -9,14 +9,14 @@ const getRequestHandler = (credentials, baseSdk, eventHandlers) => async (reques
9
9
  if (!tokenPayload)
10
10
  return responses_1.unauthorizedErrorResponse();
11
11
  const body = request.body;
12
- const error = handleEvent(body, baseSdk, eventHandlers);
12
+ const error = await handleEvent(body, baseSdk, eventHandlers);
13
13
  if (error)
14
14
  return responses_1.unexpectedErrorResponse(error);
15
15
  return responses_1.successResponse();
16
16
  return responses_1.notFoundErrorResponse();
17
17
  };
18
18
  exports.getRequestHandler = getRequestHandler;
19
- const handleEvent = (body, _baseSdk, eventHandlers) => {
19
+ const handleEvent = async (body, _baseSdk, eventHandlers) => {
20
20
  var _a, _b, _c, _d;
21
21
  const date = utils_1.parseDateTime(body.fecha_estado);
22
22
  if (body.tipo === 'consulta')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.26.2",
3
+ "version": "0.28.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {