@blackcode_sa/metaestetics-api 1.6.13 → 1.6.15
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 +343 -2
- package/dist/admin/index.d.ts +343 -2
- package/dist/admin/index.js +4712 -37532
- package/dist/admin/index.mjs +4660 -37510
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +2 -2
- package/src/admin/booking/booking.admin.ts +10 -12
- package/src/admin/calendar/calendar.admin.service.ts +8 -11
- package/src/admin/index.ts +21 -0
- package/src/admin/notifications/notifications.admin.ts +13 -36
- package/src/admin/requirements/patient-requirements.admin.service.ts +26 -33
- package/src/types/clinic/index.ts +19 -27
- package/src/types/patient/index.ts +20 -22
- package/src/utils/TIMESTAMPS.md +176 -0
- package/src/utils/TimestampUtils.ts +241 -0
package/dist/index.d.mts
CHANGED
|
@@ -1905,7 +1905,7 @@ interface CreatePatientProfileData {
|
|
|
1905
1905
|
/**
|
|
1906
1906
|
* Tip za ažuriranje Patient profila
|
|
1907
1907
|
*/
|
|
1908
|
-
interface UpdatePatientProfileData extends Partial<Omit<PatientProfile,
|
|
1908
|
+
interface UpdatePatientProfileData extends Partial<Omit<PatientProfile, 'id' | 'createdAt' | 'updatedAt'>> {
|
|
1909
1909
|
updatedAt?: FieldValue;
|
|
1910
1910
|
}
|
|
1911
1911
|
/**
|
|
@@ -1924,7 +1924,7 @@ interface RequesterInfo {
|
|
|
1924
1924
|
/** ID of the clinic admin user or practitioner user making the request. */
|
|
1925
1925
|
id: string;
|
|
1926
1926
|
/** Role of the requester, determining the search context. */
|
|
1927
|
-
role:
|
|
1927
|
+
role: 'clinic_admin' | 'practitioner';
|
|
1928
1928
|
/** If role is 'clinic_admin', this is the associated clinic ID. */
|
|
1929
1929
|
associatedClinicId?: string;
|
|
1930
1930
|
/** If role is 'practitioner', this is the associated practitioner profile ID. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1905,7 +1905,7 @@ interface CreatePatientProfileData {
|
|
|
1905
1905
|
/**
|
|
1906
1906
|
* Tip za ažuriranje Patient profila
|
|
1907
1907
|
*/
|
|
1908
|
-
interface UpdatePatientProfileData extends Partial<Omit<PatientProfile,
|
|
1908
|
+
interface UpdatePatientProfileData extends Partial<Omit<PatientProfile, 'id' | 'createdAt' | 'updatedAt'>> {
|
|
1909
1909
|
updatedAt?: FieldValue;
|
|
1910
1910
|
}
|
|
1911
1911
|
/**
|
|
@@ -1924,7 +1924,7 @@ interface RequesterInfo {
|
|
|
1924
1924
|
/** ID of the clinic admin user or practitioner user making the request. */
|
|
1925
1925
|
id: string;
|
|
1926
1926
|
/** Role of the requester, determining the search context. */
|
|
1927
|
-
role:
|
|
1927
|
+
role: 'clinic_admin' | 'practitioner';
|
|
1928
1928
|
/** If role is 'clinic_admin', this is the associated clinic ID. */
|
|
1929
1929
|
associatedClinicId?: string;
|
|
1930
1930
|
/** If role is 'practitioner', this is the associated practitioner profile ID. */
|
package/package.json
CHANGED
|
@@ -565,7 +565,7 @@ export class AppointmentAggregationService {
|
|
|
565
565
|
status: PatientInstructionStatus.PENDING_NOTIFICATION,
|
|
566
566
|
originalNotifyAtValue: notifyAtValue,
|
|
567
567
|
originalTimeframeUnit: template.timeframe.unit,
|
|
568
|
-
updatedAt: admin.firestore.
|
|
568
|
+
updatedAt: admin.firestore.Timestamp.now() as any, // Use current server timestamp
|
|
569
569
|
notificationId: undefined,
|
|
570
570
|
actionTakenAt: undefined,
|
|
571
571
|
};
|
|
@@ -707,7 +707,7 @@ export class AppointmentAggregationService {
|
|
|
707
707
|
status: PatientInstructionStatus.PENDING_NOTIFICATION,
|
|
708
708
|
originalNotifyAtValue: notifyAtValue,
|
|
709
709
|
originalTimeframeUnit: template.timeframe.unit,
|
|
710
|
-
updatedAt: admin.firestore.
|
|
710
|
+
updatedAt: admin.firestore.Timestamp.now() as any, // Use current server timestamp
|
|
711
711
|
notificationId: undefined,
|
|
712
712
|
actionTakenAt: undefined,
|
|
713
713
|
} as PatientRequirementInstruction;
|
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
} from "../../types/calendar";
|
|
63
63
|
import { DocumentManagerAdminService } from "../documentation-templates/document-manager.admin";
|
|
64
64
|
import { LinkedFormInfo } from "../../types/appointment";
|
|
65
|
+
import { TimestampUtils } from "../../utils/TimestampUtils";
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* Interface for the data required by orchestrateAppointmentCreation
|
|
@@ -204,16 +205,9 @@ export class BookingAdmin {
|
|
|
204
205
|
*/
|
|
205
206
|
private adminTimestampToClientTimestamp(
|
|
206
207
|
timestamp: admin.firestore.Timestamp
|
|
207
|
-
):
|
|
208
|
-
//
|
|
209
|
-
return
|
|
210
|
-
seconds: timestamp.seconds,
|
|
211
|
-
nanoseconds: timestamp.nanoseconds,
|
|
212
|
-
toDate: () => timestamp.toDate(),
|
|
213
|
-
toMillis: () => timestamp.toMillis(),
|
|
214
|
-
valueOf: () => timestamp.valueOf(),
|
|
215
|
-
// Add any other required methods/properties
|
|
216
|
-
};
|
|
208
|
+
): FirebaseClientTimestamp {
|
|
209
|
+
// Use TimestampUtils instead of custom implementation
|
|
210
|
+
return TimestampUtils.adminToClient(timestamp) as FirebaseClientTimestamp;
|
|
217
211
|
}
|
|
218
212
|
|
|
219
213
|
/**
|
|
@@ -223,8 +217,12 @@ export class BookingAdmin {
|
|
|
223
217
|
return events.map((event) => ({
|
|
224
218
|
...event,
|
|
225
219
|
eventTime: {
|
|
226
|
-
start:
|
|
227
|
-
|
|
220
|
+
start: TimestampUtils.adminToClient(
|
|
221
|
+
event.eventTime.start
|
|
222
|
+
) as FirebaseClientTimestamp,
|
|
223
|
+
end: TimestampUtils.adminToClient(
|
|
224
|
+
event.eventTime.end
|
|
225
|
+
) as FirebaseClientTimestamp,
|
|
228
226
|
},
|
|
229
227
|
// Convert any other timestamps in the event if needed
|
|
230
228
|
}));
|
|
@@ -10,6 +10,7 @@ import { Logger } from "../logger";
|
|
|
10
10
|
import { PRACTITIONERS_COLLECTION } from "../../types/practitioner";
|
|
11
11
|
import { PATIENTS_COLLECTION } from "../../types/patient";
|
|
12
12
|
import { CLINICS_COLLECTION } from "../../types/clinic";
|
|
13
|
+
import { TimestampUtils } from "../../utils/TimestampUtils";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @class CalendarAdminService
|
|
@@ -103,18 +104,14 @@ export class CalendarAdminService {
|
|
|
103
104
|
const batch = this.db.batch();
|
|
104
105
|
const serverTimestamp = admin.firestore.FieldValue.serverTimestamp();
|
|
105
106
|
|
|
106
|
-
// Convert
|
|
107
|
-
// or ensure the CalendarEventTime type is directly compatible.
|
|
108
|
-
// Firestore admin SDK usually handles { seconds: X, nanoseconds: Y } objects correctly.
|
|
107
|
+
// Convert client timestamps to admin timestamps since we're in server mode
|
|
109
108
|
const firestoreCompatibleEventTime = {
|
|
110
|
-
start:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
nanoseconds: newEventTime.end.nanoseconds,
|
|
117
|
-
},
|
|
109
|
+
start:
|
|
110
|
+
TimestampUtils.clientToAdmin(newEventTime.start) ||
|
|
111
|
+
admin.firestore.Timestamp.now(),
|
|
112
|
+
end:
|
|
113
|
+
TimestampUtils.clientToAdmin(newEventTime.end) ||
|
|
114
|
+
admin.firestore.Timestamp.now(),
|
|
118
115
|
};
|
|
119
116
|
|
|
120
117
|
// TODO: Confirm paths as in updateAppointmentCalendarEventsStatus
|
package/src/admin/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { NotificationsAdmin } from "./notifications/notifications.admin";
|
|
2
|
+
import * as admin from "firebase-admin";
|
|
3
|
+
import { TimestampUtils } from "../utils/TimestampUtils";
|
|
2
4
|
|
|
3
5
|
import { UserRole } from "../types";
|
|
4
6
|
// Import types needed by admin consumers (like Cloud Functions)
|
|
@@ -111,3 +113,22 @@ console.log("[Admin Module] Initialized and services exported.");
|
|
|
111
113
|
// if they have dependencies (like Firestore db) that need to be injected.
|
|
112
114
|
// The initialization pattern might differ depending on how this module is consumed
|
|
113
115
|
// (e.g., within a larger NestJS app vs. standalone Cloud Functions).
|
|
116
|
+
|
|
117
|
+
// Initialize TimestampUtils for server-side use
|
|
118
|
+
TimestampUtils.enableServerMode();
|
|
119
|
+
|
|
120
|
+
// Export all admin services that are needed
|
|
121
|
+
export * from "./booking/booking.admin";
|
|
122
|
+
export * from "./booking/booking.calculator";
|
|
123
|
+
export * from "./booking/booking.types";
|
|
124
|
+
export * from "./calendar/calendar.admin.service";
|
|
125
|
+
export * from "./documentation-templates/document-manager.admin";
|
|
126
|
+
export * from "./logger";
|
|
127
|
+
export * from "./mailing/appointment/appointment.mailing.service";
|
|
128
|
+
export * from "./notifications/notifications.admin";
|
|
129
|
+
export * from "./requirements/patient-requirements.admin.service";
|
|
130
|
+
export * from "./aggregation/appointment/appointment.aggregation.service";
|
|
131
|
+
|
|
132
|
+
// Re-export types that Cloud Functions might need direct access to
|
|
133
|
+
export * from "../types/appointment";
|
|
134
|
+
// Add other types as needed
|
|
@@ -8,6 +8,7 @@ import { Expo, ExpoPushMessage, ExpoPushTicket } from "expo-server-sdk";
|
|
|
8
8
|
import { Appointment, PaymentStatus } from "../../types/appointment";
|
|
9
9
|
import { UserRole } from "../../types";
|
|
10
10
|
import { Timestamp as FirebaseClientTimestamp } from "@firebase/firestore";
|
|
11
|
+
import { TimestampUtils } from "../../utils/TimestampUtils";
|
|
11
12
|
|
|
12
13
|
export class NotificationsAdmin {
|
|
13
14
|
private expo: Expo;
|
|
@@ -276,11 +277,7 @@ export class NotificationsAdmin {
|
|
|
276
277
|
.toLocaleDateString()} is confirmed.`;
|
|
277
278
|
}
|
|
278
279
|
|
|
279
|
-
const
|
|
280
|
-
const clientCompatibleNotificationTime = new FirebaseClientTimestamp(
|
|
281
|
-
adminTsNow.seconds,
|
|
282
|
-
adminTsNow.nanoseconds
|
|
283
|
-
);
|
|
280
|
+
const notificationTimestampForDb = admin.firestore.Timestamp.now();
|
|
284
281
|
|
|
285
282
|
const notificationData: Omit<
|
|
286
283
|
Notification,
|
|
@@ -289,7 +286,7 @@ export class NotificationsAdmin {
|
|
|
289
286
|
userId: recipientUserId,
|
|
290
287
|
userRole: recipientRole,
|
|
291
288
|
notificationType: NotificationType.APPOINTMENT_STATUS_CHANGE,
|
|
292
|
-
notificationTime:
|
|
289
|
+
notificationTime: notificationTimestampForDb as any,
|
|
293
290
|
notificationTokens: recipientExpoTokens,
|
|
294
291
|
title,
|
|
295
292
|
body,
|
|
@@ -353,11 +350,7 @@ export class NotificationsAdmin {
|
|
|
353
350
|
}
|
|
354
351
|
}
|
|
355
352
|
|
|
356
|
-
const
|
|
357
|
-
const clientCompatibleNotificationTime = new FirebaseClientTimestamp(
|
|
358
|
-
adminTsNow.seconds,
|
|
359
|
-
adminTsNow.nanoseconds
|
|
360
|
-
);
|
|
353
|
+
const notificationTimestampForDb = admin.firestore.Timestamp.now();
|
|
361
354
|
|
|
362
355
|
const notificationData: Omit<
|
|
363
356
|
Notification,
|
|
@@ -366,7 +359,7 @@ export class NotificationsAdmin {
|
|
|
366
359
|
userId: recipientUserId,
|
|
367
360
|
userRole: recipientRole,
|
|
368
361
|
notificationType: NotificationType.APPOINTMENT_CANCELLED,
|
|
369
|
-
notificationTime:
|
|
362
|
+
notificationTime: notificationTimestampForDb as any,
|
|
370
363
|
notificationTokens: recipientExpoTokens,
|
|
371
364
|
title,
|
|
372
365
|
body,
|
|
@@ -405,11 +398,7 @@ export class NotificationsAdmin {
|
|
|
405
398
|
const title = "Appointment Reschedule Proposed";
|
|
406
399
|
const body = `Action Required: A new time has been proposed for your appointment for ${appointment.procedureInfo.name}. Please review in the app.`;
|
|
407
400
|
|
|
408
|
-
const
|
|
409
|
-
const clientCompatibleNotificationTime = new FirebaseClientTimestamp(
|
|
410
|
-
adminTsNow.seconds,
|
|
411
|
-
adminTsNow.nanoseconds
|
|
412
|
-
);
|
|
401
|
+
const notificationTimestampForDb = admin.firestore.Timestamp.now();
|
|
413
402
|
|
|
414
403
|
const notificationData: Omit<
|
|
415
404
|
Notification,
|
|
@@ -418,7 +407,7 @@ export class NotificationsAdmin {
|
|
|
418
407
|
userId: patientUserId,
|
|
419
408
|
userRole: UserRole.PATIENT,
|
|
420
409
|
notificationType: NotificationType.APPOINTMENT_RESCHEDULED_PROPOSAL,
|
|
421
|
-
notificationTime:
|
|
410
|
+
notificationTime: notificationTimestampForDb as any,
|
|
422
411
|
notificationTokens: patientExpoTokens,
|
|
423
412
|
title,
|
|
424
413
|
body,
|
|
@@ -460,11 +449,7 @@ export class NotificationsAdmin {
|
|
|
460
449
|
.toDate()
|
|
461
450
|
.toLocaleDateString()} is now ${appointment.paymentStatus}.`;
|
|
462
451
|
|
|
463
|
-
const
|
|
464
|
-
const clientCompatibleNotificationTime = new FirebaseClientTimestamp(
|
|
465
|
-
adminTsNow.seconds,
|
|
466
|
-
adminTsNow.nanoseconds
|
|
467
|
-
);
|
|
452
|
+
const notificationTimestampForDb = admin.firestore.Timestamp.now();
|
|
468
453
|
|
|
469
454
|
const notificationType =
|
|
470
455
|
appointment.paymentStatus === PaymentStatus.PAID
|
|
@@ -478,7 +463,7 @@ export class NotificationsAdmin {
|
|
|
478
463
|
userId: patientUserId,
|
|
479
464
|
userRole: UserRole.PATIENT,
|
|
480
465
|
notificationType: notificationType,
|
|
481
|
-
notificationTime:
|
|
466
|
+
notificationTime: notificationTimestampForDb as any,
|
|
482
467
|
notificationTokens: patientExpoTokens,
|
|
483
468
|
title,
|
|
484
469
|
body,
|
|
@@ -517,11 +502,7 @@ export class NotificationsAdmin {
|
|
|
517
502
|
const title = "Leave a Review";
|
|
518
503
|
const body = `How was your recent appointment for ${appointment.procedureInfo.name}? We'd love to hear your feedback!`;
|
|
519
504
|
|
|
520
|
-
const
|
|
521
|
-
const clientCompatibleNotificationTime = new FirebaseClientTimestamp(
|
|
522
|
-
adminTsNow.seconds,
|
|
523
|
-
adminTsNow.nanoseconds
|
|
524
|
-
);
|
|
505
|
+
const notificationTimestampForDb = admin.firestore.Timestamp.now();
|
|
525
506
|
|
|
526
507
|
const notificationData: Omit<
|
|
527
508
|
Notification,
|
|
@@ -530,7 +511,7 @@ export class NotificationsAdmin {
|
|
|
530
511
|
userId: patientUserId,
|
|
531
512
|
userRole: UserRole.PATIENT,
|
|
532
513
|
notificationType: NotificationType.REVIEW_REQUEST,
|
|
533
|
-
notificationTime:
|
|
514
|
+
notificationTime: notificationTimestampForDb as any,
|
|
534
515
|
notificationTokens: patientExpoTokens,
|
|
535
516
|
title,
|
|
536
517
|
body,
|
|
@@ -580,11 +561,7 @@ export class NotificationsAdmin {
|
|
|
580
561
|
.toDate()
|
|
581
562
|
.toLocaleDateString()}.`;
|
|
582
563
|
|
|
583
|
-
const
|
|
584
|
-
const clientCompatibleNotificationTime = new FirebaseClientTimestamp(
|
|
585
|
-
adminTsNow.seconds,
|
|
586
|
-
adminTsNow.nanoseconds
|
|
587
|
-
);
|
|
564
|
+
const notificationTimestampForDb = admin.firestore.Timestamp.now();
|
|
588
565
|
|
|
589
566
|
const tempNotificationType = NotificationType.GENERAL_MESSAGE;
|
|
590
567
|
|
|
@@ -595,7 +572,7 @@ export class NotificationsAdmin {
|
|
|
595
572
|
userId: recipientUserId,
|
|
596
573
|
userRole: UserRole.PRACTITIONER,
|
|
597
574
|
notificationType: tempNotificationType,
|
|
598
|
-
notificationTime:
|
|
575
|
+
notificationTime: notificationTimestampForDb as any,
|
|
599
576
|
notificationTokens: recipientExpoTokens,
|
|
600
577
|
title,
|
|
601
578
|
body,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { PatientProfile, PATIENTS_COLLECTION } from "../../types/patient";
|
|
18
18
|
import { UserRole } from "../../types"; // Assuming UserRole is in the main types index
|
|
19
19
|
import { NotificationsAdmin } from "../notifications/notifications.admin";
|
|
20
|
+
import { TimestampUtils } from "../../utils/TimestampUtils";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @class PatientRequirementsAdminService
|
|
@@ -106,10 +107,9 @@ export class PatientRequirementsAdminService {
|
|
|
106
107
|
...currentInstruction,
|
|
107
108
|
notificationId: undefined,
|
|
108
109
|
status: PatientInstructionStatus.CANCELLED,
|
|
109
|
-
updatedAt:
|
|
110
|
-
adminTsNow
|
|
111
|
-
|
|
112
|
-
),
|
|
110
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
111
|
+
adminTsNow
|
|
112
|
+
) as FirebaseClientTimestamp,
|
|
113
113
|
};
|
|
114
114
|
updatedInstructions[i] = currentInstruction;
|
|
115
115
|
instructionUpdatesMade = true;
|
|
@@ -144,10 +144,9 @@ export class PatientRequirementsAdminService {
|
|
|
144
144
|
currentInstruction = {
|
|
145
145
|
...currentInstruction,
|
|
146
146
|
notificationId: undefined,
|
|
147
|
-
updatedAt:
|
|
148
|
-
adminTsNow
|
|
149
|
-
|
|
150
|
-
),
|
|
147
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
148
|
+
adminTsNow
|
|
149
|
+
) as FirebaseClientTimestamp,
|
|
151
150
|
};
|
|
152
151
|
updatedInstructions[i] = currentInstruction;
|
|
153
152
|
instructionUpdatesMade = true;
|
|
@@ -177,7 +176,7 @@ export class PatientRequirementsAdminService {
|
|
|
177
176
|
userId: patientId,
|
|
178
177
|
userRole: UserRole.PATIENT,
|
|
179
178
|
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE,
|
|
180
|
-
notificationTime: currentInstruction.dueTime, //
|
|
179
|
+
notificationTime: currentInstruction.dueTime as any, // dueTime should be an admin.firestore.Timestamp already
|
|
181
180
|
notificationTokens: patientExpoTokens,
|
|
182
181
|
title: `Reminder: ${instance.requirementName}`,
|
|
183
182
|
body: currentInstruction.instructionText,
|
|
@@ -196,10 +195,9 @@ export class PatientRequirementsAdminService {
|
|
|
196
195
|
...currentInstruction,
|
|
197
196
|
notificationId: createdNotificationId,
|
|
198
197
|
status: PatientInstructionStatus.PENDING_NOTIFICATION,
|
|
199
|
-
updatedAt:
|
|
200
|
-
adminTsNow
|
|
201
|
-
|
|
202
|
-
),
|
|
198
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
199
|
+
adminTsNow
|
|
200
|
+
) as FirebaseClientTimestamp,
|
|
203
201
|
};
|
|
204
202
|
updatedInstructions[i] = currentInstruction;
|
|
205
203
|
instructionUpdatesMade = true;
|
|
@@ -225,10 +223,9 @@ export class PatientRequirementsAdminService {
|
|
|
225
223
|
const finalAdminTsNow = admin.firestore.Timestamp.now();
|
|
226
224
|
await instanceDocRef.update({
|
|
227
225
|
instructions: updatedInstructions, // Array of instructions with actual Timestamps
|
|
228
|
-
updatedAt:
|
|
229
|
-
finalAdminTsNow
|
|
230
|
-
|
|
231
|
-
),
|
|
226
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
227
|
+
finalAdminTsNow
|
|
228
|
+
) as FirebaseClientTimestamp,
|
|
232
229
|
});
|
|
233
230
|
}
|
|
234
231
|
}
|
|
@@ -332,10 +329,9 @@ export class PatientRequirementsAdminService {
|
|
|
332
329
|
currentInstruction = {
|
|
333
330
|
...currentInstruction,
|
|
334
331
|
status: PatientInstructionStatus.MISSED,
|
|
335
|
-
updatedAt:
|
|
336
|
-
adminNowForMissed
|
|
337
|
-
|
|
338
|
-
),
|
|
332
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
333
|
+
adminNowForMissed
|
|
334
|
+
) as FirebaseClientTimestamp,
|
|
339
335
|
};
|
|
340
336
|
updatedInstructions[i] = currentInstruction;
|
|
341
337
|
changesMade = true;
|
|
@@ -349,10 +345,9 @@ export class PatientRequirementsAdminService {
|
|
|
349
345
|
const finalAdminNowForMissedUpdate = admin.firestore.Timestamp.now();
|
|
350
346
|
await instanceRef.update({
|
|
351
347
|
instructions: updatedInstructions, // Array of instructions with actual Timestamps
|
|
352
|
-
updatedAt:
|
|
353
|
-
finalAdminNowForMissedUpdate
|
|
354
|
-
|
|
355
|
-
),
|
|
348
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
349
|
+
finalAdminNowForMissedUpdate
|
|
350
|
+
) as FirebaseClientTimestamp,
|
|
356
351
|
});
|
|
357
352
|
console.log(
|
|
358
353
|
`[PRA_Service] Updated missed instructions for instance ${instanceId}.`
|
|
@@ -416,10 +411,9 @@ export class PatientRequirementsAdminService {
|
|
|
416
411
|
);
|
|
417
412
|
await instanceRef.update({
|
|
418
413
|
overallStatus: PatientRequirementOverallStatus.ACTIVE,
|
|
419
|
-
updatedAt:
|
|
420
|
-
admin.firestore.Timestamp.now()
|
|
421
|
-
|
|
422
|
-
),
|
|
414
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
415
|
+
admin.firestore.Timestamp.now()
|
|
416
|
+
) as FirebaseClientTimestamp,
|
|
423
417
|
});
|
|
424
418
|
}
|
|
425
419
|
return;
|
|
@@ -468,10 +462,9 @@ export class PatientRequirementsAdminService {
|
|
|
468
462
|
const adminTsNow = admin.firestore.Timestamp.now();
|
|
469
463
|
await instanceRef.update({
|
|
470
464
|
overallStatus: newOverallStatus,
|
|
471
|
-
updatedAt:
|
|
472
|
-
adminTsNow
|
|
473
|
-
|
|
474
|
-
),
|
|
465
|
+
updatedAt: TimestampUtils.adminToClient(
|
|
466
|
+
adminTsNow
|
|
467
|
+
) as FirebaseClientTimestamp,
|
|
475
468
|
});
|
|
476
469
|
} else {
|
|
477
470
|
console.log(
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import { Timestamp, FieldValue } from
|
|
2
|
-
import type { ProcedureFamily } from
|
|
3
|
-
import type { TreatmentBenefit } from
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import type { ClinicInfo } from "../profile";
|
|
9
|
-
import { ClinicReviewInfo } from "../reviews";
|
|
10
|
-
import { ProcedureSummaryInfo } from "../procedure";
|
|
1
|
+
import { Timestamp, FieldValue } from 'firebase/firestore';
|
|
2
|
+
import type { ProcedureFamily } from '../../backoffice/types/static/procedure-family.types';
|
|
3
|
+
import type { TreatmentBenefit } from '../../backoffice/types/static/treatment-benefit.types';
|
|
4
|
+
import type { Currency, PricingMeasure } from '../../backoffice/types/static/pricing.types';
|
|
5
|
+
import type { ClinicInfo } from '../profile';
|
|
6
|
+
import { ClinicReviewInfo } from '../reviews';
|
|
7
|
+
import { ProcedureSummaryInfo } from '../procedure';
|
|
11
8
|
|
|
12
|
-
export const CLINIC_GROUPS_COLLECTION =
|
|
13
|
-
export const CLINIC_ADMINS_COLLECTION =
|
|
14
|
-
export const CLINICS_COLLECTION =
|
|
9
|
+
export const CLINIC_GROUPS_COLLECTION = 'clinic_groups';
|
|
10
|
+
export const CLINIC_ADMINS_COLLECTION = 'clinic_admins';
|
|
11
|
+
export const CLINICS_COLLECTION = 'clinics';
|
|
15
12
|
|
|
16
|
-
import {
|
|
17
|
-
PracticeType,
|
|
18
|
-
Language,
|
|
19
|
-
ClinicTag,
|
|
20
|
-
ClinicPhotoTag,
|
|
21
|
-
} from "./preferences.types";
|
|
13
|
+
import { PracticeType, Language, ClinicTag, ClinicPhotoTag } from './preferences.types';
|
|
22
14
|
|
|
23
|
-
export * from
|
|
15
|
+
export * from './preferences.types';
|
|
24
16
|
|
|
25
17
|
/**
|
|
26
18
|
* Interface for clinic contact information
|
|
@@ -140,9 +132,9 @@ export interface UpdateClinicAdminData extends Partial<CreateClinicAdminData> {
|
|
|
140
132
|
* Enum for admin token status
|
|
141
133
|
*/
|
|
142
134
|
export enum AdminTokenStatus {
|
|
143
|
-
ACTIVE =
|
|
144
|
-
USED =
|
|
145
|
-
EXPIRED =
|
|
135
|
+
ACTIVE = 'active',
|
|
136
|
+
USED = 'used',
|
|
137
|
+
EXPIRED = 'expired',
|
|
146
138
|
}
|
|
147
139
|
|
|
148
140
|
/**
|
|
@@ -171,10 +163,10 @@ export interface AdminInfo {
|
|
|
171
163
|
* Enum for subscription models
|
|
172
164
|
*/
|
|
173
165
|
export enum SubscriptionModel {
|
|
174
|
-
NO_SUBSCRIPTION =
|
|
175
|
-
BASIC =
|
|
176
|
-
PREMIUM =
|
|
177
|
-
ENTERPRISE =
|
|
166
|
+
NO_SUBSCRIPTION = 'no_subscription',
|
|
167
|
+
BASIC = 'basic',
|
|
168
|
+
PREMIUM = 'premium',
|
|
169
|
+
ENTERPRISE = 'enterprise',
|
|
178
170
|
}
|
|
179
171
|
|
|
180
172
|
/**
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { Timestamp, FieldValue } from
|
|
2
|
-
import { User } from
|
|
3
|
-
import type { PatientMedicalInfo } from
|
|
4
|
-
import { PATIENT_MEDICAL_INFO_COLLECTION } from
|
|
1
|
+
import { Timestamp, FieldValue } from 'firebase/firestore';
|
|
2
|
+
import { User } from '..';
|
|
3
|
+
import type { PatientMedicalInfo } from './medical-info.types';
|
|
4
|
+
import { PATIENT_MEDICAL_INFO_COLLECTION } from './medical-info.types';
|
|
5
5
|
|
|
6
|
-
export const PATIENTS_COLLECTION =
|
|
7
|
-
export const PATIENT_SENSITIVE_INFO_COLLECTION =
|
|
8
|
-
export const PATIENT_MEDICAL_HISTORY_COLLECTION =
|
|
9
|
-
export const PATIENT_APPOINTMENTS_COLLECTION =
|
|
10
|
-
export const PATIENT_LOCATION_INFO_COLLECTION =
|
|
6
|
+
export const PATIENTS_COLLECTION = 'patients';
|
|
7
|
+
export const PATIENT_SENSITIVE_INFO_COLLECTION = 'sensitive-info';
|
|
8
|
+
export const PATIENT_MEDICAL_HISTORY_COLLECTION = 'medical-history';
|
|
9
|
+
export const PATIENT_APPOINTMENTS_COLLECTION = 'appointments';
|
|
10
|
+
export const PATIENT_LOCATION_INFO_COLLECTION = 'location-info';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Enumeracija za pol pacijenta
|
|
14
14
|
*/
|
|
15
15
|
export enum Gender {
|
|
16
|
-
MALE =
|
|
17
|
-
FEMALE =
|
|
18
|
-
TRANSGENDER_MALE =
|
|
19
|
-
TRANSGENDER_FEMALE =
|
|
20
|
-
PREFER_NOT_TO_SAY =
|
|
21
|
-
OTHER =
|
|
16
|
+
MALE = 'male',
|
|
17
|
+
FEMALE = 'female',
|
|
18
|
+
TRANSGENDER_MALE = 'transgender_male',
|
|
19
|
+
TRANSGENDER_FEMALE = 'transgender_female',
|
|
20
|
+
PREFER_NOT_TO_SAY = 'prefer_not_to_say',
|
|
21
|
+
OTHER = 'other',
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -83,8 +83,7 @@ export interface CreatePatientLocationInfoData {
|
|
|
83
83
|
/**
|
|
84
84
|
* Tip za ažuriranje lokacijskih informacija
|
|
85
85
|
*/
|
|
86
|
-
export interface UpdatePatientLocationInfoData
|
|
87
|
-
extends Partial<CreatePatientLocationInfoData> {
|
|
86
|
+
export interface UpdatePatientLocationInfoData extends Partial<CreatePatientLocationInfoData> {
|
|
88
87
|
updatedAt?: FieldValue;
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -129,8 +128,7 @@ export interface CreatePatientSensitiveInfoData {
|
|
|
129
128
|
/**
|
|
130
129
|
* Tip za ažuriranje osetljivih informacija
|
|
131
130
|
*/
|
|
132
|
-
export interface UpdatePatientSensitiveInfoData
|
|
133
|
-
extends Partial<CreatePatientSensitiveInfoData> {
|
|
131
|
+
export interface UpdatePatientSensitiveInfoData extends Partial<CreatePatientSensitiveInfoData> {
|
|
134
132
|
updatedAt?: FieldValue;
|
|
135
133
|
}
|
|
136
134
|
|
|
@@ -198,7 +196,7 @@ export interface CreatePatientProfileData {
|
|
|
198
196
|
* Tip za ažuriranje Patient profila
|
|
199
197
|
*/
|
|
200
198
|
export interface UpdatePatientProfileData
|
|
201
|
-
extends Partial<Omit<PatientProfile,
|
|
199
|
+
extends Partial<Omit<PatientProfile, 'id' | 'createdAt' | 'updatedAt'>> {
|
|
202
200
|
// Use Omit to exclude base fields
|
|
203
201
|
updatedAt?: FieldValue;
|
|
204
202
|
// Note: doctors, clinics, doctorIds, clinicIds should ideally be updated via specific methods (add/removeDoctor/Clinic)
|
|
@@ -221,14 +219,14 @@ export interface RequesterInfo {
|
|
|
221
219
|
/** ID of the clinic admin user or practitioner user making the request. */
|
|
222
220
|
id: string;
|
|
223
221
|
/** Role of the requester, determining the search context. */
|
|
224
|
-
role:
|
|
222
|
+
role: 'clinic_admin' | 'practitioner';
|
|
225
223
|
/** If role is 'clinic_admin', this is the associated clinic ID. */
|
|
226
224
|
associatedClinicId?: string;
|
|
227
225
|
/** If role is 'practitioner', this is the associated practitioner profile ID. */
|
|
228
226
|
associatedPractitionerId?: string;
|
|
229
227
|
}
|
|
230
228
|
|
|
231
|
-
export * from
|
|
229
|
+
export * from './medical-info.types';
|
|
232
230
|
|
|
233
231
|
// This is a type that combines all the patient data - used only in UI Frontend App
|
|
234
232
|
export interface PatientProfileComplete {
|