@blackcode_sa/metaestetics-api 1.6.5 → 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.
@@ -1143,6 +1143,8 @@ declare enum NotificationType {
1143
1143
  APPOINTMENT_STATUS_CHANGE = "appointmentStatusChange",// Generic for status changes like confirmed, checked-in etc.
1144
1144
  APPOINTMENT_RESCHEDULED_PROPOSAL = "appointmentRescheduledProposal",// When clinic proposes a new time
1145
1145
  APPOINTMENT_CANCELLED = "appointmentCancelled",// When an appointment is cancelled
1146
+ PRE_REQUIREMENT_INSTRUCTION_DUE = "preRequirementInstructionDue",
1147
+ POST_REQUIREMENT_INSTRUCTION_DUE = "postRequirementInstructionDue",
1146
1148
  REQUIREMENT_INSTRUCTION_DUE = "requirementInstructionDue",// For specific pre/post care instructions
1147
1149
  FORM_REMINDER = "formReminder",// Reminds user to fill a specific form
1148
1150
  FORM_SUBMISSION_CONFIRMATION = "formSubmissionConfirmation",// Confirms form was submitted
@@ -1209,7 +1211,7 @@ declare enum NotificationStatus {
1209
1211
  * Notifikacija za pre-requirement
1210
1212
  */
1211
1213
  interface PreRequirementNotification extends BaseNotification {
1212
- notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
1214
+ notificationType: NotificationType.PRE_REQUIREMENT_INSTRUCTION_DUE;
1213
1215
  /** ID tretmana za koji je vezan pre-requirement */
1214
1216
  treatmentId: string;
1215
1217
  /** Lista pre-requirements koji treba da se ispune */
@@ -1221,7 +1223,7 @@ interface PreRequirementNotification extends BaseNotification {
1221
1223
  * Notifikacija za post-requirement
1222
1224
  */
1223
1225
  interface PostRequirementNotification extends BaseNotification {
1224
- notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
1226
+ notificationType: NotificationType.POST_REQUIREMENT_INSTRUCTION_DUE;
1225
1227
  /** ID tretmana za koji je vezan post-requirement */
1226
1228
  treatmentId: string;
1227
1229
  /** Lista post-requirements koji treba da se ispune */
@@ -1333,6 +1335,177 @@ interface PaymentConfirmationNotification extends BaseNotification {
1333
1335
  */
1334
1336
  type Notification = PreRequirementNotification | PostRequirementNotification | RequirementInstructionDueNotification | AppointmentReminderNotification | AppointmentStatusChangeNotification | AppointmentRescheduledProposalNotification | AppointmentCancelledNotification | FormReminderNotification | FormSubmissionConfirmationNotification | ReviewRequestNotification | GeneralMessageNotification | PaymentConfirmationNotification;
1335
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
+
1336
1509
  declare class NotificationsAdmin {
1337
1510
  private expo;
1338
1511
  private db;
@@ -1365,6 +1538,19 @@ declare class NotificationsAdmin {
1365
1538
  * Briše stare notifikacije sa batch procesiranjem
1366
1539
  */
1367
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>;
1368
1554
  }
1369
1555
 
1370
1556
  /**
@@ -1739,176 +1925,6 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
1739
1925
  }): Promise<void>;
1740
1926
  }
1741
1927
 
1742
- /**
1743
- * Enum defining the possible statuses of an appointment.
1744
- */
1745
- declare enum AppointmentStatus {
1746
- PENDING = "pending",// Initial state after booking, before confirmation (if applicable)
1747
- CONFIRMED = "confirmed",// Confirmed by clinic/practitioner
1748
- CHECKED_IN = "checked_in",// Patient has arrived
1749
- IN_PROGRESS = "in_progress",// Procedure has started
1750
- COMPLETED = "completed",// Procedure finished successfully
1751
- CANCELED_PATIENT = "canceled_patient",// Canceled by the patient
1752
- CANCELED_PATIENT_RESCHEDULED = "canceled_patient_rescheduled",// Canceled by the patient and rescheduled by the clinic
1753
- CANCELED_CLINIC = "canceled_clinic",// Canceled by the clinic/practitioner
1754
- NO_SHOW = "no_show",// Patient did not attend
1755
- RESCHEDULED_BY_CLINIC = "rescheduled_by_clinic"
1756
- }
1757
- /**
1758
- * Enum defining the payment status of an appointment.
1759
- */
1760
- declare enum PaymentStatus {
1761
- UNPAID = "unpaid",
1762
- PAID = "paid",
1763
- PARTIALLY_PAID = "partially_paid",
1764
- REFUNDED = "refunded",
1765
- NOT_APPLICABLE = "not_applicable"
1766
- }
1767
- /**
1768
- * Enum for different types of media that can be attached to an appointment.
1769
- */
1770
- declare enum MediaType {
1771
- BEFORE_PHOTO = "before_photo",
1772
- AFTER_PHOTO = "after_photo",
1773
- CONSENT_SCAN = "consent_scan",
1774
- OTHER_DOCUMENT = "other_document"
1775
- }
1776
- /**
1777
- * Interface to describe a media file linked to an appointment.
1778
- */
1779
- interface AppointmentMediaItem {
1780
- id: string;
1781
- type: MediaType;
1782
- url: string;
1783
- fileName?: string;
1784
- uploadedAt: Timestamp;
1785
- uploadedBy: string;
1786
- description?: string;
1787
- }
1788
- /**
1789
- * Interface for procedure-specific information
1790
- */
1791
- interface ProcedureExtendedInfo {
1792
- id: string;
1793
- name: string;
1794
- description: string;
1795
- cost: number;
1796
- duration: number;
1797
- procedureFamily: ProcedureFamily;
1798
- procedureCategoryId: string;
1799
- procedureCategoryName: string;
1800
- procedureSubCategoryId: string;
1801
- procedureSubCategoryName: string;
1802
- procedureTechnologyId: string;
1803
- procedureTechnologyName: string;
1804
- procedureProductBrandId: string;
1805
- procedureProductBrandName: string;
1806
- procedureProductId: string;
1807
- procedureProductName: string;
1808
- }
1809
- /**
1810
- * Interface to describe a filled form linked to an appointment.
1811
- */
1812
- interface LinkedFormInfo {
1813
- formId: string;
1814
- templateId: string;
1815
- templateVersion: number;
1816
- title: string;
1817
- isUserForm: boolean;
1818
- status: FilledDocumentStatus;
1819
- path: string;
1820
- submittedAt?: Timestamp;
1821
- completedAt?: Timestamp;
1822
- }
1823
- /**
1824
- * Interface for summarized patient review information linked to an appointment.
1825
- */
1826
- interface PatientReviewInfo {
1827
- reviewId: string;
1828
- rating: number;
1829
- comment?: string;
1830
- reviewedAt: Timestamp;
1831
- }
1832
- /**
1833
- * Represents a booked appointment, aggregating key information and relevant procedure rules.
1834
- */
1835
- interface Appointment {
1836
- /** Unique identifier for the appointment */
1837
- id: string;
1838
- /** Reference to the associated CalendarEvent */
1839
- calendarEventId: string;
1840
- /** ID of the clinic branch */
1841
- clinicBranchId: string;
1842
- /** Aggregated clinic information (snapshot) */
1843
- clinicInfo: ClinicInfo;
1844
- /** ID of the practitioner */
1845
- practitionerId: string;
1846
- /** Aggregated practitioner information (snapshot) */
1847
- practitionerInfo: PractitionerProfileInfo;
1848
- /** ID of the patient */
1849
- patientId: string;
1850
- /** Aggregated patient information (snapshot) */
1851
- patientInfo: PatientProfileInfo;
1852
- /** ID of the procedure */
1853
- procedureId: string;
1854
- /** Aggregated procedure information including product/brand (snapshot) */
1855
- procedureInfo: ProcedureSummaryInfo;
1856
- /** Extended procedure information */
1857
- procedureExtendedInfo: ProcedureExtendedInfo;
1858
- /** Status of the appointment */
1859
- status: AppointmentStatus;
1860
- /** Timestamps */
1861
- bookingTime: Timestamp;
1862
- confirmationTime?: Timestamp | null;
1863
- cancellationTime?: Timestamp | null;
1864
- rescheduleTime?: Timestamp | null;
1865
- appointmentStartTime: Timestamp;
1866
- appointmentEndTime: Timestamp;
1867
- procedureActualStartTime?: Timestamp | null;
1868
- actualDurationMinutes?: number;
1869
- /** Cancellation Details */
1870
- cancellationReason?: string | null;
1871
- canceledBy?: "patient" | "clinic" | "practitioner" | "system";
1872
- /** Notes */
1873
- internalNotes?: string | null;
1874
- patientNotes?: string | null;
1875
- /** Payment Details */
1876
- cost: number;
1877
- currency: Currency;
1878
- paymentStatus: PaymentStatus;
1879
- paymentTransactionId?: string | null;
1880
- /** Procedure-related conditions and requirements */
1881
- blockingConditions: BlockingCondition[];
1882
- contraindications: Contraindication[];
1883
- preProcedureRequirements: Requirement[];
1884
- postProcedureRequirements: Requirement[];
1885
- /** Tracking information for requirements completion */
1886
- completedPreRequirements?: string[];
1887
- completedPostRequirements?: string[];
1888
- /** NEW: Linked forms (consent, procedure-specific forms, etc.) */
1889
- linkedFormIds?: string[];
1890
- linkedForms?: LinkedFormInfo[];
1891
- pendingUserFormsIds?: string[];
1892
- /** NEW: Media items (before/after photos, scanned documents, etc.) */
1893
- media?: AppointmentMediaItem[];
1894
- /** NEW: Information about the patient's review for this appointment */
1895
- reviewInfo?: PatientReviewInfo | null;
1896
- /** NEW: Details about the finalization of the appointment by the practitioner */
1897
- finalizedDetails?: {
1898
- by: string;
1899
- at: Timestamp;
1900
- notes?: string;
1901
- };
1902
- /** Timestamps for record creation and updates */
1903
- createdAt: Timestamp;
1904
- updatedAt: Timestamp;
1905
- /** Recurring appointment information */
1906
- isRecurring?: boolean;
1907
- recurringAppointmentId?: string | null;
1908
- /** NEW: Flag for soft deletion or archiving */
1909
- isArchived?: boolean;
1910
- }
1911
-
1912
1928
  /**
1913
1929
  * Interface for the data required by orchestrateAppointmentCreation
1914
1930
  */
@@ -1925,6 +1941,7 @@ interface OrchestrateAppointmentCreationData {
1925
1941
  */
1926
1942
  declare class BookingAdmin {
1927
1943
  private db;
1944
+ private documentManagerAdmin;
1928
1945
  /**
1929
1946
  * Creates a new BookingAdmin instance
1930
1947
  * @param firestore - Firestore instance provided by the caller
@@ -1973,6 +1990,7 @@ declare class BookingAdmin {
1973
1990
  * @returns Promise resolving to an array of calendar events
1974
1991
  */
1975
1992
  private getPractitionerCalendarEvents;
1993
+ private _generateCalendarProcedureInfo;
1976
1994
  /**
1977
1995
  * Orchestrates the creation of a new appointment, including data aggregation.
1978
1996
  * This method is intended to be called from a trusted backend environment (e.g., an Express route handler in a Cloud Function).
@@ -1985,8 +2003,13 @@ declare class BookingAdmin {
1985
2003
  success: boolean;
1986
2004
  appointmentId?: string;
1987
2005
  appointmentData?: Appointment;
2006
+ practitionerCalendarEventId?: string;
2007
+ patientCalendarEventId?: string;
2008
+ clinicCalendarEventId?: string;
1988
2009
  error?: string;
1989
2010
  }>;
2011
+ private _generateProcedureSummaryInfo;
2012
+ private _generateProcedureExtendedInfo;
1990
2013
  }
1991
2014
 
1992
2015
  /**