@blackcode_sa/metaestetics-api 1.12.59 → 1.12.62

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.
@@ -507,6 +507,9 @@ var PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME = "patientRequirements";
507
507
  // src/admin/aggregation/appointment/appointment.aggregation.service.ts
508
508
  import * as admin6 from "firebase-admin";
509
509
 
510
+ // src/types/procedure/index.ts
511
+ var PROCEDURES_COLLECTION = "procedures";
512
+
510
513
  // src/admin/requirements/patient-requirements.admin.service.ts
511
514
  import * as admin3 from "firebase-admin";
512
515
 
@@ -518,9 +521,6 @@ var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
518
521
  var USER_FORMS_SUBCOLLECTION = "user-forms";
519
522
  var DOCTOR_FORMS_SUBCOLLECTION = "doctor-forms";
520
523
 
521
- // src/types/procedure/index.ts
522
- var PROCEDURES_COLLECTION = "procedures";
523
-
524
524
  // src/types/reviews/index.ts
525
525
  var REVIEWS_COLLECTION = "reviews";
526
526
 
@@ -3131,17 +3131,122 @@ var AppointmentAggregationService = class {
3131
3131
  throw error;
3132
3132
  }
3133
3133
  }
3134
+ /**
3135
+ * Fetches post-requirements from a procedure document
3136
+ * @param procedureId - The procedure ID to fetch requirements from
3137
+ * @returns Promise resolving to array of post-requirements with source procedure info
3138
+ */
3139
+ async fetchPostRequirementsFromProcedure(procedureId) {
3140
+ try {
3141
+ const procedureDoc = await this.db.collection(PROCEDURES_COLLECTION).doc(procedureId).get();
3142
+ if (!procedureDoc.exists) {
3143
+ Logger.warn(`[AggService] Procedure ${procedureId} not found when fetching requirements`);
3144
+ return [];
3145
+ }
3146
+ const procedure = procedureDoc.data();
3147
+ const postRequirements = procedure.postRequirements || [];
3148
+ if (postRequirements.length === 0) {
3149
+ return [];
3150
+ }
3151
+ return postRequirements.map((req) => ({
3152
+ requirement: req,
3153
+ sourceProcedures: [
3154
+ {
3155
+ procedureId: procedure.id,
3156
+ procedureName: procedure.name
3157
+ }
3158
+ ]
3159
+ }));
3160
+ } catch (error) {
3161
+ Logger.error(
3162
+ `[AggService] Error fetching post-requirements from procedure ${procedureId}:`,
3163
+ error
3164
+ );
3165
+ return [];
3166
+ }
3167
+ }
3168
+ /**
3169
+ * Collects all post-requirements from primary and extended procedures
3170
+ * @param appointment - The appointment to collect requirements for
3171
+ * @returns Promise resolving to array of requirements with source procedures
3172
+ */
3173
+ async collectAllPostRequirements(appointment) {
3174
+ var _a;
3175
+ const allRequirements = [];
3176
+ if (appointment.procedureId) {
3177
+ const primaryRequirements = await this.fetchPostRequirementsFromProcedure(
3178
+ appointment.procedureId
3179
+ );
3180
+ allRequirements.push(...primaryRequirements);
3181
+ }
3182
+ const extendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.extendedProcedures) || [];
3183
+ if (extendedProcedures.length > 0) {
3184
+ Logger.info(
3185
+ `[AggService] Fetching post-requirements from ${extendedProcedures.length} extended procedures`
3186
+ );
3187
+ const extendedRequirementsPromises = extendedProcedures.map(
3188
+ (extProc) => this.fetchPostRequirementsFromProcedure(extProc.procedureId)
3189
+ );
3190
+ const extendedRequirementsArrays = await Promise.all(extendedRequirementsPromises);
3191
+ extendedRequirementsArrays.forEach((reqs) => {
3192
+ allRequirements.push(...reqs);
3193
+ });
3194
+ }
3195
+ return allRequirements;
3196
+ }
3197
+ /**
3198
+ * Generates a unique key for a requirement based on ID and timeframe
3199
+ * @param requirement - The requirement to generate a key for
3200
+ * @returns Unique key string
3201
+ */
3202
+ getRequirementKey(requirement) {
3203
+ var _a, _b, _c;
3204
+ const timeframeSig = JSON.stringify({
3205
+ duration: ((_a = requirement.timeframe) == null ? void 0 : _a.duration) || 0,
3206
+ unit: ((_b = requirement.timeframe) == null ? void 0 : _b.unit) || "",
3207
+ notifyAt: (((_c = requirement.timeframe) == null ? void 0 : _c.notifyAt) || []).slice().sort((a, b) => a - b)
3208
+ });
3209
+ return `${requirement.id}:${timeframeSig}`;
3210
+ }
3211
+ /**
3212
+ * Deduplicates requirements based on requirement ID and timeframe
3213
+ * Merges source procedures when requirements match
3214
+ * @param requirements - Array of requirements with sources
3215
+ * @returns Deduplicated array of requirements
3216
+ */
3217
+ deduplicateRequirements(requirements) {
3218
+ const requirementMap = /* @__PURE__ */ new Map();
3219
+ for (const reqWithSource of requirements) {
3220
+ const key = this.getRequirementKey(reqWithSource.requirement);
3221
+ if (requirementMap.has(key)) {
3222
+ const existing = requirementMap.get(key);
3223
+ const existingProcedureIds = new Set(
3224
+ existing.sourceProcedures.map((sp) => sp.procedureId)
3225
+ );
3226
+ reqWithSource.sourceProcedures.forEach((sp) => {
3227
+ if (!existingProcedureIds.has(sp.procedureId)) {
3228
+ existing.sourceProcedures.push(sp);
3229
+ }
3230
+ });
3231
+ } else {
3232
+ requirementMap.set(key, {
3233
+ requirement: reqWithSource.requirement,
3234
+ sourceProcedures: [...reqWithSource.sourceProcedures]
3235
+ });
3236
+ }
3237
+ }
3238
+ return Array.from(requirementMap.values());
3239
+ }
3134
3240
  /**
3135
3241
  * Creates POST_APPOINTMENT PatientRequirementInstance documents for a given appointment.
3136
- * Uses the `appointment.postProcedureRequirements` array.
3137
- * For each active POST requirement template, it constructs a new PatientRequirementInstance document
3138
- * with derived instructions and batch writes them to Firestore under the patient's `patient_requirements` subcollection.
3242
+ * Fetches requirements from primary and extended procedures, deduplicates them,
3243
+ * and creates requirement instances with source procedure tracking.
3139
3244
  *
3140
3245
  * @param {Appointment} appointment - The appointment for which to create post-requirement instances.
3141
3246
  * @returns {Promise<void>} A promise that resolves when the operation is complete.
3142
3247
  */
