@integraciones_doc24/sdk 1.16.40 → 1.16.42

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 (50) hide show
  1. package/README.md +21 -0
  2. package/lib/baseSdk/diagnostica.d.ts +54 -54
  3. package/lib/baseSdk/diagnostica.js +82 -82
  4. package/lib/baseSdk/external.d.ts +177 -177
  5. package/lib/baseSdk/external.js +96 -96
  6. package/lib/baseSdk/index.d.ts +2 -2
  7. package/lib/baseSdk/index.js +80 -80
  8. package/lib/baseSdk/integrationError.d.ts +16 -16
  9. package/lib/baseSdk/integrationError.js +33 -33
  10. package/lib/baseSdk/user.d.ts +115 -115
  11. package/lib/baseSdk/user.js +136 -136
  12. package/lib/index.d.ts +417 -416
  13. package/lib/index.js +24 -22
  14. package/lib/request/index.d.ts +4 -4
  15. package/lib/request/index.js +32 -32
  16. package/lib/request/token.d.ts +2 -2
  17. package/lib/request/token.js +34 -34
  18. package/lib/request/validation.d.ts +10 -10
  19. package/lib/request/validation.js +28 -28
  20. package/lib/schemas.d.ts +2930 -2813
  21. package/lib/schemas.js +640 -601
  22. package/lib/types.d.ts +183 -178
  23. package/lib/types.js +2 -2
  24. package/lib/userSdk/binah.d.ts +21 -21
  25. package/lib/userSdk/binah.js +20 -20
  26. package/lib/userSdk/chat.d.ts +57 -57
  27. package/lib/userSdk/chat.js +98 -98
  28. package/lib/userSdk/eligibility.d.ts +29 -0
  29. package/lib/userSdk/eligibility.js +81 -0
  30. package/lib/userSdk/external.d.ts +34 -34
  31. package/lib/userSdk/external.js +72 -72
  32. package/lib/userSdk/index.d.ts +2 -2
  33. package/lib/userSdk/index.js +36 -33
  34. package/lib/userSdk/patients.d.ts +62 -62
  35. package/lib/userSdk/patients.js +93 -93
  36. package/lib/userSdk/schedule.d.ts +59 -59
  37. package/lib/userSdk/schedule.js +90 -90
  38. package/lib/userSdk/specialties.d.ts +19 -19
  39. package/lib/userSdk/specialties.js +48 -48
  40. package/lib/userSdk/videoVisit.d.ts +229 -225
  41. package/lib/userSdk/videoVisit.js +288 -283
  42. package/lib/utils.d.ts +4 -4
  43. package/lib/utils.js +68 -68
  44. package/lib/webhook/index.d.ts +2 -2
  45. package/lib/webhook/index.js +67 -67
  46. package/lib/webhook/responses.d.ts +35 -35
  47. package/lib/webhook/responses.js +42 -42
  48. package/lib/webhook/token.d.ts +2 -2
  49. package/lib/webhook/token.js +23 -23
  50. package/package.json +37 -37
