@blackcode_sa/metaestetics-api 1.7.26 → 1.7.27

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
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  CalendarEventStatus: () => CalendarEventStatus,
47
47
  CalendarEventType: () => CalendarEventType,
48
48
  CalendarServiceV2: () => CalendarServiceV2,
49
+ CalendarServiceV3: () => CalendarServiceV3,
49
50
  CalendarSyncStatus: () => CalendarSyncStatus,
50
51
  CategoryService: () => CategoryService,
51
52
  CertificationLevel: () => CertificationLevel,
@@ -152,6 +153,7 @@ __export(index_exports, {
152
153
  contraindicationSchema: () => contraindicationSchema,
153
154
  createAdminTokenSchema: () => createAdminTokenSchema,
154
155
  createAppointmentSchema: () => createAppointmentSchema,
156
+ createBlockingEventSchema: () => createBlockingEventSchema,
155
157
  createCalendarEventSchema: () => createCalendarEventSchema,
156
158
  createClinicAdminSchema: () => createClinicAdminSchema,
157
159
  createClinicGroupSchema: () => createClinicGroupSchema,
@@ -222,6 +224,7 @@ __export(index_exports, {
222
224
  updateAllergySchema: () => updateAllergySchema,
223
225
  updateAppointmentSchema: () => updateAppointmentSchema,
224
226
  updateBlockingConditionSchema: () => updateBlockingConditionSchema,
227
+ updateBlockingEventSchema: () => updateBlockingEventSchema,
225
228
  updateCalendarEventSchema: () => updateCalendarEventSchema,
226
229
  updateClinicAdminSchema: () => updateClinicAdminSchema,
227
230
  updateClinicGroupSchema: () => updateClinicGroupSchema,
@@ -1483,7 +1486,7 @@ var MediaService = class extends BaseService {
1483
1486
  try {
1484
1487
  const querySnapshot = await (0, import_firestore3.getDocs)(finalQuery);
1485
1488
  const mediaList = querySnapshot.docs.map(
1486
- (doc35) => doc35.data()
1489
+ (doc36) => doc36.data()
1487
1490
  );
1488
1491
  console.log(`[MediaService] Found ${mediaList.length} media items.`);
1489
1492
  return mediaList;
@@ -2120,8 +2123,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
2120
2123
  }
2121
2124
  const patientsSnapshot = await (0, import_firestore8.getDocs)(q);
2122
2125
  const patients = [];
2123
- patientsSnapshot.forEach((doc35) => {
2124
- patients.push(doc35.data());
2126
+ patientsSnapshot.forEach((doc36) => {
2127
+ patients.push(doc36.data());
2125
2128
  });
2126
2129
  console.log(
2127
2130
  `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
@@ -2351,9 +2354,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
2351
2354
  });
2352
2355
  };
2353
2356
  var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
2354
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2355
- if (!doc35.exists()) throw new Error("Medical info not found");
2356
- const medicalInfo = doc35.data();
2357
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2358
+ if (!doc36.exists()) throw new Error("Medical info not found");
2359
+ const medicalInfo = doc36.data();
2357
2360
  if (allergyIndex >= medicalInfo.allergies.length) {
2358
2361
  throw new Error("Invalid allergy index");
2359
2362
  }
@@ -2378,9 +2381,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
2378
2381
  var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
2379
2382
  const validatedData = updateBlockingConditionSchema.parse(data);
2380
2383
  const { conditionIndex, ...updateData } = validatedData;
2381
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2382
- if (!doc35.exists()) throw new Error("Medical info not found");
2383
- const medicalInfo = doc35.data();
2384
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2385
+ if (!doc36.exists()) throw new Error("Medical info not found");
2386
+ const medicalInfo = doc36.data();
2384
2387
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
2385
2388
  throw new Error("Invalid blocking condition index");
2386
2389
  }
@@ -2396,9 +2399,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
2396
2399
  });
2397
2400
  };
2398
2401
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
2399
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2400
- if (!doc35.exists()) throw new Error("Medical info not found");
2401
- const medicalInfo = doc35.data();
2402
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2403
+ if (!doc36.exists()) throw new Error("Medical info not found");
2404
+ const medicalInfo = doc36.data();
2402
2405
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
2403
2406
  throw new Error("Invalid blocking condition index");
2404
2407
  }
@@ -2423,9 +2426,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
2423
2426
  var updateContraindicationUtil = async (db, patientId, data, userRef) => {
2424
2427
  const validatedData = updateContraindicationSchema.parse(data);
2425
2428
  const { contraindicationIndex, ...updateData } = validatedData;
2426
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2427
- if (!doc35.exists()) throw new Error("Medical info not found");
2428
- const medicalInfo = doc35.data();
2429
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2430
+ if (!doc36.exists()) throw new Error("Medical info not found");
2431
+ const medicalInfo = doc36.data();
2429
2432
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
2430
2433
  throw new Error("Invalid contraindication index");
2431
2434
  }
@@ -2441,9 +2444,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
2441
2444
  });
2442
2445
  };
2443
2446
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
2444
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2445
- if (!doc35.exists()) throw new Error("Medical info not found");
2446
- const medicalInfo = doc35.data();
2447
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2448
+ if (!doc36.exists()) throw new Error("Medical info not found");
2449
+ const medicalInfo = doc36.data();
2447
2450
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
2448
2451
  throw new Error("Invalid contraindication index");
2449
2452
  }
@@ -2468,9 +2471,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
2468
2471
  var updateMedicationUtil = async (db, patientId, data, userRef) => {
2469
2472
  const validatedData = updateMedicationSchema.parse(data);
2470
2473
  const { medicationIndex, ...updateData } = validatedData;
2471
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2472
- if (!doc35.exists()) throw new Error("Medical info not found");
2473
- const medicalInfo = doc35.data();
2474
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2475
+ if (!doc36.exists()) throw new Error("Medical info not found");
2476
+ const medicalInfo = doc36.data();
2474
2477
  if (medicationIndex >= medicalInfo.currentMedications.length) {
2475
2478
  throw new Error("Invalid medication index");
2476
2479
  }
@@ -2486,9 +2489,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
2486
2489
  });
2487
2490
  };
2488
2491
  var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
2489
- const doc35 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2490
- if (!doc35.exists()) throw new Error("Medical info not found");
2491
- const medicalInfo = doc35.data();
2492
+ const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
2493
+ if (!doc36.exists()) throw new Error("Medical info not found");
2494
+ const medicalInfo = doc36.data();
2492
2495
  if (medicationIndex >= medicalInfo.currentMedications.length) {
2493
2496
  throw new Error("Invalid medication index");
2494
2497
  }
@@ -2767,7 +2770,7 @@ var searchPatientsUtil = async (db, params, requester) => {
2767
2770
  const finalQuery = (0, import_firestore10.query)(patientsCollectionRef, ...constraints);
2768
2771
  const querySnapshot = await (0, import_firestore10.getDocs)(finalQuery);
2769
2772
  const patients = querySnapshot.docs.map(
2770
- (doc35) => doc35.data()
2773
+ (doc36) => doc36.data()
2771
2774
  );
2772
2775
  console.log(
2773
2776
  `[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
@@ -2799,8 +2802,8 @@ var getAllPatientsUtil = async (db, options) => {
2799
2802
  }
2800
2803
  const patientsSnapshot = await (0, import_firestore10.getDocs)(q);
2801
2804
  const patients = [];
2802
- patientsSnapshot.forEach((doc35) => {
2803
- patients.push(doc35.data());
2805
+ patientsSnapshot.forEach((doc36) => {
2806
+ patients.push(doc36.data());
2804
2807
  });
2805
2808
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
2806
2809
  return patients;
@@ -3012,8 +3015,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
3012
3015
  }
3013
3016
  const patientsSnapshot = await (0, import_firestore13.getDocs)(q);
3014
3017
  const patients = [];
3015
- patientsSnapshot.forEach((doc35) => {
3016
- patients.push(doc35.data());
3018
+ patientsSnapshot.forEach((doc36) => {
3019
+ patients.push(doc36.data());
3017
3020
  });
3018
3021
  console.log(
3019
3022
  `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
@@ -4281,7 +4284,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
4281
4284
  (0, import_firestore16.where)("clinicGroupId", "==", clinicGroupId)
4282
4285
  );
4283
4286
  const querySnapshot = await (0, import_firestore16.getDocs)(q);
4284
- return querySnapshot.docs.map((doc35) => doc35.data());
4287
+ return querySnapshot.docs.map((doc36) => doc36.data());
4285
4288
  }
4286
4289
  async function updateClinicAdmin(db, adminId, data) {
4287
4290
  const admin = await getClinicAdmin(db, adminId);
@@ -5018,7 +5021,7 @@ var PractitionerService = class extends BaseService {
5018
5021
  (0, import_firestore18.where)("expiresAt", ">", import_firestore18.Timestamp.now())
5019
5022
  );
5020
5023
  const querySnapshot = await (0, import_firestore18.getDocs)(q);
5021
- return querySnapshot.docs.map((doc35) => doc35.data());
5024
+ return querySnapshot.docs.map((doc36) => doc36.data());
5022
5025
  }
5023
5026
  /**
5024
5027
  * Gets a token by its string value and validates it
@@ -5128,7 +5131,7 @@ var PractitionerService = class extends BaseService {
5128
5131
  (0, import_firestore18.where)("status", "==", "active" /* ACTIVE */)
5129
5132
  );
5130
5133
  const querySnapshot = await (0, import_firestore18.getDocs)(q);
5131
- return querySnapshot.docs.map((doc35) => doc35.data());
5134
+ return querySnapshot.docs.map((doc36) => doc36.data());
5132
5135
  }
5133
5136
  /**
5134
5137
  * Dohvata sve zdravstvene radnike za određenu kliniku
@@ -5140,7 +5143,7 @@ var PractitionerService = class extends BaseService {
5140
5143
  (0, import_firestore18.where)("isActive", "==", true)
5141
5144
  );
5142
5145
  const querySnapshot = await (0, import_firestore18.getDocs)(q);
5143
- return querySnapshot.docs.map((doc35) => doc35.data());
5146
+ return querySnapshot.docs.map((doc36) => doc36.data());
5144
5147
  }
5145
5148
  /**
5146
5149
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
@@ -5152,7 +5155,7 @@ var PractitionerService = class extends BaseService {
5152
5155
  (0, import_firestore18.where)("status", "==", "draft" /* DRAFT */)
5153
5156
  );
5154
5157
  const querySnapshot = await (0, import_firestore18.getDocs)(q);
5155
- return querySnapshot.docs.map((doc35) => doc35.data());
5158
+ return querySnapshot.docs.map((doc36) => doc36.data());
5156
5159
  }
5157
5160
  /**
5158
5161
  * Updates a practitioner
@@ -5366,7 +5369,7 @@ var PractitionerService = class extends BaseService {
5366
5369
  );
5367
5370
  const querySnapshot = await (0, import_firestore18.getDocs)(q);
5368
5371
  const practitioners = querySnapshot.docs.map(
5369
- (doc35) => doc35.data()
5372
+ (doc36) => doc36.data()
5370
5373
  );
5371
5374
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
5372
5375
  return {
@@ -5437,8 +5440,8 @@ var PractitionerService = class extends BaseService {
5437
5440
  console.log(
5438
5441
  `[PRACTITIONER_SERVICE] Found ${querySnapshot.docs.length} practitioners with base query`
5439
5442
  );
5440
- let practitioners = querySnapshot.docs.map((doc35) => {
5441
- return { ...doc35.data(), id: doc35.id };
5443
+ let practitioners = querySnapshot.docs.map((doc36) => {
5444
+ return { ...doc36.data(), id: doc36.id };
5442
5445
  });
5443
5446
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
5444
5447
  if (filters.nameSearch && filters.nameSearch.trim() !== "") {
@@ -5695,7 +5698,7 @@ var UserService = class extends BaseService {
5695
5698
  ];
5696
5699
  const q = (0, import_firestore19.query)((0, import_firestore19.collection)(this.db, USERS_COLLECTION), ...constraints);
5697
5700
  const querySnapshot = await (0, import_firestore19.getDocs)(q);
5698
- const users = querySnapshot.docs.map((doc35) => doc35.data());
5701
+ const users = querySnapshot.docs.map((doc36) => doc36.data());
5699
5702
  return Promise.all(users.map((userData) => userSchema.parse(userData)));
5700
5703
  }
5701
5704
  /**
@@ -6059,7 +6062,7 @@ async function getAllActiveGroups(db) {
6059
6062
  (0, import_firestore20.where)("isActive", "==", true)
6060
6063
  );
6061
6064
  const querySnapshot = await (0, import_firestore20.getDocs)(q);
6062
- return querySnapshot.docs.map((doc35) => doc35.data());
6065
+ return querySnapshot.docs.map((doc36) => doc36.data());
6063
6066
  }
6064
6067
  async function updateClinicGroup(db, groupId, data, app) {
6065
6068
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -6499,7 +6502,7 @@ async function getClinicsByGroup(db, groupId) {
6499
6502
  (0, import_firestore21.where)("isActive", "==", true)
6500
6503
  );
6501
6504
  const querySnapshot = await (0, import_firestore21.getDocs)(q);
6502
- return querySnapshot.docs.map((doc35) => doc35.data());
6505
+ return querySnapshot.docs.map((doc36) => doc36.data());
6503
6506
  }
6504
6507
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
6505
6508
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -6693,7 +6696,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
6693
6696
  }
6694
6697
  const q = (0, import_firestore21.query)((0, import_firestore21.collection)(db, CLINICS_COLLECTION), ...constraints);
6695
6698
  const querySnapshot = await (0, import_firestore21.getDocs)(q);
6696
- return querySnapshot.docs.map((doc35) => doc35.data());
6699
+ return querySnapshot.docs.map((doc36) => doc36.data());
6697
6700
  }
6698
6701
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
6699
6702
  return getClinicsByAdmin(
@@ -6738,11 +6741,11 @@ async function getAllClinics(db, pagination, lastDoc) {
6738
6741
  }
6739
6742
  const clinicsSnapshot = await (0, import_firestore21.getDocs)(clinicsQuery);
6740
6743
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
6741
- const clinics = clinicsSnapshot.docs.map((doc35) => {
6742
- const data = doc35.data();
6744
+ const clinics = clinicsSnapshot.docs.map((doc36) => {
6745
+ const data = doc36.data();
6743
6746
  return {
6744
6747
  ...data,
6745
- id: doc35.id
6748
+ id: doc36.id
6746
6749
  };
6747
6750
  });
6748
6751
  return {
@@ -6769,8 +6772,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
6769
6772
  ];
6770
6773
  const q = (0, import_firestore21.query)((0, import_firestore21.collection)(db, CLINICS_COLLECTION), ...constraints);
6771
6774
  const querySnapshot = await (0, import_firestore21.getDocs)(q);
6772
- for (const doc35 of querySnapshot.docs) {
6773
- const clinic = doc35.data();
6775
+ for (const doc36 of querySnapshot.docs) {
6776
+ const clinic = doc36.data();
6774
6777
  const distance = (0, import_geofire_common4.distanceBetween)(
6775
6778
  [center.latitude, center.longitude],
6776
6779
  [clinic.location.latitude, clinic.location.longitude]
@@ -6887,8 +6890,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
6887
6890
  }
6888
6891
  const q = (0, import_firestore22.query)((0, import_firestore22.collection)(db, CLINICS_COLLECTION), ...constraints);
6889
6892
  const querySnapshot = await (0, import_firestore22.getDocs)(q);
6890
- for (const doc35 of querySnapshot.docs) {
6891
- const clinic = doc35.data();
6893
+ for (const doc36 of querySnapshot.docs) {
6894
+ const clinic = doc36.data();
6892
6895
  const distance = (0, import_geofire_common5.distanceBetween)(
6893
6896
  [center.latitude, center.longitude],
6894
6897
  [clinic.location.latitude, clinic.location.longitude]
@@ -6976,8 +6979,8 @@ async function getClinicsByFilters(db, filters) {
6976
6979
  console.log(
6977
6980
  `[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics in geo bound`
6978
6981
  );
6979
- for (const doc35 of querySnapshot.docs) {
6980
- const clinic = { ...doc35.data(), id: doc35.id };
6982
+ for (const doc36 of querySnapshot.docs) {
6983
+ const clinic = { ...doc36.data(), id: doc36.id };
6981
6984
  const distance = (0, import_geofire_common6.distanceBetween)(
6982
6985
  [center.latitude, center.longitude],
6983
6986
  [clinic.location.latitude, clinic.location.longitude]
@@ -7033,8 +7036,8 @@ async function getClinicsByFilters(db, filters) {
7033
7036
  console.log(
7034
7037
  `[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics with regular query`
7035
7038
  );
7036
- const clinics = querySnapshot.docs.map((doc35) => {
7037
- return { ...doc35.data(), id: doc35.id };
7039
+ const clinics = querySnapshot.docs.map((doc36) => {
7040
+ return { ...doc36.data(), id: doc36.id };
7038
7041
  });
7039
7042
  let filteredClinics = clinics;
7040
7043
  if (filters.center) {
@@ -8468,9 +8471,9 @@ var NotificationService = class extends BaseService {
8468
8471
  (0, import_firestore26.orderBy)("notificationTime", "desc")
8469
8472
  );
8470
8473
  const querySnapshot = await (0, import_firestore26.getDocs)(q);
8471
- return querySnapshot.docs.map((doc35) => ({
8472
- id: doc35.id,
8473
- ...doc35.data()
8474
+ return querySnapshot.docs.map((doc36) => ({
8475
+ id: doc36.id,
8476
+ ...doc36.data()
8474
8477
  }));
8475
8478
  }
8476
8479
  /**
@@ -8484,9 +8487,9 @@ var NotificationService = class extends BaseService {
8484
8487
  (0, import_firestore26.orderBy)("notificationTime", "desc")
8485
8488
  );
8486
8489
  const querySnapshot = await (0, import_firestore26.getDocs)(q);
8487
- return querySnapshot.docs.map((doc35) => ({
8488
- id: doc35.id,
8489
- ...doc35.data()
8490
+ return querySnapshot.docs.map((doc36) => ({
8491
+ id: doc36.id,
8492
+ ...doc36.data()
8490
8493
  }));
8491
8494
  }
8492
8495
  /**
@@ -8558,9 +8561,9 @@ var NotificationService = class extends BaseService {
8558
8561
  (0, import_firestore26.orderBy)("notificationTime", "desc")
8559
8562
  );
8560
8563
  const querySnapshot = await (0, import_firestore26.getDocs)(q);
8561
- return querySnapshot.docs.map((doc35) => ({
8562
- id: doc35.id,
8563
- ...doc35.data()
8564
+ return querySnapshot.docs.map((doc36) => ({
8565
+ id: doc36.id,
8566
+ ...doc36.data()
8564
8567
  }));
8565
8568
  }
8566
8569
  /**
@@ -8573,9 +8576,9 @@ var NotificationService = class extends BaseService {
8573
8576
  (0, import_firestore26.orderBy)("notificationTime", "desc")
8574
8577
  );
8575
8578
  const querySnapshot = await (0, import_firestore26.getDocs)(q);
8576
- return querySnapshot.docs.map((doc35) => ({
8577
- id: doc35.id,
8578
- ...doc35.data()
8579
+ return querySnapshot.docs.map((doc36) => ({
8580
+ id: doc36.id,
8581
+ ...doc36.data()
8579
8582
  }));
8580
8583
  }
8581
8584
  };
@@ -8856,7 +8859,7 @@ var ProcedureService = class extends BaseService {
8856
8859
  (0, import_firestore27.where)("isActive", "==", true)
8857
8860
  );
8858
8861
  const snapshot = await (0, import_firestore27.getDocs)(q);
8859
- return snapshot.docs.map((doc35) => doc35.data());
8862
+ return snapshot.docs.map((doc36) => doc36.data());
8860
8863
  }
8861
8864
  /**
8862
8865
  * Gets all procedures for a practitioner
@@ -8870,7 +8873,7 @@ var ProcedureService = class extends BaseService {
8870
8873
  (0, import_firestore27.where)("isActive", "==", true)
8871
8874
  );
8872
8875
  const snapshot = await (0, import_firestore27.getDocs)(q);
8873
- return snapshot.docs.map((doc35) => doc35.data());
8876
+ return snapshot.docs.map((doc36) => doc36.data());
8874
8877
  }
8875
8878
  /**
8876
8879
  * Updates a procedure
@@ -9082,11 +9085,11 @@ var ProcedureService = class extends BaseService {
9082
9085
  }
9083
9086
  const proceduresSnapshot = await (0, import_firestore27.getDocs)(proceduresQuery);
9084
9087
  const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
9085
- const procedures = proceduresSnapshot.docs.map((doc35) => {
9086
- const data = doc35.data();
9088
+ const procedures = proceduresSnapshot.docs.map((doc36) => {
9089
+ const data = doc36.data();
9087
9090
  return {
9088
9091
  ...data,
9089
- id: doc35.id
9092
+ id: doc36.id
9090
9093
  // Ensure ID is present
9091
9094
  };
9092
9095
  });
@@ -9168,8 +9171,8 @@ var ProcedureService = class extends BaseService {
9168
9171
  console.log(
9169
9172
  `[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures in geo bound`
9170
9173
  );
9171
- for (const doc35 of querySnapshot.docs) {
9172
- const procedure = { ...doc35.data(), id: doc35.id };
9174
+ for (const doc36 of querySnapshot.docs) {
9175
+ const procedure = { ...doc36.data(), id: doc36.id };
9173
9176
  const distance = (0, import_geofire_common8.distanceBetween)(
9174
9177
  [center.latitude, center.longitude],
9175
9178
  [
@@ -9220,8 +9223,8 @@ var ProcedureService = class extends BaseService {
9220
9223
  console.log(
9221
9224
  `[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures with regular query`
9222
9225
  );
9223
- const procedures = querySnapshot.docs.map((doc35) => {
9224
- return { ...doc35.data(), id: doc35.id };
9226
+ const procedures = querySnapshot.docs.map((doc36) => {
9227
+ return { ...doc36.data(), id: doc36.id };
9225
9228
  });
9226
9229
  if (filters.location) {
9227
9230
  const center = filters.location;
@@ -9432,7 +9435,7 @@ var PractitionerInviteService = class extends BaseService {
9432
9435
  ...constraints
9433
9436
  );
9434
9437
  const querySnapshot = await (0, import_firestore28.getDocs)(q);
9435
- return querySnapshot.docs.map((doc35) => doc35.data());
9438
+ return querySnapshot.docs.map((doc36) => doc36.data());
9436
9439
  } catch (error) {
9437
9440
  console.error(
9438
9441
  "[PractitionerInviteService] Error getting doctor invites:",
@@ -9461,7 +9464,7 @@ var PractitionerInviteService = class extends BaseService {
9461
9464
  ...constraints
9462
9465
  );
9463
9466
  const querySnapshot = await (0, import_firestore28.getDocs)(q);
9464
- return querySnapshot.docs.map((doc35) => doc35.data());
9467
+ return querySnapshot.docs.map((doc36) => doc36.data());
9465
9468
  } catch (error) {
9466
9469
  console.error(
9467
9470
  "[PractitionerInviteService] Error getting clinic invites:",
@@ -9617,7 +9620,7 @@ var PractitionerInviteService = class extends BaseService {
9617
9620
  );
9618
9621
  const querySnapshot = await (0, import_firestore28.getDocs)(q);
9619
9622
  let invites = querySnapshot.docs.map(
9620
- (doc35) => doc35.data()
9623
+ (doc36) => doc36.data()
9621
9624
  );
9622
9625
  if (filters.fromDate) {
9623
9626
  invites = invites.filter(
@@ -9874,8 +9877,8 @@ var DocumentationTemplateService = class extends BaseService {
9874
9877
  const q = (0, import_firestore29.query)(versionsCollectionRef, (0, import_firestore29.orderBy)("version", "desc"));
9875
9878
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
9876
9879
  const versions = [];
9877
- querySnapshot.forEach((doc35) => {
9878
- versions.push(doc35.data());
9880
+ querySnapshot.forEach((doc36) => {
9881
+ versions.push(doc36.data());
9879
9882
  });
9880
9883
  return versions;
9881
9884
  }
@@ -9906,9 +9909,9 @@ var DocumentationTemplateService = class extends BaseService {
9906
9909
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
9907
9910
  const templates = [];
9908
9911
  let lastVisible = null;
9909
- querySnapshot.forEach((doc35) => {
9910
- templates.push(doc35.data());
9911
- lastVisible = doc35;
9912
+ querySnapshot.forEach((doc36) => {
9913
+ templates.push(doc36.data());
9914
+ lastVisible = doc36;
9912
9915
  });
9913
9916
  return {
9914
9917
  templates,
@@ -9936,9 +9939,9 @@ var DocumentationTemplateService = class extends BaseService {
9936
9939
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
9937
9940
  const templates = [];
9938
9941
  let lastVisible = null;
9939
- querySnapshot.forEach((doc35) => {
9940
- templates.push(doc35.data());
9941
- lastVisible = doc35;
9942
+ querySnapshot.forEach((doc36) => {
9943
+ templates.push(doc36.data());
9944
+ lastVisible = doc36;
9942
9945
  });
9943
9946
  return {
9944
9947
  templates,
@@ -9965,9 +9968,9 @@ var DocumentationTemplateService = class extends BaseService {
9965
9968
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
9966
9969
  const templates = [];
9967
9970
  let lastVisible = null;
9968
- querySnapshot.forEach((doc35) => {
9969
- templates.push(doc35.data());
9970
- lastVisible = doc35;
9971
+ querySnapshot.forEach((doc36) => {
9972
+ templates.push(doc36.data());
9973
+ lastVisible = doc36;
9971
9974
  });
9972
9975
  return {
9973
9976
  templates,
@@ -9993,8 +9996,8 @@ var DocumentationTemplateService = class extends BaseService {
9993
9996
  }
9994
9997
  const querySnapshot = await (0, import_firestore29.getDocs)(q);
9995
9998
  const templates = [];
9996
- querySnapshot.forEach((doc35) => {
9997
- templates.push(doc35.data());
9999
+ querySnapshot.forEach((doc36) => {
10000
+ templates.push(doc36.data());
9998
10001
  });
9999
10002
  return templates;
10000
10003
  }
@@ -10189,9 +10192,9 @@ var FilledDocumentService = class extends BaseService {
10189
10192
  const querySnapshot = await (0, import_firestore30.getDocs)(q);
10190
10193
  const documents = [];
10191
10194
  let lastVisible = null;
10192
- querySnapshot.forEach((doc35) => {
10193
- documents.push(doc35.data());
10194
- lastVisible = doc35;
10195
+ querySnapshot.forEach((doc36) => {
10196
+ documents.push(doc36.data());
10197
+ lastVisible = doc36;
10195
10198
  });
10196
10199
  return {
10197
10200
  documents,
@@ -10537,6 +10540,28 @@ var calendarEventSchema = import_zod23.z.object({
10537
10540
  createdAt: import_zod23.z.instanceof(Date).or(import_zod23.z.instanceof(import_firestore32.Timestamp)),
10538
10541
  updatedAt: import_zod23.z.instanceof(Date).or(import_zod23.z.instanceof(import_firestore32.Timestamp))
10539
10542
  });
10543
+ var createBlockingEventSchema = import_zod23.z.object({
10544
+ entityType: import_zod23.z.enum(["practitioner", "clinic"]),
10545
+ entityId: import_zod23.z.string().min(1, "Entity ID is required"),
10546
+ eventName: import_zod23.z.string().min(1, "Event name is required").max(200, "Event name too long"),
10547
+ eventTime: calendarEventTimeSchema,
10548
+ eventType: import_zod23.z.enum([
10549
+ "blocking" /* BLOCKING */,
10550
+ "break" /* BREAK */,
10551
+ "free_day" /* FREE_DAY */,
10552
+ "other" /* OTHER */
10553
+ ]),
10554
+ description: import_zod23.z.string().max(1e3, "Description too long").optional()
10555
+ });
10556
+ var updateBlockingEventSchema = import_zod23.z.object({
10557
+ entityType: import_zod23.z.enum(["practitioner", "clinic"]),
10558
+ entityId: import_zod23.z.string().min(1, "Entity ID is required"),
10559
+ eventId: import_zod23.z.string().min(1, "Event ID is required"),
10560
+ eventName: import_zod23.z.string().min(1, "Event name is required").max(200, "Event name too long").optional(),
10561
+ eventTime: calendarEventTimeSchema.optional(),
10562
+ description: import_zod23.z.string().max(1e3, "Description too long").optional(),
10563
+ status: import_zod23.z.nativeEnum(CalendarEventStatus).optional()
10564
+ });
10540
10565
 
10541
10566
  // src/services/calendar/utils/clinic.utils.ts
10542
10567
  var import_firestore34 = require("firebase/firestore");
@@ -10837,7 +10862,7 @@ async function searchCalendarEventsUtil(db, params) {
10837
10862
  const finalQuery = (0, import_firestore37.query)(collectionRef, ...constraints);
10838
10863
  const querySnapshot = await (0, import_firestore37.getDocs)(finalQuery);
10839
10864
  const events = querySnapshot.docs.map(
10840
- (doc35) => ({ id: doc35.id, ...doc35.data() })
10865
+ (doc36) => ({ id: doc36.id, ...doc36.data() })
10841
10866
  );
10842
10867
  return events;
10843
10868
  } catch (error) {
@@ -10919,7 +10944,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
10919
10944
  );
10920
10945
  const q = (0, import_firestore38.query)(calendarsRef, (0, import_firestore38.orderBy)("createdAt", "desc"));
10921
10946
  const querySnapshot = await (0, import_firestore38.getDocs)(q);
10922
- return querySnapshot.docs.map((doc35) => doc35.data());
10947
+ return querySnapshot.docs.map((doc36) => doc36.data());
10923
10948
  }
10924
10949
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
10925
10950
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
@@ -10936,7 +10961,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
10936
10961
  );
10937
10962
  const q = (0, import_firestore38.query)(calendarsRef, (0, import_firestore38.orderBy)("createdAt", "desc"));
10938
10963
  const querySnapshot = await (0, import_firestore38.getDocs)(q);
10939
- return querySnapshot.docs.map((doc35) => doc35.data());
10964
+ return querySnapshot.docs.map((doc36) => doc36.data());
10940
10965
  }
10941
10966
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
10942
10967
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
@@ -10953,7 +10978,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
10953
10978
  );
10954
10979
  const q = (0, import_firestore38.query)(calendarsRef, (0, import_firestore38.orderBy)("createdAt", "desc"));
10955
10980
  const querySnapshot = await (0, import_firestore38.getDocs)(q);
10956
- return querySnapshot.docs.map((doc35) => doc35.data());
10981
+ return querySnapshot.docs.map((doc36) => doc36.data());
10957
10982
  }
10958
10983
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
10959
10984
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -12308,9 +12333,9 @@ var CalendarServiceV2 = class extends BaseService {
12308
12333
  (0, import_firestore41.where)("eventTime.start", "<=", import_firestore40.Timestamp.fromDate(endDate))
12309
12334
  );
12310
12335
  const eventsSnapshot = await (0, import_firestore41.getDocs)(q);
12311
- const events = eventsSnapshot.docs.map((doc35) => ({
12312
- id: doc35.id,
12313
- ...doc35.data()
12336
+ const events = eventsSnapshot.docs.map((doc36) => ({
12337
+ id: doc36.id,
12338
+ ...doc36.data()
12314
12339
  }));
12315
12340
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
12316
12341
  doctorId
@@ -12944,7 +12969,7 @@ var CalendarServiceV2 = class extends BaseService {
12944
12969
  ])
12945
12970
  );
12946
12971
  const querySnapshot = await (0, import_firestore41.getDocs)(q);
12947
- return querySnapshot.docs.map((doc35) => doc35.data());
12972
+ return querySnapshot.docs.map((doc36) => doc36.data());
12948
12973
  }
12949
12974
  /**
12950
12975
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -13068,8 +13093,205 @@ var CalendarServiceV2 = class extends BaseService {
13068
13093
  // #endregion
13069
13094
  };
13070
13095
 
13071
- // src/services/reviews/reviews.service.ts
13096
+ // src/services/calendar/calendar.v3.service.ts
13072
13097
  var import_firestore42 = require("firebase/firestore");
13098
+ var import_firestore43 = require("firebase/firestore");
13099
+ var CalendarServiceV3 = class extends BaseService {
13100
+ /**
13101
+ * Creates a new CalendarServiceV3 instance
13102
+ * @param db - Firestore instance
13103
+ * @param auth - Firebase Auth instance
13104
+ * @param app - Firebase App instance
13105
+ */
13106
+ constructor(db, auth, app) {
13107
+ super(db, auth, app);
13108
+ }
13109
+ // #region Blocking Event CRUD Operations
13110
+ /**
13111
+ * Creates a blocking event for a practitioner or clinic
13112
+ * @param params - Blocking event creation parameters
13113
+ * @returns Created calendar event
13114
+ */
13115
+ async createBlockingEvent(params) {
13116
+ this.validateBlockingEventParams(params);
13117
+ const eventId = this.generateId();
13118
+ const collectionPath = this.getEntityCalendarPath(
13119
+ params.entityType,
13120
+ params.entityId
13121
+ );
13122
+ const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, eventId);
13123
+ const eventData = {
13124
+ id: eventId,
13125
+ eventName: params.eventName,
13126
+ eventTime: params.eventTime,
13127
+ eventType: params.eventType,
13128
+ description: params.description || "",
13129
+ status: "confirmed" /* CONFIRMED */,
13130
+ // Blocking events are always confirmed
13131
+ syncStatus: "internal" /* INTERNAL */,
13132
+ createdAt: (0, import_firestore42.serverTimestamp)(),
13133
+ updatedAt: (0, import_firestore42.serverTimestamp)()
13134
+ };
13135
+ if (params.entityType === "practitioner") {
13136
+ eventData.practitionerProfileId = params.entityId;
13137
+ } else {
13138
+ eventData.clinicBranchId = params.entityId;
13139
+ }
13140
+ await (0, import_firestore43.setDoc)(eventRef, eventData);
13141
+ return {
13142
+ ...eventData,
13143
+ createdAt: import_firestore42.Timestamp.now(),
13144
+ updatedAt: import_firestore42.Timestamp.now()
13145
+ };
13146
+ }
13147
+ /**
13148
+ * Updates a blocking event
13149
+ * @param params - Blocking event update parameters
13150
+ * @returns Updated calendar event
13151
+ */
13152
+ async updateBlockingEvent(params) {
13153
+ const collectionPath = this.getEntityCalendarPath(
13154
+ params.entityType,
13155
+ params.entityId
13156
+ );
13157
+ const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, params.eventId);
13158
+ const eventDoc = await (0, import_firestore43.getDoc)(eventRef);
13159
+ if (!eventDoc.exists()) {
13160
+ throw new Error(`Blocking event with ID ${params.eventId} not found`);
13161
+ }
13162
+ const updateData = {
13163
+ updatedAt: (0, import_firestore42.serverTimestamp)()
13164
+ };
13165
+ if (params.eventName !== void 0) {
13166
+ updateData.eventName = params.eventName;
13167
+ }
13168
+ if (params.eventTime !== void 0) {
13169
+ updateData.eventTime = params.eventTime;
13170
+ }
13171
+ if (params.description !== void 0) {
13172
+ updateData.description = params.description;
13173
+ }
13174
+ if (params.status !== void 0) {
13175
+ updateData.status = params.status;
13176
+ }
13177
+ await (0, import_firestore43.updateDoc)(eventRef, updateData);
13178
+ const updatedEventDoc = await (0, import_firestore43.getDoc)(eventRef);
13179
+ return updatedEventDoc.data();
13180
+ }
13181
+ /**
13182
+ * Deletes a blocking event
13183
+ * @param entityType - Type of entity (practitioner or clinic)
13184
+ * @param entityId - ID of the entity
13185
+ * @param eventId - ID of the event to delete
13186
+ */
13187
+ async deleteBlockingEvent(entityType, entityId, eventId) {
13188
+ const collectionPath = this.getEntityCalendarPath(entityType, entityId);
13189
+ const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, eventId);
13190
+ const eventDoc = await (0, import_firestore43.getDoc)(eventRef);
13191
+ if (!eventDoc.exists()) {
13192
+ throw new Error(`Blocking event with ID ${eventId} not found`);
13193
+ }
13194
+ await (0, import_firestore43.deleteDoc)(eventRef);
13195
+ }
13196
+ /**
13197
+ * Gets a specific blocking event
13198
+ * @param entityType - Type of entity (practitioner or clinic)
13199
+ * @param entityId - ID of the entity
13200
+ * @param eventId - ID of the event to retrieve
13201
+ * @returns Calendar event or null if not found
13202
+ */
13203
+ async getBlockingEvent(entityType, entityId, eventId) {
13204
+ const collectionPath = this.getEntityCalendarPath(entityType, entityId);
13205
+ const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, eventId);
13206
+ const eventDoc = await (0, import_firestore43.getDoc)(eventRef);
13207
+ if (!eventDoc.exists()) {
13208
+ return null;
13209
+ }
13210
+ return eventDoc.data();
13211
+ }
13212
+ /**
13213
+ * Gets blocking events for a specific entity
13214
+ * @param entityType - Type of entity (practitioner or clinic)
13215
+ * @param entityId - ID of the entity
13216
+ * @param dateRange - Optional date range filter
13217
+ * @param eventType - Optional event type filter
13218
+ * @returns Array of calendar events
13219
+ */
13220
+ async getEntityBlockingEvents(entityType, entityId, dateRange, eventType) {
13221
+ const searchParams = {
13222
+ searchLocation: entityType === "practitioner" ? "practitioner" /* PRACTITIONER */ : "clinic" /* CLINIC */,
13223
+ entityId,
13224
+ dateRange,
13225
+ eventType
13226
+ };
13227
+ if (!eventType) {
13228
+ const allEvents = await searchCalendarEventsUtil(this.db, searchParams);
13229
+ return allEvents.filter(
13230
+ (event) => event.eventType === "blocking" /* BLOCKING */ || event.eventType === "break" /* BREAK */ || event.eventType === "free_day" /* FREE_DAY */ || event.eventType === "other" /* OTHER */
13231
+ );
13232
+ }
13233
+ return searchCalendarEventsUtil(this.db, searchParams);
13234
+ }
13235
+ // #endregion
13236
+ // #region Calendar Event Search
13237
+ /**
13238
+ * Searches for calendar events based on specified criteria.
13239
+ * This method supports searching for ALL event types (appointments, blocking events, etc.)
13240
+ *
13241
+ * @param params - The search parameters
13242
+ * @returns A promise that resolves to an array of matching calendar events
13243
+ */
13244
+ async searchCalendarEvents(params) {
13245
+ return searchCalendarEventsUtil(this.db, params);
13246
+ }
13247
+ // #endregion
13248
+ // #region Private Helper Methods
13249
+ /**
13250
+ * Gets the calendar collection path for a specific entity
13251
+ * @param entityType - Type of entity (practitioner or clinic)
13252
+ * @param entityId - ID of the entity
13253
+ * @returns Collection path string
13254
+ */
13255
+ getEntityCalendarPath(entityType, entityId) {
13256
+ if (entityType === "practitioner") {
13257
+ return `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
13258
+ } else {
13259
+ return `${CLINICS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
13260
+ }
13261
+ }
13262
+ /**
13263
+ * Validates blocking event creation parameters
13264
+ * @param params - Parameters to validate
13265
+ * @throws Error if validation fails
13266
+ */
13267
+ validateBlockingEventParams(params) {
13268
+ if (!params.entityType || !params.entityId) {
13269
+ throw new Error("Entity type and ID are required");
13270
+ }
13271
+ if (!params.eventName || params.eventName.trim() === "") {
13272
+ throw new Error("Event name is required");
13273
+ }
13274
+ if (!params.eventTime || !params.eventTime.start || !params.eventTime.end) {
13275
+ throw new Error("Event time with start and end is required");
13276
+ }
13277
+ if (params.eventTime.end.toMillis() <= params.eventTime.start.toMillis()) {
13278
+ throw new Error("Event end time must be after start time");
13279
+ }
13280
+ const validTypes = [
13281
+ "blocking" /* BLOCKING */,
13282
+ "break" /* BREAK */,
13283
+ "free_day" /* FREE_DAY */,
13284
+ "other" /* OTHER */
13285
+ ];
13286
+ if (!validTypes.includes(params.eventType)) {
13287
+ throw new Error("Invalid event type for blocking events");
13288
+ }
13289
+ }
13290
+ // #endregion
13291
+ };
13292
+
13293
+ // src/services/reviews/reviews.service.ts
13294
+ var import_firestore44 = require("firebase/firestore");
13073
13295
 
13074
13296
  // src/types/reviews/index.ts
13075
13297
  var REVIEWS_COLLECTION = "reviews";
@@ -13154,11 +13376,11 @@ var ReviewService = class extends BaseService {
13154
13376
  updatedAt: now
13155
13377
  };
13156
13378
  reviewSchema.parse(review);
13157
- const docRef = (0, import_firestore42.doc)(this.db, REVIEWS_COLLECTION, reviewId);
13158
- await (0, import_firestore42.setDoc)(docRef, {
13379
+ const docRef = (0, import_firestore44.doc)(this.db, REVIEWS_COLLECTION, reviewId);
13380
+ await (0, import_firestore44.setDoc)(docRef, {
13159
13381
  ...review,
13160
- createdAt: (0, import_firestore42.serverTimestamp)(),
13161
- updatedAt: (0, import_firestore42.serverTimestamp)()
13382
+ createdAt: (0, import_firestore44.serverTimestamp)(),
13383
+ updatedAt: (0, import_firestore44.serverTimestamp)()
13162
13384
  });
13163
13385
  return review;
13164
13386
  } catch (error) {
@@ -13174,8 +13396,8 @@ var ReviewService = class extends BaseService {
13174
13396
  * @returns The review if found, null otherwise
13175
13397
  */
13176
13398
  async getReview(reviewId) {
13177
- const docRef = (0, import_firestore42.doc)(this.db, REVIEWS_COLLECTION, reviewId);
13178
- const docSnap = await (0, import_firestore42.getDoc)(docRef);
13399
+ const docRef = (0, import_firestore44.doc)(this.db, REVIEWS_COLLECTION, reviewId);
13400
+ const docSnap = await (0, import_firestore44.getDoc)(docRef);
13179
13401
  if (!docSnap.exists()) {
13180
13402
  return null;
13181
13403
  }
@@ -13187,12 +13409,12 @@ var ReviewService = class extends BaseService {
13187
13409
  * @returns Array of reviews for the patient
13188
13410
  */
13189
13411
  async getReviewsByPatient(patientId) {
13190
- const q = (0, import_firestore42.query)(
13191
- (0, import_firestore42.collection)(this.db, REVIEWS_COLLECTION),
13192
- (0, import_firestore42.where)("patientId", "==", patientId)
13412
+ const q = (0, import_firestore44.query)(
13413
+ (0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
13414
+ (0, import_firestore44.where)("patientId", "==", patientId)
13193
13415
  );
13194
- const snapshot = await (0, import_firestore42.getDocs)(q);
13195
- return snapshot.docs.map((doc35) => doc35.data());
13416
+ const snapshot = await (0, import_firestore44.getDocs)(q);
13417
+ return snapshot.docs.map((doc36) => doc36.data());
13196
13418
  }
13197
13419
  /**
13198
13420
  * Gets all reviews for a specific clinic
@@ -13200,12 +13422,12 @@ var ReviewService = class extends BaseService {
13200
13422
  * @returns Array of reviews containing clinic reviews
13201
13423
  */
13202
13424
  async getReviewsByClinic(clinicId) {
13203
- const q = (0, import_firestore42.query)(
13204
- (0, import_firestore42.collection)(this.db, REVIEWS_COLLECTION),
13205
- (0, import_firestore42.where)("clinicReview.clinicId", "==", clinicId)
13425
+ const q = (0, import_firestore44.query)(
13426
+ (0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
13427
+ (0, import_firestore44.where)("clinicReview.clinicId", "==", clinicId)
13206
13428
  );
13207
- const snapshot = await (0, import_firestore42.getDocs)(q);
13208
- return snapshot.docs.map((doc35) => doc35.data());
13429
+ const snapshot = await (0, import_firestore44.getDocs)(q);
13430
+ return snapshot.docs.map((doc36) => doc36.data());
13209
13431
  }
13210
13432
  /**
13211
13433
  * Gets all reviews for a specific practitioner
@@ -13213,12 +13435,12 @@ var ReviewService = class extends BaseService {
13213
13435
  * @returns Array of reviews containing practitioner reviews
13214
13436
  */
13215
13437
  async getReviewsByPractitioner(practitionerId) {
13216
- const q = (0, import_firestore42.query)(
13217
- (0, import_firestore42.collection)(this.db, REVIEWS_COLLECTION),
13218
- (0, import_firestore42.where)("practitionerReview.practitionerId", "==", practitionerId)
13438
+ const q = (0, import_firestore44.query)(
13439
+ (0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
13440
+ (0, import_firestore44.where)("practitionerReview.practitionerId", "==", practitionerId)
13219
13441
  );
13220
- const snapshot = await (0, import_firestore42.getDocs)(q);
13221
- return snapshot.docs.map((doc35) => doc35.data());
13442
+ const snapshot = await (0, import_firestore44.getDocs)(q);
13443
+ return snapshot.docs.map((doc36) => doc36.data());
13222
13444
  }
13223
13445
  /**
13224
13446
  * Gets all reviews for a specific procedure
@@ -13226,12 +13448,12 @@ var ReviewService = class extends BaseService {
13226
13448
  * @returns Array of reviews containing procedure reviews
13227
13449
  */
13228
13450
  async getReviewsByProcedure(procedureId) {
13229
- const q = (0, import_firestore42.query)(
13230
- (0, import_firestore42.collection)(this.db, REVIEWS_COLLECTION),
13231
- (0, import_firestore42.where)("procedureReview.procedureId", "==", procedureId)
13451
+ const q = (0, import_firestore44.query)(
13452
+ (0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
13453
+ (0, import_firestore44.where)("procedureReview.procedureId", "==", procedureId)
13232
13454
  );
13233
- const snapshot = await (0, import_firestore42.getDocs)(q);
13234
- return snapshot.docs.map((doc35) => doc35.data());
13455
+ const snapshot = await (0, import_firestore44.getDocs)(q);
13456
+ return snapshot.docs.map((doc36) => doc36.data());
13235
13457
  }
13236
13458
  /**
13237
13459
  * Gets all reviews for a specific appointment
@@ -13239,11 +13461,11 @@ var ReviewService = class extends BaseService {
13239
13461
  * @returns The review for the appointment if found, null otherwise
13240
13462
  */
13241
13463
  async getReviewByAppointment(appointmentId) {
13242
- const q = (0, import_firestore42.query)(
13243
- (0, import_firestore42.collection)(this.db, REVIEWS_COLLECTION),
13244
- (0, import_firestore42.where)("appointmentId", "==", appointmentId)
13464
+ const q = (0, import_firestore44.query)(
13465
+ (0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
13466
+ (0, import_firestore44.where)("appointmentId", "==", appointmentId)
13245
13467
  );
13246
- const snapshot = await (0, import_firestore42.getDocs)(q);
13468
+ const snapshot = await (0, import_firestore44.getDocs)(q);
13247
13469
  if (snapshot.empty) {
13248
13470
  return null;
13249
13471
  }
@@ -13258,7 +13480,7 @@ var ReviewService = class extends BaseService {
13258
13480
  if (!review) {
13259
13481
  throw new Error(`Review with ID ${reviewId} not found`);
13260
13482
  }
13261
- await (0, import_firestore42.deleteDoc)((0, import_firestore42.doc)(this.db, REVIEWS_COLLECTION, reviewId));
13483
+ await (0, import_firestore44.deleteDoc)((0, import_firestore44.doc)(this.db, REVIEWS_COLLECTION, reviewId));
13262
13484
  }
13263
13485
  /**
13264
13486
  * Calculates the average of an array of numbers
@@ -13276,11 +13498,11 @@ var ReviewService = class extends BaseService {
13276
13498
  };
13277
13499
 
13278
13500
  // src/services/appointment/appointment.service.ts
13279
- var import_firestore44 = require("firebase/firestore");
13501
+ var import_firestore46 = require("firebase/firestore");
13280
13502
  var import_functions2 = require("firebase/functions");
13281
13503
 
13282
13504
  // src/services/appointment/utils/appointment.utils.ts
13283
- var import_firestore43 = require("firebase/firestore");
13505
+ var import_firestore45 = require("firebase/firestore");
13284
13506
 
13285
13507
  // src/backoffice/types/technology.types.ts
13286
13508
  var TECHNOLOGIES_COLLECTION = "technologies";
@@ -13288,8 +13510,8 @@ var TECHNOLOGIES_COLLECTION = "technologies";
13288
13510
  // src/services/appointment/utils/appointment.utils.ts
13289
13511
  async function updateAppointmentUtil2(db, appointmentId, data) {
13290
13512
  try {
13291
- const appointmentRef = (0, import_firestore43.doc)(db, APPOINTMENTS_COLLECTION, appointmentId);
13292
- const appointmentDoc = await (0, import_firestore43.getDoc)(appointmentRef);
13513
+ const appointmentRef = (0, import_firestore45.doc)(db, APPOINTMENTS_COLLECTION, appointmentId);
13514
+ const appointmentDoc = await (0, import_firestore45.getDoc)(appointmentRef);
13293
13515
  if (!appointmentDoc.exists()) {
13294
13516
  throw new Error(`Appointment with ID ${appointmentId} not found`);
13295
13517
  }
@@ -13338,7 +13560,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
13338
13560
  ...data,
13339
13561
  completedPreRequirements,
13340
13562
  completedPostRequirements,
13341
- updatedAt: (0, import_firestore43.serverTimestamp)()
13563
+ updatedAt: (0, import_firestore45.serverTimestamp)()
13342
13564
  };
13343
13565
  Object.keys(updateData).forEach((key) => {
13344
13566
  if (updateData[key] === void 0) {
@@ -13347,7 +13569,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
13347
13569
  });
13348
13570
  if (data.status && data.status !== currentAppointment.status) {
13349
13571
  if (data.status === "confirmed" /* CONFIRMED */ && !updateData.confirmationTime) {
13350
- updateData.confirmationTime = import_firestore43.Timestamp.now();
13572
+ updateData.confirmationTime = import_firestore45.Timestamp.now();
13351
13573
  }
13352
13574
  if (currentAppointment.calendarEventId) {
13353
13575
  await updateCalendarEventStatus(
@@ -13357,8 +13579,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
13357
13579
  );
13358
13580
  }
13359
13581
  }
13360
- await (0, import_firestore43.updateDoc)(appointmentRef, updateData);
13361
- const updatedAppointmentDoc = await (0, import_firestore43.getDoc)(appointmentRef);
13582
+ await (0, import_firestore45.updateDoc)(appointmentRef, updateData);
13583
+ const updatedAppointmentDoc = await (0, import_firestore45.getDoc)(appointmentRef);
13362
13584
  if (!updatedAppointmentDoc.exists()) {
13363
13585
  throw new Error(
13364
13586
  `Failed to retrieve updated appointment ${appointmentId}`
@@ -13372,8 +13594,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
13372
13594
  }
13373
13595
  async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus) {
13374
13596
  try {
13375
- const calendarEventRef = (0, import_firestore43.doc)(db, CALENDAR_COLLECTION, calendarEventId);
13376
- const calendarEventDoc = await (0, import_firestore43.getDoc)(calendarEventRef);
13597
+ const calendarEventRef = (0, import_firestore45.doc)(db, CALENDAR_COLLECTION, calendarEventId);
13598
+ const calendarEventDoc = await (0, import_firestore45.getDoc)(calendarEventRef);
13377
13599
  if (!calendarEventDoc.exists()) {
13378
13600
  console.warn(`Calendar event with ID ${calendarEventId} not found`);
13379
13601
  return;
@@ -13396,9 +13618,9 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
13396
13618
  default:
13397
13619
  return;
13398
13620
  }
13399
- await (0, import_firestore43.updateDoc)(calendarEventRef, {
13621
+ await (0, import_firestore45.updateDoc)(calendarEventRef, {
13400
13622
  status: calendarStatus,
13401
- updatedAt: (0, import_firestore43.serverTimestamp)()
13623
+ updatedAt: (0, import_firestore45.serverTimestamp)()
13402
13624
  });
13403
13625
  } catch (error) {
13404
13626
  console.error(`Error updating calendar event ${calendarEventId}:`, error);
@@ -13406,8 +13628,8 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
13406
13628
  }
13407
13629
  async function getAppointmentByIdUtil(db, appointmentId) {
13408
13630
  try {
13409
- const appointmentDoc = await (0, import_firestore43.getDoc)(
13410
- (0, import_firestore43.doc)(db, APPOINTMENTS_COLLECTION, appointmentId)
13631
+ const appointmentDoc = await (0, import_firestore45.getDoc)(
13632
+ (0, import_firestore45.doc)(db, APPOINTMENTS_COLLECTION, appointmentId)
13411
13633
  );
13412
13634
  if (!appointmentDoc.exists()) {
13413
13635
  return null;
@@ -13422,46 +13644,46 @@ async function searchAppointmentsUtil(db, params) {
13422
13644
  try {
13423
13645
  const constraints = [];
13424
13646
  if (params.patientId) {
13425
- constraints.push((0, import_firestore43.where)("patientId", "==", params.patientId));
13647
+ constraints.push((0, import_firestore45.where)("patientId", "==", params.patientId));
13426
13648
  }
13427
13649
  if (params.practitionerId) {
13428
- constraints.push((0, import_firestore43.where)("practitionerId", "==", params.practitionerId));
13650
+ constraints.push((0, import_firestore45.where)("practitionerId", "==", params.practitionerId));
13429
13651
  }
13430
13652
  if (params.clinicBranchId) {
13431
- constraints.push((0, import_firestore43.where)("clinicBranchId", "==", params.clinicBranchId));
13653
+ constraints.push((0, import_firestore45.where)("clinicBranchId", "==", params.clinicBranchId));
13432
13654
  }
13433
13655
  if (params.startDate) {
13434
13656
  constraints.push(
13435
- (0, import_firestore43.where)(
13657
+ (0, import_firestore45.where)(
13436
13658
  "appointmentStartTime",
13437
13659
  ">=",
13438
- import_firestore43.Timestamp.fromDate(params.startDate)
13660
+ import_firestore45.Timestamp.fromDate(params.startDate)
13439
13661
  )
13440
13662
  );
13441
13663
  }
13442
13664
  if (params.endDate) {
13443
13665
  constraints.push(
13444
- (0, import_firestore43.where)("appointmentStartTime", "<=", import_firestore43.Timestamp.fromDate(params.endDate))
13666
+ (0, import_firestore45.where)("appointmentStartTime", "<=", import_firestore45.Timestamp.fromDate(params.endDate))
13445
13667
  );
13446
13668
  }
13447
13669
  if (params.status) {
13448
13670
  if (Array.isArray(params.status)) {
13449
- constraints.push((0, import_firestore43.where)("status", "in", params.status));
13671
+ constraints.push((0, import_firestore45.where)("status", "in", params.status));
13450
13672
  } else {
13451
- constraints.push((0, import_firestore43.where)("status", "==", params.status));
13673
+ constraints.push((0, import_firestore45.where)("status", "==", params.status));
13452
13674
  }
13453
13675
  }
13454
- constraints.push((0, import_firestore43.orderBy)("appointmentStartTime", "asc"));
13676
+ constraints.push((0, import_firestore45.orderBy)("appointmentStartTime", "asc"));
13455
13677
  if (params.limit) {
13456
- constraints.push((0, import_firestore43.limit)(params.limit));
13678
+ constraints.push((0, import_firestore45.limit)(params.limit));
13457
13679
  }
13458
13680
  if (params.startAfter) {
13459
- constraints.push((0, import_firestore43.startAfter)(params.startAfter));
13681
+ constraints.push((0, import_firestore45.startAfter)(params.startAfter));
13460
13682
  }
13461
- const q = (0, import_firestore43.query)((0, import_firestore43.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
13462
- const querySnapshot = await (0, import_firestore43.getDocs)(q);
13683
+ const q = (0, import_firestore45.query)((0, import_firestore45.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
13684
+ const querySnapshot = await (0, import_firestore45.getDocs)(q);
13463
13685
  const appointments = querySnapshot.docs.map(
13464
- (doc35) => doc35.data()
13686
+ (doc36) => doc36.data()
13465
13687
  );
13466
13688
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
13467
13689
  return { appointments, lastDoc };
@@ -13830,7 +14052,7 @@ var AppointmentService = class extends BaseService {
13830
14052
  );
13831
14053
  const updateData = {
13832
14054
  status: newStatus,
13833
- updatedAt: (0, import_firestore44.serverTimestamp)()
14055
+ updatedAt: (0, import_firestore46.serverTimestamp)()
13834
14056
  };
13835
14057
  if (newStatus === "canceled_clinic" /* CANCELED_CLINIC */ || newStatus === "canceled_patient" /* CANCELED_PATIENT */ || newStatus === "canceled_patient_rescheduled" /* CANCELED_PATIENT_RESCHEDULED */) {
13836
14058
  if (!(details == null ? void 0 : details.cancellationReason)) {
@@ -13841,13 +14063,13 @@ var AppointmentService = class extends BaseService {
13841
14063
  }
13842
14064
  updateData.cancellationReason = details.cancellationReason;
13843
14065
  updateData.canceledBy = details.canceledBy;
13844
- updateData.cancellationTime = import_firestore44.Timestamp.now();
14066
+ updateData.cancellationTime = import_firestore46.Timestamp.now();
13845
14067
  }
13846
14068
  if (newStatus === "confirmed" /* CONFIRMED */) {
13847
- updateData.confirmationTime = import_firestore44.Timestamp.now();
14069
+ updateData.confirmationTime = import_firestore46.Timestamp.now();
13848
14070
  }
13849
14071
  if (newStatus === "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */) {
13850
- updateData.rescheduleTime = import_firestore44.Timestamp.now();
14072
+ updateData.rescheduleTime = import_firestore46.Timestamp.now();
13851
14073
  }
13852
14074
  return this.updateAppointment(appointmentId, updateData);
13853
14075
  }
@@ -13925,9 +14147,9 @@ var AppointmentService = class extends BaseService {
13925
14147
  status: "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */,
13926
14148
  appointmentStartTime: startTimestamp,
13927
14149
  appointmentEndTime: endTimestamp,
13928
- rescheduleTime: import_firestore44.Timestamp.now(),
14150
+ rescheduleTime: import_firestore46.Timestamp.now(),
13929
14151
  confirmationTime: null,
13930
- updatedAt: (0, import_firestore44.serverTimestamp)()
14152
+ updatedAt: (0, import_firestore46.serverTimestamp)()
13931
14153
  };
13932
14154
  return this.updateAppointment(validatedParams.appointmentId, updateData);
13933
14155
  }
@@ -13945,19 +14167,19 @@ var AppointmentService = class extends BaseService {
13945
14167
  return value;
13946
14168
  }
13947
14169
  if (typeof value === "number") {
13948
- return import_firestore44.Timestamp.fromMillis(value);
14170
+ return import_firestore46.Timestamp.fromMillis(value);
13949
14171
  }
13950
14172
  if (typeof value === "string") {
13951
- return import_firestore44.Timestamp.fromDate(new Date(value));
14173
+ return import_firestore46.Timestamp.fromDate(new Date(value));
13952
14174
  }
13953
14175
  if (value instanceof Date) {
13954
- return import_firestore44.Timestamp.fromDate(value);
14176
+ return import_firestore46.Timestamp.fromDate(value);
13955
14177
  }
13956
14178
  if (value && typeof value._seconds === "number") {
13957
- return new import_firestore44.Timestamp(value._seconds, value._nanoseconds || 0);
14179
+ return new import_firestore46.Timestamp(value._seconds, value._nanoseconds || 0);
13958
14180
  }
13959
14181
  if (value && typeof value.seconds === "number") {
13960
- return new import_firestore44.Timestamp(value.seconds, value.nanoseconds || 0);
14182
+ return new import_firestore46.Timestamp(value.seconds, value.nanoseconds || 0);
13961
14183
  }
13962
14184
  throw new Error(
13963
14185
  `Invalid timestamp format: ${typeof value}, value: ${JSON.stringify(
@@ -14056,9 +14278,9 @@ var AppointmentService = class extends BaseService {
14056
14278
  }
14057
14279
  const updateData = {
14058
14280
  status: "in_progress" /* IN_PROGRESS */,
14059
- procedureActualStartTime: import_firestore44.Timestamp.now(),
14281
+ procedureActualStartTime: import_firestore46.Timestamp.now(),
14060
14282
  // Set actual start time
14061
- updatedAt: (0, import_firestore44.serverTimestamp)()
14283
+ updatedAt: (0, import_firestore46.serverTimestamp)()
14062
14284
  };
14063
14285
  return this.updateAppointment(appointmentId, updateData);
14064
14286
  }
@@ -14076,7 +14298,7 @@ var AppointmentService = class extends BaseService {
14076
14298
  if (!appointment)
14077
14299
  throw new Error(`Appointment ${appointmentId} not found.`);
14078
14300
  let calculatedDurationMinutes = actualDurationMinutesInput;
14079
- const procedureCompletionTime = import_firestore44.Timestamp.now();
14301
+ const procedureCompletionTime = import_firestore46.Timestamp.now();
14080
14302
  if (calculatedDurationMinutes === void 0 && appointment.procedureActualStartTime) {
14081
14303
  const startTimeMillis = appointment.procedureActualStartTime.toMillis();
14082
14304
  const endTimeMillis = procedureCompletionTime.toMillis();
@@ -14099,7 +14321,7 @@ var AppointmentService = class extends BaseService {
14099
14321
  },
14100
14322
  // Optionally update appointmentEndTime to the actual completion time
14101
14323
  // appointmentEndTime: procedureCompletionTime,
14102
- updatedAt: (0, import_firestore44.serverTimestamp)()
14324
+ updatedAt: (0, import_firestore46.serverTimestamp)()
14103
14325
  };
14104
14326
  return this.updateAppointment(appointmentId, updateData);
14105
14327
  }
@@ -14113,7 +14335,7 @@ var AppointmentService = class extends BaseService {
14113
14335
  const appointment = await this.getAppointmentById(appointmentId);
14114
14336
  if (!appointment)
14115
14337
  throw new Error(`Appointment ${appointmentId} not found.`);
14116
- if (import_firestore44.Timestamp.now().toMillis() < appointment.appointmentStartTime.toMillis()) {
14338
+ if (import_firestore46.Timestamp.now().toMillis() < appointment.appointmentStartTime.toMillis()) {
14117
14339
  throw new Error("Cannot mark no-show before appointment start time.");
14118
14340
  }
14119
14341
  return this.updateAppointmentStatus(
@@ -14137,12 +14359,12 @@ var AppointmentService = class extends BaseService {
14137
14359
  const newMediaItem = {
14138
14360
  ...mediaItemData,
14139
14361
  id: this.generateId(),
14140
- uploadedAt: import_firestore44.Timestamp.now(),
14362
+ uploadedAt: import_firestore46.Timestamp.now(),
14141
14363
  uploadedBy: currentUser.uid
14142
14364
  };
14143
14365
  const updateData = {
14144
- media: (0, import_firestore44.arrayUnion)(newMediaItem),
14145
- updatedAt: (0, import_firestore44.serverTimestamp)()
14366
+ media: (0, import_firestore46.arrayUnion)(newMediaItem),
14367
+ updatedAt: (0, import_firestore46.serverTimestamp)()
14146
14368
  };
14147
14369
  return this.updateAppointment(appointmentId, updateData);
14148
14370
  }
@@ -14162,8 +14384,8 @@ var AppointmentService = class extends BaseService {
14162
14384
  throw new Error(`Media item ${mediaItemId} not found in appointment.`);
14163
14385
  }
14164
14386
  const updateData = {
14165
- media: (0, import_firestore44.arrayRemove)(mediaToRemove),
14166
- updatedAt: (0, import_firestore44.serverTimestamp)()
14387
+ media: (0, import_firestore46.arrayRemove)(mediaToRemove),
14388
+ updatedAt: (0, import_firestore46.serverTimestamp)()
14167
14389
  };
14168
14390
  return this.updateAppointment(appointmentId, updateData);
14169
14391
  }
@@ -14177,11 +14399,11 @@ var AppointmentService = class extends BaseService {
14177
14399
  const newReviewInfo = {
14178
14400
  ...reviewData,
14179
14401
  reviewId: this.generateId(),
14180
- reviewedAt: import_firestore44.Timestamp.now()
14402
+ reviewedAt: import_firestore46.Timestamp.now()
14181
14403
  };
14182
14404
  const updateData = {
14183
14405
  reviewInfo: newReviewInfo,
14184
- updatedAt: (0, import_firestore44.serverTimestamp)()
14406
+ updatedAt: (0, import_firestore46.serverTimestamp)()
14185
14407
  };
14186
14408
  return this.updateAppointment(appointmentId, updateData);
14187
14409
  }
@@ -14195,7 +14417,7 @@ var AppointmentService = class extends BaseService {
14195
14417
  const updateData = {
14196
14418
  paymentStatus,
14197
14419
  paymentTransactionId: paymentTransactionId || null,
14198
- updatedAt: (0, import_firestore44.serverTimestamp)()
14420
+ updatedAt: (0, import_firestore46.serverTimestamp)()
14199
14421
  };
14200
14422
  return this.updateAppointment(appointmentId, updateData);
14201
14423
  }
@@ -14237,38 +14459,38 @@ var AppointmentService = class extends BaseService {
14237
14459
  "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */
14238
14460
  ];
14239
14461
  const constraints = [];
14240
- constraints.push((0, import_firestore44.where)("patientId", "==", patientId));
14241
- constraints.push((0, import_firestore44.where)("status", "in", upcomingStatuses));
14462
+ constraints.push((0, import_firestore46.where)("patientId", "==", patientId));
14463
+ constraints.push((0, import_firestore46.where)("status", "in", upcomingStatuses));
14242
14464
  constraints.push(
14243
- (0, import_firestore44.where)(
14465
+ (0, import_firestore46.where)(
14244
14466
  "appointmentStartTime",
14245
14467
  ">=",
14246
- import_firestore44.Timestamp.fromDate(effectiveStartDate)
14468
+ import_firestore46.Timestamp.fromDate(effectiveStartDate)
14247
14469
  )
14248
14470
  );
14249
14471
  if (options == null ? void 0 : options.endDate) {
14250
14472
  constraints.push(
14251
- (0, import_firestore44.where)(
14473
+ (0, import_firestore46.where)(
14252
14474
  "appointmentStartTime",
14253
14475
  "<=",
14254
- import_firestore44.Timestamp.fromDate(options.endDate)
14476
+ import_firestore46.Timestamp.fromDate(options.endDate)
14255
14477
  )
14256
14478
  );
14257
14479
  }
14258
- constraints.push((0, import_firestore44.orderBy)("appointmentStartTime", "asc"));
14480
+ constraints.push((0, import_firestore46.orderBy)("appointmentStartTime", "asc"));
14259
14481
  if (options == null ? void 0 : options.limit) {
14260
- constraints.push((0, import_firestore44.limit)(options.limit));
14482
+ constraints.push((0, import_firestore46.limit)(options.limit));
14261
14483
  }
14262
14484
  if (options == null ? void 0 : options.startAfter) {
14263
- constraints.push((0, import_firestore44.startAfter)(options.startAfter));
14485
+ constraints.push((0, import_firestore46.startAfter)(options.startAfter));
14264
14486
  }
14265
- const q = (0, import_firestore44.query)(
14266
- (0, import_firestore44.collection)(this.db, APPOINTMENTS_COLLECTION),
14487
+ const q = (0, import_firestore46.query)(
14488
+ (0, import_firestore46.collection)(this.db, APPOINTMENTS_COLLECTION),
14267
14489
  ...constraints
14268
14490
  );
14269
- const querySnapshot = await (0, import_firestore44.getDocs)(q);
14491
+ const querySnapshot = await (0, import_firestore46.getDocs)(q);
14270
14492
  const appointments = querySnapshot.docs.map(
14271
- (doc35) => doc35.data()
14493
+ (doc36) => doc36.data()
14272
14494
  );
14273
14495
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
14274
14496
  console.log(
@@ -14310,38 +14532,38 @@ var AppointmentService = class extends BaseService {
14310
14532
  pastStatuses.push("no_show" /* NO_SHOW */);
14311
14533
  }
14312
14534
  const constraints = [];
14313
- constraints.push((0, import_firestore44.where)("patientId", "==", patientId));
14314
- constraints.push((0, import_firestore44.where)("status", "in", pastStatuses));
14535
+ constraints.push((0, import_firestore46.where)("patientId", "==", patientId));
14536
+ constraints.push((0, import_firestore46.where)("status", "in", pastStatuses));
14315
14537
  if (options == null ? void 0 : options.startDate) {
14316
14538
  constraints.push(
14317
- (0, import_firestore44.where)(
14539
+ (0, import_firestore46.where)(
14318
14540
  "appointmentStartTime",
14319
14541
  ">=",
14320
- import_firestore44.Timestamp.fromDate(options.startDate)
14542
+ import_firestore46.Timestamp.fromDate(options.startDate)
14321
14543
  )
14322
14544
  );
14323
14545
  }
14324
14546
  constraints.push(
14325
- (0, import_firestore44.where)(
14547
+ (0, import_firestore46.where)(
14326
14548
  "appointmentStartTime",
14327
14549
  "<=",
14328
- import_firestore44.Timestamp.fromDate(effectiveEndDate)
14550
+ import_firestore46.Timestamp.fromDate(effectiveEndDate)
14329
14551
  )
14330
14552
  );
14331
- constraints.push((0, import_firestore44.orderBy)("appointmentStartTime", "desc"));
14553
+ constraints.push((0, import_firestore46.orderBy)("appointmentStartTime", "desc"));
14332
14554
  if (options == null ? void 0 : options.limit) {
14333
- constraints.push((0, import_firestore44.limit)(options.limit));
14555
+ constraints.push((0, import_firestore46.limit)(options.limit));
14334
14556
  }
14335
14557
  if (options == null ? void 0 : options.startAfter) {
14336
- constraints.push((0, import_firestore44.startAfter)(options.startAfter));
14558
+ constraints.push((0, import_firestore46.startAfter)(options.startAfter));
14337
14559
  }
14338
- const q = (0, import_firestore44.query)(
14339
- (0, import_firestore44.collection)(this.db, APPOINTMENTS_COLLECTION),
14560
+ const q = (0, import_firestore46.query)(
14561
+ (0, import_firestore46.collection)(this.db, APPOINTMENTS_COLLECTION),
14340
14562
  ...constraints
14341
14563
  );
14342
- const querySnapshot = await (0, import_firestore44.getDocs)(q);
14564
+ const querySnapshot = await (0, import_firestore46.getDocs)(q);
14343
14565
  const appointments = querySnapshot.docs.map(
14344
- (doc35) => doc35.data()
14566
+ (doc36) => doc36.data()
14345
14567
  );
14346
14568
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
14347
14569
  console.log(
@@ -14359,7 +14581,7 @@ var AppointmentService = class extends BaseService {
14359
14581
  };
14360
14582
 
14361
14583
  // src/services/patient/patientRequirements.service.ts
14362
- var import_firestore45 = require("firebase/firestore");
14584
+ var import_firestore47 = require("firebase/firestore");
14363
14585
 
14364
14586
  // src/types/patient/patient-requirements.ts
14365
14587
  var PatientInstructionStatus = /* @__PURE__ */ ((PatientInstructionStatus2) => {
@@ -14389,13 +14611,13 @@ var PatientRequirementsService = class extends BaseService {
14389
14611
  super(db, auth, app);
14390
14612
  }
14391
14613
  getPatientRequirementsCollectionRef(patientId) {
14392
- return (0, import_firestore45.collection)(
14614
+ return (0, import_firestore47.collection)(
14393
14615
  this.db,
14394
14616
  `patients/${patientId}/${PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME}`
14395
14617
  );
14396
14618
  }
14397
14619
  getPatientRequirementDocRef(patientId, instanceId) {
14398
- return (0, import_firestore45.doc)(
14620
+ return (0, import_firestore47.doc)(
14399
14621
  this.getPatientRequirementsCollectionRef(patientId),
14400
14622
  instanceId
14401
14623
  );
@@ -14408,7 +14630,7 @@ var PatientRequirementsService = class extends BaseService {
14408
14630
  */
14409
14631
  async getPatientRequirementInstance(patientId, instanceId) {
14410
14632
  const docRef = this.getPatientRequirementDocRef(patientId, instanceId);
14411
- const docSnap = await (0, import_firestore45.getDoc)(docRef);
14633
+ const docSnap = await (0, import_firestore47.getDoc)(docRef);
14412
14634
  if (!docSnap.exists()) {
14413
14635
  return null;
14414
14636
  }
@@ -14427,22 +14649,22 @@ var PatientRequirementsService = class extends BaseService {
14427
14649
  */
14428
14650
  async getAllPatientRequirementInstances(patientId, filters, pageLimit = 20, lastVisible) {
14429
14651
  const collRef = this.getPatientRequirementsCollectionRef(patientId);
14430
- let q = (0, import_firestore45.query)(collRef, (0, import_firestore45.orderBy)("createdAt", "desc"));
14652
+ let q = (0, import_firestore47.query)(collRef, (0, import_firestore47.orderBy)("createdAt", "desc"));
14431
14653
  const queryConstraints = [];
14432
14654
  if ((filters == null ? void 0 : filters.appointmentId) && filters.appointmentId !== "all") {
14433
14655
  queryConstraints.push(
14434
- (0, import_firestore45.where)("appointmentId", "==", filters.appointmentId)
14656
+ (0, import_firestore47.where)("appointmentId", "==", filters.appointmentId)
14435
14657
  );
14436
14658
  }
14437
14659
  if ((filters == null ? void 0 : filters.statuses) && filters.statuses.length > 0) {
14438
- queryConstraints.push((0, import_firestore45.where)("overallStatus", "in", filters.statuses));
14660
+ queryConstraints.push((0, import_firestore47.where)("overallStatus", "in", filters.statuses));
14439
14661
  }
14440
14662
  if (lastVisible) {
14441
- queryConstraints.push((0, import_firestore45.startAfter)(lastVisible));
14663
+ queryConstraints.push((0, import_firestore47.startAfter)(lastVisible));
14442
14664
  }
14443
- queryConstraints.push((0, import_firestore45.limit)(pageLimit));
14444
- q = (0, import_firestore45.query)(collRef, ...queryConstraints);
14445
- const snapshot = await (0, import_firestore45.getDocs)(q);
14665
+ queryConstraints.push((0, import_firestore47.limit)(pageLimit));
14666
+ q = (0, import_firestore47.query)(collRef, ...queryConstraints);
14667
+ const snapshot = await (0, import_firestore47.getDocs)(q);
14446
14668
  let requirements = snapshot.docs.map((docSnap) => {
14447
14669
  const data = docSnap.data();
14448
14670
  return { id: docSnap.id, ...data };
@@ -14485,7 +14707,7 @@ var PatientRequirementsService = class extends BaseService {
14485
14707
  */
14486
14708
  async completeInstruction(patientId, instanceId, instructionId) {
14487
14709
  const instanceRef = this.getPatientRequirementDocRef(patientId, instanceId);
14488
- const instanceSnap = await (0, import_firestore45.getDoc)(instanceRef);
14710
+ const instanceSnap = await (0, import_firestore47.getDoc)(instanceRef);
14489
14711
  if (!instanceSnap.exists()) {
14490
14712
  throw new Error(
14491
14713
  `PatientRequirementInstance ${instanceId} not found for patient ${patientId}.`
@@ -14513,7 +14735,7 @@ var PatientRequirementsService = class extends BaseService {
14513
14735
  `Instruction ${instructionId} is in status ${instructionToUpdate.status} and cannot be marked as completed.`
14514
14736
  );
14515
14737
  }
14516
- const now = import_firestore45.Timestamp.now();
14738
+ const now = import_firestore47.Timestamp.now();
14517
14739
  const updatedInstructions = [...instance.instructions];
14518
14740
  updatedInstructions[instructionIndex] = {
14519
14741
  ...instructionToUpdate,
@@ -14540,7 +14762,7 @@ var PatientRequirementsService = class extends BaseService {
14540
14762
  if (newOverallStatus !== instance.overallStatus) {
14541
14763
  updatePayload.overallStatus = newOverallStatus;
14542
14764
  }
14543
- await (0, import_firestore45.updateDoc)(instanceRef, updatePayload);
14765
+ await (0, import_firestore47.updateDoc)(instanceRef, updatePayload);
14544
14766
  return {
14545
14767
  ...instance,
14546
14768
  instructions: updatedInstructions,
@@ -14553,7 +14775,7 @@ var PatientRequirementsService = class extends BaseService {
14553
14775
  };
14554
14776
 
14555
14777
  // src/backoffice/services/brand.service.ts
14556
- var import_firestore46 = require("firebase/firestore");
14778
+ var import_firestore48 = require("firebase/firestore");
14557
14779
 
14558
14780
  // src/backoffice/types/brand.types.ts
14559
14781
  var BRANDS_COLLECTION = "brands";
@@ -14564,7 +14786,7 @@ var BrandService = class extends BaseService {
14564
14786
  * Gets reference to brands collection
14565
14787
  */
14566
14788
  getBrandsRef() {
14567
- return (0, import_firestore46.collection)(this.db, BRANDS_COLLECTION);
14789
+ return (0, import_firestore48.collection)(this.db, BRANDS_COLLECTION);
14568
14790
  }
14569
14791
  /**
14570
14792
  * Creates a new brand
@@ -14577,19 +14799,19 @@ var BrandService = class extends BaseService {
14577
14799
  updatedAt: now,
14578
14800
  isActive: true
14579
14801
  };
14580
- const docRef = await (0, import_firestore46.addDoc)(this.getBrandsRef(), newBrand);
14802
+ const docRef = await (0, import_firestore48.addDoc)(this.getBrandsRef(), newBrand);
14581
14803
  return { id: docRef.id, ...newBrand };
14582
14804
  }
14583
14805
  /**
14584
14806
  * Gets all active brands
14585
14807
  */
14586
14808
  async getAll() {
14587
- const q = (0, import_firestore46.query)(this.getBrandsRef(), (0, import_firestore46.where)("isActive", "==", true));
14588
- const snapshot = await (0, import_firestore46.getDocs)(q);
14809
+ const q = (0, import_firestore48.query)(this.getBrandsRef(), (0, import_firestore48.where)("isActive", "==", true));
14810
+ const snapshot = await (0, import_firestore48.getDocs)(q);
14589
14811
  return snapshot.docs.map(
14590
- (doc35) => ({
14591
- id: doc35.id,
14592
- ...doc35.data()
14812
+ (doc36) => ({
14813
+ id: doc36.id,
14814
+ ...doc36.data()
14593
14815
  })
14594
14816
  );
14595
14817
  }
@@ -14601,8 +14823,8 @@ var BrandService = class extends BaseService {
14601
14823
  ...brand,
14602
14824
  updatedAt: /* @__PURE__ */ new Date()
14603
14825
  };
14604
- const docRef = (0, import_firestore46.doc)(this.getBrandsRef(), brandId);
14605
- await (0, import_firestore46.updateDoc)(docRef, updateData);
14826
+ const docRef = (0, import_firestore48.doc)(this.getBrandsRef(), brandId);
14827
+ await (0, import_firestore48.updateDoc)(docRef, updateData);
14606
14828
  return this.getById(brandId);
14607
14829
  }
14608
14830
  /**
@@ -14617,8 +14839,8 @@ var BrandService = class extends BaseService {
14617
14839
  * Gets a brand by ID
14618
14840
  */
14619
14841
  async getById(brandId) {
14620
- const docRef = (0, import_firestore46.doc)(this.getBrandsRef(), brandId);
14621
- const docSnap = await (0, import_firestore46.getDoc)(docRef);
14842
+ const docRef = (0, import_firestore48.doc)(this.getBrandsRef(), brandId);
14843
+ const docSnap = await (0, import_firestore48.getDoc)(docRef);
14622
14844
  if (!docSnap.exists()) return null;
14623
14845
  return {
14624
14846
  id: docSnap.id,
@@ -14628,7 +14850,7 @@ var BrandService = class extends BaseService {
14628
14850
  };
14629
14851
 
14630
14852
  // src/backoffice/services/category.service.ts
14631
- var import_firestore47 = require("firebase/firestore");
14853
+ var import_firestore49 = require("firebase/firestore");
14632
14854
 
14633
14855
  // src/backoffice/types/category.types.ts
14634
14856
  var CATEGORIES_COLLECTION = "backoffice_categories";
@@ -14639,7 +14861,7 @@ var CategoryService = class extends BaseService {
14639
14861
  * Referenca na Firestore kolekciju kategorija
14640
14862
  */
14641
14863
  get categoriesRef() {
14642
- return (0, import_firestore47.collection)(this.db, CATEGORIES_COLLECTION);
14864
+ return (0, import_firestore49.collection)(this.db, CATEGORIES_COLLECTION);
14643
14865
  }
14644
14866
  /**
14645
14867
  * Kreira novu kategoriju u sistemu
@@ -14654,7 +14876,7 @@ var CategoryService = class extends BaseService {
14654
14876
  updatedAt: now,
14655
14877
  isActive: true
14656
14878
  };
14657
- const docRef = await (0, import_firestore47.addDoc)(this.categoriesRef, newCategory);
14879
+ const docRef = await (0, import_firestore49.addDoc)(this.categoriesRef, newCategory);
14658
14880
  return { id: docRef.id, ...newCategory };
14659
14881
  }
14660
14882
  /**
@@ -14662,12 +14884,12 @@ var CategoryService = class extends BaseService {
14662
14884
  * @returns Lista aktivnih kategorija
14663
14885
  */
14664
14886
  async getAll() {
14665
- const q = (0, import_firestore47.query)(this.categoriesRef, (0, import_firestore47.where)("isActive", "==", true));
14666
- const snapshot = await (0, import_firestore47.getDocs)(q);
14887
+ const q = (0, import_firestore49.query)(this.categoriesRef, (0, import_firestore49.where)("isActive", "==", true));
14888
+ const snapshot = await (0, import_firestore49.getDocs)(q);
14667
14889
  return snapshot.docs.map(
14668
- (doc35) => ({
14669
- id: doc35.id,
14670
- ...doc35.data()
14890
+ (doc36) => ({
14891
+ id: doc36.id,
14892
+ ...doc36.data()
14671
14893
  })
14672
14894
  );
14673
14895
  }
@@ -14677,16 +14899,16 @@ var CategoryService = class extends BaseService {
14677
14899
  * @returns Lista kategorija koje pripadaju traženoj familiji
14678
14900
  */
14679
14901
  async getAllByFamily(family) {
14680
- const q = (0, import_firestore47.query)(
14902
+ const q = (0, import_firestore49.query)(
14681
14903
  this.categoriesRef,
14682
- (0, import_firestore47.where)("family", "==", family),
14683
- (0, import_firestore47.where)("isActive", "==", true)
14904
+ (0, import_firestore49.where)("family", "==", family),
14905
+ (0, import_firestore49.where)("isActive", "==", true)
14684
14906
  );
14685
- const snapshot = await (0, import_firestore47.getDocs)(q);
14907
+ const snapshot = await (0, import_firestore49.getDocs)(q);
14686
14908
  return snapshot.docs.map(
14687
- (doc35) => ({
14688
- id: doc35.id,
14689
- ...doc35.data()
14909
+ (doc36) => ({
14910
+ id: doc36.id,
14911
+ ...doc36.data()
14690
14912
  })
14691
14913
  );
14692
14914
  }
@@ -14701,8 +14923,8 @@ var CategoryService = class extends BaseService {
14701
14923
  ...category,
14702
14924
  updatedAt: /* @__PURE__ */ new Date()
14703
14925
  };
14704
- const docRef = (0, import_firestore47.doc)(this.categoriesRef, id);
14705
- await (0, import_firestore47.updateDoc)(docRef, updateData);
14926
+ const docRef = (0, import_firestore49.doc)(this.categoriesRef, id);
14927
+ await (0, import_firestore49.updateDoc)(docRef, updateData);
14706
14928
  return this.getById(id);
14707
14929
  }
14708
14930
  /**
@@ -14718,8 +14940,8 @@ var CategoryService = class extends BaseService {
14718
14940
  * @returns Kategorija ili null ako ne postoji
14719
14941
  */
14720
14942
  async getById(id) {
14721
- const docRef = (0, import_firestore47.doc)(this.categoriesRef, id);
14722
- const docSnap = await (0, import_firestore47.getDoc)(docRef);
14943
+ const docRef = (0, import_firestore49.doc)(this.categoriesRef, id);
14944
+ const docSnap = await (0, import_firestore49.getDoc)(docRef);
14723
14945
  if (!docSnap.exists()) return null;
14724
14946
  return {
14725
14947
  id: docSnap.id,
@@ -14729,7 +14951,7 @@ var CategoryService = class extends BaseService {
14729
14951
  };
14730
14952
 
14731
14953
  // src/backoffice/services/subcategory.service.ts
14732
- var import_firestore48 = require("firebase/firestore");
14954
+ var import_firestore50 = require("firebase/firestore");
14733
14955
 
14734
14956
  // src/backoffice/types/subcategory.types.ts
14735
14957
  var SUBCATEGORIES_COLLECTION = "subcategories";
@@ -14741,7 +14963,7 @@ var SubcategoryService = class extends BaseService {
14741
14963
  * @param categoryId - ID roditeljske kategorije
14742
14964
  */
14743
14965
  getSubcategoriesRef(categoryId) {
14744
- return (0, import_firestore48.collection)(
14966
+ return (0, import_firestore50.collection)(
14745
14967
  this.db,
14746
14968
  CATEGORIES_COLLECTION,
14747
14969
  categoryId,
@@ -14763,7 +14985,7 @@ var SubcategoryService = class extends BaseService {
14763
14985
  updatedAt: now,
14764
14986
  isActive: true
14765
14987
  };
14766
- const docRef = await (0, import_firestore48.addDoc)(
14988
+ const docRef = await (0, import_firestore50.addDoc)(
14767
14989
  this.getSubcategoriesRef(categoryId),
14768
14990
  newSubcategory
14769
14991
  );
@@ -14775,15 +14997,15 @@ var SubcategoryService = class extends BaseService {
14775
14997
  * @returns Lista aktivnih podkategorija
14776
14998
  */
14777
14999
  async getAllByCategoryId(categoryId) {
14778
- const q = (0, import_firestore48.query)(
15000
+ const q = (0, import_firestore50.query)(
14779
15001
  this.getSubcategoriesRef(categoryId),
14780
- (0, import_firestore48.where)("isActive", "==", true)
15002
+ (0, import_firestore50.where)("isActive", "==", true)
14781
15003
  );
14782
- const snapshot = await (0, import_firestore48.getDocs)(q);
15004
+ const snapshot = await (0, import_firestore50.getDocs)(q);
14783
15005
  return snapshot.docs.map(
14784
- (doc35) => ({
14785
- id: doc35.id,
14786
- ...doc35.data()
15006
+ (doc36) => ({
15007
+ id: doc36.id,
15008
+ ...doc36.data()
14787
15009
  })
14788
15010
  );
14789
15011
  }
@@ -14799,8 +15021,8 @@ var SubcategoryService = class extends BaseService {
14799
15021
  ...subcategory,
14800
15022
  updatedAt: /* @__PURE__ */ new Date()
14801
15023
  };
14802
- const docRef = (0, import_firestore48.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
14803
- await (0, import_firestore48.updateDoc)(docRef, updateData);
15024
+ const docRef = (0, import_firestore50.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
15025
+ await (0, import_firestore50.updateDoc)(docRef, updateData);
14804
15026
  return this.getById(categoryId, subcategoryId);
14805
15027
  }
14806
15028
  /**
@@ -14818,8 +15040,8 @@ var SubcategoryService = class extends BaseService {
14818
15040
  * @returns Podkategorija ili null ako ne postoji
14819
15041
  */
14820
15042
  async getById(categoryId, subcategoryId) {
14821
- const docRef = (0, import_firestore48.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
14822
- const docSnap = await (0, import_firestore48.getDoc)(docRef);
15043
+ const docRef = (0, import_firestore50.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
15044
+ const docSnap = await (0, import_firestore50.getDoc)(docRef);
14823
15045
  if (!docSnap.exists()) return null;
14824
15046
  return {
14825
15047
  id: docSnap.id,
@@ -14829,7 +15051,7 @@ var SubcategoryService = class extends BaseService {
14829
15051
  };
14830
15052
 
14831
15053
  // src/backoffice/services/technology.service.ts
14832
- var import_firestore49 = require("firebase/firestore");
15054
+ var import_firestore51 = require("firebase/firestore");
14833
15055
  var DEFAULT_CERTIFICATION_REQUIREMENT = {
14834
15056
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
14835
15057
  requiredSpecialties: []
@@ -14839,7 +15061,7 @@ var TechnologyService = class extends BaseService {
14839
15061
  * Vraća referencu na Firestore kolekciju tehnologija
14840
15062
  */
14841
15063
  getTechnologiesRef() {
14842
- return (0, import_firestore49.collection)(this.db, TECHNOLOGIES_COLLECTION);
15064
+ return (0, import_firestore51.collection)(this.db, TECHNOLOGIES_COLLECTION);
14843
15065
  }
14844
15066
  /**
14845
15067
  * Kreira novu tehnologiju
@@ -14862,7 +15084,7 @@ var TechnologyService = class extends BaseService {
14862
15084
  benefits: technology.benefits || [],
14863
15085
  certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
14864
15086
  };
14865
- const docRef = await (0, import_firestore49.addDoc)(this.getTechnologiesRef(), newTechnology);
15087
+ const docRef = await (0, import_firestore51.addDoc)(this.getTechnologiesRef(), newTechnology);
14866
15088
  return { id: docRef.id, ...newTechnology };
14867
15089
  }
14868
15090
  /**
@@ -14870,12 +15092,12 @@ var TechnologyService = class extends BaseService {
14870
15092
  * @returns Lista aktivnih tehnologija
14871
15093
  */
14872
15094
  async getAll() {
14873
- const q = (0, import_firestore49.query)(this.getTechnologiesRef(), (0, import_firestore49.where)("isActive", "==", true));
14874
- const snapshot = await (0, import_firestore49.getDocs)(q);
15095
+ const q = (0, import_firestore51.query)(this.getTechnologiesRef(), (0, import_firestore51.where)("isActive", "==", true));
15096
+ const snapshot = await (0, import_firestore51.getDocs)(q);
14875
15097
  return snapshot.docs.map(
14876
- (doc35) => ({
14877
- id: doc35.id,
14878
- ...doc35.data()
15098
+ (doc36) => ({
15099
+ id: doc36.id,
15100
+ ...doc36.data()
14879
15101
  })
14880
15102
  );
14881
15103
  }
@@ -14885,16 +15107,16 @@ var TechnologyService = class extends BaseService {
14885
15107
  * @returns Lista aktivnih tehnologija
14886
15108
  */
14887
15109
  async getAllByFamily(family) {
14888
- const q = (0, import_firestore49.query)(
15110
+ const q = (0, import_firestore51.query)(
14889
15111
  this.getTechnologiesRef(),
14890
- (0, import_firestore49.where)("isActive", "==", true),
14891
- (0, import_firestore49.where)("family", "==", family)
15112
+ (0, import_firestore51.where)("isActive", "==", true),
15113
+ (0, import_firestore51.where)("family", "==", family)
14892
15114
  );
14893
- const snapshot = await (0, import_firestore49.getDocs)(q);
15115
+ const snapshot = await (0, import_firestore51.getDocs)(q);
14894
15116
  return snapshot.docs.map(
14895
- (doc35) => ({
14896
- id: doc35.id,
14897
- ...doc35.data()
15117
+ (doc36) => ({
15118
+ id: doc36.id,
15119
+ ...doc36.data()
14898
15120
  })
14899
15121
  );
14900
15122
  }
@@ -14904,16 +15126,16 @@ var TechnologyService = class extends BaseService {
14904
15126
  * @returns Lista aktivnih tehnologija
14905
15127
  */
14906
15128
  async getAllByCategoryId(categoryId) {
14907
- const q = (0, import_firestore49.query)(
15129
+ const q = (0, import_firestore51.query)(
14908
15130
  this.getTechnologiesRef(),
14909
- (0, import_firestore49.where)("isActive", "==", true),
14910
- (0, import_firestore49.where)("categoryId", "==", categoryId)
15131
+ (0, import_firestore51.where)("isActive", "==", true),
15132
+ (0, import_firestore51.where)("categoryId", "==", categoryId)
14911
15133
  );
14912
- const snapshot = await (0, import_firestore49.getDocs)(q);
15134
+ const snapshot = await (0, import_firestore51.getDocs)(q);
14913
15135
  return snapshot.docs.map(
14914
- (doc35) => ({
14915
- id: doc35.id,
14916
- ...doc35.data()
15136
+ (doc36) => ({
15137
+ id: doc36.id,
15138
+ ...doc36.data()
14917
15139
  })
14918
15140
  );
14919
15141
  }
@@ -14923,16 +15145,16 @@ var TechnologyService = class extends BaseService {
14923
15145
  * @returns Lista aktivnih tehnologija
14924
15146
  */
14925
15147
  async getAllBySubcategoryId(subcategoryId) {
14926
- const q = (0, import_firestore49.query)(
15148
+ const q = (0, import_firestore51.query)(
14927
15149
  this.getTechnologiesRef(),
14928
- (0, import_firestore49.where)("isActive", "==", true),
14929
- (0, import_firestore49.where)("subcategoryId", "==", subcategoryId)
15150
+ (0, import_firestore51.where)("isActive", "==", true),
15151
+ (0, import_firestore51.where)("subcategoryId", "==", subcategoryId)
14930
15152
  );
14931
- const snapshot = await (0, import_firestore49.getDocs)(q);
15153
+ const snapshot = await (0, import_firestore51.getDocs)(q);
14932
15154
  return snapshot.docs.map(
14933
- (doc35) => ({
14934
- id: doc35.id,
14935
- ...doc35.data()
15155
+ (doc36) => ({
15156
+ id: doc36.id,
15157
+ ...doc36.data()
14936
15158
  })
14937
15159
  );
14938
15160
  }
@@ -14947,8 +15169,8 @@ var TechnologyService = class extends BaseService {
14947
15169
  ...technology,
14948
15170
  updatedAt: /* @__PURE__ */ new Date()
14949
15171
  };
14950
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
14951
- await (0, import_firestore49.updateDoc)(docRef, updateData);
15172
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15173
+ await (0, import_firestore51.updateDoc)(docRef, updateData);
14952
15174
  return this.getById(technologyId);
14953
15175
  }
14954
15176
  /**
@@ -14966,8 +15188,8 @@ var TechnologyService = class extends BaseService {
14966
15188
  * @returns Tehnologija ili null ako ne postoji
14967
15189
  */
14968
15190
  async getById(technologyId) {
14969
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
14970
- const docSnap = await (0, import_firestore49.getDoc)(docRef);
15191
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15192
+ const docSnap = await (0, import_firestore51.getDoc)(docRef);
14971
15193
  if (!docSnap.exists()) return null;
14972
15194
  return {
14973
15195
  id: docSnap.id,
@@ -14981,10 +15203,10 @@ var TechnologyService = class extends BaseService {
14981
15203
  * @returns Ažurirana tehnologija sa novim zahtevom
14982
15204
  */
14983
15205
  async addRequirement(technologyId, requirement) {
14984
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15206
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
14985
15207
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
14986
- await (0, import_firestore49.updateDoc)(docRef, {
14987
- [requirementType]: (0, import_firestore49.arrayUnion)(requirement),
15208
+ await (0, import_firestore51.updateDoc)(docRef, {
15209
+ [requirementType]: (0, import_firestore51.arrayUnion)(requirement),
14988
15210
  updatedAt: /* @__PURE__ */ new Date()
14989
15211
  });
14990
15212
  return this.getById(technologyId);
@@ -14996,10 +15218,10 @@ var TechnologyService = class extends BaseService {
14996
15218
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
14997
15219
  */
14998
15220
  async removeRequirement(technologyId, requirement) {
14999
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15221
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15000
15222
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
15001
- await (0, import_firestore49.updateDoc)(docRef, {
15002
- [requirementType]: (0, import_firestore49.arrayRemove)(requirement),
15223
+ await (0, import_firestore51.updateDoc)(docRef, {
15224
+ [requirementType]: (0, import_firestore51.arrayRemove)(requirement),
15003
15225
  updatedAt: /* @__PURE__ */ new Date()
15004
15226
  });
15005
15227
  return this.getById(technologyId);
@@ -15036,9 +15258,9 @@ var TechnologyService = class extends BaseService {
15036
15258
  * @returns Ažurirana tehnologija
15037
15259
  */
15038
15260
  async addBlockingCondition(technologyId, condition) {
15039
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15040
- await (0, import_firestore49.updateDoc)(docRef, {
15041
- blockingConditions: (0, import_firestore49.arrayUnion)(condition),
15261
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15262
+ await (0, import_firestore51.updateDoc)(docRef, {
15263
+ blockingConditions: (0, import_firestore51.arrayUnion)(condition),
15042
15264
  updatedAt: /* @__PURE__ */ new Date()
15043
15265
  });
15044
15266
  return this.getById(technologyId);
@@ -15050,9 +15272,9 @@ var TechnologyService = class extends BaseService {
15050
15272
  * @returns Ažurirana tehnologija
15051
15273
  */
15052
15274
  async removeBlockingCondition(technologyId, condition) {
15053
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15054
- await (0, import_firestore49.updateDoc)(docRef, {
15055
- blockingConditions: (0, import_firestore49.arrayRemove)(condition),
15275
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15276
+ await (0, import_firestore51.updateDoc)(docRef, {
15277
+ blockingConditions: (0, import_firestore51.arrayRemove)(condition),
15056
15278
  updatedAt: /* @__PURE__ */ new Date()
15057
15279
  });
15058
15280
  return this.getById(technologyId);
@@ -15064,9 +15286,9 @@ var TechnologyService = class extends BaseService {
15064
15286
  * @returns Ažurirana tehnologija
15065
15287
  */
15066
15288
  async addContraindication(technologyId, contraindication) {
15067
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15068
- await (0, import_firestore49.updateDoc)(docRef, {
15069
- contraindications: (0, import_firestore49.arrayUnion)(contraindication),
15289
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15290
+ await (0, import_firestore51.updateDoc)(docRef, {
15291
+ contraindications: (0, import_firestore51.arrayUnion)(contraindication),
15070
15292
  updatedAt: /* @__PURE__ */ new Date()
15071
15293
  });
15072
15294
  return this.getById(technologyId);
@@ -15078,9 +15300,9 @@ var TechnologyService = class extends BaseService {
15078
15300
  * @returns Ažurirana tehnologija
15079
15301
  */
15080
15302
  async removeContraindication(technologyId, contraindication) {
15081
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15082
- await (0, import_firestore49.updateDoc)(docRef, {
15083
- contraindications: (0, import_firestore49.arrayRemove)(contraindication),
15303
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15304
+ await (0, import_firestore51.updateDoc)(docRef, {
15305
+ contraindications: (0, import_firestore51.arrayRemove)(contraindication),
15084
15306
  updatedAt: /* @__PURE__ */ new Date()
15085
15307
  });
15086
15308
  return this.getById(technologyId);
@@ -15092,9 +15314,9 @@ var TechnologyService = class extends BaseService {
15092
15314
  * @returns Ažurirana tehnologija
15093
15315
  */
15094
15316
  async addBenefit(technologyId, benefit) {
15095
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15096
- await (0, import_firestore49.updateDoc)(docRef, {
15097
- benefits: (0, import_firestore49.arrayUnion)(benefit),
15317
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15318
+ await (0, import_firestore51.updateDoc)(docRef, {
15319
+ benefits: (0, import_firestore51.arrayUnion)(benefit),
15098
15320
  updatedAt: /* @__PURE__ */ new Date()
15099
15321
  });
15100
15322
  return this.getById(technologyId);
@@ -15106,9 +15328,9 @@ var TechnologyService = class extends BaseService {
15106
15328
  * @returns Ažurirana tehnologija
15107
15329
  */
15108
15330
  async removeBenefit(technologyId, benefit) {
15109
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15110
- await (0, import_firestore49.updateDoc)(docRef, {
15111
- benefits: (0, import_firestore49.arrayRemove)(benefit),
15331
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15332
+ await (0, import_firestore51.updateDoc)(docRef, {
15333
+ benefits: (0, import_firestore51.arrayRemove)(benefit),
15112
15334
  updatedAt: /* @__PURE__ */ new Date()
15113
15335
  });
15114
15336
  return this.getById(technologyId);
@@ -15147,8 +15369,8 @@ var TechnologyService = class extends BaseService {
15147
15369
  * @returns Ažurirana tehnologija
15148
15370
  */
15149
15371
  async updateCertificationRequirement(technologyId, certificationRequirement) {
15150
- const docRef = (0, import_firestore49.doc)(this.getTechnologiesRef(), technologyId);
15151
- await (0, import_firestore49.updateDoc)(docRef, {
15372
+ const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
15373
+ await (0, import_firestore51.updateDoc)(docRef, {
15152
15374
  certificationRequirement,
15153
15375
  updatedAt: /* @__PURE__ */ new Date()
15154
15376
  });
@@ -15248,7 +15470,7 @@ var TechnologyService = class extends BaseService {
15248
15470
  };
15249
15471
 
15250
15472
  // src/backoffice/services/product.service.ts
15251
- var import_firestore50 = require("firebase/firestore");
15473
+ var import_firestore52 = require("firebase/firestore");
15252
15474
 
15253
15475
  // src/backoffice/types/product.types.ts
15254
15476
  var PRODUCTS_COLLECTION = "products";
@@ -15261,7 +15483,7 @@ var ProductService = class extends BaseService {
15261
15483
  * @returns Firestore collection reference
15262
15484
  */
15263
15485
  getProductsRef(technologyId) {
15264
- return (0, import_firestore50.collection)(
15486
+ return (0, import_firestore52.collection)(
15265
15487
  this.db,
15266
15488
  TECHNOLOGIES_COLLECTION,
15267
15489
  technologyId,
@@ -15281,7 +15503,7 @@ var ProductService = class extends BaseService {
15281
15503
  updatedAt: now,
15282
15504
  isActive: true
15283
15505
  };
15284
- const productRef = await (0, import_firestore50.addDoc)(
15506
+ const productRef = await (0, import_firestore52.addDoc)(
15285
15507
  this.getProductsRef(technologyId),
15286
15508
  newProduct
15287
15509
  );
@@ -15291,15 +15513,15 @@ var ProductService = class extends BaseService {
15291
15513
  * Gets all products for a technology
15292
15514
  */
15293
15515
  async getAllByTechnology(technologyId) {
15294
- const q = (0, import_firestore50.query)(
15516
+ const q = (0, import_firestore52.query)(
15295
15517
  this.getProductsRef(technologyId),
15296
- (0, import_firestore50.where)("isActive", "==", true)
15518
+ (0, import_firestore52.where)("isActive", "==", true)
15297
15519
  );
15298
- const snapshot = await (0, import_firestore50.getDocs)(q);
15520
+ const snapshot = await (0, import_firestore52.getDocs)(q);
15299
15521
  return snapshot.docs.map(
15300
- (doc35) => ({
15301
- id: doc35.id,
15302
- ...doc35.data()
15522
+ (doc36) => ({
15523
+ id: doc36.id,
15524
+ ...doc36.data()
15303
15525
  })
15304
15526
  );
15305
15527
  }
@@ -15307,21 +15529,21 @@ var ProductService = class extends BaseService {
15307
15529
  * Gets all products for a brand by filtering through all technologies
15308
15530
  */
15309
15531
  async getAllByBrand(brandId) {
15310
- const allTechnologiesRef = (0, import_firestore50.collection)(this.db, TECHNOLOGIES_COLLECTION);
15311
- const technologiesSnapshot = await (0, import_firestore50.getDocs)(allTechnologiesRef);
15532
+ const allTechnologiesRef = (0, import_firestore52.collection)(this.db, TECHNOLOGIES_COLLECTION);
15533
+ const technologiesSnapshot = await (0, import_firestore52.getDocs)(allTechnologiesRef);
15312
15534
  const products = [];
15313
15535
  for (const techDoc of technologiesSnapshot.docs) {
15314
- const q = (0, import_firestore50.query)(
15536
+ const q = (0, import_firestore52.query)(
15315
15537
  this.getProductsRef(techDoc.id),
15316
- (0, import_firestore50.where)("brandId", "==", brandId),
15317
- (0, import_firestore50.where)("isActive", "==", true)
15538
+ (0, import_firestore52.where)("brandId", "==", brandId),
15539
+ (0, import_firestore52.where)("isActive", "==", true)
15318
15540
  );
15319
- const snapshot = await (0, import_firestore50.getDocs)(q);
15541
+ const snapshot = await (0, import_firestore52.getDocs)(q);
15320
15542
  products.push(
15321
15543
  ...snapshot.docs.map(
15322
- (doc35) => ({
15323
- id: doc35.id,
15324
- ...doc35.data()
15544
+ (doc36) => ({
15545
+ id: doc36.id,
15546
+ ...doc36.data()
15325
15547
  })
15326
15548
  )
15327
15549
  );
@@ -15336,8 +15558,8 @@ var ProductService = class extends BaseService {
15336
15558
  ...product,
15337
15559
  updatedAt: /* @__PURE__ */ new Date()
15338
15560
  };
15339
- const docRef = (0, import_firestore50.doc)(this.getProductsRef(technologyId), productId);
15340
- await (0, import_firestore50.updateDoc)(docRef, updateData);
15561
+ const docRef = (0, import_firestore52.doc)(this.getProductsRef(technologyId), productId);
15562
+ await (0, import_firestore52.updateDoc)(docRef, updateData);
15341
15563
  return this.getById(technologyId, productId);
15342
15564
  }
15343
15565
  /**
@@ -15352,8 +15574,8 @@ var ProductService = class extends BaseService {
15352
15574
  * Gets a product by ID
15353
15575
  */
15354
15576
  async getById(technologyId, productId) {
15355
- const docRef = (0, import_firestore50.doc)(this.getProductsRef(technologyId), productId);
15356
- const docSnap = await (0, import_firestore50.getDoc)(docRef);
15577
+ const docRef = (0, import_firestore52.doc)(this.getProductsRef(technologyId), productId);
15578
+ const docSnap = await (0, import_firestore52.getDoc)(docRef);
15357
15579
  if (!docSnap.exists()) return null;
15358
15580
  return {
15359
15581
  id: docSnap.id,
@@ -15476,6 +15698,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
15476
15698
  CalendarEventStatus,
15477
15699
  CalendarEventType,
15478
15700
  CalendarServiceV2,
15701
+ CalendarServiceV3,
15479
15702
  CalendarSyncStatus,
15480
15703
  CategoryService,
15481
15704
  CertificationLevel,
@@ -15582,6 +15805,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
15582
15805
  contraindicationSchema,
15583
15806
  createAdminTokenSchema,
15584
15807
  createAppointmentSchema,
15808
+ createBlockingEventSchema,
15585
15809
  createCalendarEventSchema,
15586
15810
  createClinicAdminSchema,
15587
15811
  createClinicGroupSchema,
@@ -15652,6 +15876,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
15652
15876
  updateAllergySchema,
15653
15877
  updateAppointmentSchema,
15654
15878
  updateBlockingConditionSchema,
15879
+ updateBlockingEventSchema,
15655
15880
  updateCalendarEventSchema,
15656
15881
  updateClinicAdminSchema,
15657
15882
  updateClinicGroupSchema,