@blackcode_sa/metaestetics-api 1.12.61 → 1.12.63

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.
package/dist/index.js CHANGED
@@ -205,6 +205,9 @@ var MediaType = /* @__PURE__ */ ((MediaType2) => {
205
205
  })(MediaType || {});
206
206
  var APPOINTMENTS_COLLECTION = "appointments";
207
207
 
208
+ // src/types/procedure/index.ts
209
+ var PROCEDURES_COLLECTION = "procedures";
210
+
208
211
  // src/validations/appointment.schema.ts
209
212
  var import_zod3 = require("zod");
210
213
 
@@ -1093,7 +1096,7 @@ var MediaService = class extends BaseService {
1093
1096
  try {
1094
1097
  const querySnapshot = await (0, import_firestore2.getDocs)(finalQuery);
1095
1098
  const mediaList = querySnapshot.docs.map(
1096
- (doc44) => doc44.data()
1099
+ (doc45) => doc45.data()
1097
1100
  );
1098
1101
  console.log(`[MediaService] Found ${mediaList.length} media items.`);
1099
1102
  return mediaList;
@@ -1368,9 +1371,6 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
1368
1371
  return Gender2;
1369
1372
  })(Gender || {});
1370
1373
 
1371
- // src/types/procedure/index.ts
1372
- var PROCEDURES_COLLECTION = "procedures";
1373
-
1374
1374
  // src/backoffice/types/technology.types.ts
1375
1375
  var TECHNOLOGIES_COLLECTION = "technologies";
1376
1376
 
@@ -1523,7 +1523,7 @@ async function searchAppointmentsUtil(db, params) {
1523
1523
  }