@@ -1,62 +1,62 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getPatientMethods: (makeRequest: RequestMaker) => {
3
- declarePatient: (params: {
4
- patient: {
5
- identificationType?: number | undefined;
6
- identificationValue?: string | undefined;
7
- gender?: "m" | "f" | "o" | undefined;
8
- emergencyContact?: string | null | undefined;
9
- emergencyContactPhone?: string | number | null | undefined;
10
- credential?: string | null | undefined;
11
- plan?: string | null | undefined;
12
- affiliationStatus?: string | null | undefined;
13
- localidad?: string | null | undefined;
14
- codPostal?: string | null | undefined;
15
- provincia?: string | null | undefined;
16
- firstName: string;
17
- lastName: string;
18
- countryId: string;
19
- birthdate: Date;
20
- };
21
- } & {
22
- code?: string | undefined;
23
- channel?: "1" | "2" | undefined;
24
- }) => Promise<{
25
- askCode: true;
26
- userInfo: {
27
- firstName: string;
28
- lastName: string;
29
- email: string;
30
- phone: string;
31
- };
32
- } | {
33
- patientId: number | null;
34
- askCode: false;
35
- }>;
36
- getPatientId: (patient: {
37
- identificationType?: number | undefined;
38
- identificationValue?: string | undefined;
39
- gender?: "m" | "f" | "o" | undefined;
40
- emergencyContact?: string | null | undefined;
41
- emergencyContactPhone?: string | number | null | undefined;
42
- credential?: string | null | undefined;
43
- plan?: string | null | undefined;
44
- affiliationStatus?: string | null | undefined;
45
- localidad?: string | null | undefined;
46
- codPostal?: string | null | undefined;
47
- provincia?: string | null | undefined;
48
- idPatient?: number | undefined;
49
- email?: string | undefined;
50
- firstName: string;
51
- lastName: string;
52
- countryId: string;
53
- birthdate: Date;
54
- }) => Promise<number>;
55
- deletePatient: (patientId: number) => Promise<void>;
56
- getPatientPHR: (patientId: number) => Promise<string>;
57
- submitHealthQuiz: (params: {
58
- patientId: number;
59
- quiz: Record<string, any>;
60
- origen: string;
61
- }) => Promise<void>;
62
- };
1
+ import { RequestMaker } from '../request';
2
+ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
3
+ declarePatient: (params: {
4
+ patient: {
5
+ identificationType?: number | undefined;
6
+ identificationValue?: string | undefined;
7
+ gender?: "m" | "f" | "o" | undefined;
8
+ emergencyContact?: string | null | undefined;
9
+ emergencyContactPhone?: string | number | null | undefined;
10
+ credential?: string | null | undefined;
11
+ plan?: string | null | undefined;
12
+ affiliationStatus?: string | null | undefined;
13
+ localidad?: string | null | undefined;
14
+ codPostal?: string | null | undefined;
15
+ provincia?: string | null | undefined;
16
+ firstName: string;
17
+ lastName: string;
18
+ countryId: string;
19
+ birthdate: Date;
20
+ };
21
+ } & {
22
+ code?: string | undefined;
23
+ channel?: "1" | "2" | undefined;
24
+ }) => Promise<{
25
+ askCode: true;
26
+ userInfo: {
27
+ firstName: string;
28
+ lastName: string;
29
+ email: string;
30
+ phone: string;
31
+ };
32
+ } | {
33
+ patientId: number | null;
34
+ askCode: false;
35
+ }>;
36
+ getPatientId: (patient: {
37
+ identificationType?: number | undefined;
38
+ identificationValue?: string | undefined;
39
+ gender?: "m" | "f" | "o" | undefined;
40
+ emergencyContact?: string | null | undefined;
41
+ emergencyContactPhone?: string | number | null | undefined;
42
+ credential?: string | null | undefined;
43
+ plan?: string | null | undefined;
44
+ affiliationStatus?: string | null | undefined;
45
+ localidad?: string | null | undefined;
46
+ codPostal?: string | null | undefined;
47
+ provincia?: string | null | undefined;
48
+ idPatient?: number | undefined;
49
+ email?: string | undefined;
50
+ firstName: string;
51
+ lastName: string;
52
+ countryId: string;
53
+ birthdate: Date;
54
+ }) => Promise<number>;
55
+ deletePatient: (patientId: number) => Promise<void>;
56
+ getPatientPHR: (patientId: number) => Promise<string>;
57
+ submitHealthQuiz: (params: {
58
+ patientId: number;
59
+ quiz: Record<string, any>;
60
+ origen: string;
61
+ }) => Promise<void>;
62
+ };
@@ -1,93 +1,93 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPatientMethods = 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 getPatientMethods = (makeRequest) => {
9
- const declarePatient = async ({ patient, channel, code, }) => {
10
- var _a;
11
- const path = '/patient';
12
- const mappedPatient = {
13
- lastname: patient.lastName,
14
- firstname: patient.firstName,
15
- identification_type: patient.identificationType,
16
- identification_value: patient.identificationValue,
17
- birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
18
- gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
19
- country_id: patient.countryId,
20
- emergency_contact: patient.emergencyContact,
21
- emergency_contact_phone: patient.emergencyContactPhone,
22
- credential: patient.credential,
23
- plan: patient.plan,
24
- affiliation_status: patient.affiliationStatus,
25
- localidad: patient.localidad,
26
- cod_postal: patient.codPostal,
27
- // Only sent when informed; never as null or empty
28
- provincia: patient.provincia || undefined,
29
- };
30
- const parsedChannel = channel ? parseInt(channel) : channel;
31
- const response = await makeRequest('POST', path, {
32
- user_data: mappedPatient,
33
- channel: parsedChannel,
34
- code,
35
- });
36
- const data = response.data;
37
- if (data.ask_code)
38
- return {
39
- userInfo: {
40
- firstName: data.user_info.firstname,
41
- lastName: data.user_info.lastname,
42
- phone: data.user_info.phone,
43
- email: data.user_info.email,
44
- },
45
- askCode: true,
46
- };
47
- return { askCode: false, patientId: data.patient_id };
48
- };
49
- const getPatientId = async (patient) => {
50
- var _a;
51
- const path = '/search-patient';
52
- const mappedPatient = {
53
- id_patient: patient.idPatient,
54
- lastname: patient.lastName,
55
- firstname: patient.firstName,
56
- identification_type: patient.identificationType,
57
- identification_value: patient.identificationValue,
58
- birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
59
- gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
60
- email: patient.email,
61
- country_id: patient.countryId,
62
- };
63
- const response = await makeRequest('POST', path, {
64
- user_data: mappedPatient,
65
- });
66
- return response.data.patient_id;
67
- };
68
- const deletePatient = async (patientId) => {
69
- const path = `/patient/${patientId}`;
70
- await makeRequest('DELETE', path);
71
- };
72
- const getPatientPHR = async (patientId) => {
73
- const path = `/view-phr/${patientId}`;
74
- const response = await makeRequest('GET', path);
75
- return response.data.url_acceso_paciente;
76
- };
77
- const submitHealthQuiz = async ({ patientId, quiz, origen, }) => {
78
- const path = '/health-quiz-external';
79
- await makeRequest('POST', path, {
80
- id_persona: patientId,
81
- quiz,
82
- origen,
83
- });
84
- };
85
- return {
86
- declarePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declarePatientParams]), schemas_1.doc24Schemas.declarePatientResponse, declarePatient),
87
- getPatientId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.patientSearch]), zod_1.number(), getPatientId),
88
- deletePatient: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.void(), deletePatient),
89
- getPatientPHR: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.string(), getPatientPHR),
90
- submitHealthQuiz: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.healthQuizParams]), zod_1.void(), submitHealthQuiz),
91
- };
92
- };
93
- exports.getPatientMethods = getPatientMethods;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPatientMethods = 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 getPatientMethods = (makeRequest) => {
9
+ const declarePatient = async ({ patient, channel, code, }) => {
10
+ var _a;
11
+ const path = '/patient';
12
+ const mappedPatient = {
13
+ lastname: patient.lastName,
14
+ firstname: patient.firstName,
15
+ identification_type: patient.identificationType,
16
+ identification_value: patient.identificationValue,
17
+ birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
18
+ gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
19
+ country_id: patient.countryId,
20
+ emergency_contact: patient.emergencyContact,
21
+ emergency_contact_phone: patient.emergencyContactPhone,
22
+ credential: patient.credential,
23
+ plan: patient.plan,
24
+ affiliation_status: patient.affiliationStatus,
25
+ localidad: patient.localidad,
26
+ cod_postal: patient.codPostal,
27
+ // Only sent when informed; never as null or empty
28
+ provincia: patient.provincia || undefined,
29
+ };
30
+ const parsedChannel = channel ? parseInt(channel) : channel;
31
+ const response = await makeRequest('POST', path, {
32
+ user_data: mappedPatient,
33
+ channel: parsedChannel,
34
+ code,
35
+ });
36
+ const data = response.data;
37
+ if (data.ask_code)
38
+ return {
39
+ userInfo: {
40
+ firstName: data.user_info.firstname,
41
+ lastName: data.user_info.lastname,
42
+ phone: data.user_info.phone,
43
+ email: data.user_info.email,
44
+ },
45
+ askCode: true,
46
+ };
47
+ return { askCode: false, patientId: data.patient_id };
48
+ };
49
+ const getPatientId = async (patient) => {
50
+ var _a;
51
+ const path = '/search-patient';
52
+ const mappedPatient = {
53
+ id_patient: patient.idPatient,
54
+ lastname: patient.lastName,
55
+ firstname: patient.firstName,
56
+ identification_type: patient.identificationType,
57
+ identification_value: patient.identificationValue,
58
+ birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
59
+ gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
60
+ email: patient.email,
61
+ country_id: patient.countryId,
62
+ };
63
+ const response = await makeRequest('POST', path, {
64
+ user_data: mappedPatient,
65
+ });
66
+ return response.data.patient_id;
67
+ };
68
+ const deletePatient = async (patientId) => {
69
+ const path = `/patient/${patientId}`;
70
+ await makeRequest('DELETE', path);
71
+ };
72
+ const getPatientPHR = async (patientId) => {
73
+ const path = `/view-phr/${patientId}`;
74
+ const response = await makeRequest('GET', path);
75
+ return response.data.url_acceso_paciente;
76
+ };
77
+ const submitHealthQuiz = async ({ patientId, quiz, origen, }) => {
78
+ const path = '/health-quiz-external';
79
+ await makeRequest('POST', path, {
80
+ id_persona: patientId,
81
+ quiz,
82
+ origen,
83
+ });
84
+ };
85
+ return {
86
+ declarePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declarePatientParams]), schemas_1.doc24Schemas.declarePatientResponse, declarePatient),
87
+ getPatientId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.patientSearch]), zod_1.number(), getPatientId),
88
+ deletePatient: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.void(), deletePatient),
89
+ getPatientPHR: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.string(), getPatientPHR),
90
+ submitHealthQuiz: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.healthQuizParams]), zod_1.void(), submitHealthQuiz),
91
+ };
92
+ };
93
+ exports.getPatientMethods = getPatientMethods;
@@ -1,59 +1,59 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
3
- getSchedule: (patientId: number, specialtyId: number, filter?: {
4
- date?: Date | undefined;
5
- language?: string | undefined;
6
- professionalId?: number | undefined;
7
- userTimeZone?: string | undefined;
8
- offset?: number | undefined;
9
- limit?: number | undefined;
10
- weekDay?: number | undefined;
11
- startHour?: string | undefined;
12
- finishHour?: string | undefined;
13
- showAppointmentConfiguration?: boolean | undefined;
14
- } | undefined) => Promise<{
15
- length?: number | null | undefined;
16
- address?: string | null | undefined;
17
- city?: string | null | undefined;
18
- province?: string | null | undefined;
19
- ranking?: unknown;
20
- consultation_value?: string | null | undefined;
21
- inPerson?: boolean | null | undefined;
22
- virtual?: boolean | null | undefined;
23
- addressPhone?: string | null | undefined;
24
- date: Date;
25
- type: "appointment" | "chat" | "instant";
26
- id: string | number;
27
- professional: {
28
- logoUrl?: string | null | undefined;
29
- id: number;
30
- fullName: string;
31
- };
32
- specialty: {
33
- start_age?: string | number | null | undefined;
34
- end_age?: string | number | null | undefined;
35
- authorization_code?: string | null | undefined;
36
- id: number;
37
- description: string;
38
- };
39
- clinicId: number;
40
- cost: string;
41
- atentions: number;
42
- }[]>;
43
- getScheduleDates: (patientId: number, filter?: {
44
- specialtyId?: number | undefined;
45
- language?: string | undefined;
46
- professionalId?: number | undefined;
47
- userTimeZone?: string | undefined;
48
- } | undefined) => Promise<Date[]>;
49
- getAppointment: (appointmentId: number) => Promise<{
50
- date: Date;
51
- id: number;
52
- professionalId: number;
53
- }>;
54
- getAppointmentByVcToken: (vcToken: string) => Promise<{
55
- date: Date;
56
- id: number;
57
- professionalId: number;
58
- }>;
59
- };
1
+ import { RequestMaker } from '../request';
2
+ export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
3
+ getSchedule: (patientId: number, specialtyId: number, filter?: {
4
+ date?: Date | undefined;
5
+ language?: string | undefined;
6
+ professionalId?: number | undefined;
7
+ userTimeZone?: string | undefined;
8
+ offset?: number | undefined;
9
+ limit?: number | undefined;
10
+ weekDay?: number | undefined;
11
+ startHour?: string | undefined;
12
+ finishHour?: string | undefined;
13
+ showAppointmentConfiguration?: boolean | undefined;
14
+ } | undefined) => Promise<{
15
+ length?: number | null | undefined;
16
+ address?: string | null | undefined;
17
+ city?: string | null | undefined;
18
+ province?: string | null | undefined;
19
+ ranking?: unknown;
20
+ consultation_value?: string | null | undefined;
21
+ inPerson?: boolean | null | undefined;
22
+ virtual?: boolean | null | undefined;
23
+ addressPhone?: string | null | undefined;
24
+ date: Date;
25
+ type: "appointment" | "chat" | "instant";
26
+ id: string | number;
27
+ professional: {
28
+ logoUrl?: string | null | undefined;
29
+ id: number;
30
+ fullName: string;
31
+ };
32
+ specialty: {
33
+ start_age?: string | number | null | undefined;
34
+ end_age?: string | number | null | undefined;
35
+ authorization_code?: string | null | undefined;
36
+ id: number;
37
+ description: string;
38
+ };
39
+ clinicId: number;
40
+ cost: string;
41
+ atentions: number;
42
+ }[]>;
43
+ getScheduleDates: (patientId: number, filter?: {
44
+ specialtyId?: number | undefined;
45
+ language?: string | undefined;
46
+ professionalId?: number | undefined;
47
+ userTimeZone?: string | undefined;
48
+ } | undefined) => Promise<Date[]>;
49
+ getAppointment: (appointmentId: number) => Promise<{
50
+ date: Date;
51
+ id: number;
52
+ professionalId: number;
53
+ }>;
54
+ getAppointmentByVcToken: (vcToken: string) => Promise<{
55
+ date: Date;
56
+ id: number;
57
+ professionalId: number;
58
+ }>;
59
+ };
@@ -1,90 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getScheduleMethods = 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 getScheduleMethods = (makeRequest) => {
10
- const getScheduleDates = async (patientId, filter = {}) => {
11
- var _a;
12
- const mappedFilter = {
13
- specialty_id: filter.specialtyId,
14
- professional_id: filter.professionalId,
15
- language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
16
- user_time_zone: filter.userTimeZone,
17
- };
18
- const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
19
- const response = await makeRequest('GET', path);
20
- return response.data.available_dates.map((o) => utils_1.parseDate(o.date, filter.userTimeZone));
21
- };
22
- const getSchedule = async (patientId, specialtyId, filter = {}) => {
23
- var _a;
24
- const mappedFilter = {
25
- id_professional: filter.professionalId,
26
- offset: filter.offset,
27
- limit: filter.limit,
28
- week_day: filter.weekDay,
29
- date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
30
- start_hour: filter.startHour,
31
- finish_hour: filter.finishHour,
32
- language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
33
- user_time_zone: filter.userTimeZone,
34
- show_appointment_configuration: filter.showAppointmentConfiguration ? 1 : null,
35
- };
36
- const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
37
- const response = await makeRequest('GET', path);
38
- return response.data.available_appointments.map((a) => ({
39
- id: a.id,
40
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`, utils_1.getConvertedHourTimeZone(filter.userTimeZone, a.time_zone)),
41
- clinicId: a.clinic,
42
- professional: {
43
- id: a.professional_id,
44
- fullName: a.professional,
45
- logoUrl: a.logo,
46
- },
47
- cost: a.cost,
48
- specialty: {
49
- id: a.specialty_id,
50
- description: a.specialty,
51
- },
52
- type: a.type === 'P' ? 'appointment' : a.type === 'T' ? 'chat' : 'instant',
53
- atentions: a.atentions,
54
- ranking: a.ranking,
55
- length: a.length,
56
- consultation_value: a.consultation_value,
57
- inPerson: a.in_person,
58
- virtual: a.virtual,
59
- province: a.province,
60
- city: a.city,
61
- address: a.address,
62
- addressPhone: a.address_phone,
63
- }));
64
- };
65
- const getAppointment = async (appointmentId) => {
66
- const path = `/appointment/${appointmentId}`;
67
- const response = await makeRequest('GET', path);
68
- return {
69
- id: response.data.id,
70
- professionalId: response.data.professional_id,
71
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
72
- };
73
- };
74
- const getAppointmentByVcToken = async (vcToken) => {
75
- const path = `/appointmentByToken/${vcToken}`;
76
- const response = await makeRequest('GET', path);
77
- return {
78
- id: response.data.id,
79
- professionalId: response.data.professional_id,
80
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
81
- };
82
- };
83
- return {
84
- 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), getSchedule),
85
- getScheduleDates: validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), getScheduleDates),
86
- getAppointment: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, getAppointment),
87
- getAppointmentByVcToken: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, getAppointmentByVcToken),
88
- };
89
- };
90
- exports.getScheduleMethods = getScheduleMethods;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getScheduleMethods = 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 getScheduleMethods = (makeRequest) => {
10
+ const getScheduleDates = async (patientId, filter = {}) => {
11
+ var _a;
12
+ const mappedFilter = {
13
+ specialty_id: filter.specialtyId,
14
+ professional_id: filter.professionalId,
15
+ language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
16
+ user_time_zone: filter.userTimeZone,
17
+ };
18
+ const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
19
+ const response = await makeRequest('GET', path);
20
+ return response.data.available_dates.map((o) => utils_1.parseDate(o.date, filter.userTimeZone));
21
+ };
22
+ const getSchedule = async (patientId, specialtyId, filter = {}) => {
23
+ var _a;
24
+ const mappedFilter = {
25
+ id_professional: filter.professionalId,
26
+ offset: filter.offset,
27
+ limit: filter.limit,
28
+ week_day: filter.weekDay,
29
+ date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
30
+ start_hour: filter.startHour,
31
+ finish_hour: filter.finishHour,
32
+ language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
33
+ user_time_zone: filter.userTimeZone,
34
+ show_appointment_configuration: filter.showAppointmentConfiguration ? 1 : null,
35
+ };
36
+ const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
37
+ const response = await makeRequest('GET', path);
38
+ return response.data.available_appointments.map((a) => ({
39
+ id: a.id,
40
+ date: utils_1.parseDateTime(`${a.date} ${a.hour}`, utils_1.getConvertedHourTimeZone(filter.userTimeZone, a.time_zone)),
41
+ clinicId: a.clinic,
42
+ professional: {
43
+ id: a.professional_id,
44
+ fullName: a.professional,
45
+ logoUrl: a.logo,
46
+ },
47
+ cost: a.cost,
48
+ specialty: {
49
+ id: a.specialty_id,
50
+ description: a.specialty,
51
+ },
52
+ type: a.type === 'P' ? 'appointment' : a.type === 'T' ? 'chat' : 'instant',
53
+ atentions: a.atentions,
54
+ ranking: a.ranking,
55
+ length: a.length,
56
+ consultation_value: a.consultation_value,
57
+ inPerson: a.in_person,
58
+ virtual: a.virtual,
59
+ province: a.province,
60
+ city: a.city,
61
+ address: a.address,
62
+ addressPhone: a.address_phone,
63
+ }));
64
+ };
65
+ const getAppointment = async (appointmentId) => {
66
+ const path = `/appointment/${appointmentId}`;
67
+ const response = await makeRequest('GET', path);
68
+ return {
69
+ id: response.data.id,
70
+ professionalId: response.data.professional_id,
71
+ date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
72
+ };
73
+ };
74
+ const getAppointmentByVcToken = async (vcToken) => {
75
+ const path = `/appointmentByToken/${vcToken}`;
76
+ const response = await makeRequest('GET', path);
77
+ return {
78
+ id: response.data.id,
79
+ professionalId: response.data.professional_id,
80
+ date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
81
+ };
82
+ };
83
+ return {
84
+ 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), getSchedule),
85
+ getScheduleDates: validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), getScheduleDates),
86
+ getAppointment: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, getAppointment),
87
+ getAppointmentByVcToken: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, getAppointmentByVcToken),
88
+ };
89
+ };
90
+ exports.getScheduleMethods = getScheduleMethods;
@@ -1,19 +1,19 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getSpecialtiesMethods: (makeRequest: RequestMaker) => {
3
- getSpecialties: (mode: "appointment" | "chat" | "instant", language: string) => Promise<{
4
- start_age?: string | number | null | undefined;
5
- end_age?: string | number | null | undefined;
6
- authorization_code?: string | null | undefined;
7
- id: number;
8
- description: string;
9
- }[]>;
10
- getProfessionalsBySpecialty: (...params: any) => Promise<{
11
- logoUrl?: string | null | undefined;
12
- brief?: string | null | undefined;
13
- consultation_value?: string | number | null | undefined;
14
- degree?: string | undefined;
15
- primer_turno?: string | undefined;
16
- id: number;
17
- fullName: string;
18
- }[]>;
19
- };
1
+ import { RequestMaker } from '../request';
2
+ export declare const getSpecialtiesMethods: (makeRequest: RequestMaker) => {
3
+ getSpecialties: (mode: "appointment" | "chat" | "instant", language: string) => Promise<{
4
+ start_age?: string | number | null | undefined;
5
+ end_age?: string | number | null | undefined;
6
+ authorization_code?: string | null | undefined;
7
+ id: number;
8
+ description: string;
9
+ }[]>;
10
+ getProfessionalsBySpecialty: (...params: any) => Promise<{
11
+ logoUrl?: string | null | undefined;
12
+ brief?: string | null | undefined;
13
+ consultation_value?: string | number | null | undefined;
14
+ degree?: string | undefined;
15
+ primer_turno?: string | undefined;
16
+ id: number;
17
+ fullName: string;
18
+ }[]>;
19
+ };