@blackcode_sa/metaestetics-api 1.5.44 → 1.5.45

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.mjs CHANGED
@@ -160,9 +160,9 @@ import {
160
160
  confirmPasswordReset
161
161
  } from "firebase/auth";
162
162
  import {
163
- collection as collection11,
164
- query as query11,
165
- getDocs as getDocs11
163
+ collection as collection13,
164
+ query as query13,
165
+ getDocs as getDocs13
166
166
  } from "firebase/firestore";
167
167
 
168
168
  // src/types/documentation-templates/index.ts
@@ -686,12 +686,12 @@ var BaseService = class {
686
686
 
687
687
  // src/services/user.service.ts
688
688
  import {
689
- collection as collection5,
690
- doc as doc7,
691
- getDoc as getDoc10,
692
- getDocs as getDocs5,
693
- query as query5,
694
- where as where5,
689
+ collection as collection7,
690
+ doc as doc9,
691
+ getDoc as getDoc12,
692
+ getDocs as getDocs7,
693
+ query as query7,
694
+ where as where7,
695
695
  updateDoc as updateDoc9,
696
696
  deleteDoc as deleteDoc3,
697
697
  Timestamp as Timestamp9,
@@ -796,8 +796,8 @@ import { z as z14 } from "zod";
796
796
 
797
797
  // src/services/patient/patient.service.ts
798
798
  import {
799
- doc as doc4,
800
- getDoc as getDoc7,
799
+ doc as doc6,
800
+ getDoc as getDoc9,
801
801
  writeBatch
802
802
  } from "firebase/firestore";
803
803
 
@@ -1452,9 +1452,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
1452
1452
  var updateAllergyUtil = async (db, patientId, data, userRef) => {
1453
1453
  const validatedData = updateAllergySchema.parse(data);
1454
1454
  const { allergyIndex, ...updateData } = validatedData;
1455
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1456
- if (!doc30.exists()) throw new Error("Medical info not found");
1457
- const medicalInfo = doc30.data();
1455
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1456
+ if (!doc32.exists()) throw new Error("Medical info not found");
1457
+ const medicalInfo = doc32.data();
1458
1458
  if (allergyIndex >= medicalInfo.allergies.length) {
1459
1459
  throw new Error("Invalid allergy index");
1460
1460
  }
@@ -1470,9 +1470,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
1470
1470
  });
1471
1471
  };
1472
1472
  var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
1473
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1474
- if (!doc30.exists()) throw new Error("Medical info not found");
1475
- const medicalInfo = doc30.data();
1473
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1474
+ if (!doc32.exists()) throw new Error("Medical info not found");
1475
+ const medicalInfo = doc32.data();
1476
1476
  if (allergyIndex >= medicalInfo.allergies.length) {
1477
1477
  throw new Error("Invalid allergy index");
1478
1478
  }
@@ -1497,9 +1497,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
1497
1497
  var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1498
1498
  const validatedData = updateBlockingConditionSchema.parse(data);
1499
1499
  const { conditionIndex, ...updateData } = validatedData;
1500
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1501
- if (!doc30.exists()) throw new Error("Medical info not found");
1502
- const medicalInfo = doc30.data();
1500
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1501
+ if (!doc32.exists()) throw new Error("Medical info not found");
1502
+ const medicalInfo = doc32.data();
1503
1503
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1504
1504
  throw new Error("Invalid blocking condition index");
1505
1505
  }
@@ -1515,9 +1515,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1515
1515
  });
1516
1516
  };
1517
1517
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
1518
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1519
- if (!doc30.exists()) throw new Error("Medical info not found");
1520
- const medicalInfo = doc30.data();
1518
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1519
+ if (!doc32.exists()) throw new Error("Medical info not found");
1520
+ const medicalInfo = doc32.data();
1521
1521
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1522
1522
  throw new Error("Invalid blocking condition index");
1523
1523
  }
@@ -1542,9 +1542,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
1542
1542
  var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1543
1543
  const validatedData = updateContraindicationSchema.parse(data);
1544
1544
  const { contraindicationIndex, ...updateData } = validatedData;
1545
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1546
- if (!doc30.exists()) throw new Error("Medical info not found");
1547
- const medicalInfo = doc30.data();
1545
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1546
+ if (!doc32.exists()) throw new Error("Medical info not found");
1547
+ const medicalInfo = doc32.data();
1548
1548
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1549
1549
  throw new Error("Invalid contraindication index");
1550
1550
  }
@@ -1560,9 +1560,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1560
1560
  });
1561
1561
  };
1562
1562
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
1563
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1564
- if (!doc30.exists()) throw new Error("Medical info not found");
1565
- const medicalInfo = doc30.data();
1563
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1564
+ if (!doc32.exists()) throw new Error("Medical info not found");
1565
+ const medicalInfo = doc32.data();
1566
1566
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1567
1567
  throw new Error("Invalid contraindication index");
1568
1568
  }
@@ -1587,9 +1587,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
1587
1587
  var updateMedicationUtil = async (db, patientId, data, userRef) => {
1588
1588
  const validatedData = updateMedicationSchema.parse(data);
1589
1589
  const { medicationIndex, ...updateData } = validatedData;
1590
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1591
- if (!doc30.exists()) throw new Error("Medical info not found");
1592
- const medicalInfo = doc30.data();
1590
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1591
+ if (!doc32.exists()) throw new Error("Medical info not found");
1592
+ const medicalInfo = doc32.data();
1593
1593
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1594
1594
  throw new Error("Invalid medication index");
1595
1595
  }
@@ -1605,9 +1605,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
1605
1605
  });
1606
1606
  };
1607
1607
  var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
1608
- const doc30 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1609
- if (!doc30.exists()) throw new Error("Medical info not found");
1610
- const medicalInfo = doc30.data();
1608
+ const doc32 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1609
+ if (!doc32.exists()) throw new Error("Medical info not found");
1610
+ const medicalInfo = doc32.data();
1611
1611
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1612
1612
  throw new Error("Invalid medication index");
1613
1613
  }
@@ -1885,7 +1885,7 @@ var searchPatientsUtil = async (db, params, requester) => {
1885
1885
  try {
1886
1886
  const finalQuery = query2(patientsCollectionRef, ...constraints);
1887
1887
  const querySnapshot = await getDocs2(finalQuery);
1888
- const patients = querySnapshot.docs.map((doc30) => doc30.data());
1888
+ const patients = querySnapshot.docs.map((doc32) => doc32.data());
1889
1889
  console.log(`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`);
1890
1890
  return patients;
1891
1891
  } catch (error) {
@@ -1909,8 +1909,8 @@ var getAllPatientsUtil = async (db, options) => {
1909
1909
  }
1910
1910
  const patientsSnapshot = await getDocs2(q);
1911
1911
  const patients = [];
1912
- patientsSnapshot.forEach((doc30) => {
1913
- patients.push(doc30.data());
1912
+ patientsSnapshot.forEach((doc32) => {
1913
+ patients.push(doc32.data());
1914
1914
  });
1915
1915
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
1916
1916
  return patients;
@@ -2108,6 +2108,112 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
2108
2108
  });
2109
2109
  };
2110
2110
 
2111
+ // src/services/patient/utils/practitioner.utils.ts
2112
+ import {
2113
+ collection as collection3,
2114
+ query as query3,
2115
+ where as where3,
2116
+ getDocs as getDocs3,
2117
+ limit as limit2,
2118
+ startAfter as startAfter2,
2119
+ doc as doc4,
2120
+ getDoc as getDoc7
2121
+ } from "firebase/firestore";
2122
+ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
2123
+ try {
2124
+ console.log(
2125
+ `[getPatientsByPractitionerUtil] Fetching patients for practitioner ID: ${practitionerId} with options:`,
2126
+ options
2127
+ );
2128
+ const patientsCollection = collection3(db, PATIENTS_COLLECTION);
2129
+ const constraints = [
2130
+ where3("doctorIds", "array-contains", practitionerId)
2131
+ ];
2132
+ let q = query3(patientsCollection, ...constraints);
2133
+ if (options == null ? void 0 : options.limit) {
2134
+ q = query3(q, limit2(options.limit));
2135
+ }
2136
+ if (options == null ? void 0 : options.startAfter) {
2137
+ const startAfterDoc = await getDoc7(
2138
+ doc4(db, PATIENTS_COLLECTION, options.startAfter)
2139
+ );
2140
+ if (startAfterDoc.exists()) {
2141
+ q = query3(q, startAfter2(startAfterDoc));
2142
+ }
2143
+ }
2144
+ const patientsSnapshot = await getDocs3(q);
2145
+ const patients = [];
2146
+ patientsSnapshot.forEach((doc32) => {
2147
+ patients.push(doc32.data());
2148
+ });
2149
+ console.log(
2150
+ `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
2151
+ );
2152
+ return patients;
2153
+ } catch (error) {
2154
+ console.error(
2155
+ `[getPatientsByPractitionerUtil] Error fetching patients for practitioner:`,
2156
+ error
2157
+ );
2158
+ throw new Error(
2159
+ `Failed to retrieve patients for practitioner: ${error instanceof Error ? error.message : String(error)}`
2160
+ );
2161
+ }
2162
+ };
2163
+
2164
+ // src/services/patient/utils/clinic.utils.ts
2165
+ import {
2166
+ collection as collection4,
2167
+ query as query4,
2168
+ where as where4,
2169
+ getDocs as getDocs4,
2170
+ limit as limit3,
2171
+ startAfter as startAfter3,
2172
+ doc as doc5,
2173
+ getDoc as getDoc8
2174
+ } from "firebase/firestore";
2175
+ var getPatientsByClinicUtil = async (db, clinicId, options) => {
2176
+ try {
2177
+ console.log(
2178
+ `[getPatientsByClinicUtil] Fetching patients for clinic ID: ${clinicId} with options:`,
2179
+ options
2180
+ );
2181
+ const patientsCollection = collection4(db, PATIENTS_COLLECTION);
2182
+ const constraints = [
2183
+ where4("clinicIds", "array-contains", clinicId)
2184
+ ];
2185
+ let q = query4(patientsCollection, ...constraints);
2186
+ if (options == null ? void 0 : options.limit) {
2187
+ q = query4(q, limit3(options.limit));
2188
+ }
2189
+ if (options == null ? void 0 : options.startAfter) {
2190
+ const startAfterDoc = await getDoc8(
2191
+ doc5(db, PATIENTS_COLLECTION, options.startAfter)
2192
+ );
2193
+ if (startAfterDoc.exists()) {
2194
+ q = query4(q, startAfter3(startAfterDoc));
2195
+ }
2196
+ }
2197
+ const patientsSnapshot = await getDocs4(q);
2198
+ const patients = [];
2199
+ patientsSnapshot.forEach((doc32) => {
2200
+ patients.push(doc32.data());
2201
+ });
2202
+ console.log(
2203
+ `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
2204
+ );
2205
+ return patients;
2206
+ } catch (error) {
2207
+ console.error(
2208
+ `[getPatientsByClinicUtil] Error fetching patients for clinic:`,
2209
+ error
2210
+ );
2211
+ throw new Error(
2212
+ `Failed to retrieve patients for clinic: ${error instanceof Error ? error.message : String(error)}`
2213
+ );
2214
+ }
2215
+ };
2216
+
2111
2217
  // src/services/patient/patient.service.ts