1524
1524
  const q = (0, import_firestore3.query)((0, import_firestore3.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
1525
1525
  const querySnapshot = await (0, import_firestore3.getDocs)(q);
1526
- const appointments = querySnapshot.docs.map((doc44) => doc44.data());
1526
+ const appointments = querySnapshot.docs.map((doc45) => doc45.data());
1527
1527
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
1528
1528
  return { appointments, lastDoc };
1529
1529
  } catch (error) {
@@ -2857,7 +2857,7 @@ var AppointmentService = class extends BaseService {
2857
2857
  }
2858
2858
  const q = (0, import_firestore11.query)((0, import_firestore11.collection)(this.db, APPOINTMENTS_COLLECTION), ...constraints);
2859
2859
  const querySnapshot = await (0, import_firestore11.getDocs)(q);
2860
- const appointments = querySnapshot.docs.map((doc44) => doc44.data());
2860
+ const appointments = querySnapshot.docs.map((doc45) => doc45.data());
2861
2861
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
2862
2862
  console.log(
2863
2863
  `[APPOINTMENT_SERVICE] Found ${appointments.length} upcoming appointments for patient ${patientId}`
@@ -2913,7 +2913,7 @@ var AppointmentService = class extends BaseService {
2913
2913
  }
2914
2914
  const q = (0, import_firestore11.query)((0, import_firestore11.collection)(this.db, APPOINTMENTS_COLLECTION), ...constraints);
2915
2915
  const querySnapshot = await (0, import_firestore11.getDocs)(q);
2916
- const appointments = querySnapshot.docs.map((doc44) => doc44.data());
2916
+ const appointments = querySnapshot.docs.map((doc45) => doc45.data());
2917
2917
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
2918
2918
  console.log(
2919
2919
  `[APPOINTMENT_SERVICE] Found ${appointments.length} past appointments for patient ${patientId}`
@@ -3635,6 +3635,301 @@ var AppointmentService = class extends BaseService {
3635
3635
  throw error;
3636
3636
  }
3637
3637
  }
3638
+ /**
3639
+ * Gets all next steps recommendations for a patient from their past appointments.
3640
+ * Returns recommendations with context about which appointment, practitioner, and clinic suggested them.
3641
+ *
3642
+ * @param patientId ID of the patient
3643
+ * @param options Optional parameters for filtering
3644
+ * @returns Array of next steps recommendations with context
3645
+ */
3646
+ async getPatientNextStepsRecommendations(patientId, options) {
3647
+ var _a, _b, _c;
3648
+ try {
3649
+ console.log(
3650
+ `[APPOINTMENT_SERVICE] Getting next steps recommendations for patient: ${patientId}`,
3651
+ options
3652
+ );
3653
+ const patientProfile = await this.patientService.getPatientProfile(patientId);
3654
+ const dismissedIds = new Set(
3655
+ (patientProfile == null ? void 0 : patientProfile.dismissedNextStepsRecommendations) || []
3656
+ );
3657
+ const pastAppointments = await this.getPastPatientAppointments(patientId, {
3658
+ showCanceled: false,
3659
+ showNoShow: false
3660
+ });
3661
+ const recommendations = [];
3662
+ for (const appointment of pastAppointments.appointments) {
3663
+ if ((options == null ? void 0 : options.clinicBranchId) && appointment.clinicBranchId !== options.clinicBranchId) {
3664
+ continue;
3665
+ }
3666
+ if ((options == null ? void 0 : options.practitionerId) && appointment.practitionerId !== options.practitionerId) {
3667
+ continue;
3668
+ }
3669
+ const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
3670
+ for (let index = 0; index < recommendedProcedures.length; index++) {
3671
+ const recommendedProcedure = recommendedProcedures[index];
3672
+ const recommendationId = `${appointment.id}:${index}`;
3673
+ if (!(options == null ? void 0 : options.includeDismissed) && dismissedIds.has(recommendationId)) {
3674
+ continue;
3675
+ }
3676
+ const nextStepsRecommendation = {
3677
+ id: recommendationId,
3678
+ recommendedProcedure,
3679
+ appointmentId: appointment.id,
3680
+ appointmentDate: appointment.appointmentStartTime,
3681
+ practitionerId: appointment.practitionerId,
3682
+ practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
3683
+ clinicBranchId: appointment.clinicBranchId,
3684
+ clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
3685
+ appointmentStatus: appointment.status,
3686
+ isDismissed: dismissedIds.has(recommendationId),
3687
+ dismissedAt: null
3688
+ // We don't track when it was dismissed, just that it was
3689
+ };
3690
+ recommendations.push(nextStepsRecommendation);
3691
+ }
3692
+ }
3693
+ recommendations.sort((a, b) => {
3694
+ const dateA = a.appointmentDate.toMillis();
3695
+ const dateB = b.appointmentDate.toMillis();
3696
+ return dateB - dateA;
3697
+ });
3698
+ const limitedRecommendations = (options == null ? void 0 : options.limit) ? recommendations.slice(0, options.limit) : recommendations;
3699
+ console.log(
3700
+ `[APPOINTMENT_SERVICE] Found ${limitedRecommendations.length} next steps recommendations for patient ${patientId}`
3701
+ );
3702
+ return limitedRecommendations;
3703
+ } catch (error) {
3704
+ console.error(
3705
+ `[APPOINTMENT_SERVICE] Error getting next steps recommendations for patient ${patientId}:`,
3706
+ error
3707
+ );
3708
+ throw error;
3709
+ }
3710
+ }
3711
+ /**
3712
+ * Dismisses a next steps recommendation for a patient.
3713
+ * This prevents the recommendation from showing up in the default view.
3714
+ *
3715
+ * @param patientId ID of the patient
3716
+ * @param recommendationId ID of the recommendation to dismiss (format: appointmentId:recommendationIndex)
3717
+ * @returns Updated patient profile
3718
+ */
3719
+ async dismissNextStepsRecommendation(patientId, recommendationId) {
3720
+ try {
3721
+ console.log(
3722
+ `[APPOINTMENT_SERVICE] Dismissing recommendation ${recommendationId} for patient ${patientId}`
3723
+ );
3724
+ const patientProfile = await this.patientService.getPatientProfile(patientId);
3725
+ if (!patientProfile) {
3726
+ throw new Error(`Patient profile not found for patient ${patientId}`);
3727
+ }
3728
+ const dismissedRecommendations = patientProfile.dismissedNextStepsRecommendations || [];
3729
+ if (dismissedRecommendations.includes(recommendationId)) {
3730
+ console.log(
3731
+ `[APPOINTMENT_SERVICE] Recommendation ${recommendationId} already dismissed`
3732
+ );
3733
+ return;
3734
+ }
3735
+ const updatedDismissed = [...dismissedRecommendations, recommendationId];
3736
+ await this.patientService.updatePatientProfile(patientId, {
3737
+ dismissedNextStepsRecommendations: updatedDismissed
3738
+ });
3739
+ console.log(
3740
+ `[APPOINTMENT_SERVICE] Successfully dismissed recommendation ${recommendationId} for patient ${patientId}`
3741
+ );
3742
+ } catch (error) {
3743
+ console.error(
3744
+ `[APPOINTMENT_SERVICE] Error dismissing recommendation for patient ${patientId}:`,
3745
+ error
3746
+ );
3747
+ throw error;
3748
+ }
3749
+ }
3750
+ /**
3751
+ * Undismisses a next steps recommendation for a patient.
3752
+ * This makes the recommendation visible again in the default view.
3753
+ *
3754
+ * @param patientId ID of the patient
3755
+ * @param recommendationId ID of the recommendation to undismiss (format: appointmentId:recommendationIndex)
3756
+ * @returns Updated patient profile
3757
+ */
3758
+ async undismissNextStepsRecommendation(patientId, recommendationId) {
3759
+ try {
3760
+ console.log(
3761
+ `[APPOINTMENT_SERVICE] Undismissing recommendation ${recommendationId} for patient ${patientId}`
3762
+ );
3763
+ const patientProfile = await this.patientService.getPatientProfile(patientId);
3764
+ if (!patientProfile) {
3765
+ throw new Error(`Patient profile not found for patient ${patientId}`);
3766
+ }
3767
+ const dismissedRecommendations = patientProfile.dismissedNextStepsRecommendations || [];
3768
+ if (!dismissedRecommendations.includes(recommendationId)) {
3769
+ console.log(
3770
+ `[APPOINTMENT_SERVICE] Recommendation ${recommendationId} is not dismissed`
3771
+ );
3772
+ return;
3773
+ }
3774
+ const updatedDismissed = dismissedRecommendations.filter(
3775
+ (id) => id !== recommendationId
3776
+ );
3777
+ await this.patientService.updatePatientProfile(patientId, {
3778
+ dismissedNextStepsRecommendations: updatedDismissed
3779
+ });
3780
+ console.log(
3781
+ `[APPOINTMENT_SERVICE] Successfully undismissed recommendation ${recommendationId} for patient ${patientId}`
3782
+ );
3783
+ } catch (error) {
3784
+ console.error(
3785
+ `[APPOINTMENT_SERVICE] Error undismissing recommendation for patient ${patientId}:`,
3786
+ error
3787
+ );
3788
+ throw error;
3789
+ }
3790
+ }
3791
+ /**
3792
+ * Gets next steps recommendations for a clinic.
3793
+ * Returns all recommendations from appointments at the specified clinic.
3794
+ * This is useful for clinic admins to see what treatments have been recommended to their patients.
3795
+ *
3796
+ * @param clinicBranchId ID of the clinic branch
3797
+ * @param options Optional parameters for filtering
3798
+ * @returns Array of next steps recommendations with context
3799
+ */
3800
+ async getClinicNextStepsRecommendations(clinicBranchId, options) {
3801
+ var _a, _b, _c;
3802
+ try {
3803
+ console.log(
3804
+ `[APPOINTMENT_SERVICE] Getting next steps recommendations for clinic: ${clinicBranchId}`,
3805
+ options
3806
+ );
3807
+ const searchParams = {
3808
+ clinicBranchId,
3809
+ patientId: options == null ? void 0 : options.patientId,
3810
+ practitionerId: options == null ? void 0 : options.practitionerId,
3811
+ status: "completed" /* COMPLETED */
3812
+ };
3813
+ const { appointments } = await this.searchAppointments(searchParams);
3814
+ const recommendations = [];
3815
+ for (const appointment of appointments) {
3816
+ const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
3817
+ for (let index = 0; index < recommendedProcedures.length; index++) {
3818
+ const recommendedProcedure = recommendedProcedures[index];
3819
+ const recommendationId = `${appointment.id}:${index}`;
3820
+ const nextStepsRecommendation = {
3821
+ id: recommendationId,
3822
+ recommendedProcedure,
3823
+ appointmentId: appointment.id,
3824
+ appointmentDate: appointment.appointmentStartTime,
3825
+ practitionerId: appointment.practitionerId,
3826
+ practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
3827
+ clinicBranchId: appointment.clinicBranchId,
3828
+ clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
3829
+ appointmentStatus: appointment.status,
3830
+ isDismissed: false,
3831
+ // Clinic view doesn't track dismissals
3832
+ dismissedAt: null
3833
+ };
3834
+ recommendations.push(nextStepsRecommendation);
3835
+ }
3836
+ }
3837
+ recommendations.sort((a, b) => {
3838
+ const dateA = a.appointmentDate.toMillis();
3839
+ const dateB = b.appointmentDate.toMillis();
3840
+ return dateB - dateA;
3841
+ });
3842
+ const limitedRecommendations = (options == null ? void 0 : options.limit) ? recommendations.slice(0, options.limit) : recommendations;
3843
+ console.log(
3844
+ `[APPOINTMENT_SERVICE] Found ${limitedRecommendations.length} next steps recommendations for clinic ${clinicBranchId}`
3845
+ );
3846
+ return limitedRecommendations;
3847
+ } catch (error) {
3848
+ console.error(
3849
+ `[APPOINTMENT_SERVICE] Error getting next steps recommendations for clinic ${clinicBranchId}:`,
3850
+ error
3851
+ );
3852
+ throw error;
3853
+ }
3854
+ }
3855
+ /**
3856
+ * Gets next steps recommendations from a specific appointment.
3857
+ * This is useful when viewing an appointment detail page in the clinic app
3858
+ * to see what procedures were recommended during that appointment.
3859
+ *
3860
+ * @param appointmentId ID of the appointment
3861
+ * @param options Optional parameters for filtering
3862
+ * @returns Array of next steps recommendations from that appointment
3863
+ */
3864
+ async getAppointmentNextStepsRecommendations(appointmentId, options) {
3865
+ var _a, _b, _c;
3866
+ try {
3867
+ console.log(
3868
+ `[APPOINTMENT_SERVICE] Getting next steps recommendations for appointment: ${appointmentId}`,
3869
+ options
3870
+ );
3871
+ const appointment = await this.getAppointmentById(appointmentId);
3872
+ if (!appointment) {
3873
+ throw new Error(`Appointment with ID ${appointmentId} not found`);
3874
+ }
3875
+ const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
3876
+ const recommendations = [];
3877
+ let availableProcedureIds = null;
3878
+ if (options == null ? void 0 : options.clinicBranchId) {
3879
+ const proceduresQuery = (0, import_firestore11.query)(
3880
+ (0, import_firestore11.collection)(this.db, PROCEDURES_COLLECTION),
3881
+ (0, import_firestore11.where)("clinicBranchId", "==", options.clinicBranchId),
3882
+ (0, import_firestore11.where)("isActive", "==", true)
3883
+ );
3884
+ const proceduresSnapshot = await (0, import_firestore11.getDocs)(proceduresQuery);
3885
+ availableProcedureIds = new Set(
3886
+ proceduresSnapshot.docs.map((doc45) => doc45.id)
3887
+ );
3888
+ console.log(
3889
+ `[APPOINTMENT_SERVICE] Found ${availableProcedureIds.size} procedures available at clinic ${options.clinicBranchId}`
3890
+ );
3891
+ }
3892
+ for (let index = 0; index < recommendedProcedures.length; index++) {
3893
+ const recommendedProcedure = recommendedProcedures[index];
3894
+ const procedureId = recommendedProcedure.procedure.procedureId;
3895
+ if ((options == null ? void 0 : options.clinicBranchId) && availableProcedureIds) {
3896
+ if (!availableProcedureIds.has(procedureId)) {
3897
+ console.log(
3898
+ `[APPOINTMENT_SERVICE] Skipping recommendation for procedure ${procedureId} - not available at clinic ${options.clinicBranchId}`
3899
+ );
3900
+ continue;
3901
+ }
3902
+ }
3903
+ const recommendationId = `${appointment.id}:${index}`;
3904
+ const nextStepsRecommendation = {
3905
+ id: recommendationId,
3906
+ recommendedProcedure,
3907
+ appointmentId: appointment.id,
3908
+ appointmentDate: appointment.appointmentStartTime,
3909
+ practitionerId: appointment.practitionerId,
3910
+ practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
3911
+ clinicBranchId: appointment.clinicBranchId,
3912
+ clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
3913
+ appointmentStatus: appointment.status,
3914
+ isDismissed: false,
3915
+ // Clinic view doesn't track dismissals
3916
+ dismissedAt: null
3917
+ };
3918
+ recommendations.push(nextStepsRecommendation);
3919
+ }
3920
+ console.log(
3921
+ `[APPOINTMENT_SERVICE] Found ${recommendations.length} next steps recommendations for appointment ${appointmentId}`,
3922
+ (options == null ? void 0 : options.clinicBranchId) ? `(filtered to procedures available at clinic ${options.clinicBranchId})` : ""
3923
+ );
3924
+ return recommendations;
3925
+ } catch (error) {
3926
+ console.error(
3927
+ `[APPOINTMENT_SERVICE] Error getting next steps recommendations for appointment ${appointmentId}:`,
3928
+ error
3929
+ );
3930
+ throw error;
3931
+ }
3932
+ }
3638
3933
  };
3639
3934
 
3640
3935
  // src/services/auth/auth.service.ts
@@ -4136,8 +4431,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
4136
4431
  }
4137
4432
  const patientsSnapshot = await (0, import_firestore12.getDocs)(q);
4138
4433
  const patients = [];
4139
- patientsSnapshot.forEach((doc44) => {
4140
- patients.push(doc44.data());
4434
+ patientsSnapshot.forEach((doc45) => {
4435
+ patients.push(doc45.data());
4141
4436
  });
4142
4437
  console.log(
4143
4438
  `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
@@ -4380,6 +4675,7 @@ var patientProfileSchema = import_zod7.z.object({
4380
4675
  clinics: import_zod7.z.array(patientClinicSchema),
4381
4676
  doctorIds: import_zod7.z.array(import_zod7.z.string()),
4382
4677
  clinicIds: import_zod7.z.array(import_zod7.z.string()),
4678
+ dismissedNextStepsRecommendations: import_zod7.z.array(import_zod7.z.string()).optional(),
4383
4679
  createdAt: import_zod7.z.instanceof(import_firestore14.Timestamp),
4384
4680
  updatedAt: import_zod7.z.instanceof(import_firestore14.Timestamp)
4385
4681
  });
@@ -4478,8 +4774,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
4478
4774
  }
4479
4775
  const patientsSnapshot = await (0, import_firestore15.getDocs)(q);
4480
4776
  const patients = [];
4481
- patientsSnapshot.forEach((doc44) => {
4482
- patients.push(doc44.data());
4777
+ patientsSnapshot.forEach((doc45) => {
4778
+ patients.push(doc45.data());
4483
4779
  });
4484
4780
  console.log(
4485
4781
  `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
@@ -5292,7 +5588,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
5292
5588
  (0, import_firestore17.where)("clinicGroupId", "==", clinicGroupId)
5293
5589
  );
5294
5590
  const querySnapshot = await (0, import_firestore17.getDocs)(q);
5295
- return querySnapshot.docs.map((doc44) => doc44.data());
5591
+ return querySnapshot.docs.map((doc45) => doc45.data());
5296
5592
  }
5297
5593
  async function updateClinicAdmin(db, adminId, data) {
5298
5594
  const admin = await getClinicAdmin(db, adminId);
@@ -5971,9 +6267,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
5971
6267
  };
5972
6268
  var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
5973
6269
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
5974
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
5975
- if (!doc44.exists()) throw new Error("Medical info not found");
5976
- const medicalInfo = doc44.data();
6270
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6271
+ if (!doc45.exists()) throw new Error("Medical info not found");
6272
+ const medicalInfo = doc45.data();
5977
6273
  if (allergyIndex >= medicalInfo.allergies.length) {
5978
6274
  throw new Error("Invalid allergy index");
5979
6275
  }
@@ -6000,9 +6296,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
6000
6296
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6001
6297
  const validatedData = updateBlockingConditionSchema.parse(data);
6002
6298
  const { conditionIndex, ...updateData } = validatedData;
6003
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6004
- if (!doc44.exists()) throw new Error("Medical info not found");
6005
- const medicalInfo = doc44.data();
6299
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6300
+ if (!doc45.exists()) throw new Error("Medical info not found");
6301
+ const medicalInfo = doc45.data();
6006
6302
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
6007
6303
  throw new Error("Invalid blocking condition index");
6008
6304
  }
@@ -6019,9 +6315,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
6019
6315
  };