3143
3248
  async createPostAppointmentRequirementInstances(appointment) {
3144
- var _a;
3249
+ var _a, _b;
3145
3250
  Logger.info(
3146
3251
  `[AggService] Creating POST-appointment requirement instances for appt: ${appointment.id}, patient: ${appointment.patientId}`
3147
3252
  );
@@ -3151,32 +3256,42 @@ var AppointmentAggregationService = class {
3151
3256
  );
3152
3257
  return;
3153
3258
  }
3154
- if (!appointment.postProcedureRequirements || appointment.postProcedureRequirements.length === 0) {
3259
+ try {
3260
+ const allRequirements = await this.collectAllPostRequirements(appointment);
3261
+ if (allRequirements.length === 0) {
3262
+ Logger.info(
3263
+ `[AggService] No post-requirements found from any procedures for appointment ${appointment.id}. Nothing to create.`
3264
+ );
3265
+ return;
3266
+ }
3267
+ const deduplicatedRequirements = this.deduplicateRequirements(allRequirements);
3155
3268
  Logger.info(
3156
- `[AggService] No postProcedureRequirements found on appointment ${appointment.id}. Nothing to create.`
3269
+ `[AggService] Found ${allRequirements.length} total post-requirements, ${deduplicatedRequirements.length} after deduplication`
3157
3270
  );
3158
- return;
3159
- }
3160
- try {
3161
- const batch = this.db.batch();
3162
- let instancesCreatedCount = 0;
3163
- let createdInstances = [];
3164
3271
  Logger.info(
3165
- `[AggService] Found ${appointment.postProcedureRequirements.length} post-requirements to process: ${JSON.stringify(
3166
- appointment.postProcedureRequirements.map((r) => {
3167
- var _a2, _b;
3272
+ `[AggService] Processing deduplicated post-requirements: ${JSON.stringify(
3273
+ deduplicatedRequirements.map((r) => {
3274
+ var _a2, _b2;
3168
3275
  return {
3169
- id: r.id,
3170
- name: r.name,
3171
- type: r.type,
3172
- isActive: r.isActive,
3173
- hasTimeframe: !!r.timeframe,
3174
- notifyAtLength: ((_b = (_a2 = r.timeframe) == null ? void 0 : _a2.notifyAt) == null ? void 0 : _b.length) || 0
3276
+ id: r.requirement.id,
3277
+ name: r.requirement.name,
3278
+ type: r.requirement.type,
3279
+ isActive: r.requirement.isActive,
3280
+ hasTimeframe: !!r.requirement.timeframe,
3281
+ notifyAtLength: ((_b2 = (_a2 = r.requirement.timeframe) == null ? void 0 : _a2.notifyAt) == null ? void 0 : _b2.length) || 0,
3282
+ sourceProcedures: r.sourceProcedures.map((sp) => ({
3283
+ procedureId: sp.procedureId,
3284
+ procedureName: sp.procedureName
3285
+ }))
3175
3286
  };
3176
3287
  })
3177
3288
  )}`
3178
3289
  );
3179
- for (const template of appointment.postProcedureRequirements) {
3290
+ const batch = this.db.batch();
3291
+ let instancesCreatedCount = 0;
3292
+ let createdInstances = [];
3293
+ for (const reqWithSource of deduplicatedRequirements) {
3294
+ const template = reqWithSource.requirement;
3180
3295
  if (!template) {
3181
3296
  Logger.warn(
3182
3297
  `[AggService] Found null/undefined template in postProcedureRequirements array`
@@ -3239,6 +3354,8 @@ var AppointmentAggregationService = class {
3239
3354
  requirementImportance: template.importance,
3240
3355
  overallStatus: "active" /* ACTIVE */,
3241
3356
  instructions,
3357
+ sourceProcedures: reqWithSource.sourceProcedures,
3358
+ // Track which procedures this requirement comes from
3242
3359
  createdAt: admin6.firestore.FieldValue.serverTimestamp(),
3243
3360
  updatedAt: admin6.firestore.FieldValue.serverTimestamp()
3244
3361
  };
@@ -3248,7 +3365,11 @@ var AppointmentAggregationService = class {
3248
3365
  patientId: newInstanceData.patientId,
3249
3366
  appointmentId: newInstanceData.appointmentId,
3250
3367
  requirementName: newInstanceData.requirementName,
3251
- instructionsCount: newInstanceData.instructions.length
3368
+ instructionsCount: newInstanceData.instructions.length,
3369
+ sourceProcedures: ((_b = newInstanceData.sourceProcedures) == null ? void 0 : _b.map((sp) => ({
3370
+ procedureId: sp.procedureId,
3371
+ procedureName: sp.procedureName
3372
+ }))) || []
3252
3373
  })}`
3253
3374
  );
3254
3375
  batch.set(newInstanceRef, newInstanceData);
@@ -6192,6 +6313,16 @@ var ReviewsAggregationService = class {
6192
6313
  this.updateProcedureReviewInfo(review.procedureReview.procedureId)
6193
6314
  );
6194
6315
  }
6316
+ if (review.extendedProcedureReviews && review.extendedProcedureReviews.length > 0) {
6317
+ console.log(
6318
+ `[ReviewsAggregationService] Processing ${review.extendedProcedureReviews.length} extended procedure reviews`
6319
+ );
6320
+ review.extendedProcedureReviews.forEach((extendedReview) => {
6321
+ updatePromises.push(
6322
+ this.updateProcedureReviewInfo(extendedReview.procedureId)
6323
+ );
6324
+ });
6325
+ }
6195
6326
  await Promise.all(updatePromises);
6196
6327
  console.log(
6197
6328
  `[ReviewsAggregationService] Successfully processed review: ${review.id}`
@@ -6234,6 +6365,20 @@ var ReviewsAggregationService = class {
6234
6365
  )
6235
6366
  );
6236
6367
  }
