@blackcode_sa/metaestetics-api 1.5.32 → 1.5.33

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.
@@ -1,5 +1,6 @@
1
1
  import { Timestamp } from 'firebase/firestore';
2
2
  import * as admin from 'firebase-admin';
3
+ import { Timestamp as Timestamp$1 } from 'firebase-admin/firestore';
3
4
  import * as mailgun from 'mailgun-js';
4
5
 
5
6
  /**
@@ -607,6 +608,8 @@ interface ProcedureSummaryInfo {
607
608
  categoryName: string;
608
609
  subcategoryName: string;
609
610
  technologyName: string;
611
+ brandName?: string;
612
+ productName?: string;
610
613
  price: number;
611
614
  pricingMeasure: PricingMeasure;
612
615
  currency: Currency;
@@ -736,6 +739,17 @@ interface PractitionerToken {
736
739
  usedAt?: Timestamp;
737
740
  }
738
741
 
742
+ /**
743
+ * Enumeracija za pol pacijenta
744
+ */
745
+ declare enum Gender {
746
+ MALE = "male",
747
+ FEMALE = "female",
748
+ TRANSGENDER_MALE = "transgender_male",
749
+ TRANSGENDER_FEMALE = "transgender_female",
750
+ PREFER_NOT_TO_SAY = "prefer_not_to_say",
751
+ OTHER = "other"
752
+ }
739
753
  /**
740
754
  * Interfejs za gamifikaciju
741
755
  */
@@ -798,6 +812,28 @@ interface ClinicInfo {
798
812
  location: ClinicLocation;
799
813
  contactInfo: ClinicContactInfo;
800
814
  }
815
+ /**
816
+ * Interface for practitioner profile information
817
+ */
818
+ interface PractitionerProfileInfo {
819
+ id: string;
820
+ practitionerPhoto: string | null;
821
+ name: string;
822
+ email: string;
823
+ phone: string | null;
824
+ certification: PractitionerCertification;
825
+ }
826
+ /**
827
+ * Interface for patient profile information
828
+ */
829
+ interface PatientProfileInfo {
830
+ id: string;
831
+ fullName: string;
832
+ email: string;
833
+ phone: string | null;
834
+ dateOfBirth: Timestamp$1;
835
+ gender: Gender;
836
+ }
801
837
 
