@blackcode_sa/metaestetics-api 1.5.30 → 1.5.31
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/dist/admin/index.d.mts +1 -1
- package/dist/admin/index.d.ts +1 -1
- package/dist/index.js +4 -22
- package/dist/index.mjs +4 -22
- package/package.json +1 -1
- package/src/admin/index.ts +10 -2
- package/src/services/calendar/utils/appointment.utils.ts +42 -91
package/dist/admin/index.d.mts
CHANGED
|
@@ -1475,4 +1475,4 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
|
1475
1475
|
handleTokenCreationEvent(tokenData: PractitionerToken, fromAddress: string): Promise<void>;
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
|
-
export { type AppointmentNotification, type AppointmentReminderNotification, BaseMailingService, type BaseNotification, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type PatientProfile as Patient, PatientAggregationService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, UserRole };
|
|
1478
|
+
export { type AppointmentNotification, type AppointmentReminderNotification, BaseMailingService, type BaseNotification, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type PatientProfile as Patient, PatientAggregationService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, UserRole };
|
package/dist/admin/index.d.ts
CHANGED
|
@@ -1475,4 +1475,4 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
|
1475
1475
|
handleTokenCreationEvent(tokenData: PractitionerToken, fromAddress: string): Promise<void>;
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
|
-
export { type AppointmentNotification, type AppointmentReminderNotification, BaseMailingService, type BaseNotification, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type PatientProfile as Patient, PatientAggregationService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, UserRole };
|
|
1478
|
+
export { type AppointmentNotification, type AppointmentReminderNotification, BaseMailingService, type BaseNotification, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type PatientProfile as Patient, PatientAggregationService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, UserRole };
|
package/dist/index.js
CHANGED
|
@@ -8290,37 +8290,19 @@ async function createAppointmentUtil(db, clinicId, practitionerId, patientId, ev
|
|
|
8290
8290
|
() => eventId
|
|
8291
8291
|
// Use the same ID for all calendars
|
|
8292
8292
|
);
|
|
8293
|
-
const [clinicEvent] = await Promise.all([
|
|
8294
|
-
clinicPromise,
|
|
8295
|
-
practitionerPromise,
|
|
8296
|
-
patientPromise
|
|
8297
|
-
]);
|
|
8293
|
+
const [clinicEvent] = await Promise.all([clinicPromise, practitionerPromise, patientPromise]);
|
|
8298
8294
|
return clinicEvent;
|
|
8299
8295
|
}
|
|
8300
8296
|
async function updateAppointmentUtil(db, clinicId, practitionerId, patientId, eventId, updateData) {
|
|
8301
|
-
const clinicPromise = updateClinicCalendarEventUtil(
|
|
8302
|
-
db,
|
|
8303
|
-
clinicId,
|
|
8304
|
-
eventId,
|
|
8305
|
-
updateData
|
|
8306
|
-
);
|
|
8297
|
+
const clinicPromise = updateClinicCalendarEventUtil(db, clinicId, eventId, updateData);
|
|
8307
8298
|
const practitionerPromise = updatePractitionerCalendarEventUtil(
|
|
8308
8299
|
db,
|
|
8309
8300
|
practitionerId,
|
|
8310
8301
|
eventId,
|
|
8311
8302
|
updateData
|
|
8312
8303
|
);
|
|
8313
|
-
const patientPromise = updatePatientCalendarEventUtil(
|
|
8314
|
-
|
|
8315
|
-
patientId,
|
|
8316
|
-
eventId,
|
|
8317
|
-
updateData
|
|
8318
|
-
);
|
|
8319
|
-
const [clinicEvent] = await Promise.all([
|
|
8320
|
-
clinicPromise,
|
|
8321
|
-
practitionerPromise,
|
|
8322
|
-
patientPromise
|
|
8323
|
-
]);
|
|
8304
|
+
const patientPromise = updatePatientCalendarEventUtil(db, patientId, eventId, updateData);
|
|
8305
|
+
const [clinicEvent] = await Promise.all([clinicPromise, practitionerPromise, patientPromise]);
|
|
8324
8306
|
return clinicEvent;
|
|
8325
8307
|
}
|
|
8326
8308
|
|
package/dist/index.mjs
CHANGED
|
@@ -8337,37 +8337,19 @@ async function createAppointmentUtil(db, clinicId, practitionerId, patientId, ev
|
|
|
8337
8337
|
() => eventId
|
|
8338
8338
|
// Use the same ID for all calendars
|
|
8339
8339
|
);
|
|
8340
|
-
const [clinicEvent] = await Promise.all([
|
|
8341
|
-
clinicPromise,
|
|
8342
|
-
practitionerPromise,
|
|
8343
|
-
patientPromise
|
|
8344
|
-
]);
|
|
8340
|
+
const [clinicEvent] = await Promise.all([clinicPromise, practitionerPromise, patientPromise]);
|
|
8345
8341
|
return clinicEvent;
|
|
8346
8342
|
}
|
|
8347
8343
|
async function updateAppointmentUtil(db, clinicId, practitionerId, patientId, eventId, updateData) {
|
|
8348
|
-
const clinicPromise = updateClinicCalendarEventUtil(
|
|
8349
|
-
db,
|
|
8350
|
-
clinicId,
|
|
8351
|
-
eventId,
|
|
8352
|
-
updateData
|
|
8353
|
-
);
|
|
8344
|
+
const clinicPromise = updateClinicCalendarEventUtil(db, clinicId, eventId, updateData);
|
|
8354
8345
|
const practitionerPromise = updatePractitionerCalendarEventUtil(
|
|
8355
8346
|
db,
|
|
8356
8347
|
practitionerId,
|
|
8357
8348
|
eventId,
|
|
8358
8349
|
updateData
|
|
8359
8350
|
);
|
|
8360
|
-
const patientPromise = updatePatientCalendarEventUtil(
|
|
8361
|
-
|
|
8362
|
-
patientId,
|
|
8363
|
-
eventId,
|
|
8364
|
-
updateData
|
|
8365
|
-
);
|
|
8366
|
-
const [clinicEvent] = await Promise.all([
|
|
8367
|
-
clinicPromise,
|
|
8368
|
-
practitionerPromise,
|
|
8369
|
-
patientPromise
|
|
8370
|
-
]);
|
|
8351
|
+
const patientPromise = updatePatientCalendarEventUtil(db, patientId, eventId, updateData);
|
|
8352
|
+
const [clinicEvent] = await Promise.all([clinicPromise, practitionerPromise, patientPromise]);
|
|
8371
8353
|
return clinicEvent;
|
|
8372
8354
|
}
|
|
8373
8355
|
|
package/package.json
CHANGED
package/src/admin/index.ts
CHANGED
|
@@ -8,7 +8,11 @@ import { UserRole } from "../types";
|
|
|
8
8
|
// Import types needed by admin consumers (like Cloud Functions)
|
|
9
9
|
import { Clinic, ClinicLocation } from "../types/clinic";
|
|
10
10
|
import { ClinicInfo } from "../types/profile";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
Practitioner,
|
|
13
|
+
PractitionerToken,
|
|
14
|
+
PractitionerTokenStatus,
|
|
15
|
+
} from "../types/practitioner";
|
|
12
16
|
import { DoctorInfo } from "../types/clinic";
|
|
13
17
|
import { Procedure, ProcedureSummaryInfo } from "../types/procedure";
|
|
14
18
|
import { PatientProfile } from "../types/patient";
|
|
@@ -36,7 +40,11 @@ export type {
|
|
|
36
40
|
// Re-export types needed by cloud functions
|
|
37
41
|
export type { Clinic, ClinicLocation } from "../types/clinic";
|
|
38
42
|
export type { ClinicInfo } from "../types/profile";
|
|
39
|
-
export type {
|
|
43
|
+
export type {
|
|
44
|
+
Practitioner,
|
|
45
|
+
PractitionerToken,
|
|
46
|
+
PractitionerTokenStatus,
|
|
47
|
+
} from "../types/practitioner";
|
|
40
48
|
export type { DoctorInfo } from "../types/clinic";
|
|
41
49
|
export type { Procedure, ProcedureSummaryInfo } from "../types/procedure";
|
|
42
50
|
export type { PatientProfile as Patient } from "../types/patient";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Firestore, Timestamp } from
|
|
1
|
+
import { Firestore, Timestamp } from 'firebase/firestore';
|
|
2
2
|
import {
|
|
3
3
|
CalendarEvent,
|
|
4
4
|
CalendarEventStatus,
|
|
@@ -7,23 +7,23 @@ import {
|
|
|
7
7
|
CalendarSyncStatus,
|
|
8
8
|
CreateCalendarEventData,
|
|
9
9
|
UpdateCalendarEventData,
|
|
10
|
-
} from
|
|
10
|
+
} from '../../../types/calendar';
|
|
11
11
|
import {
|
|
12
12
|
createClinicCalendarEventUtil,
|
|
13
13
|
updateClinicCalendarEventUtil,
|
|
14
14
|
deleteClinicCalendarEventUtil,
|
|
15
15
|
checkAutoConfirmAppointmentsUtil,
|
|
16
|
-
} from
|
|
16
|
+
} from './clinic.utils';
|
|
17
17
|
import {
|
|
18
18
|
createPatientCalendarEventUtil,
|
|
19
19
|
updatePatientCalendarEventUtil,
|
|
20
20
|
deletePatientCalendarEventUtil,
|
|
21
|
-
} from
|
|
21
|
+
} from './patient.utils';
|
|
22
22
|
import {
|
|
23
23
|
createPractitionerCalendarEventUtil,
|
|
24
24
|
updatePractitionerCalendarEventUtil,
|
|
25
25
|
deletePractitionerCalendarEventUtil,
|
|
26
|
-
} from
|
|
26
|
+
} from './practitioner.utils';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Creates an appointment across all relevant calendars (practitioner, patient, clinic)
|
|
@@ -42,14 +42,14 @@ export async function createAppointmentUtil(
|
|
|
42
42
|
patientId: string,
|
|
43
43
|
eventData: Omit<
|
|
44
44
|
CreateCalendarEventData,
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
45
|
+
| 'id'
|
|
46
|
+
| 'createdAt'
|
|
47
|
+
| 'updatedAt'
|
|
48
|
+
| 'clinicBranchId'
|
|
49
|
+
| 'practitionerProfileId'
|
|
50
|
+
| 'patientProfileId'
|
|
51
51
|
>,
|
|
52
|
-
generateId: () => string
|
|
52
|
+
generateId: () => string,
|
|
53
53
|
): Promise<CalendarEvent> {
|
|
54
54
|
// TODO: Add validation for appointment data
|
|
55
55
|
// - Check if all entities exist
|
|
@@ -64,15 +64,10 @@ export async function createAppointmentUtil(
|
|
|
64
64
|
const autoConfirm = await checkAutoConfirmAppointmentsUtil(db, clinicId);
|
|
65
65
|
|
|
66
66
|
// Set the initial status based on auto-confirm setting
|
|
67
|
-
const initialStatus = autoConfirm
|
|
68
|
-
? CalendarEventStatus.CONFIRMED
|
|
69
|
-
: CalendarEventStatus.PENDING;
|
|
67
|
+
const initialStatus = autoConfirm ? CalendarEventStatus.CONFIRMED : CalendarEventStatus.PENDING;
|
|
70
68
|
|
|
71
69
|
// Prepare the event data with all required IDs
|
|
72
|
-
const appointmentData: Omit<
|
|
73
|
-
CreateCalendarEventData,
|
|
74
|
-
"id" | "createdAt" | "updatedAt"
|
|
75
|
-
> = {
|
|
70
|
+
const appointmentData: Omit<CreateCalendarEventData, 'id' | 'createdAt' | 'updatedAt'> = {
|
|
76
71
|
...eventData,
|
|
77
72
|
clinicBranchId: clinicId,
|
|
78
73
|
practitionerProfileId: practitionerId,
|
|
@@ -86,29 +81,25 @@ export async function createAppointmentUtil(
|
|
|
86
81
|
db,
|
|
87
82
|
clinicId,
|
|
88
83
|
appointmentData,
|
|
89
|
-
() => eventId // Use the same ID for all calendars
|
|
84
|
+
() => eventId, // Use the same ID for all calendars
|
|
90
85
|
);
|
|
91
86
|
|
|
92
87
|
const practitionerPromise = createPractitionerCalendarEventUtil(
|
|
93
88
|
db,
|
|
94
89
|
practitionerId,
|
|
95
90
|
appointmentData,
|
|
96
|
-
() => eventId // Use the same ID for all calendars
|
|
91
|
+
() => eventId, // Use the same ID for all calendars
|
|
97
92
|
);
|
|
98
93
|
|
|
99
94
|
const patientPromise = createPatientCalendarEventUtil(
|
|
100
95
|
db,
|
|
101
96
|
patientId,
|
|
102
97
|
appointmentData,
|
|
103
|
-
() => eventId // Use the same ID for all calendars
|
|
98
|
+
() => eventId, // Use the same ID for all calendars
|
|
104
99
|
);
|
|
105
100
|
|
|
106
101
|
// Wait for all operations to complete
|
|
107
|
-
const [clinicEvent] = await Promise.all([
|
|
108
|
-
clinicPromise,
|
|
109
|
-
practitionerPromise,
|
|
110
|
-
patientPromise,
|
|
111
|
-
]);
|
|
102
|
+
const [clinicEvent] = await Promise.all([clinicPromise, practitionerPromise, patientPromise]);
|
|
112
103
|
|
|
113
104
|
// Return the event from the clinic calendar
|
|
114
105
|
return clinicEvent;
|
|
@@ -130,7 +121,7 @@ export async function updateAppointmentUtil(
|
|
|
130
121
|
practitionerId: string,
|
|
131
122
|
patientId: string,
|
|
132
123
|
eventId: string,
|
|
133
|
-
updateData: Omit<UpdateCalendarEventData,
|
|
124
|
+
updateData: Omit<UpdateCalendarEventData, 'updatedAt'>,
|
|
134
125
|
): Promise<CalendarEvent> {
|
|
135
126
|
// TODO: Add validation for update data
|
|
136
127
|
// - Check if event exists in all calendars
|
|
@@ -138,33 +129,19 @@ export async function updateAppointmentUtil(
|
|
|
138
129
|
// - Check for overlapping events
|
|
139
130
|
|
|
140
131
|
// Update the event in all three calendars
|
|
141
|
-
const clinicPromise = updateClinicCalendarEventUtil(
|
|
142
|
-
db,
|
|
143
|
-
clinicId,
|
|
144
|
-
eventId,
|
|
145
|
-
updateData
|
|
146
|
-
);
|
|
132
|
+
const clinicPromise = updateClinicCalendarEventUtil(db, clinicId, eventId, updateData);
|
|
147
133
|
|
|
148
134
|
const practitionerPromise = updatePractitionerCalendarEventUtil(
|
|
149
135
|
db,
|
|
150
136
|
practitionerId,
|
|
151
137
|
eventId,
|
|
152
|
-
updateData
|
|
138
|
+
updateData,
|
|
153
139
|
);
|
|
154
140
|
|
|
155
|
-
const patientPromise = updatePatientCalendarEventUtil(
|
|
156
|
-
db,
|
|
157
|
-
patientId,
|
|
158
|
-
eventId,
|
|
159
|
-
updateData
|
|
160
|
-
);
|
|
141
|
+
const patientPromise = updatePatientCalendarEventUtil(db, patientId, eventId, updateData);
|
|
161
142
|
|
|
162
143
|
// Wait for all operations to complete
|
|
163
|
-
const [clinicEvent] = await Promise.all([
|
|
164
|
-
clinicPromise,
|
|
165
|
-
practitionerPromise,
|
|
166
|
-
patientPromise,
|
|
167
|
-
]);
|
|
144
|
+
const [clinicEvent] = await Promise.all([clinicPromise, practitionerPromise, patientPromise]);
|
|
168
145
|
|
|
169
146
|
// Return the event from the clinic calendar
|
|
170
147
|
return clinicEvent;
|
|
@@ -183,16 +160,12 @@ export async function deleteAppointmentUtil(
|
|
|
183
160
|
clinicId: string,
|
|
184
161
|
practitionerId: string,
|
|
185
162
|
patientId: string,
|
|
186
|
-
eventId: string
|
|
163
|
+
eventId: string,
|
|
187
164
|
): Promise<void> {
|
|
188
165
|
// Delete the event from all three calendars
|
|
189
166
|
const clinicPromise = deleteClinicCalendarEventUtil(db, clinicId, eventId);
|
|
190
167
|
|
|
191
|
-
const practitionerPromise = deletePractitionerCalendarEventUtil(
|
|
192
|
-
db,
|
|
193
|
-
practitionerId,
|
|
194
|
-
eventId
|
|
195
|
-
);
|
|
168
|
+
const practitionerPromise = deletePractitionerCalendarEventUtil(db, practitionerId, eventId);
|
|
196
169
|
|
|
197
170
|
const patientPromise = deletePatientCalendarEventUtil(db, patientId, eventId);
|
|
198
171
|
|
|
@@ -214,16 +187,11 @@ export async function confirmAppointmentUtil(
|
|
|
214
187
|
clinicId: string,
|
|
215
188
|
practitionerId: string,
|
|
216
189
|
patientId: string,
|
|
217
|
-
eventId: string
|
|
190
|
+
eventId: string,
|
|
218
191
|
): Promise<CalendarEvent> {
|
|
219
|
-
return updateAppointmentUtil(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
practitionerId,
|
|
223
|
-
patientId,
|
|
224
|
-
eventId,
|
|
225
|
-
{ status: CalendarEventStatus.CONFIRMED }
|
|
226
|
-
);
|
|
192
|
+
return updateAppointmentUtil(db, clinicId, practitionerId, patientId, eventId, {
|
|
193
|
+
status: CalendarEventStatus.CONFIRMED,
|
|
194
|
+
});
|
|
227
195
|
}
|
|
228
196
|
|
|
229
197
|
/**
|
|
@@ -240,16 +208,11 @@ export async function rejectAppointmentUtil(
|
|
|
240
208
|
clinicId: string,
|
|
241
209
|
practitionerId: string,
|
|
242
210
|
patientId: string,
|
|
243
|
-
eventId: string
|
|
211
|
+
eventId: string,
|
|
244
212
|
): Promise<CalendarEvent> {
|
|
245
|
-
return updateAppointmentUtil(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
practitionerId,
|
|
249
|
-
patientId,
|
|
250
|
-
eventId,
|
|
251
|
-
{ status: CalendarEventStatus.REJECTED }
|
|
252
|
-
);
|
|
213
|
+
return updateAppointmentUtil(db, clinicId, practitionerId, patientId, eventId, {
|
|
214
|
+
status: CalendarEventStatus.REJECTED,
|
|
215
|
+
});
|
|
253
216
|
}
|
|
254
217
|
|
|
255
218
|
/**
|
|
@@ -266,16 +229,11 @@ export async function cancelAppointmentUtil(
|
|
|
266
229
|
clinicId: string,
|
|
267
230
|
practitionerId: string,
|
|
268
231
|
patientId: string,
|
|
269
|
-
eventId: string
|
|
232
|
+
eventId: string,
|
|
270
233
|
): Promise<CalendarEvent> {
|
|
271
|
-
return updateAppointmentUtil(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
practitionerId,
|
|
275
|
-
patientId,
|
|
276
|
-
eventId,
|
|
277
|
-
{ status: CalendarEventStatus.CANCELED }
|
|
278
|
-
);
|
|
234
|
+
return updateAppointmentUtil(db, clinicId, practitionerId, patientId, eventId, {
|
|
235
|
+
status: CalendarEventStatus.CANCELED,
|
|
236
|
+
});
|
|
279
237
|
}
|
|
280
238
|
|
|
281
239
|
/**
|
|
@@ -294,21 +252,14 @@ export async function rescheduleAppointmentUtil(
|
|
|
294
252
|
practitionerId: string,
|
|
295
253
|
patientId: string,
|
|
296
254
|
eventId: string,
|
|
297
|
-
newEventTime: CalendarEventTime
|
|
255
|
+
newEventTime: CalendarEventTime,
|
|
298
256
|
): Promise<CalendarEvent> {
|
|
299
257
|
// TODO: Add validation for new event time
|
|
300
258
|
// - Validate event time (start < end)
|
|
301
259
|
// - Check for overlapping events
|
|
302
260
|
|
|
303
|
-
return updateAppointmentUtil(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
patientId,
|
|
308
|
-
eventId,
|
|
309
|
-
{
|
|
310
|
-
status: CalendarEventStatus.RESCHEDULED,
|
|
311
|
-
eventTime: newEventTime,
|
|
312
|
-
}
|
|
313
|
-
);
|
|
261
|
+
return updateAppointmentUtil(db, clinicId, practitionerId, patientId, eventId, {
|
|
262
|
+
status: CalendarEventStatus.RESCHEDULED,
|
|
263
|
+
eventTime: newEventTime,
|
|
264
|
+
});
|
|
314
265
|
}
|