@blackcode_sa/metaestetics-api 1.5.44 → 1.5.46

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
@@ -371,7 +371,7 @@ var getFirebaseApp = async () => {
371
371
 
372
372
  // src/services/auth.service.ts
373
373
  var import_auth5 = require("firebase/auth");
374
- var import_firestore20 = require("firebase/firestore");
374
+ var import_firestore22 = require("firebase/firestore");
375
375
 
376
376
  // src/types/documentation-templates/index.ts
377
377
  var DOCUMENTATION_TEMPLATES_COLLECTION = "documentation-templates";
@@ -893,7 +893,7 @@ var BaseService = class {
893
893
  };
894
894
 
895
895
  // src/services/user.service.ts
896
- var import_firestore14 = require("firebase/firestore");
896
+ var import_firestore16 = require("firebase/firestore");
897
897
 
898
898
  // src/errors/user.errors.ts
899
899
  var USER_ERRORS = {
@@ -991,7 +991,7 @@ var USER_ERRORS = {
991
991
  var import_zod14 = require("zod");
992
992
 
993
993
  // src/services/patient/patient.service.ts
994
- var import_firestore9 = require("firebase/firestore");
994
+ var import_firestore11 = require("firebase/firestore");
995
995
 
996
996
  // src/services/patient/utils/profile.utils.ts
997
997
  var import_firestore6 = require("firebase/firestore");
@@ -1609,9 +1609,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
1609
1609
  var updateAllergyUtil = async (db, patientId, data, userRef) => {
1610
1610
  const validatedData = updateAllergySchema.parse(data);
1611
1611
  const { allergyIndex, ...updateData } = validatedData;
1612
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1613
- if (!doc30.exists()) throw new Error("Medical info not found");
1614
- const medicalInfo = doc30.data();
1612
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1613
+ if (!doc32.exists()) throw new Error("Medical info not found");
1614
+ const medicalInfo = doc32.data();
1615
1615
  if (allergyIndex >= medicalInfo.allergies.length) {
1616
1616
  throw new Error("Invalid allergy index");
1617
1617
  }
@@ -1627,9 +1627,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
1627
1627
  });
1628
1628
  };
1629
1629
  var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
1630
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1631
- if (!doc30.exists()) throw new Error("Medical info not found");
1632
- const medicalInfo = doc30.data();
1630
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1631
+ if (!doc32.exists()) throw new Error("Medical info not found");
1632
+ const medicalInfo = doc32.data();
1633
1633
  if (allergyIndex >= medicalInfo.allergies.length) {
1634
1634
  throw new Error("Invalid allergy index");
1635
1635
  }
@@ -1654,9 +1654,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
1654
1654
  var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1655
1655
  const validatedData = updateBlockingConditionSchema.parse(data);
1656
1656
  const { conditionIndex, ...updateData } = validatedData;
1657
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1658
- if (!doc30.exists()) throw new Error("Medical info not found");
1659
- const medicalInfo = doc30.data();
1657
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1658
+ if (!doc32.exists()) throw new Error("Medical info not found");
1659
+ const medicalInfo = doc32.data();
1660
1660
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1661
1661
  throw new Error("Invalid blocking condition index");
1662
1662
  }
@@ -1672,9 +1672,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1672
1672
  });
1673
1673
  };
1674
1674
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
1675
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1676
- if (!doc30.exists()) throw new Error("Medical info not found");
1677
- const medicalInfo = doc30.data();
1675
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1676
+ if (!doc32.exists()) throw new Error("Medical info not found");
1677
+ const medicalInfo = doc32.data();
1678
1678
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1679
1679
  throw new Error("Invalid blocking condition index");
1680
1680
  }
@@ -1699,9 +1699,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
1699
1699
  var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1700
1700
  const validatedData = updateContraindicationSchema.parse(data);
1701
1701
  const { contraindicationIndex, ...updateData } = validatedData;
1702
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1703
- if (!doc30.exists()) throw new Error("Medical info not found");
1704
- const medicalInfo = doc30.data();
1702
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1703
+ if (!doc32.exists()) throw new Error("Medical info not found");
1704
+ const medicalInfo = doc32.data();
1705
1705
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1706
1706
  throw new Error("Invalid contraindication index");
1707
1707
  }
@@ -1717,9 +1717,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1717
1717
  });
1718
1718
  };
1719
1719
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
1720
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1721
- if (!doc30.exists()) throw new Error("Medical info not found");
1722
- const medicalInfo = doc30.data();
1720
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1721
+ if (!doc32.exists()) throw new Error("Medical info not found");
1722
+ const medicalInfo = doc32.data();
1723
1723
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1724
1724
  throw new Error("Invalid contraindication index");
1725
1725
  }
@@ -1744,9 +1744,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
1744
1744
  var updateMedicationUtil = async (db, patientId, data, userRef) => {
1745
1745
  const validatedData = updateMedicationSchema.parse(data);
1746
1746
  const { medicationIndex, ...updateData } = validatedData;
1747
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1748
- if (!doc30.exists()) throw new Error("Medical info not found");
1749
- const medicalInfo = doc30.data();
1747
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1748
+ if (!doc32.exists()) throw new Error("Medical info not found");
1749
+ const medicalInfo = doc32.data();
1750
1750
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1751
1751
  throw new Error("Invalid medication index");
1752
1752
  }
@@ -1762,9 +1762,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
1762
1762
  });
1763
1763
  };
1764
1764
  var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
1765
- const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1766
- if (!doc30.exists()) throw new Error("Medical info not found");
1767
- const medicalInfo = doc30.data();
1765
+ const doc32 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1766
+ if (!doc32.exists()) throw new Error("Medical info not found");
1767
+ const medicalInfo = doc32.data();
1768
1768
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1769
1769
  throw new Error("Invalid medication index");
1770
1770
  }
@@ -2042,7 +2042,7 @@ var searchPatientsUtil = async (db, params, requester) => {
2042
2042
  try {
2043
2043
  const finalQuery = (0, import_firestore6.query)(patientsCollectionRef, ...constraints);
2044
2044
  const querySnapshot = await (0, import_firestore6.getDocs)(finalQuery);
2045
- const patients = querySnapshot.docs.map((doc30) => doc30.data());
2045
+ const patients = querySnapshot.docs.map((doc32) => doc32.data());
2046
2046
  console.log(`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`);
2047
2047
  return patients;
2048
2048
  } catch (error) {
@@ -2066,8 +2066,8 @@ var getAllPatientsUtil = async (db, options) => {
2066
2066
  }
2067
2067
  const patientsSnapshot = await (0, import_firestore6.getDocs)(q);
2068
2068
  const patients = [];
2069
- patientsSnapshot.forEach((doc30) => {
2070
- patients.push(doc30.data());
2069
+ patientsSnapshot.forEach((doc32) => {
2070
+ patients.push(doc32.data());
2071
2071
  });
2072
2072
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
2073
2073
  return patients;
@@ -2253,6 +2253,94 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
2253
2253
  });
2254
2254
  };
2255
2255
 
2256
+ // src/services/patient/utils/practitioner.utils.ts
2257
+ var import_firestore9 = require("firebase/firestore");
2258
+ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
2259
+ try {
2260
+ console.log(
2261
+ `[getPatientsByPractitionerUtil] Fetching patients for practitioner ID: ${practitionerId} with options:`,
2262
+ options
2263
+ );
2264
+ const patientsCollection = (0, import_firestore9.collection)(db, PATIENTS_COLLECTION);
2265
+ const constraints = [
2266
+ (0, import_firestore9.where)("doctorIds", "array-contains", practitionerId)
2267
+ ];
2268
+ let q = (0, import_firestore9.query)(patientsCollection, ...constraints);
2269
+ if (options == null ? void 0 : options.limit) {
2270
+ q = (0, import_firestore9.query)(q, (0, import_firestore9.limit)(options.limit));
2271
+ }
2272
+ if (options == null ? void 0 : options.startAfter) {
2273
+ const startAfterDoc = await (0, import_firestore9.getDoc)(
2274
+ (0, import_firestore9.doc)(db, PATIENTS_COLLECTION, options.startAfter)
2275
+ );
2276
+ if (startAfterDoc.exists()) {
2277
+ q = (0, import_firestore9.query)(q, (0, import_firestore9.startAfter)(startAfterDoc));
2278
+ }
2279
+ }
2280
+ const patientsSnapshot = await (0, import_firestore9.getDocs)(q);
2281
+ const patients = [];
2282
+ patientsSnapshot.forEach((doc32) => {
2283
+ patients.push(doc32.data());
2284
+ });
2285
+ console.log(
2286
+ `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
2287
+ );
2288
+ return patients;
2289
+ } catch (error) {
2290
+ console.error(
2291
+ `[getPatientsByPractitionerUtil] Error fetching patients for practitioner:`,
2292
+ error
2293
+ );
2294
+ throw new Error(
2295
+ `Failed to retrieve patients for practitioner: ${error instanceof Error ? error.message : String(error)}`
2296
+ );
2297
+ }
2298
+ };
2299
+
2300
+ // src/services/patient/utils/clinic.utils.ts
2301
+ var import_firestore10 = require("firebase/firestore");
2302
+ var getPatientsByClinicUtil = async (db, clinicId, options) => {
2303
+ try {
2304
+ console.log(
2305
+ `[getPatientsByClinicUtil] Fetching patients for clinic ID: ${clinicId} with options:`,
2306
+ options
2307
+ );
2308
+ const patientsCollection = (0, import_firestore10.collection)(db, PATIENTS_COLLECTION);
2309
+ const constraints = [
2310
+ (0, import_firestore10.where)("clinicIds", "array-contains", clinicId)
2311
+ ];
2312
+ let q = (0, import_firestore10.query)(patientsCollection, ...constraints);
2313
+ if (options == null ? void 0 : options.limit) {
2314
+ q = (0, import_firestore10.query)(q, (0, import_firestore10.limit)(options.limit));
2315
+ }
2316
+ if (options == null ? void 0 : options.startAfter) {
2317
+ const startAfterDoc = await (0, import_firestore10.getDoc)(
2318
+ (0, import_firestore10.doc)(db, PATIENTS_COLLECTION, options.startAfter)
2319
+ );
2320
+ if (startAfterDoc.exists()) {
2321
+ q = (0, import_firestore10.query)(q, (0, import_firestore10.startAfter)(startAfterDoc));
2322
+ }
2323
+ }
2324
+ const patientsSnapshot = await (0, import_firestore10.getDocs)(q);
2325
+ const patients = [];
2326
+ patientsSnapshot.forEach((doc32) => {
2327
+ patients.push(doc32.data());
2328
+ });
2329
+ console.log(
2330
+ `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
2331
+ );
2332
+ return patients;
2333
+ } catch (error) {
2334
+ console.error(
2335
+ `[getPatientsByClinicUtil] Error fetching patients for clinic:`,
2336
+ error
2337
+ );
2338
+ throw new Error(
2339
+ `Failed to retrieve patients for clinic: ${error instanceof Error ? error.message : String(error)}`
2340
+ );
2341
+ }
2342
+ };
2343
+
2256
2344
  // src/services/patient/patient.service.ts