802
838
  /**
803
839
  * Enum for all possible clinic tags
@@ -978,6 +1014,96 @@ interface Clinic {
978
1014
  logo?: string;
979
1015
  }
980
1016
 
1017
+ /**
1018
+ * Enum for synced calendar provider
1019
+ */
1020
+ declare enum SyncedCalendarProvider {
1021
+ GOOGLE = "google",
1022
+ OUTLOOK = "outlook",
1023
+ APPLE = "apple"
1024
+ }
1025
+
1026
+ /**
1027
+ * Enum for calendar event status
1028
+ */
1029
+ declare enum CalendarEventStatus {
1030
+ PENDING = "pending",// When event is created, but not confirmed
1031
+ CONFIRMED = "confirmed",// When event is confirmed and ready to be used
1032
+ REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
1033
+ CANCELED = "canceled",// When event is canceled by the patient
1034
+ RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
1035
+ COMPLETED = "completed"
1036
+ }
1037
+ /**
1038
+ * Enum for calendar event sync status
1039
+ */
1040
+ declare enum CalendarSyncStatus {
1041
+ INTERNAL = "internal",
1042
+ EXTERNAL = "external"
1043
+ }
1044
+ /**
1045
+ * Enum for calendar event types
1046
+ */
1047
+ declare enum CalendarEventType {
1048
+ APPOINTMENT = "appointment",
1049
+ BLOCKING = "blocking",
1050
+ BREAK = "break",
1051
+ FREE_DAY = "free_day",
1052
+ OTHER = "other"
1053
+ }
1054
+ /**
1055
+ * Interface for calendar event time
1056
+ */
1057
+ interface CalendarEventTime {
1058
+ start: Timestamp;
1059
+ end: Timestamp;
1060
+ }
1061
+ interface ProcedureInfo {
1062
+ name: string;
1063
+ description: string;
1064
+ duration: number;
1065
+ price: number;
1066
+ currency: Currency;
1067
+ }
1068
+ interface ProcedureCategorization {
1069
+ procedureFamily: ProcedureFamily;
1070
+ procedureCategory: Category;
1071
+ procedureSubcategory: Subcategory;
1072
+ procedureTechnology: Technology;
1073
+ procedureProduct: Product;
1074
+ }
1075
+ interface SyncedCalendarEvent {
1076
+ eventId: string;
1077
+ syncedCalendarProvider: SyncedCalendarProvider;
1078
+ syncedAt: Timestamp;
1079
+ }
1080
+ /**
1081
+ * Interface for calendar event
1082
+ */
1083
+ interface CalendarEvent {
1084
+ id: string;
1085
+ clinicBranchId?: string | null;
1086
+ clinicBranchInfo?: ClinicInfo | null;
1087
+ practitionerProfileId?: string | null;
1088
+ practitionerProfileInfo?: PractitionerProfileInfo | null;
1089
+ patientProfileId?: string | null;
1090
+ patientProfileInfo?: PatientProfileInfo | null;
1091
+ procedureId?: string | null;
1092
+ procedureInfo?: ProcedureInfo | null;
1093
+ procedureCategorization?: ProcedureCategorization | null;
1094
+ appointmentId?: string | null;
1095
+ syncedCalendarEventId?: SyncedCalendarEvent[] | null;
1096
+ eventName: string;
1097
+ eventLocation?: ClinicLocation;
1098
+ eventTime: CalendarEventTime;
1099
+ description?: string;
1100
+ status: CalendarEventStatus;
1101
+ syncStatus: CalendarSyncStatus;
1102
+ eventType: CalendarEventType;
1103
+ createdAt: Timestamp;
1104
+ updatedAt: Timestamp;
1105
+ }
1106
+
981
1107
  declare enum UserRole {
982
1108
  PATIENT = "patient",
983
1109
  PRACTITIONER = "practitioner",
@@ -1475,4 +1601,214 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
1475
1601
  handleTokenCreationEvent(tokenData: PractitionerToken, fromAddress: string): Promise<void>;
1476
1602
  }
1477
1603
 