6020
6316
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
6021
6317
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6022
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6023
- if (!doc44.exists()) throw new Error("Medical info not found");
6024
- const medicalInfo = doc44.data();
6318
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6319
+ if (!doc45.exists()) throw new Error("Medical info not found");
6320
+ const medicalInfo = doc45.data();
6025
6321
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
6026
6322
  throw new Error("Invalid blocking condition index");
6027
6323
  }
@@ -6048,9 +6344,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
6048
6344
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6049
6345
  const validatedData = updateContraindicationSchema.parse(data);
6050
6346
  const { contraindicationIndex, ...updateData } = validatedData;
6051
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6052
- if (!doc44.exists()) throw new Error("Medical info not found");
6053
- const medicalInfo = doc44.data();
6347
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6348
+ if (!doc45.exists()) throw new Error("Medical info not found");
6349
+ const medicalInfo = doc45.data();
6054
6350
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
6055
6351
  throw new Error("Invalid contraindication index");
6056
6352
  }
@@ -6067,9 +6363,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
6067
6363
  };
6068
6364
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
6069
6365
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6070
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6071
- if (!doc44.exists()) throw new Error("Medical info not found");
6072
- const medicalInfo = doc44.data();
6366
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6367
+ if (!doc45.exists()) throw new Error("Medical info not found");
6368
+ const medicalInfo = doc45.data();
6073
6369
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
6074
6370
  throw new Error("Invalid contraindication index");
6075
6371
  }
@@ -6096,9 +6392,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
6096
6392
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6097
6393
  const validatedData = updateMedicationSchema.parse(data);
6098
6394
  const { medicationIndex, ...updateData } = validatedData;
6099
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6100
- if (!doc44.exists()) throw new Error("Medical info not found");
6101
- const medicalInfo = doc44.data();
6395
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6396
+ if (!doc45.exists()) throw new Error("Medical info not found");
6397
+ const medicalInfo = doc45.data();
6102
6398
  if (medicationIndex >= medicalInfo.currentMedications.length) {
6103
6399
  throw new Error("Invalid medication index");
6104
6400
  }
@@ -6115,9 +6411,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
6115
6411
  };
6116
6412
  var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
6117
6413
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6118
- const doc44 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6119
- if (!doc44.exists()) throw new Error("Medical info not found");
6120
- const medicalInfo = doc44.data();
6414
+ const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
6415
+ if (!doc45.exists()) throw new Error("Medical info not found");
6416
+ const medicalInfo = doc45.data();
6121
6417
  if (medicationIndex >= medicalInfo.currentMedications.length) {
6122
6418
  throw new Error("Invalid medication index");
6123
6419
  }