2257
2345
  var PatientService = class extends BaseService {
2258
2346
  constructor(db, auth, app) {
@@ -2309,11 +2397,22 @@ var PatientService = class extends BaseService {
2309
2397
  // Metode za rad sa medicinskim informacijama
2310
2398
  async createMedicalInfo(patientId, data) {
2311
2399
  const currentUser = await this.getCurrentUser();
2312
- await createMedicalInfoUtil(this.db, patientId, data, currentUser.uid, currentUser.roles);
2400
+ await createMedicalInfoUtil(
2401
+ this.db,
2402
+ patientId,
2403
+ data,
2404
+ currentUser.uid,
2405
+ currentUser.roles
2406
+ );
2313
2407
  }
2314
2408
  async getMedicalInfo(patientId) {
2315
2409
  const currentUser = await this.getCurrentUser();
2316
- return getMedicalInfoUtil(this.db, patientId, currentUser.uid, currentUser.roles);
2410
+ return getMedicalInfoUtil(
2411
+ this.db,
2412
+ patientId,
2413
+ currentUser.uid,
2414
+ currentUser.roles
2415
+ );
2317
2416
  }
2318
2417
  async getMedicalInfoByUserRef(userRef) {
2319
2418
  const profile = await this.getPatientProfileByUserRef(userRef);
@@ -2345,11 +2444,21 @@ var PatientService = class extends BaseService {
2345
2444
  }
2346
2445
  async updateBlockingCondition(patientId, data) {
2347
2446
  const currentUser = await this.getCurrentUser();
2348
- await updateBlockingConditionUtil(this.db, patientId, data, currentUser.uid);
2447
+ await updateBlockingConditionUtil(
2448
+ this.db,
2449
+ patientId,
2450
+ data,
2451
+ currentUser.uid
2452
+ );
2349
2453
  }
2350
2454
  async removeBlockingCondition(patientId, conditionIndex) {
2351
2455
  const currentUser = await this.getCurrentUser();
2352
- await removeBlockingConditionUtil(this.db, patientId, conditionIndex, currentUser.uid);
2456
+ await removeBlockingConditionUtil(
2457
+ this.db,
2458
+ patientId,
2459
+ conditionIndex,
2460
+ currentUser.uid
2461
+ );
2353
2462
  }
2354
2463
  // Metode za rad sa kontraindikacijama
2355
2464
  async addContraindication(patientId, data) {
@@ -2362,7 +2471,12 @@ var PatientService = class extends BaseService {
2362
2471
  }
2363
2472
  async removeContraindication(patientId, contraindicationIndex) {
2364
2473
  const currentUser = await this.getCurrentUser();
2365
- await removeContraindicationUtil(this.db, patientId, contraindicationIndex, currentUser.uid);
2474
+ await removeContraindicationUtil(
2475
+ this.db,
2476
+ patientId,
2477
+ contraindicationIndex,
2478
+ currentUser.uid
2479
+ );
2366
2480
  }
2367
2481
  // Metode za rad sa medikacijama
2368
2482
  async addMedication(patientId, data) {
@@ -2375,7 +2489,12 @@ var PatientService = class extends BaseService {
2375
2489
  }
2376
2490
  async removeMedication(patientId, medicationIndex) {
2377
2491
  const currentUser = await this.getCurrentUser();
2378
- await removeMedicationUtil(this.db, patientId, medicationIndex, currentUser.uid);
2492
+ await removeMedicationUtil(
2493
+ this.db,
2494
+ patientId,
2495
+ medicationIndex,
2496
+ currentUser.uid
2497
+ );
2379
2498
  }
2380
2499
  // Pomoćne metode
2381
2500
  async addExpoToken(patientId, token) {
@@ -2406,7 +2525,9 @@ var PatientService = class extends BaseService {
2406
2525
  if (!this.auth.currentUser) {
2407
2526
  throw new Error("No authenticated user");
2408
2527
  }
2409
- const userDoc = await (0, import_firestore9.getDoc)((0, import_firestore9.doc)(this.db, "users", this.auth.currentUser.uid));
2528
+ const userDoc = await (0, import_firestore11.getDoc)(
2529
+ (0, import_firestore11.doc)(this.db, "users", this.auth.currentUser.uid)
2530
+ );
2410
2531
  if (!userDoc.exists()) {
2411
2532
  throw new Error("User not found");
2412
2533
  }
@@ -2416,7 +2537,7 @@ var PatientService = class extends BaseService {
2416
2537
  * Briše profil pacijenta i sve povezane subkolekcije
2417
2538
  */
2418
2539
  async deletePatientProfile(patientId) {
2419
- const batch = (0, import_firestore9.writeBatch)(this.db);
2540
+ const batch = (0, import_firestore11.writeBatch)(this.db);
2420
2541
  batch.delete(getSensitiveInfoDocRef(this.db, patientId));
2421
2542
  batch.delete(getLocationInfoDocRef(this.db, patientId));
2422
2543
  batch.delete(getMedicalInfoDocRef(this.db, patientId));
@@ -2482,13 +2603,46 @@ var PatientService = class extends BaseService {
2482
2603
  * @returns {Promise<PatientProfile[]>} A promise resolving to an array of all patient profiles.
2483
2604
  */
2484
2605
  async getAllPatients(options) {
2485
- console.log(`[PatientService.getAllPatients] Fetching patients with options:`, options);
2606
+ console.log(
2607
+ `[PatientService.getAllPatients] Fetching patients with options:`,
2608
+ options
2609
+ );
2486
2610
  return getAllPatientsUtil(this.db, options);
2487
2611
  }
2612
+ /**
2613
+ * Gets all patients associated with a specific practitioner.
2614
+ *
2615
+ * @param {string} practitionerId - ID of the practitioner whose patients to retrieve
2616
+ * @param {Object} options - Optional parameters for pagination
2617
+ * @param {number} options.limit - Maximum number of profiles to return
2618
+ * @param {string} options.startAfter - The ID of the document to start after (for pagination)
2619
+ * @returns {Promise<PatientProfile[]>} A promise resolving to an array of patient profiles
2620
+ */
2621
+ async getPatientsByPractitioner(practitionerId, options) {
2622
+ console.log(
2623
+ `[PatientService.getPatientsByPractitioner] Fetching patients for practitioner: ${practitionerId}`
2624
+ );
2625
+ return getPatientsByPractitionerUtil(this.db, practitionerId, options);
2626
+ }
2627
+ /**
2628
+ * Gets all patients associated with a specific clinic.
2629
+ *
2630
+ * @param {string} clinicId - ID of the clinic whose patients to retrieve
2631
+ * @param {Object} options - Optional parameters for pagination
2632
+ * @param {number} options.limit - Maximum number of profiles to return
2633
+ * @param {string} options.startAfter - The ID of the document to start after (for pagination)
2634
+ * @returns {Promise<PatientProfile[]>} A promise resolving to an array of patient profiles
2635
+ */
2636
+ async getPatientsByClinic(clinicId, options) {
2637
+ console.log(
2638
+ `[PatientService.getPatientsByClinic] Fetching patients for clinic: ${clinicId}`
2639
+ );
2640
+ return getPatientsByClinicUtil(this.db, clinicId, options);
2641
+ }
2488
2642
  };
2489
2643
 
2490
2644
  // src/services/clinic/utils/admin.utils.ts
2491
- var import_firestore12 = require("firebase/firestore");
2645
+ var import_firestore14 = require("firebase/firestore");
2492
2646
 
2493
2647
  // src/types/clinic/preferences.types.ts
2494
2648
  var PracticeType = /* @__PURE__ */ ((PracticeType2) => {
@@ -2615,11 +2769,11 @@ var SubscriptionModel = /* @__PURE__ */ ((SubscriptionModel2) => {
2615
2769
 
2616
2770
  // src/validations/clinic.schema.ts
2617
2771
  var import_zod12 = require("zod");
2618
- var import_firestore11 = require("firebase/firestore");
2772
+ var import_firestore13 = require("firebase/firestore");
2619
2773
 
2620
2774
  // src/validations/practitioner.schema.ts
2621
2775
  var import_zod11 = require("zod");
2622
- var import_firestore10 = require("firebase/firestore");
2776
+ var import_firestore12 = require("firebase/firestore");
2623
2777
 
2624
2778
  // src/backoffice/types/static/certification.types.ts
2625
2779
  var CertificationLevel = /* @__PURE__ */ ((CertificationLevel2) => {
@@ -2827,7 +2981,7 @@ var practitionerBasicInfoSchema = import_zod11.z.object({
2827
2981
  title: import_zod11.z.string().min(2).max(100),
2828
2982
  email: import_zod11.z.string().email(),
2829
2983
  phoneNumber: import_zod11.z.string().regex(/^\+?[1-9]\d{1,14}$/, "Invalid phone number"),
2830
- dateOfBirth: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
2984
+ dateOfBirth: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
2831
2985
  gender: import_zod11.z.enum(["male", "female", "other"]),
2832
2986
  profileImageUrl: import_zod11.z.string().url().optional(),
2833
2987
  bio: import_zod11.z.string().max(1e3).optional(),
@@ -2838,8 +2992,8 @@ var practitionerCertificationSchema = import_zod11.z.object({
2838
2992
  specialties: import_zod11.z.array(import_zod11.z.nativeEnum(CertificationSpecialty)),
2839
2993
  licenseNumber: import_zod11.z.string().min(3).max(50),
2840
2994
  issuingAuthority: import_zod11.z.string().min(2).max(100),
2841
- issueDate: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
2842
- expiryDate: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()).optional(),
2995
+ issueDate: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
2996
+ expiryDate: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()).optional(),
2843
2997
  verificationStatus: import_zod11.z.enum(["pending", "verified", "rejected"])
2844
2998
  });
2845
2999
  var timeSlotSchema = import_zod11.z.object({
@@ -2856,8 +3010,8 @@ var practitionerWorkingHoursSchema = import_zod11.z.object({
2856
3010
  friday: timeSlotSchema,
2857
3011
  saturday: timeSlotSchema,
2858
3012
  sunday: timeSlotSchema,
2859
- createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
2860
- updatedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date())
3013
+ createdAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
3014
+ updatedAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date())
2861
3015
  });
2862
3016
  var practitionerClinicWorkingHoursSchema = import_zod11.z.object({
2863
3017
  clinicId: import_zod11.z.string().min(1),
@@ -2871,8 +3025,8 @@ var practitionerClinicWorkingHoursSchema = import_zod11.z.object({
2871
3025
  sunday: timeSlotSchema
2872
3026
  }),
2873
3027
  isActive: import_zod11.z.boolean(),
2874
- createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
2875
- updatedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date())
3028
+ createdAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
3029
+ updatedAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date())
2876
3030
  });
2877
3031
  var procedureSummaryInfoSchema = import_zod11.z.object({
2878
3032
  id: import_zod11.z.string().min(1),
@@ -2906,8 +3060,8 @@ var practitionerSchema = import_zod11.z.object({
2906
3060
  isActive: import_zod11.z.boolean(),
2907
3061
  isVerified: import_zod11.z.boolean(),
2908
3062
  status: import_zod11.z.nativeEnum(PractitionerStatus),
2909
- createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
2910
- updatedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date())
3063
+ createdAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
3064
+ updatedAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date())
2911
3065
  });
2912
3066
  var createPractitionerSchema = import_zod11.z.object({
2913
3067
  userRef: import_zod11.z.string().min(1),
@@ -2939,10 +3093,10 @@ var practitionerTokenSchema = import_zod11.z.object({
2939
3093
  clinicId: import_zod11.z.string().min(1),
2940
3094
  status: import_zod11.z.nativeEnum(PractitionerTokenStatus),
2941
3095
  createdBy: import_zod11.z.string().min(1),
2942
- createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
2943
- expiresAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
3096
+ createdAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
3097
+ expiresAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()),
2944
3098
  usedBy: import_zod11.z.string().optional(),
2945
- usedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()).optional()
3099
+ usedAt: import_zod11.z.instanceof(import_firestore12.Timestamp).or(import_zod11.z.date()).optional()
2946
3100
  });
2947
3101
  var createPractitionerTokenSchema = import_zod11.z.object({
2948
3102
  practitionerId: import_zod11.z.string().min(1),
@@ -3027,8 +3181,8 @@ var clinicAdminSchema = import_zod12.z.object({
3027
3181
  clinicsManagedInfo: import_zod12.z.array(clinicInfoSchema),
3028
3182
  contactInfo: contactPersonSchema,
3029
3183
  roleTitle: import_zod12.z.string(),
3030
- createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3031
- updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3184
+ createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3185
+ updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3032
3186
  isActive: import_zod12.z.boolean()
3033
3187
  });
3034
3188
  var adminTokenSchema = import_zod12.z.object({
@@ -3037,9 +3191,9 @@ var adminTokenSchema = import_zod12.z.object({
3037
3191
  email: import_zod12.z.string().email().optional().nullable(),
3038
3192
  status: import_zod12.z.nativeEnum(AdminTokenStatus),
3039
3193
  usedByUserRef: import_zod12.z.string().optional(),
3040
- createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3194
+ createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3041
3195
  // Timestamp
3042
- expiresAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp))
3196
+ expiresAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp))
3043
3197
  // Timestamp
3044
3198
  });
3045
3199
  var createAdminTokenSchema = import_zod12.z.object({
@@ -3059,9 +3213,9 @@ var clinicGroupSchema = import_zod12.z.object({
3059
3213
  adminsInfo: import_zod12.z.array(adminInfoSchema),
3060
3214
  adminTokens: import_zod12.z.array(adminTokenSchema),
3061
3215
  ownerId: import_zod12.z.string().nullable(),
3062
- createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3216
+ createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3063
3217
  // Timestamp
3064
- updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3218
+ updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3065
3219
  // Timestamp
3066
3220
  isActive: import_zod12.z.boolean(),
3067
3221
  logo: import_zod12.z.string().optional().nullable(),
@@ -3101,9 +3255,9 @@ var clinicSchema = import_zod12.z.object({
3101
3255
  // servicesInfo: z.array(serviceInfoSchema), // Deprecated, use proceduresInfo
3102
3256
  reviewInfo: clinicReviewInfoSchema,
3103
3257
  admins: import_zod12.z.array(import_zod12.z.string()),
3104
- createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3258
+ createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3105
3259
  // Timestamp
3106
- updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
3260
+ updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore13.Timestamp)),
3107
3261
  // Timestamp
3108
3262
  isActive: import_zod12.z.boolean(),
3109
3263
  isVerified: import_zod12.z.boolean(),
@@ -3293,7 +3447,7 @@ async function createClinicAdmin(db, data, clinicGroupService) {
3293
3447
  }
3294
3448
  console.log("[CLINIC_ADMIN] Preparing admin data object");
3295
3449
  const adminData = {
3296
- id: (0, import_firestore12.doc)((0, import_firestore12.collection)(db, CLINIC_ADMINS_COLLECTION)).id,
3450
+ id: (0, import_firestore14.doc)((0, import_firestore14.collection)(db, CLINIC_ADMINS_COLLECTION)).id,
3297
3451
  // Generate a new ID for the admin document
3298
3452
  userRef: validatedData.userRef,
3299
3453
  clinicGroupId: clinicGroupId || "",
@@ -3306,15 +3460,15 @@ async function createClinicAdmin(db, data, clinicGroupService) {
3306
3460
  contactInfo: validatedData.contactInfo,
3307
3461
  roleTitle: validatedData.roleTitle,
3308
3462
  isActive: validatedData.isActive,
3309
- createdAt: (0, import_firestore12.serverTimestamp)(),
3310
- updatedAt: (0, import_firestore12.serverTimestamp)()
3463
+ createdAt: (0, import_firestore14.serverTimestamp)(),
3464
+ updatedAt: (0, import_firestore14.serverTimestamp)()
3311
3465
  };
3312
3466
  console.log("[CLINIC_ADMIN] Validating complete admin object");
3313
3467
  try {
3314
3468
  clinicAdminSchema.parse({
3315
3469
  ...adminData,
3316
- createdAt: import_firestore12.Timestamp.now(),
3317
- updatedAt: import_firestore12.Timestamp.now()
3470
+ createdAt: import_firestore14.Timestamp.now(),
3471
+ updatedAt: import_firestore14.Timestamp.now()
3318
3472
  });
3319
3473
  console.log("[CLINIC_ADMIN] Admin object validation passed");
3320
3474
  } catch (schemaError) {
@@ -3328,7 +3482,7 @@ async function createClinicAdmin(db, data, clinicGroupService) {
3328
3482
  adminId: adminData.id
3329
3483
  });
3330
3484
  try {
3331
- await (0, import_firestore12.setDoc)((0, import_firestore12.doc)(db, CLINIC_ADMINS_COLLECTION, adminData.id), adminData);
3485
+ await (0, import_firestore14.setDoc)((0, import_firestore14.doc)(db, CLINIC_ADMINS_COLLECTION, adminData.id), adminData);
3332
3486
  console.log("[CLINIC_ADMIN] Admin saved successfully");
3333
3487
  } catch (firestoreError) {
3334
3488
  console.error(
@@ -3377,31 +3531,31 @@ async function checkClinicGroupExists(db, groupId, clinicGroupService) {
3377
3531
  return !!group;
3378
3532
  }
3379
3533
  async function getClinicAdmin(db, adminId) {
3380
- const docRef = (0, import_firestore12.doc)(db, CLINIC_ADMINS_COLLECTION, adminId);
3381
- const docSnap = await (0, import_firestore12.getDoc)(docRef);
3534
+ const docRef = (0, import_firestore14.doc)(db, CLINIC_ADMINS_COLLECTION, adminId);
3535
+ const docSnap = await (0, import_firestore14.getDoc)(docRef);
3382
3536
  if (docSnap.exists()) {
3383
3537
  return docSnap.data();
3384
3538
  }
3385
3539
  return null;
3386
3540
  }
3387
3541
  async function getClinicAdminByUserRef(db, userRef) {
3388
- const q = (0, import_firestore12.query)(
3389
- (0, import_firestore12.collection)(db, CLINIC_ADMINS_COLLECTION),
3390
- (0, import_firestore12.where)("userRef", "==", userRef)
3542
+ const q = (0, import_firestore14.query)(
3543
+ (0, import_firestore14.collection)(db, CLINIC_ADMINS_COLLECTION),
3544
+ (0, import_firestore14.where)("userRef", "==", userRef)
3391
3545
  );
3392
- const querySnapshot = await (0, import_firestore12.getDocs)(q);
3546
+ const querySnapshot = await (0, import_firestore14.getDocs)(q);
3393
3547
  if (querySnapshot.empty) {
3394
3548
  return null;
3395
3549
  }
3396
3550
  return querySnapshot.docs[0].data();
3397
3551
  }
3398
3552
  async function getClinicAdminsByGroup(db, clinicGroupId) {
3399
- const q = (0, import_firestore12.query)(
3400
- (0, import_firestore12.collection)(db, CLINIC_ADMINS_COLLECTION),
3401
- (0, import_firestore12.where)("clinicGroupId", "==", clinicGroupId)
3553
+ const q = (0, import_firestore14.query)(
3554
+ (0, import_firestore14.collection)(db, CLINIC_ADMINS_COLLECTION),
3555
+ (0, import_firestore14.where)("clinicGroupId", "==", clinicGroupId)
3402
3556
  );
3403
- const querySnapshot = await (0, import_firestore12.getDocs)(q);
3404
- return querySnapshot.docs.map((doc30) => doc30.data());
3557
+ const querySnapshot = await (0, import_firestore14.getDocs)(q);
3558
+ return querySnapshot.docs.map((doc32) => doc32.data());
3405
3559
  }
3406
3560
  async function updateClinicAdmin(db, adminId, data) {
3407
3561
  const admin = await getClinicAdmin(db, adminId);
@@ -3410,9 +3564,9 @@ async function updateClinicAdmin(db, adminId, data) {
3410
3564
  }
3411
3565
  const updatedData = {
3412
3566
  ...data,
3413
- updatedAt: (0, import_firestore12.serverTimestamp)()
3567
+ updatedAt: (0, import_firestore14.serverTimestamp)()
3414
3568
  };
3415
- await (0, import_firestore12.updateDoc)((0, import_firestore12.doc)(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
3569
+ await (0, import_firestore14.updateDoc)((0, import_firestore14.doc)(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
3416
3570
  const updatedAdmin = await getClinicAdmin(db, adminId);
3417
3571
  if (!updatedAdmin) {
3418
3572
  throw new Error("Failed to retrieve updated admin");
@@ -3424,7 +3578,7 @@ async function deleteClinicAdmin(db, adminId) {
3424
3578
  if (!admin) {
3425
3579
  throw new Error("Clinic admin not found");
3426
3580
  }
3427
- await (0, import_firestore12.deleteDoc)((0, import_firestore12.doc)(db, CLINIC_ADMINS_COLLECTION, adminId));
3581
+ await (0, import_firestore14.deleteDoc)((0, import_firestore14.doc)(db, CLINIC_ADMINS_COLLECTION, adminId));
3428
3582
  }
3429
3583
  async function addClinicToManaged(db, adminId, clinicId, requesterId, clinicService) {
3430
3584
  const admin = await getClinicAdmin(db, adminId);
@@ -3665,7 +3819,7 @@ var ClinicAdminService = class extends BaseService {
3665
3819
  };
3666
3820
 
3667
3821
  // src/services/practitioner/practitioner.service.ts
3668
- var import_firestore13 = require("firebase/firestore");
3822
+ var import_firestore15 = require("firebase/firestore");
3669
3823
  var import_zod13 = require("zod");
3670
3824
  var import_geofire_common2 = require("geofire-common");
3671
3825
  var PractitionerService = class extends BaseService {
@@ -3713,20 +3867,20 @@ var PractitionerService = class extends BaseService {
3713
3867
  isActive: validData.isActive !== void 0 ? validData.isActive : true,
3714
3868
  isVerified: validData.isVerified !== void 0 ? validData.isVerified : false,
3715
3869
  status: validData.status || "active" /* ACTIVE */,
3716
- createdAt: (0, import_firestore13.serverTimestamp)(),
3717
- updatedAt: (0, import_firestore13.serverTimestamp)()
3870
+ createdAt: (0, import_firestore15.serverTimestamp)(),
3871
+ updatedAt: (0, import_firestore15.serverTimestamp)()
3718
3872
  };
3719
3873
  practitionerSchema.parse({
3720
3874
  ...practitioner,
3721
- createdAt: import_firestore13.Timestamp.now(),
3722
- updatedAt: import_firestore13.Timestamp.now()
3875
+ createdAt: import_firestore15.Timestamp.now(),
3876
+ updatedAt: import_firestore15.Timestamp.now()
3723
3877
  });
3724
- const practitionerRef = (0, import_firestore13.doc)(
3878
+ const practitionerRef = (0, import_firestore15.doc)(
3725
3879
  this.db,
3726
3880
  PRACTITIONERS_COLLECTION,
3727
3881
  practitionerId
3728
3882
  );
3729
- await (0, import_firestore13.setDoc)(practitionerRef, practitioner);
3883
+ await (0, import_firestore15.setDoc)(practitionerRef, practitioner);
3730
3884
  const createdPractitioner = await this.getPractitioner(practitionerId);
3731
3885
  if (!createdPractitioner) {
3732
3886
  throw new Error(
@@ -3796,17 +3950,17 @@ var PractitionerService = class extends BaseService {
3796
3950
  isActive: validatedData.isActive !== void 0 ? validatedData.isActive : false,
3797
3951
  isVerified: validatedData.isVerified !== void 0 ? validatedData.isVerified : false,
3798
3952
  status: "draft" /* DRAFT */,
3799
- createdAt: (0, import_firestore13.serverTimestamp)(),
3800
- updatedAt: (0, import_firestore13.serverTimestamp)()
3953
+ createdAt: (0, import_firestore15.serverTimestamp)(),
3954
+ updatedAt: (0, import_firestore15.serverTimestamp)()
3801
3955
  };
3802
3956
  practitionerSchema.parse({
3803
3957
  ...practitionerData,
3804
3958
  userRef: "temp-for-validation",
3805
- createdAt: import_firestore13.Timestamp.now(),
3806
- updatedAt: import_firestore13.Timestamp.now()
3959
+ createdAt: import_firestore15.Timestamp.now(),
3960
+ updatedAt: import_firestore15.Timestamp.now()
3807
3961
  });
3808
- await (0, import_firestore13.setDoc)(
3809
- (0, import_firestore13.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
3962
+ await (0, import_firestore15.setDoc)(
3963
+ (0, import_firestore15.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
3810
3964
  practitionerData
3811
3965
  );
3812
3966
  const savedPractitioner = await this.getPractitioner(practitionerData.id);
@@ -3823,12 +3977,12 @@ var PractitionerService = class extends BaseService {
3823
3977
  clinicId,
3824
3978
  status: "active" /* ACTIVE */,
3825
3979
  createdBy,
3826
- createdAt: import_firestore13.Timestamp.now(),
3827
- expiresAt: import_firestore13.Timestamp.fromDate(expiration)
3980
+ createdAt: import_firestore15.Timestamp.now(),
3981
+ expiresAt: import_firestore15.Timestamp.fromDate(expiration)
3828
3982
  };
3829
3983
  practitionerTokenSchema.parse(token);
3830
3984
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
3831
- await (0, import_firestore13.setDoc)((0, import_firestore13.doc)(this.db, tokenPath), token);
3985
+ await (0, import_firestore15.setDoc)((0, import_firestore15.doc)(this.db, tokenPath), token);
3832
3986
  return { practitioner: savedPractitioner, token };
3833
3987
  } catch (error) {
3834
3988
  if (error instanceof import_zod13.z.ZodError) {
@@ -3876,12 +4030,12 @@ var PractitionerService = class extends BaseService {
3876
4030
  clinicId: validatedData.clinicId,
3877
4031
  status: "active" /* ACTIVE */,
3878
4032
  createdBy,
3879
- createdAt: import_firestore13.Timestamp.now(),
3880
- expiresAt: import_firestore13.Timestamp.fromDate(expiration)
4033
+ createdAt: import_firestore15.Timestamp.now(),
4034
+ expiresAt: import_firestore15.Timestamp.fromDate(expiration)
3881
4035
  };
3882
4036
  practitionerTokenSchema.parse(token);
3883
4037
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${validatedData.practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
3884
- await (0, import_firestore13.setDoc)((0, import_firestore13.doc)(this.db, tokenPath), token);
4038
+ await (0, import_firestore15.setDoc)((0, import_firestore15.doc)(this.db, tokenPath), token);
3885
4039
  return token;
3886
4040
  } catch (error) {
3887
4041
  if (error instanceof import_zod13.z.ZodError) {
@@ -3896,17 +4050,17 @@ var PractitionerService = class extends BaseService {
3896
4050
  * @returns Array of active tokens
3897
4051
  */
3898
4052
  async getPractitionerActiveTokens(practitionerId) {
3899
- const tokensRef = (0, import_firestore13.collection)(
4053
+ const tokensRef = (0, import_firestore15.collection)(
3900
4054
  this.db,
3901
4055
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}`
3902
4056
  );
3903
- const q = (0, import_firestore13.query)(
4057
+ const q = (0, import_firestore15.query)(
3904
4058
  tokensRef,
3905
- (0, import_firestore13.where)("status", "==", "active" /* ACTIVE */),
3906
- (0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
4059
+ (0, import_firestore15.where)("status", "==", "active" /* ACTIVE */),
4060
+ (0, import_firestore15.where)("expiresAt", ">", import_firestore15.Timestamp.now())
3907
4061
  );
3908
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
3909
- return querySnapshot.docs.map((doc30) => doc30.data());
4062
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
4063
+ return querySnapshot.docs.map((doc32) => doc32.data());
3910
4064
  }
3911
4065
  /**
3912
4066
  * Gets a token by its string value and validates it
@@ -3914,21 +4068,21 @@ var PractitionerService = class extends BaseService {
3914
4068
  * @returns The token if found and valid, null otherwise
3915
4069
  */
3916
4070
  async validateToken(tokenString) {
3917
- const practitionersRef = (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION);
3918
- const practitionersSnapshot = await (0, import_firestore13.getDocs)(practitionersRef);
4071
+ const practitionersRef = (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION);
4072
+ const practitionersSnapshot = await (0, import_firestore15.getDocs)(practitionersRef);
3919
4073
  for (const practitionerDoc of practitionersSnapshot.docs) {
3920
4074
  const practitionerId = practitionerDoc.id;
3921
- const tokensRef = (0, import_firestore13.collection)(
4075
+ const tokensRef = (0, import_firestore15.collection)(
3922
4076
  this.db,
3923
4077
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}`
3924
4078
  );
3925
- const q = (0, import_firestore13.query)(
4079
+ const q = (0, import_firestore15.query)(
3926
4080
  tokensRef,
3927
- (0, import_firestore13.where)("token", "==", tokenString),
3928
- (0, import_firestore13.where)("status", "==", "active" /* ACTIVE */),
3929
- (0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
4081
+ (0, import_firestore15.where)("token", "==", tokenString),
4082
+ (0, import_firestore15.where)("status", "==", "active" /* ACTIVE */),
4083
+ (0, import_firestore15.where)("expiresAt", ">", import_firestore15.Timestamp.now())
3930
4084
  );
3931
- const tokenSnapshot = await (0, import_firestore13.getDocs)(q);
4085
+ const tokenSnapshot = await (0, import_firestore15.getDocs)(q);
3932
4086
  if (!tokenSnapshot.empty) {
3933
4087
  return tokenSnapshot.docs[0].data();
3934
4088
  }
@@ -3942,22 +4096,22 @@ var PractitionerService = class extends BaseService {
3942
4096
  * @param userId ID of the user using the token
3943
4097
  */
3944
4098
  async markTokenAsUsed(tokenId, practitionerId, userId) {
3945
- const tokenRef = (0, import_firestore13.doc)(
4099
+ const tokenRef = (0, import_firestore15.doc)(
3946
4100
  this.db,
3947
4101
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
3948
4102
  );
3949
- await (0, import_firestore13.updateDoc)(tokenRef, {
4103
+ await (0, import_firestore15.updateDoc)(tokenRef, {
3950
4104
  status: "used" /* USED */,
3951
4105
  usedBy: userId,
3952
- usedAt: import_firestore13.Timestamp.now()
4106
+ usedAt: import_firestore15.Timestamp.now()
3953
4107
  });
3954
4108
  }
3955
4109
  /**
3956
4110
  * Dohvata zdravstvenog radnika po ID-u
3957
4111
  */
3958
4112
  async getPractitioner(practitionerId) {
3959
- const practitionerDoc = await (0, import_firestore13.getDoc)(
3960
- (0, import_firestore13.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId)
4113
+ const practitionerDoc = await (0, import_firestore15.getDoc)(
4114
+ (0, import_firestore15.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId)
3961
4115
  );
3962
4116
  if (!practitionerDoc.exists()) {
3963
4117
  return null;
@@ -3968,11 +4122,11 @@ var PractitionerService = class extends BaseService {
3968
4122
  * Dohvata zdravstvenog radnika po User ID-u
3969
4123
  */
3970
4124
  async getPractitionerByUserRef(userRef) {
3971
- const q = (0, import_firestore13.query)(
3972
- (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION),
3973
- (0, import_firestore13.where)("userRef", "==", userRef)
4125
+ const q = (0, import_firestore15.query)(
4126
+ (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION),
4127
+ (0, import_firestore15.where)("userRef", "==", userRef)
3974
4128
  );
3975
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
4129
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
3976
4130
  if (querySnapshot.empty) {
3977
4131
  return null;
3978
4132
  }
@@ -3982,38 +4136,38 @@ var PractitionerService = class extends BaseService {
3982
4136
  * Dohvata sve zdravstvene radnike za određenu kliniku sa statusom ACTIVE
3983
4137
  */
3984
4138
  async getPractitionersByClinic(clinicId) {
3985
- const q = (0, import_firestore13.query)(
3986
- (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION),
3987
- (0, import_firestore13.where)("clinics", "array-contains", clinicId),
3988
- (0, import_firestore13.where)("isActive", "==", true),
3989
- (0, import_firestore13.where)("status", "==", "active" /* ACTIVE */)
4139
+ const q = (0, import_firestore15.query)(
4140
+ (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION),
4141
+ (0, import_firestore15.where)("clinics", "array-contains", clinicId),
4142
+ (0, import_firestore15.where)("isActive", "==", true),
4143
+ (0, import_firestore15.where)("status", "==", "active" /* ACTIVE */)
3990
4144
  );
3991
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
3992
- return querySnapshot.docs.map((doc30) => doc30.data());
4145
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
4146
+ return querySnapshot.docs.map((doc32) => doc32.data());
3993
4147
  }
3994
4148
  /**
3995
4149
  * Dohvata sve zdravstvene radnike za određenu kliniku
3996
4150
  */
3997
4151
  async getAllPractitionersByClinic(clinicId) {
3998
- const q = (0, import_firestore13.query)(
3999
- (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION),
4000
- (0, import_firestore13.where)("clinics", "array-contains", clinicId),
4001
- (0, import_firestore13.where)("isActive", "==", true)
4152
+ const q = (0, import_firestore15.query)(
4153
+ (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION),
4154
+ (0, import_firestore15.where)("clinics", "array-contains", clinicId),
4155
+ (0, import_firestore15.where)("isActive", "==", true)
4002
4156
  );
4003
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
4004
- return querySnapshot.docs.map((doc30) => doc30.data());
4157
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
4158
+ return querySnapshot.docs.map((doc32) => doc32.data());
4005
4159
  }
4006
4160
  /**
4007
4161
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
4008
4162
  */
4009
4163
  async getDraftPractitionersByClinic(clinicId) {
4010
- const q = (0, import_firestore13.query)(
4011
- (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION),
4012
- (0, import_firestore13.where)("clinics", "array-contains", clinicId),
4013
- (0, import_firestore13.where)("status", "==", "draft" /* DRAFT */)
4164
+ const q = (0, import_firestore15.query)(
4165
+ (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION),
4166
+ (0, import_firestore15.where)("clinics", "array-contains", clinicId),
4167
+ (0, import_firestore15.where)("status", "==", "draft" /* DRAFT */)
4014
4168
  );
4015
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
4016
- return querySnapshot.docs.map((doc30) => doc30.data());
4169
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
4170
+ return querySnapshot.docs.map((doc32) => doc32.data());
4017
4171
  }
4018
4172
  /**
4019
4173
  * Updates a practitioner
@@ -4021,21 +4175,21 @@ var PractitionerService = class extends BaseService {
4021
4175
  async updatePractitioner(practitionerId, data) {
4022
4176
  try {
4023
4177
  const validData = data;
4024
- const practitionerRef = (0, import_firestore13.doc)(
4178
+ const practitionerRef = (0, import_firestore15.doc)(
4025
4179
  this.db,
4026
4180
  PRACTITIONERS_COLLECTION,
4027
4181
  practitionerId
4028
4182
  );
4029
- const practitionerDoc = await (0, import_firestore13.getDoc)(practitionerRef);
4183
+ const practitionerDoc = await (0, import_firestore15.getDoc)(practitionerRef);
4030
4184
  if (!practitionerDoc.exists()) {
4031
4185
  throw new Error(`Practitioner ${practitionerId} not found`);
4032
4186
  }
4033
4187
  const currentPractitioner = practitionerDoc.data();
4034
4188
  const updateData = {
4035
4189
  ...validData,
4036
- updatedAt: (0, import_firestore13.serverTimestamp)()
4190
+ updatedAt: (0, import_firestore15.serverTimestamp)()
4037
4191
  };
4038
- await (0, import_firestore13.updateDoc)(practitionerRef, updateData);
4192
+ await (0, import_firestore15.updateDoc)(practitionerRef, updateData);
4039
4193
  const updatedPractitioner = await this.getPractitioner(practitionerId);
4040
4194
  if (!updatedPractitioner) {
4041
4195
  throw new Error(
@@ -4057,12 +4211,12 @@ var PractitionerService = class extends BaseService {
4057
4211
  async addClinic(practitionerId, clinicId) {
4058
4212
  var _a;
4059
4213
  try {
4060
- const practitionerRef = (0, import_firestore13.doc)(
4214
+ const practitionerRef = (0, import_firestore15.doc)(
4061
4215
  this.db,
4062
4216
  PRACTITIONERS_COLLECTION,
4063
4217
  practitionerId
4064
4218
  );
4065
- const practitionerDoc = await (0, import_firestore13.getDoc)(practitionerRef);
4219
+ const practitionerDoc = await (0, import_firestore15.getDoc)(practitionerRef);
4066
4220
  if (!practitionerDoc.exists()) {
4067
4221
  throw new Error(`Practitioner ${practitionerId} not found`);
4068
4222
  }
@@ -4073,9 +4227,9 @@ var PractitionerService = class extends BaseService {
4073
4227
  );
4074
4228
  return;
4075
4229
  }
4076
- await (0, import_firestore13.updateDoc)(practitionerRef, {
4077
- clinics: (0, import_firestore13.arrayUnion)(clinicId),
4078
- updatedAt: (0, import_firestore13.serverTimestamp)()
4230
+ await (0, import_firestore15.updateDoc)(practitionerRef, {
4231
+ clinics: (0, import_firestore15.arrayUnion)(clinicId),
4232
+ updatedAt: (0, import_firestore15.serverTimestamp)()
4079
4233
  });
4080
4234
  } catch (error) {
4081
4235
  console.error(
@@ -4090,18 +4244,18 @@ var PractitionerService = class extends BaseService {
4090
4244
  */
4091
4245
  async removeClinic(practitionerId, clinicId) {
4092
4246
  try {
4093
- const practitionerRef = (0, import_firestore13.doc)(
4247
+ const practitionerRef = (0, import_firestore15.doc)(
4094
4248
  this.db,
4095
4249
  PRACTITIONERS_COLLECTION,
4096
4250
  practitionerId
4097
4251
  );
4098
- const practitionerDoc = await (0, import_firestore13.getDoc)(practitionerRef);
4252
+ const practitionerDoc = await (0, import_firestore15.getDoc)(practitionerRef);
4099
4253
  if (!practitionerDoc.exists()) {
4100
4254
  throw new Error(`Practitioner ${practitionerId} not found`);
4101
4255
  }
4102
- await (0, import_firestore13.updateDoc)(practitionerRef, {
4103
- clinics: (0, import_firestore13.arrayRemove)(clinicId),
4104
- updatedAt: (0, import_firestore13.serverTimestamp)()
4256
+ await (0, import_firestore15.updateDoc)(practitionerRef, {
4257
+ clinics: (0, import_firestore15.arrayRemove)(clinicId),
4258
+ updatedAt: (0, import_firestore15.serverTimestamp)()
4105
4259
  });
4106
4260
  } catch (error) {
4107
4261
  console.error(
@@ -4135,7 +4289,7 @@ var PractitionerService = class extends BaseService {
4135
4289
  if (!practitioner) {
4136
4290
  throw new Error("Practitioner not found");
4137
4291
  }
4138
- await (0, import_firestore13.deleteDoc)((0, import_firestore13.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId));
4292
+ await (0, import_firestore15.deleteDoc)((0, import_firestore15.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId));
4139
4293
  }
4140
4294
  /**
4141
4295
  * Validates a registration token and claims the associated draft practitioner profile
@@ -4179,23 +4333,23 @@ var PractitionerService = class extends BaseService {
4179
4333
  try {
4180
4334
  const constraints = [];
4181
4335
  if (!(options == null ? void 0 : options.includeDraftPractitioners)) {
4182
- constraints.push((0, import_firestore13.where)("status", "==", "active" /* ACTIVE */));
4336
+ constraints.push((0, import_firestore15.where)("status", "==", "active" /* ACTIVE */));
4183
4337
  }
4184
- constraints.push((0, import_firestore13.orderBy)("basicInfo.lastName", "asc"));
4185
- constraints.push((0, import_firestore13.orderBy)("basicInfo.firstName", "asc"));
4338
+ constraints.push((0, import_firestore15.orderBy)("basicInfo.lastName", "asc"));
4339
+ constraints.push((0, import_firestore15.orderBy)("basicInfo.firstName", "asc"));
4186
4340
  if ((options == null ? void 0 : options.pagination) && options.pagination > 0) {
4187
4341
  if (options.lastDoc) {
4188
- constraints.push((0, import_firestore13.startAfter)(options.lastDoc));
4342
+ constraints.push((0, import_firestore15.startAfter)(options.lastDoc));
4189
4343
  }
4190
- constraints.push((0, import_firestore13.limit)(options.pagination));
4344
+ constraints.push((0, import_firestore15.limit)(options.pagination));
4191
4345
  }
4192
- const q = (0, import_firestore13.query)(
4193
- (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION),
4346
+ const q = (0, import_firestore15.query)(
4347
+ (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION),
4194
4348
  ...constraints
4195
4349
  );
4196
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
4350
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
4197
4351
  const practitioners = querySnapshot.docs.map(
4198
- (doc30) => doc30.data()
4352
+ (doc32) => doc32.data()
4199
4353
  );
4200
4354
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
4201
4355
  return {
@@ -4238,36 +4392,36 @@ var PractitionerService = class extends BaseService {
4238
4392
  );
4239
4393
  const constraints = [];
4240
4394
  if (!filters.includeDraftPractitioners) {
4241
- constraints.push((0, import_firestore13.where)("status", "==", "active" /* ACTIVE */));
4395
+ constraints.push((0, import_firestore15.where)("status", "==", "active" /* ACTIVE */));
4242
4396
  }
4243
- constraints.push((0, import_firestore13.where)("isActive", "==", true));
4397
+ constraints.push((0, import_firestore15.where)("isActive", "==", true));
4244
4398
  if (filters.certifications && filters.certifications.length > 0) {
4245
4399
  constraints.push(
4246
- (0, import_firestore13.where)(
4400
+ (0, import_firestore15.where)(
4247
4401
  "certification.certifications",
4248
4402
  "array-contains-any",
4249
4403
  filters.certifications
4250
4404
  )
4251
4405
  );
4252
4406
  }
4253
- constraints.push((0, import_firestore13.orderBy)("basicInfo.lastName", "asc"));
4254
- constraints.push((0, import_firestore13.orderBy)("basicInfo.firstName", "asc"));
4407
+ constraints.push((0, import_firestore15.orderBy)("basicInfo.lastName", "asc"));
4408
+ constraints.push((0, import_firestore15.orderBy)("basicInfo.firstName", "asc"));
4255
4409
  if (filters.pagination && filters.pagination > 0) {
4256
4410
  if (filters.lastDoc) {
4257
- constraints.push((0, import_firestore13.startAfter)(filters.lastDoc));
4411
+ constraints.push((0, import_firestore15.startAfter)(filters.lastDoc));
4258
4412
  }
4259
- constraints.push((0, import_firestore13.limit)(filters.pagination));
4413
+ constraints.push((0, import_firestore15.limit)(filters.pagination));
4260
4414
  }
4261
- const q = (0, import_firestore13.query)(
4262
- (0, import_firestore13.collection)(this.db, PRACTITIONERS_COLLECTION),
4415
+ const q = (0, import_firestore15.query)(
4416
+ (0, import_firestore15.collection)(this.db, PRACTITIONERS_COLLECTION),
4263
4417
  ...constraints
4264
4418
  );
4265
- const querySnapshot = await (0, import_firestore13.getDocs)(q);
4419
+ const querySnapshot = await (0, import_firestore15.getDocs)(q);
4266
4420
  console.log(
4267
4421
  `[PRACTITIONER_SERVICE] Found ${querySnapshot.docs.length} practitioners with base query`
4268
4422
  );
4269
- let practitioners = querySnapshot.docs.map((doc30) => {
4270
- return { ...doc30.data(), id: doc30.id };
4423
+ let practitioners = querySnapshot.docs.map((doc32) => {
4424
+ return { ...doc32.data(), id: doc32.id };
4271
4425
  });
4272
4426
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
4273
4427
  if (filters.nameSearch && filters.nameSearch.trim() !== "") {
@@ -4384,17 +4538,17 @@ var UserService = class extends BaseService {
4384
4538
  email: firebaseUser.email,
4385
4539
  roles: roles.length > 0 ? roles : ["patient" /* PATIENT */],
4386
4540
  isAnonymous: firebaseUser.isAnonymous,
4387
- createdAt: (0, import_firestore14.serverTimestamp)(),
4388
- updatedAt: (0, import_firestore14.serverTimestamp)(),
4389
- lastLoginAt: (0, import_firestore14.serverTimestamp)()
4541
+ createdAt: (0, import_firestore16.serverTimestamp)(),
4542
+ updatedAt: (0, import_firestore16.serverTimestamp)(),
4543
+ lastLoginAt: (0, import_firestore16.serverTimestamp)()
4390
4544
  };
4391
- await (0, import_firestore14.setDoc)((0, import_firestore14.doc)(this.db, USERS_COLLECTION, userData.uid), userData);
4545
+ await (0, import_firestore16.setDoc)((0, import_firestore16.doc)(this.db, USERS_COLLECTION, userData.uid), userData);
4392
4546
  const profiles = await this.createProfilesForRoles(
4393
4547
  userData.uid,
4394
4548
  roles,
4395
4549
  options
4396
4550
  );
4397
- await (0, import_firestore14.updateDoc)((0, import_firestore14.doc)(this.db, USERS_COLLECTION, userData.uid), profiles);
4551
+ await (0, import_firestore16.updateDoc)((0, import_firestore16.doc)(this.db, USERS_COLLECTION, userData.uid), profiles);
4398
4552
  return this.getUserById(userData.uid);
4399
4553
  }
4400
4554
  /**
@@ -4472,7 +4626,7 @@ var UserService = class extends BaseService {
4472
4626
  email: "",
4473
4627
  phoneNumber: "",
4474
4628
  title: "",
4475
- dateOfBirth: import_firestore14.Timestamp.now(),
4629
+ dateOfBirth: import_firestore16.Timestamp.now(),
4476
4630
  gender: "other",
4477
4631
  languages: ["Serbian"]
4478
4632
  },
@@ -4481,7 +4635,7 @@ var UserService = class extends BaseService {
4481
4635
  specialties: [],
4482
4636
  licenseNumber: "",
4483
4637
  issuingAuthority: "",
4484
- issueDate: import_firestore14.Timestamp.now(),
4638
+ issueDate: import_firestore16.Timestamp.now(),
4485
4639
  verificationStatus: "pending"
4486
4640
  },
4487
4641
  isActive: true,
@@ -4497,7 +4651,7 @@ var UserService = class extends BaseService {
4497
4651
  * Dohvata korisnika po ID-u
4498
4652
  */
4499
4653
  async getUserById(uid) {
4500
- const userDoc = await (0, import_firestore14.getDoc)((0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid));
4654
+ const userDoc = await (0, import_firestore16.getDoc)((0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid));
4501
4655
  if (!userDoc.exists()) {
4502
4656
  throw USER_ERRORS.NOT_FOUND;
4503
4657
  }
@@ -4508,53 +4662,53 @@ var UserService = class extends BaseService {
4508
4662
  * Dohvata korisnika po email-u
4509
4663
  */
4510
4664
  async getUserByEmail(email) {
4511
- const usersRef = (0, import_firestore14.collection)(this.db, USERS_COLLECTION);
4512
- const q = (0, import_firestore14.query)(usersRef, (0, import_firestore14.where)("email", "==", email));
4513
- const querySnapshot = await (0, import_firestore14.getDocs)(q);
4665
+ const usersRef = (0, import_firestore16.collection)(this.db, USERS_COLLECTION);
4666
+ const q = (0, import_firestore16.query)(usersRef, (0, import_firestore16.where)("email", "==", email));
4667
+ const querySnapshot = await (0, import_firestore16.getDocs)(q);
4514
4668
  if (querySnapshot.empty) return null;
4515
4669
  const userData = querySnapshot.docs[0].data();
4516
4670
  return userSchema.parse(userData);
4517
4671
  }
4518
4672
  async getUsersByRole(role) {
4519
4673
  const constraints = [
4520
- (0, import_firestore14.where)("roles", "array-contains", role)
4674
+ (0, import_firestore16.where)("roles", "array-contains", role)
4521
4675
  ];
4522
- const q = (0, import_firestore14.query)((0, import_firestore14.collection)(this.db, USERS_COLLECTION), ...constraints);
4523
- const querySnapshot = await (0, import_firestore14.getDocs)(q);
4524
- const users = querySnapshot.docs.map((doc30) => doc30.data());
4676
+ const q = (0, import_firestore16.query)((0, import_firestore16.collection)(this.db, USERS_COLLECTION), ...constraints);
4677
+ const querySnapshot = await (0, import_firestore16.getDocs)(q);
4678
+ const users = querySnapshot.docs.map((doc32) => doc32.data());
4525
4679
  return Promise.all(users.map((userData) => userSchema.parse(userData)));
4526
4680
  }
4527
4681
  /**
4528
4682
  * Ažurira timestamp poslednjeg logovanja
4529
4683
  */
4530
4684
  async updateUserLoginTimestamp(uid) {
4531
- const userRef = (0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid);
4532
- const userDoc = await (0, import_firestore14.getDoc)(userRef);
4685
+ const userRef = (0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid);
4686
+ const userDoc = await (0, import_firestore16.getDoc)(userRef);
4533
4687
  if (!userDoc.exists()) {
4534
4688
  throw AUTH_ERRORS.USER_NOT_FOUND;
4535
4689
  }
4536
- await (0, import_firestore14.updateDoc)(userRef, {
4537
- lastLoginAt: (0, import_firestore14.serverTimestamp)(),
4538
- updatedAt: (0, import_firestore14.serverTimestamp)()
4690
+ await (0, import_firestore16.updateDoc)(userRef, {
4691
+ lastLoginAt: (0, import_firestore16.serverTimestamp)(),
4692
+ updatedAt: (0, import_firestore16.serverTimestamp)()
4539
4693
  });
4540
4694
  return this.getUserById(uid);
4541
4695
  }
4542
4696
  async upgradeAnonymousUser(uid, email) {
4543
- const userRef = (0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid);
4544
- const userDoc = await (0, import_firestore14.getDoc)(userRef);
4697
+ const userRef = (0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid);
4698
+ const userDoc = await (0, import_firestore16.getDoc)(userRef);
4545
4699
  if (!userDoc.exists()) {
4546
4700
  throw USER_ERRORS.NOT_FOUND;
4547
4701
  }
4548
- await (0, import_firestore14.updateDoc)(userRef, {
4702
+ await (0, import_firestore16.updateDoc)(userRef, {
4549
4703
  email,
4550
4704
  isAnonymous: false,
4551
- updatedAt: (0, import_firestore14.serverTimestamp)()
4705
+ updatedAt: (0, import_firestore16.serverTimestamp)()
4552
4706
  });
4553
4707
  return this.getUserById(uid);
4554
4708
  }
4555
4709
  async updateUser(uid, updates) {
4556
- const userRef = (0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid);
4557
- const userDoc = await (0, import_firestore14.getDoc)(userRef);
4710
+ const userRef = (0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid);
4711
+ const userDoc = await (0, import_firestore16.getDoc)(userRef);
4558
4712
  if (!userDoc.exists()) {
4559
4713
  throw USER_ERRORS.NOT_FOUND;
4560
4714
  }
@@ -4563,12 +4717,12 @@ var UserService = class extends BaseService {
4563
4717
  const updatedUser = {
4564
4718
  ...currentUser,
4565
4719
  ...updates,
4566
- updatedAt: (0, import_firestore14.serverTimestamp)()
4720
+ updatedAt: (0, import_firestore16.serverTimestamp)()
4567
4721
  };
4568
4722
  userSchema.parse(updatedUser);
4569
- await (0, import_firestore14.updateDoc)(userRef, {
4723
+ await (0, import_firestore16.updateDoc)(userRef, {
4570
4724
  ...updates,
4571
- updatedAt: (0, import_firestore14.serverTimestamp)()
4725
+ updatedAt: (0, import_firestore16.serverTimestamp)()
4572
4726
  });
4573
4727
  return this.getUserById(uid);
4574
4728
  } catch (error) {
@@ -4585,10 +4739,10 @@ var UserService = class extends BaseService {
4585
4739
  const user = await this.getUserById(uid);
4586
4740
  if (user.roles.includes(role)) return;
4587
4741
  const profiles = await this.createProfilesForRoles(uid, [role], options);
4588
- await (0, import_firestore14.updateDoc)((0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid), {
4742
+ await (0, import_firestore16.updateDoc)((0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid), {
4589
4743
  roles: [...user.roles, role],
4590
4744
  ...profiles,
4591
- updatedAt: (0, import_firestore14.serverTimestamp)()
4745
+ updatedAt: (0, import_firestore16.serverTimestamp)()
4592
4746
  });
4593
4747
  }
4594
4748
  /**
@@ -4620,15 +4774,15 @@ var UserService = class extends BaseService {
4620
4774
  }
4621
4775
  break;
4622
4776
  }
4623
- await (0, import_firestore14.updateDoc)((0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid), {
4777
+ await (0, import_firestore16.updateDoc)((0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid), {
4624
4778
  roles: user.roles.filter((r) => r !== role),
4625
- updatedAt: (0, import_firestore14.serverTimestamp)()
4779
+ updatedAt: (0, import_firestore16.serverTimestamp)()
4626
4780
  });
4627
4781
  }
4628
4782
  // Delete operations
4629
4783
  async deleteUser(uid) {
4630
- const userRef = (0, import_firestore14.doc)(this.db, USERS_COLLECTION, uid);
4631
- const userDoc = await (0, import_firestore14.getDoc)(userRef);
4784
+ const userRef = (0, import_firestore16.doc)(this.db, USERS_COLLECTION, uid);
4785
+ const userDoc = await (0, import_firestore16.getDoc)(userRef);
4632
4786
  if (!userDoc.exists()) {
4633
4787
  throw USER_ERRORS.NOT_FOUND;
4634
4788
  }
@@ -4649,7 +4803,7 @@ var UserService = class extends BaseService {
4649
4803
  userData.adminProfile
4650
4804
  );
4651
4805
  }
4652
- await (0, import_firestore14.deleteDoc)(userRef);
4806
+ await (0, import_firestore16.deleteDoc)(userRef);
4653
4807
  } catch (error) {
4654
4808
  throw error;
4655
4809
  }
@@ -4657,7 +4811,7 @@ var UserService = class extends BaseService {
4657
4811
  };
4658
4812
 
4659
4813
  // src/services/clinic/utils/clinic-group.utils.ts
4660
- var import_firestore15 = require("firebase/firestore");
4814
+ var import_firestore17 = require("firebase/firestore");
4661
4815
  var import_geofire_common3 = require("geofire-common");
4662
4816
  var import_zod15 = require("zod");
4663
4817
 
@@ -4774,9 +4928,9 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
4774
4928
  throw geohashError;
4775
4929
  }
4776
4930
  }
4777
- const now = import_firestore15.Timestamp.now();
4931
+ const now = import_firestore17.Timestamp.now();
4778
4932
  console.log("[CLINIC_GROUP] Preparing clinic group data object");
4779
- const groupId = (0, import_firestore15.doc)((0, import_firestore15.collection)(db, CLINIC_GROUPS_COLLECTION)).id;
4933
+ const groupId = (0, import_firestore17.doc)((0, import_firestore17.collection)(db, CLINIC_GROUPS_COLLECTION)).id;
4780
4934
  console.log("[CLINIC_GROUP] Logo value:", {
4781
4935
  logoValue: validatedData.logo,
4782
4936
  logoType: validatedData.logo === null ? "null" : typeof validatedData.logo
@@ -4826,7 +4980,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
4826
4980
  groupId: groupData.id
4827
4981
  });
4828
4982
  try {
4829
- await (0, import_firestore15.setDoc)((0, import_firestore15.doc)(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
4983
+ await (0, import_firestore17.setDoc)((0, import_firestore17.doc)(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
4830
4984
  console.log("[CLINIC_GROUP] Clinic group saved successfully");
4831
4985
  } catch (firestoreError) {
4832
4986
  console.error(
@@ -4872,20 +5026,20 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
4872
5026
  }
4873
5027
  }
4874
5028
  async function getClinicGroup(db, groupId) {
4875
- const docRef = (0, import_firestore15.doc)(db, CLINIC_GROUPS_COLLECTION, groupId);
4876
- const docSnap = await (0, import_firestore15.getDoc)(docRef);
5029
+ const docRef = (0, import_firestore17.doc)(db, CLINIC_GROUPS_COLLECTION, groupId);
5030
+ const docSnap = await (0, import_firestore17.getDoc)(docRef);
4877
5031
  if (docSnap.exists()) {
4878
5032
  return docSnap.data();
4879
5033
  }
4880
5034
  return null;
4881
5035
  }
4882
5036
  async function getAllActiveGroups(db) {
4883
- const q = (0, import_firestore15.query)(
4884
- (0, import_firestore15.collection)(db, CLINIC_GROUPS_COLLECTION),
4885
- (0, import_firestore15.where)("isActive", "==", true)
5037
+ const q = (0, import_firestore17.query)(
5038
+ (0, import_firestore17.collection)(db, CLINIC_GROUPS_COLLECTION),
5039
+ (0, import_firestore17.where)("isActive", "==", true)
4886
5040
  );
4887
- const querySnapshot = await (0, import_firestore15.getDocs)(q);
4888
- return querySnapshot.docs.map((doc30) => doc30.data());
5041
+ const querySnapshot = await (0, import_firestore17.getDocs)(q);
5042
+ return querySnapshot.docs.map((doc32) => doc32.data());
4889
5043
  }
4890
5044
  async function updateClinicGroup(db, groupId, data, app) {
4891
5045
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -4913,10 +5067,10 @@ async function updateClinicGroup(db, groupId, data, app) {
4913
5067
  }
4914
5068
  updatedData = {
4915
5069
  ...updatedData,
4916
- updatedAt: import_firestore15.Timestamp.now()
5070
+ updatedAt: import_firestore17.Timestamp.now()
4917
5071
  };
4918
5072
  console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
4919
- await (0, import_firestore15.updateDoc)((0, import_firestore15.doc)(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
5073
+ await (0, import_firestore17.updateDoc)((0, import_firestore17.doc)(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
4920
5074
  console.log("[CLINIC_GROUP] Clinic group updated successfully");
4921
5075
  const updatedGroup = await getClinicGroup(db, groupId);
4922
5076
  if (!updatedGroup) {
@@ -4997,10 +5151,10 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
4997
5151
  if (!group.admins.includes(creatorAdminId)) {
4998
5152
  throw new Error("Admin does not belong to this clinic group");
4999
5153
  }
5000
- const now = import_firestore15.Timestamp.now();
5154
+ const now = import_firestore17.Timestamp.now();
5001
5155
  const expiresInDays = (data == null ? void 0 : data.expiresInDays) || 7;
5002
5156
  const email = (data == null ? void 0 : data.email) || null;
5003
- const expiresAt = new import_firestore15.Timestamp(
5157
+ const expiresAt = new import_firestore17.Timestamp(
5004
5158
  now.seconds + expiresInDays * 24 * 60 * 60,
5005
5159
  now.nanoseconds
5006
5160
  );
@@ -5034,7 +5188,7 @@ async function verifyAndUseAdminToken(db, groupId, token, userRef, app) {
5034
5188
  if (adminToken.status !== "active" /* ACTIVE */) {
5035
5189
  throw new Error("Admin token is not active");
5036
5190
  }
5037
- const now = import_firestore15.Timestamp.now();
5191
+ const now = import_firestore17.Timestamp.now();
5038
5192
  if (adminToken.expiresAt.seconds < now.seconds) {
5039
5193
  const updatedTokens2 = group.adminTokens.map(
5040
5194
  (t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
@@ -5260,30 +5414,30 @@ var ClinicGroupService = class extends BaseService {
5260
5414
  };
5261
5415
 
5262
5416
  // src/services/clinic/clinic.service.ts
5263
- var import_firestore19 = require("firebase/firestore");
5417
+ var import_firestore21 = require("firebase/firestore");
5264
5418
  var import_geofire_common7 = require("geofire-common");
5265
5419
  var import_zod17 = require("zod");
5266
5420
 
5267
5421
  // src/services/clinic/utils/clinic.utils.ts
5268
- var import_firestore16 = require("firebase/firestore");
5422
+ var import_firestore18 = require("firebase/firestore");
5269
5423
  var import_geofire_common4 = require("geofire-common");
5270
5424
  var import_zod16 = require("zod");
5271
5425
  async function getClinic(db, clinicId) {
5272
- const docRef = (0, import_firestore16.doc)(db, CLINICS_COLLECTION, clinicId);
5273
- const docSnap = await (0, import_firestore16.getDoc)(docRef);
5426
+ const docRef = (0, import_firestore18.doc)(db, CLINICS_COLLECTION, clinicId);
5427
+ const docSnap = await (0, import_firestore18.getDoc)(docRef);
5274
5428
  if (docSnap.exists()) {
5275
5429
  return docSnap.data();
5276
5430
  }
5277
5431
  return null;
5278
5432
  }
5279
5433
  async function getClinicsByGroup(db, groupId) {
5280
- const q = (0, import_firestore16.query)(
5281
- (0, import_firestore16.collection)(db, CLINICS_COLLECTION),
5282
- (0, import_firestore16.where)("clinicGroupId", "==", groupId),
5283
- (0, import_firestore16.where)("isActive", "==", true)
5434
+ const q = (0, import_firestore18.query)(
5435
+ (0, import_firestore18.collection)(db, CLINICS_COLLECTION),
5436
+ (0, import_firestore18.where)("clinicGroupId", "==", groupId),
5437
+ (0, import_firestore18.where)("isActive", "==", true)
5284
5438
  );
5285
- const querySnapshot = await (0, import_firestore16.getDocs)(q);
5286
- return querySnapshot.docs.map((doc30) => doc30.data());
5439
+ const querySnapshot = await (0, import_firestore18.getDocs)(q);
5440
+ return querySnapshot.docs.map((doc32) => doc32.data());
5287
5441
  }
5288
5442
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
5289
5443
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -5438,11 +5592,11 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
5438
5592
  }
5439
5593
  updatedData = {
5440
5594
  ...updatedData,
5441
- updatedAt: import_firestore16.Timestamp.now()
5595
+ updatedAt: import_firestore18.Timestamp.now()
5442
5596
  };
5443
5597
  console.log("[CLINIC] Updating clinic in Firestore");
5444
5598
  try {
5445
- await (0, import_firestore16.updateDoc)((0, import_firestore16.doc)(db, CLINICS_COLLECTION, clinicId), updatedData);
5599
+ await (0, import_firestore18.updateDoc)((0, import_firestore18.doc)(db, CLINICS_COLLECTION, clinicId), updatedData);
5446
5600
  console.log("[CLINIC] Clinic updated successfully");
5447
5601
  } catch (updateError) {
5448
5602
  console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
@@ -5471,13 +5625,13 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
5471
5625
  if (clinicIds.length === 0) {
5472
5626
  return [];
5473
5627
  }
5474
- const constraints = [(0, import_firestore16.where)("id", "in", clinicIds)];
5628
+ const constraints = [(0, import_firestore18.where)("id", "in", clinicIds)];
5475
5629
  if (options.isActive !== void 0) {
5476
- constraints.push((0, import_firestore16.where)("isActive", "==", options.isActive));
5630
+ constraints.push((0, import_firestore18.where)("isActive", "==", options.isActive));
5477
5631
  }
5478
- const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
5479
- const querySnapshot = await (0, import_firestore16.getDocs)(q);
5480
- return querySnapshot.docs.map((doc30) => doc30.data());
5632
+ const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
5633
+ const querySnapshot = await (0, import_firestore18.getDocs)(q);
5634
+ return querySnapshot.docs.map((doc32) => doc32.data());
5481
5635
  }
5482
5636
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
5483
5637
  return getClinicsByAdmin(
@@ -5490,8 +5644,8 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
5490
5644
  }
5491
5645
  async function getClinicById(db, clinicId) {
5492
5646
  try {
5493
- const clinicRef = (0, import_firestore16.doc)(db, CLINICS_COLLECTION, clinicId);
5494
- const clinicSnapshot = await (0, import_firestore16.getDoc)(clinicRef);
5647
+ const clinicRef = (0, import_firestore18.doc)(db, CLINICS_COLLECTION, clinicId);
5648
+ const clinicSnapshot = await (0, import_firestore18.getDoc)(clinicRef);
5495
5649
  if (!clinicSnapshot.exists()) {
5496
5650
  return null;
5497
5651
  }
@@ -5507,26 +5661,26 @@ async function getClinicById(db, clinicId) {
5507
5661
  }
5508
5662
  async function getAllClinics(db, pagination, lastDoc) {
5509
5663
  try {
5510
- const clinicsCollection = (0, import_firestore16.collection)(db, CLINICS_COLLECTION);
5511
- let clinicsQuery = (0, import_firestore16.query)(clinicsCollection);
5664
+ const clinicsCollection = (0, import_firestore18.collection)(db, CLINICS_COLLECTION);
5665
+ let clinicsQuery = (0, import_firestore18.query)(clinicsCollection);
5512
5666
  if (pagination && pagination > 0) {
5513
5667
  if (lastDoc) {
5514
- clinicsQuery = (0, import_firestore16.query)(
5668
+ clinicsQuery = (0, import_firestore18.query)(
5515
5669
  clinicsCollection,
5516
- (0, import_firestore16.startAfter)(lastDoc),
5517
- (0, import_firestore16.limit)(pagination)
5670
+ (0, import_firestore18.startAfter)(lastDoc),
5671
+ (0, import_firestore18.limit)(pagination)
5518
5672
  );
5519
5673
  } else {
5520
- clinicsQuery = (0, import_firestore16.query)(clinicsCollection, (0, import_firestore16.limit)(pagination));
5674
+ clinicsQuery = (0, import_firestore18.query)(clinicsCollection, (0, import_firestore18.limit)(pagination));
5521
5675
  }
5522
5676
  }
5523
- const clinicsSnapshot = await (0, import_firestore16.getDocs)(clinicsQuery);
5677
+ const clinicsSnapshot = await (0, import_firestore18.getDocs)(clinicsQuery);
5524
5678
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
5525
- const clinics = clinicsSnapshot.docs.map((doc30) => {
5526
- const data = doc30.data();
5679
+ const clinics = clinicsSnapshot.docs.map((doc32) => {
5680
+ const data = doc32.data();
5527
5681
  return {
5528
5682
  ...data,
5529
- id: doc30.id
5683
+ id: doc32.id
5530
5684
  };
5531
5685
  });
5532
5686
  return {
@@ -5547,14 +5701,14 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
5547
5701
  let lastDocSnapshot = null;
5548
5702
  for (const b of bounds) {
5549
5703
  const constraints = [
5550
- (0, import_firestore16.where)("location.geohash", ">=", b[0]),
5551
- (0, import_firestore16.where)("location.geohash", "<=", b[1]),
5552
- (0, import_firestore16.where)("isActive", "==", true)
5704
+ (0, import_firestore18.where)("location.geohash", ">=", b[0]),
5705
+ (0, import_firestore18.where)("location.geohash", "<=", b[1]),
5706
+ (0, import_firestore18.where)("isActive", "==", true)
5553
5707
  ];
5554
- const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
5555
- const querySnapshot = await (0, import_firestore16.getDocs)(q);
5556
- for (const doc30 of querySnapshot.docs) {
5557
- const clinic = doc30.data();
5708
+ const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
5709
+ const querySnapshot = await (0, import_firestore18.getDocs)(q);
5710
+ for (const doc32 of querySnapshot.docs) {
5711
+ const clinic = doc32.data();
5558
5712
  const distance = (0, import_geofire_common4.distanceBetween)(
5559
5713
  [center.latitude, center.longitude],
5560
5714
  [clinic.location.latitude, clinic.location.longitude]
@@ -5647,7 +5801,7 @@ async function removeTags(db, clinicId, adminId, tagsToRemove, clinicAdminServic
5647
5801
  }
5648
5802
 
5649
5803
  // src/services/clinic/utils/search.utils.ts
5650
- var import_firestore17 = require("firebase/firestore");
5804
+ var import_firestore19 = require("firebase/firestore");
5651
5805
  var import_geofire_common5 = require("geofire-common");
5652
5806
  async function findClinicsInRadius(db, center, radiusInKm, filters) {
5653
5807
  const bounds = (0, import_geofire_common5.geohashQueryBounds)(
@@ -5657,22 +5811,22 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5657
5811
  const matchingDocs = [];
5658
5812
  for (const b of bounds) {
5659
5813
  const constraints = [
5660
- (0, import_firestore17.where)("location.geohash", ">=", b[0]),
5661
- (0, import_firestore17.where)("location.geohash", "<=", b[1]),
5662
- (0, import_firestore17.where)("isActive", "==", true)
5814
+ (0, import_firestore19.where)("location.geohash", ">=", b[0]),
5815
+ (0, import_firestore19.where)("location.geohash", "<=", b[1]),
5816
+ (0, import_firestore19.where)("isActive", "==", true)
5663
5817
  ];
5664
5818
  if (filters == null ? void 0 : filters.services) {
5665
5819
  constraints.push(
5666
- (0, import_firestore17.where)("services", "array-contains-any", filters.services)
5820
+ (0, import_firestore19.where)("services", "array-contains-any", filters.services)
5667
5821
  );
5668
5822
  }
5669
5823
  if ((filters == null ? void 0 : filters.tags) && filters.tags.length > 0) {
5670
- constraints.push((0, import_firestore17.where)("tags", "array-contains-any", filters.tags));
5824
+ constraints.push((0, import_firestore19.where)("tags", "array-contains-any", filters.tags));
5671
5825
  }
5672
- const q = (0, import_firestore17.query)((0, import_firestore17.collection)(db, CLINICS_COLLECTION), ...constraints);
5673
- const querySnapshot = await (0, import_firestore17.getDocs)(q);
5674
- for (const doc30 of querySnapshot.docs) {
5675
- const clinic = doc30.data();
5826
+ const q = (0, import_firestore19.query)((0, import_firestore19.collection)(db, CLINICS_COLLECTION), ...constraints);
5827
+ const querySnapshot = await (0, import_firestore19.getDocs)(q);
5828
+ for (const doc32 of querySnapshot.docs) {
5829
+ const clinic = doc32.data();
5676
5830
  const distance = (0, import_geofire_common5.distanceBetween)(
5677
5831
  [center.latitude, center.longitude],
5678
5832
  [clinic.location.latitude, clinic.location.longitude]
@@ -5697,7 +5851,7 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5697
5851
  }
5698
5852
 
5699
5853
  // src/services/clinic/utils/filter.utils.ts
5700
- var import_firestore18 = require("firebase/firestore");
5854
+ var import_firestore20 = require("firebase/firestore");
5701
5855
  var import_geofire_common6 = require("geofire-common");
5702
5856
  async function getClinicsByFilters(db, filters) {
5703
5857
  console.log(
@@ -5707,37 +5861,37 @@ async function getClinicsByFilters(db, filters) {
5707
5861
  const isGeoQuery = filters.center && filters.radiusInKm && filters.radiusInKm > 0;
5708
5862
  const constraints = [];
5709
5863
  if (filters.isActive !== void 0) {
5710
- constraints.push((0, import_firestore18.where)("isActive", "==", filters.isActive));
5864
+ constraints.push((0, import_firestore20.where)("isActive", "==", filters.isActive));
5711
5865
  } else {
5712
- constraints.push((0, import_firestore18.where)("isActive", "==", true));
5866
+ constraints.push((0, import_firestore20.where)("isActive", "==", true));
5713
5867
  }
5714
5868
  if (filters.tags && filters.tags.length > 0) {
5715
- constraints.push((0, import_firestore18.where)("tags", "array-contains", filters.tags[0]));
5869
+ constraints.push((0, import_firestore20.where)("tags", "array-contains", filters.tags[0]));
5716
5870
  }
5717
5871
  if (filters.procedureTechnology) {
5718
5872
  constraints.push(
5719
- (0, import_firestore18.where)("servicesInfo.technology", "==", filters.procedureTechnology)
5873
+ (0, import_firestore20.where)("servicesInfo.technology", "==", filters.procedureTechnology)
5720
5874
  );
5721
5875
  } else if (filters.procedureSubcategory) {
5722
5876
  constraints.push(
5723
- (0, import_firestore18.where)("servicesInfo.subCategory", "==", filters.procedureSubcategory)
5877
+ (0, import_firestore20.where)("servicesInfo.subCategory", "==", filters.procedureSubcategory)
5724
5878
  );
5725
5879
  } else if (filters.procedureCategory) {
5726
5880
  constraints.push(
5727
- (0, import_firestore18.where)("servicesInfo.category", "==", filters.procedureCategory)
5881
+ (0, import_firestore20.where)("servicesInfo.category", "==", filters.procedureCategory)
5728
5882
  );
5729
5883
  } else if (filters.procedureFamily) {
5730
5884
  constraints.push(
5731
- (0, import_firestore18.where)("servicesInfo.procedureFamily", "==", filters.procedureFamily)
5885
+ (0, import_firestore20.where)("servicesInfo.procedureFamily", "==", filters.procedureFamily)
5732
5886
  );
5733
5887
  }
5734
5888
  if (filters.pagination && filters.pagination > 0 && filters.lastDoc) {
5735
- constraints.push((0, import_firestore18.startAfter)(filters.lastDoc));
5736
- constraints.push((0, import_firestore18.limit)(filters.pagination));
5889
+ constraints.push((0, import_firestore20.startAfter)(filters.lastDoc));
5890
+ constraints.push((0, import_firestore20.limit)(filters.pagination));
5737
5891
  } else if (filters.pagination && filters.pagination > 0) {
5738
- constraints.push((0, import_firestore18.limit)(filters.pagination));
5892
+ constraints.push((0, import_firestore20.limit)(filters.pagination));
5739
5893
  }
5740
- constraints.push((0, import_firestore18.orderBy)("location.geohash"));
5894
+ constraints.push((0, import_firestore20.orderBy)("location.geohash"));
5741
5895
  let clinicsResult = [];
5742
5896
  let lastVisibleDoc = null;
5743
5897
  if (isGeoQuery) {
@@ -5752,16 +5906,16 @@ async function getClinicsByFilters(db, filters) {
5752
5906
  for (const bound of bounds) {
5753
5907
  const geoConstraints = [
5754
5908
  ...constraints,
5755
- (0, import_firestore18.where)("location.geohash", ">=", bound[0]),
5756
- (0, import_firestore18.where)("location.geohash", "<=", bound[1])
5909
+ (0, import_firestore20.where)("location.geohash", ">=", bound[0]),
5910
+ (0, import_firestore20.where)("location.geohash", "<=", bound[1])
5757
5911
  ];
5758
- const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...geoConstraints);
5759
- const querySnapshot = await (0, import_firestore18.getDocs)(q);
5912
+ const q = (0, import_firestore20.query)((0, import_firestore20.collection)(db, CLINICS_COLLECTION), ...geoConstraints);
5913
+ const querySnapshot = await (0, import_firestore20.getDocs)(q);
5760
5914
  console.log(
5761
5915
  `[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics in geo bound`
5762
5916
  );
5763
- for (const doc30 of querySnapshot.docs) {
5764
- const clinic = { ...doc30.data(), id: doc30.id };
5917
+ for (const doc32 of querySnapshot.docs) {
5918
+ const clinic = { ...doc32.data(), id: doc32.id };
5765
5919
  const distance = (0, import_geofire_common6.distanceBetween)(
5766
5920
  [center.latitude, center.longitude],
5767
5921
  [clinic.location.latitude, clinic.location.longitude]
@@ -5812,13 +5966,13 @@ async function getClinicsByFilters(db, filters) {
5812
5966
  clinicsResult = filteredClinics;
5813
5967
  }
5814
5968
  } else {
5815
- const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
5816
- const querySnapshot = await (0, import_firestore18.getDocs)(q);
5969
+ const q = (0, import_firestore20.query)((0, import_firestore20.collection)(db, CLINICS_COLLECTION), ...constraints);
5970
+ const querySnapshot = await (0, import_firestore20.getDocs)(q);
5817
5971
  console.log(
5818
5972
  `[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics with regular query`
5819
5973
  );
5820
- const clinics = querySnapshot.docs.map((doc30) => {
5821
- return { ...doc30.data(), id: doc30.id };
5974
+ const clinics = querySnapshot.docs.map((doc32) => {
5975
+ return { ...doc32.data(), id: doc32.id };
5822
5976
  });
5823
5977
  let filteredClinics = clinics;
5824
5978
  if (filters.center) {
@@ -5918,21 +6072,21 @@ var ClinicService = class extends BaseService {
5918
6072
  isActive: validatedData.isActive,
5919
6073
  isVerified: validatedData.isVerified,
5920
6074
  logo: validatedData.logo,
5921
- createdAt: (0, import_firestore19.serverTimestamp)(),
5922
- updatedAt: (0, import_firestore19.serverTimestamp)()
6075
+ createdAt: (0, import_firestore21.serverTimestamp)(),
6076
+ updatedAt: (0, import_firestore21.serverTimestamp)()
5923
6077
  };
5924
6078
  clinicSchema.parse({
5925
6079
  ...clinicData,
5926
- createdAt: import_firestore19.Timestamp.now(),
5927
- updatedAt: import_firestore19.Timestamp.now()
6080
+ createdAt: import_firestore21.Timestamp.now(),
6081
+ updatedAt: import_firestore21.Timestamp.now()
5928
6082
  });
5929
- const batch = (0, import_firestore19.writeBatch)(this.db);
5930
- const clinicRef = (0, import_firestore19.doc)(this.db, CLINICS_COLLECTION, clinicId);
6083
+ const batch = (0, import_firestore21.writeBatch)(this.db);
6084
+ const clinicRef = (0, import_firestore21.doc)(this.db, CLINICS_COLLECTION, clinicId);
5931
6085
  batch.set(clinicRef, clinicData);
5932
- const adminRef = (0, import_firestore19.doc)(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
6086
+ const adminRef = (0, import_firestore21.doc)(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
5933
6087
  batch.update(adminRef, {
5934
- clinicsManaged: (0, import_firestore19.arrayUnion)(clinicId),
5935
- updatedAt: (0, import_firestore19.serverTimestamp)()
6088
+ clinicsManaged: (0, import_firestore21.arrayUnion)(clinicId),
6089
+ updatedAt: (0, import_firestore21.serverTimestamp)()
5936
6090
  });
5937
6091
  await batch.commit();
5938
6092
  const savedClinic = await this.getClinic(clinicId);
@@ -5950,8 +6104,8 @@ var ClinicService = class extends BaseService {
5950
6104
  * Updates a clinic.
5951
6105
  */
5952
6106
  async updateClinic(clinicId, data, adminId) {
5953
- const clinicRef = (0, import_firestore19.doc)(this.db, CLINICS_COLLECTION, clinicId);
5954
- const clinicDoc = await (0, import_firestore19.getDoc)(clinicRef);
6107
+ const clinicRef = (0, import_firestore21.doc)(this.db, CLINICS_COLLECTION, clinicId);
6108
+ const clinicDoc = await (0, import_firestore21.getDoc)(clinicRef);
5955
6109
  if (!clinicDoc.exists()) {
5956
6110
  throw new Error(`Clinic ${clinicId} not found`);
5957
6111
  }
@@ -5975,14 +6129,14 @@ var ClinicService = class extends BaseService {
5975
6129
  };
5976
6130
  clinicSchema.parse({
5977
6131
  ...finalStateForValidation,
5978
- updatedAt: import_firestore19.Timestamp.now()
6132
+ updatedAt: import_firestore21.Timestamp.now()
5979
6133
  // Use current time for validation
5980
6134
  });
5981
6135
  const updateDataForFirestore = {
5982
6136
  ...updatePayload,
5983
- updatedAt: (0, import_firestore19.serverTimestamp)()
6137
+ updatedAt: (0, import_firestore21.serverTimestamp)()
5984
6138
  };
5985
- await (0, import_firestore19.updateDoc)(clinicRef, updateDataForFirestore);
6139
+ await (0, import_firestore21.updateDoc)(clinicRef, updateDataForFirestore);
5986
6140
  const updatedClinic = await this.getClinic(clinicId);
5987
6141
  if (!updatedClinic) throw new Error("Failed to retrieve updated clinic");
5988
6142
  return updatedClinic;
@@ -6000,10 +6154,10 @@ var ClinicService = class extends BaseService {
6000
6154
  * Deactivates a clinic.
6001
6155
  */
6002
6156
  async deactivateClinic(clinicId, adminId) {
6003
- const clinicRef = (0, import_firestore19.doc)(this.db, CLINICS_COLLECTION, clinicId);
6004
- await (0, import_firestore19.updateDoc)(clinicRef, {
6157
+ const clinicRef = (0, import_firestore21.doc)(this.db, CLINICS_COLLECTION, clinicId);
6158
+ await (0, import_firestore21.updateDoc)(clinicRef, {
6005
6159
  isActive: false,
6006
- updatedAt: (0, import_firestore19.serverTimestamp)()
6160
+ updatedAt: (0, import_firestore21.serverTimestamp)()
6007
6161
  });
6008
6162
  }
6009
6163
  /**
@@ -6350,9 +6504,9 @@ var AuthService = class extends BaseService {
6350
6504
  token: data.inviteToken
6351
6505
  });
6352
6506
  console.log("[AUTH] Searching for token in clinic groups");
6353
- const groupsRef = (0, import_firestore20.collection)(this.db, CLINIC_GROUPS_COLLECTION);
6354
- const q = (0, import_firestore20.query)(groupsRef);
6355
- const querySnapshot = await (0, import_firestore20.getDocs)(q);
6507
+ const groupsRef = (0, import_firestore22.collection)(this.db, CLINIC_GROUPS_COLLECTION);
6508
+ const q = (0, import_firestore22.query)(groupsRef);
6509
+ const querySnapshot = await (0, import_firestore22.getDocs)(q);
6356
6510
  let foundGroup = null;
6357
6511
  let foundToken = null;
6358
6512
  console.log(
@@ -6798,7 +6952,7 @@ var AuthService = class extends BaseService {
6798
6952
  };
6799
6953
 
6800
6954
  // src/services/notifications/notification.service.ts
6801
- var import_firestore21 = require("firebase/firestore");
6955
+ var import_firestore23 = require("firebase/firestore");
6802
6956
 
6803
6957
  // src/types/notifications/index.ts
6804
6958
  var NotificationType = /* @__PURE__ */ ((NotificationType3) => {
@@ -6824,8 +6978,8 @@ var NotificationService = class extends BaseService {
6824
6978
  * Kreira novu notifikaciju
6825
6979
  */
6826
6980
  async createNotification(notification) {
6827
- const notificationsRef = (0, import_firestore21.collection)(this.db, NOTIFICATIONS_COLLECTION);
6828
- const now = import_firestore21.Timestamp.now();
6981
+ const notificationsRef = (0, import_firestore23.collection)(this.db, NOTIFICATIONS_COLLECTION);
6982
+ const now = import_firestore23.Timestamp.now();
6829
6983
  const notificationData = {
6830
6984
  ...notification,
6831
6985
  createdAt: now,
@@ -6834,7 +6988,7 @@ var NotificationService = class extends BaseService {
6834
6988
  isRead: false,
6835
6989
  userRole: notification.userRole || "patient" /* PATIENT */
6836
6990
  };
6837
- const docRef = await (0, import_firestore21.addDoc)(notificationsRef, notificationData);
6991
+ const docRef = await (0, import_firestore23.addDoc)(notificationsRef, notificationData);
6838
6992
  return {
6839
6993
  ...notificationData,
6840
6994
  id: docRef.id
@@ -6844,12 +6998,12 @@ var NotificationService = class extends BaseService {
6844
6998
  * Dohvata notifikaciju po ID-u
6845
6999
  */
6846
7000
  async getNotification(notificationId) {
6847
- const notificationRef = (0, import_firestore21.doc)(
7001
+ const notificationRef = (0, import_firestore23.doc)(
6848
7002
  this.db,
6849
7003
  NOTIFICATIONS_COLLECTION,
6850
7004
  notificationId
6851
7005
  );
6852
- const notificationDoc = await (0, import_firestore21.getDoc)(notificationRef);
7006
+ const notificationDoc = await (0, import_firestore23.getDoc)(notificationRef);
6853
7007
  if (!notificationDoc.exists()) {
6854
7008
  return null;
6855
7009
  }
@@ -6862,45 +7016,45 @@ var NotificationService = class extends BaseService {
6862
7016
  * Dohvata sve notifikacije za korisnika
6863
7017
  */
6864
7018
  async getUserNotifications(userId) {
6865
- const q = (0, import_firestore21.query)(
6866
- (0, import_firestore21.collection)(this.db, NOTIFICATIONS_COLLECTION),
6867
- (0, import_firestore21.where)("userId", "==", userId),
6868
- (0, import_firestore21.orderBy)("notificationTime", "desc")
6869
- );
6870
- const querySnapshot = await (0, import_firestore21.getDocs)(q);
6871
- return querySnapshot.docs.map((doc30) => ({
6872
- id: doc30.id,
6873
- ...doc30.data()
7019
+ const q = (0, import_firestore23.query)(
7020
+ (0, import_firestore23.collection)(this.db, NOTIFICATIONS_COLLECTION),
7021
+ (0, import_firestore23.where)("userId", "==", userId),
7022
+ (0, import_firestore23.orderBy)("notificationTime", "desc")
7023
+ );
7024
+ const querySnapshot = await (0, import_firestore23.getDocs)(q);
7025
+ return querySnapshot.docs.map((doc32) => ({
7026
+ id: doc32.id,
7027
+ ...doc32.data()
6874
7028
  }));
6875
7029
  }
6876
7030
  /**
6877
7031
  * Dohvata nepročitane notifikacije za korisnika
6878
7032
  */
6879
7033
  async getUnreadNotifications(userId) {
6880
- const q = (0, import_firestore21.query)(
6881
- (0, import_firestore21.collection)(this.db, NOTIFICATIONS_COLLECTION),
6882
- (0, import_firestore21.where)("userId", "==", userId),
6883
- (0, import_firestore21.where)("isRead", "==", false),
6884
- (0, import_firestore21.orderBy)("notificationTime", "desc")
6885
- );
6886
- const querySnapshot = await (0, import_firestore21.getDocs)(q);
6887
- return querySnapshot.docs.map((doc30) => ({
6888
- id: doc30.id,
6889
- ...doc30.data()
7034
+ const q = (0, import_firestore23.query)(
7035
+ (0, import_firestore23.collection)(this.db, NOTIFICATIONS_COLLECTION),
7036
+ (0, import_firestore23.where)("userId", "==", userId),
7037
+ (0, import_firestore23.where)("isRead", "==", false),
7038
+ (0, import_firestore23.orderBy)("notificationTime", "desc")
7039
+ );
7040
+ const querySnapshot = await (0, import_firestore23.getDocs)(q);
7041
+ return querySnapshot.docs.map((doc32) => ({
7042
+ id: doc32.id,
7043
+ ...doc32.data()
6890
7044
  }));
6891
7045
  }
6892
7046
  /**
6893
7047
  * Označava notifikaciju kao pročitanu
6894
7048
  */
6895
7049
  async markAsRead(notificationId) {
6896
- const notificationRef = (0, import_firestore21.doc)(
7050
+ const notificationRef = (0, import_firestore23.doc)(
6897
7051
  this.db,
6898
7052
  NOTIFICATIONS_COLLECTION,
6899
7053
  notificationId
6900
7054
  );
6901
- await (0, import_firestore21.updateDoc)(notificationRef, {
7055
+ await (0, import_firestore23.updateDoc)(notificationRef, {
6902
7056
  isRead: true,
6903
- updatedAt: import_firestore21.Timestamp.now()
7057
+ updatedAt: import_firestore23.Timestamp.now()
6904
7058
  });
6905
7059
  }
6906
7060
  /**
@@ -6908,16 +7062,16 @@ var NotificationService = class extends BaseService {
6908
7062
  */
6909
7063
  async markAllAsRead(userId) {
6910
7064
  const notifications = await this.getUnreadNotifications(userId);
6911
- const batch = (0, import_firestore21.writeBatch)(this.db);
7065
+ const batch = (0, import_firestore23.writeBatch)(this.db);
6912
7066
  notifications.forEach((notification) => {
6913
- const notificationRef = (0, import_firestore21.doc)(
7067
+ const notificationRef = (0, import_firestore23.doc)(
6914
7068
  this.db,
6915
7069
  NOTIFICATIONS_COLLECTION,
6916
7070
  notification.id
6917
7071
  );
6918
7072
  batch.update(notificationRef, {
6919
7073
  isRead: true,
6920
- updatedAt: import_firestore21.Timestamp.now()
7074
+ updatedAt: import_firestore23.Timestamp.now()
6921
7075
  });
6922
7076
  });
6923
7077
  await batch.commit();
@@ -6926,62 +7080,62 @@ var NotificationService = class extends BaseService {
6926
7080
  * Ažurira status notifikacije
6927
7081
  */
6928
7082
  async updateNotificationStatus(notificationId, status) {
6929
- const notificationRef = (0, import_firestore21.doc)(
7083
+ const notificationRef = (0, import_firestore23.doc)(
6930
7084
  this.db,
6931
7085
  NOTIFICATIONS_COLLECTION,
6932
7086
  notificationId
6933
7087
  );
6934
- await (0, import_firestore21.updateDoc)(notificationRef, {
7088
+ await (0, import_firestore23.updateDoc)(notificationRef, {
6935
7089
  status,
6936
- updatedAt: import_firestore21.Timestamp.now()
7090
+ updatedAt: import_firestore23.Timestamp.now()
6937
7091
  });
6938
7092
  }
6939
7093
  /**
6940
7094
  * Briše notifikaciju
6941
7095
  */
6942
7096
  async deleteNotification(notificationId) {
6943
- const notificationRef = (0, import_firestore21.doc)(
7097
+ const notificationRef = (0, import_firestore23.doc)(
6944
7098
  this.db,
6945
7099
  NOTIFICATIONS_COLLECTION,
6946
7100
  notificationId
6947
7101
  );
6948
- await (0, import_firestore21.deleteDoc)(notificationRef);
7102
+ await (0, import_firestore23.deleteDoc)(notificationRef);
6949
7103
  }
6950
7104
  /**
6951
7105
  * Dohvata notifikacije po tipu
6952
7106
  */
6953
7107
  async getNotificationsByType(userId, type) {
6954
- const q = (0, import_firestore21.query)(
6955
- (0, import_firestore21.collection)(this.db, NOTIFICATIONS_COLLECTION),
6956
- (0, import_firestore21.where)("userId", "==", userId),
6957
- (0, import_firestore21.where)("notificationType", "==", type),
6958
- (0, import_firestore21.orderBy)("notificationTime", "desc")
6959
- );
6960
- const querySnapshot = await (0, import_firestore21.getDocs)(q);
6961
- return querySnapshot.docs.map((doc30) => ({
6962
- id: doc30.id,
6963
- ...doc30.data()
7108
+ const q = (0, import_firestore23.query)(
7109
+ (0, import_firestore23.collection)(this.db, NOTIFICATIONS_COLLECTION),
7110
+ (0, import_firestore23.where)("userId", "==", userId),
7111
+ (0, import_firestore23.where)("notificationType", "==", type),
7112
+ (0, import_firestore23.orderBy)("notificationTime", "desc")
7113
+ );
7114
+ const querySnapshot = await (0, import_firestore23.getDocs)(q);
7115
+ return querySnapshot.docs.map((doc32) => ({
7116
+ id: doc32.id,
7117
+ ...doc32.data()
6964
7118
  }));
6965
7119
  }
6966
7120
  /**
6967
7121
  * Dohvata notifikacije za određeni termin
6968
7122
  */
6969
7123
  async getAppointmentNotifications(appointmentId) {
6970
- const q = (0, import_firestore21.query)(
6971
- (0, import_firestore21.collection)(this.db, NOTIFICATIONS_COLLECTION),
6972
- (0, import_firestore21.where)("appointmentId", "==", appointmentId),
6973
- (0, import_firestore21.orderBy)("notificationTime", "desc")
6974
- );
6975
- const querySnapshot = await (0, import_firestore21.getDocs)(q);
6976
- return querySnapshot.docs.map((doc30) => ({
6977
- id: doc30.id,
6978
- ...doc30.data()
7124
+ const q = (0, import_firestore23.query)(
7125
+ (0, import_firestore23.collection)(this.db, NOTIFICATIONS_COLLECTION),
7126
+ (0, import_firestore23.where)("appointmentId", "==", appointmentId),
7127
+ (0, import_firestore23.orderBy)("notificationTime", "desc")
7128
+ );
7129
+ const querySnapshot = await (0, import_firestore23.getDocs)(q);
7130
+ return querySnapshot.docs.map((doc32) => ({
7131
+ id: doc32.id,
7132
+ ...doc32.data()
6979
7133
  }));
6980
7134
  }
6981
7135
  };
6982
7136
 
6983
7137
  // src/services/procedure/procedure.service.ts
6984
- var import_firestore22 = require("firebase/firestore");
7138
+ var import_firestore24 = require("firebase/firestore");
6985
7139
 
6986
7140
  // src/types/procedure/index.ts
6987
7141
  var PROCEDURES_COLLECTION = "procedures";
@@ -7085,24 +7239,24 @@ var ProcedureService = class extends BaseService {
7085
7239
  if (!category || !subcategory || !technology || !product) {
7086
7240
  throw new Error("One or more required base entities not found");
7087
7241
  }
7088
- const clinicRef = (0, import_firestore22.doc)(
7242
+ const clinicRef = (0, import_firestore24.doc)(
7089
7243
  this.db,
7090
7244
  CLINICS_COLLECTION,
7091
7245
  validatedData.clinicBranchId
7092
7246
  );
7093
- const clinicSnapshot = await (0, import_firestore22.getDoc)(clinicRef);
7247
+ const clinicSnapshot = await (0, import_firestore24.getDoc)(clinicRef);
7094
7248
  if (!clinicSnapshot.exists()) {
7095
7249
  throw new Error(
7096
7250
  `Clinic with ID ${validatedData.clinicBranchId} not found`
7097
7251
  );
7098
7252
  }
7099
7253
  const clinic = clinicSnapshot.data();
7100
- const practitionerRef = (0, import_firestore22.doc)(
7254
+ const practitionerRef = (0, import_firestore24.doc)(
7101
7255
  this.db,
7102
7256
  PRACTITIONERS_COLLECTION,
7103
7257
  validatedData.practitionerId
7104
7258
  );
7105
- const practitionerSnapshot = await (0, import_firestore22.getDoc)(practitionerRef);
7259
+ const practitionerSnapshot = await (0, import_firestore24.getDoc)(practitionerRef);
7106
7260
  if (!practitionerSnapshot.exists()) {
7107
7261
  throw new Error(
7108
7262
  `Practitioner with ID ${validatedData.practitionerId} not found`
@@ -7158,13 +7312,13 @@ var ProcedureService = class extends BaseService {
7158
7312
  isActive: true
7159
7313
  // Default to active
7160
7314
  };
7161
- const procedureRef = (0, import_firestore22.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
7162
- await (0, import_firestore22.setDoc)(procedureRef, {
7315
+ const procedureRef = (0, import_firestore24.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
7316
+ await (0, import_firestore24.setDoc)(procedureRef, {
7163
7317
  ...newProcedure,
7164
- createdAt: (0, import_firestore22.serverTimestamp)(),
7165
- updatedAt: (0, import_firestore22.serverTimestamp)()
7318
+ createdAt: (0, import_firestore24.serverTimestamp)(),
7319
+ updatedAt: (0, import_firestore24.serverTimestamp)()
7166
7320
  });
7167
- const savedDoc = await (0, import_firestore22.getDoc)(procedureRef);
7321
+ const savedDoc = await (0, import_firestore24.getDoc)(procedureRef);
7168
7322
  return savedDoc.data();
7169
7323
  }
7170
7324
  /**
@@ -7173,8 +7327,8 @@ var ProcedureService = class extends BaseService {
7173
7327
  * @returns The procedure if found, null otherwise
7174
7328
  */
7175
7329
  async getProcedure(id) {
7176
- const docRef = (0, import_firestore22.doc)(this.db, PROCEDURES_COLLECTION, id);
7177
- const docSnap = await (0, import_firestore22.getDoc)(docRef);
7330
+ const docRef = (0, import_firestore24.doc)(this.db, PROCEDURES_COLLECTION, id);
7331
+ const docSnap = await (0, import_firestore24.getDoc)(docRef);
7178
7332
  if (!docSnap.exists()) {
7179
7333
  return null;
7180
7334
  }
@@ -7186,13 +7340,13 @@ var ProcedureService = class extends BaseService {
7186
7340
  * @returns List of procedures
7187
7341
  */
7188
7342
  async getProceduresByClinicBranch(clinicBranchId) {
7189
- const q = (0, import_firestore22.query)(
7190
- (0, import_firestore22.collection)(this.db, PROCEDURES_COLLECTION),
7191
- (0, import_firestore22.where)("clinicBranchId", "==", clinicBranchId),
7192
- (0, import_firestore22.where)("isActive", "==", true)
7343
+ const q = (0, import_firestore24.query)(
7344
+ (0, import_firestore24.collection)(this.db, PROCEDURES_COLLECTION),
7345
+ (0, import_firestore24.where)("clinicBranchId", "==", clinicBranchId),
7346
+ (0, import_firestore24.where)("isActive", "==", true)
7193
7347
  );
7194
- const snapshot = await (0, import_firestore22.getDocs)(q);
7195
- return snapshot.docs.map((doc30) => doc30.data());
7348
+ const snapshot = await (0, import_firestore24.getDocs)(q);
7349
+ return snapshot.docs.map((doc32) => doc32.data());
7196
7350
  }
7197
7351
  /**
7198
7352
  * Gets all procedures for a practitioner
@@ -7200,13 +7354,13 @@ var ProcedureService = class extends BaseService {
7200
7354
  * @returns List of procedures
7201
7355
  */
7202
7356
  async getProceduresByPractitioner(practitionerId) {
7203
- const q = (0, import_firestore22.query)(
7204
- (0, import_firestore22.collection)(this.db, PROCEDURES_COLLECTION),
7205
- (0, import_firestore22.where)("practitionerId", "==", practitionerId),
7206
- (0, import_firestore22.where)("isActive", "==", true)
7357
+ const q = (0, import_firestore24.query)(
7358
+ (0, import_firestore24.collection)(this.db, PROCEDURES_COLLECTION),
7359
+ (0, import_firestore24.where)("practitionerId", "==", practitionerId),
7360
+ (0, import_firestore24.where)("isActive", "==", true)
7207
7361
  );
7208
- const snapshot = await (0, import_firestore22.getDocs)(q);
7209
- return snapshot.docs.map((doc30) => doc30.data());
7362
+ const snapshot = await (0, import_firestore24.getDocs)(q);
7363
+ return snapshot.docs.map((doc32) => doc32.data());
7210
7364
  }
7211
7365
  /**
7212
7366
  * Updates a procedure
@@ -7217,8 +7371,8 @@ var ProcedureService = class extends BaseService {
7217
7371
  async updateProcedure(id, data) {
7218
7372
  var _a;
7219
7373
  const validatedData = updateProcedureSchema.parse(data);
7220
- const procedureRef = (0, import_firestore22.doc)(this.db, PROCEDURES_COLLECTION, id);
7221
- const procedureSnapshot = await (0, import_firestore22.getDoc)(procedureRef);
7374
+ const procedureRef = (0, import_firestore24.doc)(this.db, PROCEDURES_COLLECTION, id);
7375
+ const procedureSnapshot = await (0, import_firestore24.getDoc)(procedureRef);
7222
7376
  if (!procedureSnapshot.exists()) {
7223
7377
  throw new Error(`Procedure with ID ${id} not found`);
7224
7378
  }
@@ -7232,12 +7386,12 @@ var ProcedureService = class extends BaseService {
7232
7386
  let newClinic = null;
7233
7387
  if (validatedData.practitionerId && validatedData.practitionerId !== oldPractitionerId) {
7234
7388
  practitionerChanged = true;
7235
- const newPractitionerRef = (0, import_firestore22.doc)(
7389
+ const newPractitionerRef = (0, import_firestore24.doc)(
7236
7390
  this.db,
7237
7391
  PRACTITIONERS_COLLECTION,
7238
7392
  validatedData.practitionerId
7239
7393
  );
7240
- const newPractitionerSnap = await (0, import_firestore22.getDoc)(newPractitionerRef);
7394
+ const newPractitionerSnap = await (0, import_firestore24.getDoc)(newPractitionerRef);
7241
7395
  if (!newPractitionerSnap.exists())
7242
7396
  throw new Error(
7243
7397
  `New Practitioner ${validatedData.practitionerId} not found`
@@ -7254,12 +7408,12 @@ var ProcedureService = class extends BaseService {
7254
7408
  }
7255
7409
  if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
7256
7410
  clinicChanged = true;
7257
- const newClinicRef = (0, import_firestore22.doc)(
7411
+ const newClinicRef = (0, import_firestore24.doc)(
7258
7412
  this.db,
7259
7413
  CLINICS_COLLECTION,
7260
7414
  validatedData.clinicBranchId
7261
7415
  );
7262
- const newClinicSnap = await (0, import_firestore22.getDoc)(newClinicRef);
7416
+ const newClinicSnap = await (0, import_firestore24.getDoc)(newClinicRef);
7263
7417
  if (!newClinicSnap.exists())
7264
7418
  throw new Error(`New Clinic ${validatedData.clinicBranchId} not found`);
7265
7419
  newClinic = newClinicSnap.data();
@@ -7326,11 +7480,11 @@ var ProcedureService = class extends BaseService {
7326
7480
  } else if (validatedData.productId) {
7327
7481
  console.warn("Attempted to update product without a valid technologyId");
7328
7482
  }
7329
- await (0, import_firestore22.updateDoc)(procedureRef, {
7483
+ await (0, import_firestore24.updateDoc)(procedureRef, {
7330
7484
  ...updatedProcedureData,
7331
- updatedAt: (0, import_firestore22.serverTimestamp)()
7485
+ updatedAt: (0, import_firestore24.serverTimestamp)()
7332
7486
  });
7333
- const updatedSnapshot = await (0, import_firestore22.getDoc)(procedureRef);
7487
+ const updatedSnapshot = await (0, import_firestore24.getDoc)(procedureRef);
7334
7488
  return updatedSnapshot.data();
7335
7489
  }
7336
7490
  /**
@@ -7338,15 +7492,15 @@ var ProcedureService = class extends BaseService {
7338
7492
  * @param id - The ID of the procedure to deactivate
7339
7493
  */
7340
7494
  async deactivateProcedure(id) {
7341
- const procedureRef = (0, import_firestore22.doc)(this.db, PROCEDURES_COLLECTION, id);
7342
- const procedureSnap = await (0, import_firestore22.getDoc)(procedureRef);
7495
+ const procedureRef = (0, import_firestore24.doc)(this.db, PROCEDURES_COLLECTION, id);
7496
+ const procedureSnap = await (0, import_firestore24.getDoc)(procedureRef);
7343
7497
  if (!procedureSnap.exists()) {
7344
7498
  console.warn(`Procedure ${id} not found for deactivation.`);
7345
7499
  return;
7346
7500
  }
7347
- await (0, import_firestore22.updateDoc)(procedureRef, {
7501
+ await (0, import_firestore24.updateDoc)(procedureRef, {
7348
7502
  isActive: false,
7349
- updatedAt: (0, import_firestore22.serverTimestamp)()
7503
+ updatedAt: (0, import_firestore24.serverTimestamp)()
7350
7504
  });
7351
7505
  }
7352
7506
  /**
@@ -7355,12 +7509,12 @@ var ProcedureService = class extends BaseService {
7355
7509
  * @returns A boolean indicating if the deletion was successful
7356
7510
  */
7357
7511
  async deleteProcedure(id) {
7358
- const procedureRef = (0, import_firestore22.doc)(this.db, PROCEDURES_COLLECTION, id);
7359
- const procedureSnapshot = await (0, import_firestore22.getDoc)(procedureRef);
7512
+ const procedureRef = (0, import_firestore24.doc)(this.db, PROCEDURES_COLLECTION, id);
7513
+ const procedureSnapshot = await (0, import_firestore24.getDoc)(procedureRef);
7360
7514
  if (!procedureSnapshot.exists()) {
7361
7515
  return false;
7362
7516
  }
7363
- await (0, import_firestore22.deleteDoc)(procedureRef);
7517
+ await (0, import_firestore24.deleteDoc)(procedureRef);
7364
7518
  return true;
7365
7519
  }
7366
7520
  /**
@@ -7386,35 +7540,35 @@ var ProcedureService = class extends BaseService {
7386
7540
  */
7387
7541
  async getAllProcedures(pagination, lastDoc) {
7388
7542
  try {
7389
- const proceduresCollection = (0, import_firestore22.collection)(this.db, PROCEDURES_COLLECTION);
7390
- let proceduresQuery = (0, import_firestore22.query)(proceduresCollection);
7543
+ const proceduresCollection = (0, import_firestore24.collection)(this.db, PROCEDURES_COLLECTION);
7544
+ let proceduresQuery = (0, import_firestore24.query)(proceduresCollection);
7391
7545
  if (pagination && pagination > 0) {
7392
- const { limit: limit9, startAfter: startAfter9 } = await import("firebase/firestore");
7546
+ const { limit: limit11, startAfter: startAfter11 } = await import("firebase/firestore");
7393
7547
  if (lastDoc) {
7394
- proceduresQuery = (0, import_firestore22.query)(
7548
+ proceduresQuery = (0, import_firestore24.query)(
7395
7549
  proceduresCollection,
7396
- (0, import_firestore22.orderBy)("name"),
7550
+ (0, import_firestore24.orderBy)("name"),
7397
7551
  // Use imported orderBy
7398
- startAfter9(lastDoc),
7399
- limit9(pagination)
7552
+ startAfter11(lastDoc),
7553
+ limit11(pagination)
7400
7554
  );
7401
7555
  } else {
7402
- proceduresQuery = (0, import_firestore22.query)(
7556
+ proceduresQuery = (0, import_firestore24.query)(
7403
7557
  proceduresCollection,
7404
- (0, import_firestore22.orderBy)("name"),
7405
- limit9(pagination)
7558
+ (0, import_firestore24.orderBy)("name"),
7559
+ limit11(pagination)
7406
7560
  );
7407
7561
  }
7408
7562
  } else {
7409
- proceduresQuery = (0, import_firestore22.query)(proceduresCollection, (0, import_firestore22.orderBy)("name"));
7563
+ proceduresQuery = (0, import_firestore24.query)(proceduresCollection, (0, import_firestore24.orderBy)("name"));
7410
7564
  }
7411
- const proceduresSnapshot = await (0, import_firestore22.getDocs)(proceduresQuery);
7565
+ const proceduresSnapshot = await (0, import_firestore24.getDocs)(proceduresQuery);
7412
7566
  const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
7413
- const procedures = proceduresSnapshot.docs.map((doc30) => {
7414
- const data = doc30.data();
7567
+ const procedures = proceduresSnapshot.docs.map((doc32) => {
7568
+ const data = doc32.data();
7415
7569
  return {
7416
7570
  ...data,
7417
- id: doc30.id
7571
+ id: doc32.id
7418
7572
  // Ensure ID is present
7419
7573
  };
7420
7574
  });
@@ -7457,19 +7611,19 @@ var ProcedureService = class extends BaseService {
7457
7611
  const isGeoQuery = filters.location && filters.radiusInKm && filters.radiusInKm > 0;
7458
7612
  const constraints = [];
7459
7613
  if (filters.isActive !== void 0) {
7460
- constraints.push((0, import_firestore22.where)("isActive", "==", filters.isActive));
7614
+ constraints.push((0, import_firestore24.where)("isActive", "==", filters.isActive));
7461
7615
  } else {
7462
- constraints.push((0, import_firestore22.where)("isActive", "==", true));
7616
+ constraints.push((0, import_firestore24.where)("isActive", "==", true));
7463
7617
  }
7464
7618
  if (filters.procedureFamily) {
7465
- constraints.push((0, import_firestore22.where)("family", "==", filters.procedureFamily));
7619
+ constraints.push((0, import_firestore24.where)("family", "==", filters.procedureFamily));
7466
7620
  }
7467
- constraints.push((0, import_firestore22.orderBy)("clinicInfo.location.geohash"));
7621
+ constraints.push((0, import_firestore24.orderBy)("clinicInfo.location.geohash"));
7468
7622
  if (filters.pagination && filters.pagination > 0 && filters.lastDoc) {
7469
- constraints.push((0, import_firestore22.startAfter)(filters.lastDoc));
7470
- constraints.push((0, import_firestore22.limit)(filters.pagination));
7623
+ constraints.push((0, import_firestore24.startAfter)(filters.lastDoc));
7624
+ constraints.push((0, import_firestore24.limit)(filters.pagination));
7471
7625
  } else if (filters.pagination && filters.pagination > 0) {
7472
- constraints.push((0, import_firestore22.limit)(filters.pagination));
7626
+ constraints.push((0, import_firestore24.limit)(filters.pagination));
7473
7627
  }
7474
7628
  let proceduresResult = [];
7475
7629
  let lastVisibleDoc = null;
@@ -7485,19 +7639,19 @@ var ProcedureService = class extends BaseService {
7485
7639
  for (const bound of bounds) {
7486
7640
  const geoConstraints = [
7487
7641
  ...constraints,
7488
- (0, import_firestore22.where)("clinicInfo.location.geohash", ">=", bound[0]),
7489
- (0, import_firestore22.where)("clinicInfo.location.geohash", "<=", bound[1])
7642
+ (0, import_firestore24.where)("clinicInfo.location.geohash", ">=", bound[0]),
7643
+ (0, import_firestore24.where)("clinicInfo.location.geohash", "<=", bound[1])
7490
7644
  ];
7491
- const q = (0, import_firestore22.query)(
7492
- (0, import_firestore22.collection)(this.db, PROCEDURES_COLLECTION),
7645
+ const q = (0, import_firestore24.query)(
7646
+ (0, import_firestore24.collection)(this.db, PROCEDURES_COLLECTION),
7493
7647
  ...geoConstraints
7494
7648
  );
7495
- const querySnapshot = await (0, import_firestore22.getDocs)(q);
7649
+ const querySnapshot = await (0, import_firestore24.getDocs)(q);
7496
7650
  console.log(
7497
7651
  `[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures in geo bound`
7498
7652
  );
7499
- for (const doc30 of querySnapshot.docs) {
7500
- const procedure = { ...doc30.data(), id: doc30.id };
7653
+ for (const doc32 of querySnapshot.docs) {
7654
+ const procedure = { ...doc32.data(), id: doc32.id };
7501
7655
  const distance = (0, import_geofire_common8.distanceBetween)(
7502
7656
  [center.latitude, center.longitude],
7503
7657
  [
@@ -7540,16 +7694,16 @@ var ProcedureService = class extends BaseService {
7540
7694
  proceduresResult = filteredProcedures;
7541
7695
  }
7542
7696
  } else {
7543
- const q = (0, import_firestore22.query)(
7544
- (0, import_firestore22.collection)(this.db, PROCEDURES_COLLECTION),
7697
+ const q = (0, import_firestore24.query)(
7698
+ (0, import_firestore24.collection)(this.db, PROCEDURES_COLLECTION),
7545
7699
  ...constraints
7546
7700
  );
7547
- const querySnapshot = await (0, import_firestore22.getDocs)(q);
7701
+ const querySnapshot = await (0, import_firestore24.getDocs)(q);
7548
7702
  console.log(
7549
7703
  `[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures with regular query`
7550
7704
  );
7551
- const procedures = querySnapshot.docs.map((doc30) => {
7552
- return { ...doc30.data(), id: doc30.id };
7705
+ const procedures = querySnapshot.docs.map((doc32) => {
7706
+ return { ...doc32.data(), id: doc32.id };
7553
7707
  });
7554
7708
  if (filters.location) {
7555
7709
  const center = filters.location;
@@ -7656,11 +7810,11 @@ var ProcedureService = class extends BaseService {
7656
7810
  };
7657
7811
 
7658
7812
  // src/services/documentation-templates/documentation-template.service.ts
7659
- var import_firestore23 = require("firebase/firestore");
7813
+ var import_firestore25 = require("firebase/firestore");
7660
7814
  var DocumentationTemplateService = class extends BaseService {
7661
7815
  constructor() {
7662
7816
  super(...arguments);
7663
- this.collectionRef = (0, import_firestore23.collection)(
7817
+ this.collectionRef = (0, import_firestore25.collection)(
7664
7818
  this.db,
7665
7819
  DOCUMENTATION_TEMPLATES_COLLECTION
7666
7820
  );
@@ -7691,8 +7845,8 @@ var DocumentationTemplateService = class extends BaseService {
7691
7845
  isActive: true,
7692
7846
  tags: validatedData.tags || []
7693
7847
  };
7694
- const docRef = (0, import_firestore23.doc)(this.collectionRef, templateId);
7695
- await (0, import_firestore23.setDoc)(docRef, template);
7848
+ const docRef = (0, import_firestore25.doc)(this.collectionRef, templateId);
7849
+ await (0, import_firestore25.setDoc)(docRef, template);
7696
7850
  return template;
7697
7851
  }
7698
7852
  /**
@@ -7701,8 +7855,8 @@ var DocumentationTemplateService = class extends BaseService {
7701
7855
  * @returns The template or null if not found
7702
7856
  */
7703
7857
  async getTemplateById(templateId) {
7704
- const docRef = (0, import_firestore23.doc)(this.collectionRef, templateId);
7705
- const docSnap = await (0, import_firestore23.getDoc)(docRef);
7858
+ const docRef = (0, import_firestore25.doc)(this.collectionRef, templateId);
7859
+ const docSnap = await (0, import_firestore25.getDoc)(docRef);
7706
7860
  if (!docSnap.exists()) {
7707
7861
  return null;
7708
7862
  }
@@ -7733,8 +7887,8 @@ var DocumentationTemplateService = class extends BaseService {
7733
7887
  updatedAt: Date.now(),
7734
7888
  version: template.version + 1
7735
7889
  };
7736
- const docRef = (0, import_firestore23.doc)(this.collectionRef, templateId);
7737
- await (0, import_firestore23.updateDoc)(docRef, updateData);
7890
+ const docRef = (0, import_firestore25.doc)(this.collectionRef, templateId);
7891
+ await (0, import_firestore25.updateDoc)(docRef, updateData);
7738
7892
  return {
7739
7893
  ...template,
7740
7894
  ...updateData
@@ -7745,8 +7899,8 @@ var DocumentationTemplateService = class extends BaseService {
7745
7899
  * @param templateId - ID of the template to delete
7746
7900
  */
7747
7901
  async deleteTemplate(templateId) {
7748
- const docRef = (0, import_firestore23.doc)(this.collectionRef, templateId);
7749
- await (0, import_firestore23.deleteDoc)(docRef);
7902
+ const docRef = (0, import_firestore25.doc)(this.collectionRef, templateId);
7903
+ await (0, import_firestore25.deleteDoc)(docRef);
7750
7904
  }
7751
7905
  /**
7752
7906
  * Get all active templates
@@ -7755,21 +7909,21 @@ var DocumentationTemplateService = class extends BaseService {
7755
7909
  * @returns Array of templates and the last document for pagination
7756
7910
  */
7757
7911
  async getActiveTemplates(pageSize = 20, lastDoc) {
7758
- let q = (0, import_firestore23.query)(
7912
+ let q = (0, import_firestore25.query)(
7759
7913
  this.collectionRef,
7760
- (0, import_firestore23.where)("isActive", "==", true),
7761
- (0, import_firestore23.orderBy)("updatedAt", "desc"),
7762
- (0, import_firestore23.limit)(pageSize)
7914
+ (0, import_firestore25.where)("isActive", "==", true),
7915
+ (0, import_firestore25.orderBy)("updatedAt", "desc"),
7916
+ (0, import_firestore25.limit)(pageSize)
7763
7917
  );
7764
7918
  if (lastDoc) {
7765
- q = (0, import_firestore23.query)(q, (0, import_firestore23.startAfter)(lastDoc));
7919
+ q = (0, import_firestore25.query)(q, (0, import_firestore25.startAfter)(lastDoc));
7766
7920
  }
7767
- const querySnapshot = await (0, import_firestore23.getDocs)(q);
7921
+ const querySnapshot = await (0, import_firestore25.getDocs)(q);
7768
7922
  const templates = [];
7769
7923
  let lastVisible = null;
7770
- querySnapshot.forEach((doc30) => {
7771
- templates.push(doc30.data());
7772
- lastVisible = doc30;
7924
+ querySnapshot.forEach((doc32) => {
7925
+ templates.push(doc32.data());
7926
+ lastVisible = doc32;
7773
7927
  });
7774
7928
  return {
7775
7929
  templates,
@@ -7784,22 +7938,22 @@ var DocumentationTemplateService = class extends BaseService {
7784
7938
  * @returns Array of templates and the last document for pagination
7785
7939
  */
7786
7940
  async getTemplatesByTags(tags, pageSize = 20, lastDoc) {
7787
- let q = (0, import_firestore23.query)(
7941
+ let q = (0, import_firestore25.query)(
7788
7942
  this.collectionRef,
7789
- (0, import_firestore23.where)("isActive", "==", true),
7790
- (0, import_firestore23.where)("tags", "array-contains-any", tags),
7791
- (0, import_firestore23.orderBy)("updatedAt", "desc"),
7792
- (0, import_firestore23.limit)(pageSize)
7943
+ (0, import_firestore25.where)("isActive", "==", true),
7944
+ (0, import_firestore25.where)("tags", "array-contains-any", tags),
7945
+ (0, import_firestore25.orderBy)("updatedAt", "desc"),
7946
+ (0, import_firestore25.limit)(pageSize)
7793
7947
  );
7794
7948
  if (lastDoc) {
7795
- q = (0, import_firestore23.query)(q, (0, import_firestore23.startAfter)(lastDoc));
7949
+ q = (0, import_firestore25.query)(q, (0, import_firestore25.startAfter)(lastDoc));
7796
7950
  }
7797
- const querySnapshot = await (0, import_firestore23.getDocs)(q);
7951
+ const querySnapshot = await (0, import_firestore25.getDocs)(q);
7798
7952
  const templates = [];
7799
7953
  let lastVisible = null;
7800
- querySnapshot.forEach((doc30) => {
7801
- templates.push(doc30.data());
7802
- lastVisible = doc30;
7954
+ querySnapshot.forEach((doc32) => {
7955
+ templates.push(doc32.data());
7956
+ lastVisible = doc32;
7803
7957
  });
7804
7958
  return {
7805
7959
  templates,
@@ -7814,21 +7968,21 @@ var DocumentationTemplateService = class extends BaseService {
7814
7968
  * @returns Array of templates and the last document for pagination
7815
7969
  */
7816
7970
  async getTemplatesByCreator(userId, pageSize = 20, lastDoc) {
7817
- let q = (0, import_firestore23.query)(
7971
+ let q = (0, import_firestore25.query)(
7818
7972
  this.collectionRef,
7819
- (0, import_firestore23.where)("createdBy", "==", userId),
7820
- (0, import_firestore23.orderBy)("updatedAt", "desc"),
7821
- (0, import_firestore23.limit)(pageSize)
7973
+ (0, import_firestore25.where)("createdBy", "==", userId),
7974
+ (0, import_firestore25.orderBy)("updatedAt", "desc"),
7975
+ (0, import_firestore25.limit)(pageSize)
7822
7976
  );
7823
7977
  if (lastDoc) {
7824
- q = (0, import_firestore23.query)(q, (0, import_firestore23.startAfter)(lastDoc));
7978
+ q = (0, import_firestore25.query)(q, (0, import_firestore25.startAfter)(lastDoc));
7825
7979
  }
7826
- const querySnapshot = await (0, import_firestore23.getDocs)(q);
7980
+ const querySnapshot = await (0, import_firestore25.getDocs)(q);
7827
7981
  const templates = [];
7828
7982
  let lastVisible = null;
7829
- querySnapshot.forEach((doc30) => {
7830
- templates.push(doc30.data());
7831
- lastVisible = doc30;
7983
+ querySnapshot.forEach((doc32) => {
7984
+ templates.push(doc32.data());
7985
+ lastVisible = doc32;
7832
7986
  });
7833
7987
  return {
7834
7988
  templates,
@@ -7838,11 +7992,11 @@ var DocumentationTemplateService = class extends BaseService {
7838
7992
  };
7839
7993
 
7840
7994
  // src/services/documentation-templates/filled-document.service.ts
7841
- var import_firestore24 = require("firebase/firestore");
7995
+ var import_firestore26 = require("firebase/firestore");
7842
7996
  var FilledDocumentService = class extends BaseService {
7843
7997
  constructor(...args) {
7844
7998
  super(...args);
7845
- this.collectionRef = (0, import_firestore24.collection)(
7999
+ this.collectionRef = (0, import_firestore26.collection)(
7846
8000
  this.db,
7847
8001
  FILLED_DOCUMENTS_COLLECTION
7848
8002
  );
@@ -7875,8 +8029,8 @@ var FilledDocumentService = class extends BaseService {
7875
8029
  values: {},
7876
8030
  status: "draft" /* DRAFT */
7877
8031
  };
7878
- const docRef = (0, import_firestore24.doc)(this.collectionRef, documentId3);
7879
- await (0, import_firestore24.setDoc)(docRef, filledDocument);
8032
+ const docRef = (0, import_firestore26.doc)(this.collectionRef, documentId3);
8033
+ await (0, import_firestore26.setDoc)(docRef, filledDocument);
7880
8034
  return filledDocument;
7881
8035
  }
7882
8036
  /**
@@ -7885,8 +8039,8 @@ var FilledDocumentService = class extends BaseService {
7885
8039
  * @returns The filled document or null if not found
7886
8040
  */
7887
8041
  async getFilledDocumentById(documentId3) {
7888
- const docRef = (0, import_firestore24.doc)(this.collectionRef, documentId3);
7889
- const docSnap = await (0, import_firestore24.getDoc)(docRef);
8042
+ const docRef = (0, import_firestore26.doc)(this.collectionRef, documentId3);
8043
+ const docSnap = await (0, import_firestore26.getDoc)(docRef);
7890
8044
  if (!docSnap.exists()) {
7891
8045
  return null;
7892
8046
  }
@@ -7914,8 +8068,8 @@ var FilledDocumentService = class extends BaseService {
7914
8068
  if (status) {
7915
8069
  updateData.status = status;
7916
8070
  }
7917
- const docRef = (0, import_firestore24.doc)(this.collectionRef, documentId3);
7918
- await (0, import_firestore24.updateDoc)(docRef, updateData);
8071
+ const docRef = (0, import_firestore26.doc)(this.collectionRef, documentId3);
8072
+ await (0, import_firestore26.updateDoc)(docRef, updateData);
7919
8073
  return {
7920
8074
  ...filledDocument,
7921
8075
  ...updateData
@@ -7929,21 +8083,21 @@ var FilledDocumentService = class extends BaseService {
7929
8083
  * @returns Array of filled documents and the last document for pagination
7930
8084
  */
7931
8085
  async getFilledDocumentsByPatient(patientId, pageSize = 20, lastDoc) {
7932
- let q = (0, import_firestore24.query)(
8086
+ let q = (0, import_firestore26.query)(
7933
8087
  this.collectionRef,
7934
- (0, import_firestore24.where)("patientId", "==", patientId),
7935
- (0, import_firestore24.orderBy)("updatedAt", "desc"),
7936
- (0, import_firestore24.limit)(pageSize)
8088
+ (0, import_firestore26.where)("patientId", "==", patientId),
8089
+ (0, import_firestore26.orderBy)("updatedAt", "desc"),
8090
+ (0, import_firestore26.limit)(pageSize)
7937
8091
  );
7938
8092
  if (lastDoc) {
7939
- q = (0, import_firestore24.query)(q, (0, import_firestore24.startAfter)(lastDoc));
8093
+ q = (0, import_firestore26.query)(q, (0, import_firestore26.startAfter)(lastDoc));
7940
8094
  }
7941
- const querySnapshot = await (0, import_firestore24.getDocs)(q);
8095
+ const querySnapshot = await (0, import_firestore26.getDocs)(q);
7942
8096
  const documents = [];
7943
8097
  let lastVisible = null;
7944
- querySnapshot.forEach((doc30) => {
7945
- documents.push(doc30.data());
7946
- lastVisible = doc30;
8098
+ querySnapshot.forEach((doc32) => {
8099
+ documents.push(doc32.data());
8100
+ lastVisible = doc32;
7947
8101
  });
7948
8102
  return {
7949
8103
  documents,
@@ -7958,21 +8112,21 @@ var FilledDocumentService = class extends BaseService {
7958
8112
  * @returns Array of filled documents and the last document for pagination
7959
8113
  */
7960
8114
  async getFilledDocumentsByPractitioner(practitionerId, pageSize = 20, lastDoc) {
7961
- let q = (0, import_firestore24.query)(
8115
+ let q = (0, import_firestore26.query)(
7962
8116
  this.collectionRef,
7963
- (0, import_firestore24.where)("practitionerId", "==", practitionerId),
7964
- (0, import_firestore24.orderBy)("updatedAt", "desc"),
7965
- (0, import_firestore24.limit)(pageSize)
8117
+ (0, import_firestore26.where)("practitionerId", "==", practitionerId),
8118
+ (0, import_firestore26.orderBy)("updatedAt", "desc"),
8119
+ (0, import_firestore26.limit)(pageSize)
7966
8120
  );
7967
8121
  if (lastDoc) {
7968
- q = (0, import_firestore24.query)(q, (0, import_firestore24.startAfter)(lastDoc));
8122
+ q = (0, import_firestore26.query)(q, (0, import_firestore26.startAfter)(lastDoc));
7969
8123
  }
7970
- const querySnapshot = await (0, import_firestore24.getDocs)(q);
8124
+ const querySnapshot = await (0, import_firestore26.getDocs)(q);
7971
8125
  const documents = [];
7972
8126
  let lastVisible = null;
7973
- querySnapshot.forEach((doc30) => {
7974
- documents.push(doc30.data());
7975
- lastVisible = doc30;
8127
+ querySnapshot.forEach((doc32) => {
8128
+ documents.push(doc32.data());
8129
+ lastVisible = doc32;
7976
8130
  });
7977
8131
  return {
7978
8132
  documents,
@@ -7987,21 +8141,21 @@ var FilledDocumentService = class extends BaseService {
7987
8141
  * @returns Array of filled documents and the last document for pagination
7988
8142
  */
7989
8143
  async getFilledDocumentsByClinic(clinicId, pageSize = 20, lastDoc) {
7990
- let q = (0, import_firestore24.query)(
8144
+ let q = (0, import_firestore26.query)(
7991
8145
  this.collectionRef,
7992
- (0, import_firestore24.where)("clinicId", "==", clinicId),
7993
- (0, import_firestore24.orderBy)("updatedAt", "desc"),
7994
- (0, import_firestore24.limit)(pageSize)
8146
+ (0, import_firestore26.where)("clinicId", "==", clinicId),
8147
+ (0, import_firestore26.orderBy)("updatedAt", "desc"),
8148
+ (0, import_firestore26.limit)(pageSize)
7995
8149
  );
7996
8150
  if (lastDoc) {
7997
- q = (0, import_firestore24.query)(q, (0, import_firestore24.startAfter)(lastDoc));
8151
+ q = (0, import_firestore26.query)(q, (0, import_firestore26.startAfter)(lastDoc));
7998
8152
  }
7999
- const querySnapshot = await (0, import_firestore24.getDocs)(q);
8153
+ const querySnapshot = await (0, import_firestore26.getDocs)(q);
8000
8154
  const documents = [];
8001
8155
  let lastVisible = null;
8002
- querySnapshot.forEach((doc30) => {
8003
- documents.push(doc30.data());
8004
- lastVisible = doc30;
8156
+ querySnapshot.forEach((doc32) => {
8157
+ documents.push(doc32.data());
8158
+ lastVisible = doc32;
8005
8159
  });
8006
8160
  return {
8007
8161
  documents,
@@ -8016,21 +8170,21 @@ var FilledDocumentService = class extends BaseService {
8016
8170
  * @returns Array of filled documents and the last document for pagination
8017
8171
  */
8018
8172
  async getFilledDocumentsByTemplate(templateId, pageSize = 20, lastDoc) {
8019
- let q = (0, import_firestore24.query)(
8173
+ let q = (0, import_firestore26.query)(
8020
8174
  this.collectionRef,
8021
- (0, import_firestore24.where)("templateId", "==", templateId),
8022
- (0, import_firestore24.orderBy)("updatedAt", "desc"),
8023
- (0, import_firestore24.limit)(pageSize)
8175
+ (0, import_firestore26.where)("templateId", "==", templateId),
8176
+ (0, import_firestore26.orderBy)("updatedAt", "desc"),
8177
+ (0, import_firestore26.limit)(pageSize)
8024
8178
  );
8025
8179
  if (lastDoc) {
8026
- q = (0, import_firestore24.query)(q, (0, import_firestore24.startAfter)(lastDoc));
8180
+ q = (0, import_firestore26.query)(q, (0, import_firestore26.startAfter)(lastDoc));
8027
8181
  }
8028
- const querySnapshot = await (0, import_firestore24.getDocs)(q);
8182
+ const querySnapshot = await (0, import_firestore26.getDocs)(q);
8029
8183
  const documents = [];
8030
8184
  let lastVisible = null;
8031
- querySnapshot.forEach((doc30) => {
8032
- documents.push(doc30.data());
8033
- lastVisible = doc30;
8185
+ querySnapshot.forEach((doc32) => {
8186
+ documents.push(doc32.data());
8187
+ lastVisible = doc32;
8034
8188
  });
8035
8189
  return {
8036
8190
  documents,
@@ -8045,21 +8199,21 @@ var FilledDocumentService = class extends BaseService {
8045
8199
  * @returns Array of filled documents and the last document for pagination
8046
8200
  */
8047
8201
  async getFilledDocumentsByStatus(status, pageSize = 20, lastDoc) {
8048
- let q = (0, import_firestore24.query)(
8202
+ let q = (0, import_firestore26.query)(
8049
8203
  this.collectionRef,
8050
- (0, import_firestore24.where)("status", "==", status),
8051
- (0, import_firestore24.orderBy)("updatedAt", "desc"),
8052
- (0, import_firestore24.limit)(pageSize)
8204
+ (0, import_firestore26.where)("status", "==", status),
8205
+ (0, import_firestore26.orderBy)("updatedAt", "desc"),
8206
+ (0, import_firestore26.limit)(pageSize)
8053
8207
  );
8054
8208
  if (lastDoc) {
8055
- q = (0, import_firestore24.query)(q, (0, import_firestore24.startAfter)(lastDoc));
8209
+ q = (0, import_firestore26.query)(q, (0, import_firestore26.startAfter)(lastDoc));
8056
8210
  }
8057
- const querySnapshot = await (0, import_firestore24.getDocs)(q);
8211
+ const querySnapshot = await (0, import_firestore26.getDocs)(q);
8058
8212
  const documents = [];
8059
8213
  let lastVisible = null;
8060
- querySnapshot.forEach((doc30) => {
8061
- documents.push(doc30.data());
8062
- lastVisible = doc30;
8214
+ querySnapshot.forEach((doc32) => {
8215
+ documents.push(doc32.data());
8216
+ lastVisible = doc32;
8063
8217
  });
8064
8218
  return {
8065
8219
  documents,
@@ -8069,7 +8223,7 @@ var FilledDocumentService = class extends BaseService {
8069
8223
  };
8070
8224
 
8071
8225
  // src/services/calendar/calendar-refactored.service.ts
8072
- var import_firestore34 = require("firebase/firestore");
8226
+ var import_firestore36 = require("firebase/firestore");
8073
8227
 
8074
8228
  // src/types/calendar/synced-calendar.types.ts
8075
8229
  var SyncedCalendarProvider = /* @__PURE__ */ ((SyncedCalendarProvider3) => {
@@ -8081,15 +8235,15 @@ var SyncedCalendarProvider = /* @__PURE__ */ ((SyncedCalendarProvider3) => {
8081
8235
  var SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
8082
8236
 
8083
8237
  // src/services/calendar/calendar-refactored.service.ts
8084
- var import_firestore35 = require("firebase/firestore");
8238
+ var import_firestore37 = require("firebase/firestore");
8085
8239
 
8086
8240
  // src/validations/calendar.schema.ts
8087
8241
  var import_zod21 = require("zod");
8088
- var import_firestore26 = require("firebase/firestore");
8242
+ var import_firestore28 = require("firebase/firestore");
8089
8243
 
8090
8244
  // src/validations/profile-info.schema.ts
8091
8245
  var import_zod20 = require("zod");
8092
- var import_firestore25 = require("firebase/firestore");
8246
+ var import_firestore27 = require("firebase/firestore");
8093
8247
  var clinicInfoSchema2 = import_zod20.z.object({
8094
8248
  id: import_zod20.z.string(),
8095
8249
  featuredPhoto: import_zod20.z.string(),
@@ -8111,19 +8265,19 @@ var patientProfileInfoSchema = import_zod20.z.object({
8111
8265
  fullName: import_zod20.z.string(),
8112
8266
  email: import_zod20.z.string().email(),
8113
8267
  phone: import_zod20.z.string().nullable(),
8114
- dateOfBirth: import_zod20.z.instanceof(import_firestore25.Timestamp),
8268
+ dateOfBirth: import_zod20.z.instanceof(import_firestore27.Timestamp),
8115
8269
  gender: import_zod20.z.nativeEnum(Gender)
8116
8270
  });
8117
8271
 
8118
8272
  // src/validations/calendar.schema.ts
8119
8273
  var MIN_APPOINTMENT_DURATION = 15;
8120
8274
  var calendarEventTimeSchema = import_zod21.z.object({
8121
- start: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp)),
8122
- end: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp))
8275
+ start: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore28.Timestamp)),
8276
+ end: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore28.Timestamp))
8123
8277
  }).refine(
8124
8278
  (data) => {
8125
- const startDate = data.start instanceof import_firestore26.Timestamp ? data.start.toDate() : data.start;
8126
- const endDate = data.end instanceof import_firestore26.Timestamp ? data.end.toDate() : data.end;
8279
+ const startDate = data.start instanceof import_firestore28.Timestamp ? data.start.toDate() : data.start;
8280
+ const endDate = data.end instanceof import_firestore28.Timestamp ? data.end.toDate() : data.end;
8127
8281
  return startDate < endDate;
8128
8282
  },
8129
8283
  {
@@ -8132,7 +8286,7 @@ var calendarEventTimeSchema = import_zod21.z.object({
8132
8286
  }
8133
8287
  ).refine(
8134
8288
  (data) => {
8135
- const startDate = data.start instanceof import_firestore26.Timestamp ? data.start.toDate() : data.start;
8289
+ const startDate = data.start instanceof import_firestore28.Timestamp ? data.start.toDate() : data.start;
8136
8290
  return startDate > /* @__PURE__ */ new Date();
8137
8291
  },
8138
8292
  {
@@ -8151,7 +8305,7 @@ var timeSlotSchema2 = import_zod21.z.object({
8151
8305
  var syncedCalendarEventSchema = import_zod21.z.object({
8152
8306
  eventId: import_zod21.z.string(),
8153
8307
  syncedCalendarProvider: import_zod21.z.nativeEnum(SyncedCalendarProvider),
8154
- syncedAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp))
8308
+ syncedAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore28.Timestamp))
8155
8309
  });
8156
8310
  var procedureInfoSchema = import_zod21.z.object({
8157
8311
  name: import_zod21.z.string(),
@@ -8253,47 +8407,47 @@ var calendarEventSchema = import_zod21.z.object({
8253
8407
  status: import_zod21.z.nativeEnum(CalendarEventStatus),
8254
8408
  syncStatus: import_zod21.z.nativeEnum(CalendarSyncStatus),
8255
8409
  eventType: import_zod21.z.nativeEnum(CalendarEventType),
8256
- createdAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp)),
8257
- updatedAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp))
8410
+ createdAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore28.Timestamp)),
8411
+ updatedAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore28.Timestamp))
8258
8412
  });
8259
8413
 
8260
8414
  // src/services/calendar/utils/clinic.utils.ts
8261
- var import_firestore28 = require("firebase/firestore");
8415
+ var import_firestore30 = require("firebase/firestore");
8262
8416
 
8263
8417
  // src/services/calendar/utils/docs.utils.ts
8264
- var import_firestore27 = require("firebase/firestore");
8418
+ var import_firestore29 = require("firebase/firestore");
8265
8419
  function getPractitionerCalendarEventDocRef(db, practitionerId, eventId) {
8266
- return (0, import_firestore27.doc)(
8420
+ return (0, import_firestore29.doc)(
8267
8421
  db,
8268
8422
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${CALENDAR_COLLECTION}/${eventId}`
8269
8423
  );
8270
8424
  }
8271
8425
  function getPatientCalendarEventDocRef(db, patientId, eventId) {
8272
- return (0, import_firestore27.doc)(
8426
+ return (0, import_firestore29.doc)(
8273
8427
  db,
8274
8428
  `${PATIENTS_COLLECTION}/${patientId}/${CALENDAR_COLLECTION}/${eventId}`
8275
8429
  );
8276
8430
  }
8277
8431
  function getClinicCalendarEventDocRef(db, clinicId, eventId) {
8278
- return (0, import_firestore27.doc)(
8432
+ return (0, import_firestore29.doc)(
8279
8433
  db,
8280
8434
  `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}/${eventId}`
8281
8435
  );
8282
8436
  }
8283
8437
  function getPractitionerSyncedCalendarDocRef(db, practitionerId, syncedCalendarId) {
8284
- return (0, import_firestore27.doc)(
8438
+ return (0, import_firestore29.doc)(
8285
8439
  db,
8286
8440
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/syncedCalendars/${syncedCalendarId}`
8287
8441
  );
8288
8442
  }
8289
8443
  function getPatientSyncedCalendarDocRef(db, patientId, syncedCalendarId) {
8290
- return (0, import_firestore27.doc)(
8444
+ return (0, import_firestore29.doc)(
8291
8445
  db,
8292
8446
  `${PATIENTS_COLLECTION}/${patientId}/syncedCalendars/${syncedCalendarId}`
8293
8447
  );
8294
8448
  }
8295
8449
  function getClinicSyncedCalendarDocRef(db, clinicId, syncedCalendarId) {
8296
- return (0, import_firestore27.doc)(
8450
+ return (0, import_firestore29.doc)(
8297
8451
  db,
8298
8452
  `${CLINICS_COLLECTION}/${clinicId}/syncedCalendars/${syncedCalendarId}`
8299
8453
  );
@@ -8306,31 +8460,31 @@ async function createClinicCalendarEventUtil(db, clinicId, eventData, generateId
8306
8460
  const newEvent = {
8307
8461
  id: eventId,
8308
8462
  ...eventData,
8309
- createdAt: (0, import_firestore28.serverTimestamp)(),
8310
- updatedAt: (0, import_firestore28.serverTimestamp)()
8463
+ createdAt: (0, import_firestore30.serverTimestamp)(),
8464
+ updatedAt: (0, import_firestore30.serverTimestamp)()
8311
8465
  };
8312
- await (0, import_firestore28.setDoc)(eventRef, newEvent);
8466
+ await (0, import_firestore30.setDoc)(eventRef, newEvent);
8313
8467
  return {
8314
8468
  ...newEvent,
8315
- createdAt: import_firestore28.Timestamp.now(),
8316
- updatedAt: import_firestore28.Timestamp.now()
8469
+ createdAt: import_firestore30.Timestamp.now(),
8470
+ updatedAt: import_firestore30.Timestamp.now()
8317
8471
  };
8318
8472
  }
8319
8473
  async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData) {
8320
8474
  const eventRef = getClinicCalendarEventDocRef(db, clinicId, eventId);
8321
8475
  const updates = {
8322
8476
  ...updateData,
8323
- updatedAt: (0, import_firestore28.serverTimestamp)()
8477
+ updatedAt: (0, import_firestore30.serverTimestamp)()
8324
8478
  };
8325
- await (0, import_firestore28.updateDoc)(eventRef, updates);
8326
- const updatedDoc = await (0, import_firestore28.getDoc)(eventRef);
8479
+ await (0, import_firestore30.updateDoc)(eventRef, updates);
8480
+ const updatedDoc = await (0, import_firestore30.getDoc)(eventRef);
8327
8481
  if (!updatedDoc.exists()) {
8328
8482
  throw new Error("Event not found after update");
8329
8483
  }
8330
8484
  return updatedDoc.data();
8331
8485
  }
8332
8486
  async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
8333
- const clinicDoc = await (0, import_firestore28.getDoc)((0, import_firestore28.doc)(db, `clinics/${clinicId}`));
8487
+ const clinicDoc = await (0, import_firestore30.getDoc)((0, import_firestore30.doc)(db, `clinics/${clinicId}`));
8334
8488
  if (!clinicDoc.exists()) {
8335
8489
  throw new Error(`Clinic with ID ${clinicId} not found`);
8336
8490
  }
@@ -8339,8 +8493,8 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
8339
8493
  if (!clinicGroupId) {
8340
8494
  return false;
8341
8495
  }
8342
- const clinicGroupDoc = await (0, import_firestore28.getDoc)(
8343
- (0, import_firestore28.doc)(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
8496
+ const clinicGroupDoc = await (0, import_firestore30.getDoc)(
8497
+ (0, import_firestore30.doc)(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
8344
8498
  );
8345
8499
  if (!clinicGroupDoc.exists()) {
8346
8500
  return false;
@@ -8350,31 +8504,31 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
8350
8504
  }
8351
8505
 
8352
8506
  // src/services/calendar/utils/patient.utils.ts
8353
- var import_firestore29 = require("firebase/firestore");
8507
+ var import_firestore31 = require("firebase/firestore");
8354
8508
  async function createPatientCalendarEventUtil(db, patientId, eventData, generateId2) {
8355
8509
  const eventId = generateId2();
8356
8510
  const eventRef = getPatientCalendarEventDocRef(db, patientId, eventId);
8357
8511
  const newEvent = {
8358
8512
  id: eventId,
8359
8513
  ...eventData,
8360
- createdAt: (0, import_firestore29.serverTimestamp)(),
8361
- updatedAt: (0, import_firestore29.serverTimestamp)()
8514
+ createdAt: (0, import_firestore31.serverTimestamp)(),
8515
+ updatedAt: (0, import_firestore31.serverTimestamp)()
8362
8516
  };
8363
- await (0, import_firestore29.setDoc)(eventRef, newEvent);
8517
+ await (0, import_firestore31.setDoc)(eventRef, newEvent);
8364
8518
  return {
8365
8519
  ...newEvent,
8366
- createdAt: import_firestore29.Timestamp.now(),
8367
- updatedAt: import_firestore29.Timestamp.now()
8520
+ createdAt: import_firestore31.Timestamp.now(),
8521
+ updatedAt: import_firestore31.Timestamp.now()
8368
8522
  };
8369
8523
  }
8370
8524
  async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData) {
8371
8525
  const eventRef = getPatientCalendarEventDocRef(db, patientId, eventId);
8372
8526
  const updates = {
8373
8527
  ...updateData,
8374
- updatedAt: (0, import_firestore29.serverTimestamp)()
8528
+ updatedAt: (0, import_firestore31.serverTimestamp)()
8375
8529
  };
8376
- await (0, import_firestore29.updateDoc)(eventRef, updates);
8377
- const updatedDoc = await (0, import_firestore29.getDoc)(eventRef);
8530
+ await (0, import_firestore31.updateDoc)(eventRef, updates);
8531
+ const updatedDoc = await (0, import_firestore31.getDoc)(eventRef);
8378
8532
  if (!updatedDoc.exists()) {
8379
8533
  throw new Error("Event not found after update");
8380
8534
  }
@@ -8382,7 +8536,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
8382
8536
  }
8383
8537
 
8384
8538
  // src/services/calendar/utils/practitioner.utils.ts
8385
- var import_firestore30 = require("firebase/firestore");
8539
+ var import_firestore32 = require("firebase/firestore");
8386
8540
  async function createPractitionerCalendarEventUtil(db, practitionerId, eventData, generateId2) {
8387
8541
  const eventId = generateId2();
8388
8542
  const eventRef = getPractitionerCalendarEventDocRef(
@@ -8393,14 +8547,14 @@ async function createPractitionerCalendarEventUtil(db, practitionerId, eventData
8393
8547
  const newEvent = {
8394
8548
  id: eventId,
8395
8549
  ...eventData,
8396
- createdAt: (0, import_firestore30.serverTimestamp)(),
8397
- updatedAt: (0, import_firestore30.serverTimestamp)()
8550
+ createdAt: (0, import_firestore32.serverTimestamp)(),
8551
+ updatedAt: (0, import_firestore32.serverTimestamp)()
8398
8552
  };
8399
- await (0, import_firestore30.setDoc)(eventRef, newEvent);
8553
+ await (0, import_firestore32.setDoc)(eventRef, newEvent);
8400
8554
  return {
8401
8555
  ...newEvent,
8402
- createdAt: import_firestore30.Timestamp.now(),
8403
- updatedAt: import_firestore30.Timestamp.now()
8556
+ createdAt: import_firestore32.Timestamp.now(),
8557
+ updatedAt: import_firestore32.Timestamp.now()
8404
8558
  };
8405
8559
  }
8406
8560
  async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId, updateData) {
@@ -8411,10 +8565,10 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
8411
8565
  );
8412
8566
  const updates = {
8413
8567
  ...updateData,
8414
- updatedAt: (0, import_firestore30.serverTimestamp)()
8568
+ updatedAt: (0, import_firestore32.serverTimestamp)()
8415
8569
  };
8416
- await (0, import_firestore30.updateDoc)(eventRef, updates);
8417
- const updatedDoc = await (0, import_firestore30.getDoc)(eventRef);
8570
+ await (0, import_firestore32.updateDoc)(eventRef, updates);
8571
+ const updatedDoc = await (0, import_firestore32.getDoc)(eventRef);
8418
8572
  if (!updatedDoc.exists()) {
8419
8573
  throw new Error("Event not found after update");
8420
8574
  }
@@ -8472,7 +8626,7 @@ async function updateAppointmentUtil(db, clinicId, practitionerId, patientId, ev
8472
8626
  }
8473
8627
 
8474
8628
  // src/services/calendar/utils/calendar-event.utils.ts
8475
- var import_firestore31 = require("firebase/firestore");
8629
+ var import_firestore33 = require("firebase/firestore");
8476
8630
  async function searchCalendarEventsUtil(db, params) {
8477
8631
  const { searchLocation, entityId, ...filters } = params;
8478
8632
  let baseCollectionPath;
@@ -8515,7 +8669,7 @@ async function searchCalendarEventsUtil(db, params) {
8515
8669
  );
8516
8670
  }
8517
8671
  baseCollectionPath = `${CLINICS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
8518
- constraints.push((0, import_firestore31.where)("clinicBranchId", "==", entityId));
8672
+ constraints.push((0, import_firestore33.where)("clinicBranchId", "==", entityId));
8519
8673
  if (filters.clinicId && filters.clinicId !== entityId) {
8520
8674
  console.warn(
8521
8675
  `Provided clinicId filter (${filters.clinicId}) does not match search entityId (${entityId}). Returning empty results.`
@@ -8527,36 +8681,36 @@ async function searchCalendarEventsUtil(db, params) {
8527
8681
  default:
8528
8682
  throw new Error(`Invalid search location: ${searchLocation}`);
8529
8683
  }
8530
- const collectionRef = (0, import_firestore31.collection)(db, baseCollectionPath);
8684
+ const collectionRef = (0, import_firestore33.collection)(db, baseCollectionPath);
8531
8685
  if (filters.clinicId) {
8532
- constraints.push((0, import_firestore31.where)("clinicBranchId", "==", filters.clinicId));
8686
+ constraints.push((0, import_firestore33.where)("clinicBranchId", "==", filters.clinicId));
8533
8687
  }
8534
8688
  if (filters.practitionerId) {
8535
8689
  constraints.push(
8536
- (0, import_firestore31.where)("practitionerProfileId", "==", filters.practitionerId)
8690
+ (0, import_firestore33.where)("practitionerProfileId", "==", filters.practitionerId)
8537
8691
  );
8538
8692
  }
8539
8693
  if (filters.patientId) {
8540
- constraints.push((0, import_firestore31.where)("patientProfileId", "==", filters.patientId));
8694
+ constraints.push((0, import_firestore33.where)("patientProfileId", "==", filters.patientId));
8541
8695
  }
8542
8696
  if (filters.procedureId) {
8543
- constraints.push((0, import_firestore31.where)("procedureId", "==", filters.procedureId));
8697
+ constraints.push((0, import_firestore33.where)("procedureId", "==", filters.procedureId));
8544
8698
  }
8545
8699
  if (filters.eventStatus) {
8546
- constraints.push((0, import_firestore31.where)("status", "==", filters.eventStatus));
8700
+ constraints.push((0, import_firestore33.where)("status", "==", filters.eventStatus));
8547
8701
  }
8548
8702
  if (filters.eventType) {
8549
- constraints.push((0, import_firestore31.where)("eventType", "==", filters.eventType));
8703
+ constraints.push((0, import_firestore33.where)("eventType", "==", filters.eventType));
8550
8704
  }
8551
8705
  if (filters.dateRange) {
8552
- constraints.push((0, import_firestore31.where)("eventTime.start", ">=", filters.dateRange.start));
8553
- constraints.push((0, import_firestore31.where)("eventTime.start", "<=", filters.dateRange.end));
8706
+ constraints.push((0, import_firestore33.where)("eventTime.start", ">=", filters.dateRange.start));
8707
+ constraints.push((0, import_firestore33.where)("eventTime.start", "<=", filters.dateRange.end));
8554
8708
  }
8555
8709
  try {
8556
- const finalQuery = (0, import_firestore31.query)(collectionRef, ...constraints);
8557
- const querySnapshot = await (0, import_firestore31.getDocs)(finalQuery);
8710
+ const finalQuery = (0, import_firestore33.query)(collectionRef, ...constraints);
8711
+ const querySnapshot = await (0, import_firestore33.getDocs)(finalQuery);
8558
8712
  const events = querySnapshot.docs.map(
8559
- (doc30) => ({ id: doc30.id, ...doc30.data() })
8713
+ (doc32) => ({ id: doc32.id, ...doc32.data() })
8560
8714
  );
8561
8715
  return events;
8562
8716
  } catch (error) {
@@ -8566,7 +8720,7 @@ async function searchCalendarEventsUtil(db, params) {
8566
8720
  }
8567
8721
 
8568
8722
  // src/services/calendar/utils/synced-calendar.utils.ts
8569
- var import_firestore32 = require("firebase/firestore");
8723
+ var import_firestore34 = require("firebase/firestore");
8570
8724
  async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendarData, generateId2) {
8571
8725
  const calendarId = generateId2();
8572
8726
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -8577,14 +8731,14 @@ async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendar
8577
8731
  const newCalendar = {
8578
8732
  id: calendarId,
8579
8733
  ...calendarData,
8580
- createdAt: (0, import_firestore32.serverTimestamp)(),
8581
- updatedAt: (0, import_firestore32.serverTimestamp)()
8734
+ createdAt: (0, import_firestore34.serverTimestamp)(),
8735
+ updatedAt: (0, import_firestore34.serverTimestamp)()
8582
8736
  };
8583
- await (0, import_firestore32.setDoc)(calendarRef, newCalendar);
8737
+ await (0, import_firestore34.setDoc)(calendarRef, newCalendar);
8584
8738
  return {
8585
8739
  ...newCalendar,
8586
- createdAt: import_firestore32.Timestamp.now(),
8587
- updatedAt: import_firestore32.Timestamp.now()
8740
+ createdAt: import_firestore34.Timestamp.now(),
8741
+ updatedAt: import_firestore34.Timestamp.now()
8588
8742
  };
8589
8743
  }
8590
8744
  async function createPatientSyncedCalendarUtil(db, patientId, calendarData, generateId2) {
@@ -8593,14 +8747,14 @@ async function createPatientSyncedCalendarUtil(db, patientId, calendarData, gene
8593
8747
  const newCalendar = {
8594
8748
  id: calendarId,
8595
8749
  ...calendarData,
8596
- createdAt: (0, import_firestore32.serverTimestamp)(),
8597
- updatedAt: (0, import_firestore32.serverTimestamp)()
8750
+ createdAt: (0, import_firestore34.serverTimestamp)(),
8751
+ updatedAt: (0, import_firestore34.serverTimestamp)()
8598
8752
  };
8599
- await (0, import_firestore32.setDoc)(calendarRef, newCalendar);
8753
+ await (0, import_firestore34.setDoc)(calendarRef, newCalendar);
8600
8754
  return {
8601
8755
  ...newCalendar,
8602
- createdAt: import_firestore32.Timestamp.now(),
8603
- updatedAt: import_firestore32.Timestamp.now()
8756
+ createdAt: import_firestore34.Timestamp.now(),
8757
+ updatedAt: import_firestore34.Timestamp.now()
8604
8758
  };
8605
8759
  }
8606
8760
  async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, generateId2) {
@@ -8609,14 +8763,14 @@ async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, genera
8609
8763
  const newCalendar = {
8610
8764
  id: calendarId,
8611
8765
  ...calendarData,
8612
- createdAt: (0, import_firestore32.serverTimestamp)(),
8613
- updatedAt: (0, import_firestore32.serverTimestamp)()
8766
+ createdAt: (0, import_firestore34.serverTimestamp)(),
8767
+ updatedAt: (0, import_firestore34.serverTimestamp)()
8614
8768
  };
8615
- await (0, import_firestore32.setDoc)(calendarRef, newCalendar);
8769
+ await (0, import_firestore34.setDoc)(calendarRef, newCalendar);
8616
8770
  return {
8617
8771
  ...newCalendar,
8618
- createdAt: import_firestore32.Timestamp.now(),
8619
- updatedAt: import_firestore32.Timestamp.now()
8772
+ createdAt: import_firestore34.Timestamp.now(),
8773
+ updatedAt: import_firestore34.Timestamp.now()
8620
8774
  };
8621
8775
  }
8622
8776
  async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId) {
@@ -8625,54 +8779,54 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
8625
8779
  practitionerId,
8626
8780
  calendarId
8627
8781
  );
8628
- const calendarDoc = await (0, import_firestore32.getDoc)(calendarRef);
8782
+ const calendarDoc = await (0, import_firestore34.getDoc)(calendarRef);
8629
8783
  if (!calendarDoc.exists()) {
8630
8784
  return null;
8631
8785
  }
8632
8786
  return calendarDoc.data();
8633
8787
  }
8634
8788
  async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
8635
- const calendarsRef = (0, import_firestore32.collection)(
8789
+ const calendarsRef = (0, import_firestore34.collection)(
8636
8790
  db,
8637
8791
  `practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
8638
8792
  );
8639
- const q = (0, import_firestore32.query)(calendarsRef, (0, import_firestore32.orderBy)("createdAt", "desc"));
8640
- const querySnapshot = await (0, import_firestore32.getDocs)(q);
8641
- return querySnapshot.docs.map((doc30) => doc30.data());
8793
+ const q = (0, import_firestore34.query)(calendarsRef, (0, import_firestore34.orderBy)("createdAt", "desc"));
8794
+ const querySnapshot = await (0, import_firestore34.getDocs)(q);
8795
+ return querySnapshot.docs.map((doc32) => doc32.data());
8642
8796
  }
8643
8797
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
8644
8798
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
8645
- const calendarDoc = await (0, import_firestore32.getDoc)(calendarRef);
8799
+ const calendarDoc = await (0, import_firestore34.getDoc)(calendarRef);
8646
8800
  if (!calendarDoc.exists()) {
8647
8801
  return null;
8648
8802
  }
8649
8803
  return calendarDoc.data();
8650
8804
  }
8651
8805
  async function getPatientSyncedCalendarsUtil(db, patientId) {
8652
- const calendarsRef = (0, import_firestore32.collection)(
8806
+ const calendarsRef = (0, import_firestore34.collection)(
8653
8807
  db,
8654
8808
  `patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
8655
8809
  );
8656
- const q = (0, import_firestore32.query)(calendarsRef, (0, import_firestore32.orderBy)("createdAt", "desc"));
8657
- const querySnapshot = await (0, import_firestore32.getDocs)(q);
8658
- return querySnapshot.docs.map((doc30) => doc30.data());
8810
+ const q = (0, import_firestore34.query)(calendarsRef, (0, import_firestore34.orderBy)("createdAt", "desc"));
8811
+ const querySnapshot = await (0, import_firestore34.getDocs)(q);
8812
+ return querySnapshot.docs.map((doc32) => doc32.data());
8659
8813
  }
8660
8814
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
8661
8815
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
8662
- const calendarDoc = await (0, import_firestore32.getDoc)(calendarRef);
8816
+ const calendarDoc = await (0, import_firestore34.getDoc)(calendarRef);
8663
8817
  if (!calendarDoc.exists()) {
8664
8818
  return null;
8665
8819
  }
8666
8820
  return calendarDoc.data();
8667
8821
  }
8668
8822
  async function getClinicSyncedCalendarsUtil(db, clinicId) {
8669
- const calendarsRef = (0, import_firestore32.collection)(
8823
+ const calendarsRef = (0, import_firestore34.collection)(
8670
8824
  db,
8671
8825
  `clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
8672
8826
  );
8673
- const q = (0, import_firestore32.query)(calendarsRef, (0, import_firestore32.orderBy)("createdAt", "desc"));
8674
- const querySnapshot = await (0, import_firestore32.getDocs)(q);
8675
- return querySnapshot.docs.map((doc30) => doc30.data());
8827
+ const q = (0, import_firestore34.query)(calendarsRef, (0, import_firestore34.orderBy)("createdAt", "desc"));
8828
+ const querySnapshot = await (0, import_firestore34.getDocs)(q);
8829
+ return querySnapshot.docs.map((doc32) => doc32.data());
8676
8830
  }
8677
8831
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
8678
8832
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -8682,10 +8836,10 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
8682
8836
  );
8683
8837
  const updates = {
8684
8838
  ...updateData,
8685
- updatedAt: (0, import_firestore32.serverTimestamp)()
8839
+ updatedAt: (0, import_firestore34.serverTimestamp)()
8686
8840
  };
8687
- await (0, import_firestore32.updateDoc)(calendarRef, updates);
8688
- const updatedDoc = await (0, import_firestore32.getDoc)(calendarRef);
8841
+ await (0, import_firestore34.updateDoc)(calendarRef, updates);
8842
+ const updatedDoc = await (0, import_firestore34.getDoc)(calendarRef);
8689
8843
  if (!updatedDoc.exists()) {
8690
8844
  throw new Error("Synced calendar not found after update");
8691
8845
  }
@@ -8695,10 +8849,10 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
8695
8849
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
8696
8850
  const updates = {
8697
8851
  ...updateData,
8698
- updatedAt: (0, import_firestore32.serverTimestamp)()
8852
+ updatedAt: (0, import_firestore34.serverTimestamp)()
8699
8853
  };
8700
- await (0, import_firestore32.updateDoc)(calendarRef, updates);
8701
- const updatedDoc = await (0, import_firestore32.getDoc)(calendarRef);
8854
+ await (0, import_firestore34.updateDoc)(calendarRef, updates);
8855
+ const updatedDoc = await (0, import_firestore34.getDoc)(calendarRef);
8702
8856
  if (!updatedDoc.exists()) {
8703
8857
  throw new Error("Synced calendar not found after update");
8704
8858
  }
@@ -8708,10 +8862,10 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
8708
8862
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
8709
8863
  const updates = {
8710
8864
  ...updateData,
8711
- updatedAt: (0, import_firestore32.serverTimestamp)()
8865
+ updatedAt: (0, import_firestore34.serverTimestamp)()
8712
8866
  };
8713
- await (0, import_firestore32.updateDoc)(calendarRef, updates);
8714
- const updatedDoc = await (0, import_firestore32.getDoc)(calendarRef);
8867
+ await (0, import_firestore34.updateDoc)(calendarRef, updates);
8868
+ const updatedDoc = await (0, import_firestore34.getDoc)(calendarRef);
8715
8869
  if (!updatedDoc.exists()) {
8716
8870
  throw new Error("Synced calendar not found after update");
8717
8871
  }
@@ -8723,19 +8877,19 @@ async function deletePractitionerSyncedCalendarUtil(db, practitionerId, calendar
8723
8877
  practitionerId,
8724
8878
  calendarId
8725
8879
  );
8726
- await (0, import_firestore32.deleteDoc)(calendarRef);
8880
+ await (0, import_firestore34.deleteDoc)(calendarRef);
8727
8881
  }
8728
8882
  async function deletePatientSyncedCalendarUtil(db, patientId, calendarId) {
8729
8883
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
8730
- await (0, import_firestore32.deleteDoc)(calendarRef);
8884
+ await (0, import_firestore34.deleteDoc)(calendarRef);
8731
8885
  }
8732
8886
  async function deleteClinicSyncedCalendarUtil(db, clinicId, calendarId) {
8733
8887
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
8734
- await (0, import_firestore32.deleteDoc)(calendarRef);
8888
+ await (0, import_firestore34.deleteDoc)(calendarRef);
8735
8889
  }
8736
8890
  async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarId) {
8737
8891
  const updateData = {
8738
- lastSyncedAt: import_firestore32.Timestamp.now()
8892
+ lastSyncedAt: import_firestore34.Timestamp.now()
8739
8893
  };
8740
8894
  switch (entityType) {
8741
8895
  case "practitioner":
@@ -8765,7 +8919,7 @@ async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarI
8765
8919
  }
8766
8920
 
8767
8921
  // src/services/calendar/utils/google-calendar.utils.ts
8768
- var import_firestore33 = require("firebase/firestore");
8922
+ var import_firestore35 = require("firebase/firestore");
8769
8923
  var GOOGLE_CALENDAR_API_URL = "https://www.googleapis.com/calendar/v3";
8770
8924
  var GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token";
8771
8925
  var CLIENT_ID = "your-client-id";
@@ -8885,7 +9039,7 @@ async function ensureValidToken(db, entityType, entityId, syncedCalendar) {
8885
9039
  tokenExpiry.setSeconds(tokenExpiry.getSeconds() + expiresIn);
8886
9040
  const updateData = {
8887
9041
  accessToken,
8888
- tokenExpiry: import_firestore33.Timestamp.fromDate(tokenExpiry)
9042
+ tokenExpiry: import_firestore35.Timestamp.fromDate(tokenExpiry)
8889
9043
  };
8890
9044
  switch (entityType) {
8891
9045
  case "practitioner":
@@ -9060,8 +9214,8 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
9060
9214
  eventName: googleEvent.summary || "External Event",
9061
9215
  eventLocation: googleEvent.location,
9062
9216
  eventTime: {
9063
- start: import_firestore33.Timestamp.fromDate(start),
9064
- end: import_firestore33.Timestamp.fromDate(end)
9217
+ start: import_firestore35.Timestamp.fromDate(start),
9218
+ end: import_firestore35.Timestamp.fromDate(end)
9065
9219
  },
9066
9220
  description: googleEvent.description || "",
9067
9221
  // External events are always set as CONFIRMED - status updates will happen externally
@@ -9075,7 +9229,7 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
9075
9229
  {
9076
9230
  eventId: googleEvent.id,
9077
9231
  syncedCalendarProvider: "google" /* GOOGLE */,
9078
- syncedAt: import_firestore33.Timestamp.now()
9232
+ syncedAt: import_firestore35.Timestamp.now()
9079
9233
  }
9080
9234
  ]
9081
9235
  };
@@ -9853,7 +10007,7 @@ var CalendarServiceV2 = class extends BaseService {
9853
10007
  return 0;
9854
10008
  }
9855
10009
  let importedEventsCount = 0;
9856
- const currentTime = import_firestore34.Timestamp.now();
10010
+ const currentTime = import_firestore36.Timestamp.now();
9857
10011
  for (const calendar of activeCalendars) {
9858
10012
  try {
9859
10013
  let externalEvents = [];
@@ -9920,7 +10074,7 @@ var CalendarServiceV2 = class extends BaseService {
9920
10074
  async createDoctorBlockingEvent(doctorId, eventData) {
9921
10075
  try {
9922
10076
  const eventId = this.generateId();
9923
- const eventRef = (0, import_firestore35.doc)(
10077
+ const eventRef = (0, import_firestore37.doc)(
9924
10078
  this.db,
9925
10079
  PRACTITIONERS_COLLECTION,
9926
10080
  doctorId,
@@ -9930,14 +10084,14 @@ var CalendarServiceV2 = class extends BaseService {
9930
10084
  const newEvent = {
9931
10085
  id: eventId,
9932
10086
  ...eventData,
9933
- createdAt: (0, import_firestore34.serverTimestamp)(),
9934
- updatedAt: (0, import_firestore34.serverTimestamp)()
10087
+ createdAt: (0, import_firestore36.serverTimestamp)(),
10088
+ updatedAt: (0, import_firestore36.serverTimestamp)()
9935
10089
  };
9936
- await (0, import_firestore35.setDoc)(eventRef, newEvent);
10090
+ await (0, import_firestore37.setDoc)(eventRef, newEvent);
9937
10091
  return {
9938
10092
  ...newEvent,
9939
- createdAt: import_firestore34.Timestamp.now(),
9940
- updatedAt: import_firestore34.Timestamp.now()
10093
+ createdAt: import_firestore36.Timestamp.now(),
10094
+ updatedAt: import_firestore36.Timestamp.now()
9941
10095
  };
9942
10096
  } catch (error) {
9943
10097
  console.error(
@@ -9955,8 +10109,8 @@ var CalendarServiceV2 = class extends BaseService {
9955
10109
  */
9956
10110
  async synchronizeExternalCalendars(lookbackDays = 7, lookforwardDays = 30) {
9957
10111
  try {
9958
- const practitionersRef = (0, import_firestore35.collection)(this.db, PRACTITIONERS_COLLECTION);
9959
- const practitionersSnapshot = await (0, import_firestore35.getDocs)(practitionersRef);
10112
+ const practitionersRef = (0, import_firestore37.collection)(this.db, PRACTITIONERS_COLLECTION);
10113
+ const practitionersSnapshot = await (0, import_firestore37.getDocs)(practitionersRef);
9960
10114
  const startDate = /* @__PURE__ */ new Date();
9961
10115
  startDate.setDate(startDate.getDate() - lookbackDays);
9962
10116
  const endDate = /* @__PURE__ */ new Date();
@@ -10014,22 +10168,22 @@ var CalendarServiceV2 = class extends BaseService {
10014
10168
  async updateExistingEventsFromExternalCalendars(doctorId, startDate, endDate) {
10015
10169
  var _a;
10016
10170
  try {
10017
- const eventsRef = (0, import_firestore35.collection)(
10171
+ const eventsRef = (0, import_firestore37.collection)(
10018
10172
  this.db,
10019
10173
  PRACTITIONERS_COLLECTION,
10020
10174
  doctorId,
10021
10175
  CALENDAR_COLLECTION
10022
10176
  );
10023
- const q = (0, import_firestore35.query)(
10177
+ const q = (0, import_firestore37.query)(
10024
10178
  eventsRef,
10025
- (0, import_firestore35.where)("syncStatus", "==", "external" /* EXTERNAL */),
10026
- (0, import_firestore35.where)("eventTime.start", ">=", import_firestore34.Timestamp.fromDate(startDate)),
10027
- (0, import_firestore35.where)("eventTime.start", "<=", import_firestore34.Timestamp.fromDate(endDate))
10028
- );
10029
- const eventsSnapshot = await (0, import_firestore35.getDocs)(q);
10030
- const events = eventsSnapshot.docs.map((doc30) => ({
10031
- id: doc30.id,
10032
- ...doc30.data()
10179
+ (0, import_firestore37.where)("syncStatus", "==", "external" /* EXTERNAL */),
10180
+ (0, import_firestore37.where)("eventTime.start", ">=", import_firestore36.Timestamp.fromDate(startDate)),
10181
+ (0, import_firestore37.where)("eventTime.start", "<=", import_firestore36.Timestamp.fromDate(endDate))
10182
+ );
10183
+ const eventsSnapshot = await (0, import_firestore37.getDocs)(q);
10184
+ const events = eventsSnapshot.docs.map((doc32) => ({
10185
+ id: doc32.id,
10186
+ ...doc32.data()
10033
10187
  }));
10034
10188
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
10035
10189
  doctorId
@@ -10133,21 +10287,21 @@ var CalendarServiceV2 = class extends BaseService {
10133
10287
  const endTime = new Date(
10134
10288
  externalEvent.end.dateTime || externalEvent.end.date
10135
10289
  );
10136
- const eventRef = (0, import_firestore35.doc)(
10290
+ const eventRef = (0, import_firestore37.doc)(
10137
10291
  this.db,
10138
10292
  PRACTITIONERS_COLLECTION,
10139
10293
  doctorId,
10140
10294
  CALENDAR_COLLECTION,
10141
10295
  eventId
10142
10296
  );
10143
- await (0, import_firestore35.updateDoc)(eventRef, {
10297
+ await (0, import_firestore37.updateDoc)(eventRef, {
10144
10298
  eventName: externalEvent.summary || "External Event",
10145
10299
  eventTime: {
10146
- start: import_firestore34.Timestamp.fromDate(startTime),
10147
- end: import_firestore34.Timestamp.fromDate(endTime)
10300
+ start: import_firestore36.Timestamp.fromDate(startTime),
10301
+ end: import_firestore36.Timestamp.fromDate(endTime)
10148
10302
  },
10149
10303
  description: externalEvent.description || "",
10150
- updatedAt: (0, import_firestore34.serverTimestamp)()
10304
+ updatedAt: (0, import_firestore36.serverTimestamp)()
10151
10305
  });
10152
10306
  console.log(`Updated local event ${eventId} from external event`);
10153
10307
  } catch (error) {
@@ -10165,16 +10319,16 @@ var CalendarServiceV2 = class extends BaseService {
10165
10319
  */
10166
10320
  async updateEventStatus(doctorId, eventId, status) {
10167
10321
  try {
10168
- const eventRef = (0, import_firestore35.doc)(
10322
+ const eventRef = (0, import_firestore37.doc)(
10169
10323
  this.db,
10170
10324
  PRACTITIONERS_COLLECTION,
10171
10325
  doctorId,
10172
10326
  CALENDAR_COLLECTION,
10173
10327
  eventId
10174
10328
  );
10175
- await (0, import_firestore35.updateDoc)(eventRef, {
10329
+ await (0, import_firestore37.updateDoc)(eventRef, {
10176
10330
  status,
10177
- updatedAt: (0, import_firestore34.serverTimestamp)()
10331
+ updatedAt: (0, import_firestore36.serverTimestamp)()
10178
10332
  });
10179
10333
  console.log(`Updated event ${eventId} status to ${status}`);
10180
10334
  } catch (error) {
@@ -10222,8 +10376,8 @@ var CalendarServiceV2 = class extends BaseService {
10222
10376
  */
10223
10377
  async getPractitionerUpcomingAppointments(doctorId, startDate, endDate, status = "confirmed" /* CONFIRMED */) {
10224
10378
  const dateRange = {
10225
- start: import_firestore34.Timestamp.fromDate(startDate),
10226
- end: import_firestore34.Timestamp.fromDate(endDate)
10379
+ start: import_firestore36.Timestamp.fromDate(startDate),
10380
+ end: import_firestore36.Timestamp.fromDate(endDate)
10227
10381
  };
10228
10382
  const searchParams = {
10229
10383
  searchLocation: "practitioner" /* PRACTITIONER */,
@@ -10245,8 +10399,8 @@ var CalendarServiceV2 = class extends BaseService {
10245
10399
  */
10246
10400
  async getPatientAppointments(patientId, startDate, endDate, status) {
10247
10401
  const dateRange = {
10248
- start: import_firestore34.Timestamp.fromDate(startDate),
10249
- end: import_firestore34.Timestamp.fromDate(endDate)
10402
+ start: import_firestore36.Timestamp.fromDate(startDate),
10403
+ end: import_firestore36.Timestamp.fromDate(endDate)
10250
10404
  };
10251
10405
  const searchParams = {
10252
10406
  searchLocation: "patient" /* PATIENT */,
@@ -10271,8 +10425,8 @@ var CalendarServiceV2 = class extends BaseService {
10271
10425
  */
10272
10426
  async getClinicAppointments(clinicId, startDate, endDate, doctorId, status) {
10273
10427
  const dateRange = {
10274
- start: import_firestore34.Timestamp.fromDate(startDate),
10275
- end: import_firestore34.Timestamp.fromDate(endDate)
10428
+ start: import_firestore36.Timestamp.fromDate(startDate),
10429
+ end: import_firestore36.Timestamp.fromDate(endDate)
10276
10430
  };
10277
10431
  const searchParams = {
10278
10432
  searchLocation: "clinic" /* CLINIC */,
@@ -10331,8 +10485,8 @@ var CalendarServiceV2 = class extends BaseService {
10331
10485
  const startDate = eventTime.start.toDate();
10332
10486
  const startTime = startDate;
10333
10487
  const endTime = eventTime.end.toDate();
10334
- const practitionerRef = (0, import_firestore35.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
10335
- const practitionerDoc = await (0, import_firestore35.getDoc)(practitionerRef);
10488
+ const practitionerRef = (0, import_firestore37.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
10489
+ const practitionerDoc = await (0, import_firestore37.getDoc)(practitionerRef);
10336
10490
  if (!practitionerDoc.exists()) {
10337
10491
  throw new Error(`Doctor with ID ${doctorId} not found`);
10338
10492
  }
@@ -10390,8 +10544,8 @@ var CalendarServiceV2 = class extends BaseService {
10390
10544
  */
10391
10545
  async updateAppointmentStatus(appointmentId, clinicId, status) {
10392
10546
  const baseCollectionPath = `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}`;
10393
- const appointmentRef = (0, import_firestore35.doc)(this.db, baseCollectionPath, appointmentId);
10394
- const appointmentDoc = await (0, import_firestore35.getDoc)(appointmentRef);
10547
+ const appointmentRef = (0, import_firestore37.doc)(this.db, baseCollectionPath, appointmentId);
10548
+ const appointmentDoc = await (0, import_firestore37.getDoc)(appointmentRef);
10395
10549
  if (!appointmentDoc.exists()) {
10396
10550
  throw new Error(`Appointment with ID ${appointmentId} not found`);
10397
10551
  }
@@ -10524,7 +10678,7 @@ var CalendarServiceV2 = class extends BaseService {
10524
10678
  const newSyncEvent = {
10525
10679
  eventId: result.eventIds[0],
10526
10680
  syncedCalendarProvider: calendar.provider,
10527
- syncedAt: import_firestore34.Timestamp.now()
10681
+ syncedAt: import_firestore36.Timestamp.now()
10528
10682
  };
10529
10683
  await this.updateEventWithSyncId(
10530
10684
  entityType === "doctor" ? appointment.practitionerProfileId : appointment.patientProfileId,
@@ -10548,8 +10702,8 @@ var CalendarServiceV2 = class extends BaseService {
10548
10702
  async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
10549
10703
  try {
10550
10704
  const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
10551
- const eventRef = (0, import_firestore35.doc)(this.db, collectionPath, eventId);
10552
- const eventDoc = await (0, import_firestore35.getDoc)(eventRef);
10705
+ const eventRef = (0, import_firestore37.doc)(this.db, collectionPath, eventId);
10706
+ const eventDoc = await (0, import_firestore37.getDoc)(eventRef);
10553
10707
  if (eventDoc.exists()) {
10554
10708
  const event = eventDoc.data();
10555
10709
  const syncIds = [...event.syncedCalendarEventId || []];
@@ -10561,9 +10715,9 @@ var CalendarServiceV2 = class extends BaseService {
10561
10715
  } else {
10562
10716
  syncIds.push(syncEvent);
10563
10717
  }
10564
- await (0, import_firestore35.updateDoc)(eventRef, {
10718
+ await (0, import_firestore37.updateDoc)(eventRef, {
10565
10719
  syncedCalendarEventId: syncIds,
10566
- updatedAt: (0, import_firestore34.serverTimestamp)()
10720
+ updatedAt: (0, import_firestore36.serverTimestamp)()
10567
10721
  });
10568
10722
  console.log(
10569
10723
  `Updated event ${eventId} with sync ID ${syncEvent.eventId}`
@@ -10587,8 +10741,8 @@ var CalendarServiceV2 = class extends BaseService {
10587
10741
  * @returns Working hours for the clinic
10588
10742
  */
10589
10743
  async getClinicWorkingHours(clinicId, date) {
10590
- const clinicRef = (0, import_firestore35.doc)(this.db, CLINICS_COLLECTION, clinicId);
10591
- const clinicDoc = await (0, import_firestore35.getDoc)(clinicRef);
10744
+ const clinicRef = (0, import_firestore37.doc)(this.db, CLINICS_COLLECTION, clinicId);
10745
+ const clinicDoc = await (0, import_firestore37.getDoc)(clinicRef);
10592
10746
  if (!clinicDoc.exists()) {
10593
10747
  throw new Error(`Clinic with ID ${clinicId} not found`);
10594
10748
  }
@@ -10616,8 +10770,8 @@ var CalendarServiceV2 = class extends BaseService {
10616
10770
  * @returns Doctor's schedule
10617
10771
  */
10618
10772
  async getDoctorSchedule(doctorId, date) {
10619
- const practitionerRef = (0, import_firestore35.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
10620
- const practitionerDoc = await (0, import_firestore35.getDoc)(practitionerRef);
10773
+ const practitionerRef = (0, import_firestore37.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
10774
+ const practitionerDoc = await (0, import_firestore37.getDoc)(practitionerRef);
10621
10775
  if (!practitionerDoc.exists()) {
10622
10776
  throw new Error(`Doctor with ID ${doctorId} not found`);
10623
10777
  }
@@ -10649,19 +10803,19 @@ var CalendarServiceV2 = class extends BaseService {
10649
10803
  startOfDay.setHours(0, 0, 0, 0);
10650
10804
  const endOfDay = new Date(date);
10651
10805
  endOfDay.setHours(23, 59, 59, 999);
10652
- const appointmentsRef = (0, import_firestore35.collection)(this.db, CALENDAR_COLLECTION);
10653
- const q = (0, import_firestore35.query)(
10806
+ const appointmentsRef = (0, import_firestore37.collection)(this.db, CALENDAR_COLLECTION);
10807
+ const q = (0, import_firestore37.query)(
10654
10808
  appointmentsRef,
10655
- (0, import_firestore35.where)("practitionerProfileId", "==", doctorId),
10656
- (0, import_firestore35.where)("eventTime.start", ">=", import_firestore34.Timestamp.fromDate(startOfDay)),
10657
- (0, import_firestore35.where)("eventTime.start", "<=", import_firestore34.Timestamp.fromDate(endOfDay)),
10658
- (0, import_firestore35.where)("status", "in", [
10809
+ (0, import_firestore37.where)("practitionerProfileId", "==", doctorId),
10810
+ (0, import_firestore37.where)("eventTime.start", ">=", import_firestore36.Timestamp.fromDate(startOfDay)),
10811
+ (0, import_firestore37.where)("eventTime.start", "<=", import_firestore36.Timestamp.fromDate(endOfDay)),
10812
+ (0, import_firestore37.where)("status", "in", [
10659
10813
  "confirmed" /* CONFIRMED */,
10660
10814
  "pending" /* PENDING */
10661
10815
  ])
10662
10816
  );
10663
- const querySnapshot = await (0, import_firestore35.getDocs)(q);
10664
- return querySnapshot.docs.map((doc30) => doc30.data());
10817
+ const querySnapshot = await (0, import_firestore37.getDocs)(q);
10818
+ return querySnapshot.docs.map((doc32) => doc32.data());
10665
10819
  }
10666
10820
  /**
10667
10821
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -10718,11 +10872,11 @@ var CalendarServiceV2 = class extends BaseService {
10718
10872
  var _a;
10719
10873
  try {
10720
10874
  const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
10721
- (0, import_firestore35.getDoc)((0, import_firestore35.doc)(this.db, CLINICS_COLLECTION, clinicId)),
10722
- (0, import_firestore35.getDoc)((0, import_firestore35.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId)),
10723
- (0, import_firestore35.getDoc)((0, import_firestore35.doc)(this.db, PATIENTS_COLLECTION, patientId)),
10724
- (0, import_firestore35.getDoc)(
10725
- (0, import_firestore35.doc)(
10875
+ (0, import_firestore37.getDoc)((0, import_firestore37.doc)(this.db, CLINICS_COLLECTION, clinicId)),
10876
+ (0, import_firestore37.getDoc)((0, import_firestore37.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId)),
10877
+ (0, import_firestore37.getDoc)((0, import_firestore37.doc)(this.db, PATIENTS_COLLECTION, patientId)),
10878
+ (0, import_firestore37.getDoc)(
10879
+ (0, import_firestore37.doc)(
10726
10880
  this.db,
10727
10881
  PATIENTS_COLLECTION,
10728
10882
  patientId,
@@ -10755,7 +10909,7 @@ var CalendarServiceV2 = class extends BaseService {
10755
10909
  fullName: `${sensitiveData.firstName} ${sensitiveData.lastName}`,
10756
10910
  email: sensitiveData.email || "",
10757
10911
  phone: sensitiveData.phoneNumber || null,
10758
- dateOfBirth: sensitiveData.dateOfBirth || import_firestore34.Timestamp.now(),
10912
+ dateOfBirth: sensitiveData.dateOfBirth || import_firestore36.Timestamp.now(),
10759
10913
  gender: sensitiveData.gender || "other" /* OTHER */
10760
10914
  };
10761
10915
  } else if (patientDoc.exists()) {
@@ -10764,7 +10918,7 @@ var CalendarServiceV2 = class extends BaseService {
10764
10918
  fullName: patientDoc.data().displayName,
10765
10919
  email: ((_a = patientDoc.data().contactInfo) == null ? void 0 : _a.email) || "",
10766
10920
  phone: patientDoc.data().phoneNumber || null,
10767
- dateOfBirth: patientDoc.data().dateOfBirth || import_firestore34.Timestamp.now(),
10921
+ dateOfBirth: patientDoc.data().dateOfBirth || import_firestore36.Timestamp.now(),
10768
10922
  gender: patientDoc.data().gender || "other" /* OTHER */
10769
10923
  };
10770
10924
  }
@@ -10786,7 +10940,7 @@ var CalendarServiceV2 = class extends BaseService {
10786
10940
  };
10787
10941
 
10788
10942
  // src/services/reviews/reviews.service.ts
10789
- var import_firestore36 = require("firebase/firestore");
10943
+ var import_firestore38 = require("firebase/firestore");
10790
10944
 
10791
10945
  // src/types/reviews/index.ts
10792
10946
  var REVIEWS_COLLECTION = "reviews";
@@ -10871,11 +11025,11 @@ var ReviewService = class extends BaseService {
10871
11025
  updatedAt: now
10872
11026
  };
10873
11027
  reviewSchema.parse(review);
10874
- const docRef = (0, import_firestore36.doc)(this.db, REVIEWS_COLLECTION, reviewId);
10875
- await (0, import_firestore36.setDoc)(docRef, {
11028
+ const docRef = (0, import_firestore38.doc)(this.db, REVIEWS_COLLECTION, reviewId);
11029
+ await (0, import_firestore38.setDoc)(docRef, {
10876
11030
  ...review,
10877
- createdAt: (0, import_firestore36.serverTimestamp)(),
10878
- updatedAt: (0, import_firestore36.serverTimestamp)()
11031
+ createdAt: (0, import_firestore38.serverTimestamp)(),
11032
+ updatedAt: (0, import_firestore38.serverTimestamp)()
10879
11033
  });
10880
11034
  const updatePromises = [];
10881
11035
  if (data.clinicReview) {
@@ -10910,8 +11064,8 @@ var ReviewService = class extends BaseService {
10910
11064
  * @returns The review if found, null otherwise
10911
11065
  */
10912
11066
  async getReview(reviewId) {
10913
- const docRef = (0, import_firestore36.doc)(this.db, REVIEWS_COLLECTION, reviewId);
10914
- const docSnap = await (0, import_firestore36.getDoc)(docRef);
11067
+ const docRef = (0, import_firestore38.doc)(this.db, REVIEWS_COLLECTION, reviewId);
11068
+ const docSnap = await (0, import_firestore38.getDoc)(docRef);
10915
11069
  if (!docSnap.exists()) {
10916
11070
  return null;
10917
11071
  }
@@ -10923,12 +11077,12 @@ var ReviewService = class extends BaseService {
10923
11077
  * @returns Array of reviews for the patient
10924
11078
  */
10925
11079
  async getReviewsByPatient(patientId) {
10926
- const q = (0, import_firestore36.query)(
10927
- (0, import_firestore36.collection)(this.db, REVIEWS_COLLECTION),
10928
- (0, import_firestore36.where)("patientId", "==", patientId)
11080
+ const q = (0, import_firestore38.query)(
11081
+ (0, import_firestore38.collection)(this.db, REVIEWS_COLLECTION),
11082
+ (0, import_firestore38.where)("patientId", "==", patientId)
10929
11083
  );
10930
- const snapshot = await (0, import_firestore36.getDocs)(q);
10931
- return snapshot.docs.map((doc30) => doc30.data());
11084
+ const snapshot = await (0, import_firestore38.getDocs)(q);
11085
+ return snapshot.docs.map((doc32) => doc32.data());
10932
11086
  }
10933
11087
  /**
10934
11088
  * Gets all reviews for a specific clinic
@@ -10936,12 +11090,12 @@ var ReviewService = class extends BaseService {
10936
11090
  * @returns Array of reviews containing clinic reviews
10937
11091
  */
10938
11092
  async getReviewsByClinic(clinicId) {
10939
- const q = (0, import_firestore36.query)(
10940
- (0, import_firestore36.collection)(this.db, REVIEWS_COLLECTION),
10941
- (0, import_firestore36.where)("clinicReview.clinicId", "==", clinicId)
11093
+ const q = (0, import_firestore38.query)(
11094
+ (0, import_firestore38.collection)(this.db, REVIEWS_COLLECTION),
11095
+ (0, import_firestore38.where)("clinicReview.clinicId", "==", clinicId)
10942
11096
  );
10943
- const snapshot = await (0, import_firestore36.getDocs)(q);
10944
- return snapshot.docs.map((doc30) => doc30.data());
11097
+ const snapshot = await (0, import_firestore38.getDocs)(q);
11098
+ return snapshot.docs.map((doc32) => doc32.data());
10945
11099
  }
10946
11100
  /**
10947
11101
  * Gets all reviews for a specific practitioner
@@ -10949,12 +11103,12 @@ var ReviewService = class extends BaseService {
10949
11103
  * @returns Array of reviews containing practitioner reviews
10950
11104
  */
10951
11105
  async getReviewsByPractitioner(practitionerId) {
10952
- const q = (0, import_firestore36.query)(
10953
- (0, import_firestore36.collection)(this.db, REVIEWS_COLLECTION),
10954
- (0, import_firestore36.where)("practitionerReview.practitionerId", "==", practitionerId)
11106
+ const q = (0, import_firestore38.query)(
11107
+ (0, import_firestore38.collection)(this.db, REVIEWS_COLLECTION),
11108
+ (0, import_firestore38.where)("practitionerReview.practitionerId", "==", practitionerId)
10955
11109
  );
10956
- const snapshot = await (0, import_firestore36.getDocs)(q);
10957
- return snapshot.docs.map((doc30) => doc30.data());
11110
+ const snapshot = await (0, import_firestore38.getDocs)(q);
11111
+ return snapshot.docs.map((doc32) => doc32.data());
10958
11112
  }
10959
11113
  /**
10960
11114
  * Gets all reviews for a specific procedure
@@ -10962,12 +11116,12 @@ var ReviewService = class extends BaseService {
10962
11116
  * @returns Array of reviews containing procedure reviews
10963
11117
  */
10964
11118
  async getReviewsByProcedure(procedureId) {
10965
- const q = (0, import_firestore36.query)(
10966
- (0, import_firestore36.collection)(this.db, REVIEWS_COLLECTION),
10967
- (0, import_firestore36.where)("procedureReview.procedureId", "==", procedureId)
11119
+ const q = (0, import_firestore38.query)(
11120
+ (0, import_firestore38.collection)(this.db, REVIEWS_COLLECTION),
11121
+ (0, import_firestore38.where)("procedureReview.procedureId", "==", procedureId)
10968
11122
  );
10969
- const snapshot = await (0, import_firestore36.getDocs)(q);
10970
- return snapshot.docs.map((doc30) => doc30.data());
11123
+ const snapshot = await (0, import_firestore38.getDocs)(q);
11124
+ return snapshot.docs.map((doc32) => doc32.data());
10971
11125
  }
10972
11126
  /**
10973
11127
  * Gets all reviews for a specific appointment
@@ -10975,11 +11129,11 @@ var ReviewService = class extends BaseService {
10975
11129
  * @returns The review for the appointment if found, null otherwise
10976
11130
  */
10977
11131
  async getReviewByAppointment(appointmentId) {
10978
- const q = (0, import_firestore36.query)(
10979
- (0, import_firestore36.collection)(this.db, REVIEWS_COLLECTION),
10980
- (0, import_firestore36.where)("appointmentId", "==", appointmentId)
11132
+ const q = (0, import_firestore38.query)(
11133
+ (0, import_firestore38.collection)(this.db, REVIEWS_COLLECTION),
11134
+ (0, import_firestore38.where)("appointmentId", "==", appointmentId)
10981
11135
  );
10982
- const snapshot = await (0, import_firestore36.getDocs)(q);
11136
+ const snapshot = await (0, import_firestore38.getDocs)(q);
10983
11137
  if (snapshot.empty) {
10984
11138
  return null;
10985
11139
  }
@@ -10994,7 +11148,7 @@ var ReviewService = class extends BaseService {
10994
11148
  if (!review) {
10995
11149
  throw new Error(`Review with ID ${reviewId} not found`);
10996
11150
  }
10997
- await (0, import_firestore36.deleteDoc)((0, import_firestore36.doc)(this.db, REVIEWS_COLLECTION, reviewId));
11151
+ await (0, import_firestore38.deleteDoc)((0, import_firestore38.doc)(this.db, REVIEWS_COLLECTION, reviewId));
10998
11152
  const updatePromises = [];
10999
11153
  if (review.clinicReview) {
11000
11154
  updatePromises.push(
@@ -11033,7 +11187,7 @@ var ReviewService = class extends BaseService {
11033
11187
  * @returns The updated clinic review info
11034
11188
  */
11035
11189
  async updateClinicReviewInfo(clinicId, newReview, isRemoval = false) {
11036
- const clinicDoc = await (0, import_firestore36.getDoc)((0, import_firestore36.doc)(this.db, CLINICS_COLLECTION, clinicId));
11190
+ const clinicDoc = await (0, import_firestore38.getDoc)((0, import_firestore38.doc)(this.db, CLINICS_COLLECTION, clinicId));
11037
11191
  if (!clinicDoc.exists()) {
11038
11192
  throw new Error(`Clinic with ID ${clinicId} not found`);
11039
11193
  }
@@ -11049,9 +11203,9 @@ var ReviewService = class extends BaseService {
11049
11203
  recommendationPercentage: 0
11050
11204
  };
11051
11205
  if (currentReviewInfo.totalReviews === 0 && !newReview) {
11052
- await (0, import_firestore36.updateDoc)((0, import_firestore36.doc)(this.db, CLINICS_COLLECTION, clinicId), {
11206
+ await (0, import_firestore38.updateDoc)((0, import_firestore38.doc)(this.db, CLINICS_COLLECTION, clinicId), {
11053
11207
  reviewInfo: currentReviewInfo,
11054
- updatedAt: (0, import_firestore36.serverTimestamp)()
11208
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11055
11209
  });
11056
11210
  return currentReviewInfo;
11057
11211
  }
@@ -11112,9 +11266,9 @@ var ReviewService = class extends BaseService {
11112
11266
  } else {
11113
11267
  updatedReviewInfo = { ...currentReviewInfo };
11114
11268
  }
11115
- await (0, import_firestore36.updateDoc)((0, import_firestore36.doc)(this.db, CLINICS_COLLECTION, clinicId), {
11269
+ await (0, import_firestore38.updateDoc)((0, import_firestore38.doc)(this.db, CLINICS_COLLECTION, clinicId), {
11116
11270
  reviewInfo: updatedReviewInfo,
11117
- updatedAt: (0, import_firestore36.serverTimestamp)()
11271
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11118
11272
  });
11119
11273
  return updatedReviewInfo;
11120
11274
  }
@@ -11126,8 +11280,8 @@ var ReviewService = class extends BaseService {
11126
11280
  * @returns The updated practitioner review info
11127
11281
  */
11128
11282
  async updatePractitionerReviewInfo(practitionerId, newReview, isRemoval = false) {
11129
- const practitionerDoc = await (0, import_firestore36.getDoc)(
11130
- (0, import_firestore36.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId)
11283
+ const practitionerDoc = await (0, import_firestore38.getDoc)(
11284
+ (0, import_firestore38.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId)
11131
11285
  );
11132
11286
  if (!practitionerDoc.exists()) {
11133
11287
  throw new Error(`Practitioner with ID ${practitionerId} not found`);
@@ -11144,9 +11298,9 @@ var ReviewService = class extends BaseService {
11144
11298
  recommendationPercentage: 0
11145
11299
  };
11146
11300
  if (currentReviewInfo.totalReviews === 0 && !newReview) {
11147
- await (0, import_firestore36.updateDoc)((0, import_firestore36.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11301
+ await (0, import_firestore38.updateDoc)((0, import_firestore38.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11148
11302
  reviewInfo: currentReviewInfo,
11149
- updatedAt: (0, import_firestore36.serverTimestamp)()
11303
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11150
11304
  });
11151
11305
  return currentReviewInfo;
11152
11306
  }
@@ -11207,9 +11361,9 @@ var ReviewService = class extends BaseService {
11207
11361
  } else {
11208
11362
  updatedReviewInfo = { ...currentReviewInfo };
11209
11363
  }
11210
- await (0, import_firestore36.updateDoc)((0, import_firestore36.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11364
+ await (0, import_firestore38.updateDoc)((0, import_firestore38.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11211
11365
  reviewInfo: updatedReviewInfo,
11212
- updatedAt: (0, import_firestore36.serverTimestamp)()
11366
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11213
11367
  });
11214
11368
  await this.updateDoctorInfoInProcedures(
11215
11369
  practitionerId,
@@ -11225,8 +11379,8 @@ var ReviewService = class extends BaseService {
11225
11379
  * @returns The updated procedure review info
11226
11380
  */
11227
11381
  async updateProcedureReviewInfo(procedureId, newReview, isRemoval = false) {
11228
- const procedureDoc = await (0, import_firestore36.getDoc)(
11229
- (0, import_firestore36.doc)(this.db, PROCEDURES_COLLECTION, procedureId)
11382
+ const procedureDoc = await (0, import_firestore38.getDoc)(
11383
+ (0, import_firestore38.doc)(this.db, PROCEDURES_COLLECTION, procedureId)
11230
11384
  );
11231
11385
  if (!procedureDoc.exists()) {
11232
11386
  throw new Error(`Procedure with ID ${procedureId} not found`);
@@ -11243,9 +11397,9 @@ var ReviewService = class extends BaseService {
11243
11397
  recommendationPercentage: 0
11244
11398
  };
11245
11399
  if (currentReviewInfo.totalReviews === 0 && !newReview) {
11246
- await (0, import_firestore36.updateDoc)((0, import_firestore36.doc)(this.db, PROCEDURES_COLLECTION, procedureId), {
11400
+ await (0, import_firestore38.updateDoc)((0, import_firestore38.doc)(this.db, PROCEDURES_COLLECTION, procedureId), {
11247
11401
  reviewInfo: currentReviewInfo,
11248
- updatedAt: (0, import_firestore36.serverTimestamp)()
11402
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11249
11403
  });
11250
11404
  return currentReviewInfo;
11251
11405
  }
@@ -11306,9 +11460,9 @@ var ReviewService = class extends BaseService {
11306
11460
  } else {
11307
11461
  updatedReviewInfo = { ...currentReviewInfo };
11308
11462
  }
11309
- await (0, import_firestore36.updateDoc)((0, import_firestore36.doc)(this.db, PROCEDURES_COLLECTION, procedureId), {
11463
+ await (0, import_firestore38.updateDoc)((0, import_firestore38.doc)(this.db, PROCEDURES_COLLECTION, procedureId), {
11310
11464
  reviewInfo: updatedReviewInfo,
11311
- updatedAt: (0, import_firestore36.serverTimestamp)()
11465
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11312
11466
  });
11313
11467
  return updatedReviewInfo;
11314
11468
  }
@@ -11318,20 +11472,20 @@ var ReviewService = class extends BaseService {
11318
11472
  * @param rating The new rating to set
11319
11473
  */
11320
11474
  async updateDoctorInfoInProcedures(practitionerId, rating) {
11321
- const q = (0, import_firestore36.query)(
11322
- (0, import_firestore36.collection)(this.db, PROCEDURES_COLLECTION),
11323
- (0, import_firestore36.where)("practitionerId", "==", practitionerId)
11475
+ const q = (0, import_firestore38.query)(
11476
+ (0, import_firestore38.collection)(this.db, PROCEDURES_COLLECTION),
11477
+ (0, import_firestore38.where)("practitionerId", "==", practitionerId)
11324
11478
  );
11325
- const snapshot = await (0, import_firestore36.getDocs)(q);
11479
+ const snapshot = await (0, import_firestore38.getDocs)(q);
11326
11480
  if (snapshot.empty) {
11327
11481
  return;
11328
11482
  }
11329
- const batch = (0, import_firestore36.writeBatch)(this.db);
11483
+ const batch = (0, import_firestore38.writeBatch)(this.db);
11330
11484
  snapshot.docs.forEach((docSnapshot) => {
11331
- const procedureRef = (0, import_firestore36.doc)(this.db, PROCEDURES_COLLECTION, docSnapshot.id);
11485
+ const procedureRef = (0, import_firestore38.doc)(this.db, PROCEDURES_COLLECTION, docSnapshot.id);
11332
11486
  batch.update(procedureRef, {
11333
11487
  "doctorInfo.rating": rating,
11334
- updatedAt: (0, import_firestore36.serverTimestamp)()
11488
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11335
11489
  });
11336
11490
  });
11337
11491
  await batch.commit();
@@ -11345,9 +11499,9 @@ var ReviewService = class extends BaseService {
11345
11499
  if (!review) {
11346
11500
  throw new Error(`Review with ID ${reviewId} not found`);
11347
11501
  }
11348
- const batch = (0, import_firestore36.writeBatch)(this.db);
11349
- batch.update((0, import_firestore36.doc)(this.db, REVIEWS_COLLECTION, reviewId), {
11350
- updatedAt: (0, import_firestore36.serverTimestamp)()
11502
+ const batch = (0, import_firestore38.writeBatch)(this.db);
11503
+ batch.update((0, import_firestore38.doc)(this.db, REVIEWS_COLLECTION, reviewId), {
11504
+ updatedAt: (0, import_firestore38.serverTimestamp)()
11351
11505
  });
11352
11506
  if (review.clinicReview) {
11353
11507
  review.clinicReview.isVerified = true;
@@ -11395,11 +11549,11 @@ var ReviewService = class extends BaseService {
11395
11549
  };
11396
11550
 
11397
11551
  // src/services/appointment/appointment.service.ts
11398
- var import_firestore38 = require("firebase/firestore");
11552
+ var import_firestore40 = require("firebase/firestore");
11399
11553
  var import_functions = require("firebase/functions");
11400
11554
 
11401
11555
  // src/services/appointment/utils/appointment.utils.ts
11402
- var import_firestore37 = require("firebase/firestore");
11556
+ var import_firestore39 = require("firebase/firestore");
11403
11557
 
11404
11558
  // src/backoffice/types/technology.types.ts
11405
11559
  var TECHNOLOGIES_COLLECTION = "technologies";
@@ -11409,10 +11563,10 @@ async function fetchAggregatedInfoUtil(db, clinicId, practitionerId, patientId,
11409
11563
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
11410
11564
  try {
11411
11565
  const [clinicDoc, practitionerDoc, patientDoc, procedureDoc] = await Promise.all([
11412
- (0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, CLINICS_COLLECTION, clinicId)),
11413
- (0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, PRACTITIONERS_COLLECTION, practitionerId)),
11414
- (0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, PATIENTS_COLLECTION, patientId)),
11415
- (0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, PROCEDURES_COLLECTION, procedureId))
11566
+ (0, import_firestore39.getDoc)((0, import_firestore39.doc)(db, CLINICS_COLLECTION, clinicId)),
11567
+ (0, import_firestore39.getDoc)((0, import_firestore39.doc)(db, PRACTITIONERS_COLLECTION, practitionerId)),
11568
+ (0, import_firestore39.getDoc)((0, import_firestore39.doc)(db, PATIENTS_COLLECTION, patientId)),
11569
+ (0, import_firestore39.getDoc)((0, import_firestore39.doc)(db, PROCEDURES_COLLECTION, procedureId))
11416
11570
  ]);
11417
11571
  if (!clinicDoc.exists()) {
11418
11572
  throw new Error(`Clinic with ID ${clinicId} not found`);
@@ -11451,7 +11605,7 @@ async function fetchAggregatedInfoUtil(db, clinicId, practitionerId, patientId,
11451
11605
  fullName: patientData.displayName || "",
11452
11606
  email: patientData.email || "",
11453
11607
  phone: patientData.phoneNumber || null,
11454
- dateOfBirth: patientData.dateOfBirth || import_firestore37.Timestamp.now(),
11608
+ dateOfBirth: patientData.dateOfBirth || import_firestore39.Timestamp.now(),
11455
11609
  gender: patientData.gender || "other"
11456
11610
  };
11457
11611
  const procedureInfo = {
@@ -11483,8 +11637,8 @@ async function fetchAggregatedInfoUtil(db, clinicId, practitionerId, patientId,
11483
11637
  let preProcedureRequirements = [];
11484
11638
  let postProcedureRequirements = [];
11485
11639
  if (technologyId) {
11486
- const technologyDoc = await (0, import_firestore37.getDoc)(
11487
- (0, import_firestore37.doc)(db, TECHNOLOGIES_COLLECTION, technologyId)
11640
+ const technologyDoc = await (0, import_firestore39.getDoc)(
11641
+ (0, import_firestore39.doc)(db, TECHNOLOGIES_COLLECTION, technologyId)
11488
11642
  );
11489
11643
  if (technologyDoc.exists()) {
11490
11644
  const technologyData = technologyDoc.data();
@@ -11529,7 +11683,7 @@ async function createAppointmentUtil2(db, data, aggregatedInfo, generateId2) {
11529
11683
  procedureId: data.procedureId,
11530
11684
  procedureInfo: aggregatedInfo.procedureInfo,
11531
11685
  status: data.initialStatus,
11532
- bookingTime: import_firestore37.Timestamp.now(),
11686
+ bookingTime: import_firestore39.Timestamp.now(),
11533
11687
  appointmentStartTime: data.appointmentStartTime,
11534
11688
  appointmentEndTime: data.appointmentEndTime,
11535
11689
  patientNotes: data.patientNotes || null,
@@ -11542,19 +11696,19 @@ async function createAppointmentUtil2(db, data, aggregatedInfo, generateId2) {
11542
11696
  postProcedureRequirements: aggregatedInfo.postProcedureRequirements,
11543
11697
  completedPreRequirements: [],
11544
11698
  completedPostRequirements: [],
11545
- createdAt: (0, import_firestore37.serverTimestamp)(),
11546
- updatedAt: (0, import_firestore37.serverTimestamp)()
11699
+ createdAt: (0, import_firestore39.serverTimestamp)(),
11700
+ updatedAt: (0, import_firestore39.serverTimestamp)()
11547
11701
  };
11548
11702
  if (data.initialStatus === "confirmed" /* CONFIRMED */) {
11549
- appointment.confirmationTime = import_firestore37.Timestamp.now();
11703
+ appointment.confirmationTime = import_firestore39.Timestamp.now();
11550
11704
  }
11551
- await (0, import_firestore37.setDoc)((0, import_firestore37.doc)(db, APPOINTMENTS_COLLECTION, appointmentId), appointment);
11552
- const calendarEventRef = (0, import_firestore37.doc)(db, CALENDAR_COLLECTION, data.calendarEventId);
11553
- await (0, import_firestore37.updateDoc)(calendarEventRef, {
11705
+ await (0, import_firestore39.setDoc)((0, import_firestore39.doc)(db, APPOINTMENTS_COLLECTION, appointmentId), appointment);
11706
+ const calendarEventRef = (0, import_firestore39.doc)(db, CALENDAR_COLLECTION, data.calendarEventId);
11707
+ await (0, import_firestore39.updateDoc)(calendarEventRef, {
11554
11708
  appointmentId,
11555
- updatedAt: (0, import_firestore37.serverTimestamp)()
11709
+ updatedAt: (0, import_firestore39.serverTimestamp)()
11556
11710
  });
11557
- const now = import_firestore37.Timestamp.now();
11711
+ const now = import_firestore39.Timestamp.now();
11558
11712
  return {
11559
11713
  ...appointment,
11560
11714
  createdAt: now,
@@ -11567,8 +11721,8 @@ async function createAppointmentUtil2(db, data, aggregatedInfo, generateId2) {
11567
11721
  }
11568
11722
  async function updateAppointmentUtil2(db, appointmentId, data) {
11569
11723
  try {
11570
- const appointmentRef = (0, import_firestore37.doc)(db, APPOINTMENTS_COLLECTION, appointmentId);
11571
- const appointmentDoc = await (0, import_firestore37.getDoc)(appointmentRef);
11724
+ const appointmentRef = (0, import_firestore39.doc)(db, APPOINTMENTS_COLLECTION, appointmentId);
11725
+ const appointmentDoc = await (0, import_firestore39.getDoc)(appointmentRef);
11572
11726
  if (!appointmentDoc.exists()) {
11573
11727
  throw new Error(`Appointment with ID ${appointmentId} not found`);
11574
11728
  }
@@ -11617,7 +11771,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
11617
11771
  ...data,
11618
11772
  completedPreRequirements,
11619
11773
  completedPostRequirements,
11620
- updatedAt: (0, import_firestore37.serverTimestamp)()
11774
+ updatedAt: (0, import_firestore39.serverTimestamp)()
11621
11775
  };
11622
11776
  Object.keys(updateData).forEach((key) => {
11623
11777
  if (updateData[key] === void 0) {
@@ -11626,7 +11780,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
11626
11780
  });
11627
11781
  if (data.status && data.status !== currentAppointment.status) {
11628
11782
  if (data.status === "confirmed" /* CONFIRMED */ && !updateData.confirmationTime) {
11629
- updateData.confirmationTime = import_firestore37.Timestamp.now();
11783
+ updateData.confirmationTime = import_firestore39.Timestamp.now();
11630
11784
  }
11631
11785
  if (currentAppointment.calendarEventId) {
11632
11786
  await updateCalendarEventStatus(
@@ -11636,8 +11790,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
11636
11790
  );
11637
11791
  }
11638
11792
  }
11639
- await (0, import_firestore37.updateDoc)(appointmentRef, updateData);
11640
- const updatedAppointmentDoc = await (0, import_firestore37.getDoc)(appointmentRef);
11793
+ await (0, import_firestore39.updateDoc)(appointmentRef, updateData);
11794
+ const updatedAppointmentDoc = await (0, import_firestore39.getDoc)(appointmentRef);
11641
11795
  if (!updatedAppointmentDoc.exists()) {
11642
11796
  throw new Error(
11643
11797
  `Failed to retrieve updated appointment ${appointmentId}`
@@ -11651,8 +11805,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
11651
11805
  }
11652
11806
  async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus) {
11653
11807
  try {
11654
- const calendarEventRef = (0, import_firestore37.doc)(db, CALENDAR_COLLECTION, calendarEventId);
11655
- const calendarEventDoc = await (0, import_firestore37.getDoc)(calendarEventRef);
11808
+ const calendarEventRef = (0, import_firestore39.doc)(db, CALENDAR_COLLECTION, calendarEventId);
11809
+ const calendarEventDoc = await (0, import_firestore39.getDoc)(calendarEventRef);
11656
11810
  if (!calendarEventDoc.exists()) {
11657
11811
  console.warn(`Calendar event with ID ${calendarEventId} not found`);
11658
11812
  return;
@@ -11675,9 +11829,9 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
11675
11829
  default:
11676
11830
  return;
11677
11831
  }
11678
- await (0, import_firestore37.updateDoc)(calendarEventRef, {
11832
+ await (0, import_firestore39.updateDoc)(calendarEventRef, {
11679
11833
  status: calendarStatus,
11680
- updatedAt: (0, import_firestore37.serverTimestamp)()
11834
+ updatedAt: (0, import_firestore39.serverTimestamp)()
11681
11835
  });
11682
11836
  } catch (error) {
11683
11837
  console.error(`Error updating calendar event ${calendarEventId}:`, error);
@@ -11685,8 +11839,8 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
11685
11839
  }
11686
11840
  async function getAppointmentByIdUtil(db, appointmentId) {
11687
11841
  try {
11688
- const appointmentDoc = await (0, import_firestore37.getDoc)(
11689
- (0, import_firestore37.doc)(db, APPOINTMENTS_COLLECTION, appointmentId)
11842
+ const appointmentDoc = await (0, import_firestore39.getDoc)(
11843
+ (0, import_firestore39.doc)(db, APPOINTMENTS_COLLECTION, appointmentId)
11690
11844
  );
11691
11845
  if (!appointmentDoc.exists()) {
11692
11846
  return null;
@@ -11701,46 +11855,46 @@ async function searchAppointmentsUtil(db, params) {
11701
11855
  try {
11702
11856
  const constraints = [];
11703
11857
  if (params.patientId) {
11704
- constraints.push((0, import_firestore37.where)("patientId", "==", params.patientId));
11858
+ constraints.push((0, import_firestore39.where)("patientId", "==", params.patientId));
11705
11859
  }
11706
11860
  if (params.practitionerId) {
11707
- constraints.push((0, import_firestore37.where)("practitionerId", "==", params.practitionerId));
11861
+ constraints.push((0, import_firestore39.where)("practitionerId", "==", params.practitionerId));
11708
11862
  }
11709
11863
  if (params.clinicBranchId) {
11710
- constraints.push((0, import_firestore37.where)("clinicBranchId", "==", params.clinicBranchId));
11864
+ constraints.push((0, import_firestore39.where)("clinicBranchId", "==", params.clinicBranchId));
11711
11865
  }
11712
11866
  if (params.startDate) {
11713
11867
  constraints.push(
11714
- (0, import_firestore37.where)(
11868
+ (0, import_firestore39.where)(
11715
11869
  "appointmentStartTime",
11716
11870
  ">=",
11717
- import_firestore37.Timestamp.fromDate(params.startDate)
11871
+ import_firestore39.Timestamp.fromDate(params.startDate)
11718
11872
  )
11719
11873
  );
11720
11874
  }
11721
11875
  if (params.endDate) {
11722
11876
  constraints.push(
11723
- (0, import_firestore37.where)("appointmentStartTime", "<=", import_firestore37.Timestamp.fromDate(params.endDate))
11877
+ (0, import_firestore39.where)("appointmentStartTime", "<=", import_firestore39.Timestamp.fromDate(params.endDate))
11724
11878
  );
11725
11879
  }
11726
11880
  if (params.status) {
11727
11881
  if (Array.isArray(params.status)) {
11728
- constraints.push((0, import_firestore37.where)("status", "in", params.status));
11882
+ constraints.push((0, import_firestore39.where)("status", "in", params.status));
11729
11883
  } else {
11730
- constraints.push((0, import_firestore37.where)("status", "==", params.status));
11884
+ constraints.push((0, import_firestore39.where)("status", "==", params.status));
11731
11885
  }
11732
11886
  }
11733
- constraints.push((0, import_firestore37.orderBy)("appointmentStartTime", "asc"));
11887
+ constraints.push((0, import_firestore39.orderBy)("appointmentStartTime", "asc"));
11734
11888
  if (params.limit) {
11735
- constraints.push((0, import_firestore37.limit)(params.limit));
11889
+ constraints.push((0, import_firestore39.limit)(params.limit));
11736
11890
  }
11737
11891
  if (params.startAfter) {
11738
- constraints.push((0, import_firestore37.startAfter)(params.startAfter));
11892
+ constraints.push((0, import_firestore39.startAfter)(params.startAfter));
11739
11893
  }
11740
- const q = (0, import_firestore37.query)((0, import_firestore37.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
11741
- const querySnapshot = await (0, import_firestore37.getDocs)(q);
11894
+ const q = (0, import_firestore39.query)((0, import_firestore39.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
11895
+ const querySnapshot = await (0, import_firestore39.getDocs)(q);
11742
11896
  const appointments = querySnapshot.docs.map(
11743
- (doc30) => doc30.data()
11897
+ (doc32) => doc32.data()
11744
11898
  );
11745
11899
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
11746
11900
  return { appointments, lastDoc };
@@ -12148,7 +12302,7 @@ var AppointmentService = class extends BaseService {
12148
12302
  updateData.canceledBy = canceledBy;
12149
12303
  }
12150
12304
  if (newStatus === "confirmed" /* CONFIRMED */) {
12151
- updateData.confirmationTime = import_firestore38.Timestamp.now();
12305
+ updateData.confirmationTime = import_firestore40.Timestamp.now();
12152
12306
  }
12153
12307
  return this.updateAppointment(appointmentId, updateData);
12154
12308
  }
@@ -12351,7 +12505,7 @@ var AppointmentService = class extends BaseService {
12351
12505
  };
12352
12506
 
12353
12507
  // src/backoffice/services/brand.service.ts
12354
- var import_firestore39 = require("firebase/firestore");
12508
+ var import_firestore41 = require("firebase/firestore");
12355
12509
 
12356
12510
  // src/backoffice/types/brand.types.ts
12357
12511
  var BRANDS_COLLECTION = "brands";
@@ -12362,7 +12516,7 @@ var BrandService = class extends BaseService {
12362
12516
  * Gets reference to brands collection
12363
12517
  */
12364
12518
  getBrandsRef() {
12365
- return (0, import_firestore39.collection)(this.db, BRANDS_COLLECTION);
12519
+ return (0, import_firestore41.collection)(this.db, BRANDS_COLLECTION);
12366
12520
  }
12367
12521
  /**
12368
12522
  * Creates a new brand
@@ -12375,19 +12529,19 @@ var BrandService = class extends BaseService {
12375
12529
  updatedAt: now,
12376
12530
  isActive: true
12377
12531
  };
12378
- const docRef = await (0, import_firestore39.addDoc)(this.getBrandsRef(), newBrand);
12532
+ const docRef = await (0, import_firestore41.addDoc)(this.getBrandsRef(), newBrand);
12379
12533
  return { id: docRef.id, ...newBrand };
12380
12534
  }
12381
12535
  /**
12382
12536
  * Gets all active brands
12383
12537
  */
12384
12538
  async getAll() {
12385
- const q = (0, import_firestore39.query)(this.getBrandsRef(), (0, import_firestore39.where)("isActive", "==", true));
12386
- const snapshot = await (0, import_firestore39.getDocs)(q);
12539
+ const q = (0, import_firestore41.query)(this.getBrandsRef(), (0, import_firestore41.where)("isActive", "==", true));
12540
+ const snapshot = await (0, import_firestore41.getDocs)(q);
12387
12541
  return snapshot.docs.map(
12388
- (doc30) => ({
12389
- id: doc30.id,
12390
- ...doc30.data()
12542
+ (doc32) => ({
12543
+ id: doc32.id,
12544
+ ...doc32.data()
12391
12545
  })
12392
12546
  );
12393
12547
  }
@@ -12399,8 +12553,8 @@ var BrandService = class extends BaseService {
12399
12553
  ...brand,
12400
12554
  updatedAt: /* @__PURE__ */ new Date()
12401
12555
  };
12402
- const docRef = (0, import_firestore39.doc)(this.getBrandsRef(), brandId);
12403
- await (0, import_firestore39.updateDoc)(docRef, updateData);
12556
+ const docRef = (0, import_firestore41.doc)(this.getBrandsRef(), brandId);
12557
+ await (0, import_firestore41.updateDoc)(docRef, updateData);
12404
12558
  return this.getById(brandId);
12405
12559
  }
12406
12560
  /**
@@ -12415,8 +12569,8 @@ var BrandService = class extends BaseService {
12415
12569
  * Gets a brand by ID
12416
12570
  */
12417
12571
  async getById(brandId) {
12418
- const docRef = (0, import_firestore39.doc)(this.getBrandsRef(), brandId);
12419
- const docSnap = await (0, import_firestore39.getDoc)(docRef);
12572
+ const docRef = (0, import_firestore41.doc)(this.getBrandsRef(), brandId);
12573
+ const docSnap = await (0, import_firestore41.getDoc)(docRef);
12420
12574
  if (!docSnap.exists()) return null;
12421
12575
  return {
12422
12576
  id: docSnap.id,
@@ -12426,7 +12580,7 @@ var BrandService = class extends BaseService {
12426
12580
  };
12427
12581
 
12428
12582
  // src/backoffice/services/category.service.ts
12429
- var import_firestore40 = require("firebase/firestore");
12583
+ var import_firestore42 = require("firebase/firestore");
12430
12584
 
12431
12585
  // src/backoffice/types/category.types.ts
12432
12586
  var CATEGORIES_COLLECTION = "backoffice_categories";
@@ -12437,7 +12591,7 @@ var CategoryService = class extends BaseService {
12437
12591
  * Referenca na Firestore kolekciju kategorija
12438
12592
  */
12439
12593
  get categoriesRef() {
12440
- return (0, import_firestore40.collection)(this.db, CATEGORIES_COLLECTION);
12594
+ return (0, import_firestore42.collection)(this.db, CATEGORIES_COLLECTION);
12441
12595
  }
12442
12596
  /**
12443
12597
  * Kreira novu kategoriju u sistemu
@@ -12452,7 +12606,7 @@ var CategoryService = class extends BaseService {
12452
12606
  updatedAt: now,
12453
12607
  isActive: true
12454
12608
  };
12455
- const docRef = await (0, import_firestore40.addDoc)(this.categoriesRef, newCategory);
12609
+ const docRef = await (0, import_firestore42.addDoc)(this.categoriesRef, newCategory);
12456
12610
  return { id: docRef.id, ...newCategory };
12457
12611
  }
12458
12612
  /**
@@ -12460,12 +12614,12 @@ var CategoryService = class extends BaseService {
12460
12614
  * @returns Lista aktivnih kategorija
12461
12615
  */
12462
12616
  async getAll() {
12463
- const q = (0, import_firestore40.query)(this.categoriesRef, (0, import_firestore40.where)("isActive", "==", true));
12464
- const snapshot = await (0, import_firestore40.getDocs)(q);
12617
+ const q = (0, import_firestore42.query)(this.categoriesRef, (0, import_firestore42.where)("isActive", "==", true));
12618
+ const snapshot = await (0, import_firestore42.getDocs)(q);
12465
12619
  return snapshot.docs.map(
12466
- (doc30) => ({
12467
- id: doc30.id,
12468
- ...doc30.data()
12620
+ (doc32) => ({
12621
+ id: doc32.id,
12622
+ ...doc32.data()
12469
12623
  })
12470
12624
  );
12471
12625
  }
@@ -12475,16 +12629,16 @@ var CategoryService = class extends BaseService {
12475
12629
  * @returns Lista kategorija koje pripadaju traženoj familiji
12476
12630
  */
12477
12631
  async getAllByFamily(family) {
12478
- const q = (0, import_firestore40.query)(
12632
+ const q = (0, import_firestore42.query)(
12479
12633
  this.categoriesRef,
12480
- (0, import_firestore40.where)("family", "==", family),
12481
- (0, import_firestore40.where)("isActive", "==", true)
12634
+ (0, import_firestore42.where)("family", "==", family),
12635
+ (0, import_firestore42.where)("isActive", "==", true)
12482
12636
  );
12483
- const snapshot = await (0, import_firestore40.getDocs)(q);
12637
+ const snapshot = await (0, import_firestore42.getDocs)(q);
12484
12638
  return snapshot.docs.map(
12485
- (doc30) => ({
12486
- id: doc30.id,
12487
- ...doc30.data()
12639
+ (doc32) => ({
12640
+ id: doc32.id,
12641
+ ...doc32.data()
12488
12642
  })
12489
12643
  );
12490
12644
  }
@@ -12499,8 +12653,8 @@ var CategoryService = class extends BaseService {
12499
12653
  ...category,
12500
12654
  updatedAt: /* @__PURE__ */ new Date()
12501
12655
  };
12502
- const docRef = (0, import_firestore40.doc)(this.categoriesRef, id);
12503
- await (0, import_firestore40.updateDoc)(docRef, updateData);
12656
+ const docRef = (0, import_firestore42.doc)(this.categoriesRef, id);
12657
+ await (0, import_firestore42.updateDoc)(docRef, updateData);
12504
12658
  return this.getById(id);
12505
12659
  }
12506
12660
  /**
@@ -12516,8 +12670,8 @@ var CategoryService = class extends BaseService {
12516
12670
  * @returns Kategorija ili null ako ne postoji
12517
12671
  */
12518
12672
  async getById(id) {
12519
- const docRef = (0, import_firestore40.doc)(this.categoriesRef, id);
12520
- const docSnap = await (0, import_firestore40.getDoc)(docRef);
12673
+ const docRef = (0, import_firestore42.doc)(this.categoriesRef, id);
12674
+ const docSnap = await (0, import_firestore42.getDoc)(docRef);
12521
12675
  if (!docSnap.exists()) return null;
12522
12676
  return {
12523
12677
  id: docSnap.id,
@@ -12527,7 +12681,7 @@ var CategoryService = class extends BaseService {
12527
12681
  };
12528
12682
 
12529
12683
  // src/backoffice/services/subcategory.service.ts
12530
- var import_firestore41 = require("firebase/firestore");
12684
+ var import_firestore43 = require("firebase/firestore");
12531
12685
 
12532
12686
  // src/backoffice/types/subcategory.types.ts
12533
12687
  var SUBCATEGORIES_COLLECTION = "subcategories";
@@ -12539,7 +12693,7 @@ var SubcategoryService = class extends BaseService {
12539
12693
  * @param categoryId - ID roditeljske kategorije
12540
12694
  */
12541
12695
  getSubcategoriesRef(categoryId) {
12542
- return (0, import_firestore41.collection)(
12696
+ return (0, import_firestore43.collection)(
12543
12697
  this.db,
12544
12698
  CATEGORIES_COLLECTION,
12545
12699
  categoryId,
@@ -12561,7 +12715,7 @@ var SubcategoryService = class extends BaseService {
12561
12715
  updatedAt: now,
12562
12716
  isActive: true
12563
12717
  };
12564
- const docRef = await (0, import_firestore41.addDoc)(
12718
+ const docRef = await (0, import_firestore43.addDoc)(
12565
12719
  this.getSubcategoriesRef(categoryId),
12566
12720
  newSubcategory
12567
12721
  );
@@ -12573,15 +12727,15 @@ var SubcategoryService = class extends BaseService {
12573
12727
  * @returns Lista aktivnih podkategorija
12574
12728
  */
12575
12729
  async getAllByCategoryId(categoryId) {
12576
- const q = (0, import_firestore41.query)(
12730
+ const q = (0, import_firestore43.query)(
12577
12731
  this.getSubcategoriesRef(categoryId),
12578
- (0, import_firestore41.where)("isActive", "==", true)
12732
+ (0, import_firestore43.where)("isActive", "==", true)
12579
12733
  );
12580
- const snapshot = await (0, import_firestore41.getDocs)(q);
12734
+ const snapshot = await (0, import_firestore43.getDocs)(q);
12581
12735
  return snapshot.docs.map(
12582
- (doc30) => ({
12583
- id: doc30.id,
12584
- ...doc30.data()
12736
+ (doc32) => ({
12737
+ id: doc32.id,
12738
+ ...doc32.data()
12585
12739
  })
12586
12740
  );
12587
12741
  }
@@ -12597,8 +12751,8 @@ var SubcategoryService = class extends BaseService {
12597
12751
  ...subcategory,
12598
12752
  updatedAt: /* @__PURE__ */ new Date()
12599
12753
  };
12600
- const docRef = (0, import_firestore41.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
12601
- await (0, import_firestore41.updateDoc)(docRef, updateData);
12754
+ const docRef = (0, import_firestore43.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
12755
+ await (0, import_firestore43.updateDoc)(docRef, updateData);
12602
12756
  return this.getById(categoryId, subcategoryId);
12603
12757
  }
12604
12758
  /**
@@ -12616,8 +12770,8 @@ var SubcategoryService = class extends BaseService {
12616
12770
  * @returns Podkategorija ili null ako ne postoji
12617
12771
  */
12618
12772
  async getById(categoryId, subcategoryId) {
12619
- const docRef = (0, import_firestore41.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
12620
- const docSnap = await (0, import_firestore41.getDoc)(docRef);
12773
+ const docRef = (0, import_firestore43.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
12774
+ const docSnap = await (0, import_firestore43.getDoc)(docRef);
12621
12775
  if (!docSnap.exists()) return null;
12622
12776
  return {
12623
12777
  id: docSnap.id,
@@ -12627,7 +12781,7 @@ var SubcategoryService = class extends BaseService {
12627
12781
  };
12628
12782
 
12629
12783
  // src/backoffice/services/technology.service.ts
12630
- var import_firestore42 = require("firebase/firestore");
12784
+ var import_firestore44 = require("firebase/firestore");
12631
12785
  var DEFAULT_CERTIFICATION_REQUIREMENT = {
12632
12786
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
12633
12787
  requiredSpecialties: []
@@ -12637,7 +12791,7 @@ var TechnologyService = class extends BaseService {
12637
12791
  * Vraća referencu na Firestore kolekciju tehnologija
12638
12792
  */
12639
12793
  getTechnologiesRef() {
12640
- return (0, import_firestore42.collection)(this.db, TECHNOLOGIES_COLLECTION);
12794
+ return (0, import_firestore44.collection)(this.db, TECHNOLOGIES_COLLECTION);
12641
12795
  }
12642
12796
  /**
12643
12797
  * Kreira novu tehnologiju
@@ -12660,7 +12814,7 @@ var TechnologyService = class extends BaseService {
12660
12814
  benefits: technology.benefits || [],
12661
12815
  certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
12662
12816
  };
12663
- const docRef = await (0, import_firestore42.addDoc)(this.getTechnologiesRef(), newTechnology);
12817
+ const docRef = await (0, import_firestore44.addDoc)(this.getTechnologiesRef(), newTechnology);
12664
12818
  return { id: docRef.id, ...newTechnology };
12665
12819
  }
12666
12820
  /**
@@ -12668,12 +12822,12 @@ var TechnologyService = class extends BaseService {
12668
12822
  * @returns Lista aktivnih tehnologija
12669
12823
  */
12670
12824
  async getAll() {
12671
- const q = (0, import_firestore42.query)(this.getTechnologiesRef(), (0, import_firestore42.where)("isActive", "==", true));
12672
- const snapshot = await (0, import_firestore42.getDocs)(q);
12825
+ const q = (0, import_firestore44.query)(this.getTechnologiesRef(), (0, import_firestore44.where)("isActive", "==", true));
12826
+ const snapshot = await (0, import_firestore44.getDocs)(q);
12673
12827
  return snapshot.docs.map(
12674
- (doc30) => ({
12675
- id: doc30.id,
12676
- ...doc30.data()
12828
+ (doc32) => ({
12829
+ id: doc32.id,
12830
+ ...doc32.data()
12677
12831
  })
12678
12832
  );
12679
12833
  }
@@ -12683,16 +12837,16 @@ var TechnologyService = class extends BaseService {
12683
12837
  * @returns Lista aktivnih tehnologija
12684
12838
  */
12685
12839
  async getAllByFamily(family) {
12686
- const q = (0, import_firestore42.query)(
12840
+ const q = (0, import_firestore44.query)(
12687
12841
  this.getTechnologiesRef(),
12688
- (0, import_firestore42.where)("isActive", "==", true),
12689
- (0, import_firestore42.where)("family", "==", family)
12842
+ (0, import_firestore44.where)("isActive", "==", true),
12843
+ (0, import_firestore44.where)("family", "==", family)
12690
12844
  );
12691
- const snapshot = await (0, import_firestore42.getDocs)(q);
12845
+ const snapshot = await (0, import_firestore44.getDocs)(q);
12692
12846
  return snapshot.docs.map(
12693
- (doc30) => ({
12694
- id: doc30.id,
12695
- ...doc30.data()
12847
+ (doc32) => ({
12848
+ id: doc32.id,
12849
+ ...doc32.data()
12696
12850
  })
12697
12851
  );
12698
12852
  }
@@ -12702,16 +12856,16 @@ var TechnologyService = class extends BaseService {
12702
12856
  * @returns Lista aktivnih tehnologija
12703
12857
  */
12704
12858
  async getAllByCategoryId(categoryId) {
12705
- const q = (0, import_firestore42.query)(
12859
+ const q = (0, import_firestore44.query)(
12706
12860
  this.getTechnologiesRef(),
12707
- (0, import_firestore42.where)("isActive", "==", true),
12708
- (0, import_firestore42.where)("categoryId", "==", categoryId)
12861
+ (0, import_firestore44.where)("isActive", "==", true),
12862
+ (0, import_firestore44.where)("categoryId", "==", categoryId)
12709
12863
  );
12710
- const snapshot = await (0, import_firestore42.getDocs)(q);
12864
+ const snapshot = await (0, import_firestore44.getDocs)(q);
12711
12865
  return snapshot.docs.map(
12712
- (doc30) => ({
12713
- id: doc30.id,
12714
- ...doc30.data()
12866
+ (doc32) => ({
12867
+ id: doc32.id,
12868
+ ...doc32.data()
12715
12869
  })
12716
12870
  );
12717
12871
  }
@@ -12721,16 +12875,16 @@ var TechnologyService = class extends BaseService {
12721
12875
  * @returns Lista aktivnih tehnologija
12722
12876
  */
12723
12877
  async getAllBySubcategoryId(subcategoryId) {
12724
- const q = (0, import_firestore42.query)(
12878
+ const q = (0, import_firestore44.query)(
12725
12879
  this.getTechnologiesRef(),
12726
- (0, import_firestore42.where)("isActive", "==", true),
12727
- (0, import_firestore42.where)("subcategoryId", "==", subcategoryId)
12880
+ (0, import_firestore44.where)("isActive", "==", true),
12881
+ (0, import_firestore44.where)("subcategoryId", "==", subcategoryId)
12728
12882
  );
12729
- const snapshot = await (0, import_firestore42.getDocs)(q);
12883
+ const snapshot = await (0, import_firestore44.getDocs)(q);
12730
12884
  return snapshot.docs.map(
12731
- (doc30) => ({
12732
- id: doc30.id,
12733
- ...doc30.data()
12885
+ (doc32) => ({
12886
+ id: doc32.id,
12887
+ ...doc32.data()
12734
12888
  })
12735
12889
  );
12736
12890
  }
@@ -12745,8 +12899,8 @@ var TechnologyService = class extends BaseService {
12745
12899
  ...technology,
12746
12900
  updatedAt: /* @__PURE__ */ new Date()
12747
12901
  };
12748
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12749
- await (0, import_firestore42.updateDoc)(docRef, updateData);
12902
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
12903
+ await (0, import_firestore44.updateDoc)(docRef, updateData);
12750
12904
  return this.getById(technologyId);
12751
12905
  }
12752
12906
  /**
@@ -12764,8 +12918,8 @@ var TechnologyService = class extends BaseService {
12764
12918
  * @returns Tehnologija ili null ako ne postoji
12765
12919
  */
12766
12920
  async getById(technologyId) {
12767
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12768
- const docSnap = await (0, import_firestore42.getDoc)(docRef);
12921
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
12922
+ const docSnap = await (0, import_firestore44.getDoc)(docRef);
12769
12923
  if (!docSnap.exists()) return null;
12770
12924
  return {
12771
12925
  id: docSnap.id,
@@ -12779,10 +12933,10 @@ var TechnologyService = class extends BaseService {
12779
12933
  * @returns Ažurirana tehnologija sa novim zahtevom
12780
12934
  */
12781
12935
  async addRequirement(technologyId, requirement) {
12782
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12936
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
12783
12937
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
12784
- await (0, import_firestore42.updateDoc)(docRef, {
12785
- [requirementType]: (0, import_firestore42.arrayUnion)(requirement),
12938
+ await (0, import_firestore44.updateDoc)(docRef, {
12939
+ [requirementType]: (0, import_firestore44.arrayUnion)(requirement),
12786
12940
  updatedAt: /* @__PURE__ */ new Date()
12787
12941
  });
12788
12942
  return this.getById(technologyId);
@@ -12794,10 +12948,10 @@ var TechnologyService = class extends BaseService {
12794
12948
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
12795
12949
  */
12796
12950
  async removeRequirement(technologyId, requirement) {
12797
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12951
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
12798
12952
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
12799
- await (0, import_firestore42.updateDoc)(docRef, {
12800
- [requirementType]: (0, import_firestore42.arrayRemove)(requirement),
12953
+ await (0, import_firestore44.updateDoc)(docRef, {
12954
+ [requirementType]: (0, import_firestore44.arrayRemove)(requirement),
12801
12955
  updatedAt: /* @__PURE__ */ new Date()
12802
12956
  });
12803
12957
  return this.getById(technologyId);
@@ -12834,9 +12988,9 @@ var TechnologyService = class extends BaseService {
12834
12988
  * @returns Ažurirana tehnologija
12835
12989
  */
12836
12990
  async addBlockingCondition(technologyId, condition) {
12837
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12838
- await (0, import_firestore42.updateDoc)(docRef, {
12839
- blockingConditions: (0, import_firestore42.arrayUnion)(condition),
12991
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
12992
+ await (0, import_firestore44.updateDoc)(docRef, {
12993
+ blockingConditions: (0, import_firestore44.arrayUnion)(condition),
12840
12994
  updatedAt: /* @__PURE__ */ new Date()
12841
12995
  });
12842
12996
  return this.getById(technologyId);
@@ -12848,9 +13002,9 @@ var TechnologyService = class extends BaseService {
12848
13002
  * @returns Ažurirana tehnologija
12849
13003
  */
12850
13004
  async removeBlockingCondition(technologyId, condition) {
12851
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12852
- await (0, import_firestore42.updateDoc)(docRef, {
12853
- blockingConditions: (0, import_firestore42.arrayRemove)(condition),
13005
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
13006
+ await (0, import_firestore44.updateDoc)(docRef, {
13007
+ blockingConditions: (0, import_firestore44.arrayRemove)(condition),
12854
13008
  updatedAt: /* @__PURE__ */ new Date()
12855
13009
  });
12856
13010
  return this.getById(technologyId);
@@ -12862,9 +13016,9 @@ var TechnologyService = class extends BaseService {
12862
13016
  * @returns Ažurirana tehnologija
12863
13017
  */
12864
13018
  async addContraindication(technologyId, contraindication) {
12865
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12866
- await (0, import_firestore42.updateDoc)(docRef, {
12867
- contraindications: (0, import_firestore42.arrayUnion)(contraindication),
13019
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
13020
+ await (0, import_firestore44.updateDoc)(docRef, {
13021
+ contraindications: (0, import_firestore44.arrayUnion)(contraindication),
12868
13022
  updatedAt: /* @__PURE__ */ new Date()
12869
13023
  });
12870
13024
  return this.getById(technologyId);
@@ -12876,9 +13030,9 @@ var TechnologyService = class extends BaseService {
12876
13030
  * @returns Ažurirana tehnologija
12877
13031
  */
12878
13032
  async removeContraindication(technologyId, contraindication) {
12879
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12880
- await (0, import_firestore42.updateDoc)(docRef, {
12881
- contraindications: (0, import_firestore42.arrayRemove)(contraindication),
13033
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
13034
+ await (0, import_firestore44.updateDoc)(docRef, {
13035
+ contraindications: (0, import_firestore44.arrayRemove)(contraindication),
12882
13036
  updatedAt: /* @__PURE__ */ new Date()
12883
13037
  });
12884
13038
  return this.getById(technologyId);
@@ -12890,9 +13044,9 @@ var TechnologyService = class extends BaseService {
12890
13044
  * @returns Ažurirana tehnologija
12891
13045
  */
12892
13046
  async addBenefit(technologyId, benefit) {
12893
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12894
- await (0, import_firestore42.updateDoc)(docRef, {
12895
- benefits: (0, import_firestore42.arrayUnion)(benefit),
13047
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
13048
+ await (0, import_firestore44.updateDoc)(docRef, {
13049
+ benefits: (0, import_firestore44.arrayUnion)(benefit),
12896
13050
  updatedAt: /* @__PURE__ */ new Date()
12897
13051
  });
12898
13052
  return this.getById(technologyId);
@@ -12904,9 +13058,9 @@ var TechnologyService = class extends BaseService {
12904
13058
  * @returns Ažurirana tehnologija
12905
13059
  */
12906
13060
  async removeBenefit(technologyId, benefit) {
12907
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12908
- await (0, import_firestore42.updateDoc)(docRef, {
12909
- benefits: (0, import_firestore42.arrayRemove)(benefit),
13061
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
13062
+ await (0, import_firestore44.updateDoc)(docRef, {
13063
+ benefits: (0, import_firestore44.arrayRemove)(benefit),
12910
13064
  updatedAt: /* @__PURE__ */ new Date()
12911
13065
  });
12912
13066
  return this.getById(technologyId);
@@ -12945,8 +13099,8 @@ var TechnologyService = class extends BaseService {
12945
13099
  * @returns Ažurirana tehnologija
12946
13100
  */
12947
13101
  async updateCertificationRequirement(technologyId, certificationRequirement) {
12948
- const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
12949
- await (0, import_firestore42.updateDoc)(docRef, {
13102
+ const docRef = (0, import_firestore44.doc)(this.getTechnologiesRef(), technologyId);
13103
+ await (0, import_firestore44.updateDoc)(docRef, {
12950
13104
  certificationRequirement,
12951
13105
  updatedAt: /* @__PURE__ */ new Date()
12952
13106
  });
@@ -13046,7 +13200,7 @@ var TechnologyService = class extends BaseService {
13046
13200
  };
13047
13201
 
13048
13202
  // src/backoffice/services/product.service.ts
13049
- var import_firestore43 = require("firebase/firestore");
13203
+ var import_firestore45 = require("firebase/firestore");
13050
13204
 
13051
13205
  // src/backoffice/types/product.types.ts
13052
13206
  var PRODUCTS_COLLECTION = "products";
@@ -13059,7 +13213,7 @@ var ProductService = class extends BaseService {
13059
13213
  * @returns Firestore collection reference
13060
13214
  */
13061
13215
  getProductsRef(technologyId) {
13062
- return (0, import_firestore43.collection)(
13216
+ return (0, import_firestore45.collection)(
13063
13217
  this.db,
13064
13218
  TECHNOLOGIES_COLLECTION,
13065
13219
  technologyId,
@@ -13079,7 +13233,7 @@ var ProductService = class extends BaseService {
13079
13233
  updatedAt: now,
13080
13234
  isActive: true
13081
13235
  };
13082
- const productRef = await (0, import_firestore43.addDoc)(
13236
+ const productRef = await (0, import_firestore45.addDoc)(
13083
13237
  this.getProductsRef(technologyId),
13084
13238
  newProduct
13085
13239
  );
@@ -13089,15 +13243,15 @@ var ProductService = class extends BaseService {
13089
13243
  * Gets all products for a technology
13090
13244
  */
13091
13245
  async getAllByTechnology(technologyId) {
13092
- const q = (0, import_firestore43.query)(
13246
+ const q = (0, import_firestore45.query)(
13093
13247
  this.getProductsRef(technologyId),
13094
- (0, import_firestore43.where)("isActive", "==", true)
13248
+ (0, import_firestore45.where)("isActive", "==", true)
13095
13249
  );
13096
- const snapshot = await (0, import_firestore43.getDocs)(q);
13250
+ const snapshot = await (0, import_firestore45.getDocs)(q);
13097
13251
  return snapshot.docs.map(
13098
- (doc30) => ({
13099
- id: doc30.id,
13100
- ...doc30.data()
13252
+ (doc32) => ({
13253
+ id: doc32.id,
13254
+ ...doc32.data()
13101
13255
  })
13102
13256
  );
13103
13257
  }
@@ -13105,21 +13259,21 @@ var ProductService = class extends BaseService {
13105
13259
  * Gets all products for a brand by filtering through all technologies
13106
13260
  */
13107
13261
  async getAllByBrand(brandId) {
13108
- const allTechnologiesRef = (0, import_firestore43.collection)(this.db, TECHNOLOGIES_COLLECTION);
13109
- const technologiesSnapshot = await (0, import_firestore43.getDocs)(allTechnologiesRef);
13262
+ const allTechnologiesRef = (0, import_firestore45.collection)(this.db, TECHNOLOGIES_COLLECTION);
13263
+ const technologiesSnapshot = await (0, import_firestore45.getDocs)(allTechnologiesRef);
13110
13264
  const products = [];
13111
13265
  for (const techDoc of technologiesSnapshot.docs) {
13112
- const q = (0, import_firestore43.query)(
13266
+ const q = (0, import_firestore45.query)(
13113
13267
  this.getProductsRef(techDoc.id),
13114
- (0, import_firestore43.where)("brandId", "==", brandId),
13115
- (0, import_firestore43.where)("isActive", "==", true)
13268
+ (0, import_firestore45.where)("brandId", "==", brandId),
13269
+ (0, import_firestore45.where)("isActive", "==", true)
13116
13270
  );
13117
- const snapshot = await (0, import_firestore43.getDocs)(q);
13271
+ const snapshot = await (0, import_firestore45.getDocs)(q);
13118
13272
  products.push(
13119
13273
  ...snapshot.docs.map(
13120
- (doc30) => ({
13121
- id: doc30.id,
13122
- ...doc30.data()
13274
+ (doc32) => ({
13275
+ id: doc32.id,
13276
+ ...doc32.data()
13123
13277
  })
13124
13278
  )
13125
13279
  );
@@ -13134,8 +13288,8 @@ var ProductService = class extends BaseService {
13134
13288
  ...product,
13135
13289
  updatedAt: /* @__PURE__ */ new Date()
13136
13290
  };
13137
- const docRef = (0, import_firestore43.doc)(this.getProductsRef(technologyId), productId);
13138
- await (0, import_firestore43.updateDoc)(docRef, updateData);
13291
+ const docRef = (0, import_firestore45.doc)(this.getProductsRef(technologyId), productId);
13292
+ await (0, import_firestore45.updateDoc)(docRef, updateData);
13139
13293
  return this.getById(technologyId, productId);
13140
13294
  }
13141
13295
  /**
@@ -13150,8 +13304,8 @@ var ProductService = class extends BaseService {
13150
13304
  * Gets a product by ID
13151
13305
  */
13152
13306
  async getById(technologyId, productId) {
13153
- const docRef = (0, import_firestore43.doc)(this.getProductsRef(technologyId), productId);
13154
- const docSnap = await (0, import_firestore43.getDoc)(docRef);
13307
+ const docRef = (0, import_firestore45.doc)(this.getProductsRef(technologyId), productId);
13308
+ const docSnap = await (0, import_firestore45.getDoc)(docRef);
13155
13309
  if (!docSnap.exists()) return null;
13156
13310
  return {
13157
13311
  id: docSnap.id,