1478
- export { type AppointmentNotification, type AppointmentReminderNotification, BaseMailingService, type BaseNotification, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type PatientProfile as Patient, PatientAggregationService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, UserRole };
1604
+ /**
1605
+ * Request parameters for calculating available booking slots
1606
+ */
1607
+ interface BookingAvailabilityRequest {
1608
+ /** The clinic for which to calculate booking slots */
1609
+ clinic: Clinic;
1610
+ /** The practitioner for which to calculate booking slots */
1611
+ practitioner: Practitioner;
1612
+ /** The procedure for which to calculate booking slots */
1613
+ procedure: Procedure;
1614
+ /** The timeframe for which to calculate booking slots */
1615
+ timeframe: {
1616
+ start: Timestamp;
1617
+ end: Timestamp;
1618
+ };
1619
+ /** Calendar events for the clinic during the specified timeframe */
1620
+ clinicCalendarEvents: CalendarEvent[];
1621
+ /** Calendar events for the practitioner during the specified timeframe */
1622
+ practitionerCalendarEvents: CalendarEvent[];
1623
+ }
1624
+ /**
1625
+ * Represents a single available booking slot
1626
+ */
1627
+ interface AvailableSlot {
1628
+ /** Start time of the available booking slot */
1629
+ start: Timestamp;
1630
+ }
1631
+ /**
1632
+ * Response with available booking slots
1633
+ */
1634
+ interface BookingAvailabilityResponse {
1635
+ /** Array of available booking slots */
1636
+ availableSlots: AvailableSlot[];
1637
+ }
1638
+ /**
1639
+ * Represents a time interval with start and end times
1640
+ * Used internally for availability calculations
1641
+ */
1642
+ interface TimeInterval {
1643
+ start: Timestamp;
1644
+ end: Timestamp;
1645
+ }
1646
+
1647
+ /**
1648
+ * Calculator for determining available booking slots
1649
+ * This class handles the complex logic of determining when appointments can be scheduled
1650
+ * based on clinic working hours, practitioner availability, and existing calendar events.
1651
+ */
1652
+ declare class BookingAvailabilityCalculator {
1653
+ /** Default scheduling interval in minutes if not specified by the clinic */
1654
+ private static readonly DEFAULT_INTERVAL_MINUTES;
1655
+ /**
1656
+ * Calculate available booking slots based on the provided data
1657
+ *
1658
+ * @param request - The request containing all necessary data for calculation
1659
+ * @returns Response with available booking slots
1660
+ */
1661
+ static calculateSlots(request: BookingAvailabilityRequest): BookingAvailabilityResponse;
1662
+ /**
1663
+ * Apply clinic working hours to available intervals
1664
+ *
1665
+ * @param intervals - Current available intervals
1666
+ * @param workingHours - Clinic working hours
1667
+ * @param timeframe - Overall timeframe being considered
1668
+ * @returns Intervals filtered by clinic working hours
1669
+ */
1670
+ private static applyClinicWorkingHours;
1671
+ /**
1672
+ * Create time intervals for working hours across multiple days
1673
+ *
1674
+ * @param workingHours - Working hours definition
1675
+ * @param startDate - Start date of the overall timeframe
1676
+ * @param endDate - End date of the overall timeframe
1677
+ * @returns Array of time intervals representing working hours
1678
+ */
1679
+ private static createWorkingHoursIntervals;
1680
+ /**
1681
+ * Subtract blocking events from available intervals
1682
+ *
1683
+ * @param intervals - Current available intervals
1684
+ * @param events - Calendar events to subtract
1685
+ * @returns Available intervals after removing blocking events
1686
+ */
1687
+ private static subtractBlockingEvents;
1688
+ /**
1689
+ * Apply practitioner's specific working hours for the given clinic
1690
+ *
1691
+ * @param intervals - Current available intervals
1692
+ * @param practitioner - Practitioner object
1693
+ * @param clinicId - ID of the clinic
1694
+ * @param timeframe - Overall timeframe being considered
1695
+ * @returns Intervals filtered by practitioner's working hours
1696
+ */
1697
+ private static applyPractitionerWorkingHours;
1698
+ /**
1699
+ * Create time intervals for practitioner's working hours across multiple days
1700
+ *
1701
+ * @param workingHours - Practitioner's working hours definition
1702
+ * @param startDate - Start date of the overall timeframe
1703
+ * @param endDate - End date of the overall timeframe
1704
+ * @returns Array of time intervals representing practitioner's working hours
1705
+ */
1706
+ private static createPractitionerWorkingHoursIntervals;
1707
+ /**
1708
+ * Subtract practitioner's busy times from available intervals
1709
+ *
1710
+ * @param intervals - Current available intervals
1711
+ * @param events - Practitioner's calendar events
1712
+ * @returns Available intervals after removing busy times
1713
+ */
1714
+ private static subtractPractitionerBusyTimes;
1715
+ /**
1716
+ * Generate available booking slots based on the final available intervals
1717
+ *
1718
+ * @param intervals - Final available intervals
1719
+ * @param intervalMinutes - Scheduling interval in minutes
1720
+ * @param durationMinutes - Procedure duration in minutes
1721
+ * @returns Array of available booking slots
1722
+ */
1723
+ private static generateAvailableSlots;
1724
+ /**
1725
+ * Check if a time slot is fully available within the given intervals
1726
+ *
1727
+ * @param slotStart - Start time of the slot
1728
+ * @param slotEnd - End time of the slot
1729
+ * @param intervals - Available intervals
1730
+ * @returns True if the slot is fully contained within an available interval
1731
+ */
1732
+ private static isSlotFullyAvailable;
1733
+ /**
1734
+ * Intersect two sets of time intervals
1735
+ *
1736
+ * @param intervalsA - First set of intervals
1737
+ * @param intervalsB - Second set of intervals
1738
+ * @returns Intersection of the two sets of intervals
1739
+ */
1740
+ private static intersectIntervals;
1741
+ /**
1742
+ * Subtract one interval from another, potentially resulting in 0, 1, or 2 intervals
1743
+ *
1744
+ * @param interval - Interval to subtract from
1745
+ * @param subtrahend - Interval to subtract
1746
+ * @returns Array of remaining intervals after subtraction
1747
+ */
1748
+ private static subtractInterval;
1749
+ /**
1750
+ * Merge overlapping intervals to simplify the result
1751
+ *
1752
+ * @param intervals - Intervals to merge
1753
+ * @returns Merged intervals
1754
+ */
1755
+ private static mergeOverlappingIntervals;
1756
+ }
1757
+
1758
+ /**
1759
+ * Admin service for handling booking-related operations.
1760
+ * This is the cloud-based implementation that will be used in Cloud Functions.
1761
+ */
1762
+ declare class BookingAdmin {
1763
+ private db;
1764
+ /**
1765
+ * Creates a new BookingAdmin instance
1766
+ * @param firestore - Firestore instance provided by the caller
1767
+ */
1768
+ constructor(firestore?: admin.firestore.Firestore);
1769
+ /**
1770
+ * Gets available booking time slots for a specific clinic, practitioner, and procedure
1771
+ *
1772
+ * @param clinicId - ID of the clinic
1773
+ * @param practitionerId - ID of the practitioner
1774
+ * @param procedureId - ID of the procedure
1775
+ * @param timeframe - Time range to check for availability
1776
+ * @returns Promise resolving to an array of available booking slots
1777
+ */
1778
+ getAvailableBookingSlots(clinicId: string, practitionerId: string, procedureId: string, timeframe: {
1779
+ start: Date | admin.firestore.Timestamp;
1780
+ end: Date | admin.firestore.Timestamp;
1781
+ }): Promise<{
1782
+ availableSlots: {
1783
+ start: admin.firestore.Timestamp;
1784
+ }[];
1785
+ }>;
1786
+ /**
1787
+ * Converts an admin Firestore Timestamp to a client Firestore Timestamp
1788
+ */
1789
+ private adminTimestampToClientTimestamp;
1790
+ /**
1791
+ * Converts timestamps in calendar events from admin Firestore Timestamps to client Firestore Timestamps
1792
+ */
1793
+ private convertEventsTimestamps;
1794
+ /**
1795
+ * Fetches clinic calendar events for a specific time range
1796
+ *
1797
+ * @param clinicId - ID of the clinic
1798
+ * @param start - Start time of the range
1799
+ * @param end - End time of the range
1800
+ * @returns Promise resolving to an array of calendar events
1801
+ */
1802
+ private getClinicCalendarEvents;
1803
+ /**
1804
+ * Fetches practitioner calendar events for a specific time range
1805
+ *
1806
+ * @param practitionerId - ID of the practitioner
1807
+ * @param start - Start time of the range
1808
+ * @param end - End time of the range
1809
+ * @returns Promise resolving to an array of calendar events
1810
+ */
1811
+ private getPractitionerCalendarEvents;
1812
+ }
1813
+
1814
+ export { type AppointmentNotification, type AppointmentReminderNotification, type AvailableSlot, BaseMailingService, type BaseNotification, BookingAdmin, BookingAvailabilityCalculator, type BookingAvailabilityRequest, type BookingAvailabilityResponse, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, type PatientProfile as Patient, PatientAggregationService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, type TimeInterval, UserRole };