2112
2218
  var PatientService = class extends BaseService {
2113
2219
  constructor(db, auth, app) {
@@ -2164,11 +2270,22 @@ var PatientService = class extends BaseService {
2164
2270
  // Metode za rad sa medicinskim informacijama
2165
2271
  async createMedicalInfo(patientId, data) {
2166
2272
  const currentUser = await this.getCurrentUser();
2167
- await createMedicalInfoUtil(this.db, patientId, data, currentUser.uid, currentUser.roles);
2273
+ await createMedicalInfoUtil(
2274
+ this.db,
2275
+ patientId,
2276
+ data,
2277
+ currentUser.uid,
2278
+ currentUser.roles
2279
+ );
2168
2280
  }
2169
2281
  async getMedicalInfo(patientId) {
2170
2282
  const currentUser = await this.getCurrentUser();
2171
- return getMedicalInfoUtil(this.db, patientId, currentUser.uid, currentUser.roles);
2283
+ return getMedicalInfoUtil(
2284
+ this.db,
2285
+ patientId,
2286
+ currentUser.uid,
2287
+ currentUser.roles
2288
+ );
2172
2289
  }
2173
2290
  async getMedicalInfoByUserRef(userRef) {
2174
2291
  const profile = await this.getPatientProfileByUserRef(userRef);
@@ -2200,11 +2317,21 @@ var PatientService = class extends BaseService {
2200
2317
  }
2201
2318
  async updateBlockingCondition(patientId, data) {
2202
2319
  const currentUser = await this.getCurrentUser();
2203
- await updateBlockingConditionUtil(this.db, patientId, data, currentUser.uid);
2320
+ await updateBlockingConditionUtil(
2321
+ this.db,
2322
+ patientId,
2323
+ data,
2324
+ currentUser.uid
2325
+ );
2204
2326
  }
2205
2327
  async removeBlockingCondition(patientId, conditionIndex) {
2206
2328
  const currentUser = await this.getCurrentUser();
2207
- await removeBlockingConditionUtil(this.db, patientId, conditionIndex, currentUser.uid);
2329
+ await removeBlockingConditionUtil(
2330
+ this.db,
2331
+ patientId,
2332
+ conditionIndex,
2333
+ currentUser.uid
2334
+ );
2208
2335
  }
2209
2336
  // Metode za rad sa kontraindikacijama
2210
2337
  async addContraindication(patientId, data) {
@@ -2217,7 +2344,12 @@ var PatientService = class extends BaseService {
2217
2344
  }
2218
2345
  async removeContraindication(patientId, contraindicationIndex) {
2219
2346
  const currentUser = await this.getCurrentUser();
2220
- await removeContraindicationUtil(this.db, patientId, contraindicationIndex, currentUser.uid);
2347
+ await removeContraindicationUtil(
2348
+ this.db,
2349
+ patientId,
2350
+ contraindicationIndex,
2351
+ currentUser.uid
2352
+ );
2221
2353
  }
2222
2354
  // Metode za rad sa medikacijama
2223
2355
  async addMedication(patientId, data) {
@@ -2230,7 +2362,12 @@ var PatientService = class extends BaseService {
2230
2362
  }
2231
2363
  async removeMedication(patientId, medicationIndex) {
2232
2364
  const currentUser = await this.getCurrentUser();
2233
- await removeMedicationUtil(this.db, patientId, medicationIndex, currentUser.uid);
2365
+ await removeMedicationUtil(
2366
+ this.db,
2367
+ patientId,
2368
+ medicationIndex,
2369
+ currentUser.uid
2370
+ );
2234
2371
  }
2235
2372
  // Pomoćne metode
2236
2373
  async addExpoToken(patientId, token) {
@@ -2261,7 +2398,9 @@ var PatientService = class extends BaseService {
2261
2398
  if (!this.auth.currentUser) {
2262
2399
  throw new Error("No authenticated user");
2263
2400
  }
2264
- const userDoc = await getDoc7(doc4(this.db, "users", this.auth.currentUser.uid));
2401
+ const userDoc = await getDoc9(
2402
+ doc6(this.db, "users", this.auth.currentUser.uid)
2403
+ );
2265
2404
  if (!userDoc.exists()) {
2266
2405
  throw new Error("User not found");
2267
2406
  }
@@ -2337,19 +2476,52 @@ var PatientService = class extends BaseService {
2337
2476
  * @returns {Promise<PatientProfile[]>} A promise resolving to an array of all patient profiles.
2338
2477
  */
2339
2478
  async getAllPatients(options) {
2340
- console.log(`[PatientService.getAllPatients] Fetching patients with options:`, options);
2479
+ console.log(
2480
+ `[PatientService.getAllPatients] Fetching patients with options:`,
2481
+ options
2482
+ );
2341
2483
  return getAllPatientsUtil(this.db, options);
2342
2484
  }
2485
+ /**
2486
+ * Gets all patients associated with a specific practitioner.
2487
+ *
2488
+ * @param {string} practitionerId - ID of the practitioner whose patients to retrieve
2489
+ * @param {Object} options - Optional parameters for pagination
2490
+ * @param {number} options.limit - Maximum number of profiles to return
2491
+ * @param {string} options.startAfter - The ID of the document to start after (for pagination)
2492
+ * @returns {Promise<PatientProfile[]>} A promise resolving to an array of patient profiles
2493
+ */
2494
+ async getPatientsByPractitioner(practitionerId, options) {
2495
+ console.log(
2496
+ `[PatientService.getPatientsByPractitioner] Fetching patients for practitioner: ${practitionerId}`
2497
+ );
2498
+ return getPatientsByPractitionerUtil(this.db, practitionerId, options);
2499
+ }
2500
+ /**
2501
+ * Gets all patients associated with a specific clinic.
2502
+ *
2503
+ * @param {string} clinicId - ID of the clinic whose patients to retrieve
2504
+ * @param {Object} options - Optional parameters for pagination
2505
+ * @param {number} options.limit - Maximum number of profiles to return
2506
+ * @param {string} options.startAfter - The ID of the document to start after (for pagination)
2507
+ * @returns {Promise<PatientProfile[]>} A promise resolving to an array of patient profiles
2508
+ */
2509
+ async getPatientsByClinic(clinicId, options) {
2510
+ console.log(
2511
+ `[PatientService.getPatientsByClinic] Fetching patients for clinic: ${clinicId}`
2512
+ );
2513
+ return getPatientsByClinicUtil(this.db, clinicId, options);
2514
+ }
2343
2515
  };
2344
2516
 
2345
2517
  // src/services/clinic/utils/admin.utils.ts
2346
2518
  import {
2347
- collection as collection3,
2348
- doc as doc5,
2349
- getDoc as getDoc8,
2350
- getDocs as getDocs3,
2351
- query as query3,
2352
- where as where3,
2519
+ collection as collection5,
2520
+ doc as doc7,
2521
+ getDoc as getDoc10,
2522
+ getDocs as getDocs5,
2523
+ query as query5,
2524
+ where as where5,
2353
2525
  updateDoc as updateDoc7,
2354
2526
  setDoc as setDoc6,
2355
2527
  deleteDoc,
@@ -3160,7 +3332,7 @@ async function createClinicAdmin(db, data, clinicGroupService) {
3160
3332
  }
3161
3333
  console.log("[CLINIC_ADMIN] Preparing admin data object");
3162
3334
  const adminData = {
3163
- id: doc5(collection3(db, CLINIC_ADMINS_COLLECTION)).id,
3335
+ id: doc7(collection5(db, CLINIC_ADMINS_COLLECTION)).id,
3164
3336
  // Generate a new ID for the admin document
3165
3337
  userRef: validatedData.userRef,
3166
3338
  clinicGroupId: clinicGroupId || "",
@@ -3195,7 +3367,7 @@ async function createClinicAdmin(db, data, clinicGroupService) {
3195
3367
  adminId: adminData.id
3196
3368
  });
3197
3369
  try {
3198
- await setDoc6(doc5(db, CLINIC_ADMINS_COLLECTION, adminData.id), adminData);
3370
+ await setDoc6(doc7(db, CLINIC_ADMINS_COLLECTION, adminData.id), adminData);
3199
3371
  console.log("[CLINIC_ADMIN] Admin saved successfully");
3200
3372
  } catch (firestoreError) {
3201
3373
  console.error(
@@ -3244,31 +3416,31 @@ async function checkClinicGroupExists(db, groupId, clinicGroupService) {
3244
3416
  return !!group;
3245
3417
  }
3246
3418
  async function getClinicAdmin(db, adminId) {
3247
- const docRef = doc5(db, CLINIC_ADMINS_COLLECTION, adminId);
3248
- const docSnap = await getDoc8(docRef);
3419
+ const docRef = doc7(db, CLINIC_ADMINS_COLLECTION, adminId);
3420
+ const docSnap = await getDoc10(docRef);
3249
3421
  if (docSnap.exists()) {
3250
3422
  return docSnap.data();
3251
3423
  }
3252
3424
  return null;
3253
3425
  }
3254
3426
  async function getClinicAdminByUserRef(db, userRef) {
3255
- const q = query3(
3256
- collection3(db, CLINIC_ADMINS_COLLECTION),
3257
- where3("userRef", "==", userRef)
3427
+ const q = query5(
3428
+ collection5(db, CLINIC_ADMINS_COLLECTION),
3429
+ where5("userRef", "==", userRef)
3258
3430
  );
3259
- const querySnapshot = await getDocs3(q);
3431
+ const querySnapshot = await getDocs5(q);
3260
3432
  if (querySnapshot.empty) {
3261
3433
  return null;
3262
3434
  }
3263
3435
  return querySnapshot.docs[0].data();
3264
3436
  }
3265
3437
  async function getClinicAdminsByGroup(db, clinicGroupId) {
3266
- const q = query3(
3267
- collection3(db, CLINIC_ADMINS_COLLECTION),
3268
- where3("clinicGroupId", "==", clinicGroupId)
3438
+ const q = query5(
3439
+ collection5(db, CLINIC_ADMINS_COLLECTION),
3440
+ where5("clinicGroupId", "==", clinicGroupId)
3269
3441
  );
3270
- const querySnapshot = await getDocs3(q);
3271
- return querySnapshot.docs.map((doc30) => doc30.data());
3442
+ const querySnapshot = await getDocs5(q);
3443
+ return querySnapshot.docs.map((doc32) => doc32.data());
3272
3444
  }
3273
3445
  async function updateClinicAdmin(db, adminId, data) {
3274
3446
  const admin = await getClinicAdmin(db, adminId);
@@ -3279,7 +3451,7 @@ async function updateClinicAdmin(db, adminId, data) {
3279
3451
  ...data,
3280
3452
  updatedAt: serverTimestamp8()
3281
3453
  };
3282
- await updateDoc7(doc5(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
3454
+ await updateDoc7(doc7(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
3283
3455
  const updatedAdmin = await getClinicAdmin(db, adminId);
3284
3456
  if (!updatedAdmin) {
3285
3457
  throw new Error("Failed to retrieve updated admin");
@@ -3291,7 +3463,7 @@ async function deleteClinicAdmin(db, adminId) {
3291
3463
  if (!admin) {
3292
3464
  throw new Error("Clinic admin not found");
3293
3465
  }
3294
- await deleteDoc(doc5(db, CLINIC_ADMINS_COLLECTION, adminId));
3466
+ await deleteDoc(doc7(db, CLINIC_ADMINS_COLLECTION, adminId));
3295
3467
  }
3296
3468
  async function addClinicToManaged(db, adminId, clinicId, requesterId, clinicService) {
3297
3469
  const admin = await getClinicAdmin(db, adminId);
@@ -3533,19 +3705,19 @@ var ClinicAdminService = class extends BaseService {
3533
3705
 
3534
3706
  // src/services/practitioner/practitioner.service.ts
3535
3707
  import {
3536
- collection as collection4,
3537
- doc as doc6,
3538
- getDoc as getDoc9,
3539
- getDocs as getDocs4,
3540
- query as query4,
3541
- where as where4,
3708
+ collection as collection6,
3709
+ doc as doc8,
3710
+ getDoc as getDoc11,
3711
+ getDocs as getDocs6,
3712
+ query as query6,
3713
+ where as where6,
3542
3714
  updateDoc as updateDoc8,
3543
3715
  setDoc as setDoc7,
3544
3716
  deleteDoc as deleteDoc2,
3545
3717
  Timestamp as Timestamp8,
3546
3718
  serverTimestamp as serverTimestamp9,
3547
- limit as limit2,
3548
- startAfter as startAfter2,
3719
+ limit as limit4,
3720
+ startAfter as startAfter4,
3549
3721
  orderBy,
3550
3722
  arrayUnion as arrayUnion5,
3551
3723
  arrayRemove as arrayRemove4
@@ -3605,7 +3777,7 @@ var PractitionerService = class extends BaseService {
3605
3777
  createdAt: Timestamp8.now(),
3606
3778
  updatedAt: Timestamp8.now()
3607
3779
  });
3608
- const practitionerRef = doc6(
3780
+ const practitionerRef = doc8(
3609
3781
  this.db,
3610
3782
  PRACTITIONERS_COLLECTION,
3611
3783
  practitionerId
@@ -3690,7 +3862,7 @@ var PractitionerService = class extends BaseService {
3690
3862
  updatedAt: Timestamp8.now()
3691
3863
  });
3692
3864
  await setDoc7(
3693
- doc6(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
3865
+ doc8(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
3694
3866
  practitionerData
3695
3867
  );
3696
3868
  const savedPractitioner = await this.getPractitioner(practitionerData.id);
@@ -3712,7 +3884,7 @@ var PractitionerService = class extends BaseService {
3712
3884
  };
3713
3885
  practitionerTokenSchema.parse(token);
3714
3886
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
3715
- await setDoc7(doc6(this.db, tokenPath), token);
3887
+ await setDoc7(doc8(this.db, tokenPath), token);
3716
3888
  return { practitioner: savedPractitioner, token };
3717
3889
  } catch (error) {
3718
3890
  if (error instanceof z13.ZodError) {
@@ -3765,7 +3937,7 @@ var PractitionerService = class extends BaseService {
3765
3937
  };
3766
3938
  practitionerTokenSchema.parse(token);
3767
3939
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${validatedData.practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
3768
- await setDoc7(doc6(this.db, tokenPath), token);
3940
+ await setDoc7(doc8(this.db, tokenPath), token);
3769
3941
  return token;
3770
3942
  } catch (error) {
3771
3943
  if (error instanceof z13.ZodError) {
@@ -3780,17 +3952,17 @@ var PractitionerService = class extends BaseService {
3780
3952
  * @returns Array of active tokens
3781
3953
  */
3782
3954
  async getPractitionerActiveTokens(practitionerId) {
3783
- const tokensRef = collection4(
3955
+ const tokensRef = collection6(
3784
3956
  this.db,
3785
3957
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}`
3786
3958
  );
3787
- const q = query4(
3959
+ const q = query6(
3788
3960
  tokensRef,
3789
- where4("status", "==", "active" /* ACTIVE */),
3790
- where4("expiresAt", ">", Timestamp8.now())
3961
+ where6("status", "==", "active" /* ACTIVE */),
3962
+ where6("expiresAt", ">", Timestamp8.now())
3791
3963
  );
3792
- const querySnapshot = await getDocs4(q);
3793
- return querySnapshot.docs.map((doc30) => doc30.data());
3964
+ const querySnapshot = await getDocs6(q);
3965
+ return querySnapshot.docs.map((doc32) => doc32.data());
3794
3966
  }
3795
3967
  /**
3796
3968
  * Gets a token by its string value and validates it
@@ -3798,21 +3970,21 @@ var PractitionerService = class extends BaseService {
3798
3970
  * @returns The token if found and valid, null otherwise
3799
3971
  */
3800
3972
  async validateToken(tokenString) {
3801
- const practitionersRef = collection4(this.db, PRACTITIONERS_COLLECTION);
3802
- const practitionersSnapshot = await getDocs4(practitionersRef);
3973
+ const practitionersRef = collection6(this.db, PRACTITIONERS_COLLECTION);
3974
+ const practitionersSnapshot = await getDocs6(practitionersRef);
3803
3975
  for (const practitionerDoc of practitionersSnapshot.docs) {
3804
3976
  const practitionerId = practitionerDoc.id;
3805
- const tokensRef = collection4(
3977
+ const tokensRef = collection6(
3806
3978
  this.db,
3807
3979
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}`
3808
3980
  );
3809
- const q = query4(
3981
+ const q = query6(
3810
3982
  tokensRef,
3811
- where4("token", "==", tokenString),
3812
- where4("status", "==", "active" /* ACTIVE */),
3813
- where4("expiresAt", ">", Timestamp8.now())
3983
+ where6("token", "==", tokenString),
3984
+ where6("status", "==", "active" /* ACTIVE */),
3985
+ where6("expiresAt", ">", Timestamp8.now())
3814
3986
  );
3815
- const tokenSnapshot = await getDocs4(q);
3987
+ const tokenSnapshot = await getDocs6(q);
3816
3988
  if (!tokenSnapshot.empty) {
3817
3989
  return tokenSnapshot.docs[0].data();
3818
3990
  }
@@ -3826,7 +3998,7 @@ var PractitionerService = class extends BaseService {
3826
3998
  * @param userId ID of the user using the token
3827
3999
  */
3828
4000
  async markTokenAsUsed(tokenId, practitionerId, userId) {
3829
- const tokenRef = doc6(
4001
+ const tokenRef = doc8(
3830
4002
  this.db,
3831
4003
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
3832
4004
  );
@@ -3840,8 +4012,8 @@ var PractitionerService = class extends BaseService {
3840
4012
  * Dohvata zdravstvenog radnika po ID-u
3841
4013
  */
3842
4014
  async getPractitioner(practitionerId) {
3843
- const practitionerDoc = await getDoc9(
3844
- doc6(this.db, PRACTITIONERS_COLLECTION, practitionerId)
4015
+ const practitionerDoc = await getDoc11(
4016
+ doc8(this.db, PRACTITIONERS_COLLECTION, practitionerId)
3845
4017
  );
3846
4018
  if (!practitionerDoc.exists()) {
3847
4019
  return null;
@@ -3852,11 +4024,11 @@ var PractitionerService = class extends BaseService {
3852
4024
  * Dohvata zdravstvenog radnika po User ID-u
3853
4025
  */
3854
4026
  async getPractitionerByUserRef(userRef) {
3855
- const q = query4(
3856
- collection4(this.db, PRACTITIONERS_COLLECTION),
3857
- where4("userRef", "==", userRef)
4027
+ const q = query6(
4028
+ collection6(this.db, PRACTITIONERS_COLLECTION),
4029
+ where6("userRef", "==", userRef)
3858
4030
  );
3859
- const querySnapshot = await getDocs4(q);
4031
+ const querySnapshot = await getDocs6(q);
3860
4032
  if (querySnapshot.empty) {
3861
4033
  return null;
3862
4034
  }
@@ -3866,38 +4038,38 @@ var PractitionerService = class extends BaseService {
3866
4038
  * Dohvata sve zdravstvene radnike za određenu kliniku sa statusom ACTIVE
3867
4039
  */
3868
4040
  async getPractitionersByClinic(clinicId) {
3869
- const q = query4(
3870
- collection4(this.db, PRACTITIONERS_COLLECTION),
3871
- where4("clinics", "array-contains", clinicId),
3872
- where4("isActive", "==", true),
3873
- where4("status", "==", "active" /* ACTIVE */)
4041
+ const q = query6(
4042
+ collection6(this.db, PRACTITIONERS_COLLECTION),
4043
+ where6("clinics", "array-contains", clinicId),
4044
+ where6("isActive", "==", true),
4045
+ where6("status", "==", "active" /* ACTIVE */)
3874
4046
  );
3875
- const querySnapshot = await getDocs4(q);
3876
- return querySnapshot.docs.map((doc30) => doc30.data());
4047
+ const querySnapshot = await getDocs6(q);
4048
+ return querySnapshot.docs.map((doc32) => doc32.data());
3877
4049
  }
3878
4050
  /**
3879
4051
  * Dohvata sve zdravstvene radnike za određenu kliniku
3880
4052
  */
3881
4053
  async getAllPractitionersByClinic(clinicId) {
3882
- const q = query4(
3883
- collection4(this.db, PRACTITIONERS_COLLECTION),
3884
- where4("clinics", "array-contains", clinicId),
3885
- where4("isActive", "==", true)
4054
+ const q = query6(
4055
+ collection6(this.db, PRACTITIONERS_COLLECTION),
4056
+ where6("clinics", "array-contains", clinicId),
4057
+ where6("isActive", "==", true)
3886
4058
  );
3887
- const querySnapshot = await getDocs4(q);
3888
- return querySnapshot.docs.map((doc30) => doc30.data());
4059
+ const querySnapshot = await getDocs6(q);
4060
+ return querySnapshot.docs.map((doc32) => doc32.data());
3889
4061
  }
3890
4062
  /**
3891
4063
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
3892
4064
  */
3893
4065
  async getDraftPractitionersByClinic(clinicId) {
3894
- const q = query4(
3895
- collection4(this.db, PRACTITIONERS_COLLECTION),
3896
- where4("clinics", "array-contains", clinicId),
3897
- where4("status", "==", "draft" /* DRAFT */)
4066
+ const q = query6(
4067
+ collection6(this.db, PRACTITIONERS_COLLECTION),
4068
+ where6("clinics", "array-contains", clinicId),
4069
+ where6("status", "==", "draft" /* DRAFT */)
3898
4070
  );
3899
- const querySnapshot = await getDocs4(q);
3900
- return querySnapshot.docs.map((doc30) => doc30.data());
4071
+ const querySnapshot = await getDocs6(q);
4072
+ return querySnapshot.docs.map((doc32) => doc32.data());
3901
4073
  }
3902
4074
  /**
3903
4075
  * Updates a practitioner
@@ -3905,12 +4077,12 @@ var PractitionerService = class extends BaseService {
3905
4077
  async updatePractitioner(practitionerId, data) {
3906
4078
  try {
3907
4079
  const validData = data;
3908
- const practitionerRef = doc6(
4080
+ const practitionerRef = doc8(
3909
4081
  this.db,
3910
4082
  PRACTITIONERS_COLLECTION,
3911
4083
  practitionerId
3912
4084
  );
3913
- const practitionerDoc = await getDoc9(practitionerRef);
4085
+ const practitionerDoc = await getDoc11(practitionerRef);
3914
4086
  if (!practitionerDoc.exists()) {
3915
4087
  throw new Error(`Practitioner ${practitionerId} not found`);
3916
4088
  }
@@ -3941,12 +4113,12 @@ var PractitionerService = class extends BaseService {
3941
4113
  async addClinic(practitionerId, clinicId) {
3942
4114
  var _a;
3943
4115
  try {
3944
- const practitionerRef = doc6(
4116
+ const practitionerRef = doc8(
3945
4117
  this.db,
3946
4118
  PRACTITIONERS_COLLECTION,
3947
4119
  practitionerId
3948
4120
  );
3949
- const practitionerDoc = await getDoc9(practitionerRef);
4121
+ const practitionerDoc = await getDoc11(practitionerRef);
3950
4122
  if (!practitionerDoc.exists()) {
3951
4123
  throw new Error(`Practitioner ${practitionerId} not found`);
3952
4124
  }
@@ -3974,12 +4146,12 @@ var PractitionerService = class extends BaseService {
3974
4146
  */
3975
4147
  async removeClinic(practitionerId, clinicId) {
3976
4148
  try {
3977
- const practitionerRef = doc6(
4149
+ const practitionerRef = doc8(
3978
4150
  this.db,
3979
4151
  PRACTITIONERS_COLLECTION,
3980
4152
  practitionerId
3981
4153
  );
3982
- const practitionerDoc = await getDoc9(practitionerRef);
4154
+ const practitionerDoc = await getDoc11(practitionerRef);
3983
4155
  if (!practitionerDoc.exists()) {
3984
4156
  throw new Error(`Practitioner ${practitionerId} not found`);
3985
4157
  }
@@ -4019,7 +4191,7 @@ var PractitionerService = class extends BaseService {
4019
4191
  if (!practitioner) {
4020
4192
  throw new Error("Practitioner not found");
4021
4193
  }
4022
- await deleteDoc2(doc6(this.db, PRACTITIONERS_COLLECTION, practitionerId));
4194
+ await deleteDoc2(doc8(this.db, PRACTITIONERS_COLLECTION, practitionerId));
4023
4195
  }
4024
4196
  /**
4025
4197
  * Validates a registration token and claims the associated draft practitioner profile
@@ -4063,23 +4235,23 @@ var PractitionerService = class extends BaseService {
4063
4235
  try {
4064
4236
  const constraints = [];
4065
4237
  if (!(options == null ? void 0 : options.includeDraftPractitioners)) {
4066
- constraints.push(where4("status", "==", "active" /* ACTIVE */));
4238
+ constraints.push(where6("status", "==", "active" /* ACTIVE */));
4067
4239
  }
4068
4240
  constraints.push(orderBy("basicInfo.lastName", "asc"));
4069
4241
  constraints.push(orderBy("basicInfo.firstName", "asc"));
4070
4242
  if ((options == null ? void 0 : options.pagination) && options.pagination > 0) {
4071
4243
  if (options.lastDoc) {
4072
- constraints.push(startAfter2(options.lastDoc));
4244
+ constraints.push(startAfter4(options.lastDoc));
4073
4245
  }
4074
- constraints.push(limit2(options.pagination));
4246
+ constraints.push(limit4(options.pagination));
4075
4247
  }
4076
- const q = query4(
4077
- collection4(this.db, PRACTITIONERS_COLLECTION),
4248
+ const q = query6(
4249
+ collection6(this.db, PRACTITIONERS_COLLECTION),
4078
4250
  ...constraints
4079
4251
  );
4080
- const querySnapshot = await getDocs4(q);
4252
+ const querySnapshot = await getDocs6(q);
4081
4253
  const practitioners = querySnapshot.docs.map(
4082
- (doc30) => doc30.data()
4254
+ (doc32) => doc32.data()
4083
4255
  );
4084
4256
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
4085
4257
  return {
@@ -4122,12 +4294,12 @@ var PractitionerService = class extends BaseService {
4122
4294
  );
4123
4295
  const constraints = [];
4124
4296
  if (!filters.includeDraftPractitioners) {
4125
- constraints.push(where4("status", "==", "active" /* ACTIVE */));
4297
+ constraints.push(where6("status", "==", "active" /* ACTIVE */));
4126
4298
  }
4127
- constraints.push(where4("isActive", "==", true));
4299
+ constraints.push(where6("isActive", "==", true));
4128
4300
  if (filters.certifications && filters.certifications.length > 0) {
4129
4301
  constraints.push(
4130
- where4(
4302
+ where6(
4131
4303
  "certification.certifications",
4132
4304
  "array-contains-any",
4133
4305
  filters.certifications
@@ -4138,20 +4310,20 @@ var PractitionerService = class extends BaseService {
4138
4310
  constraints.push(orderBy("basicInfo.firstName", "asc"));
4139
4311
  if (filters.pagination && filters.pagination > 0) {
4140
4312
  if (filters.lastDoc) {
4141
- constraints.push(startAfter2(filters.lastDoc));
4313
+ constraints.push(startAfter4(filters.lastDoc));
4142
4314
  }
4143
- constraints.push(limit2(filters.pagination));
4315
+ constraints.push(limit4(filters.pagination));
4144
4316
  }
4145
- const q = query4(
4146
- collection4(this.db, PRACTITIONERS_COLLECTION),
4317
+ const q = query6(
4318
+ collection6(this.db, PRACTITIONERS_COLLECTION),
4147
4319
  ...constraints
4148
4320
  );
4149
- const querySnapshot = await getDocs4(q);
4321
+ const querySnapshot = await getDocs6(q);
4150
4322
  console.log(
4151
4323
  `[PRACTITIONER_SERVICE] Found ${querySnapshot.docs.length} practitioners with base query`
4152
4324
  );
4153
- let practitioners = querySnapshot.docs.map((doc30) => {
4154
- return { ...doc30.data(), id: doc30.id };
4325
+ let practitioners = querySnapshot.docs.map((doc32) => {
4326
+ return { ...doc32.data(), id: doc32.id };
4155
4327
  });
4156
4328
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
4157
4329
  if (filters.nameSearch && filters.nameSearch.trim() !== "") {
@@ -4272,13 +4444,13 @@ var UserService = class extends BaseService {
4272
4444
  updatedAt: serverTimestamp10(),
4273
4445
  lastLoginAt: serverTimestamp10()
4274
4446
  };
4275
- await setDoc8(doc7(this.db, USERS_COLLECTION, userData.uid), userData);
4447
+ await setDoc8(doc9(this.db, USERS_COLLECTION, userData.uid), userData);
4276
4448
  const profiles = await this.createProfilesForRoles(
4277
4449
  userData.uid,
4278
4450
  roles,
4279
4451
  options
4280
4452
  );
4281
- await updateDoc9(doc7(this.db, USERS_COLLECTION, userData.uid), profiles);
4453
+ await updateDoc9(doc9(this.db, USERS_COLLECTION, userData.uid), profiles);
4282
4454
  return this.getUserById(userData.uid);
4283
4455
  }
4284
4456
  /**
@@ -4381,7 +4553,7 @@ var UserService = class extends BaseService {
4381
4553
  * Dohvata korisnika po ID-u
4382
4554
  */
4383
4555
  async getUserById(uid) {
4384
- const userDoc = await getDoc10(doc7(this.db, USERS_COLLECTION, uid));
4556
+ const userDoc = await getDoc12(doc9(this.db, USERS_COLLECTION, uid));
4385
4557
  if (!userDoc.exists()) {
4386
4558
  throw USER_ERRORS.NOT_FOUND;
4387
4559
  }
@@ -4392,28 +4564,28 @@ var UserService = class extends BaseService {
4392
4564
  * Dohvata korisnika po email-u
4393
4565
  */
4394
4566
  async getUserByEmail(email) {
4395
- const usersRef = collection5(this.db, USERS_COLLECTION);
4396
- const q = query5(usersRef, where5("email", "==", email));
4397
- const querySnapshot = await getDocs5(q);
4567
+ const usersRef = collection7(this.db, USERS_COLLECTION);
4568
+ const q = query7(usersRef, where7("email", "==", email));
4569
+ const querySnapshot = await getDocs7(q);
4398
4570
  if (querySnapshot.empty) return null;
4399
4571
  const userData = querySnapshot.docs[0].data();
4400
4572
  return userSchema.parse(userData);
4401
4573
  }
4402
4574
  async getUsersByRole(role) {
4403
4575
  const constraints = [
4404
- where5("roles", "array-contains", role)
4576
+ where7("roles", "array-contains", role)
4405
4577
  ];
4406
- const q = query5(collection5(this.db, USERS_COLLECTION), ...constraints);
4407
- const querySnapshot = await getDocs5(q);
4408
- const users = querySnapshot.docs.map((doc30) => doc30.data());
4578
+ const q = query7(collection7(this.db, USERS_COLLECTION), ...constraints);
4579
+ const querySnapshot = await getDocs7(q);
4580
+ const users = querySnapshot.docs.map((doc32) => doc32.data());
4409
4581
  return Promise.all(users.map((userData) => userSchema.parse(userData)));
4410
4582
  }
4411
4583
  /**
4412
4584
  * Ažurira timestamp poslednjeg logovanja
4413
4585
  */
4414
4586
  async updateUserLoginTimestamp(uid) {
4415
- const userRef = doc7(this.db, USERS_COLLECTION, uid);
4416
- const userDoc = await getDoc10(userRef);
4587
+ const userRef = doc9(this.db, USERS_COLLECTION, uid);
4588
+ const userDoc = await getDoc12(userRef);
4417
4589
  if (!userDoc.exists()) {
4418
4590
  throw AUTH_ERRORS.USER_NOT_FOUND;
4419
4591
  }
@@ -4424,8 +4596,8 @@ var UserService = class extends BaseService {
4424
4596
  return this.getUserById(uid);
4425
4597
  }
4426
4598
  async upgradeAnonymousUser(uid, email) {
4427
- const userRef = doc7(this.db, USERS_COLLECTION, uid);
4428
- const userDoc = await getDoc10(userRef);
4599
+ const userRef = doc9(this.db, USERS_COLLECTION, uid);
4600
+ const userDoc = await getDoc12(userRef);
4429
4601
  if (!userDoc.exists()) {
4430
4602
  throw USER_ERRORS.NOT_FOUND;
4431
4603
  }
@@ -4437,8 +4609,8 @@ var UserService = class extends BaseService {
4437
4609
  return this.getUserById(uid);
4438
4610
  }
4439
4611
  async updateUser(uid, updates) {
4440
- const userRef = doc7(this.db, USERS_COLLECTION, uid);
4441
- const userDoc = await getDoc10(userRef);
4612
+ const userRef = doc9(this.db, USERS_COLLECTION, uid);
4613
+ const userDoc = await getDoc12(userRef);
4442
4614
  if (!userDoc.exists()) {
4443
4615
  throw USER_ERRORS.NOT_FOUND;
4444
4616
  }
@@ -4469,7 +4641,7 @@ var UserService = class extends BaseService {
4469
4641
  const user = await this.getUserById(uid);
4470
4642
  if (user.roles.includes(role)) return;
4471
4643
  const profiles = await this.createProfilesForRoles(uid, [role], options);
4472
- await updateDoc9(doc7(this.db, USERS_COLLECTION, uid), {
4644
+ await updateDoc9(doc9(this.db, USERS_COLLECTION, uid), {
4473
4645
  roles: [...user.roles, role],
4474
4646
  ...profiles,
4475
4647
  updatedAt: serverTimestamp10()
@@ -4504,15 +4676,15 @@ var UserService = class extends BaseService {
4504
4676
  }
4505
4677
  break;
4506
4678
  }
4507
- await updateDoc9(doc7(this.db, USERS_COLLECTION, uid), {
4679
+ await updateDoc9(doc9(this.db, USERS_COLLECTION, uid), {
4508
4680
  roles: user.roles.filter((r) => r !== role),
4509
4681
  updatedAt: serverTimestamp10()
4510
4682
  });
4511
4683
  }
4512
4684
  // Delete operations
4513
4685
  async deleteUser(uid) {
4514
- const userRef = doc7(this.db, USERS_COLLECTION, uid);
4515
- const userDoc = await getDoc10(userRef);
4686
+ const userRef = doc9(this.db, USERS_COLLECTION, uid);
4687
+ const userDoc = await getDoc12(userRef);
4516
4688
  if (!userDoc.exists()) {
4517
4689
  throw USER_ERRORS.NOT_FOUND;
4518
4690
  }
@@ -4542,12 +4714,12 @@ var UserService = class extends BaseService {
4542
4714
 
4543
4715
  // src/services/clinic/utils/clinic-group.utils.ts
4544
4716
  import {
4545
- collection as collection6,
4546
- doc as doc8,
4547
- getDoc as getDoc11,
4548
- getDocs as getDocs6,
4549
- query as query6,
4550
- where as where6,
4717
+ collection as collection8,
4718
+ doc as doc10,
4719
+ getDoc as getDoc13,
4720
+ getDocs as getDocs8,
4721
+ query as query8,
4722
+ where as where8,
4551
4723
  updateDoc as updateDoc10,
4552
4724
  setDoc as setDoc9,
4553
4725
  Timestamp as Timestamp10
@@ -4676,7 +4848,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
4676
4848
  }
4677
4849
  const now = Timestamp10.now();
4678
4850
  console.log("[CLINIC_GROUP] Preparing clinic group data object");
4679
- const groupId = doc8(collection6(db, CLINIC_GROUPS_COLLECTION)).id;
4851
+ const groupId = doc10(collection8(db, CLINIC_GROUPS_COLLECTION)).id;
4680
4852
  console.log("[CLINIC_GROUP] Logo value:", {
4681
4853
  logoValue: validatedData.logo,
4682
4854
  logoType: validatedData.logo === null ? "null" : typeof validatedData.logo
@@ -4726,7 +4898,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
4726
4898
  groupId: groupData.id
4727
4899
  });
4728
4900
  try {
4729
- await setDoc9(doc8(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
4901
+ await setDoc9(doc10(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
4730
4902
  console.log("[CLINIC_GROUP] Clinic group saved successfully");
4731
4903
  } catch (firestoreError) {
4732
4904
  console.error(
@@ -4772,20 +4944,20 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
4772
4944
  }
4773
4945
  }
4774
4946
  async function getClinicGroup(db, groupId) {
4775
- const docRef = doc8(db, CLINIC_GROUPS_COLLECTION, groupId);
4776
- const docSnap = await getDoc11(docRef);
4947
+ const docRef = doc10(db, CLINIC_GROUPS_COLLECTION, groupId);
4948
+ const docSnap = await getDoc13(docRef);
4777
4949
  if (docSnap.exists()) {
4778
4950
  return docSnap.data();
4779
4951
  }
4780
4952
  return null;
4781
4953
  }
4782
4954
  async function getAllActiveGroups(db) {
4783
- const q = query6(
4784
- collection6(db, CLINIC_GROUPS_COLLECTION),
4785
- where6("isActive", "==", true)
4955
+ const q = query8(
4956
+ collection8(db, CLINIC_GROUPS_COLLECTION),
4957
+ where8("isActive", "==", true)
4786
4958
  );
4787
- const querySnapshot = await getDocs6(q);
4788
- return querySnapshot.docs.map((doc30) => doc30.data());
4959
+ const querySnapshot = await getDocs8(q);
4960
+ return querySnapshot.docs.map((doc32) => doc32.data());
4789
4961
  }
4790
4962
  async function updateClinicGroup(db, groupId, data, app) {
4791
4963
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -4816,7 +4988,7 @@ async function updateClinicGroup(db, groupId, data, app) {
4816
4988
  updatedAt: Timestamp10.now()
4817
4989
  };
4818
4990
  console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
4819
- await updateDoc10(doc8(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
4991
+ await updateDoc10(doc10(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
4820
4992
  console.log("[CLINIC_GROUP] Clinic group updated successfully");
4821
4993
  const updatedGroup = await getClinicGroup(db, groupId);
4822
4994
  if (!updatedGroup) {
@@ -5161,8 +5333,8 @@ var ClinicGroupService = class extends BaseService {
5161
5333
 
5162
5334
  // src/services/clinic/clinic.service.ts
5163
5335
  import {
5164
- doc as doc10,
5165
- getDoc as getDoc13,
5336
+ doc as doc12,
5337
+ getDoc as getDoc15,
5166
5338
  updateDoc as updateDoc12,
5167
5339
  Timestamp as Timestamp12,
5168
5340
  serverTimestamp as serverTimestamp12,
@@ -5176,17 +5348,17 @@ import { z as z17 } from "zod";
5176
5348
 
5177
5349
  // src/services/clinic/utils/clinic.utils.ts
5178
5350
  import {
5179
- collection as collection7,
5180
- doc as doc9,
5181
- getDoc as getDoc12,
5182
- getDocs as getDocs7,
5183
- query as query7,
5184
- where as where7,
5351
+ collection as collection9,
5352
+ doc as doc11,
5353
+ getDoc as getDoc14,
5354
+ getDocs as getDocs9,
5355
+ query as query9,
5356
+ where as where9,
5185
5357
  updateDoc as updateDoc11,
5186
5358
  setDoc as setDoc10,
5187
5359
  Timestamp as Timestamp11,
5188
- limit as limit3,
5189
- startAfter as startAfter3
5360
+ limit as limit5,
5361
+ startAfter as startAfter5
5190
5362
  } from "firebase/firestore";
5191
5363
  import {
5192
5364
  geohashForLocation as geohashForLocation3,
@@ -5195,21 +5367,21 @@ import {
5195
5367
  } from "geofire-common";
5196
5368
  import { z as z16 } from "zod";
5197
5369
  async function getClinic(db, clinicId) {
5198
- const docRef = doc9(db, CLINICS_COLLECTION, clinicId);
5199
- const docSnap = await getDoc12(docRef);
5370
+ const docRef = doc11(db, CLINICS_COLLECTION, clinicId);
5371
+ const docSnap = await getDoc14(docRef);
5200
5372
  if (docSnap.exists()) {
5201
5373
  return docSnap.data();
5202
5374
  }
5203
5375
  return null;
5204
5376
  }
5205
5377
  async function getClinicsByGroup(db, groupId) {
5206
- const q = query7(
5207
- collection7(db, CLINICS_COLLECTION),
5208
- where7("clinicGroupId", "==", groupId),
5209
- where7("isActive", "==", true)
5378
+ const q = query9(
5379
+ collection9(db, CLINICS_COLLECTION),
5380
+ where9("clinicGroupId", "==", groupId),
5381
+ where9("isActive", "==", true)
5210
5382
  );
5211
- const querySnapshot = await getDocs7(q);
5212
- return querySnapshot.docs.map((doc30) => doc30.data());
5383
+ const querySnapshot = await getDocs9(q);
5384
+ return querySnapshot.docs.map((doc32) => doc32.data());
5213
5385
  }
5214
5386
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
5215
5387
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -5368,7 +5540,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
5368
5540
  };
5369
5541
  console.log("[CLINIC] Updating clinic in Firestore");
5370
5542
  try {
5371
- await updateDoc11(doc9(db, CLINICS_COLLECTION, clinicId), updatedData);
5543
+ await updateDoc11(doc11(db, CLINICS_COLLECTION, clinicId), updatedData);
5372
5544
  console.log("[CLINIC] Clinic updated successfully");
5373
5545
  } catch (updateError) {
5374
5546
  console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
@@ -5397,13 +5569,13 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
5397
5569
  if (clinicIds.length === 0) {
5398
5570
  return [];
5399
5571
  }
5400
- const constraints = [where7("id", "in", clinicIds)];
5572
+ const constraints = [where9("id", "in", clinicIds)];
5401
5573
  if (options.isActive !== void 0) {
5402
- constraints.push(where7("isActive", "==", options.isActive));
5574
+ constraints.push(where9("isActive", "==", options.isActive));
5403
5575
  }
5404
- const q = query7(collection7(db, CLINICS_COLLECTION), ...constraints);
5405
- const querySnapshot = await getDocs7(q);
5406
- return querySnapshot.docs.map((doc30) => doc30.data());
5576
+ const q = query9(collection9(db, CLINICS_COLLECTION), ...constraints);
5577
+ const querySnapshot = await getDocs9(q);
5578
+ return querySnapshot.docs.map((doc32) => doc32.data());
5407
5579
  }
5408
5580
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
5409
5581
  return getClinicsByAdmin(
@@ -5416,8 +5588,8 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
5416
5588
  }
5417
5589
  async function getClinicById(db, clinicId) {
5418
5590
  try {
5419
- const clinicRef = doc9(db, CLINICS_COLLECTION, clinicId);
5420
- const clinicSnapshot = await getDoc12(clinicRef);
5591
+ const clinicRef = doc11(db, CLINICS_COLLECTION, clinicId);
5592
+ const clinicSnapshot = await getDoc14(clinicRef);
5421
5593
  if (!clinicSnapshot.exists()) {
5422
5594
  return null;
5423
5595
  }
@@ -5433,26 +5605,26 @@ async function getClinicById(db, clinicId) {
5433
5605
  }
5434
5606
  async function getAllClinics(db, pagination, lastDoc) {
5435
5607
  try {
5436
- const clinicsCollection = collection7(db, CLINICS_COLLECTION);
5437
- let clinicsQuery = query7(clinicsCollection);
5608
+ const clinicsCollection = collection9(db, CLINICS_COLLECTION);
5609
+ let clinicsQuery = query9(clinicsCollection);
5438
5610
  if (pagination && pagination > 0) {
5439
5611
  if (lastDoc) {
5440
- clinicsQuery = query7(
5612
+ clinicsQuery = query9(
5441
5613
  clinicsCollection,
5442
- startAfter3(lastDoc),
5443
- limit3(pagination)
5614
+ startAfter5(lastDoc),
5615
+ limit5(pagination)
5444
5616
  );
5445
5617
  } else {
5446
- clinicsQuery = query7(clinicsCollection, limit3(pagination));
5618
+ clinicsQuery = query9(clinicsCollection, limit5(pagination));
5447
5619
  }
5448
5620
  }
5449
- const clinicsSnapshot = await getDocs7(clinicsQuery);
5621
+ const clinicsSnapshot = await getDocs9(clinicsQuery);
5450
5622
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
5451
- const clinics = clinicsSnapshot.docs.map((doc30) => {
5452
- const data = doc30.data();
5623
+ const clinics = clinicsSnapshot.docs.map((doc32) => {
5624
+ const data = doc32.data();
5453
5625
  return {
5454
5626
  ...data,
5455
- id: doc30.id
5627
+ id: doc32.id
5456
5628
  };
5457
5629
  });
5458
5630
  return {
@@ -5473,14 +5645,14 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
5473
5645
  let lastDocSnapshot = null;
5474
5646
  for (const b of bounds) {
5475
5647
  const constraints = [
5476
- where7("location.geohash", ">=", b[0]),
5477
- where7("location.geohash", "<=", b[1]),
5478
- where7("isActive", "==", true)
5648
+ where9("location.geohash", ">=", b[0]),
5649
+ where9("location.geohash", "<=", b[1]),
5650
+ where9("isActive", "==", true)
5479
5651
  ];
5480
- const q = query7(collection7(db, CLINICS_COLLECTION), ...constraints);
5481
- const querySnapshot = await getDocs7(q);
5482
- for (const doc30 of querySnapshot.docs) {
5483
- const clinic = doc30.data();
5652
+ const q = query9(collection9(db, CLINICS_COLLECTION), ...constraints);
5653
+ const querySnapshot = await getDocs9(q);
5654
+ for (const doc32 of querySnapshot.docs) {
5655
+ const clinic = doc32.data();
5484
5656
  const distance = distanceBetween2(
5485
5657
  [center.latitude, center.longitude],
5486
5658
  [clinic.location.latitude, clinic.location.longitude]
@@ -5574,10 +5746,10 @@ async function removeTags(db, clinicId, adminId, tagsToRemove, clinicAdminServic
5574
5746
 
5575
5747
  // src/services/clinic/utils/search.utils.ts
5576
5748
  import {
5577
- collection as collection8,
5578
- query as query8,
5579
- where as where8,
5580
- getDocs as getDocs8
5749
+ collection as collection10,
5750
+ query as query10,
5751
+ where as where10,
5752
+ getDocs as getDocs10
5581
5753
  } from "firebase/firestore";
5582
5754
  import { geohashQueryBounds as geohashQueryBounds2, distanceBetween as distanceBetween3 } from "geofire-common";
5583
5755
  async function findClinicsInRadius(db, center, radiusInKm, filters) {
@@ -5588,22 +5760,22 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5588
5760
  const matchingDocs = [];
5589
5761
  for (const b of bounds) {
5590
5762
  const constraints = [
5591
- where8("location.geohash", ">=", b[0]),
5592
- where8("location.geohash", "<=", b[1]),
5593
- where8("isActive", "==", true)
5763
+ where10("location.geohash", ">=", b[0]),
5764
+ where10("location.geohash", "<=", b[1]),
5765
+ where10("isActive", "==", true)
5594
5766
  ];
5595
5767
  if (filters == null ? void 0 : filters.services) {
5596
5768
  constraints.push(
5597
- where8("services", "array-contains-any", filters.services)
5769
+ where10("services", "array-contains-any", filters.services)
5598
5770
  );
5599
5771
  }
5600
5772
  if ((filters == null ? void 0 : filters.tags) && filters.tags.length > 0) {
5601
- constraints.push(where8("tags", "array-contains-any", filters.tags));
5773
+ constraints.push(where10("tags", "array-contains-any", filters.tags));
5602
5774
  }
5603
- const q = query8(collection8(db, CLINICS_COLLECTION), ...constraints);
5604
- const querySnapshot = await getDocs8(q);
5605
- for (const doc30 of querySnapshot.docs) {
5606
- const clinic = doc30.data();
5775
+ const q = query10(collection10(db, CLINICS_COLLECTION), ...constraints);
5776
+ const querySnapshot = await getDocs10(q);
5777
+ for (const doc32 of querySnapshot.docs) {
5778
+ const clinic = doc32.data();
5607
5779
  const distance = distanceBetween3(
5608
5780
  [center.latitude, center.longitude],
5609
5781
  [clinic.location.latitude, clinic.location.longitude]
@@ -5629,12 +5801,12 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5629
5801
 
5630
5802
  // src/services/clinic/utils/filter.utils.ts
5631
5803
  import {
5632
- collection as collection9,
5633
- query as query9,
5634
- where as where9,
5635
- getDocs as getDocs9,
5636
- startAfter as startAfter4,
5637
- limit as limit4,
5804
+ collection as collection11,
5805
+ query as query11,
5806
+ where as where11,
5807
+ getDocs as getDocs11,
5808
+ startAfter as startAfter6,
5809
+ limit as limit6,
5638
5810
  orderBy as orderBy2
5639
5811
  } from "firebase/firestore";
5640
5812
  import { geohashQueryBounds as geohashQueryBounds3, distanceBetween as distanceBetween4 } from "geofire-common";
@@ -5646,35 +5818,35 @@ async function getClinicsByFilters(db, filters) {
5646
5818
  const isGeoQuery = filters.center && filters.radiusInKm && filters.radiusInKm > 0;
5647
5819
  const constraints = [];
5648
5820
  if (filters.isActive !== void 0) {
5649
- constraints.push(where9("isActive", "==", filters.isActive));
5821
+ constraints.push(where11("isActive", "==", filters.isActive));
5650
5822
  } else {
5651
- constraints.push(where9("isActive", "==", true));
5823
+ constraints.push(where11("isActive", "==", true));
5652
5824
  }
5653
5825
  if (filters.tags && filters.tags.length > 0) {
5654
- constraints.push(where9("tags", "array-contains", filters.tags[0]));
5826
+ constraints.push(where11("tags", "array-contains", filters.tags[0]));
5655
5827
  }
5656
5828
  if (filters.procedureTechnology) {
5657
5829
  constraints.push(
5658
- where9("servicesInfo.technology", "==", filters.procedureTechnology)
5830
+ where11("servicesInfo.technology", "==", filters.procedureTechnology)
5659
5831
  );
5660
5832
  } else if (filters.procedureSubcategory) {
5661
5833
  constraints.push(
5662
- where9("servicesInfo.subCategory", "==", filters.procedureSubcategory)
5834
+ where11("servicesInfo.subCategory", "==", filters.procedureSubcategory)
5663
5835
  );
5664
5836
  } else if (filters.procedureCategory) {
5665
5837
  constraints.push(
5666
- where9("servicesInfo.category", "==", filters.procedureCategory)
5838
+ where11("servicesInfo.category", "==", filters.procedureCategory)
5667
5839
  );
5668
5840
  } else if (filters.procedureFamily) {
5669
5841
  constraints.push(
5670
- where9("servicesInfo.procedureFamily", "==", filters.procedureFamily)
5842
+ where11("servicesInfo.procedureFamily", "==", filters.procedureFamily)
5671
5843
  );
5672
5844
  }
5673
5845
  if (filters.pagination && filters.pagination > 0 && filters.lastDoc) {
5674
- constraints.push(startAfter4(filters.lastDoc));
5675
- constraints.push(limit4(filters.pagination));
5846
+ constraints.push(startAfter6(filters.lastDoc));
5847
+ constraints.push(limit6(filters.pagination));
5676
5848
  } else if (filters.pagination && filters.pagination > 0) {
5677
- constraints.push(limit4(filters.pagination));
5849
+ constraints.push(limit6(filters.pagination));
5678
5850
  }
5679
5851
  constraints.push(orderBy2("location.geohash"));
5680
5852
  let clinicsResult = [];
@@ -5691,16 +5863,16 @@ async function getClinicsByFilters(db, filters) {
5691
5863
  for (const bound of bounds) {
5692
5864
  const geoConstraints = [
5693
5865
  ...constraints,
5694
- where9("location.geohash", ">=", bound[0]),
5695
- where9("location.geohash", "<=", bound[1])
5866
+ where11("location.geohash", ">=", bound[0]),
5867
+ where11("location.geohash", "<=", bound[1])
5696
5868
  ];
5697
- const q = query9(collection9(db, CLINICS_COLLECTION), ...geoConstraints);
5698
- const querySnapshot = await getDocs9(q);
5869
+ const q = query11(collection11(db, CLINICS_COLLECTION), ...geoConstraints);
5870
+ const querySnapshot = await getDocs11(q);
5699
5871
  console.log(
5700
5872
  `[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics in geo bound`
5701
5873
  );
5702
- for (const doc30 of querySnapshot.docs) {
5703
- const clinic = { ...doc30.data(), id: doc30.id };
5874
+ for (const doc32 of querySnapshot.docs) {
5875
+ const clinic = { ...doc32.data(), id: doc32.id };
5704
5876
  const distance = distanceBetween4(
5705
5877
  [center.latitude, center.longitude],
5706
5878
  [clinic.location.latitude, clinic.location.longitude]
@@ -5751,13 +5923,13 @@ async function getClinicsByFilters(db, filters) {
5751
5923
  clinicsResult = filteredClinics;
5752
5924
  }
5753
5925
  } else {
5754
- const q = query9(collection9(db, CLINICS_COLLECTION), ...constraints);
5755
- const querySnapshot = await getDocs9(q);
5926
+ const q = query11(collection11(db, CLINICS_COLLECTION), ...constraints);
5927
+ const querySnapshot = await getDocs11(q);
5756
5928
  console.log(
5757
5929
  `[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics with regular query`
5758
5930
  );
5759
- const clinics = querySnapshot.docs.map((doc30) => {
5760
- return { ...doc30.data(), id: doc30.id };
5931
+ const clinics = querySnapshot.docs.map((doc32) => {
5932
+ return { ...doc32.data(), id: doc32.id };
5761
5933
  });
5762
5934
  let filteredClinics = clinics;
5763
5935
  if (filters.center) {
@@ -5866,9 +6038,9 @@ var ClinicService = class extends BaseService {
5866
6038
  updatedAt: Timestamp12.now()
5867
6039
  });
5868
6040
  const batch = writeBatch4(this.db);
5869
- const clinicRef = doc10(this.db, CLINICS_COLLECTION, clinicId);
6041
+ const clinicRef = doc12(this.db, CLINICS_COLLECTION, clinicId);
5870
6042
  batch.set(clinicRef, clinicData);
5871
- const adminRef = doc10(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
6043
+ const adminRef = doc12(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
5872
6044
  batch.update(adminRef, {
5873
6045
  clinicsManaged: arrayUnion6(clinicId),
5874
6046
  updatedAt: serverTimestamp12()
@@ -5889,8 +6061,8 @@ var ClinicService = class extends BaseService {
5889
6061
  * Updates a clinic.
5890
6062
  */
5891
6063
  async updateClinic(clinicId, data, adminId) {
5892
- const clinicRef = doc10(this.db, CLINICS_COLLECTION, clinicId);
5893
- const clinicDoc = await getDoc13(clinicRef);
6064
+ const clinicRef = doc12(this.db, CLINICS_COLLECTION, clinicId);
6065
+ const clinicDoc = await getDoc15(clinicRef);
5894
6066
  if (!clinicDoc.exists()) {
5895
6067
  throw new Error(`Clinic ${clinicId} not found`);
5896
6068
  }
@@ -5939,7 +6111,7 @@ var ClinicService = class extends BaseService {
5939
6111
  * Deactivates a clinic.
5940
6112
  */
5941
6113
  async deactivateClinic(clinicId, adminId) {
5942
- const clinicRef = doc10(this.db, CLINICS_COLLECTION, clinicId);
6114
+ const clinicRef = doc12(this.db, CLINICS_COLLECTION, clinicId);
5943
6115
  await updateDoc12(clinicRef, {
5944
6116
  isActive: false,
5945
6117
  updatedAt: serverTimestamp12()
@@ -6289,9 +6461,9 @@ var AuthService = class extends BaseService {
6289
6461
  token: data.inviteToken
6290
6462
  });
6291
6463
  console.log("[AUTH] Searching for token in clinic groups");
6292
- const groupsRef = collection11(this.db, CLINIC_GROUPS_COLLECTION);
6293
- const q = query11(groupsRef);
6294
- const querySnapshot = await getDocs11(q);
6464
+ const groupsRef = collection13(this.db, CLINIC_GROUPS_COLLECTION);
6465
+ const q = query13(groupsRef);
6466
+ const querySnapshot = await getDocs13(q);
6295
6467
  let foundGroup = null;
6296
6468
  let foundToken = null;
6297
6469
  console.log(
@@ -6738,12 +6910,12 @@ var AuthService = class extends BaseService {
6738
6910
 
6739
6911
  // src/services/notifications/notification.service.ts
6740
6912
  import {
6741
- collection as collection12,
6742
- doc as doc12,
6743
- getDoc as getDoc15,
6744
- getDocs as getDocs12,
6745
- query as query12,
6746
- where as where12,
6913
+ collection as collection14,
6914
+ doc as doc14,
6915
+ getDoc as getDoc17,
6916
+ getDocs as getDocs14,
6917
+ query as query14,
6918
+ where as where14,
6747
6919
  updateDoc as updateDoc14,
6748
6920
  deleteDoc as deleteDoc7,
6749
6921
  orderBy as orderBy3,
@@ -6776,7 +6948,7 @@ var NotificationService = class extends BaseService {
6776
6948
  * Kreira novu notifikaciju
6777
6949
  */
6778
6950
  async createNotification(notification) {
6779
- const notificationsRef = collection12(this.db, NOTIFICATIONS_COLLECTION);
6951
+ const notificationsRef = collection14(this.db, NOTIFICATIONS_COLLECTION);
6780
6952
  const now = Timestamp14.now();
6781
6953
  const notificationData = {
6782
6954
  ...notification,
@@ -6796,12 +6968,12 @@ var NotificationService = class extends BaseService {
6796
6968
  * Dohvata notifikaciju po ID-u
6797
6969
  */
6798
6970
  async getNotification(notificationId) {
6799
- const notificationRef = doc12(
6971
+ const notificationRef = doc14(
6800
6972
  this.db,
6801
6973
  NOTIFICATIONS_COLLECTION,
6802
6974
  notificationId
6803
6975
  );
6804
- const notificationDoc = await getDoc15(notificationRef);
6976
+ const notificationDoc = await getDoc17(notificationRef);
6805
6977
  if (!notificationDoc.exists()) {
6806
6978
  return null;
6807
6979
  }
@@ -6814,38 +6986,38 @@ var NotificationService = class extends BaseService {
6814
6986
  * Dohvata sve notifikacije za korisnika
6815
6987
  */
6816
6988
  async getUserNotifications(userId) {
6817
- const q = query12(
6818
- collection12(this.db, NOTIFICATIONS_COLLECTION),
6819
- where12("userId", "==", userId),
6989
+ const q = query14(
6990
+ collection14(this.db, NOTIFICATIONS_COLLECTION),
6991
+ where14("userId", "==", userId),
6820
6992
  orderBy3("notificationTime", "desc")
6821
6993
  );
6822
- const querySnapshot = await getDocs12(q);
6823
- return querySnapshot.docs.map((doc30) => ({
6824
- id: doc30.id,
6825
- ...doc30.data()
6994
+ const querySnapshot = await getDocs14(q);
6995
+ return querySnapshot.docs.map((doc32) => ({
6996
+ id: doc32.id,
6997
+ ...doc32.data()
6826
6998
  }));
6827
6999
  }
6828
7000
  /**
6829
7001
  * Dohvata nepročitane notifikacije za korisnika
6830
7002
  */
6831
7003
  async getUnreadNotifications(userId) {
6832
- const q = query12(
6833
- collection12(this.db, NOTIFICATIONS_COLLECTION),
6834
- where12("userId", "==", userId),
6835
- where12("isRead", "==", false),
7004
+ const q = query14(
7005
+ collection14(this.db, NOTIFICATIONS_COLLECTION),
7006
+ where14("userId", "==", userId),
7007
+ where14("isRead", "==", false),
6836
7008
  orderBy3("notificationTime", "desc")
6837
7009
  );
6838
- const querySnapshot = await getDocs12(q);
6839
- return querySnapshot.docs.map((doc30) => ({
6840
- id: doc30.id,
6841
- ...doc30.data()
7010
+ const querySnapshot = await getDocs14(q);
7011
+ return querySnapshot.docs.map((doc32) => ({
7012
+ id: doc32.id,
7013
+ ...doc32.data()
6842
7014
  }));
6843
7015
  }
6844
7016
  /**
6845
7017
  * Označava notifikaciju kao pročitanu
6846
7018
  */
6847
7019
  async markAsRead(notificationId) {
6848
- const notificationRef = doc12(
7020
+ const notificationRef = doc14(
6849
7021
  this.db,
6850
7022
  NOTIFICATIONS_COLLECTION,
6851
7023
  notificationId
@@ -6862,7 +7034,7 @@ var NotificationService = class extends BaseService {
6862
7034
  const notifications = await this.getUnreadNotifications(userId);
6863
7035
  const batch = writeBatch5(this.db);
6864
7036
  notifications.forEach((notification) => {
6865
- const notificationRef = doc12(
7037
+ const notificationRef = doc14(
6866
7038
  this.db,
6867
7039
  NOTIFICATIONS_COLLECTION,
6868
7040
  notification.id
@@ -6878,7 +7050,7 @@ var NotificationService = class extends BaseService {
6878
7050
  * Ažurira status notifikacije
6879
7051
  */
6880
7052
  async updateNotificationStatus(notificationId, status) {
6881
- const notificationRef = doc12(
7053
+ const notificationRef = doc14(
6882
7054
  this.db,
6883
7055
  NOTIFICATIONS_COLLECTION,
6884
7056
  notificationId
@@ -6892,7 +7064,7 @@ var NotificationService = class extends BaseService {
6892
7064
  * Briše notifikaciju
6893
7065
  */
6894
7066
  async deleteNotification(notificationId) {
6895
- const notificationRef = doc12(
7067
+ const notificationRef = doc14(
6896
7068
  this.db,
6897
7069
  NOTIFICATIONS_COLLECTION,
6898
7070
  notificationId
@@ -6903,50 +7075,50 @@ var NotificationService = class extends BaseService {
6903
7075
  * Dohvata notifikacije po tipu
6904
7076
  */
6905
7077
  async getNotificationsByType(userId, type) {
6906
- const q = query12(
6907
- collection12(this.db, NOTIFICATIONS_COLLECTION),
6908
- where12("userId", "==", userId),
6909
- where12("notificationType", "==", type),
7078
+ const q = query14(
7079
+ collection14(this.db, NOTIFICATIONS_COLLECTION),
7080
+ where14("userId", "==", userId),
7081
+ where14("notificationType", "==", type),
6910
7082
  orderBy3("notificationTime", "desc")
6911
7083
  );
6912
- const querySnapshot = await getDocs12(q);
6913
- return querySnapshot.docs.map((doc30) => ({
6914
- id: doc30.id,
6915
- ...doc30.data()
7084
+ const querySnapshot = await getDocs14(q);
7085
+ return querySnapshot.docs.map((doc32) => ({
7086
+ id: doc32.id,
7087
+ ...doc32.data()
6916
7088
  }));
6917
7089
  }
6918
7090
  /**
6919
7091
  * Dohvata notifikacije za određeni termin
6920
7092
  */
6921
7093
  async getAppointmentNotifications(appointmentId) {
6922
- const q = query12(
6923
- collection12(this.db, NOTIFICATIONS_COLLECTION),
6924
- where12("appointmentId", "==", appointmentId),
7094
+ const q = query14(
7095
+ collection14(this.db, NOTIFICATIONS_COLLECTION),
7096
+ where14("appointmentId", "==", appointmentId),
6925
7097
  orderBy3("notificationTime", "desc")
6926
7098
  );
6927
- const querySnapshot = await getDocs12(q);
6928
- return querySnapshot.docs.map((doc30) => ({
6929
- id: doc30.id,
6930
- ...doc30.data()
7099
+ const querySnapshot = await getDocs14(q);
7100
+ return querySnapshot.docs.map((doc32) => ({
7101
+ id: doc32.id,
7102
+ ...doc32.data()
6931
7103
  }));
6932
7104
  }
6933
7105
  };
6934
7106
 
6935
7107
  // src/services/procedure/procedure.service.ts
6936
7108
  import {
6937
- collection as collection13,
6938
- doc as doc13,
6939
- getDoc as getDoc16,
6940
- getDocs as getDocs13,
6941
- query as query13,
6942
- where as where13,
7109
+ collection as collection15,
7110
+ doc as doc15,
7111
+ getDoc as getDoc18,
7112
+ getDocs as getDocs15,
7113
+ query as query15,
7114
+ where as where15,
6943
7115
  updateDoc as updateDoc15,
6944
7116
  setDoc as setDoc13,
6945
7117
  deleteDoc as deleteDoc8,
6946
7118
  serverTimestamp as serverTimestamp14,
6947
7119
  orderBy as orderBy4,
6948
- limit as limit5,
6949
- startAfter as startAfter5
7120
+ limit as limit7,
7121
+ startAfter as startAfter7
6950
7122
  } from "firebase/firestore";
6951
7123
 
6952
7124
  // src/types/procedure/index.ts
@@ -7051,24 +7223,24 @@ var ProcedureService = class extends BaseService {
7051
7223
  if (!category || !subcategory || !technology || !product) {
7052
7224
  throw new Error("One or more required base entities not found");
7053
7225
  }
7054
- const clinicRef = doc13(
7226
+ const clinicRef = doc15(
7055
7227
  this.db,
7056
7228
  CLINICS_COLLECTION,
7057
7229
  validatedData.clinicBranchId
7058
7230
  );
7059
- const clinicSnapshot = await getDoc16(clinicRef);
7231
+ const clinicSnapshot = await getDoc18(clinicRef);
7060
7232
  if (!clinicSnapshot.exists()) {
7061
7233
  throw new Error(
7062
7234
  `Clinic with ID ${validatedData.clinicBranchId} not found`
7063
7235
  );
7064
7236
  }
7065
7237
  const clinic = clinicSnapshot.data();
7066
- const practitionerRef = doc13(
7238
+ const practitionerRef = doc15(
7067
7239
  this.db,
7068
7240
  PRACTITIONERS_COLLECTION,
7069
7241
  validatedData.practitionerId
7070
7242
  );
7071
- const practitionerSnapshot = await getDoc16(practitionerRef);
7243
+ const practitionerSnapshot = await getDoc18(practitionerRef);
7072
7244
  if (!practitionerSnapshot.exists()) {
7073
7245
  throw new Error(
7074
7246
  `Practitioner with ID ${validatedData.practitionerId} not found`
@@ -7124,13 +7296,13 @@ var ProcedureService = class extends BaseService {
7124
7296
  isActive: true
7125
7297
  // Default to active
7126
7298
  };
7127
- const procedureRef = doc13(this.db, PROCEDURES_COLLECTION, procedureId);
7299
+ const procedureRef = doc15(this.db, PROCEDURES_COLLECTION, procedureId);
7128
7300
  await setDoc13(procedureRef, {
7129
7301
  ...newProcedure,
7130
7302
  createdAt: serverTimestamp14(),
7131
7303
  updatedAt: serverTimestamp14()
7132
7304
  });
7133
- const savedDoc = await getDoc16(procedureRef);
7305
+ const savedDoc = await getDoc18(procedureRef);
7134
7306
  return savedDoc.data();
7135
7307
  }
7136
7308
  /**
@@ -7139,8 +7311,8 @@ var ProcedureService = class extends BaseService {
7139
7311
  * @returns The procedure if found, null otherwise
7140
7312
  */
7141
7313
  async getProcedure(id) {
7142
- const docRef = doc13(this.db, PROCEDURES_COLLECTION, id);
7143
- const docSnap = await getDoc16(docRef);
7314
+ const docRef = doc15(this.db, PROCEDURES_COLLECTION, id);
7315
+ const docSnap = await getDoc18(docRef);
7144
7316
  if (!docSnap.exists()) {
7145
7317
  return null;
7146
7318
  }
@@ -7152,13 +7324,13 @@ var ProcedureService = class extends BaseService {
7152
7324
  * @returns List of procedures
7153
7325
  */
7154
7326
  async getProceduresByClinicBranch(clinicBranchId) {
7155
- const q = query13(
7156
- collection13(this.db, PROCEDURES_COLLECTION),
7157
- where13("clinicBranchId", "==", clinicBranchId),
7158
- where13("isActive", "==", true)
7327
+ const q = query15(
7328
+ collection15(this.db, PROCEDURES_COLLECTION),
7329
+ where15("clinicBranchId", "==", clinicBranchId),
7330
+ where15("isActive", "==", true)
7159
7331
  );
7160
- const snapshot = await getDocs13(q);
7161
- return snapshot.docs.map((doc30) => doc30.data());
7332
+ const snapshot = await getDocs15(q);
7333
+ return snapshot.docs.map((doc32) => doc32.data());
7162
7334
  }
7163
7335
  /**
7164
7336
  * Gets all procedures for a practitioner
@@ -7166,13 +7338,13 @@ var ProcedureService = class extends BaseService {
7166
7338
  * @returns List of procedures
7167
7339
  */
7168
7340
  async getProceduresByPractitioner(practitionerId) {
7169
- const q = query13(
7170
- collection13(this.db, PROCEDURES_COLLECTION),
7171
- where13("practitionerId", "==", practitionerId),
7172
- where13("isActive", "==", true)
7341
+ const q = query15(
7342
+ collection15(this.db, PROCEDURES_COLLECTION),
7343
+ where15("practitionerId", "==", practitionerId),
7344
+ where15("isActive", "==", true)
7173
7345
  );
7174
- const snapshot = await getDocs13(q);
7175
- return snapshot.docs.map((doc30) => doc30.data());
7346
+ const snapshot = await getDocs15(q);
7347
+ return snapshot.docs.map((doc32) => doc32.data());
7176
7348
  }
7177
7349
  /**
7178
7350
  * Updates a procedure
@@ -7183,8 +7355,8 @@ var ProcedureService = class extends BaseService {
7183
7355
  async updateProcedure(id, data) {
7184
7356
  var _a;
7185
7357
  const validatedData = updateProcedureSchema.parse(data);
7186
- const procedureRef = doc13(this.db, PROCEDURES_COLLECTION, id);
7187
- const procedureSnapshot = await getDoc16(procedureRef);
7358
+ const procedureRef = doc15(this.db, PROCEDURES_COLLECTION, id);
7359
+ const procedureSnapshot = await getDoc18(procedureRef);
7188
7360
  if (!procedureSnapshot.exists()) {
7189
7361
  throw new Error(`Procedure with ID ${id} not found`);
7190
7362
  }
@@ -7198,12 +7370,12 @@ var ProcedureService = class extends BaseService {
7198
7370
  let newClinic = null;
7199
7371
  if (validatedData.practitionerId && validatedData.practitionerId !== oldPractitionerId) {
7200
7372
  practitionerChanged = true;
7201
- const newPractitionerRef = doc13(
7373
+ const newPractitionerRef = doc15(
7202
7374
  this.db,
7203
7375
  PRACTITIONERS_COLLECTION,
7204
7376
  validatedData.practitionerId
7205
7377
  );
7206
- const newPractitionerSnap = await getDoc16(newPractitionerRef);
7378
+ const newPractitionerSnap = await getDoc18(newPractitionerRef);
7207
7379
  if (!newPractitionerSnap.exists())
7208
7380
  throw new Error(
7209
7381
  `New Practitioner ${validatedData.practitionerId} not found`
@@ -7220,12 +7392,12 @@ var ProcedureService = class extends BaseService {
7220
7392
  }
7221
7393
  if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
7222
7394
  clinicChanged = true;
7223
- const newClinicRef = doc13(
7395
+ const newClinicRef = doc15(
7224
7396
  this.db,
7225
7397
  CLINICS_COLLECTION,
7226
7398
  validatedData.clinicBranchId
7227
7399
  );
7228
- const newClinicSnap = await getDoc16(newClinicRef);
7400
+ const newClinicSnap = await getDoc18(newClinicRef);
7229
7401
  if (!newClinicSnap.exists())
7230
7402
  throw new Error(`New Clinic ${validatedData.clinicBranchId} not found`);
7231
7403
  newClinic = newClinicSnap.data();
@@ -7296,7 +7468,7 @@ var ProcedureService = class extends BaseService {
7296
7468
  ...updatedProcedureData,
7297
7469
  updatedAt: serverTimestamp14()
7298
7470
  });
7299
- const updatedSnapshot = await getDoc16(procedureRef);
7471
+ const updatedSnapshot = await getDoc18(procedureRef);
7300
7472
  return updatedSnapshot.data();
7301
7473
  }
7302
7474
  /**
@@ -7304,8 +7476,8 @@ var ProcedureService = class extends BaseService {
7304
7476
  * @param id - The ID of the procedure to deactivate
7305
7477
  */
7306
7478
  async deactivateProcedure(id) {
7307
- const procedureRef = doc13(this.db, PROCEDURES_COLLECTION, id);
7308
- const procedureSnap = await getDoc16(procedureRef);
7479
+ const procedureRef = doc15(this.db, PROCEDURES_COLLECTION, id);
7480
+ const procedureSnap = await getDoc18(procedureRef);
7309
7481
  if (!procedureSnap.exists()) {
7310
7482
  console.warn(`Procedure ${id} not found for deactivation.`);
7311
7483
  return;
@@ -7321,8 +7493,8 @@ var ProcedureService = class extends BaseService {
7321
7493
  * @returns A boolean indicating if the deletion was successful
7322
7494
  */
7323
7495
  async deleteProcedure(id) {
7324
- const procedureRef = doc13(this.db, PROCEDURES_COLLECTION, id);
7325
- const procedureSnapshot = await getDoc16(procedureRef);
7496
+ const procedureRef = doc15(this.db, PROCEDURES_COLLECTION, id);
7497
+ const procedureSnapshot = await getDoc18(procedureRef);
7326
7498
  if (!procedureSnapshot.exists()) {
7327
7499
  return false;
7328
7500
  }
@@ -7352,35 +7524,35 @@ var ProcedureService = class extends BaseService {
7352
7524
  */
7353
7525
  async getAllProcedures(pagination, lastDoc) {
7354
7526
  try {
7355
- const proceduresCollection = collection13(this.db, PROCEDURES_COLLECTION);
7356
- let proceduresQuery = query13(proceduresCollection);
7527
+ const proceduresCollection = collection15(this.db, PROCEDURES_COLLECTION);
7528
+ let proceduresQuery = query15(proceduresCollection);
7357
7529
  if (pagination && pagination > 0) {
7358
- const { limit: limit9, startAfter: startAfter9 } = await import("firebase/firestore");
7530
+ const { limit: limit11, startAfter: startAfter11 } = await import("firebase/firestore");
7359
7531
  if (lastDoc) {
7360
- proceduresQuery = query13(
7532
+ proceduresQuery = query15(
7361
7533
  proceduresCollection,
7362
7534
  orderBy4("name"),
7363
7535
  // Use imported orderBy
7364
- startAfter9(lastDoc),
7365
- limit9(pagination)
7536
+ startAfter11(lastDoc),
7537
+ limit11(pagination)
7366
7538
  );
7367
7539
  } else {
7368
- proceduresQuery = query13(
7540
+ proceduresQuery = query15(
7369
7541
  proceduresCollection,
7370
7542
  orderBy4("name"),
7371
- limit9(pagination)
7543
+ limit11(pagination)
7372
7544
  );
7373
7545
  }
7374
7546
  } else {
7375
- proceduresQuery = query13(proceduresCollection, orderBy4("name"));
7547
+ proceduresQuery = query15(proceduresCollection, orderBy4("name"));
7376
7548
  }
7377
- const proceduresSnapshot = await getDocs13(proceduresQuery);
7549
+ const proceduresSnapshot = await getDocs15(proceduresQuery);
7378
7550
  const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
7379
- const procedures = proceduresSnapshot.docs.map((doc30) => {
7380
- const data = doc30.data();
7551
+ const procedures = proceduresSnapshot.docs.map((doc32) => {
7552
+ const data = doc32.data();
7381
7553
  return {
7382
7554
  ...data,
7383
- id: doc30.id
7555
+ id: doc32.id
7384
7556
  // Ensure ID is present
7385
7557
  };
7386
7558
  });
@@ -7423,19 +7595,19 @@ var ProcedureService = class extends BaseService {
7423
7595
  const isGeoQuery = filters.location && filters.radiusInKm && filters.radiusInKm > 0;
7424
7596
  const constraints = [];
7425
7597
  if (filters.isActive !== void 0) {
7426
- constraints.push(where13("isActive", "==", filters.isActive));
7598
+ constraints.push(where15("isActive", "==", filters.isActive));
7427
7599
  } else {
7428
- constraints.push(where13("isActive", "==", true));
7600
+ constraints.push(where15("isActive", "==", true));
7429
7601
  }
7430
7602
  if (filters.procedureFamily) {
7431
- constraints.push(where13("family", "==", filters.procedureFamily));
7603
+ constraints.push(where15("family", "==", filters.procedureFamily));
7432
7604
  }
7433
7605
  constraints.push(orderBy4("clinicInfo.location.geohash"));
7434
7606
  if (filters.pagination && filters.pagination > 0 && filters.lastDoc) {
7435
- constraints.push(startAfter5(filters.lastDoc));
7436
- constraints.push(limit5(filters.pagination));
7607
+ constraints.push(startAfter7(filters.lastDoc));
7608
+ constraints.push(limit7(filters.pagination));
7437
7609
  } else if (filters.pagination && filters.pagination > 0) {
7438
- constraints.push(limit5(filters.pagination));
7610
+ constraints.push(limit7(filters.pagination));
7439
7611
  }
7440
7612
  let proceduresResult = [];
7441
7613
  let lastVisibleDoc = null;
@@ -7451,19 +7623,19 @@ var ProcedureService = class extends BaseService {
7451
7623
  for (const bound of bounds) {
7452
7624
  const geoConstraints = [
7453
7625
  ...constraints,
7454
- where13("clinicInfo.location.geohash", ">=", bound[0]),
7455
- where13("clinicInfo.location.geohash", "<=", bound[1])
7626
+ where15("clinicInfo.location.geohash", ">=", bound[0]),
7627
+ where15("clinicInfo.location.geohash", "<=", bound[1])
7456
7628
  ];
7457
- const q = query13(
7458
- collection13(this.db, PROCEDURES_COLLECTION),
7629
+ const q = query15(
7630
+ collection15(this.db, PROCEDURES_COLLECTION),
7459
7631
  ...geoConstraints
7460
7632
  );
7461
- const querySnapshot = await getDocs13(q);
7633
+ const querySnapshot = await getDocs15(q);
7462
7634
  console.log(
7463
7635
  `[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures in geo bound`
7464
7636
  );
7465
- for (const doc30 of querySnapshot.docs) {
7466
- const procedure = { ...doc30.data(), id: doc30.id };
7637
+ for (const doc32 of querySnapshot.docs) {
7638
+ const procedure = { ...doc32.data(), id: doc32.id };
7467
7639
  const distance = distanceBetween6(
7468
7640
  [center.latitude, center.longitude],
7469
7641
  [
@@ -7506,16 +7678,16 @@ var ProcedureService = class extends BaseService {
7506
7678
  proceduresResult = filteredProcedures;
7507
7679
  }
7508
7680
  } else {
7509
- const q = query13(
7510
- collection13(this.db, PROCEDURES_COLLECTION),
7681
+ const q = query15(
7682
+ collection15(this.db, PROCEDURES_COLLECTION),
7511
7683
  ...constraints
7512
7684
  );
7513
- const querySnapshot = await getDocs13(q);
7685
+ const querySnapshot = await getDocs15(q);
7514
7686
  console.log(
7515
7687
  `[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures with regular query`
7516
7688
  );
7517
- const procedures = querySnapshot.docs.map((doc30) => {
7518
- return { ...doc30.data(), id: doc30.id };
7689
+ const procedures = querySnapshot.docs.map((doc32) => {
7690
+ return { ...doc32.data(), id: doc32.id };
7519
7691
  });
7520
7692
  if (filters.location) {
7521
7693
  const center = filters.location;
@@ -7623,23 +7795,23 @@ var ProcedureService = class extends BaseService {
7623
7795
 
7624
7796
  // src/services/documentation-templates/documentation-template.service.ts
7625
7797
  import {
7626
- collection as collection14,
7627
- doc as doc14,
7628
- getDoc as getDoc17,
7629
- getDocs as getDocs14,
7798
+ collection as collection16,
7799
+ doc as doc16,
7800
+ getDoc as getDoc19,
7801
+ getDocs as getDocs16,
7630
7802
  setDoc as setDoc14,
7631
7803
  updateDoc as updateDoc16,
7632
7804
  deleteDoc as deleteDoc9,
7633
- query as query14,
7634
- where as where14,
7805
+ query as query16,
7806
+ where as where16,
7635
7807
  orderBy as orderBy5,
7636
- limit as limit6,
7637
- startAfter as startAfter6
7808
+ limit as limit8,
7809
+ startAfter as startAfter8
7638
7810
  } from "firebase/firestore";
7639
7811
  var DocumentationTemplateService = class extends BaseService {
7640
7812
  constructor() {
7641
7813
  super(...arguments);
7642
- this.collectionRef = collection14(
7814
+ this.collectionRef = collection16(
7643
7815
  this.db,
7644
7816
  DOCUMENTATION_TEMPLATES_COLLECTION
7645
7817
  );
@@ -7670,7 +7842,7 @@ var DocumentationTemplateService = class extends BaseService {
7670
7842
  isActive: true,
7671
7843
  tags: validatedData.tags || []
7672
7844
  };
7673
- const docRef = doc14(this.collectionRef, templateId);
7845
+ const docRef = doc16(this.collectionRef, templateId);
7674
7846
  await setDoc14(docRef, template);
7675
7847
  return template;
7676
7848
  }
@@ -7680,8 +7852,8 @@ var DocumentationTemplateService = class extends BaseService {
7680
7852
  * @returns The template or null if not found
7681
7853
  */
7682
7854
  async getTemplateById(templateId) {
7683
- const docRef = doc14(this.collectionRef, templateId);
7684
- const docSnap = await getDoc17(docRef);
7855
+ const docRef = doc16(this.collectionRef, templateId);
7856
+ const docSnap = await getDoc19(docRef);
7685
7857
  if (!docSnap.exists()) {
7686
7858
  return null;
7687
7859
  }
@@ -7712,7 +7884,7 @@ var DocumentationTemplateService = class extends BaseService {
7712
7884
  updatedAt: Date.now(),
7713
7885
  version: template.version + 1
7714
7886
  };
7715
- const docRef = doc14(this.collectionRef, templateId);
7887
+ const docRef = doc16(this.collectionRef, templateId);
7716
7888
  await updateDoc16(docRef, updateData);
7717
7889
  return {
7718
7890
  ...template,
@@ -7724,7 +7896,7 @@ var DocumentationTemplateService = class extends BaseService {
7724
7896
  * @param templateId - ID of the template to delete
7725
7897
  */
7726
7898
  async deleteTemplate(templateId) {
7727
- const docRef = doc14(this.collectionRef, templateId);
7899
+ const docRef = doc16(this.collectionRef, templateId);
7728
7900
  await deleteDoc9(docRef);
7729
7901
  }
7730
7902
  /**
@@ -7734,21 +7906,21 @@ var DocumentationTemplateService = class extends BaseService {
7734
7906
  * @returns Array of templates and the last document for pagination
7735
7907
  */
7736
7908
  async getActiveTemplates(pageSize = 20, lastDoc) {
7737
- let q = query14(
7909
+ let q = query16(
7738
7910
  this.collectionRef,
7739
- where14("isActive", "==", true),
7911
+ where16("isActive", "==", true),
7740
7912
  orderBy5("updatedAt", "desc"),
7741
- limit6(pageSize)
7913
+ limit8(pageSize)
7742
7914
  );
7743
7915
  if (lastDoc) {
7744
- q = query14(q, startAfter6(lastDoc));
7916
+ q = query16(q, startAfter8(lastDoc));
7745
7917
  }
7746
- const querySnapshot = await getDocs14(q);
7918
+ const querySnapshot = await getDocs16(q);
7747
7919
  const templates = [];
7748
7920
  let lastVisible = null;
7749
- querySnapshot.forEach((doc30) => {
7750
- templates.push(doc30.data());
7751
- lastVisible = doc30;
7921
+ querySnapshot.forEach((doc32) => {
7922
+ templates.push(doc32.data());
7923
+ lastVisible = doc32;
7752
7924
  });
7753
7925
  return {
7754
7926
  templates,
@@ -7763,22 +7935,22 @@ var DocumentationTemplateService = class extends BaseService {
7763
7935
  * @returns Array of templates and the last document for pagination
7764
7936
  */
7765
7937
  async getTemplatesByTags(tags, pageSize = 20, lastDoc) {
7766
- let q = query14(
7938
+ let q = query16(
7767
7939
  this.collectionRef,
7768
- where14("isActive", "==", true),
7769
- where14("tags", "array-contains-any", tags),
7940
+ where16("isActive", "==", true),
7941
+ where16("tags", "array-contains-any", tags),
7770
7942
  orderBy5("updatedAt", "desc"),
7771
- limit6(pageSize)
7943
+ limit8(pageSize)
7772
7944
  );
7773
7945
  if (lastDoc) {
7774
- q = query14(q, startAfter6(lastDoc));
7946
+ q = query16(q, startAfter8(lastDoc));
7775
7947
  }
7776
- const querySnapshot = await getDocs14(q);
7948
+ const querySnapshot = await getDocs16(q);
7777
7949
  const templates = [];
7778
7950
  let lastVisible = null;
7779
- querySnapshot.forEach((doc30) => {
7780
- templates.push(doc30.data());
7781
- lastVisible = doc30;
7951
+ querySnapshot.forEach((doc32) => {
7952
+ templates.push(doc32.data());
7953
+ lastVisible = doc32;
7782
7954
  });
7783
7955
  return {
7784
7956
  templates,
@@ -7793,21 +7965,21 @@ var DocumentationTemplateService = class extends BaseService {
7793
7965
  * @returns Array of templates and the last document for pagination
7794
7966
  */
7795
7967
  async getTemplatesByCreator(userId, pageSize = 20, lastDoc) {
7796
- let q = query14(
7968
+ let q = query16(
7797
7969
  this.collectionRef,
7798
- where14("createdBy", "==", userId),
7970
+ where16("createdBy", "==", userId),
7799
7971
  orderBy5("updatedAt", "desc"),
7800
- limit6(pageSize)
7972
+ limit8(pageSize)
7801
7973
  );
7802
7974
  if (lastDoc) {
7803
- q = query14(q, startAfter6(lastDoc));
7975
+ q = query16(q, startAfter8(lastDoc));
7804
7976
  }
7805
- const querySnapshot = await getDocs14(q);
7977
+ const querySnapshot = await getDocs16(q);
7806
7978
  const templates = [];
7807
7979
  let lastVisible = null;
7808
- querySnapshot.forEach((doc30) => {
7809
- templates.push(doc30.data());
7810
- lastVisible = doc30;
7980
+ querySnapshot.forEach((doc32) => {
7981
+ templates.push(doc32.data());
7982
+ lastVisible = doc32;
7811
7983
  });
7812
7984
  return {
7813
7985
  templates,
@@ -7818,22 +7990,22 @@ var DocumentationTemplateService = class extends BaseService {
7818
7990
 
7819
7991
  // src/services/documentation-templates/filled-document.service.ts
7820
7992
  import {
7821
- collection as collection15,
7822
- doc as doc15,
7823
- getDoc as getDoc18,
7824
- getDocs as getDocs15,
7993
+ collection as collection17,
7994
+ doc as doc17,
7995
+ getDoc as getDoc20,
7996
+ getDocs as getDocs17,
7825
7997
  setDoc as setDoc15,
7826
7998
  updateDoc as updateDoc17,
7827
- query as query15,
7828
- where as where15,
7999
+ query as query17,
8000
+ where as where17,
7829
8001
  orderBy as orderBy6,
7830
- limit as limit7,
7831
- startAfter as startAfter7
8002
+ limit as limit9,
8003
+ startAfter as startAfter9
7832
8004
  } from "firebase/firestore";
7833
8005
  var FilledDocumentService = class extends BaseService {
7834
8006
  constructor(...args) {
7835
8007
  super(...args);
7836
- this.collectionRef = collection15(
8008
+ this.collectionRef = collection17(
7837
8009
  this.db,
7838
8010
  FILLED_DOCUMENTS_COLLECTION
7839
8011
  );
@@ -7866,7 +8038,7 @@ var FilledDocumentService = class extends BaseService {
7866
8038
  values: {},
7867
8039
  status: "draft" /* DRAFT */
7868
8040
  };
7869
- const docRef = doc15(this.collectionRef, documentId3);
8041
+ const docRef = doc17(this.collectionRef, documentId3);
7870
8042
  await setDoc15(docRef, filledDocument);
7871
8043
  return filledDocument;
7872
8044
  }
@@ -7876,8 +8048,8 @@ var FilledDocumentService = class extends BaseService {
7876
8048
  * @returns The filled document or null if not found
7877
8049
  */
7878
8050
  async getFilledDocumentById(documentId3) {
7879
- const docRef = doc15(this.collectionRef, documentId3);
7880
- const docSnap = await getDoc18(docRef);
8051
+ const docRef = doc17(this.collectionRef, documentId3);
8052
+ const docSnap = await getDoc20(docRef);
7881
8053
  if (!docSnap.exists()) {
7882
8054
  return null;
7883
8055
  }
@@ -7905,7 +8077,7 @@ var FilledDocumentService = class extends BaseService {
7905
8077
  if (status) {
7906
8078
  updateData.status = status;
7907
8079
  }
7908
- const docRef = doc15(this.collectionRef, documentId3);
8080
+ const docRef = doc17(this.collectionRef, documentId3);
7909
8081
  await updateDoc17(docRef, updateData);
7910
8082
  return {
7911
8083
  ...filledDocument,
@@ -7920,21 +8092,21 @@ var FilledDocumentService = class extends BaseService {
7920
8092
  * @returns Array of filled documents and the last document for pagination
7921
8093
  */
7922
8094
  async getFilledDocumentsByPatient(patientId, pageSize = 20, lastDoc) {
7923
- let q = query15(
8095
+ let q = query17(
7924
8096
  this.collectionRef,
7925
- where15("patientId", "==", patientId),
8097
+ where17("patientId", "==", patientId),
7926
8098
  orderBy6("updatedAt", "desc"),
7927
- limit7(pageSize)
8099
+ limit9(pageSize)
7928
8100
  );
7929
8101
  if (lastDoc) {
7930
- q = query15(q, startAfter7(lastDoc));
8102
+ q = query17(q, startAfter9(lastDoc));
7931
8103
  }
7932
- const querySnapshot = await getDocs15(q);
8104
+ const querySnapshot = await getDocs17(q);
7933
8105
  const documents = [];
7934
8106
  let lastVisible = null;
7935
- querySnapshot.forEach((doc30) => {
7936
- documents.push(doc30.data());
7937
- lastVisible = doc30;
8107
+ querySnapshot.forEach((doc32) => {
8108
+ documents.push(doc32.data());
8109
+ lastVisible = doc32;
7938
8110
  });
7939
8111
  return {
7940
8112
  documents,
@@ -7949,21 +8121,21 @@ var FilledDocumentService = class extends BaseService {
7949
8121
  * @returns Array of filled documents and the last document for pagination
7950
8122
  */
7951
8123
  async getFilledDocumentsByPractitioner(practitionerId, pageSize = 20, lastDoc) {
7952
- let q = query15(
8124
+ let q = query17(
7953
8125
  this.collectionRef,
7954
- where15("practitionerId", "==", practitionerId),
8126
+ where17("practitionerId", "==", practitionerId),
7955
8127
  orderBy6("updatedAt", "desc"),
7956
- limit7(pageSize)
8128
+ limit9(pageSize)
7957
8129
  );
7958
8130
  if (lastDoc) {
7959
- q = query15(q, startAfter7(lastDoc));
8131
+ q = query17(q, startAfter9(lastDoc));
7960
8132
  }
7961
- const querySnapshot = await getDocs15(q);
8133
+ const querySnapshot = await getDocs17(q);
7962
8134
  const documents = [];
7963
8135
  let lastVisible = null;
7964
- querySnapshot.forEach((doc30) => {
7965
- documents.push(doc30.data());
7966
- lastVisible = doc30;
8136
+ querySnapshot.forEach((doc32) => {
8137
+ documents.push(doc32.data());
8138
+ lastVisible = doc32;
7967
8139
  });
7968
8140
  return {
7969
8141
  documents,
@@ -7978,21 +8150,21 @@ var FilledDocumentService = class extends BaseService {
7978
8150
  * @returns Array of filled documents and the last document for pagination
7979
8151
  */
7980
8152
  async getFilledDocumentsByClinic(clinicId, pageSize = 20, lastDoc) {
7981
- let q = query15(
8153
+ let q = query17(
7982
8154
  this.collectionRef,
7983
- where15("clinicId", "==", clinicId),
8155
+ where17("clinicId", "==", clinicId),
7984
8156
  orderBy6("updatedAt", "desc"),
7985
- limit7(pageSize)
8157
+ limit9(pageSize)
7986
8158
  );
7987
8159
  if (lastDoc) {
7988
- q = query15(q, startAfter7(lastDoc));
8160
+ q = query17(q, startAfter9(lastDoc));
7989
8161
  }
7990
- const querySnapshot = await getDocs15(q);
8162
+ const querySnapshot = await getDocs17(q);
7991
8163
  const documents = [];
7992
8164
  let lastVisible = null;
7993
- querySnapshot.forEach((doc30) => {
7994
- documents.push(doc30.data());
7995
- lastVisible = doc30;
8165
+ querySnapshot.forEach((doc32) => {
8166
+ documents.push(doc32.data());
8167
+ lastVisible = doc32;
7996
8168
  });
7997
8169
  return {
7998
8170
  documents,
@@ -8007,21 +8179,21 @@ var FilledDocumentService = class extends BaseService {
8007
8179
  * @returns Array of filled documents and the last document for pagination
8008
8180
  */
8009
8181
  async getFilledDocumentsByTemplate(templateId, pageSize = 20, lastDoc) {
8010
- let q = query15(
8182
+ let q = query17(
8011
8183
  this.collectionRef,
8012
- where15("templateId", "==", templateId),
8184
+ where17("templateId", "==", templateId),
8013
8185
  orderBy6("updatedAt", "desc"),
8014
- limit7(pageSize)
8186
+ limit9(pageSize)
8015
8187
  );
8016
8188
  if (lastDoc) {
8017
- q = query15(q, startAfter7(lastDoc));
8189
+ q = query17(q, startAfter9(lastDoc));
8018
8190
  }
8019
- const querySnapshot = await getDocs15(q);
8191
+ const querySnapshot = await getDocs17(q);
8020
8192
  const documents = [];
8021
8193
  let lastVisible = null;
8022
- querySnapshot.forEach((doc30) => {
8023
- documents.push(doc30.data());
8024
- lastVisible = doc30;
8194
+ querySnapshot.forEach((doc32) => {
8195
+ documents.push(doc32.data());
8196
+ lastVisible = doc32;
8025
8197
  });
8026
8198
  return {
8027
8199
  documents,
@@ -8036,21 +8208,21 @@ var FilledDocumentService = class extends BaseService {
8036
8208
  * @returns Array of filled documents and the last document for pagination
8037
8209
  */
8038
8210
  async getFilledDocumentsByStatus(status, pageSize = 20, lastDoc) {
8039
- let q = query15(
8211
+ let q = query17(
8040
8212
  this.collectionRef,
8041
- where15("status", "==", status),
8213
+ where17("status", "==", status),
8042
8214
  orderBy6("updatedAt", "desc"),
8043
- limit7(pageSize)
8215
+ limit9(pageSize)
8044
8216
  );
8045
8217
  if (lastDoc) {
8046
- q = query15(q, startAfter7(lastDoc));
8218
+ q = query17(q, startAfter9(lastDoc));
8047
8219
  }
8048
- const querySnapshot = await getDocs15(q);
8220
+ const querySnapshot = await getDocs17(q);
8049
8221
  const documents = [];
8050
8222
  let lastVisible = null;
8051
- querySnapshot.forEach((doc30) => {
8052
- documents.push(doc30.data());
8053
- lastVisible = doc30;
8223
+ querySnapshot.forEach((doc32) => {
8224
+ documents.push(doc32.data());
8225
+ lastVisible = doc32;
8054
8226
  });
8055
8227
  return {
8056
8228
  documents,
@@ -8073,12 +8245,12 @@ var SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
8073
8245
 
8074
8246
  // src/services/calendar/calendar-refactored.service.ts
8075
8247
  import {
8076
- doc as doc22,
8077
- getDoc as getDoc24,
8078
- collection as collection21,
8079
- query as query21,
8080
- where as where21,
8081
- getDocs as getDocs21,
8248
+ doc as doc24,
8249
+ getDoc as getDoc26,
8250
+ collection as collection23,
8251
+ query as query23,
8252
+ where as where23,
8253
+ getDocs as getDocs23,
8082
8254
  setDoc as setDoc21,
8083
8255
  updateDoc as updateDoc23
8084
8256
  } from "firebase/firestore";
@@ -8259,54 +8431,54 @@ var calendarEventSchema = z21.object({
8259
8431
 
8260
8432
  // src/services/calendar/utils/clinic.utils.ts
8261
8433
  import {
8262
- collection as collection16,
8263
- doc as doc17,
8264
- getDoc as getDoc19,
8265
- getDocs as getDocs16,
8434
+ collection as collection18,
8435
+ doc as doc19,
8436
+ getDoc as getDoc21,
8437
+ getDocs as getDocs18,
8266
8438
  setDoc as setDoc16,
8267
8439
  updateDoc as updateDoc18,
8268
8440
  deleteDoc as deleteDoc10,
8269
- query as query16,
8270
- where as where16,
8441
+ query as query18,
8442
+ where as where18,
8271
8443
  orderBy as orderBy7,
8272
8444
  Timestamp as Timestamp19,
8273
8445
  serverTimestamp as serverTimestamp16
8274
8446
  } from "firebase/firestore";
8275
8447
 
8276
8448
  // src/services/calendar/utils/docs.utils.ts
8277
- import { doc as doc16 } from "firebase/firestore";
8449
+ import { doc as doc18 } from "firebase/firestore";
8278
8450
  function getPractitionerCalendarEventDocRef(db, practitionerId, eventId) {
8279
- return doc16(
8451
+ return doc18(
8280
8452
  db,
8281
8453
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${CALENDAR_COLLECTION}/${eventId}`
8282
8454
  );
8283
8455
  }
8284
8456
  function getPatientCalendarEventDocRef(db, patientId, eventId) {
8285
- return doc16(
8457
+ return doc18(
8286
8458
  db,
8287
8459
  `${PATIENTS_COLLECTION}/${patientId}/${CALENDAR_COLLECTION}/${eventId}`
8288
8460
  );
8289
8461
  }
8290
8462
  function getClinicCalendarEventDocRef(db, clinicId, eventId) {
8291
- return doc16(
8463
+ return doc18(
8292
8464
  db,
8293
8465
  `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}/${eventId}`
8294
8466
  );
8295
8467
  }
8296
8468
  function getPractitionerSyncedCalendarDocRef(db, practitionerId, syncedCalendarId) {
8297
- return doc16(
8469
+ return doc18(
8298
8470
  db,
8299
8471
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/syncedCalendars/${syncedCalendarId}`
8300
8472
  );
8301
8473
  }
8302
8474
  function getPatientSyncedCalendarDocRef(db, patientId, syncedCalendarId) {
8303
- return doc16(
8475
+ return doc18(
8304
8476
  db,
8305
8477
  `${PATIENTS_COLLECTION}/${patientId}/syncedCalendars/${syncedCalendarId}`
8306
8478
  );
8307
8479
  }
8308
8480
  function getClinicSyncedCalendarDocRef(db, clinicId, syncedCalendarId) {
8309
- return doc16(
8481
+ return doc18(
8310
8482
  db,
8311
8483
  `${CLINICS_COLLECTION}/${clinicId}/syncedCalendars/${syncedCalendarId}`
8312
8484
  );
@@ -8336,14 +8508,14 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
8336
8508
  updatedAt: serverTimestamp16()
8337
8509
  };
8338
8510
  await updateDoc18(eventRef, updates);
8339
- const updatedDoc = await getDoc19(eventRef);
8511
+ const updatedDoc = await getDoc21(eventRef);
8340
8512
  if (!updatedDoc.exists()) {
8341
8513
  throw new Error("Event not found after update");
8342
8514
  }
8343
8515
  return updatedDoc.data();
8344
8516
  }
8345
8517
  async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
8346
- const clinicDoc = await getDoc19(doc17(db, `clinics/${clinicId}`));
8518
+ const clinicDoc = await getDoc21(doc19(db, `clinics/${clinicId}`));
8347
8519
  if (!clinicDoc.exists()) {
8348
8520
  throw new Error(`Clinic with ID ${clinicId} not found`);
8349
8521
  }
@@ -8352,8 +8524,8 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
8352
8524
  if (!clinicGroupId) {
8353
8525
  return false;
8354
8526
  }
8355
- const clinicGroupDoc = await getDoc19(
8356
- doc17(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
8527
+ const clinicGroupDoc = await getDoc21(
8528
+ doc19(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
8357
8529
  );
8358
8530
  if (!clinicGroupDoc.exists()) {
8359
8531
  return false;
@@ -8364,14 +8536,14 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
8364
8536
 
8365
8537
  // src/services/calendar/utils/patient.utils.ts
8366
8538
  import {
8367
- collection as collection17,
8368
- getDoc as getDoc20,
8369
- getDocs as getDocs17,
8539
+ collection as collection19,
8540
+ getDoc as getDoc22,
8541
+ getDocs as getDocs19,
8370
8542
  setDoc as setDoc17,
8371
8543
  updateDoc as updateDoc19,
8372
8544
  deleteDoc as deleteDoc11,
8373
- query as query17,
8374
- where as where17,
8545
+ query as query19,
8546
+ where as where19,
8375
8547
  orderBy as orderBy8,
8376
8548
  Timestamp as Timestamp20,
8377
8549
  serverTimestamp as serverTimestamp17
@@ -8399,7 +8571,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
8399
8571
  updatedAt: serverTimestamp17()
8400
8572
  };
8401
8573
  await updateDoc19(eventRef, updates);
8402
- const updatedDoc = await getDoc20(eventRef);
8574
+ const updatedDoc = await getDoc22(eventRef);
8403
8575
  if (!updatedDoc.exists()) {
8404
8576
  throw new Error("Event not found after update");
8405
8577
  }
@@ -8408,14 +8580,14 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
8408
8580
 
8409
8581
  // src/services/calendar/utils/practitioner.utils.ts
8410
8582
  import {
8411
- collection as collection18,
8412
- getDoc as getDoc21,
8413
- getDocs as getDocs18,
8583
+ collection as collection20,
8584
+ getDoc as getDoc23,
8585
+ getDocs as getDocs20,
8414
8586
  setDoc as setDoc18,
8415
8587
  updateDoc as updateDoc20,
8416
8588
  deleteDoc as deleteDoc12,
8417
- query as query18,
8418
- where as where18,
8589
+ query as query20,
8590
+ where as where20,
8419
8591
  orderBy as orderBy9,
8420
8592
  Timestamp as Timestamp21,
8421
8593
  serverTimestamp as serverTimestamp18
@@ -8451,7 +8623,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
8451
8623
  updatedAt: serverTimestamp18()
8452
8624
  };
8453
8625
  await updateDoc20(eventRef, updates);
8454
- const updatedDoc = await getDoc21(eventRef);
8626
+ const updatedDoc = await getDoc23(eventRef);
8455
8627
  if (!updatedDoc.exists()) {
8456
8628
  throw new Error("Event not found after update");
8457
8629
  }
@@ -8510,15 +8682,15 @@ async function updateAppointmentUtil(db, clinicId, practitionerId, patientId, ev
8510
8682
 
8511
8683
  // src/services/calendar/utils/calendar-event.utils.ts
8512
8684
  import {
8513
- collection as collection19,
8514
- doc as doc20,
8515
- getDoc as getDoc22,
8516
- getDocs as getDocs19,
8685
+ collection as collection21,
8686
+ doc as doc22,
8687
+ getDoc as getDoc24,
8688
+ getDocs as getDocs21,
8517
8689
  setDoc as setDoc19,
8518
8690
  updateDoc as updateDoc21,
8519
8691
  deleteDoc as deleteDoc13,
8520
- query as query19,
8521
- where as where19,
8692
+ query as query21,
8693
+ where as where21,
8522
8694
  orderBy as orderBy10,
8523
8695
  Timestamp as Timestamp22,
8524
8696
  serverTimestamp as serverTimestamp19
@@ -8565,7 +8737,7 @@ async function searchCalendarEventsUtil(db, params) {
8565
8737
  );
8566
8738
  }
8567
8739
  baseCollectionPath = `${CLINICS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
8568
- constraints.push(where19("clinicBranchId", "==", entityId));
8740
+ constraints.push(where21("clinicBranchId", "==", entityId));
8569
8741
  if (filters.clinicId && filters.clinicId !== entityId) {
8570
8742
  console.warn(
8571
8743
  `Provided clinicId filter (${filters.clinicId}) does not match search entityId (${entityId}). Returning empty results.`
@@ -8577,36 +8749,36 @@ async function searchCalendarEventsUtil(db, params) {
8577
8749
  default:
8578
8750
  throw new Error(`Invalid search location: ${searchLocation}`);
8579
8751
  }
8580
- const collectionRef = collection19(db, baseCollectionPath);
8752
+ const collectionRef = collection21(db, baseCollectionPath);
8581
8753
  if (filters.clinicId) {
8582
- constraints.push(where19("clinicBranchId", "==", filters.clinicId));
8754
+ constraints.push(where21("clinicBranchId", "==", filters.clinicId));
8583
8755
  }
8584
8756
  if (filters.practitionerId) {
8585
8757
  constraints.push(
8586
- where19("practitionerProfileId", "==", filters.practitionerId)
8758
+ where21("practitionerProfileId", "==", filters.practitionerId)
8587
8759
  );
8588
8760
  }
8589
8761
  if (filters.patientId) {
8590
- constraints.push(where19("patientProfileId", "==", filters.patientId));
8762
+ constraints.push(where21("patientProfileId", "==", filters.patientId));
8591
8763
  }
8592
8764
  if (filters.procedureId) {
8593
- constraints.push(where19("procedureId", "==", filters.procedureId));
8765
+ constraints.push(where21("procedureId", "==", filters.procedureId));
8594
8766
  }
8595
8767
  if (filters.eventStatus) {
8596
- constraints.push(where19("status", "==", filters.eventStatus));
8768
+ constraints.push(where21("status", "==", filters.eventStatus));
8597
8769
  }
8598
8770
  if (filters.eventType) {
8599
- constraints.push(where19("eventType", "==", filters.eventType));
8771
+ constraints.push(where21("eventType", "==", filters.eventType));
8600
8772
  }
8601
8773
  if (filters.dateRange) {
8602
- constraints.push(where19("eventTime.start", ">=", filters.dateRange.start));
8603
- constraints.push(where19("eventTime.start", "<=", filters.dateRange.end));
8774
+ constraints.push(where21("eventTime.start", ">=", filters.dateRange.start));
8775
+ constraints.push(where21("eventTime.start", "<=", filters.dateRange.end));
8604
8776
  }
8605
8777
  try {
8606
- const finalQuery = query19(collectionRef, ...constraints);
8607
- const querySnapshot = await getDocs19(finalQuery);
8778
+ const finalQuery = query21(collectionRef, ...constraints);
8779
+ const querySnapshot = await getDocs21(finalQuery);
8608
8780
  const events = querySnapshot.docs.map(
8609
- (doc30) => ({ id: doc30.id, ...doc30.data() })
8781
+ (doc32) => ({ id: doc32.id, ...doc32.data() })
8610
8782
  );
8611
8783
  return events;
8612
8784
  } catch (error) {
@@ -8617,13 +8789,13 @@ async function searchCalendarEventsUtil(db, params) {
8617
8789
 
8618
8790
  // src/services/calendar/utils/synced-calendar.utils.ts
8619
8791
  import {
8620
- collection as collection20,
8621
- getDoc as getDoc23,
8622
- getDocs as getDocs20,
8792
+ collection as collection22,
8793
+ getDoc as getDoc25,
8794
+ getDocs as getDocs22,
8623
8795
  setDoc as setDoc20,
8624
8796
  updateDoc as updateDoc22,
8625
8797
  deleteDoc as deleteDoc14,
8626
- query as query20,
8798
+ query as query22,
8627
8799
  orderBy as orderBy11,
8628
8800
  Timestamp as Timestamp23,
8629
8801
  serverTimestamp as serverTimestamp20
@@ -8686,54 +8858,54 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
8686
8858
  practitionerId,
8687
8859
  calendarId
8688
8860
  );
8689
- const calendarDoc = await getDoc23(calendarRef);
8861
+ const calendarDoc = await getDoc25(calendarRef);
8690
8862
  if (!calendarDoc.exists()) {
8691
8863
  return null;
8692
8864
  }
8693
8865
  return calendarDoc.data();
8694
8866
  }
8695
8867
  async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
8696
- const calendarsRef = collection20(
8868
+ const calendarsRef = collection22(
8697
8869
  db,
8698
8870
  `practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
8699
8871
  );
8700
- const q = query20(calendarsRef, orderBy11("createdAt", "desc"));
8701
- const querySnapshot = await getDocs20(q);
8702
- return querySnapshot.docs.map((doc30) => doc30.data());
8872
+ const q = query22(calendarsRef, orderBy11("createdAt", "desc"));
8873
+ const querySnapshot = await getDocs22(q);
8874
+ return querySnapshot.docs.map((doc32) => doc32.data());
8703
8875
  }
8704
8876
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
8705
8877
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
8706
- const calendarDoc = await getDoc23(calendarRef);
8878
+ const calendarDoc = await getDoc25(calendarRef);
8707
8879
  if (!calendarDoc.exists()) {
8708
8880
  return null;
8709
8881
  }
8710
8882
  return calendarDoc.data();
8711
8883
  }
8712
8884
  async function getPatientSyncedCalendarsUtil(db, patientId) {
8713
- const calendarsRef = collection20(
8885
+ const calendarsRef = collection22(
8714
8886
  db,
8715
8887
  `patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
8716
8888
  );
8717
- const q = query20(calendarsRef, orderBy11("createdAt", "desc"));
8718
- const querySnapshot = await getDocs20(q);
8719
- return querySnapshot.docs.map((doc30) => doc30.data());
8889
+ const q = query22(calendarsRef, orderBy11("createdAt", "desc"));
8890
+ const querySnapshot = await getDocs22(q);
8891
+ return querySnapshot.docs.map((doc32) => doc32.data());
8720
8892
  }
8721
8893
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
8722
8894
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
8723
- const calendarDoc = await getDoc23(calendarRef);
8895
+ const calendarDoc = await getDoc25(calendarRef);
8724
8896
  if (!calendarDoc.exists()) {
8725
8897
  return null;
8726
8898
  }
8727
8899
  return calendarDoc.data();
8728
8900
  }
8729
8901
  async function getClinicSyncedCalendarsUtil(db, clinicId) {
8730
- const calendarsRef = collection20(
8902
+ const calendarsRef = collection22(
8731
8903
  db,
8732
8904
  `clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
8733
8905
  );
8734
- const q = query20(calendarsRef, orderBy11("createdAt", "desc"));
8735
- const querySnapshot = await getDocs20(q);
8736
- return querySnapshot.docs.map((doc30) => doc30.data());
8906
+ const q = query22(calendarsRef, orderBy11("createdAt", "desc"));
8907
+ const querySnapshot = await getDocs22(q);
8908
+ return querySnapshot.docs.map((doc32) => doc32.data());
8737
8909
  }
8738
8910
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
8739
8911
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -8746,7 +8918,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
8746
8918
  updatedAt: serverTimestamp20()
8747
8919
  };
8748
8920
  await updateDoc22(calendarRef, updates);
8749
- const updatedDoc = await getDoc23(calendarRef);
8921
+ const updatedDoc = await getDoc25(calendarRef);
8750
8922
  if (!updatedDoc.exists()) {
8751
8923
  throw new Error("Synced calendar not found after update");
8752
8924
  }
@@ -8759,7 +8931,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
8759
8931
  updatedAt: serverTimestamp20()
8760
8932
  };
8761
8933
  await updateDoc22(calendarRef, updates);
8762
- const updatedDoc = await getDoc23(calendarRef);
8934
+ const updatedDoc = await getDoc25(calendarRef);
8763
8935
  if (!updatedDoc.exists()) {
8764
8936
  throw new Error("Synced calendar not found after update");
8765
8937
  }
@@ -8772,7 +8944,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
8772
8944
  updatedAt: serverTimestamp20()
8773
8945
  };
8774
8946
  await updateDoc22(calendarRef, updates);
8775
- const updatedDoc = await getDoc23(calendarRef);
8947
+ const updatedDoc = await getDoc25(calendarRef);
8776
8948
  if (!updatedDoc.exists()) {
8777
8949
  throw new Error("Synced calendar not found after update");
8778
8950
  }
@@ -9981,7 +10153,7 @@ var CalendarServiceV2 = class extends BaseService {
9981
10153
  async createDoctorBlockingEvent(doctorId, eventData) {
9982
10154
  try {
9983
10155
  const eventId = this.generateId();
9984
- const eventRef = doc22(
10156
+ const eventRef = doc24(
9985
10157
  this.db,
9986
10158
  PRACTITIONERS_COLLECTION,
9987
10159
  doctorId,
@@ -10016,8 +10188,8 @@ var CalendarServiceV2 = class extends BaseService {
10016
10188
  */
10017
10189
  async synchronizeExternalCalendars(lookbackDays = 7, lookforwardDays = 30) {
10018
10190
  try {
10019
- const practitionersRef = collection21(this.db, PRACTITIONERS_COLLECTION);
10020
- const practitionersSnapshot = await getDocs21(practitionersRef);
10191
+ const practitionersRef = collection23(this.db, PRACTITIONERS_COLLECTION);
10192
+ const practitionersSnapshot = await getDocs23(practitionersRef);
10021
10193
  const startDate = /* @__PURE__ */ new Date();
10022
10194
  startDate.setDate(startDate.getDate() - lookbackDays);
10023
10195
  const endDate = /* @__PURE__ */ new Date();
@@ -10075,22 +10247,22 @@ var CalendarServiceV2 = class extends BaseService {
10075
10247
  async updateExistingEventsFromExternalCalendars(doctorId, startDate, endDate) {
10076
10248
  var _a;
10077
10249
  try {
10078
- const eventsRef = collection21(
10250
+ const eventsRef = collection23(
10079
10251
  this.db,
10080
10252
  PRACTITIONERS_COLLECTION,
10081
10253
  doctorId,
10082
10254
  CALENDAR_COLLECTION
10083
10255
  );
10084
- const q = query21(
10256
+ const q = query23(
10085
10257
  eventsRef,
10086
- where21("syncStatus", "==", "external" /* EXTERNAL */),
10087
- where21("eventTime.start", ">=", Timestamp25.fromDate(startDate)),
10088
- where21("eventTime.start", "<=", Timestamp25.fromDate(endDate))
10089
- );
10090
- const eventsSnapshot = await getDocs21(q);
10091
- const events = eventsSnapshot.docs.map((doc30) => ({
10092
- id: doc30.id,
10093
- ...doc30.data()
10258
+ where23("syncStatus", "==", "external" /* EXTERNAL */),
10259
+ where23("eventTime.start", ">=", Timestamp25.fromDate(startDate)),
10260
+ where23("eventTime.start", "<=", Timestamp25.fromDate(endDate))
10261
+ );
10262
+ const eventsSnapshot = await getDocs23(q);
10263
+ const events = eventsSnapshot.docs.map((doc32) => ({
10264
+ id: doc32.id,
10265
+ ...doc32.data()
10094
10266
  }));
10095
10267
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
10096
10268
  doctorId
@@ -10194,7 +10366,7 @@ var CalendarServiceV2 = class extends BaseService {
10194
10366
  const endTime = new Date(
10195
10367
  externalEvent.end.dateTime || externalEvent.end.date
10196
10368
  );
10197
- const eventRef = doc22(
10369
+ const eventRef = doc24(
10198
10370
  this.db,
10199
10371
  PRACTITIONERS_COLLECTION,
10200
10372
  doctorId,
@@ -10226,7 +10398,7 @@ var CalendarServiceV2 = class extends BaseService {
10226
10398
  */
10227
10399
  async updateEventStatus(doctorId, eventId, status) {
10228
10400
  try {
10229
- const eventRef = doc22(
10401
+ const eventRef = doc24(
10230
10402
  this.db,
10231
10403
  PRACTITIONERS_COLLECTION,
10232
10404
  doctorId,
@@ -10392,8 +10564,8 @@ var CalendarServiceV2 = class extends BaseService {
10392
10564
  const startDate = eventTime.start.toDate();
10393
10565
  const startTime = startDate;
10394
10566
  const endTime = eventTime.end.toDate();
10395
- const practitionerRef = doc22(this.db, PRACTITIONERS_COLLECTION, doctorId);
10396
- const practitionerDoc = await getDoc24(practitionerRef);
10567
+ const practitionerRef = doc24(this.db, PRACTITIONERS_COLLECTION, doctorId);
10568
+ const practitionerDoc = await getDoc26(practitionerRef);
10397
10569
  if (!practitionerDoc.exists()) {
10398
10570
  throw new Error(`Doctor with ID ${doctorId} not found`);
10399
10571
  }
@@ -10451,8 +10623,8 @@ var CalendarServiceV2 = class extends BaseService {
10451
10623
  */
10452
10624
  async updateAppointmentStatus(appointmentId, clinicId, status) {
10453
10625
  const baseCollectionPath = `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}`;
10454
- const appointmentRef = doc22(this.db, baseCollectionPath, appointmentId);
10455
- const appointmentDoc = await getDoc24(appointmentRef);
10626
+ const appointmentRef = doc24(this.db, baseCollectionPath, appointmentId);
10627
+ const appointmentDoc = await getDoc26(appointmentRef);
10456
10628
  if (!appointmentDoc.exists()) {
10457
10629
  throw new Error(`Appointment with ID ${appointmentId} not found`);
10458
10630
  }
@@ -10609,8 +10781,8 @@ var CalendarServiceV2 = class extends BaseService {
10609
10781
  async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
10610
10782
  try {
10611
10783
  const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
10612
- const eventRef = doc22(this.db, collectionPath, eventId);
10613
- const eventDoc = await getDoc24(eventRef);
10784
+ const eventRef = doc24(this.db, collectionPath, eventId);
10785
+ const eventDoc = await getDoc26(eventRef);
10614
10786
  if (eventDoc.exists()) {
10615
10787
  const event = eventDoc.data();
10616
10788
  const syncIds = [...event.syncedCalendarEventId || []];
@@ -10648,8 +10820,8 @@ var CalendarServiceV2 = class extends BaseService {
10648
10820
  * @returns Working hours for the clinic
10649
10821
  */
10650
10822
  async getClinicWorkingHours(clinicId, date) {
10651
- const clinicRef = doc22(this.db, CLINICS_COLLECTION, clinicId);
10652
- const clinicDoc = await getDoc24(clinicRef);
10823
+ const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
10824
+ const clinicDoc = await getDoc26(clinicRef);
10653
10825
  if (!clinicDoc.exists()) {
10654
10826
  throw new Error(`Clinic with ID ${clinicId} not found`);
10655
10827
  }
@@ -10677,8 +10849,8 @@ var CalendarServiceV2 = class extends BaseService {
10677
10849
  * @returns Doctor's schedule
10678
10850
  */
10679
10851
  async getDoctorSchedule(doctorId, date) {
10680
- const practitionerRef = doc22(this.db, PRACTITIONERS_COLLECTION, doctorId);
10681
- const practitionerDoc = await getDoc24(practitionerRef);
10852
+ const practitionerRef = doc24(this.db, PRACTITIONERS_COLLECTION, doctorId);
10853
+ const practitionerDoc = await getDoc26(practitionerRef);
10682
10854
  if (!practitionerDoc.exists()) {
10683
10855
  throw new Error(`Doctor with ID ${doctorId} not found`);
10684
10856
  }
@@ -10710,19 +10882,19 @@ var CalendarServiceV2 = class extends BaseService {
10710
10882
  startOfDay.setHours(0, 0, 0, 0);
10711
10883
  const endOfDay = new Date(date);
10712
10884
  endOfDay.setHours(23, 59, 59, 999);
10713
- const appointmentsRef = collection21(this.db, CALENDAR_COLLECTION);
10714
- const q = query21(
10885
+ const appointmentsRef = collection23(this.db, CALENDAR_COLLECTION);
10886
+ const q = query23(
10715
10887
  appointmentsRef,
10716
- where21("practitionerProfileId", "==", doctorId),
10717
- where21("eventTime.start", ">=", Timestamp25.fromDate(startOfDay)),
10718
- where21("eventTime.start", "<=", Timestamp25.fromDate(endOfDay)),
10719
- where21("status", "in", [
10888
+ where23("practitionerProfileId", "==", doctorId),
10889
+ where23("eventTime.start", ">=", Timestamp25.fromDate(startOfDay)),
10890
+ where23("eventTime.start", "<=", Timestamp25.fromDate(endOfDay)),
10891
+ where23("status", "in", [
10720
10892
  "confirmed" /* CONFIRMED */,
10721
10893
  "pending" /* PENDING */
10722
10894
  ])
10723
10895
  );
10724
- const querySnapshot = await getDocs21(q);
10725
- return querySnapshot.docs.map((doc30) => doc30.data());
10896
+ const querySnapshot = await getDocs23(q);
10897
+ return querySnapshot.docs.map((doc32) => doc32.data());
10726
10898
  }
10727
10899
  /**
10728
10900
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -10779,11 +10951,11 @@ var CalendarServiceV2 = class extends BaseService {
10779
10951
  var _a;
10780
10952
  try {
10781
10953
  const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
10782
- getDoc24(doc22(this.db, CLINICS_COLLECTION, clinicId)),
10783
- getDoc24(doc22(this.db, PRACTITIONERS_COLLECTION, doctorId)),
10784
- getDoc24(doc22(this.db, PATIENTS_COLLECTION, patientId)),
10785
- getDoc24(
10786
- doc22(
10954
+ getDoc26(doc24(this.db, CLINICS_COLLECTION, clinicId)),
10955
+ getDoc26(doc24(this.db, PRACTITIONERS_COLLECTION, doctorId)),
10956
+ getDoc26(doc24(this.db, PATIENTS_COLLECTION, patientId)),
10957
+ getDoc26(
10958
+ doc24(
10787
10959
  this.db,
10788
10960
  PATIENTS_COLLECTION,
10789
10961
  patientId,
@@ -10848,12 +11020,12 @@ var CalendarServiceV2 = class extends BaseService {
10848
11020
 
10849
11021
  // src/services/reviews/reviews.service.ts
10850
11022
  import {
10851
- collection as collection22,
10852
- doc as doc23,
10853
- getDoc as getDoc25,
10854
- getDocs as getDocs22,
10855
- query as query22,
10856
- where as where22,
11023
+ collection as collection24,
11024
+ doc as doc25,
11025
+ getDoc as getDoc27,
11026
+ getDocs as getDocs24,
11027
+ query as query24,
11028
+ where as where24,
10857
11029
  updateDoc as updateDoc24,
10858
11030
  setDoc as setDoc22,
10859
11031
  deleteDoc as deleteDoc15,
@@ -10944,7 +11116,7 @@ var ReviewService = class extends BaseService {
10944
11116
  updatedAt: now
10945
11117
  };
10946
11118
  reviewSchema.parse(review);
10947
- const docRef = doc23(this.db, REVIEWS_COLLECTION, reviewId);
11119
+ const docRef = doc25(this.db, REVIEWS_COLLECTION, reviewId);
10948
11120
  await setDoc22(docRef, {
10949
11121
  ...review,
10950
11122
  createdAt: serverTimestamp22(),
@@ -10983,8 +11155,8 @@ var ReviewService = class extends BaseService {
10983
11155
  * @returns The review if found, null otherwise
10984
11156
  */
10985
11157
  async getReview(reviewId) {
10986
- const docRef = doc23(this.db, REVIEWS_COLLECTION, reviewId);
10987
- const docSnap = await getDoc25(docRef);
11158
+ const docRef = doc25(this.db, REVIEWS_COLLECTION, reviewId);
11159
+ const docSnap = await getDoc27(docRef);
10988
11160
  if (!docSnap.exists()) {
10989
11161
  return null;
10990
11162
  }
@@ -10996,12 +11168,12 @@ var ReviewService = class extends BaseService {
10996
11168
  * @returns Array of reviews for the patient
10997
11169
  */
10998
11170
  async getReviewsByPatient(patientId) {
10999
- const q = query22(
11000
- collection22(this.db, REVIEWS_COLLECTION),
11001
- where22("patientId", "==", patientId)
11171
+ const q = query24(
11172
+ collection24(this.db, REVIEWS_COLLECTION),
11173
+ where24("patientId", "==", patientId)
11002
11174
  );
11003
- const snapshot = await getDocs22(q);
11004
- return snapshot.docs.map((doc30) => doc30.data());
11175
+ const snapshot = await getDocs24(q);
11176
+ return snapshot.docs.map((doc32) => doc32.data());
11005
11177
  }
11006
11178
  /**
11007
11179
  * Gets all reviews for a specific clinic
@@ -11009,12 +11181,12 @@ var ReviewService = class extends BaseService {
11009
11181
  * @returns Array of reviews containing clinic reviews
11010
11182
  */
11011
11183
  async getReviewsByClinic(clinicId) {
11012
- const q = query22(
11013
- collection22(this.db, REVIEWS_COLLECTION),
11014
- where22("clinicReview.clinicId", "==", clinicId)
11184
+ const q = query24(
11185
+ collection24(this.db, REVIEWS_COLLECTION),
11186
+ where24("clinicReview.clinicId", "==", clinicId)
11015
11187
  );
11016
- const snapshot = await getDocs22(q);
11017
- return snapshot.docs.map((doc30) => doc30.data());
11188
+ const snapshot = await getDocs24(q);
11189
+ return snapshot.docs.map((doc32) => doc32.data());
11018
11190
  }
11019
11191
  /**
11020
11192
  * Gets all reviews for a specific practitioner
@@ -11022,12 +11194,12 @@ var ReviewService = class extends BaseService {
11022
11194
  * @returns Array of reviews containing practitioner reviews
11023
11195
  */
11024
11196
  async getReviewsByPractitioner(practitionerId) {
11025
- const q = query22(
11026
- collection22(this.db, REVIEWS_COLLECTION),
11027
- where22("practitionerReview.practitionerId", "==", practitionerId)
11197
+ const q = query24(
11198
+ collection24(this.db, REVIEWS_COLLECTION),
11199
+ where24("practitionerReview.practitionerId", "==", practitionerId)
11028
11200
  );
11029
- const snapshot = await getDocs22(q);
11030
- return snapshot.docs.map((doc30) => doc30.data());
11201
+ const snapshot = await getDocs24(q);
11202
+ return snapshot.docs.map((doc32) => doc32.data());
11031
11203
  }
11032
11204
  /**
11033
11205
  * Gets all reviews for a specific procedure
@@ -11035,12 +11207,12 @@ var ReviewService = class extends BaseService {
11035
11207
  * @returns Array of reviews containing procedure reviews
11036
11208
  */
11037
11209
  async getReviewsByProcedure(procedureId) {
11038
- const q = query22(
11039
- collection22(this.db, REVIEWS_COLLECTION),
11040
- where22("procedureReview.procedureId", "==", procedureId)
11210
+ const q = query24(
11211
+ collection24(this.db, REVIEWS_COLLECTION),
11212
+ where24("procedureReview.procedureId", "==", procedureId)
11041
11213
  );
11042
- const snapshot = await getDocs22(q);
11043
- return snapshot.docs.map((doc30) => doc30.data());
11214
+ const snapshot = await getDocs24(q);
11215
+ return snapshot.docs.map((doc32) => doc32.data());
11044
11216
  }
11045
11217
  /**
11046
11218
  * Gets all reviews for a specific appointment
@@ -11048,11 +11220,11 @@ var ReviewService = class extends BaseService {
11048
11220
  * @returns The review for the appointment if found, null otherwise
11049
11221
  */
11050
11222
  async getReviewByAppointment(appointmentId) {
11051
- const q = query22(
11052
- collection22(this.db, REVIEWS_COLLECTION),
11053
- where22("appointmentId", "==", appointmentId)
11223
+ const q = query24(
11224
+ collection24(this.db, REVIEWS_COLLECTION),
11225
+ where24("appointmentId", "==", appointmentId)
11054
11226
  );
11055
- const snapshot = await getDocs22(q);
11227
+ const snapshot = await getDocs24(q);
11056
11228
  if (snapshot.empty) {
11057
11229
  return null;
11058
11230
  }
@@ -11067,7 +11239,7 @@ var ReviewService = class extends BaseService {
11067
11239
  if (!review) {
11068
11240
  throw new Error(`Review with ID ${reviewId} not found`);
11069
11241
  }
11070
- await deleteDoc15(doc23(this.db, REVIEWS_COLLECTION, reviewId));
11242
+ await deleteDoc15(doc25(this.db, REVIEWS_COLLECTION, reviewId));
11071
11243
  const updatePromises = [];
11072
11244
  if (review.clinicReview) {
11073
11245
  updatePromises.push(
@@ -11106,7 +11278,7 @@ var ReviewService = class extends BaseService {
11106
11278
  * @returns The updated clinic review info
11107
11279
  */
11108
11280
  async updateClinicReviewInfo(clinicId, newReview, isRemoval = false) {
11109
- const clinicDoc = await getDoc25(doc23(this.db, CLINICS_COLLECTION, clinicId));
11281
+ const clinicDoc = await getDoc27(doc25(this.db, CLINICS_COLLECTION, clinicId));
11110
11282
  if (!clinicDoc.exists()) {
11111
11283
  throw new Error(`Clinic with ID ${clinicId} not found`);
11112
11284
  }
@@ -11122,7 +11294,7 @@ var ReviewService = class extends BaseService {
11122
11294
  recommendationPercentage: 0
11123
11295
  };
11124
11296
  if (currentReviewInfo.totalReviews === 0 && !newReview) {
11125
- await updateDoc24(doc23(this.db, CLINICS_COLLECTION, clinicId), {
11297
+ await updateDoc24(doc25(this.db, CLINICS_COLLECTION, clinicId), {
11126
11298
  reviewInfo: currentReviewInfo,
11127
11299
  updatedAt: serverTimestamp22()
11128
11300
  });
@@ -11185,7 +11357,7 @@ var ReviewService = class extends BaseService {
11185
11357
  } else {
11186
11358
  updatedReviewInfo = { ...currentReviewInfo };
11187
11359
  }
11188
- await updateDoc24(doc23(this.db, CLINICS_COLLECTION, clinicId), {
11360
+ await updateDoc24(doc25(this.db, CLINICS_COLLECTION, clinicId), {
11189
11361
  reviewInfo: updatedReviewInfo,
11190
11362
  updatedAt: serverTimestamp22()
11191
11363
  });
@@ -11199,8 +11371,8 @@ var ReviewService = class extends BaseService {
11199
11371
  * @returns The updated practitioner review info
11200
11372
  */
11201
11373
  async updatePractitionerReviewInfo(practitionerId, newReview, isRemoval = false) {
11202
- const practitionerDoc = await getDoc25(
11203
- doc23(this.db, PRACTITIONERS_COLLECTION, practitionerId)
11374
+ const practitionerDoc = await getDoc27(
11375
+ doc25(this.db, PRACTITIONERS_COLLECTION, practitionerId)
11204
11376
  );
11205
11377
  if (!practitionerDoc.exists()) {
11206
11378
  throw new Error(`Practitioner with ID ${practitionerId} not found`);
@@ -11217,7 +11389,7 @@ var ReviewService = class extends BaseService {
11217
11389
  recommendationPercentage: 0
11218
11390
  };
11219
11391
  if (currentReviewInfo.totalReviews === 0 && !newReview) {
11220
- await updateDoc24(doc23(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11392
+ await updateDoc24(doc25(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11221
11393
  reviewInfo: currentReviewInfo,
11222
11394
  updatedAt: serverTimestamp22()
11223
11395
  });
@@ -11280,7 +11452,7 @@ var ReviewService = class extends BaseService {
11280
11452
  } else {
11281
11453
  updatedReviewInfo = { ...currentReviewInfo };
11282
11454
  }
11283
- await updateDoc24(doc23(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11455
+ await updateDoc24(doc25(this.db, PRACTITIONERS_COLLECTION, practitionerId), {
11284
11456
  reviewInfo: updatedReviewInfo,
11285
11457
  updatedAt: serverTimestamp22()
11286
11458
  });
@@ -11298,8 +11470,8 @@ var ReviewService = class extends BaseService {
11298
11470
  * @returns The updated procedure review info
11299
11471
  */
11300
11472
  async updateProcedureReviewInfo(procedureId, newReview, isRemoval = false) {
11301
- const procedureDoc = await getDoc25(
11302
- doc23(this.db, PROCEDURES_COLLECTION, procedureId)
11473
+ const procedureDoc = await getDoc27(
11474
+ doc25(this.db, PROCEDURES_COLLECTION, procedureId)
11303
11475
  );
11304
11476
  if (!procedureDoc.exists()) {
11305
11477
  throw new Error(`Procedure with ID ${procedureId} not found`);
@@ -11316,7 +11488,7 @@ var ReviewService = class extends BaseService {
11316
11488
  recommendationPercentage: 0
11317
11489
  };
11318
11490
  if (currentReviewInfo.totalReviews === 0 && !newReview) {
11319
- await updateDoc24(doc23(this.db, PROCEDURES_COLLECTION, procedureId), {
11491
+ await updateDoc24(doc25(this.db, PROCEDURES_COLLECTION, procedureId), {
11320
11492
  reviewInfo: currentReviewInfo,
11321
11493
  updatedAt: serverTimestamp22()
11322
11494
  });
@@ -11379,7 +11551,7 @@ var ReviewService = class extends BaseService {
11379
11551
  } else {
11380
11552
  updatedReviewInfo = { ...currentReviewInfo };
11381
11553
  }
11382
- await updateDoc24(doc23(this.db, PROCEDURES_COLLECTION, procedureId), {
11554
+ await updateDoc24(doc25(this.db, PROCEDURES_COLLECTION, procedureId), {
11383
11555
  reviewInfo: updatedReviewInfo,
11384
11556
  updatedAt: serverTimestamp22()
11385
11557
  });
@@ -11391,17 +11563,17 @@ var ReviewService = class extends BaseService {
11391
11563
  * @param rating The new rating to set
11392
11564
  */
11393
11565
  async updateDoctorInfoInProcedures(practitionerId, rating) {
11394
- const q = query22(
11395
- collection22(this.db, PROCEDURES_COLLECTION),
11396
- where22("practitionerId", "==", practitionerId)
11566
+ const q = query24(
11567
+ collection24(this.db, PROCEDURES_COLLECTION),
11568
+ where24("practitionerId", "==", practitionerId)
11397
11569
  );
11398
- const snapshot = await getDocs22(q);
11570
+ const snapshot = await getDocs24(q);
11399
11571
  if (snapshot.empty) {
11400
11572
  return;
11401
11573
  }
11402
11574
  const batch = writeBatch7(this.db);
11403
11575
  snapshot.docs.forEach((docSnapshot) => {
11404
- const procedureRef = doc23(this.db, PROCEDURES_COLLECTION, docSnapshot.id);
11576
+ const procedureRef = doc25(this.db, PROCEDURES_COLLECTION, docSnapshot.id);
11405
11577
  batch.update(procedureRef, {
11406
11578
  "doctorInfo.rating": rating,
11407
11579
  updatedAt: serverTimestamp22()
@@ -11419,7 +11591,7 @@ var ReviewService = class extends BaseService {
11419
11591
  throw new Error(`Review with ID ${reviewId} not found`);
11420
11592
  }
11421
11593
  const batch = writeBatch7(this.db);
11422
- batch.update(doc23(this.db, REVIEWS_COLLECTION, reviewId), {
11594
+ batch.update(doc25(this.db, REVIEWS_COLLECTION, reviewId), {
11423
11595
  updatedAt: serverTimestamp22()
11424
11596
  });
11425
11597
  if (review.clinicReview) {
@@ -11475,19 +11647,19 @@ import { getFunctions, httpsCallable } from "firebase/functions";
11475
11647
 
11476
11648
  // src/services/appointment/utils/appointment.utils.ts
11477
11649
  import {
11478
- collection as collection23,
11479
- doc as doc24,
11480
- getDoc as getDoc26,
11481
- getDocs as getDocs23,
11482
- query as query23,
11483
- where as where23,
11650
+ collection as collection25,
11651
+ doc as doc26,
11652
+ getDoc as getDoc28,
11653
+ getDocs as getDocs25,
11654
+ query as query25,
11655
+ where as where25,
11484
11656
  setDoc as setDoc23,
11485
11657
  updateDoc as updateDoc25,
11486
11658
  serverTimestamp as serverTimestamp23,
11487
11659
  Timestamp as Timestamp27,
11488
11660
  orderBy as orderBy12,
11489
- limit as limit8,
11490
- startAfter as startAfter8
11661
+ limit as limit10,
11662
+ startAfter as startAfter10
11491
11663
  } from "firebase/firestore";
11492
11664
 
11493
11665
  // src/backoffice/types/technology.types.ts
@@ -11498,10 +11670,10 @@ async function fetchAggregatedInfoUtil(db, clinicId, practitionerId, patientId,
11498
11670
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
11499
11671
  try {
11500
11672
  const [clinicDoc, practitionerDoc, patientDoc, procedureDoc] = await Promise.all([
11501
- getDoc26(doc24(db, CLINICS_COLLECTION, clinicId)),
11502
- getDoc26(doc24(db, PRACTITIONERS_COLLECTION, practitionerId)),
11503
- getDoc26(doc24(db, PATIENTS_COLLECTION, patientId)),
11504
- getDoc26(doc24(db, PROCEDURES_COLLECTION, procedureId))
11673
+ getDoc28(doc26(db, CLINICS_COLLECTION, clinicId)),
11674
+ getDoc28(doc26(db, PRACTITIONERS_COLLECTION, practitionerId)),
11675
+ getDoc28(doc26(db, PATIENTS_COLLECTION, patientId)),
11676
+ getDoc28(doc26(db, PROCEDURES_COLLECTION, procedureId))
11505
11677
  ]);
11506
11678
  if (!clinicDoc.exists()) {
11507
11679
  throw new Error(`Clinic with ID ${clinicId} not found`);
@@ -11572,8 +11744,8 @@ async function fetchAggregatedInfoUtil(db, clinicId, practitionerId, patientId,
11572
11744
  let preProcedureRequirements = [];
11573
11745
  let postProcedureRequirements = [];
11574
11746
  if (technologyId) {
11575
- const technologyDoc = await getDoc26(
11576
- doc24(db, TECHNOLOGIES_COLLECTION, technologyId)
11747
+ const technologyDoc = await getDoc28(
11748
+ doc26(db, TECHNOLOGIES_COLLECTION, technologyId)
11577
11749
  );
11578
11750
  if (technologyDoc.exists()) {
11579
11751
  const technologyData = technologyDoc.data();
@@ -11637,8 +11809,8 @@ async function createAppointmentUtil2(db, data, aggregatedInfo, generateId2) {
11637
11809
  if (data.initialStatus === "confirmed" /* CONFIRMED */) {
11638
11810
  appointment.confirmationTime = Timestamp27.now();
11639
11811
  }
11640
- await setDoc23(doc24(db, APPOINTMENTS_COLLECTION, appointmentId), appointment);
11641
- const calendarEventRef = doc24(db, CALENDAR_COLLECTION, data.calendarEventId);
11812
+ await setDoc23(doc26(db, APPOINTMENTS_COLLECTION, appointmentId), appointment);
11813
+ const calendarEventRef = doc26(db, CALENDAR_COLLECTION, data.calendarEventId);
11642
11814
  await updateDoc25(calendarEventRef, {
11643
11815
  appointmentId,
11644
11816
  updatedAt: serverTimestamp23()
@@ -11656,8 +11828,8 @@ async function createAppointmentUtil2(db, data, aggregatedInfo, generateId2) {
11656
11828
  }
11657
11829
  async function updateAppointmentUtil2(db, appointmentId, data) {
11658
11830
  try {
11659
- const appointmentRef = doc24(db, APPOINTMENTS_COLLECTION, appointmentId);
11660
- const appointmentDoc = await getDoc26(appointmentRef);
11831
+ const appointmentRef = doc26(db, APPOINTMENTS_COLLECTION, appointmentId);
11832
+ const appointmentDoc = await getDoc28(appointmentRef);
11661
11833
  if (!appointmentDoc.exists()) {
11662
11834
  throw new Error(`Appointment with ID ${appointmentId} not found`);
11663
11835
  }
@@ -11726,7 +11898,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
11726
11898
  }
11727
11899
  }
11728
11900
  await updateDoc25(appointmentRef, updateData);
11729
- const updatedAppointmentDoc = await getDoc26(appointmentRef);
11901
+ const updatedAppointmentDoc = await getDoc28(appointmentRef);
11730
11902
  if (!updatedAppointmentDoc.exists()) {
11731
11903
  throw new Error(
11732
11904
  `Failed to retrieve updated appointment ${appointmentId}`
@@ -11740,8 +11912,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
11740
11912
  }
11741
11913
  async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus) {
11742
11914
  try {
11743
- const calendarEventRef = doc24(db, CALENDAR_COLLECTION, calendarEventId);
11744
- const calendarEventDoc = await getDoc26(calendarEventRef);
11915
+ const calendarEventRef = doc26(db, CALENDAR_COLLECTION, calendarEventId);
11916
+ const calendarEventDoc = await getDoc28(calendarEventRef);
11745
11917
  if (!calendarEventDoc.exists()) {
11746
11918
  console.warn(`Calendar event with ID ${calendarEventId} not found`);
11747
11919
  return;
@@ -11774,8 +11946,8 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
11774
11946
  }
11775
11947
  async function getAppointmentByIdUtil(db, appointmentId) {
11776
11948
  try {
11777
- const appointmentDoc = await getDoc26(
11778
- doc24(db, APPOINTMENTS_COLLECTION, appointmentId)
11949
+ const appointmentDoc = await getDoc28(
11950
+ doc26(db, APPOINTMENTS_COLLECTION, appointmentId)
11779
11951
  );
11780
11952
  if (!appointmentDoc.exists()) {
11781
11953
  return null;
@@ -11790,17 +11962,17 @@ async function searchAppointmentsUtil(db, params) {
11790
11962
  try {
11791
11963
  const constraints = [];
11792
11964
  if (params.patientId) {
11793
- constraints.push(where23("patientId", "==", params.patientId));
11965
+ constraints.push(where25("patientId", "==", params.patientId));
11794
11966
  }
11795
11967
  if (params.practitionerId) {
11796
- constraints.push(where23("practitionerId", "==", params.practitionerId));
11968
+ constraints.push(where25("practitionerId", "==", params.practitionerId));
11797
11969
  }
11798
11970
  if (params.clinicBranchId) {
11799
- constraints.push(where23("clinicBranchId", "==", params.clinicBranchId));
11971
+ constraints.push(where25("clinicBranchId", "==", params.clinicBranchId));
11800
11972
  }
11801
11973
  if (params.startDate) {
11802
11974
  constraints.push(
11803
- where23(
11975
+ where25(
11804
11976
  "appointmentStartTime",
11805
11977
  ">=",
11806
11978
  Timestamp27.fromDate(params.startDate)
@@ -11809,27 +11981,27 @@ async function searchAppointmentsUtil(db, params) {
11809
11981
  }
11810
11982
  if (params.endDate) {
11811
11983
  constraints.push(
11812
- where23("appointmentStartTime", "<=", Timestamp27.fromDate(params.endDate))
11984
+ where25("appointmentStartTime", "<=", Timestamp27.fromDate(params.endDate))
11813
11985
  );
11814
11986
  }
11815
11987
  if (params.status) {
11816
11988
  if (Array.isArray(params.status)) {
11817
- constraints.push(where23("status", "in", params.status));
11989
+ constraints.push(where25("status", "in", params.status));
11818
11990
  } else {
11819
- constraints.push(where23("status", "==", params.status));
11991
+ constraints.push(where25("status", "==", params.status));
11820
11992
  }
11821
11993
  }
11822
11994
  constraints.push(orderBy12("appointmentStartTime", "asc"));
11823
11995
  if (params.limit) {
11824
- constraints.push(limit8(params.limit));
11996
+ constraints.push(limit10(params.limit));
11825
11997
  }
11826
11998
  if (params.startAfter) {
11827
- constraints.push(startAfter8(params.startAfter));
11999
+ constraints.push(startAfter10(params.startAfter));
11828
12000
  }
11829
- const q = query23(collection23(db, APPOINTMENTS_COLLECTION), ...constraints);
11830
- const querySnapshot = await getDocs23(q);
12001
+ const q = query25(collection25(db, APPOINTMENTS_COLLECTION), ...constraints);
12002
+ const querySnapshot = await getDocs25(q);
11831
12003
  const appointments = querySnapshot.docs.map(
11832
- (doc30) => doc30.data()
12004
+ (doc32) => doc32.data()
11833
12005
  );
11834
12006
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
11835
12007
  return { appointments, lastDoc };
@@ -12442,13 +12614,13 @@ var AppointmentService = class extends BaseService {
12442
12614
  // src/backoffice/services/brand.service.ts
12443
12615
  import {
12444
12616
  addDoc as addDoc3,
12445
- collection as collection24,
12446
- doc as doc25,
12447
- getDoc as getDoc27,
12448
- getDocs as getDocs24,
12449
- query as query24,
12617
+ collection as collection26,
12618
+ doc as doc27,
12619
+ getDoc as getDoc29,
12620
+ getDocs as getDocs26,
12621
+ query as query26,
12450
12622
  updateDoc as updateDoc26,
12451
- where as where24
12623
+ where as where26
12452
12624
  } from "firebase/firestore";
12453
12625
 
12454
12626
  // src/backoffice/types/brand.types.ts
@@ -12460,7 +12632,7 @@ var BrandService = class extends BaseService {
12460
12632
  * Gets reference to brands collection
12461
12633
  */
12462
12634
  getBrandsRef() {
12463
- return collection24(this.db, BRANDS_COLLECTION);
12635
+ return collection26(this.db, BRANDS_COLLECTION);
12464
12636
  }
12465
12637
  /**
12466
12638
  * Creates a new brand
@@ -12480,12 +12652,12 @@ var BrandService = class extends BaseService {
12480
12652
  * Gets all active brands
12481
12653
  */
12482
12654
  async getAll() {
12483
- const q = query24(this.getBrandsRef(), where24("isActive", "==", true));
12484
- const snapshot = await getDocs24(q);
12655
+ const q = query26(this.getBrandsRef(), where26("isActive", "==", true));
12656
+ const snapshot = await getDocs26(q);
12485
12657
  return snapshot.docs.map(
12486
- (doc30) => ({
12487
- id: doc30.id,
12488
- ...doc30.data()
12658
+ (doc32) => ({
12659
+ id: doc32.id,
12660
+ ...doc32.data()
12489
12661
  })
12490
12662
  );
12491
12663
  }
@@ -12497,7 +12669,7 @@ var BrandService = class extends BaseService {
12497
12669
  ...brand,
12498
12670
  updatedAt: /* @__PURE__ */ new Date()
12499
12671
  };
12500
- const docRef = doc25(this.getBrandsRef(), brandId);
12672
+ const docRef = doc27(this.getBrandsRef(), brandId);
12501
12673
  await updateDoc26(docRef, updateData);
12502
12674
  return this.getById(brandId);
12503
12675
  }
@@ -12513,8 +12685,8 @@ var BrandService = class extends BaseService {
12513
12685
  * Gets a brand by ID
12514
12686
  */
12515
12687
  async getById(brandId) {
12516
- const docRef = doc25(this.getBrandsRef(), brandId);
12517
- const docSnap = await getDoc27(docRef);
12688
+ const docRef = doc27(this.getBrandsRef(), brandId);
12689
+ const docSnap = await getDoc29(docRef);
12518
12690
  if (!docSnap.exists()) return null;
12519
12691
  return {
12520
12692
  id: docSnap.id,
@@ -12526,13 +12698,13 @@ var BrandService = class extends BaseService {
12526
12698
  // src/backoffice/services/category.service.ts
12527
12699
  import {
12528
12700
  addDoc as addDoc4,
12529
- collection as collection25,
12530
- doc as doc26,
12531
- getDoc as getDoc28,
12532
- getDocs as getDocs25,
12533
- query as query25,
12701
+ collection as collection27,
12702
+ doc as doc28,
12703
+ getDoc as getDoc30,
12704
+ getDocs as getDocs27,
12705
+ query as query27,
12534
12706
  updateDoc as updateDoc27,
12535
- where as where25
12707
+ where as where27
12536
12708
  } from "firebase/firestore";
12537
12709
 
12538
12710
  // src/backoffice/types/category.types.ts
@@ -12544,7 +12716,7 @@ var CategoryService = class extends BaseService {
12544
12716
  * Referenca na Firestore kolekciju kategorija
12545
12717
  */
12546
12718
  get categoriesRef() {
12547
- return collection25(this.db, CATEGORIES_COLLECTION);
12719
+ return collection27(this.db, CATEGORIES_COLLECTION);
12548
12720
  }
12549
12721
  /**
12550
12722
  * Kreira novu kategoriju u sistemu
@@ -12567,12 +12739,12 @@ var CategoryService = class extends BaseService {
12567
12739
  * @returns Lista aktivnih kategorija
12568
12740
  */
12569
12741
  async getAll() {
12570
- const q = query25(this.categoriesRef, where25("isActive", "==", true));
12571
- const snapshot = await getDocs25(q);
12742
+ const q = query27(this.categoriesRef, where27("isActive", "==", true));
12743
+ const snapshot = await getDocs27(q);
12572
12744
  return snapshot.docs.map(
12573
- (doc30) => ({
12574
- id: doc30.id,
12575
- ...doc30.data()
12745
+ (doc32) => ({
12746
+ id: doc32.id,
12747
+ ...doc32.data()
12576
12748
  })
12577
12749
  );
12578
12750
  }
@@ -12582,16 +12754,16 @@ var CategoryService = class extends BaseService {
12582
12754
  * @returns Lista kategorija koje pripadaju traženoj familiji
12583
12755
  */
12584
12756
  async getAllByFamily(family) {
12585
- const q = query25(
12757
+ const q = query27(
12586
12758
  this.categoriesRef,
12587
- where25("family", "==", family),
12588
- where25("isActive", "==", true)
12759
+ where27("family", "==", family),
12760
+ where27("isActive", "==", true)
12589
12761
  );
12590
- const snapshot = await getDocs25(q);
12762
+ const snapshot = await getDocs27(q);
12591
12763
  return snapshot.docs.map(
12592
- (doc30) => ({
12593
- id: doc30.id,
12594
- ...doc30.data()
12764
+ (doc32) => ({
12765
+ id: doc32.id,
12766
+ ...doc32.data()
12595
12767
  })
12596
12768
  );
12597
12769
  }
@@ -12606,7 +12778,7 @@ var CategoryService = class extends BaseService {
12606
12778
  ...category,
12607
12779
  updatedAt: /* @__PURE__ */ new Date()
12608
12780
  };
12609
- const docRef = doc26(this.categoriesRef, id);
12781
+ const docRef = doc28(this.categoriesRef, id);
12610
12782
  await updateDoc27(docRef, updateData);
12611
12783
  return this.getById(id);
12612
12784
  }
@@ -12623,8 +12795,8 @@ var CategoryService = class extends BaseService {
12623
12795
  * @returns Kategorija ili null ako ne postoji
12624
12796
  */
12625
12797
  async getById(id) {
12626
- const docRef = doc26(this.categoriesRef, id);
12627
- const docSnap = await getDoc28(docRef);
12798
+ const docRef = doc28(this.categoriesRef, id);
12799
+ const docSnap = await getDoc30(docRef);
12628
12800
  if (!docSnap.exists()) return null;
12629
12801
  return {
12630
12802
  id: docSnap.id,
@@ -12636,13 +12808,13 @@ var CategoryService = class extends BaseService {
12636
12808
  // src/backoffice/services/subcategory.service.ts
12637
12809
  import {
12638
12810
  addDoc as addDoc5,
12639
- collection as collection26,
12640
- doc as doc27,
12641
- getDoc as getDoc29,
12642
- getDocs as getDocs26,
12643
- query as query26,
12811
+ collection as collection28,
12812
+ doc as doc29,
12813
+ getDoc as getDoc31,
12814
+ getDocs as getDocs28,
12815
+ query as query28,
12644
12816
  updateDoc as updateDoc28,
12645
- where as where26
12817
+ where as where28
12646
12818
  } from "firebase/firestore";
12647
12819
 
12648
12820
  // src/backoffice/types/subcategory.types.ts
@@ -12655,7 +12827,7 @@ var SubcategoryService = class extends BaseService {
12655
12827
  * @param categoryId - ID roditeljske kategorije
12656
12828
  */
12657
12829
  getSubcategoriesRef(categoryId) {
12658
- return collection26(
12830
+ return collection28(
12659
12831
  this.db,
12660
12832
  CATEGORIES_COLLECTION,
12661
12833
  categoryId,
@@ -12689,15 +12861,15 @@ var SubcategoryService = class extends BaseService {
12689
12861
  * @returns Lista aktivnih podkategorija
12690
12862
  */
12691
12863
  async getAllByCategoryId(categoryId) {
12692
- const q = query26(
12864
+ const q = query28(
12693
12865
  this.getSubcategoriesRef(categoryId),
12694
- where26("isActive", "==", true)
12866
+ where28("isActive", "==", true)
12695
12867
  );
12696
- const snapshot = await getDocs26(q);
12868
+ const snapshot = await getDocs28(q);
12697
12869
  return snapshot.docs.map(
12698
- (doc30) => ({
12699
- id: doc30.id,
12700
- ...doc30.data()
12870
+ (doc32) => ({
12871
+ id: doc32.id,
12872
+ ...doc32.data()
12701
12873
  })
12702
12874
  );
12703
12875
  }
@@ -12713,7 +12885,7 @@ var SubcategoryService = class extends BaseService {
12713
12885
  ...subcategory,
12714
12886
  updatedAt: /* @__PURE__ */ new Date()
12715
12887
  };
12716
- const docRef = doc27(this.getSubcategoriesRef(categoryId), subcategoryId);
12888
+ const docRef = doc29(this.getSubcategoriesRef(categoryId), subcategoryId);
12717
12889
  await updateDoc28(docRef, updateData);
12718
12890
  return this.getById(categoryId, subcategoryId);
12719
12891
  }
@@ -12732,8 +12904,8 @@ var SubcategoryService = class extends BaseService {
12732
12904
  * @returns Podkategorija ili null ako ne postoji
12733
12905
  */
12734
12906
  async getById(categoryId, subcategoryId) {
12735
- const docRef = doc27(this.getSubcategoriesRef(categoryId), subcategoryId);
12736
- const docSnap = await getDoc29(docRef);
12907
+ const docRef = doc29(this.getSubcategoriesRef(categoryId), subcategoryId);
12908
+ const docSnap = await getDoc31(docRef);
12737
12909
  if (!docSnap.exists()) return null;
12738
12910
  return {
12739
12911
  id: docSnap.id,
@@ -12745,13 +12917,13 @@ var SubcategoryService = class extends BaseService {
12745
12917
  // src/backoffice/services/technology.service.ts
12746
12918
  import {
12747
12919
  addDoc as addDoc6,
12748
- collection as collection27,
12749
- doc as doc28,
12750
- getDoc as getDoc30,
12751
- getDocs as getDocs27,
12752
- query as query27,
12920
+ collection as collection29,
12921
+ doc as doc30,
12922
+ getDoc as getDoc32,
12923
+ getDocs as getDocs29,
12924
+ query as query29,
12753
12925
  updateDoc as updateDoc29,
12754
- where as where27,
12926
+ where as where29,
12755
12927
  arrayUnion as arrayUnion8,
12756
12928
  arrayRemove as arrayRemove7
12757
12929
  } from "firebase/firestore";
@@ -12764,7 +12936,7 @@ var TechnologyService = class extends BaseService {
12764
12936
  * Vraća referencu na Firestore kolekciju tehnologija
12765
12937
  */
12766
12938
  getTechnologiesRef() {
12767
- return collection27(this.db, TECHNOLOGIES_COLLECTION);
12939
+ return collection29(this.db, TECHNOLOGIES_COLLECTION);
12768
12940
  }
12769
12941
  /**
12770
12942
  * Kreira novu tehnologiju
@@ -12795,12 +12967,12 @@ var TechnologyService = class extends BaseService {
12795
12967
  * @returns Lista aktivnih tehnologija
12796
12968
  */
12797
12969
  async getAll() {
12798
- const q = query27(this.getTechnologiesRef(), where27("isActive", "==", true));
12799
- const snapshot = await getDocs27(q);
12970
+ const q = query29(this.getTechnologiesRef(), where29("isActive", "==", true));
12971
+ const snapshot = await getDocs29(q);
12800
12972
  return snapshot.docs.map(
12801
- (doc30) => ({
12802
- id: doc30.id,
12803
- ...doc30.data()
12973
+ (doc32) => ({
12974
+ id: doc32.id,
12975
+ ...doc32.data()
12804
12976
  })
12805
12977
  );
12806
12978
  }
@@ -12810,16 +12982,16 @@ var TechnologyService = class extends BaseService {
12810
12982
  * @returns Lista aktivnih tehnologija
12811
12983
  */
12812
12984
  async getAllByFamily(family) {
12813
- const q = query27(
12985
+ const q = query29(
12814
12986
  this.getTechnologiesRef(),
12815
- where27("isActive", "==", true),
12816
- where27("family", "==", family)
12987
+ where29("isActive", "==", true),
12988
+ where29("family", "==", family)
12817
12989
  );
12818
- const snapshot = await getDocs27(q);
12990
+ const snapshot = await getDocs29(q);
12819
12991
  return snapshot.docs.map(
12820
- (doc30) => ({
12821
- id: doc30.id,
12822
- ...doc30.data()
12992
+ (doc32) => ({
12993
+ id: doc32.id,
12994
+ ...doc32.data()
12823
12995
  })
12824
12996
  );
12825
12997
  }
@@ -12829,16 +13001,16 @@ var TechnologyService = class extends BaseService {
12829
13001
  * @returns Lista aktivnih tehnologija
12830
13002
  */
12831
13003
  async getAllByCategoryId(categoryId) {
12832
- const q = query27(
13004
+ const q = query29(
12833
13005
  this.getTechnologiesRef(),
12834
- where27("isActive", "==", true),
12835
- where27("categoryId", "==", categoryId)
13006
+ where29("isActive", "==", true),
13007
+ where29("categoryId", "==", categoryId)
12836
13008
  );
12837
- const snapshot = await getDocs27(q);
13009
+ const snapshot = await getDocs29(q);
12838
13010
  return snapshot.docs.map(
12839
- (doc30) => ({
12840
- id: doc30.id,
12841
- ...doc30.data()
13011
+ (doc32) => ({
13012
+ id: doc32.id,
13013
+ ...doc32.data()
12842
13014
  })
12843
13015
  );
12844
13016
  }
@@ -12848,16 +13020,16 @@ var TechnologyService = class extends BaseService {
12848
13020
  * @returns Lista aktivnih tehnologija
12849
13021
  */
12850
13022
  async getAllBySubcategoryId(subcategoryId) {
12851
- const q = query27(
13023
+ const q = query29(
12852
13024
  this.getTechnologiesRef(),
12853
- where27("isActive", "==", true),
12854
- where27("subcategoryId", "==", subcategoryId)
13025
+ where29("isActive", "==", true),
13026
+ where29("subcategoryId", "==", subcategoryId)
12855
13027
  );
12856
- const snapshot = await getDocs27(q);
13028
+ const snapshot = await getDocs29(q);
12857
13029
  return snapshot.docs.map(
12858
- (doc30) => ({
12859
- id: doc30.id,
12860
- ...doc30.data()
13030
+ (doc32) => ({
13031
+ id: doc32.id,
13032
+ ...doc32.data()
12861
13033
  })
12862
13034
  );
12863
13035
  }
@@ -12872,7 +13044,7 @@ var TechnologyService = class extends BaseService {
12872
13044
  ...technology,
12873
13045
  updatedAt: /* @__PURE__ */ new Date()
12874
13046
  };
12875
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13047
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
12876
13048
  await updateDoc29(docRef, updateData);
12877
13049
  return this.getById(technologyId);
12878
13050
  }
@@ -12891,8 +13063,8 @@ var TechnologyService = class extends BaseService {
12891
13063
  * @returns Tehnologija ili null ako ne postoji
12892
13064
  */
12893
13065
  async getById(technologyId) {
12894
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
12895
- const docSnap = await getDoc30(docRef);
13066
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
13067
+ const docSnap = await getDoc32(docRef);
12896
13068
  if (!docSnap.exists()) return null;
12897
13069
  return {
12898
13070
  id: docSnap.id,
@@ -12906,7 +13078,7 @@ var TechnologyService = class extends BaseService {
12906
13078
  * @returns Ažurirana tehnologija sa novim zahtevom
12907
13079
  */
12908
13080
  async addRequirement(technologyId, requirement) {
12909
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13081
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
12910
13082
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
12911
13083
  await updateDoc29(docRef, {
12912
13084
  [requirementType]: arrayUnion8(requirement),
@@ -12921,7 +13093,7 @@ var TechnologyService = class extends BaseService {
12921
13093
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
12922
13094
  */
12923
13095
  async removeRequirement(technologyId, requirement) {
12924
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13096
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
12925
13097
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
12926
13098
  await updateDoc29(docRef, {
12927
13099
  [requirementType]: arrayRemove7(requirement),
@@ -12961,7 +13133,7 @@ var TechnologyService = class extends BaseService {
12961
13133
  * @returns Ažurirana tehnologija
12962
13134
  */
12963
13135
  async addBlockingCondition(technologyId, condition) {
12964
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13136
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
12965
13137
  await updateDoc29(docRef, {
12966
13138
  blockingConditions: arrayUnion8(condition),
12967
13139
  updatedAt: /* @__PURE__ */ new Date()
@@ -12975,7 +13147,7 @@ var TechnologyService = class extends BaseService {
12975
13147
  * @returns Ažurirana tehnologija
12976
13148
  */
12977
13149
  async removeBlockingCondition(technologyId, condition) {
12978
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13150
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
12979
13151
  await updateDoc29(docRef, {
12980
13152
  blockingConditions: arrayRemove7(condition),
12981
13153
  updatedAt: /* @__PURE__ */ new Date()
@@ -12989,7 +13161,7 @@ var TechnologyService = class extends BaseService {
12989
13161
  * @returns Ažurirana tehnologija
12990
13162
  */
12991
13163
  async addContraindication(technologyId, contraindication) {
12992
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13164
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
12993
13165
  await updateDoc29(docRef, {
12994
13166
  contraindications: arrayUnion8(contraindication),
12995
13167
  updatedAt: /* @__PURE__ */ new Date()
@@ -13003,7 +13175,7 @@ var TechnologyService = class extends BaseService {
13003
13175
  * @returns Ažurirana tehnologija
13004
13176
  */
13005
13177
  async removeContraindication(technologyId, contraindication) {
13006
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13178
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
13007
13179
  await updateDoc29(docRef, {
13008
13180
  contraindications: arrayRemove7(contraindication),
13009
13181
  updatedAt: /* @__PURE__ */ new Date()
@@ -13017,7 +13189,7 @@ var TechnologyService = class extends BaseService {
13017
13189
  * @returns Ažurirana tehnologija
13018
13190
  */
13019
13191
  async addBenefit(technologyId, benefit) {
13020
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13192
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
13021
13193
  await updateDoc29(docRef, {
13022
13194
  benefits: arrayUnion8(benefit),
13023
13195
  updatedAt: /* @__PURE__ */ new Date()
@@ -13031,7 +13203,7 @@ var TechnologyService = class extends BaseService {
13031
13203
  * @returns Ažurirana tehnologija
13032
13204
  */
13033
13205
  async removeBenefit(technologyId, benefit) {
13034
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13206
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
13035
13207
  await updateDoc29(docRef, {
13036
13208
  benefits: arrayRemove7(benefit),
13037
13209
  updatedAt: /* @__PURE__ */ new Date()
@@ -13072,7 +13244,7 @@ var TechnologyService = class extends BaseService {
13072
13244
  * @returns Ažurirana tehnologija
13073
13245
  */
13074
13246
  async updateCertificationRequirement(technologyId, certificationRequirement) {
13075
- const docRef = doc28(this.getTechnologiesRef(), technologyId);
13247
+ const docRef = doc30(this.getTechnologiesRef(), technologyId);
13076
13248
  await updateDoc29(docRef, {
13077
13249
  certificationRequirement,
13078
13250
  updatedAt: /* @__PURE__ */ new Date()
@@ -13175,13 +13347,13 @@ var TechnologyService = class extends BaseService {
13175
13347
  // src/backoffice/services/product.service.ts
13176
13348
  import {
13177
13349
  addDoc as addDoc7,
13178
- collection as collection28,
13179
- doc as doc29,
13180
- getDoc as getDoc31,
13181
- getDocs as getDocs28,
13182
- query as query28,
13350
+ collection as collection30,
13351
+ doc as doc31,
13352
+ getDoc as getDoc33,
13353
+ getDocs as getDocs30,
13354
+ query as query30,
13183
13355
  updateDoc as updateDoc30,
13184
- where as where28
13356
+ where as where30
13185
13357
  } from "firebase/firestore";
13186
13358
 
13187
13359
  // src/backoffice/types/product.types.ts
@@ -13195,7 +13367,7 @@ var ProductService = class extends BaseService {
13195
13367
  * @returns Firestore collection reference
13196
13368
  */
13197
13369
  getProductsRef(technologyId) {
13198
- return collection28(
13370
+ return collection30(
13199
13371
  this.db,
13200
13372
  TECHNOLOGIES_COLLECTION,
13201
13373
  technologyId,
@@ -13225,15 +13397,15 @@ var ProductService = class extends BaseService {
13225
13397
  * Gets all products for a technology
13226
13398
  */
13227
13399
  async getAllByTechnology(technologyId) {
13228
- const q = query28(
13400
+ const q = query30(
13229
13401
  this.getProductsRef(technologyId),
13230
- where28("isActive", "==", true)
13402
+ where30("isActive", "==", true)
13231
13403
  );
13232
- const snapshot = await getDocs28(q);
13404
+ const snapshot = await getDocs30(q);
13233
13405
  return snapshot.docs.map(
13234
- (doc30) => ({
13235
- id: doc30.id,
13236
- ...doc30.data()
13406
+ (doc32) => ({
13407
+ id: doc32.id,
13408
+ ...doc32.data()
13237
13409
  })
13238
13410
  );
13239
13411
  }
@@ -13241,21 +13413,21 @@ var ProductService = class extends BaseService {
13241
13413
  * Gets all products for a brand by filtering through all technologies
13242
13414
  */
13243
13415
  async getAllByBrand(brandId) {
13244
- const allTechnologiesRef = collection28(this.db, TECHNOLOGIES_COLLECTION);
13245
- const technologiesSnapshot = await getDocs28(allTechnologiesRef);
13416
+ const allTechnologiesRef = collection30(this.db, TECHNOLOGIES_COLLECTION);
13417
+ const technologiesSnapshot = await getDocs30(allTechnologiesRef);
13246
13418
  const products = [];
13247
13419
  for (const techDoc of technologiesSnapshot.docs) {
13248
- const q = query28(
13420
+ const q = query30(
13249
13421
  this.getProductsRef(techDoc.id),
13250
- where28("brandId", "==", brandId),
13251
- where28("isActive", "==", true)
13422
+ where30("brandId", "==", brandId),
13423
+ where30("isActive", "==", true)
13252
13424
  );
13253
- const snapshot = await getDocs28(q);
13425
+ const snapshot = await getDocs30(q);
13254
13426
  products.push(
13255
13427
  ...snapshot.docs.map(
13256
- (doc30) => ({
13257
- id: doc30.id,
13258
- ...doc30.data()
13428
+ (doc32) => ({
13429
+ id: doc32.id,
13430
+ ...doc32.data()
13259
13431
  })
13260
13432
  )
13261
13433
  );
@@ -13270,7 +13442,7 @@ var ProductService = class extends BaseService {
13270
13442
  ...product,
13271
13443
  updatedAt: /* @__PURE__ */ new Date()
13272
13444
  };
13273
- const docRef = doc29(this.getProductsRef(technologyId), productId);
13445
+ const docRef = doc31(this.getProductsRef(technologyId), productId);
13274
13446
  await updateDoc30(docRef, updateData);
13275
13447
  return this.getById(technologyId, productId);
13276
13448
  }
@@ -13286,8 +13458,8 @@ var ProductService = class extends BaseService {
13286
13458
  * Gets a product by ID
13287
13459
  */
13288
13460
  async getById(technologyId, productId) {
13289
- const docRef = doc29(this.getProductsRef(technologyId), productId);
13290
- const docSnap = await getDoc31(docRef);
13461
+ const docRef = doc31(this.getProductsRef(technologyId), productId);
13462
+ const docSnap = await getDoc33(docRef);
13291
13463
  if (!docSnap.exists()) return null;
13292
13464
  return {
13293
13465
  id: docSnap.id,