@blackcode_sa/metaestetics-api 1.15.16 → 1.15.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/admin/index.d.mts +377 -222
  2. package/dist/admin/index.d.ts +377 -222
  3. package/dist/admin/index.js +625 -206
  4. package/dist/admin/index.mjs +624 -206
  5. package/dist/backoffice/index.d.mts +24 -0
  6. package/dist/backoffice/index.d.ts +24 -0
  7. package/dist/index.d.mts +371 -4
  8. package/dist/index.d.ts +371 -4
  9. package/dist/index.js +2227 -1580
  10. package/dist/index.mjs +1543 -891
  11. package/package.json +1 -1
  12. package/src/admin/aggregation/appointment/README.md +24 -2
  13. package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +46 -0
  14. package/src/admin/booking/README.md +61 -2
  15. package/src/admin/booking/booking.admin.ts +257 -0
  16. package/src/admin/booking/booking.calculator.ts +139 -1
  17. package/src/admin/booking/booking.types.ts +17 -0
  18. package/src/admin/calendar/README.md +56 -1
  19. package/src/admin/calendar/index.ts +1 -0
  20. package/src/admin/calendar/resource-calendar.admin.ts +198 -0
  21. package/src/config/index.ts +1 -0
  22. package/src/config/tiers.config.ts +116 -0
  23. package/src/services/index.ts +1 -0
  24. package/src/services/plan-config.service.ts +55 -0
  25. package/src/services/resource/README.md +119 -0
  26. package/src/services/resource/index.ts +1 -0
  27. package/src/services/resource/resource.service.ts +555 -0
  28. package/src/services/tier-enforcement.ts +15 -10
  29. package/src/types/appointment/index.ts +7 -0
  30. package/src/types/calendar/index.ts +1 -0
  31. package/src/types/clinic/index.ts +1 -0
  32. package/src/types/clinic/rbac.types.ts +3 -2
  33. package/src/types/index.ts +6 -0
  34. package/src/types/procedure/index.ts +6 -0
  35. package/src/types/resource/README.md +153 -0
  36. package/src/types/resource/index.ts +199 -0
  37. package/src/types/system/index.ts +1 -0
  38. package/src/types/system/planConfig.types.ts +86 -0
  39. package/src/validations/README.md +94 -0
  40. package/src/validations/index.ts +1 -0
  41. package/src/validations/procedure.schema.ts +12 -0
  42. package/src/validations/resource.schema.ts +57 -0