6368
+ if (review.extendedProcedureReviews && review.extendedProcedureReviews.length > 0) {
6369
+ console.log(
6370
+ `[ReviewsAggregationService] Processing deletion of ${review.extendedProcedureReviews.length} extended procedure reviews`
6371
+ );
6372
+ review.extendedProcedureReviews.forEach((extendedReview) => {
6373
+ updatePromises.push(
6374
+ this.updateProcedureReviewInfo(
6375
+ extendedReview.procedureId,
6376
+ extendedReview,
6377
+ true
6378
+ )
6379
+ );
6380
+ });
6381
+ }
6237
6382
  await Promise.all(updatePromises);
6238
6383
  console.log(
6239
6384
  `[ReviewsAggregationService] Successfully processed deleted review: ${review.id}`
@@ -6451,8 +6596,21 @@ var ReviewsAggregationService = class {
6451
6596
  valueForMoney: 0,
6452
6597
  recommendationPercentage: 0
6453
6598
  };
6454
- const reviewsQuery = await this.db.collection(REVIEWS_COLLECTION).where("procedureReview.procedureId", "==", procedureId).get();
6455
- if (isRemoval && reviewsQuery.size <= 1 || reviewsQuery.empty) {
6599
+ const allReviewsQuery = await this.db.collection(REVIEWS_COLLECTION).get();
6600
+ const reviews = allReviewsQuery.docs.map((doc) => doc.data());
6601
+ const procedureReviews = [];
6602
+ reviews.forEach((review) => {
6603
+ if (review.procedureReview && review.procedureReview.procedureId === procedureId) {
6604
+ procedureReviews.push(review.procedureReview);
6605
+ }
6606
+ if (review.extendedProcedureReviews && review.extendedProcedureReviews.length > 0) {
6607
+ const matchingExtended = review.extendedProcedureReviews.filter(
6608
+ (extReview) => extReview.procedureId === procedureId
6609
+ );
6610
+ procedureReviews.push(...matchingExtended);
6611
+ }
6612
+ });
6613
+ if (procedureReviews.length === 0) {
6456
6614
  const updatedReviewInfo2 = {
6457
6615
  totalReviews: 0,
6458
6616
  averageRating: 0,
@@ -6472,8 +6630,6 @@ var ReviewsAggregationService = class {
6472
6630
  );
6473
6631
  return updatedReviewInfo2;
6474
6632
  }
6475
- const reviews = reviewsQuery.docs.map((doc) => doc.data());
6476
- const procedureReviews = reviews.map((review) => review.procedureReview).filter((review) => review !== void 0);
6477
6633
  let totalRating = 0;
6478
6634
  let totalEffectivenessOfTreatment = 0;
6479
6635
  let totalOutcomeExplanation = 0;
@@ -6567,10 +6723,16 @@ var ReviewsAggregationService = class {
6567
6723
  if (review.procedureReview) {
6568
6724
  review.procedureReview.isVerified = true;
6569
6725
  }
6726
+ if (review.extendedProcedureReviews && review.extendedProcedureReviews.length > 0) {
6727
+ review.extendedProcedureReviews.forEach((extReview) => {
6728
+ extReview.isVerified = true;
6729
+ });
6730
+ }
6570
6731
  batch.update(reviewRef, {
6571
6732
  clinicReview: review.clinicReview,
6572
6733
  practitionerReview: review.practitionerReview,
6573
6734
  procedureReview: review.procedureReview,
6735
+ extendedProcedureReviews: review.extendedProcedureReviews,
6574
6736
  updatedAt: admin13.firestore.FieldValue.serverTimestamp()
6575
6737
  });
6576
6738
  await batch.commit();
package/dist/index.d.mts CHANGED
@@ -70,6 +70,7 @@ interface PractitionerReview extends BaseReview {
70
70
  /**
71
71
  * Procedure review interface
72
72
  * @description Full review for a medical procedure
73
+ * Used for both main and extended procedures
73
74
  */
74
75
  interface ProcedureReview extends BaseReview {
75
76
  procedureId: string;
@@ -138,6 +139,7 @@ interface Review {
138
139
  clinicReview?: ClinicReview;
139
140
  practitionerReview?: PractitionerReview;
140
141
  procedureReview?: ProcedureReview;
142
+ extendedProcedureReviews?: ProcedureReview[];
141
143
  overallComment: string;
142
144
  overallRating: number;
143
145
  }
@@ -3809,6 +3811,13 @@ declare enum PatientRequirementOverallStatus {
3809
3811
  SUPERSEDED_RESCHEDULE = "supersededReschedule",// This instance was replaced by a new one due to appointment reschedule.
3810
3812
  FAILED_TO_PROCESS = "failedToProcess"
3811
3813
  }
3814
+ /**
3815
+ * Represents source procedure information for a requirement instance
3816
+ */
3817
+ interface RequirementSourceProcedure {
3818
+ procedureId: string;
3819
+ procedureName: string;
3820
+ }
3812
3821
  /**
3813
3822
  * Represents an instance of a backoffice Requirement, tailored to a specific patient and appointment.
3814
3823
  * This document lives in the patient's subcollection: `patients/{patientId}/patientRequirements/{instanceId}`.
@@ -3824,6 +3833,7 @@ interface PatientRequirementInstance {
3824
3833
  requirementImportance: RequirementImportance;
3825
3834
  overallStatus: PatientRequirementOverallStatus;
3826
3835
  instructions: PatientRequirementInstruction[];
3836
+ sourceProcedures?: RequirementSourceProcedure[];
3827
3837
  createdAt: Timestamp;
3828
3838
  updatedAt: Timestamp;
3829
3839
  }
@@ -7514,4 +7524,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
7514
7524
  declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
7515
7525
  declare const getFirebaseFunctions: () => Promise<Functions>;
7516
7526
 
7517
- export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
7527
+ export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
package/dist/index.d.ts CHANGED
@@ -70,6 +70,7 @@ interface PractitionerReview extends BaseReview {
70
70
  /**
71
71
  * Procedure review interface
72
72
  * @description Full review for a medical procedure
73
+ * Used for both main and extended procedures
73
74
  */
74
75
  interface ProcedureReview extends BaseReview {
75
76
  procedureId: string;
@@ -138,6 +139,7 @@ interface Review {
138
139
  clinicReview?: ClinicReview;
139
140
  practitionerReview?: PractitionerReview;
140
141
  procedureReview?: ProcedureReview;
142
+ extendedProcedureReviews?: ProcedureReview[];
141
143
  overallComment: string;
142
144
  overallRating: number;
143
145
  }
@@ -3809,6 +3811,13 @@ declare enum PatientRequirementOverallStatus {
3809
3811
  SUPERSEDED_RESCHEDULE = "supersededReschedule",// This instance was replaced by a new one due to appointment reschedule.
3810
3812
  FAILED_TO_PROCESS = "failedToProcess"
3811
3813
  }
3814
+ /**
3815
+ * Represents source procedure information for a requirement instance
3816
+ */
3817
+ interface RequirementSourceProcedure {
3818
+ procedureId: string;
3819
+ procedureName: string;
3820
+ }
3812
3821
  /**
3813
3822
  * Represents an instance of a backoffice Requirement, tailored to a specific patient and appointment.
3814
3823
  * This document lives in the patient's subcollection: `patients/{patientId}/patientRequirements/{instanceId}`.
@@ -3824,6 +3833,7 @@ interface PatientRequirementInstance {
3824
3833
  requirementImportance: RequirementImportance;
3825
3834
  overallStatus: PatientRequirementOverallStatus;
3826
3835
  instructions: PatientRequirementInstruction[];
3836
+ sourceProcedures?: RequirementSourceProcedure[];
3827
3837
  createdAt: Timestamp;
3828
3838
  updatedAt: Timestamp;
3829
3839
  }
@@ -7514,4 +7524,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
7514
7524
  declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
7515
7525
  declare const getFirebaseFunctions: () => Promise<Functions>;
7516
7526
 
7517
- export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
7527
+ export { AESTHETIC_ANALYSIS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, CALENDAR_COLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicBranchSetupData, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DynamicTextElement, DynamicVariable, type EmergencyContact, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, type Notification, NotificationService, NotificationStatus, NotificationType, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, type ParagraphElement, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedureProduct, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, ProductService, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type Review, type ReviewRequestNotification, ReviewService, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
package/dist/index.js CHANGED
@@ -4696,6 +4696,7 @@ var reviewSchema = import_zod8.z.object({
4696
4696
  clinicReview: clinicReviewSchema.optional(),
4697
4697
  practitionerReview: practitionerReviewSchema.optional(),
4698
4698
  procedureReview: procedureReviewSchema.optional(),
4699
+ extendedProcedureReviews: import_zod8.z.array(procedureReviewSchema).optional(),
4699
4700
  overallComment: import_zod8.z.string().min(1).max(2e3),
4700
4701
  overallRating: import_zod8.z.number().min(1).max(5)
4701
4702
  });
@@ -4704,13 +4705,14 @@ var createReviewSchema = import_zod8.z.object({
4704
4705
  clinicReview: createClinicReviewSchema.optional(),
4705
4706
  practitionerReview: createPractitionerReviewSchema.optional(),
4706
4707
  procedureReview: createProcedureReviewSchema.optional(),
4708
+ extendedProcedureReviews: import_zod8.z.array(createProcedureReviewSchema).optional(),
4707
4709
  overallComment: import_zod8.z.string().min(1).max(2e3)
4708
4710
  }).refine(
4709
4711
  (data) => {
4710
- return data.clinicReview || data.practitionerReview || data.procedureReview;
4712
+ return data.clinicReview || data.practitionerReview || data.procedureReview || data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0;
4711
4713
  },
4712
4714
  {
4713
- message: "At least one review type (clinic, practitioner, or procedure) must be provided",
4715
+ message: "At least one review type (clinic, practitioner, procedure, or extended procedure) must be provided",
4714
4716
  path: ["reviewType"]
4715
4717
  }
4716
4718
  );
@@ -17658,16 +17660,17 @@ var ReviewService = class extends BaseService {
17658
17660
  * @returns The created review
17659
17661
  */
17660
17662
  async createReview(data, appointmentId) {
17661
- var _a, _b, _c, _d, _e, _f;
17663
+ var _a, _b, _c, _d, _e, _f, _g, _h;
17662
17664
  try {
17663
17665
  console.log("\u{1F50D} ReviewService.createReview - Input data:", {
17664
17666
  appointmentId,
17665
17667
  hasClinicReview: !!data.clinicReview,
17666
17668
  hasPractitionerReview: !!data.practitionerReview,
17667
17669
  hasProcedureReview: !!data.procedureReview,
17668
- practitionerId: (_a = data.practitionerReview) == null ? void 0 : _a.practitionerId,
17669
- clinicId: (_b = data.clinicReview) == null ? void 0 : _b.clinicId,
17670
- procedureId: (_c = data.procedureReview) == null ? void 0 : _c.procedureId
17670
+ extendedProcedureReviewsCount: ((_a = data.extendedProcedureReviews) == null ? void 0 : _a.length) || 0,
17671
+ practitionerId: (_b = data.practitionerReview) == null ? void 0 : _b.practitionerId,
17672
+ clinicId: (_c = data.clinicReview) == null ? void 0 : _c.clinicId,
17673
+ procedureId: (_d = data.procedureReview) == null ? void 0 : _d.procedureId
17671
17674
  });
17672
17675
  const validatedData = createReviewSchema.parse(data);
17673
17676
  const ratings = [];
@@ -17707,6 +17710,20 @@ var ReviewService = class extends BaseService {
17707
17710
  data.procedureReview.overallRating = procedureAverage;
17708
17711
  ratings.push(procedureAverage);
17709
17712
  }
17713
+ if (data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0) {
17714
+ data.extendedProcedureReviews.forEach((extendedReview) => {
17715
+ const extendedRatings = [
17716
+ extendedReview.effectivenessOfTreatment,
17717
+ extendedReview.outcomeExplanation,
17718
+ extendedReview.painManagement,
17719
+ extendedReview.followUpCare,
17720
+ extendedReview.valueForMoney
17721
+ ];
17722
+ const extendedAverage = this.calculateAverage(extendedRatings);
17723
+ extendedReview.overallRating = extendedAverage;
17724
+ ratings.push(extendedAverage);
17725
+ });
17726
+ }
17710
17727
  const overallRating = this.calculateAverage(ratings);
17711
17728
  const reviewId = this.generateId();
17712
17729
  if (data.clinicReview) {
@@ -17722,6 +17739,14 @@ var ReviewService = class extends BaseService {
17722
17739
  data.procedureReview.fullReviewId = reviewId;
17723
17740
  }
17724
17741
  const now = /* @__PURE__ */ new Date();
17742
+ if (data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0) {
17743
+ data.extendedProcedureReviews.forEach((extendedReview) => {
17744
+ extendedReview.id = this.generateId();
17745
+ extendedReview.fullReviewId = reviewId;
17746
+ extendedReview.createdAt = now;
17747
+ extendedReview.updatedAt = now;
17748
+ });
17749
+ }
17725
17750
  const review = {
17726
17751
  id: reviewId,
17727
17752
  appointmentId,
@@ -17729,6 +17754,7 @@ var ReviewService = class extends BaseService {
17729
17754
  clinicReview: data.clinicReview,
17730
17755
  practitionerReview: data.practitionerReview,
17731
17756
  procedureReview: data.procedureReview,
17757
+ extendedProcedureReviews: data.extendedProcedureReviews,
17732
17758
  overallComment: data.overallComment,
17733
17759
  overallRating,
17734
17760
  createdAt: now,
@@ -17743,9 +17769,10 @@ var ReviewService = class extends BaseService {
17743
17769
  });
17744
17770
  console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
17745
17771
  reviewId,
17746
- practitionerId: (_d = review.practitionerReview) == null ? void 0 : _d.practitionerId,
17747
- clinicId: (_e = review.clinicReview) == null ? void 0 : _e.clinicId,
17748
- procedureId: (_f = review.procedureReview) == null ? void 0 : _f.procedureId
17772
+ practitionerId: (_e = review.practitionerReview) == null ? void 0 : _e.practitionerId,
17773
+ clinicId: (_f = review.clinicReview) == null ? void 0 : _f.clinicId,
17774
+ procedureId: (_g = review.procedureReview) == null ? void 0 : _g.procedureId,
17775
+ extendedProcedureReviewsCount: ((_h = review.extendedProcedureReviews) == null ? void 0 : _h.length) || 0
17749
17776
  });
17750
17777
  return review;
17751
17778
  } catch (error) {
@@ -17761,7 +17788,7 @@ var ReviewService = class extends BaseService {
17761
17788
  * @returns The review with entity names if found, null otherwise
17762
17789
  */
17763
17790
  async getReview(reviewId) {
17764
- var _a, _b, _c;
17791
+ var _a, _b, _c, _d, _e;
17765
17792
  console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
17766
17793
  const docRef = (0, import_firestore56.doc)(this.db, REVIEWS_COLLECTION, reviewId);
17767
17794
  const docSnap = await (0, import_firestore56.getDoc)(docRef);
@@ -17795,12 +17822,27 @@ var ReviewService = class extends BaseService {
17795
17822
  procedureName: appointment.procedureInfo.name
17796
17823
  };
17797
17824
  }
17825
+ if (enhancedReview.extendedProcedureReviews && enhancedReview.extendedProcedureReviews.length > 0) {
17826
+ const extendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.extendedProcedures) || [];
17827
+ enhancedReview.extendedProcedureReviews = enhancedReview.extendedProcedureReviews.map((extendedReview) => {
17828
+ const procedureInfo = extendedProcedures.find(
17829
+ (ep) => ep.procedureId === extendedReview.procedureId
17830
+ );
17831
+ if (procedureInfo) {
17832
+ return {
17833
+ ...extendedReview,
17834
+ procedureName: procedureInfo.procedureName
17835
+ };
17836
+ }
17837
+ return extendedReview;
17838
+ });
17839
+ }
17798
17840
  if (appointment.patientInfo) {
17799
17841
  enhancedReview.patientName = appointment.patientInfo.fullName;
17800
17842
  }
17801
17843
  console.log("\u2705 ReviewService.getReview - Enhanced review:", {
17802
17844
  reviewId,
17803
- hasEntityNames: !!(((_a = enhancedReview.clinicReview) == null ? void 0 : _a.clinicName) || ((_b = enhancedReview.practitionerReview) == null ? void 0 : _b.practitionerName) || ((_c = enhancedReview.procedureReview) == null ? void 0 : _c.procedureName) || enhancedReview.patientName)
17845
+ hasEntityNames: !!(((_b = enhancedReview.clinicReview) == null ? void 0 : _b.clinicName) || ((_c = enhancedReview.practitionerReview) == null ? void 0 : _c.practitionerName) || ((_d = enhancedReview.procedureReview) == null ? void 0 : _d.procedureName) || enhancedReview.patientName || ((_e = enhancedReview.extendedProcedureReviews) == null ? void 0 : _e.some((epr) => epr.procedureName)))
17804
17846
  });
17805
17847
  return enhancedReview;
17806
17848
  }