@blackcode_sa/metaestetics-api 1.6.4 → 1.6.5

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.
@@ -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 */
@@ -1722,6 +1739,186 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
1722
1739
  }): Promise<void>;
1723
1740
  }
1724
1741
 
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
+ /**
1913
+ * Interface for the data required by orchestrateAppointmentCreation
1914
+ */
1915
+ interface OrchestrateAppointmentCreationData {
1916
+ patientId: string;
1917
+ procedureId: string;
1918
+ appointmentStartTime: admin.firestore.Timestamp;
1919
+ appointmentEndTime: admin.firestore.Timestamp;
1920
+ patientNotes?: string | null;
1921
+ }
1725
1922
  /**
1726
1923
  * Admin service for handling booking-related operations.
1727
1924
  * This is the cloud-based implementation that will be used in Cloud Functions.
@@ -1776,6 +1973,20 @@ declare class BookingAdmin {
1776
1973
  * @returns Promise resolving to an array of calendar events
1777
1974
  */
1778
1975
  private getPractitionerCalendarEvents;
1976
+ /**
1977
+ * Orchestrates the creation of a new appointment, including data aggregation.
1978
+ * This method is intended to be called from a trusted backend environment (e.g., an Express route handler in a Cloud Function).
1979
+ *
1980
+ * @param data - Data required to create the appointment.
1981
+ * @param authenticatedUserId - The ID of the user making the request (for auditing, and usually is the patientId).
1982
+ * @returns Promise resolving to an object indicating success, and appointmentId or an error message.
1983
+ */
1984
+ orchestrateAppointmentCreation(data: OrchestrateAppointmentCreationData, authenticatedUserId: string): Promise<{
1985
+ success: boolean;
1986
+ appointmentId?: string;
1987
+ appointmentData?: Appointment;
1988
+ error?: string;
1989
+ }>;
1779
1990
  }
1780
1991
 
1781
1992
  /**
@@ -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 */
@@ -1722,6 +1739,186 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
1722
1739
  }): Promise<void>;
1723
1740
  }
1724
1741
 
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
+ /**
1913
+ * Interface for the data required by orchestrateAppointmentCreation
1914
+ */
1915
+ interface OrchestrateAppointmentCreationData {
1916
+ patientId: string;
1917
+ procedureId: string;
1918
+ appointmentStartTime: admin.firestore.Timestamp;
1919
+ appointmentEndTime: admin.firestore.Timestamp;
1920
+ patientNotes?: string | null;
1921
+ }
1725
1922
  /**
1726
1923
  * Admin service for handling booking-related operations.
1727
1924
  * This is the cloud-based implementation that will be used in Cloud Functions.
@@ -1776,6 +1973,20 @@ declare class BookingAdmin {
1776
1973
  * @returns Promise resolving to an array of calendar events
1777
1974
  */
1778
1975
  private getPractitionerCalendarEvents;
1976
+ /**
1977
+ * Orchestrates the creation of a new appointment, including data aggregation.
1978
+ * This method is intended to be called from a trusted backend environment (e.g., an Express route handler in a Cloud Function).
1979
+ *
1980
+ * @param data - Data required to create the appointment.
1981
+ * @param authenticatedUserId - The ID of the user making the request (for auditing, and usually is the patientId).
1982
+ * @returns Promise resolving to an object indicating success, and appointmentId or an error message.
1983
+ */
1984
+ orchestrateAppointmentCreation(data: OrchestrateAppointmentCreationData, authenticatedUserId: string): Promise<{
1985
+ success: boolean;
1986
+ appointmentId?: string;
1987
+ appointmentData?: Appointment;
1988
+ error?: string;
1989
+ }>;
1779
1990
  }
1780
1991
 
1781
1992
  /**