@@ -758,6 +758,301 @@ interface ProcedureProduct {
758
758
  */
759
759
  type MediaResource = string | File | Blob;
760
760
 
761
+ /**
762
+ * Osnovne informacije o zdravstvenom radniku
763
+ */
764
+ interface PractitionerBasicInfo {
765
+ firstName: string;
766
+ lastName: string;
767
+ title: string;
768
+ email: string;
769
+ phoneNumber: string | null;
770
+ dateOfBirth: Timestamp | Date | null;
771
+ gender: "male" | "female" | "other";
772
+ profileImageUrl?: MediaResource | null;
773
+ bio?: string;
774
+ languages: string[];
775
+ }
776
+ /**
777
+ * Sertifikacija zdravstvenog radnika
778
+ */
779
+ interface PractitionerCertification {
780
+ level: CertificationLevel;
781
+ specialties: CertificationSpecialty[];
782
+ licenseNumber: string;
783
+ issuingAuthority: string;
784
+ issueDate: Timestamp | Date;
785
+ expiryDate?: Timestamp | Date | null;
786
+ verificationStatus: "pending" | "verified" | "rejected";
787
+ diploma?: string;
788
+ diplomaNumber?: string;
789
+ }
790
+ /**
791
+ * Interfejs za radno vreme zdravstvenog radnika u klinici
792
+ */
793
+ interface PractitionerClinicWorkingHours {
794
+ clinicId: string;
795
+ workingHours: {
796
+ monday: {
797
+ start: string;
798
+ end: string;
799
+ } | null;
800
+ tuesday: {
801
+ start: string;
802
+ end: string;
803
+ } | null;
804
+ wednesday: {
805
+ start: string;
806
+ end: string;
807
+ } | null;
808
+ thursday: {
809
+ start: string;
810
+ end: string;
811
+ } | null;
812
+ friday: {
813
+ start: string;
814
+ end: string;
815
+ } | null;
816
+ saturday: {
817
+ start: string;
818
+ end: string;
819
+ } | null;
820
+ sunday: {
821
+ start: string;
822
+ end: string;
823
+ } | null;
824
+ };
825
+ isActive: boolean;
826
+ createdAt: Timestamp | Date;
827
+ updatedAt: Timestamp | Date;
828
+ }
829
+ /**
830
+ * Status of practitioner profile
831
+ */
832
+ declare enum PractitionerStatus {
833
+ DRAFT = "draft",
834
+ ACTIVE = "active"
835
+ }
836
+ /**
837
+ * Token status for practitioner invitations
838
+ */
839
+ declare enum PractitionerTokenStatus {
840
+ ACTIVE = "active",
841
+ USED = "used",
842
+ EXPIRED = "expired",
843
+ REVOKED = "revoked"
844
+ }
845
+ /**
846
+ * Interfejs za zdravstvenog radnika
847
+ */
848
+ interface Practitioner {
849
+ id: string;
850
+ userRef: string;
851
+ basicInfo: PractitionerBasicInfo;
852
+ fullNameLower: string;
853
+ certification: PractitionerCertification;
854
+ clinics: string[];
855
+ clinicWorkingHours: PractitionerClinicWorkingHours[];
856
+ clinicsInfo: ClinicInfo[];
857
+ procedures: string[];
858
+ freeConsultations?: Record<string, string> | null;
859
+ proceduresInfo: ProcedureSummaryInfo[];
860
+ reviewInfo: PractitionerReviewInfo;
861
+ isActive: boolean;
862
+ isVerified: boolean;
863
+ status: PractitionerStatus;
864
+ createdAt: Timestamp;
865
+ updatedAt: Timestamp;
866
+ }
867
+ /**
868
+ * Token za pozivanje zdravstvenog radnika
869
+ */
870
+ interface PractitionerToken {
871
+ id: string;
872
+ token: string;
873
+ practitionerId: string;
874
+ email: string;
875
+ clinicId: string;
876
+ status: PractitionerTokenStatus;
877
+ createdBy: string;
878
+ createdAt: Timestamp;
879
+ expiresAt: Timestamp;
880
+ usedBy?: string;
881
+ usedAt?: Timestamp;
882
+ emailSent?: boolean;
883
+ emailSentAt?: Timestamp;
884
+ emailError?: string;
885
+ emailErrorAt?: Timestamp;
886
+ }
887
+
888
+ /**
889
+ * Enum for synced calendar provider
890
+ */
891
+ declare enum SyncedCalendarProvider {
892
+ GOOGLE = "google",
893
+ OUTLOOK = "outlook",
894
+ APPLE = "apple"
895
+ }
896
+
897
+ /**
898
+ * Enum for calendar event status
899
+ */
900
+ declare enum CalendarEventStatus {
901
+ PENDING = "pending",// When event is created, but not confirmed
902
+ CONFIRMED = "confirmed",// When event is confirmed and ready to be used
903
+ CHECKED_IN = "checked_in",// Patient has arrived and checked in
904
+ IN_PROGRESS = "in_progress",// Procedure has started
905
+ REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
906
+ CANCELED = "canceled",// When event is canceled by the patient
907
+ RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
908
+ COMPLETED = "completed",// When event is completed
909
+ NO_SHOW = "no_show"
910
+ }
911
+ /**
912
+ * Enum for calendar event sync status
913
+ */
914
+ declare enum CalendarSyncStatus {
915
+ INTERNAL = "internal",
916
+ EXTERNAL = "external"
917
+ }
918
+ /**
919
+ * Enum for calendar event types
920
+ */
921
+ declare enum CalendarEventType {
922
+ APPOINTMENT = "appointment",
923
+ BLOCKING = "blocking",
924
+ BREAK = "break",
925
+ FREE_DAY = "free_day",
926
+ RESOURCE_BOOKING = "resource_booking",
927
+ OTHER = "other"
928
+ }
929
+ /**
930
+ * Interface for calendar event time
931
+ */
932
+ interface CalendarEventTime {
933
+ start: Timestamp;
934
+ end: Timestamp;
935
+ }
936
+ interface ProcedureInfo {
937
+ name: string;
938
+ description: string;
939
+ duration: number;
940
+ price: number;
941
+ currency: Currency;
942
+ }
943
+ interface ProcedureCategorization {
944
+ procedureFamily: ProcedureFamily;
945
+ procedureCategory: Category;
946
+ procedureSubcategory: Subcategory;
947
+ procedureTechnology: Technology;
948
+ procedureProduct: Product;
949
+ }
950
+ interface SyncedCalendarEvent {
951
+ eventId: string;
952
+ syncedCalendarProvider: SyncedCalendarProvider;
953
+ syncedAt: Timestamp;
954
+ }
955
+ /**
956
+ * Interface for calendar event
957
+ */
958
+ interface CalendarEvent {
959
+ id: string;
960
+ clinicBranchId?: string | null;
961
+ clinicBranchInfo?: ClinicInfo | null;
962
+ practitionerProfileId?: string | null;
963
+ practitionerProfileInfo?: PractitionerProfileInfo | null;
964
+ patientProfileId?: string | null;
965
+ patientProfileInfo?: PatientProfileInfo | null;
966
+ procedureId?: string | null;
967
+ procedureInfo?: ProcedureInfo | null;
968
+ procedureCategorization?: ProcedureCategorization | null;
969
+ appointmentId?: string | null;
970
+ syncedCalendarEventId?: SyncedCalendarEvent[] | null;
971
+ eventName: string;
972
+ eventLocation?: ClinicLocation;
973
+ eventTime: CalendarEventTime;
974
+ description?: string;
975
+ status: CalendarEventStatus;
976
+ syncStatus: CalendarSyncStatus;
977
+ eventType: CalendarEventType;
978
+ createdAt: Timestamp;
979
+ updatedAt: Timestamp;
980
+ }
981
+
982
+ /**
983
+ * Category of a clinic resource
984
+ */
985
+ declare enum ResourceCategory {
986
+ MEDICAL_DEVICE = "medical_device",
987
+ ROOM = "room",
988
+ SURGERY_SUITE = "surgery_suite",
989
+ EQUIPMENT = "equipment",
990
+ OTHER = "other"
991
+ }
992
+ /**
993
+ * Calendar event on a resource instance.
994
+ * Can be either a booking event (created during appointment creation) or a blocking event (created manually by admin).
995
+ * Stored at: clinics/{clinicId}/resources/{resourceId}/instances/{instanceId}/calendar/{eventId}
996
+ */
997
+ interface ResourceCalendarEvent {
998
+ /** Unique identifier */
999
+ id: string;
1000
+ /** Parent resource ID */
1001
+ resourceId: string;
1002
+ /** Instance this event is on */
1003
+ resourceInstanceId: string;
1004
+ /** Clinic branch */
1005
+ clinicBranchId: string;
1006
+ /** Type of event — RESOURCE_BOOKING for appointment bookings, BLOCKING for manual blocks */
1007
+ eventType: CalendarEventType;
1008
+ /** Appointment that booked this resource (only for RESOURCE_BOOKING events) */
1009
+ appointmentId?: string;
1010
+ /** Procedure requiring this resource (only for RESOURCE_BOOKING events) */
1011
+ procedureId?: string;
1012
+ /** Practitioner performing the procedure (only for RESOURCE_BOOKING events) */
1013
+ practitionerId?: string;
1014
+ /** Patient for the appointment (only for RESOURCE_BOOKING events) */
1015
+ patientId?: string;
1016
+ /** Time range of the event */
1017
+ eventTime: CalendarEventTime;
1018
+ /** Event status — CONFIRMED for blocking events, mirrors appointment status for bookings */
1019
+ status: CalendarEventStatus;
1020
+ /** Display name for the event */
1021
+ eventName: string;
1022
+ /** Optional description (primarily for blocking events, e.g., reason for maintenance) */
1023
+ description?: string;
1024
+ createdAt: Timestamp;
1025
+ updatedAt: Timestamp;
1026
+ }
1027
+ /**
1028
+ * Lightweight reference stored on procedures to indicate which resources are required.
1029
+ * Denormalized snapshot of resource info at the time of linking.
1030
+ */
1031
+ interface ResourceRequirement {
1032
+ /** ID of the required resource */
1033
+ resourceId: string;
1034
+ /** Name of the resource (snapshot) */
1035
+ resourceName: string;
1036
+ /** Category of the resource (snapshot) */
1037
+ resourceCategory: ResourceCategory;
1038
+ }
1039
+ /**
1040
+ * Info about a specific resource instance booking, stored on the appointment
1041
+ * after a resource has been allocated during appointment creation.
1042
+ */
1043
+ interface ResourceBookingInfo {
1044
+ /** ID of the booked resource */
1045
+ resourceId: string;
1046
+ /** Name of the resource (snapshot) */
1047
+ resourceName: string;
1048
+ /** ID of the specific instance that was allocated */
1049
+ resourceInstanceId: string;
1050
+ /** Label of the instance (e.g., "Surgery Room #2") */
1051
+ resourceInstanceLabel: string;
1052
+ /** ID of the calendar event created on the instance */
1053
+ calendarEventId: string;
1054
+ }
1055
+
761
1056
  /**
762
1057
  * Procedure represents a specific medical procedure that can be performed by a practitioner in a clinic
763
1058
  * It inherits properties from technology and adds clinic/practitioner specific details
@@ -820,6 +1115,8 @@ interface Procedure {
820
1115
  doctorInfo: DoctorInfo;
821
1116
  /** Aggregated review information for this procedure */
822
1117
  reviewInfo: ProcedureReviewInfo;
1118
+ /** Optional resources required for this procedure (e.g., surgery room, device) */
1119
+ resourceRequirements?: ResourceRequirement[];
823
1120
  /** Whether this procedure is active */
824
1121
  isActive: boolean;
825
1122
  /** When this procedure was created */
@@ -852,6 +1149,7 @@ interface ProcedureSummaryInfo {
852
1149
  clinicName: string;
853
1150
  practitionerId: string;
854
1151
  practitionerName: string;
1152
+ resourceRequirements?: ResourceRequirement[];
855
1153
  }
856
1154
 
857
1155
  /**
@@ -1197,7 +1495,8 @@ declare enum BillingTransactionType {
1197
1495
  SUBSCRIPTION_UPDATED = "subscription_updated",
1198
1496
  SUBSCRIPTION_CANCELED = "subscription_canceled",
1199
1497
  SUBSCRIPTION_REACTIVATED = "subscription_reactivated",
1200
- SUBSCRIPTION_DELETED = "subscription_deleted"
1498
+ SUBSCRIPTION_DELETED = "subscription_deleted",
1499
+ ADDON_PURCHASED = "addon_purchased"
1201
1500
  }
1202
1501
  /**
1203
1502
  * Interface for Stripe data in billing transactions
@@ -1327,133 +1626,6 @@ interface Clinic {
1327
1626
  acceptingBookings?: boolean;
1328
1627
  }
1329
1628
 
1330
- /**
1331
- * Osnovne informacije o zdravstvenom radniku
1332
- */
1333
- interface PractitionerBasicInfo {
1334
- firstName: string;
1335
- lastName: string;
1336
- title: string;
1337
- email: string;
1338
- phoneNumber: string | null;
1339
- dateOfBirth: Timestamp | Date | null;
1340
- gender: "male" | "female" | "other";
1341
- profileImageUrl?: MediaResource | null;
1342
- bio?: string;
1343
- languages: string[];
1344
- }
1345
- /**
1346
- * Sertifikacija zdravstvenog radnika
1347
- */
1348
- interface PractitionerCertification {
1349
- level: CertificationLevel;
1350
- specialties: CertificationSpecialty[];
1351
- licenseNumber: string;
1352
- issuingAuthority: string;
1353
- issueDate: Timestamp | Date;
1354
- expiryDate?: Timestamp | Date | null;
1355
- verificationStatus: "pending" | "verified" | "rejected";
1356
- diploma?: string;
1357
- diplomaNumber?: string;
1358
- }
1359
- /**
1360
- * Interfejs za radno vreme zdravstvenog radnika u klinici
1361
- */
1362
- interface PractitionerClinicWorkingHours {
1363
- clinicId: string;
1364
- workingHours: {
1365
- monday: {
1366
- start: string;
1367
- end: string;
1368
- } | null;
1369
- tuesday: {
1370
- start: string;
1371
- end: string;
1372
- } | null;
1373
- wednesday: {
1374
- start: string;
1375
- end: string;
1376
- } | null;
1377
- thursday: {
1378
- start: string;
1379
- end: string;
1380
- } | null;
1381
- friday: {
1382
- start: string;
1383
- end: string;
1384
- } | null;
1385
- saturday: {
1386
- start: string;
1387
- end: string;
1388
- } | null;
1389
- sunday: {
1390
- start: string;
1391
- end: string;
1392
- } | null;
1393
- };
1394
- isActive: boolean;
1395
- createdAt: Timestamp | Date;
1396
- updatedAt: Timestamp | Date;
1397
- }
1398
- /**
1399
- * Status of practitioner profile
1400
- */
1401
- declare enum PractitionerStatus {
1402
- DRAFT = "draft",
1403
- ACTIVE = "active"
1404
- }
1405
- /**
1406
- * Token status for practitioner invitations
1407
- */
1408
- declare enum PractitionerTokenStatus {
1409
- ACTIVE = "active",
1410
- USED = "used",
1411
- EXPIRED = "expired",
1412
- REVOKED = "revoked"
1413
- }
1414
- /**
1415
- * Interfejs za zdravstvenog radnika
1416
- */
1417
- interface Practitioner {
1418
- id: string;
1419
- userRef: string;
1420
- basicInfo: PractitionerBasicInfo;
1421
- fullNameLower: string;
1422
- certification: PractitionerCertification;
1423
- clinics: string[];
1424
- clinicWorkingHours: PractitionerClinicWorkingHours[];
1425
- clinicsInfo: ClinicInfo[];
1426
- procedures: string[];
1427
- freeConsultations?: Record<string, string> | null;
1428
- proceduresInfo: ProcedureSummaryInfo[];
1429
- reviewInfo: PractitionerReviewInfo;
1430
- isActive: boolean;
1431
- isVerified: boolean;
1432
- status: PractitionerStatus;
1433
- createdAt: Timestamp;
1434
- updatedAt: Timestamp;
1435
- }
1436
- /**
1437
- * Token za pozivanje zdravstvenog radnika
1438
- */
1439
- interface PractitionerToken {
1440
- id: string;
1441
- token: string;
1442
- practitionerId: string;
1443
- email: string;
1444
- clinicId: string;
1445
- status: PractitionerTokenStatus;
1446
- createdBy: string;
1447
- createdAt: Timestamp;
1448
- expiresAt: Timestamp;
1449
- usedBy?: string;
1450
- usedAt?: Timestamp;
1451
- emailSent?: boolean;
1452
- emailSentAt?: Timestamp;
1453
- emailError?: string;
1454
- emailErrorAt?: Timestamp;
1455
- }
1456
-
1457
1629
  declare enum AllergyType {
1458
1630
  MEDICATION = "medication",
1459
1631
  FOOD = "food",
@@ -2054,99 +2226,8 @@ interface Appointment {
2054
2226
  isArchived?: boolean;
2055
2227
  /** NEW: Metadata for the appointment - used for area selection and photos */
2056
2228
  metadata?: AppointmentMetadata;
2057
- }
2058
-
2059
- /**
2060
- * Enum for synced calendar provider
2061
- */
2062
- declare enum SyncedCalendarProvider {
2063
- GOOGLE = "google",
2064
- OUTLOOK = "outlook",
2065
- APPLE = "apple"
2066
- }
2067
-
2068
- /**
2069
- * Enum for calendar event status
2070
- */
2071
- declare enum CalendarEventStatus {
2072
- PENDING = "pending",// When event is created, but not confirmed
2073
- CONFIRMED = "confirmed",// When event is confirmed and ready to be used
2074
- CHECKED_IN = "checked_in",// Patient has arrived and checked in
2075
- IN_PROGRESS = "in_progress",// Procedure has started
2076
- REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
2077
- CANCELED = "canceled",// When event is canceled by the patient
2078
- RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
2079
- COMPLETED = "completed",// When event is completed
2080
- NO_SHOW = "no_show"
2081
- }
2082
- /**
2083
- * Enum for calendar event sync status
2084
- */
2085
- declare enum CalendarSyncStatus {
2086
- INTERNAL = "internal",
2087
- EXTERNAL = "external"
2088
- }
2089
- /**
2090
- * Enum for calendar event types
2091
- */
2092
- declare enum CalendarEventType {
2093
- APPOINTMENT = "appointment",
2094
- BLOCKING = "blocking",
2095
- BREAK = "break",
2096
- FREE_DAY = "free_day",
2097
- OTHER = "other"
2098
- }
2099
- /**
2100
- * Interface for calendar event time
2101
- */
2102
- interface CalendarEventTime {
2103
- start: Timestamp;
2104
- end: Timestamp;
2105
- }
2106
- interface ProcedureInfo {
2107
- name: string;
2108
- description: string;
2109
- duration: number;
2110
- price: number;
2111
- currency: Currency;
2112
- }
2113
- interface ProcedureCategorization {
2114
- procedureFamily: ProcedureFamily;
2115
- procedureCategory: Category;
2116
- procedureSubcategory: Subcategory;
2117
- procedureTechnology: Technology;
2118
- procedureProduct: Product;
2119
- }
2120
- interface SyncedCalendarEvent {
2121
- eventId: string;
2122
- syncedCalendarProvider: SyncedCalendarProvider;
2123
- syncedAt: Timestamp;
2124
- }
2125
- /**
2126
- * Interface for calendar event
2127
- */
2128
- interface CalendarEvent {
2129
- id: string;
2130
- clinicBranchId?: string | null;
2131
- clinicBranchInfo?: ClinicInfo | null;
2132
- practitionerProfileId?: string | null;
2133
- practitionerProfileInfo?: PractitionerProfileInfo | null;
2134
- patientProfileId?: string | null;
2135
- patientProfileInfo?: PatientProfileInfo | null;
2136
- procedureId?: string | null;
2137
- procedureInfo?: ProcedureInfo | null;
2138
- procedureCategorization?: ProcedureCategorization | null;
2139
- appointmentId?: string | null;
2140
- syncedCalendarEventId?: SyncedCalendarEvent[] | null;
2141
- eventName: string;
2142
- eventLocation?: ClinicLocation;
2143
- eventTime: CalendarEventTime;
2144
- description?: string;
2145
- status: CalendarEventStatus;
2146
- syncStatus: CalendarSyncStatus;
2147
- eventType: CalendarEventType;
2148
- createdAt: Timestamp;
2149
- updatedAt: Timestamp;
2229
+ /** Resources booked for this appointment (e.g., surgery room instance, device instance) */
2230
+ resourceBookings?: ResourceBookingInfo[];
2150
2231
  }
2151
2232
 
2152
2233
  /**
@@ -3607,6 +3688,7 @@ declare class AppointmentAggregationService {
3607
3688
  private appointmentMailingService;
3608
3689
  private notificationsAdmin;
3609
3690
  private calendarAdminService;
3691
+ private resourceCalendarAdminService;
3610
3692
  private patientRequirementsAdminService;
3611
3693
  /**
3612
3694
  * Constructor for AppointmentAggregationService.
@@ -4356,6 +4438,18 @@ interface BookingAvailabilityRequest {
4356
4438
  practitionerCalendarEvents: CalendarEvent[];
4357
4439
  /** IANA timezone of the clinic */
4358
4440
  tz: string;
4441
+ /**
4442
+ * Resource calendar events per resource, keyed by resourceId.
4443
+ * Each entry contains all instances' events for that resource.
4444
+ * Only present when the procedure has resourceRequirements.
4445
+ */
4446
+ resourceCalendarEventsMap?: Record<string, {
4447
+ resourceId: string;
4448
+ resourceName: string;
4449
+ quantity: number;
4450
+ /** Calendar events keyed by instanceId */
4451
+ instanceEvents: Record<string, ResourceCalendarEvent[]>;
4452
+ }>;
4359
4453
  }
4360
4454
  /**
4361
4455
  * Represents a single available booking slot
@@ -4495,6 +4589,29 @@ declare class BookingAvailabilityCalculator {
4495
4589
  * @returns Merged intervals
4496
4590
  */
4497
4591
  private static mergeOverlappingIntervals;
4592
+ /**
4593
+ * Apply resource availability constraints to the available intervals.
4594
+ * For each required resource:
4595
+ * - Compute each instance's availability (full timeframe minus its busy events)
4596
+ * - Union all instance availabilities (at least one must be free)
4597
+ * Then intersect all resource availabilities with the current doctor availability.
4598
+ *
4599
+ * @param intervals - Current available intervals (doctor availability)
4600
+ * @param resourceEventsMap - Map of resource data with per-instance calendar events
4601
+ * @param timeframe - Overall timeframe being considered
4602
+ * @returns Intervals where doctor AND all required resources are available
4603
+ */
4604
+ private static applyResourceAvailability;
4605
+ /**
4606
+ * Compute combined availability for a single resource across all its instances.
4607
+ * For each instance, subtract its busy events from the full timeframe.
4608
+ * Then union all instance availabilities — if at least one instance is free, the resource is available.
4609
+ *
4610
+ * @param instanceEvents - Calendar events keyed by instanceId
4611
+ * @param timeframe - Overall timeframe
4612
+ * @returns Combined availability intervals for the resource
4613
+ */
4614
+ private static computeResourceAvailability;
4498
4615
  }