@@ -6404,7 +6700,7 @@ var searchPatientsUtil = async (db, params, requester) => {
6404
6700
  const finalQuery = (0, import_firestore23.query)(patientsCollectionRef, ...constraints);
6405
6701
  const querySnapshot = await (0, import_firestore23.getDocs)(finalQuery);
6406
6702
  const patients = querySnapshot.docs.map(
6407
- (doc44) => doc44.data()
6703
+ (doc45) => doc45.data()
6408
6704
  );
6409
6705
  console.log(
6410
6706
  `[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
@@ -6436,8 +6732,8 @@ var getAllPatientsUtil = async (db, options) => {
6436
6732
  }
6437
6733
  const patientsSnapshot = await (0, import_firestore23.getDocs)(q);
6438
6734
  const patients = [];
6439
- patientsSnapshot.forEach((doc44) => {
6440
- patients.push(doc44.data());
6735
+ patientsSnapshot.forEach((doc45) => {
6736
+ patients.push(doc45.data());
6441
6737
  });
6442
6738
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
6443
6739
  return patients;
@@ -6559,7 +6855,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
6559
6855
  if (querySnapshot.empty) {
6560
6856
  return [];
6561
6857
  }
6562
- return querySnapshot.docs.map((doc44) => doc44.data());
6858
+ return querySnapshot.docs.map((doc45) => doc45.data());
6563
6859
  };
6564
6860
  var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
6565
6861
  const tokensRef = (0, import_firestore24.collection)(
@@ -6577,7 +6873,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
6577
6873
  if (querySnapshot.empty) {
6578
6874
  return [];
6579
6875
  }
6580
- return querySnapshot.docs.map((doc44) => doc44.data());
6876
+ return querySnapshot.docs.map((doc45) => doc45.data());
6581
6877
  };
6582
6878
 
6583
6879
  // src/services/patient/utils/aesthetic-analysis.utils.ts
@@ -7946,7 +8242,7 @@ var PractitionerService = class extends BaseService {
7946
8242
  (0, import_firestore29.where)("expiresAt", ">", import_firestore29.Timestamp.now())
7947
8243
  );
7948
8244
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
7949
- return querySnapshot.docs.map((doc44) => doc44.data());
8245
+ return querySnapshot.docs.map((doc45) => doc45.data());
7950
8246
  }
7951
8247
  /**
7952
8248
  * Gets a token by its string value and validates it
@@ -8056,7 +8352,7 @@ var PractitionerService = class extends BaseService {
8056
8352
  (0, import_firestore29.where)("status", "==", "active" /* ACTIVE */)
8057
8353
  );
8058
8354
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8059
- return querySnapshot.docs.map((doc44) => doc44.data());
8355
+ return querySnapshot.docs.map((doc45) => doc45.data());
8060
8356
  }
8061
8357
  /**
8062
8358
  * Dohvata sve zdravstvene radnike za određenu kliniku
@@ -8068,7 +8364,7 @@ var PractitionerService = class extends BaseService {
8068
8364
  (0, import_firestore29.where)("isActive", "==", true)
8069
8365
  );
8070
8366
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8071
- return querySnapshot.docs.map((doc44) => doc44.data());
8367
+ return querySnapshot.docs.map((doc45) => doc45.data());
8072
8368
  }
8073
8369
  /**
8074
8370
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
@@ -8080,7 +8376,7 @@ var PractitionerService = class extends BaseService {
8080
8376
  (0, import_firestore29.where)("status", "==", "draft" /* DRAFT */)
8081
8377
  );
8082
8378
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8083
- return querySnapshot.docs.map((doc44) => doc44.data());
8379
+ return querySnapshot.docs.map((doc45) => doc45.data());
8084
8380
  }
8085
8381
  /**
8086
8382
  * Updates a practitioner
@@ -8297,7 +8593,7 @@ var PractitionerService = class extends BaseService {
8297
8593
  );
8298
8594
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8299
8595
  const practitioners = querySnapshot.docs.map(
8300
- (doc44) => doc44.data()
8596
+ (doc45) => doc45.data()
8301
8597
  );
8302
8598
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8303
8599
  return {
@@ -8382,7 +8678,7 @@ var PractitionerService = class extends BaseService {
8382
8678
  );
8383
8679
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8384
8680
  const practitioners = querySnapshot.docs.map(
8385
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8681
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8386
8682
  );
8387
8683
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8388
8684
  console.log(
@@ -8446,7 +8742,7 @@ var PractitionerService = class extends BaseService {
8446
8742
  );
8447
8743
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8448
8744
  let practitioners = querySnapshot.docs.map(
8449
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8745
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8450
8746
  );
8451
8747
  if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
8452
8748
  const location = filters.location;
@@ -8491,7 +8787,7 @@ var PractitionerService = class extends BaseService {
8491
8787
  );
8492
8788
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8493
8789
  let practitioners = querySnapshot.docs.map(
8494
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8790
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8495
8791
  );
8496
8792
  practitioners = this.applyInMemoryFilters(practitioners, filters);
8497
8793
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -8521,7 +8817,7 @@ var PractitionerService = class extends BaseService {
8521
8817
  );
8522
8818
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
8523
8819
  let practitioners = querySnapshot.docs.map(
8524
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8820
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8525
8821
  );
8526
8822
  practitioners = this.applyInMemoryFilters(practitioners, filters);
8527
8823
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -9068,7 +9364,7 @@ var UserService = class extends BaseService {
9068
9364
  const constraints = [(0, import_firestore30.where)("roles", "array-contains", role)];
9069
9365
  const q = (0, import_firestore30.query)((0, import_firestore30.collection)(this.db, USERS_COLLECTION), ...constraints);
9070
9366
  const querySnapshot = await (0, import_firestore30.getDocs)(q);
9071
- const users = querySnapshot.docs.map((doc44) => doc44.data());
9367
+ const users = querySnapshot.docs.map((doc45) => doc45.data());
9072
9368
  return users.map((userData) => userSchema.parse(userData));
9073
9369
  }
9074
9370
  /**
@@ -9226,9 +9522,9 @@ var BillingTransactionsService = class extends BaseService {
9226
9522
  const querySnapshot = await (0, import_firestore31.getDocs)(q);
9227
9523
  const docs = querySnapshot.docs;
9228
9524
  const hasMore = docs.length > queryLimit;
9229
- const transactions = docs.slice(0, queryLimit).map((doc44) => ({
9230
- id: doc44.id,
9231
- ...doc44.data()
9525
+ const transactions = docs.slice(0, queryLimit).map((doc45) => ({
9526
+ id: doc45.id,
9527
+ ...doc45.data()
9232
9528
  }));
9233
9529
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
9234
9530
  return {
@@ -9304,9 +9600,9 @@ var BillingTransactionsService = class extends BaseService {
9304
9600
  const querySnapshot = await (0, import_firestore31.getDocs)(q);
9305
9601
  const docs = querySnapshot.docs;
9306
9602
  const hasMore = docs.length > queryLimit;
9307
- const transactions = docs.slice(0, queryLimit).map((doc44) => ({
9308
- id: doc44.id,
9309
- ...doc44.data()
9603
+ const transactions = docs.slice(0, queryLimit).map((doc45) => ({
9604
+ id: doc45.id,
9605
+ ...doc45.data()
9310
9606
  }));
9311
9607
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
9312
9608
  return {
@@ -9555,7 +9851,7 @@ async function getAllActiveGroups(db) {
9555
9851
  (0, import_firestore32.where)("isActive", "==", true)
9556
9852
  );
9557
9853
  const querySnapshot = await (0, import_firestore32.getDocs)(q);
9558
- return querySnapshot.docs.map((doc44) => doc44.data());
9854
+ return querySnapshot.docs.map((doc45) => doc45.data());
9559
9855
  }
9560
9856
  async function updateClinicGroup(db, groupId, data, app) {
9561
9857
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -9991,7 +10287,7 @@ async function getClinicsByGroup(db, groupId) {
9991
10287
  (0, import_firestore33.where)("isActive", "==", true)
9992
10288
  );
9993
10289
  const querySnapshot = await (0, import_firestore33.getDocs)(q);
9994
- return querySnapshot.docs.map((doc44) => doc44.data());
10290
+ return querySnapshot.docs.map((doc45) => doc45.data());
9995
10291
  }
9996
10292
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
9997
10293
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -10185,7 +10481,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
10185
10481
  }
10186
10482
  const q = (0, import_firestore33.query)((0, import_firestore33.collection)(db, CLINICS_COLLECTION), ...constraints);
10187
10483
  const querySnapshot = await (0, import_firestore33.getDocs)(q);
10188
- return querySnapshot.docs.map((doc44) => doc44.data());
10484
+ return querySnapshot.docs.map((doc45) => doc45.data());
10189
10485
  }
10190
10486
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
10191
10487
  return getClinicsByAdmin(
@@ -10230,11 +10526,11 @@ async function getAllClinics(db, pagination, lastDoc) {
10230
10526
  }
10231
10527
  const clinicsSnapshot = await (0, import_firestore33.getDocs)(clinicsQuery);
10232
10528
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
10233
- const clinics = clinicsSnapshot.docs.map((doc44) => {
10234
- const data = doc44.data();
10529
+ const clinics = clinicsSnapshot.docs.map((doc45) => {
10530
+ const data = doc45.data();
10235
10531
  return {
10236
10532
  ...data,
10237
- id: doc44.id
10533
+ id: doc45.id
10238
10534
  };
10239
10535
  });
10240
10536
  return {
@@ -10261,8 +10557,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
10261
10557
  ];
10262
10558
  const q = (0, import_firestore33.query)((0, import_firestore33.collection)(db, CLINICS_COLLECTION), ...constraints);
10263
10559
  const querySnapshot = await (0, import_firestore33.getDocs)(q);
10264
- for (const doc44 of querySnapshot.docs) {
10265
- const clinic = doc44.data();
10560
+ for (const doc45 of querySnapshot.docs) {
10561
+ const clinic = doc45.data();
10266
10562
  const distance = (0, import_geofire_common4.distanceBetween)(
10267
10563
  [center.latitude, center.longitude],
10268
10564
  [clinic.location.latitude, clinic.location.longitude]
@@ -10379,8 +10675,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
10379
10675
  }
10380
10676
  const q = (0, import_firestore34.query)((0, import_firestore34.collection)(db, CLINICS_COLLECTION), ...constraints);
10381
10677
  const querySnapshot = await (0, import_firestore34.getDocs)(q);
10382
- for (const doc44 of querySnapshot.docs) {
10383
- const clinic = doc44.data();
10678
+ for (const doc45 of querySnapshot.docs) {
10679
+ const clinic = doc45.data();
10384
10680
  const distance = (0, import_geofire_common5.distanceBetween)(
10385
10681
  [center.latitude, center.longitude],
10386
10682
  [clinic.location.latitude, clinic.location.longitude]
@@ -10501,7 +10797,7 @@ async function getClinicsByFilters(db, filters) {
10501
10797
  constraints.push((0, import_firestore35.limit)(filters.pagination || 5));
10502
10798
  const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
10503
10799
  const querySnapshot = await (0, import_firestore35.getDocs)(q);
10504
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10800
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10505
10801
  clinics = applyInMemoryFilters(clinics, filters);
10506
10802
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10507
10803
  console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
@@ -10533,7 +10829,7 @@ async function getClinicsByFilters(db, filters) {
10533
10829
  constraints.push((0, import_firestore35.limit)(filters.pagination || 5));
10534
10830
  const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
10535
10831
  const querySnapshot = await (0, import_firestore35.getDocs)(q);
10536
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10832
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10537
10833
  clinics = applyInMemoryFilters(clinics, filters);
10538
10834
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10539
10835
  console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
@@ -10563,7 +10859,7 @@ async function getClinicsByFilters(db, filters) {
10563
10859
  constraints.push((0, import_firestore35.limit)(filters.pagination || 5));
10564
10860
  const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
10565
10861
  const querySnapshot = await (0, import_firestore35.getDocs)(q);
10566
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10862
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10567
10863
  clinics = applyInMemoryFilters(clinics, filters);
10568
10864
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10569
10865
  console.log(`[CLINIC_SERVICE] Strategy 3 success: ${clinics.length} clinics`);
@@ -10583,7 +10879,7 @@ async function getClinicsByFilters(db, filters) {
10583
10879
  ];
10584
10880
  const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
10585
10881
  const querySnapshot = await (0, import_firestore35.getDocs)(q);
10586
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10882
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10587
10883
  clinics = applyInMemoryFilters(clinics, filters);
10588
10884
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10589
10885
  console.log(`[CLINIC_SERVICE] Strategy 4 success: ${clinics.length} clinics`);
@@ -11155,11 +11451,11 @@ var ClinicService = class extends BaseService {
11155
11451
  async getClinicsForMap() {
11156
11452
  const clinicsRef = (0, import_firestore36.collection)(this.db, CLINICS_COLLECTION);
11157
11453
  const snapshot = await (0, import_firestore36.getDocs)(clinicsRef);
11158
- const clinicsForMap = snapshot.docs.map((doc44) => {
11454
+ const clinicsForMap = snapshot.docs.map((doc45) => {
11159
11455
  var _a, _b, _c;
11160
- const data = doc44.data();
11456
+ const data = doc45.data();
11161
11457
  return {
11162
- id: doc44.id,
11458
+ id: doc45.id,
11163
11459
  name: data.name,
11164
11460
  address: ((_a = data.location) == null ? void 0 : _a.address) || "",
11165
11461
  latitude: (_b = data.location) == null ? void 0 : _b.latitude,
@@ -12287,7 +12583,7 @@ async function searchCalendarEventsUtil(db, params) {
12287
12583
  const finalQuery = (0, import_firestore42.query)(collectionRef, ...constraints);
12288
12584
  const querySnapshot = await (0, import_firestore42.getDocs)(finalQuery);
12289
12585
  const events = querySnapshot.docs.map(
12290
- (doc44) => ({ id: doc44.id, ...doc44.data() })
12586
+ (doc45) => ({ id: doc45.id, ...doc45.data() })
12291
12587
  );
12292
12588
  return events;
12293
12589
  } catch (error) {
@@ -12369,7 +12665,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
12369
12665
  );
12370
12666
  const q = (0, import_firestore43.query)(calendarsRef, (0, import_firestore43.orderBy)("createdAt", "desc"));
12371
12667
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
12372
- return querySnapshot.docs.map((doc44) => doc44.data());
12668
+ return querySnapshot.docs.map((doc45) => doc45.data());
12373
12669
  }
12374
12670
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
12375
12671
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
@@ -12386,7 +12682,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
12386
12682
  );
12387
12683
  const q = (0, import_firestore43.query)(calendarsRef, (0, import_firestore43.orderBy)("createdAt", "desc"));
12388
12684
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
12389
- return querySnapshot.docs.map((doc44) => doc44.data());
12685
+ return querySnapshot.docs.map((doc45) => doc45.data());
12390
12686
  }
12391
12687
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
12392
12688
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
@@ -12403,7 +12699,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
12403
12699
  );
12404
12700
  const q = (0, import_firestore43.query)(calendarsRef, (0, import_firestore43.orderBy)("createdAt", "desc"));
12405
12701
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
12406
- return querySnapshot.docs.map((doc44) => doc44.data());
12702
+ return querySnapshot.docs.map((doc45) => doc45.data());
12407
12703
  }
12408
12704
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
12409
12705
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -13758,9 +14054,9 @@ var CalendarServiceV2 = class extends BaseService {
13758
14054
  (0, import_firestore46.where)("eventTime.start", "<=", import_firestore45.Timestamp.fromDate(endDate))
13759
14055
  );
13760
14056
  const eventsSnapshot = await (0, import_firestore46.getDocs)(q);
13761
- const events = eventsSnapshot.docs.map((doc44) => ({
13762
- id: doc44.id,
13763
- ...doc44.data()
14057
+ const events = eventsSnapshot.docs.map((doc45) => ({
14058
+ id: doc45.id,
14059
+ ...doc45.data()
13764
14060
  }));
13765
14061
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
13766
14062
  doctorId
@@ -14394,7 +14690,7 @@ var CalendarServiceV2 = class extends BaseService {
14394
14690
  ])
14395
14691
  );
14396
14692
  const querySnapshot = await (0, import_firestore46.getDocs)(q);
14397
- return querySnapshot.docs.map((doc44) => doc44.data());
14693
+ return querySnapshot.docs.map((doc45) => doc45.data());
14398
14694
  }
14399
14695
  /**
14400
14696
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -14925,7 +15221,7 @@ var PractitionerInviteService = class extends BaseService {
14925
15221
  ...constraints
14926
15222
  );
14927
15223
  const querySnapshot = await (0, import_firestore49.getDocs)(q);
14928
- return querySnapshot.docs.map((doc44) => doc44.data());
15224
+ return querySnapshot.docs.map((doc45) => doc45.data());
14929
15225
  } catch (error) {
14930
15226
  console.error(
14931
15227
  "[PractitionerInviteService] Error getting doctor invites:",
@@ -14954,7 +15250,7 @@ var PractitionerInviteService = class extends BaseService {
14954
15250
  ...constraints
14955
15251
  );
14956
15252
  const querySnapshot = await (0, import_firestore49.getDocs)(q);
14957
- return querySnapshot.docs.map((doc44) => doc44.data());
15253
+ return querySnapshot.docs.map((doc45) => doc45.data());
14958
15254
  } catch (error) {
14959
15255
  console.error(
14960
15256
  "[PractitionerInviteService] Error getting clinic invites:",
@@ -15110,7 +15406,7 @@ var PractitionerInviteService = class extends BaseService {
15110
15406
  );
15111
15407
  const querySnapshot = await (0, import_firestore49.getDocs)(q);
15112
15408
  let invites = querySnapshot.docs.map(
15113
- (doc44) => doc44.data()
15409
+ (doc45) => doc45.data()
15114
15410
  );
15115
15411
  if (filters.fromDate) {
15116
15412
  invites = invites.filter(
@@ -15368,8 +15664,8 @@ var DocumentationTemplateService = class extends BaseService {
15368
15664
  const q = (0, import_firestore50.query)(versionsCollectionRef, (0, import_firestore50.orderBy)("version", "desc"));
15369
15665
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15370
15666
  const versions = [];
15371
- querySnapshot.forEach((doc44) => {
15372
- versions.push(doc44.data());
15667
+ querySnapshot.forEach((doc45) => {
15668
+ versions.push(doc45.data());
15373
15669
  });
15374
15670
  return versions;
15375
15671
  }
@@ -15400,9 +15696,9 @@ var DocumentationTemplateService = class extends BaseService {
15400
15696
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15401
15697
  const templates = [];
15402
15698
  let lastVisible = null;
15403
- querySnapshot.forEach((doc44) => {
15404
- templates.push(doc44.data());
15405
- lastVisible = doc44;
15699
+ querySnapshot.forEach((doc45) => {
15700
+ templates.push(doc45.data());
15701
+ lastVisible = doc45;
15406
15702
  });
15407
15703
  return {
15408
15704
  templates,
@@ -15444,9 +15740,9 @@ var DocumentationTemplateService = class extends BaseService {
15444
15740
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15445
15741
  const templates = [];
15446
15742
  let lastVisible = null;
15447
- querySnapshot.forEach((doc44) => {
15448
- templates.push(doc44.data());
15449
- lastVisible = doc44;
15743
+ querySnapshot.forEach((doc45) => {
15744
+ templates.push(doc45.data());
15745
+ lastVisible = doc45;
15450
15746
  });
15451
15747
  return {
15452
15748
  templates,
@@ -15486,8 +15782,8 @@ var DocumentationTemplateService = class extends BaseService {
15486
15782
  );
15487
15783
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15488
15784
  const templates = [];
15489
- querySnapshot.forEach((doc44) => {
15490
- templates.push(doc44.data());
15785
+ querySnapshot.forEach((doc45) => {
15786
+ templates.push(doc45.data());
15491
15787
  });
15492
15788
  return templates;
15493
15789
  }
@@ -15512,9 +15808,9 @@ var DocumentationTemplateService = class extends BaseService {
15512
15808
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15513
15809
  const templates = [];
15514
15810
  let lastVisible = null;
15515
- querySnapshot.forEach((doc44) => {
15516
- templates.push(doc44.data());
15517
- lastVisible = doc44;
15811
+ querySnapshot.forEach((doc45) => {
15812
+ templates.push(doc45.data());
15813
+ lastVisible = doc45;
15518
15814
  });
15519
15815
  return {
15520
15816
  templates,
@@ -15541,9 +15837,9 @@ var DocumentationTemplateService = class extends BaseService {
15541
15837
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15542
15838
  const templates = [];
15543
15839
  let lastVisible = null;
15544
- querySnapshot.forEach((doc44) => {
15545
- templates.push(doc44.data());
15546
- lastVisible = doc44;
15840
+ querySnapshot.forEach((doc45) => {
15841
+ templates.push(doc45.data());
15842
+ lastVisible = doc45;
15547
15843
  });
15548
15844
  return {
15549
15845
  templates,
@@ -15569,8 +15865,8 @@ var DocumentationTemplateService = class extends BaseService {
15569
15865
  }
15570
15866
  const querySnapshot = await (0, import_firestore50.getDocs)(q);
15571
15867
  const templates = [];
15572
- querySnapshot.forEach((doc44) => {
15573
- templates.push(doc44.data());
15868
+ querySnapshot.forEach((doc45) => {
15869
+ templates.push(doc45.data());
15574
15870
  });
15575
15871
  return templates;
15576
15872
  }
@@ -15765,9 +16061,9 @@ var FilledDocumentService = class extends BaseService {
15765
16061
  const querySnapshot = await (0, import_firestore52.getDocs)(q);
15766
16062
  const documents = [];
15767
16063
  let lastVisible = null;
15768
- querySnapshot.forEach((doc44) => {
15769
- documents.push(doc44.data());
15770
- lastVisible = doc44;
16064
+ querySnapshot.forEach((doc45) => {
16065
+ documents.push(doc45.data());
16066
+ lastVisible = doc45;
15771
16067
  });
15772
16068
  return {
15773
16069
  documents,
@@ -15976,9 +16272,9 @@ var NotificationService = class extends BaseService {
15976
16272
  (0, import_firestore53.orderBy)("notificationTime", "desc")
15977
16273
  );
15978
16274
  const querySnapshot = await (0, import_firestore53.getDocs)(q);
15979
- return querySnapshot.docs.map((doc44) => ({
15980
- id: doc44.id,
15981
- ...doc44.data()
16275
+ return querySnapshot.docs.map((doc45) => ({
16276
+ id: doc45.id,
16277
+ ...doc45.data()
15982
16278
  }));
15983
16279
  }
15984
16280
  /**
@@ -15992,9 +16288,9 @@ var NotificationService = class extends BaseService {
15992
16288
  (0, import_firestore53.orderBy)("notificationTime", "desc")
15993
16289
  );
15994
16290
  const querySnapshot = await (0, import_firestore53.getDocs)(q);
15995
- return querySnapshot.docs.map((doc44) => ({
15996
- id: doc44.id,
15997
- ...doc44.data()
16291
+ return querySnapshot.docs.map((doc45) => ({
16292
+ id: doc45.id,
16293
+ ...doc45.data()
15998
16294
  }));
15999
16295
  }
16000
16296
  /**
@@ -16066,9 +16362,9 @@ var NotificationService = class extends BaseService {
16066
16362
  (0, import_firestore53.orderBy)("notificationTime", "desc")
16067
16363
  );
16068
16364
  const querySnapshot = await (0, import_firestore53.getDocs)(q);
16069
- return querySnapshot.docs.map((doc44) => ({
16070
- id: doc44.id,
16071
- ...doc44.data()
16365
+ return querySnapshot.docs.map((doc45) => ({
16366
+ id: doc45.id,
16367
+ ...doc45.data()
16072
16368
  }));
16073
16369
  }
16074
16370
  /**
@@ -16081,9 +16377,9 @@ var NotificationService = class extends BaseService {
16081
16377
  (0, import_firestore53.orderBy)("notificationTime", "desc")
16082
16378
  );
16083
16379
  const querySnapshot = await (0, import_firestore53.getDocs)(q);
16084
- return querySnapshot.docs.map((doc44) => ({
16085
- id: doc44.id,
16086
- ...doc44.data()
16380
+ return querySnapshot.docs.map((doc45) => ({
16381
+ id: doc45.id,
16382
+ ...doc45.data()
16087
16383
  }));
16088
16384
  }
16089
16385
  };
@@ -16694,8 +16990,8 @@ var ProcedureService = class extends BaseService {
16694
16990
  (0, import_firestore55.where)((0, import_firestore55.documentId)(), "in", chunk)
16695
16991
  );
16696
16992
  const practitionersSnapshot = await (0, import_firestore55.getDocs)(practitionersQuery);
16697
- practitionersSnapshot.docs.forEach((doc44) => {
16698
- practitionersMap.set(doc44.id, doc44.data());
16993
+ practitionersSnapshot.docs.forEach((doc45) => {
16994
+ practitionersMap.set(doc45.id, doc45.data());
16699
16995
  });
16700
16996
  }
16701
16997
  if (practitionersMap.size !== practitionerIds.length) {
@@ -16790,8 +17086,8 @@ var ProcedureService = class extends BaseService {
16790
17086
  const chunk = createdProcedureIds.slice(i, i + 30);
16791
17087
  const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), (0, import_firestore55.where)((0, import_firestore55.documentId)(), "in", chunk));
16792
17088
  const snapshot = await (0, import_firestore55.getDocs)(q);
16793
- snapshot.forEach((doc44) => {
16794
- fetchedProcedures.push(doc44.data());
17089
+ snapshot.forEach((doc45) => {
17090
+ fetchedProcedures.push(doc45.data());
16795
17091
  });
16796
17092
  }
16797
17093
  return fetchedProcedures;
@@ -16821,7 +17117,7 @@ var ProcedureService = class extends BaseService {
16821
17117
  (0, import_firestore55.where)("isActive", "==", true)
16822
17118
  );
16823
17119
  const snapshot = await (0, import_firestore55.getDocs)(q);
16824
- return snapshot.docs.map((doc44) => doc44.data());
17120
+ return snapshot.docs.map((doc45) => doc45.data());
16825
17121
  }
16826
17122
  /**
16827
17123
  * Gets all procedures for a practitioner
@@ -16835,7 +17131,7 @@ var ProcedureService = class extends BaseService {
16835
17131
  (0, import_firestore55.where)("isActive", "==", true)
16836
17132
  );
16837
17133
  const snapshot = await (0, import_firestore55.getDocs)(q);
16838
- return snapshot.docs.map((doc44) => doc44.data());
17134
+ return snapshot.docs.map((doc45) => doc45.data());
16839
17135
  }
16840
17136
  /**
16841
17137
  * Gets all inactive procedures for a practitioner
@@ -16849,7 +17145,7 @@ var ProcedureService = class extends BaseService {
16849
17145
  (0, import_firestore55.where)("isActive", "==", false)
16850
17146
  );
16851
17147
  const snapshot = await (0, import_firestore55.getDocs)(q);
16852
- return snapshot.docs.map((doc44) => doc44.data());
17148
+ return snapshot.docs.map((doc45) => doc45.data());
16853
17149
  }
16854
17150
  /**
16855
17151
  * Updates a procedure
@@ -17068,11 +17364,11 @@ var ProcedureService = class extends BaseService {
17068
17364
  }
17069
17365
  const proceduresSnapshot = await (0, import_firestore55.getDocs)(proceduresQuery);
17070
17366
  const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
17071
- const procedures = proceduresSnapshot.docs.map((doc44) => {
17072
- const data = doc44.data();
17367
+ const procedures = proceduresSnapshot.docs.map((doc45) => {
17368
+ const data = doc45.data();
17073
17369
  return {
17074
17370
  ...data,
17075
- id: doc44.id
17371
+ id: doc45.id
17076
17372
  // Ensure ID is present
17077
17373
  };
17078
17374
  });
@@ -17191,7 +17487,7 @@ var ProcedureService = class extends BaseService {
17191
17487
  const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
17192
17488
  const querySnapshot = await (0, import_firestore55.getDocs)(q);
17193
17489
  const procedures = querySnapshot.docs.map(
17194
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17490
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17195
17491
  );
17196
17492
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
17197
17493
  console.log(`[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`);
@@ -17224,7 +17520,7 @@ var ProcedureService = class extends BaseService {
17224
17520
  const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
17225
17521
  const querySnapshot = await (0, import_firestore55.getDocs)(q);
17226
17522
  const procedures = querySnapshot.docs.map(
17227
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17523
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17228
17524
  );
17229
17525
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
17230
17526
  console.log(`[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`);
@@ -17255,7 +17551,7 @@ var ProcedureService = class extends BaseService {
17255
17551
  const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
17256
17552
  const querySnapshot = await (0, import_firestore55.getDocs)(q);
17257
17553
  let procedures = querySnapshot.docs.map(
17258
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17554
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17259
17555
  );
17260
17556
  procedures = this.applyInMemoryFilters(procedures, filters);
17261
17557
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -17283,7 +17579,7 @@ var ProcedureService = class extends BaseService {
17283
17579
  const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
17284
17580
  const querySnapshot = await (0, import_firestore55.getDocs)(q);
17285
17581
  let procedures = querySnapshot.docs.map(
17286
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17582
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17287
17583
  );
17288
17584
  procedures = this.applyInMemoryFilters(procedures, filters);
17289
17585
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -17590,11 +17886,11 @@ var ProcedureService = class extends BaseService {
17590
17886
  async getProceduresForMap() {
17591
17887
  const proceduresRef = (0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION);
17592
17888
  const snapshot = await (0, import_firestore55.getDocs)(proceduresRef);
17593
- const proceduresForMap = snapshot.docs.map((doc44) => {
17889
+ const proceduresForMap = snapshot.docs.map((doc45) => {
17594
17890
  var _a, _b, _c, _d, _e, _f, _g, _h;
17595
- const data = doc44.data();
17891
+ const data = doc45.data();
17596
17892
  return {
17597
- id: doc44.id,
17893
+ id: doc45.id,
17598
17894
  name: data.name,
17599
17895
  clinicId: (_a = data.clinicInfo) == null ? void 0 : _a.id,
17600
17896
  clinicName: (_b = data.clinicInfo) == null ? void 0 : _b.name,
@@ -17637,9 +17933,9 @@ var ProcedureService = class extends BaseService {
17637
17933
  (0, import_firestore55.orderBy)("name", "asc")
17638
17934
  );
17639
17935
  const querySnapshot = await (0, import_firestore55.getDocs)(proceduresQuery);
17640
- return querySnapshot.docs.map((doc44) => ({
17641
- id: doc44.id,
17642
- ...doc44.data()
17936
+ return querySnapshot.docs.map((doc45) => ({
17937
+ id: doc45.id,
17938
+ ...doc45.data()
17643
17939
  }));
17644
17940
  }
17645
17941
  };
@@ -17819,7 +18115,7 @@ var ReviewService = class extends BaseService {
17819
18115
  async getReviewsByPatient(patientId) {
17820
18116
  const q = (0, import_firestore56.query)((0, import_firestore56.collection)(this.db, REVIEWS_COLLECTION), (0, import_firestore56.where)("patientId", "==", patientId));
17821
18117
  const snapshot = await (0, import_firestore56.getDocs)(q);
17822
- const reviews = snapshot.docs.map((doc44) => doc44.data());
18118
+ const reviews = snapshot.docs.map((doc45) => doc45.data());
17823
18119
  const enhancedReviews = await Promise.all(
17824
18120
  reviews.map(async (review) => {
17825
18121
  try {
@@ -17873,9 +18169,9 @@ var ReviewService = class extends BaseService {
17873
18169
  (0, import_firestore56.where)("clinicReview.clinicId", "==", clinicId)
17874
18170
  );
17875
18171
  const snapshot = await (0, import_firestore56.getDocs)(q);
17876
- const reviews = snapshot.docs.map((doc44) => {
17877
- const data = doc44.data();
17878
- return { ...data, id: doc44.id };
18172
+ const reviews = snapshot.docs.map((doc45) => {
18173
+ const data = doc45.data();
18174
+ return { ...data, id: doc45.id };
17879
18175
  });
17880
18176
  console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
17881
18177
  clinicId,
@@ -17949,9 +18245,9 @@ var ReviewService = class extends BaseService {
17949
18245
  (0, import_firestore56.where)("practitionerReview.practitionerId", "==", practitionerId)
17950
18246
  );
17951
18247
  const snapshot = await (0, import_firestore56.getDocs)(q);
17952
- const reviews = snapshot.docs.map((doc44) => {
17953
- const data = doc44.data();
17954
- return { ...data, id: doc44.id };
18248
+ const reviews = snapshot.docs.map((doc45) => {
18249
+ const data = doc45.data();
18250
+ return { ...data, id: doc45.id };
17955
18251
  });
17956
18252
  console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
17957
18253
  practitionerId,
@@ -18022,9 +18318,9 @@ var ReviewService = class extends BaseService {
18022
18318
  (0, import_firestore56.where)("procedureReview.procedureId", "==", procedureId)
18023
18319
  );
18024
18320
  const snapshot = await (0, import_firestore56.getDocs)(q);
18025
- const reviews = snapshot.docs.map((doc44) => {
18026
- const data = doc44.data();
18027
- return { ...data, id: doc44.id };
18321
+ const reviews = snapshot.docs.map((doc45) => {
18322
+ const data = doc45.data();
18323
+ return { ...data, id: doc45.id };
18028
18324
  });
18029
18325
  console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
18030
18326
  procedureId,
@@ -18232,9 +18528,9 @@ var BrandService = class extends BaseService {
18232
18528
  const q = (0, import_firestore58.query)(this.getBrandsRef(), ...constraints);
18233
18529
  const snapshot = await (0, import_firestore58.getDocs)(q);
18234
18530
  const brands = snapshot.docs.map(
18235
- (doc44) => ({
18236
- id: doc44.id,
18237
- ...doc44.data()
18531
+ (doc45) => ({
18532
+ id: doc45.id,
18533
+ ...doc45.data()
18238
18534
  })
18239
18535
  );
18240
18536
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -18268,9 +18564,9 @@ var BrandService = class extends BaseService {
18268
18564
  );
18269
18565
  const snapshot = await (0, import_firestore58.getDocs)(q);
18270
18566
  return snapshot.docs.map(
18271
- (doc44) => ({
18272
- id: doc44.id,
18273
- ...doc44.data()
18567
+ (doc45) => ({
18568
+ id: doc45.id,
18569
+ ...doc45.data()
18274
18570
  })
18275
18571
  );
18276
18572
  }
@@ -18435,9 +18731,9 @@ var CategoryService = class extends BaseService {
18435
18731
  const q = (0, import_firestore59.query)(this.categoriesRef, (0, import_firestore59.where)("isActive", "==", true));
18436
18732
  const snapshot = await (0, import_firestore59.getDocs)(q);
18437
18733
  return snapshot.docs.map(
18438
- (doc44) => ({
18439
- id: doc44.id,
18440
- ...doc44.data()
18734
+ (doc45) => ({
18735
+ id: doc45.id,
18736
+ ...doc45.data()
18441
18737
  })
18442
18738
  );
18443
18739
  }
@@ -18455,9 +18751,9 @@ var CategoryService = class extends BaseService {
18455
18751
  );
18456
18752
  const snapshot = await (0, import_firestore59.getDocs)(q);
18457
18753
  return snapshot.docs.map(
18458
- (doc44) => ({
18459
- id: doc44.id,
18460
- ...doc44.data()
18754
+ (doc45) => ({
18755
+ id: doc45.id,
18756
+ ...doc45.data()
18461
18757
  })
18462
18758
  );
18463
18759
  }
@@ -18477,9 +18773,9 @@ var CategoryService = class extends BaseService {
18477
18773
  const q = (0, import_firestore59.query)(this.categoriesRef, ...constraints);
18478
18774
  const snapshot = await (0, import_firestore59.getDocs)(q);
18479
18775
  const categories = snapshot.docs.map(
18480
- (doc44) => ({
18481
- id: doc44.id,
18482
- ...doc44.data()
18776
+ (doc45) => ({
18777
+ id: doc45.id,
18778
+ ...doc45.data()
18483
18779
  })
18484
18780
  );
18485
18781
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -18503,9 +18799,9 @@ var CategoryService = class extends BaseService {
18503
18799
  const q = (0, import_firestore59.query)(this.categoriesRef, ...constraints);
18504
18800
  const snapshot = await (0, import_firestore59.getDocs)(q);
18505
18801
  const categories = snapshot.docs.map(
18506
- (doc44) => ({
18507
- id: doc44.id,
18508
- ...doc44.data()
18802
+ (doc45) => ({
18803
+ id: doc45.id,
18804
+ ...doc45.data()
18509
18805
  })
18510
18806
  );
18511
18807
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -18697,9 +18993,9 @@ var SubcategoryService = class extends BaseService {
18697
18993
  const q = (0, import_firestore60.query)(this.getSubcategoriesRef(categoryId), ...constraints);
18698
18994
  const querySnapshot = await (0, import_firestore60.getDocs)(q);
18699
18995
  const subcategories = querySnapshot.docs.map(
18700
- (doc44) => ({
18701
- id: doc44.id,
18702
- ...doc44.data()
18996
+ (doc45) => ({
18997
+ id: doc45.id,
18998
+ ...doc45.data()
18703
18999
  })
18704
19000
  );
18705
19001
  const newLastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
@@ -18727,9 +19023,9 @@ var SubcategoryService = class extends BaseService {
18727
19023
  );
18728
19024
  const querySnapshot = await (0, import_firestore60.getDocs)(q);
18729
19025
  const subcategories = querySnapshot.docs.map(
18730
- (doc44) => ({
18731
- id: doc44.id,
18732
- ...doc44.data()
19026
+ (doc45) => ({
19027
+ id: doc45.id,
19028
+ ...doc45.data()
18733
19029
  })
18734
19030
  );
18735
19031
  const newLastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
@@ -18747,9 +19043,9 @@ var SubcategoryService = class extends BaseService {
18747
19043
  );
18748
19044
  const querySnapshot = await (0, import_firestore60.getDocs)(q);
18749
19045
  return querySnapshot.docs.map(
18750
- (doc44) => ({
18751
- id: doc44.id,
18752
- ...doc44.data()
19046
+ (doc45) => ({
19047
+ id: doc45.id,
19048
+ ...doc45.data()
18753
19049
  })
18754
19050
  );
18755
19051
  }
@@ -18764,9 +19060,9 @@ var SubcategoryService = class extends BaseService {
18764
19060
  );
18765
19061
  const querySnapshot = await (0, import_firestore60.getDocs)(q);
18766
19062
  return querySnapshot.docs.map(
18767
- (doc44) => ({
18768
- id: doc44.id,
18769
- ...doc44.data()
19063
+ (doc45) => ({
19064
+ id: doc45.id,
19065
+ ...doc45.data()
18770
19066
  })
18771
19067
  );
18772
19068
  }
@@ -18960,6 +19256,9 @@ var TechnologyService = class extends BaseService {
18960
19256
  if (technology.technicalDetails) {
18961
19257
  newTechnology.technicalDetails = technology.technicalDetails;
18962
19258
  }
19259
+ if (technology.photoTemplate) {
19260
+ newTechnology.photoTemplate = technology.photoTemplate;
19261
+ }
18963
19262
  const docRef = await (0, import_firestore61.addDoc)(this.technologiesRef, newTechnology);
18964
19263
  return { id: docRef.id, ...newTechnology };
18965
19264
  }
@@ -18972,8 +19271,8 @@ var TechnologyService = class extends BaseService {
18972
19271
  const q = (0, import_firestore61.query)(this.technologiesRef, (0, import_firestore61.where)("isActive", "==", active));
18973
19272
  const snapshot = await (0, import_firestore61.getDocs)(q);
18974
19273
  const counts = {};
18975
- snapshot.docs.forEach((doc44) => {
18976
- const tech = doc44.data();
19274
+ snapshot.docs.forEach((doc45) => {
19275
+ const tech = doc45.data();
18977
19276
  counts[tech.subcategoryId] = (counts[tech.subcategoryId] || 0) + 1;
18978
19277
  });
18979
19278
  return counts;
@@ -18987,8 +19286,8 @@ var TechnologyService = class extends BaseService {
18987
19286
  const q = (0, import_firestore61.query)(this.technologiesRef, (0, import_firestore61.where)("isActive", "==", active));
18988
19287
  const snapshot = await (0, import_firestore61.getDocs)(q);
18989
19288
  const counts = {};
18990
- snapshot.docs.forEach((doc44) => {
18991
- const tech = doc44.data();
19289
+ snapshot.docs.forEach((doc45) => {
19290
+ const tech = doc45.data();
18992
19291
  counts[tech.categoryId] = (counts[tech.categoryId] || 0) + 1;
18993
19292
  });
18994
19293
  return counts;
@@ -19009,9 +19308,9 @@ var TechnologyService = class extends BaseService {
19009
19308
  const q = (0, import_firestore61.query)(this.technologiesRef, ...constraints);
19010
19309
  const snapshot = await (0, import_firestore61.getDocs)(q);
19011
19310
  const technologies = snapshot.docs.map(
19012
- (doc44) => ({
19013
- id: doc44.id,
19014
- ...doc44.data()
19311
+ (doc45) => ({
19312
+ id: doc45.id,
19313
+ ...doc45.data()
19015
19314
  })
19016
19315
  );
19017
19316
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19035,9 +19334,9 @@ var TechnologyService = class extends BaseService {
19035
19334
  const q = (0, import_firestore61.query)(this.technologiesRef, ...constraints);
19036
19335
  const snapshot = await (0, import_firestore61.getDocs)(q);
19037
19336
  const technologies = snapshot.docs.map(
19038
- (doc44) => ({
19039
- id: doc44.id,
19040
- ...doc44.data()
19337
+ (doc45) => ({
19338
+ id: doc45.id,
19339
+ ...doc45.data()
19041
19340
  })
19042
19341
  );
19043
19342
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19061,9 +19360,9 @@ var TechnologyService = class extends BaseService {
19061
19360
  const q = (0, import_firestore61.query)(this.technologiesRef, ...constraints);
19062
19361
  const snapshot = await (0, import_firestore61.getDocs)(q);
19063
19362
  const technologies = snapshot.docs.map(
19064
- (doc44) => ({
19065
- id: doc44.id,
19066
- ...doc44.data()
19363
+ (doc45) => ({
19364
+ id: doc45.id,
19365
+ ...doc45.data()
19067
19366
  })
19068
19367
  );
19069
19368
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19082,6 +19381,13 @@ var TechnologyService = class extends BaseService {
19082
19381
  delete updateData[key];
19083
19382
  }
19084
19383
  });
19384
+ if ("photoTemplate" in technology) {
19385
+ if (technology.photoTemplate === null || technology.photoTemplate === "") {
19386
+ updateData.photoTemplate = null;
19387
+ } else if (technology.photoTemplate !== void 0) {
19388
+ updateData.photoTemplate = technology.photoTemplate;
19389
+ }
19390
+ }
19085
19391
  updateData.updatedAt = /* @__PURE__ */ new Date();
19086
19392
  const docRef = (0, import_firestore61.doc)(this.technologiesRef, id);
19087
19393
  const beforeTech = await this.getById(id);
@@ -19487,9 +19793,9 @@ var TechnologyService = class extends BaseService {
19487
19793
  );
19488
19794
  const snapshot = await (0, import_firestore61.getDocs)(q);
19489
19795
  return snapshot.docs.map(
19490
- (doc44) => ({
19491
- id: doc44.id,
19492
- ...doc44.data()
19796
+ (doc45) => ({
19797
+ id: doc45.id,
19798
+ ...doc45.data()
19493
19799
  })
19494
19800
  );
19495
19801
  }
@@ -19508,9 +19814,9 @@ var TechnologyService = class extends BaseService {
19508
19814
  );
19509
19815
  const snapshot = await (0, import_firestore61.getDocs)(q);
19510
19816
  return snapshot.docs.map(
19511
- (doc44) => ({
19512
- id: doc44.id,
19513
- ...doc44.data()
19817
+ (doc45) => ({
19818
+ id: doc45.id,
19819
+ ...doc45.data()
19514
19820
  })
19515
19821
  );
19516
19822
  }
@@ -19525,9 +19831,9 @@ var TechnologyService = class extends BaseService {
19525
19831
  );
19526
19832
  const snapshot = await (0, import_firestore61.getDocs)(q);
19527
19833
  return snapshot.docs.map(
19528
- (doc44) => ({
19529
- id: doc44.id,
19530
- ...doc44.data()
19834
+ (doc45) => ({
19835
+ id: doc45.id,
19836
+ ...doc45.data()
19531
19837
  })
19532
19838
  );
19533
19839
  }
@@ -19577,9 +19883,9 @@ var TechnologyService = class extends BaseService {
19577
19883
  );
19578
19884
  const snapshot = await (0, import_firestore61.getDocs)(q);
19579
19885
  return snapshot.docs.map(
19580
- (doc44) => ({
19581
- id: doc44.id,
19582
- ...doc44.data()
19886
+ (doc45) => ({
19887
+ id: doc45.id,
19888
+ ...doc45.data()
19583
19889
  })
19584
19890
  );
19585
19891
  }
@@ -19594,9 +19900,9 @@ var TechnologyService = class extends BaseService {
19594
19900
  );
19595
19901
  const snapshot = await (0, import_firestore61.getDocs)(q);
19596
19902
  const allProducts = snapshot.docs.map(
19597
- (doc44) => ({
19598
- id: doc44.id,
19599
- ...doc44.data()
19903
+ (doc45) => ({
19904
+ id: doc45.id,
19905
+ ...doc45.data()
19600
19906
  })
19601
19907
  );
19602
19908
  return allProducts.filter(
@@ -19713,8 +20019,8 @@ var TechnologyService = class extends BaseService {
19713
20019
  const productsRef = (0, import_firestore61.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
19714
20020
  const q = (0, import_firestore61.query)(productsRef, (0, import_firestore61.where)("isActive", "==", true));
19715
20021
  const snapshot = await (0, import_firestore61.getDocs)(q);
19716
- return snapshot.docs.map((doc44) => {
19717
- const product = doc44.data();
20022
+ return snapshot.docs.map((doc45) => {
20023
+ const product = doc45.data();
19718
20024
  return product.name || "";
19719
20025
  }).filter((name) => name);
19720
20026
  } catch (error) {
@@ -19810,9 +20116,9 @@ var ProductService = class extends BaseService {
19810
20116
  const q = (0, import_firestore62.query)((0, import_firestore62.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
19811
20117
  const snapshot = await (0, import_firestore62.getDocs)(q);
19812
20118
  const products = snapshot.docs.map(
19813
- (doc44) => ({
19814
- id: doc44.id,
19815
- ...doc44.data()
20119
+ (doc45) => ({
20120
+ id: doc45.id,
20121
+ ...doc45.data()
19816
20122
  })
19817
20123
  );
19818
20124
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19849,8 +20155,8 @@ var ProductService = class extends BaseService {
19849
20155
  };
19850
20156
  const q = (0, import_firestore62.query)((0, import_firestore62.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore62.where)("isActive", "==", true));
19851
20157
  const snapshot = await (0, import_firestore62.getDocs)(q);
19852
- snapshot.docs.forEach((doc44) => {
19853
- const product = doc44.data();
20158
+ snapshot.docs.forEach((doc45) => {
20159
+ const product = doc45.data();
19854
20160
  if (product.categoryId) {
19855
20161
  counts.byCategory[product.categoryId] = (counts.byCategory[product.categoryId] || 0) + 1;
19856
20162
  }
@@ -19874,9 +20180,9 @@ var ProductService = class extends BaseService {
19874
20180
  );
19875
20181
  const snapshot = await (0, import_firestore62.getDocs)(q);
19876
20182
  return snapshot.docs.map(
19877
- (doc44) => ({
19878
- id: doc44.id,
19879
- ...doc44.data()
20183
+ (doc45) => ({
20184
+ id: doc45.id,
20185
+ ...doc45.data()
19880
20186
  })
19881
20187
  );
19882
20188
  }
@@ -19896,9 +20202,9 @@ var ProductService = class extends BaseService {
19896
20202
  const snapshot = await (0, import_firestore62.getDocs)(q);
19897
20203
  products.push(
19898
20204
  ...snapshot.docs.map(
19899
- (doc44) => ({
19900
- id: doc44.id,
19901
- ...doc44.data()
20205
+ (doc45) => ({
20206
+ id: doc45.id,
20207
+ ...doc45.data()
19902
20208
  })
19903
20209
  )
19904
20210
  );
@@ -19972,9 +20278,9 @@ var ProductService = class extends BaseService {
19972
20278
  const q = (0, import_firestore62.query)(this.getTopLevelProductsRef(), ...constraints);
19973
20279
  const snapshot = await (0, import_firestore62.getDocs)(q);
19974
20280
  const products = snapshot.docs.map(
19975
- (doc44) => ({
19976
- id: doc44.id,
19977
- ...doc44.data()
20281
+ (doc45) => ({
20282
+ id: doc45.id,
20283
+ ...doc45.data()
19978
20284
  })
19979
20285
  );
19980
20286
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -20044,9 +20350,9 @@ var ProductService = class extends BaseService {
20044
20350
  );
20045
20351
  const snapshot = await (0, import_firestore62.getDocs)(q);
20046
20352
  return snapshot.docs.map(
20047
- (doc44) => ({
20048
- id: doc44.id,
20049
- ...doc44.data()
20353
+ (doc45) => ({
20354
+ id: doc45.id,
20355
+ ...doc45.data()
20050
20356
  })
20051
20357
  );
20052
20358
  }
@@ -20061,9 +20367,9 @@ var ProductService = class extends BaseService {
20061
20367
  );
20062
20368
  const snapshot = await (0, import_firestore62.getDocs)(q);
20063
20369
  const allProducts = snapshot.docs.map(
20064
- (doc44) => ({
20065
- id: doc44.id,
20066
- ...doc44.data()
20370
+ (doc45) => ({
20371
+ id: doc45.id,
20372
+ ...doc45.data()
20067
20373
  })
20068
20374
  );
20069
20375
  return allProducts.filter(
@@ -20085,9 +20391,9 @@ var ProductService = class extends BaseService {
20085
20391
  );
20086
20392
  const snapshot = await (0, import_firestore62.getDocs)(q);
20087
20393
  return snapshot.docs.map(
20088
- (doc44) => ({
20089
- id: doc44.id,
20090
- ...doc44.data()
20394
+ (doc45) => ({
20395
+ id: doc45.id,
20396
+ ...doc45.data()
20091
20397
  })
20092
20398
  );
20093
20399
  }