@blackcode_sa/metaestetics-api 1.6.4 → 1.6.6
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 +236 -2
- package/dist/admin/index.d.ts +236 -2
- package/dist/admin/index.js +11251 -10447
- package/dist/admin/index.mjs +11251 -10447
- package/dist/backoffice/index.d.mts +2 -0
- package/dist/backoffice/index.d.ts +2 -0
- package/dist/index.d.mts +50 -77
- package/dist/index.d.ts +50 -77
- package/dist/index.js +77 -305
- package/dist/index.mjs +78 -306
- package/package.json +1 -1
- package/src/admin/aggregation/appointment/README.md +128 -0
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +1053 -0
- package/src/admin/booking/README.md +125 -0
- package/src/admin/booking/booking.admin.ts +638 -3
- package/src/admin/calendar/calendar.admin.service.ts +183 -0
- package/src/admin/documentation-templates/document-manager.admin.ts +131 -0
- package/src/admin/mailing/appointment/appointment.mailing.service.ts +264 -0
- package/src/admin/mailing/appointment/templates/patient/appointment-confirmed.html +40 -0
- package/src/admin/mailing/base.mailing.service.ts +1 -1
- package/src/admin/mailing/index.ts +2 -0
- package/src/admin/notifications/notifications.admin.ts +397 -1
- package/src/backoffice/types/product.types.ts +2 -0
- package/src/services/appointment/appointment.service.ts +89 -182
- package/src/services/procedure/procedure.service.ts +1 -0
- package/src/types/appointment/index.ts +3 -1
- package/src/types/notifications/index.ts +4 -2
- package/src/types/procedure/index.ts +7 -0
- package/src/validations/appointment.schema.ts +2 -3
- package/src/validations/procedure.schema.ts +3 -0
package/dist/admin/index.d.mts
CHANGED
|
@@ -171,6 +171,17 @@ interface DocumentTemplate {
|
|
|
171
171
|
version: number;
|
|
172
172
|
isActive: boolean;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Enum for filled document status
|
|
176
|
+
*/
|
|
177
|
+
declare enum FilledDocumentStatus {
|
|
178
|
+
DRAFT = "draft",
|
|
179
|
+
SKIPPED = "skipped",
|
|
180
|
+
PENDING = "pending",
|
|
181
|
+
COMPLETED = "completed",// When doctor or patient completes the form
|
|
182
|
+
SIGNED = "signed",// Only used for user forms
|
|
183
|
+
REJECTED = "rejected"
|
|
184
|
+
}
|
|
174
185
|
|
|
175
186
|
/**
|
|
176
187
|
* Nivoi sertifikacije medicinskog osoblja, poređani od najnižeg do najvišeg
|
|
@@ -511,7 +522,9 @@ interface Product {
|
|
|
511
522
|
id?: string;
|
|
512
523
|
name: string;
|
|
513
524
|
brandId: string;
|
|
525
|
+
brandName: string;
|
|
514
526
|
technologyId: string;
|
|
527
|
+
technologyName: string;
|
|
515
528
|
createdAt: Date;
|
|
516
529
|
updatedAt: Date;
|
|
517
530
|
isActive: boolean;
|
|
@@ -549,6 +562,8 @@ interface Procedure {
|
|
|
549
562
|
id: string;
|
|
550
563
|
/** Name of the procedure */
|
|
551
564
|
name: string;
|
|
565
|
+
/** Photos of the procedure */
|
|
566
|
+
photos?: string[];
|
|
552
567
|
/** Detailed description of the procedure */
|
|
553
568
|
description: string;
|
|
554
569
|
/** Family of procedures this belongs to (aesthetics/surgery) */
|
|
@@ -573,6 +588,8 @@ interface Procedure {
|
|
|
573
588
|
blockingConditions: BlockingCondition[];
|
|
574
589
|
/** Treatment benefits of this procedure */
|
|
575
590
|
treatmentBenefits: TreatmentBenefit[];
|
|
591
|
+
/** Contraindications of this procedure */
|
|
592
|
+
contraindications: Contraindication[];
|
|
576
593
|
/** Pre-procedure requirements */
|
|
577
594
|
preRequirements: Requirement[];
|
|
578
595
|
/** Post-procedure requirements */
|
|
@@ -1126,6 +1143,8 @@ declare enum NotificationType {
|
|
|
1126
1143
|
APPOINTMENT_STATUS_CHANGE = "appointmentStatusChange",// Generic for status changes like confirmed, checked-in etc.
|
|
1127
1144
|
APPOINTMENT_RESCHEDULED_PROPOSAL = "appointmentRescheduledProposal",// When clinic proposes a new time
|
|
1128
1145
|
APPOINTMENT_CANCELLED = "appointmentCancelled",// When an appointment is cancelled
|
|
1146
|
+
PRE_REQUIREMENT_INSTRUCTION_DUE = "preRequirementInstructionDue",
|
|
1147
|
+
POST_REQUIREMENT_INSTRUCTION_DUE = "postRequirementInstructionDue",
|
|
1129
1148
|
REQUIREMENT_INSTRUCTION_DUE = "requirementInstructionDue",// For specific pre/post care instructions
|
|
1130
1149
|
FORM_REMINDER = "formReminder",// Reminds user to fill a specific form
|
|
1131
1150
|
FORM_SUBMISSION_CONFIRMATION = "formSubmissionConfirmation",// Confirms form was submitted
|
|
@@ -1192,7 +1211,7 @@ declare enum NotificationStatus {
|
|
|
1192
1211
|
* Notifikacija za pre-requirement
|
|
1193
1212
|
*/
|
|
1194
1213
|
interface PreRequirementNotification extends BaseNotification {
|
|
1195
|
-
notificationType: NotificationType.
|
|
1214
|
+
notificationType: NotificationType.PRE_REQUIREMENT_INSTRUCTION_DUE;
|
|
1196
1215
|
/** ID tretmana za koji je vezan pre-requirement */
|
|
1197
1216
|
treatmentId: string;
|
|
1198
1217
|
/** Lista pre-requirements koji treba da se ispune */
|
|
@@ -1204,7 +1223,7 @@ interface PreRequirementNotification extends BaseNotification {
|
|
|
1204
1223
|
* Notifikacija za post-requirement
|
|
1205
1224
|
*/
|
|
1206
1225
|
interface PostRequirementNotification extends BaseNotification {
|
|
1207
|
-
notificationType: NotificationType.
|
|
1226
|
+
notificationType: NotificationType.POST_REQUIREMENT_INSTRUCTION_DUE;
|
|
1208
1227
|
/** ID tretmana za koji je vezan post-requirement */
|
|
1209
1228
|
treatmentId: string;
|
|
1210
1229
|
/** Lista post-requirements koji treba da se ispune */
|
|
@@ -1316,6 +1335,177 @@ interface PaymentConfirmationNotification extends BaseNotification {
|
|
|
1316
1335
|
*/
|
|
1317
1336
|
type Notification = PreRequirementNotification | PostRequirementNotification | RequirementInstructionDueNotification | AppointmentReminderNotification | AppointmentStatusChangeNotification | AppointmentRescheduledProposalNotification | AppointmentCancelledNotification | FormReminderNotification | FormSubmissionConfirmationNotification | ReviewRequestNotification | GeneralMessageNotification | PaymentConfirmationNotification;
|
|
1318
1337
|
|
|
1338
|
+
/**
|
|
1339
|
+
* Enum defining the possible statuses of an appointment.
|
|
1340
|
+
*/
|
|
1341
|
+
declare enum AppointmentStatus {
|
|
1342
|
+
PENDING = "pending",// Initial state after booking, before confirmation (if applicable)
|
|
1343
|
+
CONFIRMED = "confirmed",// Confirmed by clinic/practitioner
|
|
1344
|
+
CHECKED_IN = "checked_in",// Patient has arrived
|
|
1345
|
+
IN_PROGRESS = "in_progress",// Procedure has started
|
|
1346
|
+
COMPLETED = "completed",// Procedure finished successfully
|
|
1347
|
+
CANCELED_PATIENT = "canceled_patient",// Canceled by the patient
|
|
1348
|
+
CANCELED_PATIENT_RESCHEDULED = "canceled_patient_rescheduled",// Canceled by the patient and rescheduled by the clinic
|
|
1349
|
+
CANCELED_CLINIC = "canceled_clinic",// Canceled by the clinic/practitioner
|
|
1350
|
+
NO_SHOW = "no_show",// Patient did not attend
|
|
1351
|
+
RESCHEDULED_BY_CLINIC = "rescheduled_by_clinic"
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Enum defining the payment status of an appointment.
|
|
1355
|
+
*/
|
|
1356
|
+
declare enum PaymentStatus {
|
|
1357
|
+
UNPAID = "unpaid",
|
|
1358
|
+
PAID = "paid",
|
|
1359
|
+
PARTIALLY_PAID = "partially_paid",
|
|
1360
|
+
REFUNDED = "refunded",
|
|
1361
|
+
NOT_APPLICABLE = "not_applicable"
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Enum for different types of media that can be attached to an appointment.
|
|
1365
|
+
*/
|
|
1366
|
+
declare enum MediaType {
|
|
1367
|
+
BEFORE_PHOTO = "before_photo",
|
|
1368
|
+
AFTER_PHOTO = "after_photo",
|
|
1369
|
+
CONSENT_SCAN = "consent_scan",
|
|
1370
|
+
OTHER_DOCUMENT = "other_document"
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Interface to describe a media file linked to an appointment.
|
|
1374
|
+
*/
|
|
1375
|
+
interface AppointmentMediaItem {
|
|
1376
|
+
id: string;
|
|
1377
|
+
type: MediaType;
|
|
1378
|
+
url: string;
|
|
1379
|
+
fileName?: string;
|
|
1380
|
+
uploadedAt: Timestamp;
|
|
1381
|
+
uploadedBy: string;
|
|
1382
|
+
description?: string;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Interface for procedure-specific information
|
|
1386
|
+
*/
|
|
1387
|
+
interface ProcedureExtendedInfo {
|
|
1388
|
+
id: string;
|
|
1389
|
+
name: string;
|
|
1390
|
+
description: string;
|
|
1391
|
+
cost: number;
|
|
1392
|
+
duration: number;
|
|
1393
|
+
procedureFamily: ProcedureFamily;
|
|
1394
|
+
procedureCategoryId: string;
|
|
1395
|
+
procedureCategoryName: string;
|
|
1396
|
+
procedureSubCategoryId: string;
|
|
1397
|
+
procedureSubCategoryName: string;
|
|
1398
|
+
procedureTechnologyId: string;
|
|
1399
|
+
procedureTechnologyName: string;
|
|
1400
|
+
procedureProductBrandId: string;
|
|
1401
|
+
procedureProductBrandName: string;
|
|
1402
|
+
procedureProductId: string;
|
|
1403
|
+
procedureProductName: string;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Interface to describe a filled form linked to an appointment.
|
|
1407
|
+
*/
|
|
1408
|
+
interface LinkedFormInfo {
|
|
1409
|
+
formId: string;
|
|
1410
|
+
templateId: string;
|
|
1411
|
+
templateVersion: number;
|
|
1412
|
+
title: string;
|
|
1413
|
+
isUserForm: boolean;
|
|
1414
|
+
isRequired?: boolean;
|
|
1415
|
+
status: FilledDocumentStatus;
|
|
1416
|
+
path: string;
|
|
1417
|
+
submittedAt?: Timestamp;
|
|
1418
|
+
completedAt?: Timestamp;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Interface for summarized patient review information linked to an appointment.
|
|
1422
|
+
*/
|
|
1423
|
+
interface PatientReviewInfo {
|
|
1424
|
+
reviewId: string;
|
|
1425
|
+
rating: number;
|
|
1426
|
+
comment?: string;
|
|
1427
|
+
reviewedAt: Timestamp;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Represents a booked appointment, aggregating key information and relevant procedure rules.
|
|
1431
|
+
*/
|
|
1432
|
+
interface Appointment {
|
|
1433
|
+
/** Unique identifier for the appointment */
|
|
1434
|
+
id: string;
|
|
1435
|
+
/** Reference to the associated CalendarEvent */
|
|
1436
|
+
calendarEventId: string;
|
|
1437
|
+
/** ID of the clinic branch */
|
|
1438
|
+
clinicBranchId: string;
|
|
1439
|
+
/** Aggregated clinic information (snapshot) */
|
|
1440
|
+
clinicInfo: ClinicInfo;
|
|
1441
|
+
/** ID of the practitioner */
|
|
1442
|
+
practitionerId: string;
|
|
1443
|
+
/** Aggregated practitioner information (snapshot) */
|
|
1444
|
+
practitionerInfo: PractitionerProfileInfo;
|
|
1445
|
+
/** ID of the patient */
|
|
1446
|
+
patientId: string;
|
|
1447
|
+
/** Aggregated patient information (snapshot) */
|
|
1448
|
+
patientInfo: PatientProfileInfo;
|
|
1449
|
+
/** ID of the procedure */
|
|
1450
|
+
procedureId: string;
|
|
1451
|
+
/** Aggregated procedure information including product/brand (snapshot) */
|
|
1452
|
+
procedureInfo: ProcedureSummaryInfo;
|
|
1453
|
+
/** Extended procedure information */
|
|
1454
|
+
procedureExtendedInfo: ProcedureExtendedInfo;
|
|
1455
|
+
/** Status of the appointment */
|
|
1456
|
+
status: AppointmentStatus;
|
|
1457
|
+
/** Timestamps */
|
|
1458
|
+
bookingTime: Timestamp;
|
|
1459
|
+
confirmationTime?: Timestamp | null;
|
|
1460
|
+
cancellationTime?: Timestamp | null;
|
|
1461
|
+
rescheduleTime?: Timestamp | null;
|
|
1462
|
+
appointmentStartTime: Timestamp;
|
|
1463
|
+
appointmentEndTime: Timestamp;
|
|
1464
|
+
procedureActualStartTime?: Timestamp | null;
|
|
1465
|
+
actualDurationMinutes?: number;
|
|
1466
|
+
/** Cancellation Details */
|
|
1467
|
+
cancellationReason?: string | null;
|
|
1468
|
+
canceledBy?: "patient" | "clinic" | "practitioner" | "system";
|
|
1469
|
+
/** Notes */
|
|
1470
|
+
internalNotes?: string | null;
|
|
1471
|
+
patientNotes?: string | null;
|
|
1472
|
+
/** Payment Details */
|
|
1473
|
+
cost: number;
|
|
1474
|
+
currency: Currency;
|
|
1475
|
+
paymentStatus: PaymentStatus;
|
|
1476
|
+
paymentTransactionId?: string | null;
|
|
1477
|
+
/** Procedure-related conditions and requirements */
|
|
1478
|
+
blockingConditions: BlockingCondition[];
|
|
1479
|
+
contraindications: Contraindication[];
|
|
1480
|
+
preProcedureRequirements: Requirement[];
|
|
1481
|
+
postProcedureRequirements: Requirement[];
|
|
1482
|
+
/** Tracking information for requirements completion */
|
|
1483
|
+
completedPreRequirements?: string[];
|
|
1484
|
+
completedPostRequirements?: string[];
|
|
1485
|
+
/** NEW: Linked forms (consent, procedure-specific forms, etc.) */
|
|
1486
|
+
linkedFormIds?: string[];
|
|
1487
|
+
linkedForms?: LinkedFormInfo[];
|
|
1488
|
+
pendingUserFormsIds?: string[];
|
|
1489
|
+
/** NEW: Media items (before/after photos, scanned documents, etc.) */
|
|
1490
|
+
media?: AppointmentMediaItem[];
|
|
1491
|
+
/** NEW: Information about the patient's review for this appointment */
|
|
1492
|
+
reviewInfo?: PatientReviewInfo | null;
|
|
1493
|
+
/** NEW: Details about the finalization of the appointment by the practitioner */
|
|
1494
|
+
finalizedDetails?: {
|
|
1495
|
+
by: string;
|
|
1496
|
+
at: Timestamp;
|
|
1497
|
+
notes?: string;
|
|
1498
|
+
};
|
|
1499
|
+
/** Timestamps for record creation and updates */
|
|
1500
|
+
createdAt: Timestamp;
|
|
1501
|
+
updatedAt: Timestamp;
|
|
1502
|
+
/** Recurring appointment information */
|
|
1503
|
+
isRecurring?: boolean;
|
|
1504
|
+
recurringAppointmentId?: string | null;
|
|
1505
|
+
/** NEW: Flag for soft deletion or archiving */
|
|
1506
|
+
isArchived?: boolean;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1319
1509
|
declare class NotificationsAdmin {
|
|
1320
1510
|
private expo;
|
|
1321
1511
|
private db;
|
|
@@ -1348,6 +1538,19 @@ declare class NotificationsAdmin {
|
|
|
1348
1538
|
* Briše stare notifikacije sa batch procesiranjem
|
|
1349
1539
|
*/
|
|
1350
1540
|
cleanupOldNotifications(daysOld?: number, batchSize?: number): Promise<void>;
|
|
1541
|
+
/**
|
|
1542
|
+
* Creates and potentially sends a push notification for a confirmed appointment.
|
|
1543
|
+
* @param appointment The confirmed appointment object.
|
|
1544
|
+
* @param recipientUserId The ID of the user receiving the notification.
|
|
1545
|
+
* @param recipientExpoTokens Array of Expo push tokens for the recipient.
|
|
1546
|
+
* @param recipientRole The role of the recipient (e.g., PATIENT, PRACTITIONER).
|
|
1547
|
+
*/
|
|
1548
|
+
sendAppointmentConfirmedPush(appointment: Appointment, recipientUserId: string, recipientExpoTokens: string[], recipientRole: UserRole): Promise<string | null>;
|
|
1549
|
+
sendAppointmentCancelledPush(appointment: Appointment, recipientUserId: string, recipientExpoTokens: string[], recipientRole: UserRole): Promise<string | null>;
|
|
1550
|
+
sendAppointmentRescheduledProposalPush(appointment: Appointment, patientUserId: string, patientExpoTokens: string[]): Promise<string | null>;
|
|
1551
|
+
sendPaymentUpdatePush(appointment: Appointment, patientUserId: string, patientExpoTokens: string[]): Promise<string | null>;
|
|
1552
|
+
sendReviewRequestPush(appointment: Appointment, patientUserId: string, patientExpoTokens: string[]): Promise<string | null>;
|
|
1553
|
+
sendReviewAddedPush(appointment: Appointment, recipientUserId: string, recipientExpoTokens: string[], recipientRole: UserRole): Promise<string | null>;
|
|
1351
1554
|
}
|
|
1352
1555
|
|
|
1353
1556
|
/**
|
|
@@ -1722,12 +1925,23 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
|
1722
1925
|
}): Promise<void>;
|
|
1723
1926
|
}
|
|
1724
1927
|
|
|
1928
|
+
/**
|
|
1929
|
+
* Interface for the data required by orchestrateAppointmentCreation
|
|
1930
|
+
*/
|
|
1931
|
+
interface OrchestrateAppointmentCreationData {
|
|
1932
|
+
patientId: string;
|
|
1933
|
+
procedureId: string;
|
|
1934
|
+
appointmentStartTime: admin.firestore.Timestamp;
|
|
1935
|
+
appointmentEndTime: admin.firestore.Timestamp;
|
|
1936
|
+
patientNotes?: string | null;
|
|
1937
|
+
}
|
|
1725
1938
|
/**
|
|
1726
1939
|
* Admin service for handling booking-related operations.
|
|
1727
1940
|
* This is the cloud-based implementation that will be used in Cloud Functions.
|
|
1728
1941
|
*/
|
|
1729
1942
|
declare class BookingAdmin {
|
|
1730
1943
|
private db;
|
|
1944
|
+
private documentManagerAdmin;
|
|
1731
1945
|
/**
|
|
1732
1946
|
* Creates a new BookingAdmin instance
|
|
1733
1947
|
* @param firestore - Firestore instance provided by the caller
|
|
@@ -1776,6 +1990,26 @@ declare class BookingAdmin {
|
|
|
1776
1990
|
* @returns Promise resolving to an array of calendar events
|
|
1777
1991
|
*/
|
|
1778
1992
|
private getPractitionerCalendarEvents;
|
|
1993
|
+
private _generateCalendarProcedureInfo;
|
|
1994
|
+
/**
|
|
1995
|
+
* Orchestrates the creation of a new appointment, including data aggregation.
|
|
1996
|
+
* This method is intended to be called from a trusted backend environment (e.g., an Express route handler in a Cloud Function).
|
|
1997
|
+
*
|
|
1998
|
+
* @param data - Data required to create the appointment.
|
|
1999
|
+
* @param authenticatedUserId - The ID of the user making the request (for auditing, and usually is the patientId).
|
|
2000
|
+
* @returns Promise resolving to an object indicating success, and appointmentId or an error message.
|
|
2001
|
+
*/
|
|
2002
|
+
orchestrateAppointmentCreation(data: OrchestrateAppointmentCreationData, authenticatedUserId: string): Promise<{
|
|
2003
|
+
success: boolean;
|
|
2004
|
+
appointmentId?: string;
|
|
2005
|
+
appointmentData?: Appointment;
|
|
2006
|
+
practitionerCalendarEventId?: string;
|
|
2007
|
+
patientCalendarEventId?: string;
|
|
2008
|
+
clinicCalendarEventId?: string;
|
|
2009
|
+
error?: string;
|
|
2010
|
+
}>;
|
|
2011
|
+
private _generateProcedureSummaryInfo;
|
|
2012
|
+
private _generateProcedureExtendedInfo;
|
|
1779
2013
|
}
|
|
1780
2014
|
|
|
1781
2015
|
/**
|
package/dist/admin/index.d.ts
CHANGED
|
@@ -171,6 +171,17 @@ interface DocumentTemplate {
|
|
|
171
171
|
version: number;
|
|
172
172
|
isActive: boolean;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Enum for filled document status
|
|
176
|
+
*/
|
|
177
|
+
declare enum FilledDocumentStatus {
|
|
178
|
+
DRAFT = "draft",
|
|
179
|
+
SKIPPED = "skipped",
|
|
180
|
+
PENDING = "pending",
|
|
181
|
+
COMPLETED = "completed",// When doctor or patient completes the form
|
|
182
|
+
SIGNED = "signed",// Only used for user forms
|
|
183
|
+
REJECTED = "rejected"
|
|
184
|
+
}
|
|
174
185
|
|
|
175
186
|
/**
|
|
176
187
|
* Nivoi sertifikacije medicinskog osoblja, poređani od najnižeg do najvišeg
|
|
@@ -511,7 +522,9 @@ interface Product {
|
|
|
511
522
|
id?: string;
|
|
512
523
|
name: string;
|
|
513
524
|
brandId: string;
|
|
525
|
+
brandName: string;
|
|
514
526
|
technologyId: string;
|
|
527
|
+
technologyName: string;
|
|
515
528
|
createdAt: Date;
|
|
516
529
|
updatedAt: Date;
|
|
517
530
|
isActive: boolean;
|
|
@@ -549,6 +562,8 @@ interface Procedure {
|
|
|
549
562
|
id: string;
|
|
550
563
|
/** Name of the procedure */
|
|
551
564
|
name: string;
|
|
565
|
+
/** Photos of the procedure */
|
|
566
|
+
photos?: string[];
|
|
552
567
|
/** Detailed description of the procedure */
|
|
553
568
|
description: string;
|
|
554
569
|
/** Family of procedures this belongs to (aesthetics/surgery) */
|
|
@@ -573,6 +588,8 @@ interface Procedure {
|
|
|
573
588
|
blockingConditions: BlockingCondition[];
|
|
574
589
|
/** Treatment benefits of this procedure */
|
|
575
590
|
treatmentBenefits: TreatmentBenefit[];
|
|
591
|
+
/** Contraindications of this procedure */
|
|
592
|
+
contraindications: Contraindication[];
|
|
576
593
|
/** Pre-procedure requirements */
|
|
577
594
|
preRequirements: Requirement[];
|
|
578
595
|
/** Post-procedure requirements */
|
|
@@ -1126,6 +1143,8 @@ declare enum NotificationType {
|
|
|
1126
1143
|
APPOINTMENT_STATUS_CHANGE = "appointmentStatusChange",// Generic for status changes like confirmed, checked-in etc.
|
|
1127
1144
|
APPOINTMENT_RESCHEDULED_PROPOSAL = "appointmentRescheduledProposal",// When clinic proposes a new time
|
|
1128
1145
|
APPOINTMENT_CANCELLED = "appointmentCancelled",// When an appointment is cancelled
|
|
1146
|
+
PRE_REQUIREMENT_INSTRUCTION_DUE = "preRequirementInstructionDue",
|
|
1147
|
+
POST_REQUIREMENT_INSTRUCTION_DUE = "postRequirementInstructionDue",
|
|
1129
1148
|
REQUIREMENT_INSTRUCTION_DUE = "requirementInstructionDue",// For specific pre/post care instructions
|
|
1130
1149
|
FORM_REMINDER = "formReminder",// Reminds user to fill a specific form
|
|
1131
1150
|
FORM_SUBMISSION_CONFIRMATION = "formSubmissionConfirmation",// Confirms form was submitted
|
|
@@ -1192,7 +1211,7 @@ declare enum NotificationStatus {
|
|
|
1192
1211
|
* Notifikacija za pre-requirement
|
|
1193
1212
|
*/
|
|
1194
1213
|
interface PreRequirementNotification extends BaseNotification {
|
|
1195
|
-
notificationType: NotificationType.
|
|
1214
|
+
notificationType: NotificationType.PRE_REQUIREMENT_INSTRUCTION_DUE;
|
|
1196
1215
|
/** ID tretmana za koji je vezan pre-requirement */
|
|
1197
1216
|
treatmentId: string;
|
|
1198
1217
|
/** Lista pre-requirements koji treba da se ispune */
|
|
@@ -1204,7 +1223,7 @@ interface PreRequirementNotification extends BaseNotification {
|
|
|
1204
1223
|
* Notifikacija za post-requirement
|
|
1205
1224
|
*/
|
|
1206
1225
|
interface PostRequirementNotification extends BaseNotification {
|
|
1207
|
-
notificationType: NotificationType.
|
|
1226
|
+
notificationType: NotificationType.POST_REQUIREMENT_INSTRUCTION_DUE;
|
|
1208
1227
|
/** ID tretmana za koji je vezan post-requirement */
|
|
1209
1228
|
treatmentId: string;
|
|
1210
1229
|
/** Lista post-requirements koji treba da se ispune */
|
|
@@ -1316,6 +1335,177 @@ interface PaymentConfirmationNotification extends BaseNotification {
|
|
|
1316
1335
|
*/
|
|
1317
1336
|
type Notification = PreRequirementNotification | PostRequirementNotification | RequirementInstructionDueNotification | AppointmentReminderNotification | AppointmentStatusChangeNotification | AppointmentRescheduledProposalNotification | AppointmentCancelledNotification | FormReminderNotification | FormSubmissionConfirmationNotification | ReviewRequestNotification | GeneralMessageNotification | PaymentConfirmationNotification;
|
|
1318
1337
|
|
|
1338
|
+
/**
|
|
1339
|
+
* Enum defining the possible statuses of an appointment.
|
|
1340
|
+
*/
|
|
1341
|
+
declare enum AppointmentStatus {
|
|
1342
|
+
PENDING = "pending",// Initial state after booking, before confirmation (if applicable)
|
|
1343
|
+
CONFIRMED = "confirmed",// Confirmed by clinic/practitioner
|
|
1344
|
+
CHECKED_IN = "checked_in",// Patient has arrived
|
|
1345
|
+
IN_PROGRESS = "in_progress",// Procedure has started
|
|
1346
|
+
COMPLETED = "completed",// Procedure finished successfully
|
|
1347
|
+
CANCELED_PATIENT = "canceled_patient",// Canceled by the patient
|
|
1348
|
+
CANCELED_PATIENT_RESCHEDULED = "canceled_patient_rescheduled",// Canceled by the patient and rescheduled by the clinic
|
|
1349
|
+
CANCELED_CLINIC = "canceled_clinic",// Canceled by the clinic/practitioner
|
|
1350
|
+
NO_SHOW = "no_show",// Patient did not attend
|
|
1351
|
+
RESCHEDULED_BY_CLINIC = "rescheduled_by_clinic"
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Enum defining the payment status of an appointment.
|
|
1355
|
+
*/
|
|
1356
|
+
declare enum PaymentStatus {
|
|
1357
|
+
UNPAID = "unpaid",
|
|
1358
|
+
PAID = "paid",
|
|
1359
|
+
PARTIALLY_PAID = "partially_paid",
|
|
1360
|
+
REFUNDED = "refunded",
|
|
1361
|
+
NOT_APPLICABLE = "not_applicable"
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Enum for different types of media that can be attached to an appointment.
|
|
1365
|
+
*/
|
|
1366
|
+
declare enum MediaType {
|
|
1367
|
+
BEFORE_PHOTO = "before_photo",
|
|
1368
|
+
AFTER_PHOTO = "after_photo",
|
|
1369
|
+
CONSENT_SCAN = "consent_scan",
|
|
1370
|
+
OTHER_DOCUMENT = "other_document"
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Interface to describe a media file linked to an appointment.
|
|
1374
|
+
*/
|
|
1375
|
+
interface AppointmentMediaItem {
|
|
1376
|
+
id: string;
|
|
1377
|
+
type: MediaType;
|
|
1378
|
+
url: string;
|
|
1379
|
+
fileName?: string;
|
|
1380
|
+
uploadedAt: Timestamp;
|
|
1381
|
+
uploadedBy: string;
|
|
1382
|
+
description?: string;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Interface for procedure-specific information
|
|
1386
|
+
*/
|
|
1387
|
+
interface ProcedureExtendedInfo {
|
|
1388
|
+
id: string;
|
|
1389
|
+
name: string;
|
|
1390
|
+
description: string;
|
|
1391
|
+
cost: number;
|
|
1392
|
+
duration: number;
|
|
1393
|
+
procedureFamily: ProcedureFamily;
|
|
1394
|
+
procedureCategoryId: string;
|
|
1395
|
+
procedureCategoryName: string;
|
|
1396
|
+
procedureSubCategoryId: string;
|
|
1397
|
+
procedureSubCategoryName: string;
|
|
1398
|
+
procedureTechnologyId: string;
|
|
1399
|
+
procedureTechnologyName: string;
|
|
1400
|
+
procedureProductBrandId: string;
|
|
1401
|
+
procedureProductBrandName: string;
|
|
1402
|
+
procedureProductId: string;
|
|
1403
|
+
procedureProductName: string;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Interface to describe a filled form linked to an appointment.
|
|
1407
|
+
*/
|
|
1408
|
+
interface LinkedFormInfo {
|
|
1409
|
+
formId: string;
|
|
1410
|
+
templateId: string;
|
|
1411
|
+
templateVersion: number;
|
|
1412
|
+
title: string;
|
|
1413
|
+
isUserForm: boolean;
|
|
1414
|
+
isRequired?: boolean;
|
|
1415
|
+
status: FilledDocumentStatus;
|
|
1416
|
+
path: string;
|
|
1417
|
+
submittedAt?: Timestamp;
|
|
1418
|
+
completedAt?: Timestamp;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Interface for summarized patient review information linked to an appointment.
|
|
1422
|
+
*/
|
|
1423
|
+
interface PatientReviewInfo {
|
|
1424
|
+
reviewId: string;
|
|
1425
|
+
rating: number;
|
|
1426
|
+
comment?: string;
|
|
1427
|
+
reviewedAt: Timestamp;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Represents a booked appointment, aggregating key information and relevant procedure rules.
|
|
1431
|
+
*/
|
|
1432
|
+
interface Appointment {
|
|
1433
|
+
/** Unique identifier for the appointment */
|
|
1434
|
+
id: string;
|
|
1435
|
+
/** Reference to the associated CalendarEvent */
|
|
1436
|
+
calendarEventId: string;
|
|
1437
|
+
/** ID of the clinic branch */
|
|
1438
|
+
clinicBranchId: string;
|
|
1439
|
+
/** Aggregated clinic information (snapshot) */
|
|
1440
|
+
clinicInfo: ClinicInfo;
|
|
1441
|
+
/** ID of the practitioner */
|
|
1442
|
+
practitionerId: string;
|
|
1443
|
+
/** Aggregated practitioner information (snapshot) */
|
|
1444
|
+
practitionerInfo: PractitionerProfileInfo;
|
|
1445
|
+
/** ID of the patient */
|
|
1446
|
+
patientId: string;
|
|
1447
|
+
/** Aggregated patient information (snapshot) */
|
|
1448
|
+
patientInfo: PatientProfileInfo;
|
|
1449
|
+
/** ID of the procedure */
|
|
1450
|
+
procedureId: string;
|
|
1451
|
+
/** Aggregated procedure information including product/brand (snapshot) */
|
|
1452
|
+
procedureInfo: ProcedureSummaryInfo;
|
|
1453
|
+
/** Extended procedure information */
|
|
1454
|
+
procedureExtendedInfo: ProcedureExtendedInfo;
|
|
1455
|
+
/** Status of the appointment */
|
|
1456
|
+
status: AppointmentStatus;
|
|
1457
|
+
/** Timestamps */
|
|
1458
|
+
bookingTime: Timestamp;
|
|
1459
|
+
confirmationTime?: Timestamp | null;
|
|
1460
|
+
cancellationTime?: Timestamp | null;
|
|
1461
|
+
rescheduleTime?: Timestamp | null;
|
|
1462
|
+
appointmentStartTime: Timestamp;
|
|
1463
|
+
appointmentEndTime: Timestamp;
|
|
1464
|
+
procedureActualStartTime?: Timestamp | null;
|
|
1465
|
+
actualDurationMinutes?: number;
|
|
1466
|
+
/** Cancellation Details */
|
|
1467
|
+
cancellationReason?: string | null;
|
|
1468
|
+
canceledBy?: "patient" | "clinic" | "practitioner" | "system";
|
|
1469
|
+
/** Notes */
|
|
1470
|
+
internalNotes?: string | null;
|
|
1471
|
+
patientNotes?: string | null;
|
|
1472
|
+
/** Payment Details */
|
|
1473
|
+
cost: number;
|
|
1474
|
+
currency: Currency;
|
|
1475
|
+
paymentStatus: PaymentStatus;
|
|
1476
|
+
paymentTransactionId?: string | null;
|
|
1477
|
+
/** Procedure-related conditions and requirements */
|
|
1478
|
+
blockingConditions: BlockingCondition[];
|
|
1479
|
+
contraindications: Contraindication[];
|
|
1480
|
+
preProcedureRequirements: Requirement[];
|
|
1481
|
+
postProcedureRequirements: Requirement[];
|
|
1482
|
+
/** Tracking information for requirements completion */
|
|
1483
|
+
completedPreRequirements?: string[];
|
|
1484
|
+
completedPostRequirements?: string[];
|
|
1485
|
+
/** NEW: Linked forms (consent, procedure-specific forms, etc.) */
|
|
1486
|
+
linkedFormIds?: string[];
|
|
1487
|
+
linkedForms?: LinkedFormInfo[];
|
|
1488
|
+
pendingUserFormsIds?: string[];
|
|
1489
|
+
/** NEW: Media items (before/after photos, scanned documents, etc.) */
|
|
1490
|
+
media?: AppointmentMediaItem[];
|
|
1491
|
+
/** NEW: Information about the patient's review for this appointment */
|
|
1492
|
+
reviewInfo?: PatientReviewInfo | null;
|
|
1493
|
+
/** NEW: Details about the finalization of the appointment by the practitioner */
|
|
1494
|
+
finalizedDetails?: {
|
|
1495
|
+
by: string;
|
|
1496
|
+
at: Timestamp;
|
|
1497
|
+
notes?: string;
|
|
1498
|
+
};
|
|
1499
|
+
/** Timestamps for record creation and updates */
|
|
1500
|
+
createdAt: Timestamp;
|
|
1501
|
+
updatedAt: Timestamp;
|
|
1502
|
+
/** Recurring appointment information */
|
|
1503
|
+
isRecurring?: boolean;
|
|
1504
|
+
recurringAppointmentId?: string | null;
|
|
1505
|
+
/** NEW: Flag for soft deletion or archiving */
|
|
1506
|
+
isArchived?: boolean;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1319
1509
|
declare class NotificationsAdmin {
|
|
1320
1510
|
private expo;
|
|
1321
1511
|
private db;
|
|
@@ -1348,6 +1538,19 @@ declare class NotificationsAdmin {
|
|
|
1348
1538
|
* Briše stare notifikacije sa batch procesiranjem
|
|
1349
1539
|
*/
|
|
1350
1540
|
cleanupOldNotifications(daysOld?: number, batchSize?: number): Promise<void>;
|
|
1541
|
+
/**
|
|
1542
|
+
* Creates and potentially sends a push notification for a confirmed appointment.
|
|
1543
|
+
* @param appointment The confirmed appointment object.
|
|
1544
|
+
* @param recipientUserId The ID of the user receiving the notification.
|
|
1545
|
+
* @param recipientExpoTokens Array of Expo push tokens for the recipient.
|
|
1546
|
+
* @param recipientRole The role of the recipient (e.g., PATIENT, PRACTITIONER).
|
|
1547
|
+
*/
|
|
1548
|
+
sendAppointmentConfirmedPush(appointment: Appointment, recipientUserId: string, recipientExpoTokens: string[], recipientRole: UserRole): Promise<string | null>;
|
|
1549
|
+
sendAppointmentCancelledPush(appointment: Appointment, recipientUserId: string, recipientExpoTokens: string[], recipientRole: UserRole): Promise<string | null>;
|
|
1550
|
+
sendAppointmentRescheduledProposalPush(appointment: Appointment, patientUserId: string, patientExpoTokens: string[]): Promise<string | null>;
|
|
1551
|
+
sendPaymentUpdatePush(appointment: Appointment, patientUserId: string, patientExpoTokens: string[]): Promise<string | null>;
|
|
1552
|
+
sendReviewRequestPush(appointment: Appointment, patientUserId: string, patientExpoTokens: string[]): Promise<string | null>;
|
|
1553
|
+
sendReviewAddedPush(appointment: Appointment, recipientUserId: string, recipientExpoTokens: string[], recipientRole: UserRole): Promise<string | null>;
|
|
1351
1554
|
}
|
|
1352
1555
|
|
|
1353
1556
|
/**
|
|
@@ -1722,12 +1925,23 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
|
1722
1925
|
}): Promise<void>;
|
|
1723
1926
|
}
|
|
1724
1927
|
|
|
1928
|
+
/**
|
|
1929
|
+
* Interface for the data required by orchestrateAppointmentCreation
|
|
1930
|
+
*/
|
|
1931
|
+
interface OrchestrateAppointmentCreationData {
|
|
1932
|
+
patientId: string;
|
|
1933
|
+
procedureId: string;
|
|
1934
|
+
appointmentStartTime: admin.firestore.Timestamp;
|
|
1935
|
+
appointmentEndTime: admin.firestore.Timestamp;
|
|
1936
|
+
patientNotes?: string | null;
|
|
1937
|
+
}
|
|
1725
1938
|
/**
|
|
1726
1939
|
* Admin service for handling booking-related operations.
|
|
1727
1940
|
* This is the cloud-based implementation that will be used in Cloud Functions.
|
|
1728
1941
|
*/
|
|
1729
1942
|
declare class BookingAdmin {
|
|
1730
1943
|
private db;
|
|
1944
|
+
private documentManagerAdmin;
|
|
1731
1945
|
/**
|
|
1732
1946
|
* Creates a new BookingAdmin instance
|
|
1733
1947
|
* @param firestore - Firestore instance provided by the caller
|
|
@@ -1776,6 +1990,26 @@ declare class BookingAdmin {
|
|
|
1776
1990
|
* @returns Promise resolving to an array of calendar events
|
|
1777
1991
|
*/
|
|
1778
1992
|
private getPractitionerCalendarEvents;
|
|
1993
|
+
private _generateCalendarProcedureInfo;
|
|
1994
|
+
/**
|
|
1995
|
+
* Orchestrates the creation of a new appointment, including data aggregation.
|
|
1996
|
+
* This method is intended to be called from a trusted backend environment (e.g., an Express route handler in a Cloud Function).
|
|
1997
|
+
*
|
|
1998
|
+
* @param data - Data required to create the appointment.
|
|
1999
|
+
* @param authenticatedUserId - The ID of the user making the request (for auditing, and usually is the patientId).
|
|
2000
|
+
* @returns Promise resolving to an object indicating success, and appointmentId or an error message.
|
|
2001
|
+
*/
|
|
2002
|
+
orchestrateAppointmentCreation(data: OrchestrateAppointmentCreationData, authenticatedUserId: string): Promise<{
|
|
2003
|
+
success: boolean;
|
|
2004
|
+
appointmentId?: string;
|
|
2005
|
+
appointmentData?: Appointment;
|
|
2006
|
+
practitionerCalendarEventId?: string;
|
|
2007
|
+
patientCalendarEventId?: string;
|
|
2008
|
+
clinicCalendarEventId?: string;
|
|
2009
|
+
error?: string;
|
|
2010
|
+
}>;
|
|
2011
|
+
private _generateProcedureSummaryInfo;
|
|
2012
|
+
private _generateProcedureExtendedInfo;
|
|
1779
2013
|
}
|
|
1780
2014
|
|
|
1781
2015
|
/**
|