4499
4616
 
4500
4617
  /**
@@ -4628,6 +4745,44 @@ declare class CalendarAdminService {
4628
4745
  deleteAppointmentCalendarEvents(appointment: Appointment): Promise<void>;
4629
4746
  }
4630
4747
 
4748
+ /**
4749
+ * @class ResourceCalendarAdminService
4750
+ * @description Handles administrative tasks for resource calendar events linked to appointments,
4751
+ * such as status updates, time changes, or deletions during appointment lifecycle events.
4752
+ */
4753
+ declare class ResourceCalendarAdminService {
4754
+ private db;
4755
+ constructor(firestore?: admin.firestore.Firestore);
4756
+ /**
4757
+ * Builds the Firestore document path for a resource calendar event.
4758
+ */
4759
+ private getResourceCalendarEventPath;
4760
+ /**
4761
+ * Updates the status of all resource calendar events associated with a given appointment.
4762
+ *
4763
+ * @param appointment - The appointment object containing resourceBookings.
4764
+ * @param newStatus - The new CalendarEventStatus to set.
4765
+ */
4766
+ updateResourceBookingEventsStatus(appointment: Appointment, newStatus: CalendarEventStatus): Promise<void>;
4767
+ /**
4768
+ * Updates the eventTime (start and end) of all resource calendar events
4769
+ * associated with a given appointment.
4770
+ *
4771
+ * @param appointment - The appointment object containing resourceBookings.
4772
+ * @param newEventTime - The new event time with admin Timestamps.
4773
+ */
4774
+ updateResourceBookingEventsTime(appointment: Appointment, newEventTime: {
4775
+ start: admin.firestore.Timestamp;
4776
+ end: admin.firestore.Timestamp;
4777
+ }): Promise<void>;
4778
+ /**
4779
+ * Deletes all resource calendar events associated with a given appointment.
4780
+ *
4781
+ * @param appointment - The appointment object containing resourceBookings.
4782
+ */
4783
+ deleteResourceBookingEvents(appointment: Appointment): Promise<void>;
4784
+ }
4785
+
4631
4786
  interface InitializeAppointmentFormsResult {
4632
4787
  initializedFormsInfo: LinkedFormInfo[];
4633
4788
  pendingUserFormsIds: string[];
@@ -5104,4 +5259,4 @@ declare class UserProfileAdminService {
5104
5259
  initializePractitionerRole(userId: string): Promise<User>;
5105
5260
  }
5106
5261
 
5107
- export { ANALYTICS_COLLECTION, AnalyticsAdminService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, type Appointment, AppointmentAggregationService, type AppointmentCancellationEmailData, type AppointmentConfirmationEmailData, type AppointmentEmailDataBase, AppointmentMailingService, type AppointmentReminderNotification, type AppointmentRequestedEmailData, type AppointmentRescheduledProposalEmailData, AppointmentStatus, type AppointmentTrend, type AvailableSlot, BaseMailingService, type BaseMetrics, type BaseNotification, type BillingInfo, type BillingTransaction, BillingTransactionType, BookingAdmin, BookingAvailabilityCalculator, type BookingAvailabilityRequest, type BookingAvailabilityResponse, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CalendarAdminService, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Clinic, type ClinicAdminNotificationData, ClinicAggregationService, type ClinicAnalytics, type ClinicComparisonMetrics, type ClinicGroup, type ClinicInfo, type ClinicLocation, type ClinicWelcomeEmailData, ClinicWelcomeMailingService, type CostPerPatientMetrics, type CreateBillingTransactionData, DASHBOARD_ANALYTICS_SUBCOLLECTION, type DashboardAnalytics, type DoctorInfo, DocumentManagerAdminService, type DurationTrend, type EntityType, type ExistingPractitionerInviteEmailData, ExistingPractitionerInviteMailingService, type FilledDocument, FilledFormsAggregationService, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, INVITE_TOKENS_COLLECTION, type InitializeAppointmentFormsResult, Logger, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NewMailgunClient$4 as NewMailgunClient, type NoShowMetrics, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type OrchestrateAppointmentCreationData, PATIENTS_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type PatientProfile as Patient, PatientAggregationService, type PatientAnalytics, PatientInstructionStatus, type PatientInviteEmailData, PatientInviteMailingService, type PatientLifetimeValueMetrics, type PatientProfile, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, PatientRequirementsAdminService, type PatientRetentionMetrics, type PatientSensitiveInfo, type PatientToken, PatientTokenStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, type PractitionerAnalytics, type PractitionerInvite, PractitionerInviteAggregationService, type PractitionerInviteEmailData, PractitionerInviteMailingService, PractitionerInviteStatus, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureAnalytics, type ProcedurePopularity, type ProcedureProfitability, type ProcedureSummaryInfo, type ProductRevenueMetrics, type ProductUsageByProcedure, type ProductUsageMetrics, REVENUE_ANALYTICS_SUBCOLLECTION, type ReadStoredAnalyticsOptions, type RequirementSourceProcedure, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAddedEmailData, type ReviewMetrics, type ReviewRequestEmailData, type ReviewTrend, ReviewsAggregationService, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, SubscriptionStatus, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type TimeEfficiencyMetrics, type TimeInterval, type TrendPeriod, UserProfileAdminService, UserRole, freeConsultationInfrastructure };
5262
+ export { ANALYTICS_COLLECTION, AnalyticsAdminService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, type Appointment, AppointmentAggregationService, type AppointmentCancellationEmailData, type AppointmentConfirmationEmailData, type AppointmentEmailDataBase, AppointmentMailingService, type AppointmentReminderNotification, type AppointmentRequestedEmailData, type AppointmentRescheduledProposalEmailData, AppointmentStatus, type AppointmentTrend, type AvailableSlot, BaseMailingService, type BaseMetrics, type BaseNotification, type BillingInfo, type BillingTransaction, BillingTransactionType, BookingAdmin, BookingAvailabilityCalculator, type BookingAvailabilityRequest, type BookingAvailabilityResponse, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CalendarAdminService, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Clinic, type ClinicAdminNotificationData, ClinicAggregationService, type ClinicAnalytics, type ClinicComparisonMetrics, type ClinicGroup, type ClinicInfo, type ClinicLocation, type ClinicWelcomeEmailData, ClinicWelcomeMailingService, type CostPerPatientMetrics, type CreateBillingTransactionData, DASHBOARD_ANALYTICS_SUBCOLLECTION, type DashboardAnalytics, type DoctorInfo, DocumentManagerAdminService, type DurationTrend, type EntityType, type ExistingPractitionerInviteEmailData, ExistingPractitionerInviteMailingService, type FilledDocument, FilledFormsAggregationService, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, INVITE_TOKENS_COLLECTION, type InitializeAppointmentFormsResult, Logger, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NewMailgunClient$4 as NewMailgunClient, type NoShowMetrics, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type OrchestrateAppointmentCreationData, PATIENTS_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type PatientProfile as Patient, PatientAggregationService, type PatientAnalytics, PatientInstructionStatus, type PatientInviteEmailData, PatientInviteMailingService, type PatientLifetimeValueMetrics, type PatientProfile, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, PatientRequirementsAdminService, type PatientRetentionMetrics, type PatientSensitiveInfo, type PatientToken, PatientTokenStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, type PractitionerAnalytics, type PractitionerInvite, PractitionerInviteAggregationService, type PractitionerInviteEmailData, PractitionerInviteMailingService, PractitionerInviteStatus, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureAnalytics, type ProcedurePopularity, type ProcedureProfitability, type ProcedureSummaryInfo, type ProductRevenueMetrics, type ProductUsageByProcedure, type ProductUsageMetrics, REVENUE_ANALYTICS_SUBCOLLECTION, type ReadStoredAnalyticsOptions, type RequirementSourceProcedure, ResourceCalendarAdminService, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAddedEmailData, type ReviewMetrics, type ReviewRequestEmailData, type ReviewTrend, ReviewsAggregationService, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, SubscriptionStatus, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type TimeEfficiencyMetrics, type TimeInterval, type TrendPeriod, UserProfileAdminService, UserRole, freeConsultationInfrastructure };