@blackcode_sa/metaestetics-api 1.5.3 → 1.5.6

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.
Files changed (32) hide show
  1. package/dist/backoffice/index.d.mts +1306 -63
  2. package/dist/backoffice/index.d.ts +1306 -63
  3. package/dist/backoffice/index.js +35 -26
  4. package/dist/backoffice/index.mjs +35 -26
  5. package/dist/index.d.mts +165 -8
  6. package/dist/index.d.ts +165 -8
  7. package/dist/index.js +726 -414
  8. package/dist/index.mjs +772 -451
  9. package/package.json +1 -1
  10. package/src/backoffice/services/brand.service.ts +2 -4
  11. package/src/backoffice/services/category.service.ts +2 -7
  12. package/src/backoffice/services/product.service.ts +5 -7
  13. package/src/backoffice/services/requirement.service.ts +6 -7
  14. package/src/backoffice/services/subcategory.service.ts +11 -8
  15. package/src/backoffice/services/technology.service.ts +6 -11
  16. package/src/backoffice/types/brand.types.ts +5 -0
  17. package/src/backoffice/types/category.types.ts +5 -0
  18. package/src/backoffice/types/documentation-templates.types.ts +4 -0
  19. package/src/backoffice/types/product.types.ts +5 -0
  20. package/src/backoffice/types/requirement.types.ts +5 -0
  21. package/src/backoffice/types/subcategory.types.ts +5 -0
  22. package/src/backoffice/types/technology.types.ts +10 -0
  23. package/src/backoffice/validations/schemas.ts +2 -0
  24. package/src/errors/auth.errors.ts +7 -0
  25. package/src/index.ts +59 -70
  26. package/src/services/auth.service.ts +94 -0
  27. package/src/services/clinic/clinic.service.ts +6 -0
  28. package/src/services/documentation-templates/documentation-template.service.ts +4 -1
  29. package/src/services/procedure/procedure.service.ts +238 -0
  30. package/src/types/documentation-templates/index.ts +5 -0
  31. package/src/types/procedure/index.ts +104 -0
  32. package/src/validations/procedure.schema.ts +58 -0
package/dist/index.mjs CHANGED
@@ -454,6 +454,12 @@ var AUTH_ERRORS = {
454
454
  "AUTH/INVALID_CREDENTIAL",
455
455
  401
456
456
  ),
457
+ // Resource not found
458
+ NOT_FOUND: new AuthError(
459
+ "The requested resource was not found",
460
+ "AUTH/NOT_FOUND",
461
+ 404
462
+ ),
457
463
  // Detailed password validation errors
458
464
  PASSWORD_LENGTH_ERROR: new AuthError(
459
465
  "Password must be at least 8 characters long",
@@ -1304,9 +1310,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
1304
1310
  var updateAllergyUtil = async (db, patientId, data, userRef) => {
1305
1311
  const validatedData = updateAllergySchema.parse(data);
1306
1312
  const { allergyIndex, ...updateData } = validatedData;
1307
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1308
- if (!doc20.exists()) throw new Error("Medical info not found");
1309
- const medicalInfo = doc20.data();
1313
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1314
+ if (!doc21.exists()) throw new Error("Medical info not found");
1315
+ const medicalInfo = doc21.data();
1310
1316
  if (allergyIndex >= medicalInfo.allergies.length) {
1311
1317
  throw new Error("Invalid allergy index");
1312
1318
  }
@@ -1322,9 +1328,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
1322
1328
  });
1323
1329
  };
1324
1330
  var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
1325
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1326
- if (!doc20.exists()) throw new Error("Medical info not found");
1327
- const medicalInfo = doc20.data();
1331
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1332
+ if (!doc21.exists()) throw new Error("Medical info not found");
1333
+ const medicalInfo = doc21.data();
1328
1334
  if (allergyIndex >= medicalInfo.allergies.length) {
1329
1335
  throw new Error("Invalid allergy index");
1330
1336
  }
@@ -1349,9 +1355,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
1349
1355
  var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1350
1356
  const validatedData = updateBlockingConditionSchema.parse(data);
1351
1357
  const { conditionIndex, ...updateData } = validatedData;
1352
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1353
- if (!doc20.exists()) throw new Error("Medical info not found");
1354
- const medicalInfo = doc20.data();
1358
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1359
+ if (!doc21.exists()) throw new Error("Medical info not found");
1360
+ const medicalInfo = doc21.data();
1355
1361
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1356
1362
  throw new Error("Invalid blocking condition index");
1357
1363
  }
@@ -1367,9 +1373,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1367
1373
  });
1368
1374
  };
1369
1375
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
1370
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1371
- if (!doc20.exists()) throw new Error("Medical info not found");
1372
- const medicalInfo = doc20.data();
1376
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1377
+ if (!doc21.exists()) throw new Error("Medical info not found");
1378
+ const medicalInfo = doc21.data();
1373
1379
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1374
1380
  throw new Error("Invalid blocking condition index");
1375
1381
  }
@@ -1394,9 +1400,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
1394
1400
  var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1395
1401
  const validatedData = updateContraindicationSchema.parse(data);
1396
1402
  const { contraindicationIndex, ...updateData } = validatedData;
1397
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1398
- if (!doc20.exists()) throw new Error("Medical info not found");
1399
- const medicalInfo = doc20.data();
1403
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1404
+ if (!doc21.exists()) throw new Error("Medical info not found");
1405
+ const medicalInfo = doc21.data();
1400
1406
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1401
1407
  throw new Error("Invalid contraindication index");
1402
1408
  }
@@ -1412,9 +1418,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1412
1418
  });
1413
1419
  };
1414
1420
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
1415
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1416
- if (!doc20.exists()) throw new Error("Medical info not found");
1417
- const medicalInfo = doc20.data();
1421
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1422
+ if (!doc21.exists()) throw new Error("Medical info not found");
1423
+ const medicalInfo = doc21.data();
1418
1424
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1419
1425
  throw new Error("Invalid contraindication index");
1420
1426
  }
@@ -1439,9 +1445,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
1439
1445
  var updateMedicationUtil = async (db, patientId, data, userRef) => {
1440
1446
  const validatedData = updateMedicationSchema.parse(data);
1441
1447
  const { medicationIndex, ...updateData } = validatedData;
1442
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1443
- if (!doc20.exists()) throw new Error("Medical info not found");
1444
- const medicalInfo = doc20.data();
1448
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1449
+ if (!doc21.exists()) throw new Error("Medical info not found");
1450
+ const medicalInfo = doc21.data();
1445
1451
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1446
1452
  throw new Error("Invalid medication index");
1447
1453
  }
@@ -1457,9 +1463,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
1457
1463
  });
1458
1464
  };
1459
1465
  var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
1460
- const doc20 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1461
- if (!doc20.exists()) throw new Error("Medical info not found");
1462
- const medicalInfo = doc20.data();
1466
+ const doc21 = await getDoc3(getMedicalInfoDocRef(db, patientId));
1467
+ if (!doc21.exists()) throw new Error("Medical info not found");
1468
+ const medicalInfo = doc21.data();
1463
1469
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1464
1470
  throw new Error("Invalid medication index");
1465
1471
  }
@@ -2776,7 +2782,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
2776
2782
  where2("clinicGroupId", "==", clinicGroupId)
2777
2783
  );
2778
2784
  const querySnapshot = await getDocs2(q);
2779
- return querySnapshot.docs.map((doc20) => doc20.data());
2785
+ return querySnapshot.docs.map((doc21) => doc21.data());
2780
2786
  }
2781
2787
  async function updateClinicAdmin(db, adminId, data) {
2782
2788
  const admin = await getClinicAdmin(db, adminId);
@@ -3443,7 +3449,7 @@ var PractitionerService = class extends BaseService {
3443
3449
  where3("expiresAt", ">", Timestamp8.now())
3444
3450
  );
3445
3451
  const querySnapshot = await getDocs3(q);
3446
- return querySnapshot.docs.map((doc20) => doc20.data());
3452
+ return querySnapshot.docs.map((doc21) => doc21.data());
3447
3453
  }
3448
3454
  /**
3449
3455
  * Gets a token by its string value and validates it
@@ -3526,7 +3532,7 @@ var PractitionerService = class extends BaseService {
3526
3532
  where3("status", "==", "active" /* ACTIVE */)
3527
3533
  );
3528
3534
  const querySnapshot = await getDocs3(q);
3529
- return querySnapshot.docs.map((doc20) => doc20.data());
3535
+ return querySnapshot.docs.map((doc21) => doc21.data());
3530
3536
  }
3531
3537
  /**
3532
3538
  * Dohvata sve draft zdravstvene radnike za određenu kliniku
@@ -3538,7 +3544,7 @@ var PractitionerService = class extends BaseService {
3538
3544
  where3("status", "==", "draft" /* DRAFT */)
3539
3545
  );
3540
3546
  const querySnapshot = await getDocs3(q);
3541
- return querySnapshot.docs.map((doc20) => doc20.data());
3547
+ return querySnapshot.docs.map((doc21) => doc21.data());
3542
3548
  }
3543
3549
  /**
3544
3550
  * Ažurira profil zdravstvenog radnika
@@ -3847,7 +3853,7 @@ var UserService = class extends BaseService {
3847
3853
  ];
3848
3854
  const q = query4(collection4(this.db, USERS_COLLECTION), ...constraints);
3849
3855
  const querySnapshot = await getDocs4(q);
3850
- const users = querySnapshot.docs.map((doc20) => doc20.data());
3856
+ const users = querySnapshot.docs.map((doc21) => doc21.data());
3851
3857
  return Promise.all(users.map((userData) => userSchema.parse(userData)));
3852
3858
  }
3853
3859
  /**
@@ -4227,7 +4233,7 @@ async function getAllActiveGroups(db) {
4227
4233
  where5("isActive", "==", true)
4228
4234
  );
4229
4235
  const querySnapshot = await getDocs5(q);
4230
- return querySnapshot.docs.map((doc20) => doc20.data());
4236
+ return querySnapshot.docs.map((doc21) => doc21.data());
4231
4237
  }
4232
4238
  async function updateClinicGroup(db, groupId, data, app) {
4233
4239
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -4897,7 +4903,7 @@ async function getClinicsByGroup(db, groupId) {
4897
4903
  where6("isActive", "==", true)
4898
4904
  );
4899
4905
  const querySnapshot = await getDocs6(q);
4900
- return querySnapshot.docs.map((doc20) => doc20.data());
4906
+ return querySnapshot.docs.map((doc21) => doc21.data());
4901
4907
  }
4902
4908
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
4903
4909
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -5109,7 +5115,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
5109
5115
  }
5110
5116
  const q = query6(collection6(db, CLINICS_COLLECTION), ...constraints);
5111
5117
  const querySnapshot = await getDocs6(q);
5112
- return querySnapshot.docs.map((doc20) => doc20.data());
5118
+ return querySnapshot.docs.map((doc21) => doc21.data());
5113
5119
  }
5114
5120
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
5115
5121
  return getClinicsByAdmin(
@@ -5262,8 +5268,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5262
5268
  }
5263
5269
  const q = query7(collection8(db, CLINICS_COLLECTION), ...constraints);
5264
5270
  const querySnapshot = await getDocs7(q);
5265
- for (const doc20 of querySnapshot.docs) {
5266
- const clinic = doc20.data();
5271
+ for (const doc21 of querySnapshot.docs) {
5272
+ const clinic = doc21.data();
5267
5273
  const distance = distanceBetween(
5268
5274
  [center.latitude, center.longitude],
5269
5275
  [clinic.location.latitude, clinic.location.longitude]
@@ -5800,6 +5806,77 @@ var AuthService = class extends BaseService {
5800
5806
  );
5801
5807
  return this.userService.getOrCreateUser(firebaseUser);
5802
5808
  }
5809
+ /**
5810
+ * Prijavljuje korisnika sa email-om i lozinkom samo za clinic_admin role
5811
+ * @param email - Email korisnika
5812
+ * @param password - Lozinka korisnika
5813
+ * @returns Objekat koji sadrži korisnika, admin profil i grupu klinika
5814
+ * @throws {AUTH_ERRORS.INVALID_ROLE} Ako korisnik nema clinic_admin rolu
5815
+ * @throws {AUTH_ERRORS.NOT_FOUND} Ako admin profil nije pronađen
5816
+ */
5817
+ async signInClinicAdmin(email, password) {
5818
+ var _a;
5819
+ try {
5820
+ const clinicAdminService = new ClinicAdminService(
5821
+ this.db,
5822
+ this.auth,
5823
+ this.app
5824
+ );
5825
+ const clinicGroupService = new ClinicGroupService(
5826
+ this.db,
5827
+ this.auth,
5828
+ this.app,
5829
+ clinicAdminService
5830
+ );
5831
+ const clinicService = new ClinicService(
5832
+ this.db,
5833
+ this.auth,
5834
+ this.app,
5835
+ clinicGroupService,
5836
+ clinicAdminService
5837
+ );
5838
+ clinicAdminService.setServices(clinicGroupService, clinicService);
5839
+ const { user: firebaseUser } = await signInWithEmailAndPassword(
5840
+ this.auth,
5841
+ email,
5842
+ password
5843
+ );
5844
+ const user = await this.userService.getOrCreateUser(firebaseUser);
5845
+ if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
5846
+ console.error("[AUTH] User is not a clinic admin:", user.uid);
5847
+ throw AUTH_ERRORS.INVALID_ROLE;
5848
+ }
5849
+ if (!user.adminProfile) {
5850
+ console.error("[AUTH] User has no admin profile:", user.uid);
5851
+ throw AUTH_ERRORS.NOT_FOUND;
5852
+ }
5853
+ const adminProfile = await clinicAdminService.getClinicAdmin(
5854
+ user.adminProfile
5855
+ );
5856
+ if (!adminProfile) {
5857
+ console.error("[AUTH] Admin profile not found:", user.adminProfile);
5858
+ throw AUTH_ERRORS.NOT_FOUND;
5859
+ }
5860
+ const clinicGroup = await clinicGroupService.getClinicGroup(
5861
+ adminProfile.clinicGroupId
5862
+ );
5863
+ if (!clinicGroup) {
5864
+ console.error(
5865
+ "[AUTH] Clinic group not found:",
5866
+ adminProfile.clinicGroupId
5867
+ );
5868
+ throw AUTH_ERRORS.NOT_FOUND;
5869
+ }
5870
+ return {
5871
+ user,
5872
+ clinicAdmin: adminProfile,
5873
+ clinicGroup
5874
+ };
5875
+ } catch (error) {
5876
+ console.error("[AUTH] Error in signInClinicAdmin:", error);
5877
+ throw error;
5878
+ }
5879
+ }
5803
5880
  /**
5804
5881
  * Prijavljuje korisnika sa Facebook-om
5805
5882
  */
@@ -6137,9 +6214,9 @@ var NotificationService = class extends BaseService {
6137
6214
  orderBy("notificationTime", "desc")
6138
6215
  );
6139
6216
  const querySnapshot = await getDocs9(q);
6140
- return querySnapshot.docs.map((doc20) => ({
6141
- id: doc20.id,
6142
- ...doc20.data()
6217
+ return querySnapshot.docs.map((doc21) => ({
6218
+ id: doc21.id,
6219
+ ...doc21.data()
6143
6220
  }));
6144
6221
  }
6145
6222
  /**
@@ -6153,9 +6230,9 @@ var NotificationService = class extends BaseService {
6153
6230
  orderBy("notificationTime", "desc")
6154
6231
  );
6155
6232
  const querySnapshot = await getDocs9(q);
6156
- return querySnapshot.docs.map((doc20) => ({
6157
- id: doc20.id,
6158
- ...doc20.data()
6233
+ return querySnapshot.docs.map((doc21) => ({
6234
+ id: doc21.id,
6235
+ ...doc21.data()
6159
6236
  }));
6160
6237
  }
6161
6238
  /**
@@ -6227,9 +6304,9 @@ var NotificationService = class extends BaseService {
6227
6304
  orderBy("notificationTime", "desc")
6228
6305
  );
6229
6306
  const querySnapshot = await getDocs9(q);
6230
- return querySnapshot.docs.map((doc20) => ({
6231
- id: doc20.id,
6232
- ...doc20.data()
6307
+ return querySnapshot.docs.map((doc21) => ({
6308
+ id: doc21.id,
6309
+ ...doc21.data()
6233
6310
  }));
6234
6311
  }
6235
6312
  /**
@@ -6242,24 +6319,267 @@ var NotificationService = class extends BaseService {
6242
6319
  orderBy("notificationTime", "desc")
6243
6320
  );
6244
6321
  const querySnapshot = await getDocs9(q);
6245
- return querySnapshot.docs.map((doc20) => ({
6246
- id: doc20.id,
6247
- ...doc20.data()
6322
+ return querySnapshot.docs.map((doc21) => ({
6323
+ id: doc21.id,
6324
+ ...doc21.data()
6248
6325
  }));
6249
6326
  }
6250
6327
  };
6251
6328
 
6252
- // src/services/documentation-templates/documentation-template.service.ts
6329
+ // src/services/procedure/procedure.service.ts
6253
6330
  import {
6254
6331
  collection as collection11,
6255
6332
  doc as doc12,
6256
6333
  getDoc as getDoc16,
6257
6334
  getDocs as getDocs10,
6258
- setDoc as setDoc13,
6259
- updateDoc as updateDoc14,
6260
- deleteDoc as deleteDoc7,
6261
6335
  query as query10,
6262
6336
  where as where10,
6337
+ updateDoc as updateDoc14,
6338
+ setDoc as setDoc13,
6339
+ serverTimestamp as serverTimestamp13
6340
+ } from "firebase/firestore";
6341
+
6342
+ // src/types/procedure/index.ts
6343
+ var PROCEDURES_COLLECTION = "procedures";
6344
+
6345
+ // src/validations/procedure.schema.ts
6346
+ import { z as z16 } from "zod";
6347
+ var createProcedureSchema = z16.object({
6348
+ name: z16.string().min(1).max(200),
6349
+ description: z16.string().min(1).max(2e3),
6350
+ family: z16.nativeEnum(ProcedureFamily),
6351
+ categoryId: z16.string().min(1),
6352
+ subcategoryId: z16.string().min(1),
6353
+ technologyId: z16.string().min(1),
6354
+ productId: z16.string().min(1),
6355
+ price: z16.number().min(0),
6356
+ currency: z16.nativeEnum(Currency),
6357
+ pricingMeasure: z16.nativeEnum(PricingMeasure),
6358
+ duration: z16.number().min(1).max(480),
6359
+ // Max 8 hours
6360
+ practitionerId: z16.string().min(1),
6361
+ clinicBranchId: z16.string().min(1)
6362
+ });
6363
+ var updateProcedureSchema = z16.object({
6364
+ name: z16.string().min(1).max(200).optional(),
6365
+ description: z16.string().min(1).max(2e3).optional(),
6366
+ price: z16.number().min(0).optional(),
6367
+ currency: z16.nativeEnum(Currency).optional(),
6368
+ pricingMeasure: z16.nativeEnum(PricingMeasure).optional(),
6369
+ duration: z16.number().min(1).max(480).optional(),
6370
+ // Max 8 hours
6371
+ isActive: z16.boolean().optional()
6372
+ });
6373
+ var procedureSchema = createProcedureSchema.extend({
6374
+ id: z16.string().min(1),
6375
+ category: z16.any(),
6376
+ // We'll validate the full category object separately
6377
+ subcategory: z16.any(),
6378
+ // We'll validate the full subcategory object separately
6379
+ technology: z16.any(),
6380
+ // We'll validate the full technology object separately
6381
+ product: z16.any(),
6382
+ // We'll validate the full product object separately
6383
+ blockingConditions: z16.array(z16.any()),
6384
+ // We'll validate blocking conditions separately
6385
+ treatmentBenefits: z16.array(z16.any()),
6386
+ // We'll validate treatment benefits separately
6387
+ preRequirements: z16.array(z16.any()),
6388
+ // We'll validate requirements separately
6389
+ postRequirements: z16.array(z16.any()),
6390
+ // We'll validate requirements separately
6391
+ certificationRequirement: z16.any(),
6392
+ // We'll validate certification requirement separately
6393
+ documentationTemplates: z16.array(z16.any()),
6394
+ // We'll validate documentation templates separately
6395
+ isActive: z16.boolean(),
6396
+ createdAt: z16.date(),
6397
+ updatedAt: z16.date()
6398
+ });
6399
+
6400
+ // src/backoffice/types/category.types.ts
6401
+ var CATEGORIES_COLLECTION = "backoffice_categories";
6402
+
6403
+ // src/backoffice/types/subcategory.types.ts
6404
+ var SUBCATEGORIES_COLLECTION = "subcategories";
6405
+
6406
+ // src/backoffice/types/technology.types.ts
6407
+ var TECHNOLOGIES_COLLECTION = "technologies";
6408
+
6409
+ // src/backoffice/types/product.types.ts
6410
+ var PRODUCTS_COLLECTION = "products";
6411
+
6412
+ // src/services/procedure/procedure.service.ts
6413
+ var ProcedureService = class extends BaseService {
6414
+ constructor(db, auth, app) {
6415
+ super(db, auth, app);
6416
+ }
6417
+ /**
6418
+ * Creates a new procedure
6419
+ * @param data - The data for creating a new procedure
6420
+ * @returns The created procedure
6421
+ */
6422
+ async createProcedure(data) {
6423
+ const validatedData = createProcedureSchema.parse(data);
6424
+ const [category, subcategory, technology, product] = await Promise.all([
6425
+ this.getCategory(validatedData.categoryId),
6426
+ this.getSubcategory(validatedData.subcategoryId),
6427
+ this.getTechnology(validatedData.technologyId),
6428
+ this.getProduct(validatedData.productId)
6429
+ ]);
6430
+ if (!category || !subcategory || !technology || !product) {
6431
+ throw new Error("One or more required entities not found");
6432
+ }
6433
+ const procedure = {
6434
+ ...validatedData,
6435
+ category,
6436
+ subcategory,
6437
+ technology,
6438
+ product,
6439
+ blockingConditions: technology.blockingConditions,
6440
+ treatmentBenefits: technology.benefits,
6441
+ preRequirements: technology.requirements.pre,
6442
+ postRequirements: technology.requirements.post,
6443
+ certificationRequirement: technology.certificationRequirement,
6444
+ documentationTemplates: technology.documentationTemplates || [],
6445
+ isActive: true,
6446
+ createdAt: /* @__PURE__ */ new Date(),
6447
+ updatedAt: /* @__PURE__ */ new Date()
6448
+ };
6449
+ const id = this.generateId();
6450
+ const docRef = doc12(this.db, PROCEDURES_COLLECTION, id);
6451
+ await setDoc13(docRef, {
6452
+ ...procedure,
6453
+ id,
6454
+ createdAt: serverTimestamp13(),
6455
+ updatedAt: serverTimestamp13()
6456
+ });
6457
+ return { ...procedure, id };
6458
+ }
6459
+ /**
6460
+ * Gets a procedure by ID
6461
+ * @param id - The ID of the procedure to get
6462
+ * @returns The procedure if found, null otherwise
6463
+ */
6464
+ async getProcedure(id) {
6465
+ const docRef = doc12(this.db, PROCEDURES_COLLECTION, id);
6466
+ const docSnap = await getDoc16(docRef);
6467
+ if (!docSnap.exists()) {
6468
+ return null;
6469
+ }
6470
+ return docSnap.data();
6471
+ }
6472
+ /**
6473
+ * Gets all procedures for a clinic branch
6474
+ * @param clinicBranchId - The ID of the clinic branch
6475
+ * @returns List of procedures
6476
+ */
6477
+ async getProceduresByClinicBranch(clinicBranchId) {
6478
+ const q = query10(
6479
+ collection11(this.db, PROCEDURES_COLLECTION),
6480
+ where10("clinicBranchId", "==", clinicBranchId),
6481
+ where10("isActive", "==", true)
6482
+ );
6483
+ const snapshot = await getDocs10(q);
6484
+ return snapshot.docs.map((doc21) => doc21.data());
6485
+ }
6486
+ /**
6487
+ * Gets all procedures for a practitioner
6488
+ * @param practitionerId - The ID of the practitioner
6489
+ * @returns List of procedures
6490
+ */
6491
+ async getProceduresByPractitioner(practitionerId) {
6492
+ const q = query10(
6493
+ collection11(this.db, PROCEDURES_COLLECTION),
6494
+ where10("practitionerId", "==", practitionerId),
6495
+ where10("isActive", "==", true)
6496
+ );
6497
+ const snapshot = await getDocs10(q);
6498
+ return snapshot.docs.map((doc21) => doc21.data());
6499
+ }
6500
+ /**
6501
+ * Updates a procedure
6502
+ * @param id - The ID of the procedure to update
6503
+ * @param data - The data to update
6504
+ * @returns The updated procedure
6505
+ */
6506
+ async updateProcedure(id, data) {
6507
+ const validatedData = updateProcedureSchema.parse(data);
6508
+ const existingProcedure = await this.getProcedure(id);
6509
+ if (!existingProcedure) {
6510
+ throw new Error(`Procedure with ID ${id} not found`);
6511
+ }
6512
+ const docRef = doc12(this.db, PROCEDURES_COLLECTION, id);
6513
+ await updateDoc14(docRef, {
6514
+ ...validatedData,
6515
+ updatedAt: serverTimestamp13()
6516
+ });
6517
+ return {
6518
+ ...existingProcedure,
6519
+ ...validatedData,
6520
+ updatedAt: /* @__PURE__ */ new Date()
6521
+ };
6522
+ }
6523
+ /**
6524
+ * Deactivates a procedure
6525
+ * @param id - The ID of the procedure to deactivate
6526
+ */
6527
+ async deactivateProcedure(id) {
6528
+ const docRef = doc12(this.db, PROCEDURES_COLLECTION, id);
6529
+ await updateDoc14(docRef, {
6530
+ isActive: false,
6531
+ updatedAt: serverTimestamp13()
6532
+ });
6533
+ }
6534
+ /**
6535
+ * Gets a category by ID
6536
+ * @private
6537
+ */
6538
+ async getCategory(id) {
6539
+ const docRef = doc12(this.db, CATEGORIES_COLLECTION, id);
6540
+ const docSnap = await getDoc16(docRef);
6541
+ return docSnap.exists() ? docSnap.data() : null;
6542
+ }
6543
+ /**
6544
+ * Gets a subcategory by ID
6545
+ * @private
6546
+ */
6547
+ async getSubcategory(id) {
6548
+ const docRef = doc12(this.db, SUBCATEGORIES_COLLECTION, id);
6549
+ const docSnap = await getDoc16(docRef);
6550
+ return docSnap.exists() ? docSnap.data() : null;
6551
+ }
6552
+ /**
6553
+ * Gets a technology by ID
6554
+ * @private
6555
+ */
6556
+ async getTechnology(id) {
6557
+ const docRef = doc12(this.db, TECHNOLOGIES_COLLECTION, id);
6558
+ const docSnap = await getDoc16(docRef);
6559
+ return docSnap.exists() ? docSnap.data() : null;
6560
+ }
6561
+ /**
6562
+ * Gets a product by ID
6563
+ * @private
6564
+ */
6565
+ async getProduct(id) {
6566
+ const docRef = doc12(this.db, PRODUCTS_COLLECTION, id);
6567
+ const docSnap = await getDoc16(docRef);
6568
+ return docSnap.exists() ? docSnap.data() : null;
6569
+ }
6570
+ };
6571
+
6572
+ // src/services/documentation-templates/documentation-template.service.ts
6573
+ import {
6574
+ collection as collection12,
6575
+ doc as doc13,
6576
+ getDoc as getDoc17,
6577
+ getDocs as getDocs11,
6578
+ setDoc as setDoc14,
6579
+ updateDoc as updateDoc15,
6580
+ deleteDoc as deleteDoc8,
6581
+ query as query11,
6582
+ where as where11,
6263
6583
  orderBy as orderBy2,
6264
6584
  limit,
6265
6585
  startAfter
@@ -6267,7 +6587,7 @@ import {
6267
6587
  var DocumentationTemplateService = class extends BaseService {
6268
6588
  constructor() {
6269
6589
  super(...arguments);
6270
- this.collectionRef = collection11(
6590
+ this.collectionRef = collection12(
6271
6591
  this.db,
6272
6592
  DOCUMENTATION_TEMPLATES_COLLECTION
6273
6593
  );
@@ -6298,8 +6618,8 @@ var DocumentationTemplateService = class extends BaseService {
6298
6618
  isActive: true,
6299
6619
  tags: validatedData.tags || []
6300
6620
  };
6301
- const docRef = doc12(this.collectionRef, templateId);
6302
- await setDoc13(docRef, template);
6621
+ const docRef = doc13(this.collectionRef, templateId);
6622
+ await setDoc14(docRef, template);
6303
6623
  return template;
6304
6624
  }
6305
6625
  /**
@@ -6308,8 +6628,8 @@ var DocumentationTemplateService = class extends BaseService {
6308
6628
  * @returns The template or null if not found
6309
6629
  */
6310
6630
  async getTemplateById(templateId) {
6311
- const docRef = doc12(this.collectionRef, templateId);
6312
- const docSnap = await getDoc16(docRef);
6631
+ const docRef = doc13(this.collectionRef, templateId);
6632
+ const docSnap = await getDoc17(docRef);
6313
6633
  if (!docSnap.exists()) {
6314
6634
  return null;
6315
6635
  }
@@ -6340,8 +6660,8 @@ var DocumentationTemplateService = class extends BaseService {
6340
6660
  updatedAt: Date.now(),
6341
6661
  version: template.version + 1
6342
6662
  };
6343
- const docRef = doc12(this.collectionRef, templateId);
6344
- await updateDoc14(docRef, updateData);
6663
+ const docRef = doc13(this.collectionRef, templateId);
6664
+ await updateDoc15(docRef, updateData);
6345
6665
  return {
6346
6666
  ...template,
6347
6667
  ...updateData
@@ -6352,8 +6672,8 @@ var DocumentationTemplateService = class extends BaseService {
6352
6672
  * @param templateId - ID of the template to delete
6353
6673
  */
6354
6674
  async deleteTemplate(templateId) {
6355
- const docRef = doc12(this.collectionRef, templateId);
6356
- await deleteDoc7(docRef);
6675
+ const docRef = doc13(this.collectionRef, templateId);
6676
+ await deleteDoc8(docRef);
6357
6677
  }
6358
6678
  /**
6359
6679
  * Get all active templates
@@ -6362,21 +6682,21 @@ var DocumentationTemplateService = class extends BaseService {
6362
6682
  * @returns Array of templates and the last document for pagination
6363
6683
  */
6364
6684
  async getActiveTemplates(pageSize = 20, lastDoc) {
6365
- let q = query10(
6685
+ let q = query11(
6366
6686
  this.collectionRef,
6367
- where10("isActive", "==", true),
6687
+ where11("isActive", "==", true),
6368
6688
  orderBy2("updatedAt", "desc"),
6369
6689
  limit(pageSize)
6370
6690
  );
6371
6691
  if (lastDoc) {
6372
- q = query10(q, startAfter(lastDoc));
6692
+ q = query11(q, startAfter(lastDoc));
6373
6693
  }
6374
- const querySnapshot = await getDocs10(q);
6694
+ const querySnapshot = await getDocs11(q);
6375
6695
  const templates = [];
6376
6696
  let lastVisible = null;
6377
- querySnapshot.forEach((doc20) => {
6378
- templates.push(doc20.data());
6379
- lastVisible = doc20;
6697
+ querySnapshot.forEach((doc21) => {
6698
+ templates.push(doc21.data());
6699
+ lastVisible = doc21;
6380
6700
  });
6381
6701
  return {
6382
6702
  templates,
@@ -6391,22 +6711,22 @@ var DocumentationTemplateService = class extends BaseService {
6391
6711
  * @returns Array of templates and the last document for pagination
6392
6712
  */
6393
6713
  async getTemplatesByTags(tags, pageSize = 20, lastDoc) {
6394
- let q = query10(
6714
+ let q = query11(
6395
6715
  this.collectionRef,
6396
- where10("isActive", "==", true),
6397
- where10("tags", "array-contains-any", tags),
6716
+ where11("isActive", "==", true),
6717
+ where11("tags", "array-contains-any", tags),
6398
6718
  orderBy2("updatedAt", "desc"),
6399
6719
  limit(pageSize)
6400
6720
  );
6401
6721
  if (lastDoc) {
6402
- q = query10(q, startAfter(lastDoc));
6722
+ q = query11(q, startAfter(lastDoc));
6403
6723
  }
6404
- const querySnapshot = await getDocs10(q);
6724
+ const querySnapshot = await getDocs11(q);
6405
6725
  const templates = [];
6406
6726
  let lastVisible = null;
6407
- querySnapshot.forEach((doc20) => {
6408
- templates.push(doc20.data());
6409
- lastVisible = doc20;
6727
+ querySnapshot.forEach((doc21) => {
6728
+ templates.push(doc21.data());
6729
+ lastVisible = doc21;
6410
6730
  });
6411
6731
  return {
6412
6732
  templates,
@@ -6421,21 +6741,21 @@ var DocumentationTemplateService = class extends BaseService {
6421
6741
  * @returns Array of templates and the last document for pagination
6422
6742
  */
6423
6743
  async getTemplatesByCreator(userId, pageSize = 20, lastDoc) {
6424
- let q = query10(
6744
+ let q = query11(
6425
6745
  this.collectionRef,
6426
- where10("createdBy", "==", userId),
6746
+ where11("createdBy", "==", userId),
6427
6747
  orderBy2("updatedAt", "desc"),
6428
6748
  limit(pageSize)
6429
6749
  );
6430
6750
  if (lastDoc) {
6431
- q = query10(q, startAfter(lastDoc));
6751
+ q = query11(q, startAfter(lastDoc));
6432
6752
  }
6433
- const querySnapshot = await getDocs10(q);
6753
+ const querySnapshot = await getDocs11(q);
6434
6754
  const templates = [];
6435
6755
  let lastVisible = null;
6436
- querySnapshot.forEach((doc20) => {
6437
- templates.push(doc20.data());
6438
- lastVisible = doc20;
6756
+ querySnapshot.forEach((doc21) => {
6757
+ templates.push(doc21.data());
6758
+ lastVisible = doc21;
6439
6759
  });
6440
6760
  return {
6441
6761
  templates,
@@ -6446,14 +6766,14 @@ var DocumentationTemplateService = class extends BaseService {
6446
6766
 
6447
6767
  // src/services/documentation-templates/filled-document.service.ts
6448
6768
  import {
6449
- collection as collection12,
6450
- doc as doc13,
6451
- getDoc as getDoc17,
6452
- getDocs as getDocs11,
6453
- setDoc as setDoc14,
6454
- updateDoc as updateDoc15,
6455
- query as query11,
6456
- where as where11,
6769
+ collection as collection13,
6770
+ doc as doc14,
6771
+ getDoc as getDoc18,
6772
+ getDocs as getDocs12,
6773
+ setDoc as setDoc15,
6774
+ updateDoc as updateDoc16,
6775
+ query as query12,
6776
+ where as where12,
6457
6777
  orderBy as orderBy3,
6458
6778
  limit as limit2,
6459
6779
  startAfter as startAfter2
@@ -6461,7 +6781,7 @@ import {
6461
6781
  var FilledDocumentService = class extends BaseService {
6462
6782
  constructor(...args) {
6463
6783
  super(...args);
6464
- this.collectionRef = collection12(
6784
+ this.collectionRef = collection13(
6465
6785
  this.db,
6466
6786
  FILLED_DOCUMENTS_COLLECTION
6467
6787
  );
@@ -6494,8 +6814,8 @@ var FilledDocumentService = class extends BaseService {
6494
6814
  values: {},
6495
6815
  status: "draft" /* DRAFT */
6496
6816
  };
6497
- const docRef = doc13(this.collectionRef, documentId);
6498
- await setDoc14(docRef, filledDocument);
6817
+ const docRef = doc14(this.collectionRef, documentId);
6818
+ await setDoc15(docRef, filledDocument);
6499
6819
  return filledDocument;
6500
6820
  }
6501
6821
  /**
@@ -6504,8 +6824,8 @@ var FilledDocumentService = class extends BaseService {
6504
6824
  * @returns The filled document or null if not found
6505
6825
  */
6506
6826
  async getFilledDocumentById(documentId) {
6507
- const docRef = doc13(this.collectionRef, documentId);
6508
- const docSnap = await getDoc17(docRef);
6827
+ const docRef = doc14(this.collectionRef, documentId);
6828
+ const docSnap = await getDoc18(docRef);
6509
6829
  if (!docSnap.exists()) {
6510
6830
  return null;
6511
6831
  }
@@ -6533,8 +6853,8 @@ var FilledDocumentService = class extends BaseService {
6533
6853
  if (status) {
6534
6854
  updateData.status = status;
6535
6855
  }
6536
- const docRef = doc13(this.collectionRef, documentId);
6537
- await updateDoc15(docRef, updateData);
6856
+ const docRef = doc14(this.collectionRef, documentId);
6857
+ await updateDoc16(docRef, updateData);
6538
6858
  return {
6539
6859
  ...filledDocument,
6540
6860
  ...updateData
@@ -6548,21 +6868,21 @@ var FilledDocumentService = class extends BaseService {
6548
6868
  * @returns Array of filled documents and the last document for pagination
6549
6869
  */
6550
6870
  async getFilledDocumentsByPatient(patientId, pageSize = 20, lastDoc) {
6551
- let q = query11(
6871
+ let q = query12(
6552
6872
  this.collectionRef,
6553
- where11("patientId", "==", patientId),
6873
+ where12("patientId", "==", patientId),
6554
6874
  orderBy3("updatedAt", "desc"),
6555
6875
  limit2(pageSize)
6556
6876
  );
6557
6877
  if (lastDoc) {
6558
- q = query11(q, startAfter2(lastDoc));
6878
+ q = query12(q, startAfter2(lastDoc));
6559
6879
  }
6560
- const querySnapshot = await getDocs11(q);
6880
+ const querySnapshot = await getDocs12(q);
6561
6881
  const documents = [];
6562
6882
  let lastVisible = null;
6563
- querySnapshot.forEach((doc20) => {
6564
- documents.push(doc20.data());
6565
- lastVisible = doc20;
6883
+ querySnapshot.forEach((doc21) => {
6884
+ documents.push(doc21.data());
6885
+ lastVisible = doc21;
6566
6886
  });
6567
6887
  return {
6568
6888
  documents,
@@ -6577,21 +6897,21 @@ var FilledDocumentService = class extends BaseService {
6577
6897
  * @returns Array of filled documents and the last document for pagination
6578
6898
  */
6579
6899
  async getFilledDocumentsByPractitioner(practitionerId, pageSize = 20, lastDoc) {
6580
- let q = query11(
6900
+ let q = query12(
6581
6901
  this.collectionRef,
6582
- where11("practitionerId", "==", practitionerId),
6902
+ where12("practitionerId", "==", practitionerId),
6583
6903
  orderBy3("updatedAt", "desc"),
6584
6904
  limit2(pageSize)
6585
6905
  );
6586
6906
  if (lastDoc) {
6587
- q = query11(q, startAfter2(lastDoc));
6907
+ q = query12(q, startAfter2(lastDoc));
6588
6908
  }
6589
- const querySnapshot = await getDocs11(q);
6909
+ const querySnapshot = await getDocs12(q);
6590
6910
  const documents = [];
6591
6911
  let lastVisible = null;
6592
- querySnapshot.forEach((doc20) => {
6593
- documents.push(doc20.data());
6594
- lastVisible = doc20;
6912
+ querySnapshot.forEach((doc21) => {
6913
+ documents.push(doc21.data());
6914
+ lastVisible = doc21;
6595
6915
  });
6596
6916
  return {
6597
6917
  documents,
@@ -6606,21 +6926,21 @@ var FilledDocumentService = class extends BaseService {
6606
6926
  * @returns Array of filled documents and the last document for pagination
6607
6927
  */
6608
6928
  async getFilledDocumentsByClinic(clinicId, pageSize = 20, lastDoc) {
6609
- let q = query11(
6929
+ let q = query12(
6610
6930
  this.collectionRef,
6611
- where11("clinicId", "==", clinicId),
6931
+ where12("clinicId", "==", clinicId),
6612
6932
  orderBy3("updatedAt", "desc"),
6613
6933
  limit2(pageSize)
6614
6934
  );
6615
6935
  if (lastDoc) {
6616
- q = query11(q, startAfter2(lastDoc));
6936
+ q = query12(q, startAfter2(lastDoc));
6617
6937
  }
6618
- const querySnapshot = await getDocs11(q);
6938
+ const querySnapshot = await getDocs12(q);
6619
6939
  const documents = [];
6620
6940
  let lastVisible = null;
6621
- querySnapshot.forEach((doc20) => {
6622
- documents.push(doc20.data());
6623
- lastVisible = doc20;
6941
+ querySnapshot.forEach((doc21) => {
6942
+ documents.push(doc21.data());
6943
+ lastVisible = doc21;
6624
6944
  });
6625
6945
  return {
6626
6946
  documents,
@@ -6635,21 +6955,21 @@ var FilledDocumentService = class extends BaseService {
6635
6955
  * @returns Array of filled documents and the last document for pagination
6636
6956
  */
6637
6957
  async getFilledDocumentsByTemplate(templateId, pageSize = 20, lastDoc) {
6638
- let q = query11(
6958
+ let q = query12(
6639
6959
  this.collectionRef,
6640
- where11("templateId", "==", templateId),
6960
+ where12("templateId", "==", templateId),
6641
6961
  orderBy3("updatedAt", "desc"),
6642
6962
  limit2(pageSize)
6643
6963
  );
6644
6964
  if (lastDoc) {
6645
- q = query11(q, startAfter2(lastDoc));
6965
+ q = query12(q, startAfter2(lastDoc));
6646
6966
  }
6647
- const querySnapshot = await getDocs11(q);
6967
+ const querySnapshot = await getDocs12(q);
6648
6968
  const documents = [];
6649
6969
  let lastVisible = null;
6650
- querySnapshot.forEach((doc20) => {
6651
- documents.push(doc20.data());
6652
- lastVisible = doc20;
6970
+ querySnapshot.forEach((doc21) => {
6971
+ documents.push(doc21.data());
6972
+ lastVisible = doc21;
6653
6973
  });
6654
6974
  return {
6655
6975
  documents,
@@ -6664,21 +6984,21 @@ var FilledDocumentService = class extends BaseService {
6664
6984
  * @returns Array of filled documents and the last document for pagination
6665
6985
  */
6666
6986
  async getFilledDocumentsByStatus(status, pageSize = 20, lastDoc) {
6667
- let q = query11(
6987
+ let q = query12(
6668
6988
  this.collectionRef,
6669
- where11("status", "==", status),
6989
+ where12("status", "==", status),
6670
6990
  orderBy3("updatedAt", "desc"),
6671
6991
  limit2(pageSize)
6672
6992
  );
6673
6993
  if (lastDoc) {
6674
- q = query11(q, startAfter2(lastDoc));
6994
+ q = query12(q, startAfter2(lastDoc));
6675
6995
  }
6676
- const querySnapshot = await getDocs11(q);
6996
+ const querySnapshot = await getDocs12(q);
6677
6997
  const documents = [];
6678
6998
  let lastVisible = null;
6679
- querySnapshot.forEach((doc20) => {
6680
- documents.push(doc20.data());
6681
- lastVisible = doc20;
6999
+ querySnapshot.forEach((doc21) => {
7000
+ documents.push(doc21.data());
7001
+ lastVisible = doc21;
6682
7002
  });
6683
7003
  return {
6684
7004
  documents,
@@ -6688,7 +7008,7 @@ var FilledDocumentService = class extends BaseService {
6688
7008
  };
6689
7009
 
6690
7010
  // src/services/calendar/calendar-refactored.service.ts
6691
- import { Timestamp as Timestamp23, serverTimestamp as serverTimestamp18 } from "firebase/firestore";
7011
+ import { Timestamp as Timestamp24, serverTimestamp as serverTimestamp19 } from "firebase/firestore";
6692
7012
 
6693
7013
  // src/types/calendar/synced-calendar.types.ts
6694
7014
  var SyncedCalendarProvider = /* @__PURE__ */ ((SyncedCalendarProvider3) => {
@@ -6701,57 +7021,57 @@ var SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
6701
7021
 
6702
7022
  // src/services/calendar/calendar-refactored.service.ts
6703
7023
  import {
6704
- doc as doc19,
6705
- getDoc as getDoc22,
6706
- collection as collection17,
6707
- query as query16,
6708
- where as where16,
6709
- getDocs as getDocs16,
6710
- setDoc as setDoc19,
6711
- updateDoc as updateDoc20
7024
+ doc as doc20,
7025
+ getDoc as getDoc23,
7026
+ collection as collection18,
7027
+ query as query17,
7028
+ where as where17,
7029
+ getDocs as getDocs17,
7030
+ setDoc as setDoc20,
7031
+ updateDoc as updateDoc21
6712
7032
  } from "firebase/firestore";
6713
7033
 
6714
7034
  // src/validations/calendar.schema.ts
6715
- import { z as z17 } from "zod";
6716
- import { Timestamp as Timestamp17 } from "firebase/firestore";
7035
+ import { z as z18 } from "zod";
7036
+ import { Timestamp as Timestamp18 } from "firebase/firestore";
6717
7037
 
6718
7038
  // src/validations/profile-info.schema.ts
6719
- import { z as z16 } from "zod";
6720
- import { Timestamp as Timestamp16 } from "firebase/firestore";
6721
- var clinicInfoSchema2 = z16.object({
6722
- id: z16.string(),
6723
- featuredPhoto: z16.string(),
6724
- name: z16.string(),
6725
- description: z16.string(),
7039
+ import { z as z17 } from "zod";
7040
+ import { Timestamp as Timestamp17 } from "firebase/firestore";
7041
+ var clinicInfoSchema2 = z17.object({
7042
+ id: z17.string(),
7043
+ featuredPhoto: z17.string(),
7044
+ name: z17.string(),
7045
+ description: z17.string(),
6726
7046
  location: clinicLocationSchema,
6727
7047
  contactInfo: clinicContactInfoSchema
6728
7048
  });
6729
- var practitionerProfileInfoSchema = z16.object({
6730
- id: z16.string(),
6731
- practitionerPhoto: z16.string().nullable(),
6732
- name: z16.string(),
6733
- email: z16.string().email(),
6734
- phone: z16.string().nullable(),
7049
+ var practitionerProfileInfoSchema = z17.object({
7050
+ id: z17.string(),
7051
+ practitionerPhoto: z17.string().nullable(),
7052
+ name: z17.string(),
7053
+ email: z17.string().email(),
7054
+ phone: z17.string().nullable(),
6735
7055
  certification: practitionerCertificationSchema
6736
7056
  });
6737
- var patientProfileInfoSchema = z16.object({
6738
- id: z16.string(),
6739
- fullName: z16.string(),
6740
- email: z16.string().email(),
6741
- phone: z16.string().nullable(),
6742
- dateOfBirth: z16.instanceof(Timestamp16),
6743
- gender: z16.nativeEnum(Gender)
7057
+ var patientProfileInfoSchema = z17.object({
7058
+ id: z17.string(),
7059
+ fullName: z17.string(),
7060
+ email: z17.string().email(),
7061
+ phone: z17.string().nullable(),
7062
+ dateOfBirth: z17.instanceof(Timestamp17),
7063
+ gender: z17.nativeEnum(Gender)
6744
7064
  });
6745
7065
 
6746
7066
  // src/validations/calendar.schema.ts
6747
7067
  var MIN_APPOINTMENT_DURATION = 15;
6748
- var calendarEventTimeSchema = z17.object({
6749
- start: z17.instanceof(Date).or(z17.instanceof(Timestamp17)),
6750
- end: z17.instanceof(Date).or(z17.instanceof(Timestamp17))
7068
+ var calendarEventTimeSchema = z18.object({
7069
+ start: z18.instanceof(Date).or(z18.instanceof(Timestamp18)),
7070
+ end: z18.instanceof(Date).or(z18.instanceof(Timestamp18))
6751
7071
  }).refine(
6752
7072
  (data) => {
6753
- const startDate = data.start instanceof Timestamp17 ? data.start.toDate() : data.start;
6754
- const endDate = data.end instanceof Timestamp17 ? data.end.toDate() : data.end;
7073
+ const startDate = data.start instanceof Timestamp18 ? data.start.toDate() : data.start;
7074
+ const endDate = data.end instanceof Timestamp18 ? data.end.toDate() : data.end;
6755
7075
  return startDate < endDate;
6756
7076
  },
6757
7077
  {
@@ -6760,7 +7080,7 @@ var calendarEventTimeSchema = z17.object({
6760
7080
  }
6761
7081
  ).refine(
6762
7082
  (data) => {
6763
- const startDate = data.start instanceof Timestamp17 ? data.start.toDate() : data.start;
7083
+ const startDate = data.start instanceof Timestamp18 ? data.start.toDate() : data.start;
6764
7084
  return startDate > /* @__PURE__ */ new Date();
6765
7085
  },
6766
7086
  {
@@ -6768,46 +7088,46 @@ var calendarEventTimeSchema = z17.object({
6768
7088
  path: ["start"]
6769
7089
  }
6770
7090
  );
6771
- var timeSlotSchema2 = z17.object({
6772
- start: z17.date(),
6773
- end: z17.date(),
6774
- isAvailable: z17.boolean()
7091
+ var timeSlotSchema2 = z18.object({
7092
+ start: z18.date(),
7093
+ end: z18.date(),
7094
+ isAvailable: z18.boolean()
6775
7095
  }).refine((data) => data.start < data.end, {
6776
7096
  message: "End time must be after start time",
6777
7097
  path: ["end"]
6778
7098
  });
6779
- var syncedCalendarEventSchema = z17.object({
6780
- eventId: z17.string(),
6781
- syncedCalendarProvider: z17.nativeEnum(SyncedCalendarProvider),
6782
- syncedAt: z17.instanceof(Date).or(z17.instanceof(Timestamp17))
7099
+ var syncedCalendarEventSchema = z18.object({
7100
+ eventId: z18.string(),
7101
+ syncedCalendarProvider: z18.nativeEnum(SyncedCalendarProvider),
7102
+ syncedAt: z18.instanceof(Date).or(z18.instanceof(Timestamp18))
6783
7103
  });
6784
- var procedureInfoSchema = z17.object({
6785
- name: z17.string(),
6786
- description: z17.string(),
6787
- duration: z17.number().min(MIN_APPOINTMENT_DURATION),
6788
- price: z17.number().min(0),
6789
- currency: z17.nativeEnum(Currency)
7104
+ var procedureInfoSchema = z18.object({
7105
+ name: z18.string(),
7106
+ description: z18.string(),
7107
+ duration: z18.number().min(MIN_APPOINTMENT_DURATION),
7108
+ price: z18.number().min(0),
7109
+ currency: z18.nativeEnum(Currency)
6790
7110
  });
6791
- var procedureCategorizationSchema = z17.object({
6792
- procedureFamily: z17.string(),
7111
+ var procedureCategorizationSchema = z18.object({
7112
+ procedureFamily: z18.string(),
6793
7113
  // Replace with proper enum when available
6794
- procedureCategory: z17.string(),
7114
+ procedureCategory: z18.string(),
6795
7115
  // Replace with proper enum when available
6796
- procedureSubcategory: z17.string(),
7116
+ procedureSubcategory: z18.string(),
6797
7117
  // Replace with proper enum when available
6798
- procedureTechnology: z17.string(),
7118
+ procedureTechnology: z18.string(),
6799
7119
  // Replace with proper enum when available
6800
- procedureProduct: z17.string()
7120
+ procedureProduct: z18.string()
6801
7121
  // Replace with proper enum when available
6802
7122
  });
6803
- var createAppointmentSchema = z17.object({
6804
- clinicId: z17.string().min(1, "Clinic ID is required"),
6805
- doctorId: z17.string().min(1, "Doctor ID is required"),
6806
- patientId: z17.string().min(1, "Patient ID is required"),
6807
- procedureId: z17.string().min(1, "Procedure ID is required"),
7123
+ var createAppointmentSchema = z18.object({
7124
+ clinicId: z18.string().min(1, "Clinic ID is required"),
7125
+ doctorId: z18.string().min(1, "Doctor ID is required"),
7126
+ patientId: z18.string().min(1, "Patient ID is required"),
7127
+ procedureId: z18.string().min(1, "Procedure ID is required"),
6808
7128
  eventLocation: clinicLocationSchema,
6809
7129
  eventTime: calendarEventTimeSchema,
6810
- description: z17.string().optional()
7130
+ description: z18.string().optional()
6811
7131
  }).refine(
6812
7132
  (data) => {
6813
7133
  return true;
@@ -6816,125 +7136,125 @@ var createAppointmentSchema = z17.object({
6816
7136
  message: "Invalid appointment parameters"
6817
7137
  }
6818
7138
  );
6819
- var updateAppointmentSchema = z17.object({
6820
- appointmentId: z17.string().min(1, "Appointment ID is required"),
6821
- clinicId: z17.string().min(1, "Clinic ID is required"),
6822
- doctorId: z17.string().min(1, "Doctor ID is required"),
6823
- patientId: z17.string().min(1, "Patient ID is required"),
7139
+ var updateAppointmentSchema = z18.object({
7140
+ appointmentId: z18.string().min(1, "Appointment ID is required"),
7141
+ clinicId: z18.string().min(1, "Clinic ID is required"),
7142
+ doctorId: z18.string().min(1, "Doctor ID is required"),
7143
+ patientId: z18.string().min(1, "Patient ID is required"),
6824
7144
  eventTime: calendarEventTimeSchema.optional(),
6825
- description: z17.string().optional(),
6826
- status: z17.nativeEnum(CalendarEventStatus).optional()
7145
+ description: z18.string().optional(),
7146
+ status: z18.nativeEnum(CalendarEventStatus).optional()
6827
7147
  });
6828
- var createCalendarEventSchema = z17.object({
6829
- id: z17.string(),
6830
- clinicBranchId: z17.string().nullable().optional(),
6831
- clinicBranchInfo: z17.any().nullable().optional(),
6832
- practitionerProfileId: z17.string().nullable().optional(),
7148
+ var createCalendarEventSchema = z18.object({
7149
+ id: z18.string(),
7150
+ clinicBranchId: z18.string().nullable().optional(),
7151
+ clinicBranchInfo: z18.any().nullable().optional(),
7152
+ practitionerProfileId: z18.string().nullable().optional(),
6833
7153
  practitionerProfileInfo: practitionerProfileInfoSchema.nullable().optional(),
6834
- patientProfileId: z17.string().nullable().optional(),
7154
+ patientProfileId: z18.string().nullable().optional(),
6835
7155
  patientProfileInfo: patientProfileInfoSchema.nullable().optional(),
6836
- procedureId: z17.string().nullable().optional(),
6837
- appointmentId: z17.string().nullable().optional(),
6838
- syncedCalendarEventId: z17.array(syncedCalendarEventSchema).nullable().optional(),
6839
- eventName: z17.string().min(1, "Event name is required"),
7156
+ procedureId: z18.string().nullable().optional(),
7157
+ appointmentId: z18.string().nullable().optional(),
7158
+ syncedCalendarEventId: z18.array(syncedCalendarEventSchema).nullable().optional(),
7159
+ eventName: z18.string().min(1, "Event name is required"),
6840
7160
  eventLocation: clinicLocationSchema.optional(),
6841
7161
  eventTime: calendarEventTimeSchema,
6842
- description: z17.string().optional(),
6843
- status: z17.nativeEnum(CalendarEventStatus),
6844
- syncStatus: z17.nativeEnum(CalendarSyncStatus),
6845
- eventType: z17.nativeEnum(CalendarEventType),
6846
- createdAt: z17.any(),
7162
+ description: z18.string().optional(),
7163
+ status: z18.nativeEnum(CalendarEventStatus),
7164
+ syncStatus: z18.nativeEnum(CalendarSyncStatus),
7165
+ eventType: z18.nativeEnum(CalendarEventType),
7166
+ createdAt: z18.any(),
6847
7167
  // FieldValue for server timestamp
6848
- updatedAt: z17.any()
7168
+ updatedAt: z18.any()
6849
7169
  // FieldValue for server timestamp
6850
7170
  });
6851
- var updateCalendarEventSchema = z17.object({
6852
- syncedCalendarEventId: z17.array(syncedCalendarEventSchema).nullable().optional(),
6853
- appointmentId: z17.string().nullable().optional(),
6854
- eventName: z17.string().optional(),
7171
+ var updateCalendarEventSchema = z18.object({
7172
+ syncedCalendarEventId: z18.array(syncedCalendarEventSchema).nullable().optional(),
7173
+ appointmentId: z18.string().nullable().optional(),
7174
+ eventName: z18.string().optional(),
6855
7175
  eventTime: calendarEventTimeSchema.optional(),
6856
- description: z17.string().optional(),
6857
- status: z17.nativeEnum(CalendarEventStatus).optional(),
6858
- syncStatus: z17.nativeEnum(CalendarSyncStatus).optional(),
6859
- eventType: z17.nativeEnum(CalendarEventType).optional(),
6860
- updatedAt: z17.any()
7176
+ description: z18.string().optional(),
7177
+ status: z18.nativeEnum(CalendarEventStatus).optional(),
7178
+ syncStatus: z18.nativeEnum(CalendarSyncStatus).optional(),
7179
+ eventType: z18.nativeEnum(CalendarEventType).optional(),
7180
+ updatedAt: z18.any()
6861
7181
  // FieldValue for server timestamp
6862
7182
  });
6863
- var calendarEventSchema = z17.object({
6864
- id: z17.string(),
6865
- clinicBranchId: z17.string().nullable().optional(),
6866
- clinicBranchInfo: z17.any().nullable().optional(),
7183
+ var calendarEventSchema = z18.object({
7184
+ id: z18.string(),
7185
+ clinicBranchId: z18.string().nullable().optional(),
7186
+ clinicBranchInfo: z18.any().nullable().optional(),
6867
7187
  // Will be replaced with proper clinic info schema
6868
- practitionerProfileId: z17.string().nullable().optional(),
7188
+ practitionerProfileId: z18.string().nullable().optional(),
6869
7189
  practitionerProfileInfo: practitionerProfileInfoSchema.nullable().optional(),
6870
- patientProfileId: z17.string().nullable().optional(),
7190
+ patientProfileId: z18.string().nullable().optional(),
6871
7191
  patientProfileInfo: patientProfileInfoSchema.nullable().optional(),
6872
- procedureId: z17.string().nullable().optional(),
7192
+ procedureId: z18.string().nullable().optional(),
6873
7193
  procedureInfo: procedureInfoSchema.nullable().optional(),
6874
7194
  procedureCategorization: procedureCategorizationSchema.nullable().optional(),
6875
- appointmentId: z17.string().nullable().optional(),
6876
- syncedCalendarEventId: z17.array(syncedCalendarEventSchema).nullable().optional(),
6877
- eventName: z17.string(),
7195
+ appointmentId: z18.string().nullable().optional(),
7196
+ syncedCalendarEventId: z18.array(syncedCalendarEventSchema).nullable().optional(),
7197
+ eventName: z18.string(),
6878
7198
  eventLocation: clinicLocationSchema.optional(),
6879
7199
  eventTime: calendarEventTimeSchema,
6880
- description: z17.string().optional(),
6881
- status: z17.nativeEnum(CalendarEventStatus),
6882
- syncStatus: z17.nativeEnum(CalendarSyncStatus),
6883
- eventType: z17.nativeEnum(CalendarEventType),
6884
- createdAt: z17.instanceof(Date).or(z17.instanceof(Timestamp17)),
6885
- updatedAt: z17.instanceof(Date).or(z17.instanceof(Timestamp17))
7200
+ description: z18.string().optional(),
7201
+ status: z18.nativeEnum(CalendarEventStatus),
7202
+ syncStatus: z18.nativeEnum(CalendarSyncStatus),
7203
+ eventType: z18.nativeEnum(CalendarEventType),
7204
+ createdAt: z18.instanceof(Date).or(z18.instanceof(Timestamp18)),
7205
+ updatedAt: z18.instanceof(Date).or(z18.instanceof(Timestamp18))
6886
7206
  });
6887
7207
 
6888
7208
  // src/services/calendar/utils/clinic.utils.ts
6889
7209
  import {
6890
- collection as collection13,
6891
- doc as doc15,
6892
- getDoc as getDoc18,
6893
- getDocs as getDocs12,
6894
- setDoc as setDoc15,
6895
- updateDoc as updateDoc16,
6896
- deleteDoc as deleteDoc8,
6897
- query as query12,
6898
- where as where12,
7210
+ collection as collection14,
7211
+ doc as doc16,
7212
+ getDoc as getDoc19,
7213
+ getDocs as getDocs13,
7214
+ setDoc as setDoc16,
7215
+ updateDoc as updateDoc17,
7216
+ deleteDoc as deleteDoc9,
7217
+ query as query13,
7218
+ where as where13,
6899
7219
  orderBy as orderBy4,
6900
- Timestamp as Timestamp18,
6901
- serverTimestamp as serverTimestamp14
7220
+ Timestamp as Timestamp19,
7221
+ serverTimestamp as serverTimestamp15
6902
7222
  } from "firebase/firestore";
6903
7223
 
6904
7224
  // src/services/calendar/utils/docs.utils.ts
6905
- import { doc as doc14 } from "firebase/firestore";
7225
+ import { doc as doc15 } from "firebase/firestore";
6906
7226
  function getPractitionerCalendarEventDocRef(db, practitionerId, eventId) {
6907
- return doc14(
7227
+ return doc15(
6908
7228
  db,
6909
7229
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${CALENDAR_COLLECTION}/${eventId}`
6910
7230
  );
6911
7231
  }
6912
7232
  function getPatientCalendarEventDocRef(db, patientId, eventId) {
6913
- return doc14(
7233
+ return doc15(
6914
7234
  db,
6915
7235
  `${PATIENTS_COLLECTION}/${patientId}/${CALENDAR_COLLECTION}/${eventId}`
6916
7236
  );
6917
7237
  }
6918
7238
  function getClinicCalendarEventDocRef(db, clinicId, eventId) {
6919
- return doc14(
7239
+ return doc15(
6920
7240
  db,
6921
7241
  `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}/${eventId}`
6922
7242
  );
6923
7243
  }
6924
7244
  function getPractitionerSyncedCalendarDocRef(db, practitionerId, syncedCalendarId) {
6925
- return doc14(
7245
+ return doc15(
6926
7246
  db,
6927
7247
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/syncedCalendars/${syncedCalendarId}`
6928
7248
  );
6929
7249
  }
6930
7250
  function getPatientSyncedCalendarDocRef(db, patientId, syncedCalendarId) {
6931
- return doc14(
7251
+ return doc15(
6932
7252
  db,
6933
7253
  `${PATIENTS_COLLECTION}/${patientId}/syncedCalendars/${syncedCalendarId}`
6934
7254
  );
6935
7255
  }
6936
7256
  function getClinicSyncedCalendarDocRef(db, clinicId, syncedCalendarId) {
6937
- return doc14(
7257
+ return doc15(
6938
7258
  db,
6939
7259
  `${CLINICS_COLLECTION}/${clinicId}/syncedCalendars/${syncedCalendarId}`
6940
7260
  );
@@ -6947,31 +7267,31 @@ async function createClinicCalendarEventUtil(db, clinicId, eventData, generateId
6947
7267
  const newEvent = {
6948
7268
  id: eventId,
6949
7269
  ...eventData,
6950
- createdAt: serverTimestamp14(),
6951
- updatedAt: serverTimestamp14()
7270
+ createdAt: serverTimestamp15(),
7271
+ updatedAt: serverTimestamp15()
6952
7272
  };
6953
- await setDoc15(eventRef, newEvent);
7273
+ await setDoc16(eventRef, newEvent);
6954
7274
  return {
6955
7275
  ...newEvent,
6956
- createdAt: Timestamp18.now(),
6957
- updatedAt: Timestamp18.now()
7276
+ createdAt: Timestamp19.now(),
7277
+ updatedAt: Timestamp19.now()
6958
7278
  };
6959
7279
  }
6960
7280
  async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData) {
6961
7281
  const eventRef = getClinicCalendarEventDocRef(db, clinicId, eventId);
6962
7282
  const updates = {
6963
7283
  ...updateData,
6964
- updatedAt: serverTimestamp14()
7284
+ updatedAt: serverTimestamp15()
6965
7285
  };
6966
- await updateDoc16(eventRef, updates);
6967
- const updatedDoc = await getDoc18(eventRef);
7286
+ await updateDoc17(eventRef, updates);
7287
+ const updatedDoc = await getDoc19(eventRef);
6968
7288
  if (!updatedDoc.exists()) {
6969
7289
  throw new Error("Event not found after update");
6970
7290
  }
6971
7291
  return updatedDoc.data();
6972
7292
  }
6973
7293
  async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
6974
- const clinicDoc = await getDoc18(doc15(db, `clinics/${clinicId}`));
7294
+ const clinicDoc = await getDoc19(doc16(db, `clinics/${clinicId}`));
6975
7295
  if (!clinicDoc.exists()) {
6976
7296
  throw new Error(`Clinic with ID ${clinicId} not found`);
6977
7297
  }
@@ -6980,8 +7300,8 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
6980
7300
  if (!clinicGroupId) {
6981
7301
  return false;
6982
7302
  }
6983
- const clinicGroupDoc = await getDoc18(
6984
- doc15(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
7303
+ const clinicGroupDoc = await getDoc19(
7304
+ doc16(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
6985
7305
  );
6986
7306
  if (!clinicGroupDoc.exists()) {
6987
7307
  return false;
@@ -6992,17 +7312,17 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
6992
7312
 
6993
7313
  // src/services/calendar/utils/patient.utils.ts
6994
7314
  import {
6995
- collection as collection14,
6996
- getDoc as getDoc19,
6997
- getDocs as getDocs13,
6998
- setDoc as setDoc16,
6999
- updateDoc as updateDoc17,
7000
- deleteDoc as deleteDoc9,
7001
- query as query13,
7002
- where as where13,
7315
+ collection as collection15,
7316
+ getDoc as getDoc20,
7317
+ getDocs as getDocs14,
7318
+ setDoc as setDoc17,
7319
+ updateDoc as updateDoc18,
7320
+ deleteDoc as deleteDoc10,
7321
+ query as query14,
7322
+ where as where14,
7003
7323
  orderBy as orderBy5,
7004
- Timestamp as Timestamp19,
7005
- serverTimestamp as serverTimestamp15
7324
+ Timestamp as Timestamp20,
7325
+ serverTimestamp as serverTimestamp16
7006
7326
  } from "firebase/firestore";
7007
7327
  async function createPatientCalendarEventUtil(db, patientId, eventData, generateId2) {
7008
7328
  const eventId = generateId2();
@@ -7010,24 +7330,24 @@ async function createPatientCalendarEventUtil(db, patientId, eventData, generate
7010
7330
  const newEvent = {
7011
7331
  id: eventId,
7012
7332
  ...eventData,
7013
- createdAt: serverTimestamp15(),
7014
- updatedAt: serverTimestamp15()
7333
+ createdAt: serverTimestamp16(),
7334
+ updatedAt: serverTimestamp16()
7015
7335
  };
7016
- await setDoc16(eventRef, newEvent);
7336
+ await setDoc17(eventRef, newEvent);
7017
7337
  return {
7018
7338
  ...newEvent,
7019
- createdAt: Timestamp19.now(),
7020
- updatedAt: Timestamp19.now()
7339
+ createdAt: Timestamp20.now(),
7340
+ updatedAt: Timestamp20.now()
7021
7341
  };
7022
7342
  }
7023
7343
  async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData) {
7024
7344
  const eventRef = getPatientCalendarEventDocRef(db, patientId, eventId);
7025
7345
  const updates = {
7026
7346
  ...updateData,
7027
- updatedAt: serverTimestamp15()
7347
+ updatedAt: serverTimestamp16()
7028
7348
  };
7029
- await updateDoc17(eventRef, updates);
7030
- const updatedDoc = await getDoc19(eventRef);
7349
+ await updateDoc18(eventRef, updates);
7350
+ const updatedDoc = await getDoc20(eventRef);
7031
7351
  if (!updatedDoc.exists()) {
7032
7352
  throw new Error("Event not found after update");
7033
7353
  }
@@ -7036,17 +7356,17 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
7036
7356
 
7037
7357
  // src/services/calendar/utils/practitioner.utils.ts
7038
7358
  import {
7039
- collection as collection15,
7040
- getDoc as getDoc20,
7041
- getDocs as getDocs14,
7042
- setDoc as setDoc17,
7043
- updateDoc as updateDoc18,
7044
- deleteDoc as deleteDoc10,
7045
- query as query14,
7046
- where as where14,
7359
+ collection as collection16,
7360
+ getDoc as getDoc21,
7361
+ getDocs as getDocs15,
7362
+ setDoc as setDoc18,
7363
+ updateDoc as updateDoc19,
7364
+ deleteDoc as deleteDoc11,
7365
+ query as query15,
7366
+ where as where15,
7047
7367
  orderBy as orderBy6,
7048
- Timestamp as Timestamp20,
7049
- serverTimestamp as serverTimestamp16
7368
+ Timestamp as Timestamp21,
7369
+ serverTimestamp as serverTimestamp17
7050
7370
  } from "firebase/firestore";
7051
7371
  async function createPractitionerCalendarEventUtil(db, practitionerId, eventData, generateId2) {
7052
7372
  const eventId = generateId2();
@@ -7058,14 +7378,14 @@ async function createPractitionerCalendarEventUtil(db, practitionerId, eventData
7058
7378
  const newEvent = {
7059
7379
  id: eventId,
7060
7380
  ...eventData,
7061
- createdAt: serverTimestamp16(),
7062
- updatedAt: serverTimestamp16()
7381
+ createdAt: serverTimestamp17(),
7382
+ updatedAt: serverTimestamp17()
7063
7383
  };
7064
- await setDoc17(eventRef, newEvent);
7384
+ await setDoc18(eventRef, newEvent);
7065
7385
  return {
7066
7386
  ...newEvent,
7067
- createdAt: Timestamp20.now(),
7068
- updatedAt: Timestamp20.now()
7387
+ createdAt: Timestamp21.now(),
7388
+ updatedAt: Timestamp21.now()
7069
7389
  };
7070
7390
  }
7071
7391
  async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId, updateData) {
@@ -7076,10 +7396,10 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
7076
7396
  );
7077
7397
  const updates = {
7078
7398
  ...updateData,
7079
- updatedAt: serverTimestamp16()
7399
+ updatedAt: serverTimestamp17()
7080
7400
  };
7081
- await updateDoc18(eventRef, updates);
7082
- const updatedDoc = await getDoc20(eventRef);
7401
+ await updateDoc19(eventRef, updates);
7402
+ const updatedDoc = await getDoc21(eventRef);
7083
7403
  if (!updatedDoc.exists()) {
7084
7404
  throw new Error("Event not found after update");
7085
7405
  }
@@ -7156,16 +7476,16 @@ async function updateAppointmentUtil(db, clinicId, practitionerId, patientId, ev
7156
7476
 
7157
7477
  // src/services/calendar/utils/synced-calendar.utils.ts
7158
7478
  import {
7159
- collection as collection16,
7160
- getDoc as getDoc21,
7161
- getDocs as getDocs15,
7162
- setDoc as setDoc18,
7163
- updateDoc as updateDoc19,
7164
- deleteDoc as deleteDoc11,
7165
- query as query15,
7479
+ collection as collection17,
7480
+ getDoc as getDoc22,
7481
+ getDocs as getDocs16,
7482
+ setDoc as setDoc19,
7483
+ updateDoc as updateDoc20,
7484
+ deleteDoc as deleteDoc12,
7485
+ query as query16,
7166
7486
  orderBy as orderBy7,
7167
- Timestamp as Timestamp21,
7168
- serverTimestamp as serverTimestamp17
7487
+ Timestamp as Timestamp22,
7488
+ serverTimestamp as serverTimestamp18
7169
7489
  } from "firebase/firestore";
7170
7490
  async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendarData, generateId2) {
7171
7491
  const calendarId = generateId2();
@@ -7177,14 +7497,14 @@ async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendar
7177
7497
  const newCalendar = {
7178
7498
  id: calendarId,
7179
7499
  ...calendarData,
7180
- createdAt: serverTimestamp17(),
7181
- updatedAt: serverTimestamp17()
7500
+ createdAt: serverTimestamp18(),
7501
+ updatedAt: serverTimestamp18()
7182
7502
  };
7183
- await setDoc18(calendarRef, newCalendar);
7503
+ await setDoc19(calendarRef, newCalendar);
7184
7504
  return {
7185
7505
  ...newCalendar,
7186
- createdAt: Timestamp21.now(),
7187
- updatedAt: Timestamp21.now()
7506
+ createdAt: Timestamp22.now(),
7507
+ updatedAt: Timestamp22.now()
7188
7508
  };
7189
7509
  }
7190
7510
  async function createPatientSyncedCalendarUtil(db, patientId, calendarData, generateId2) {
@@ -7193,14 +7513,14 @@ async function createPatientSyncedCalendarUtil(db, patientId, calendarData, gene
7193
7513
  const newCalendar = {
7194
7514
  id: calendarId,
7195
7515
  ...calendarData,
7196
- createdAt: serverTimestamp17(),
7197
- updatedAt: serverTimestamp17()
7516
+ createdAt: serverTimestamp18(),
7517
+ updatedAt: serverTimestamp18()
7198
7518
  };
7199
- await setDoc18(calendarRef, newCalendar);
7519
+ await setDoc19(calendarRef, newCalendar);
7200
7520
  return {
7201
7521
  ...newCalendar,
7202
- createdAt: Timestamp21.now(),
7203
- updatedAt: Timestamp21.now()
7522
+ createdAt: Timestamp22.now(),
7523
+ updatedAt: Timestamp22.now()
7204
7524
  };
7205
7525
  }
7206
7526
  async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, generateId2) {
@@ -7209,14 +7529,14 @@ async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, genera
7209
7529
  const newCalendar = {
7210
7530
  id: calendarId,
7211
7531
  ...calendarData,
7212
- createdAt: serverTimestamp17(),
7213
- updatedAt: serverTimestamp17()
7532
+ createdAt: serverTimestamp18(),
7533
+ updatedAt: serverTimestamp18()
7214
7534
  };
7215
- await setDoc18(calendarRef, newCalendar);
7535
+ await setDoc19(calendarRef, newCalendar);
7216
7536
  return {
7217
7537
  ...newCalendar,
7218
- createdAt: Timestamp21.now(),
7219
- updatedAt: Timestamp21.now()
7538
+ createdAt: Timestamp22.now(),
7539
+ updatedAt: Timestamp22.now()
7220
7540
  };
7221
7541
  }
7222
7542
  async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId) {
@@ -7225,54 +7545,54 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
7225
7545
  practitionerId,
7226
7546
  calendarId
7227
7547
  );
7228
- const calendarDoc = await getDoc21(calendarRef);
7548
+ const calendarDoc = await getDoc22(calendarRef);
7229
7549
  if (!calendarDoc.exists()) {
7230
7550
  return null;
7231
7551
  }
7232
7552
  return calendarDoc.data();
7233
7553
  }
7234
7554
  async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
7235
- const calendarsRef = collection16(
7555
+ const calendarsRef = collection17(
7236
7556
  db,
7237
7557
  `practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
7238
7558
  );
7239
- const q = query15(calendarsRef, orderBy7("createdAt", "desc"));
7240
- const querySnapshot = await getDocs15(q);
7241
- return querySnapshot.docs.map((doc20) => doc20.data());
7559
+ const q = query16(calendarsRef, orderBy7("createdAt", "desc"));
7560
+ const querySnapshot = await getDocs16(q);
7561
+ return querySnapshot.docs.map((doc21) => doc21.data());
7242
7562
  }
7243
7563
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
7244
7564
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
7245
- const calendarDoc = await getDoc21(calendarRef);
7565
+ const calendarDoc = await getDoc22(calendarRef);
7246
7566
  if (!calendarDoc.exists()) {
7247
7567
  return null;
7248
7568
  }
7249
7569
  return calendarDoc.data();
7250
7570
  }
7251
7571
  async function getPatientSyncedCalendarsUtil(db, patientId) {
7252
- const calendarsRef = collection16(
7572
+ const calendarsRef = collection17(
7253
7573
  db,
7254
7574
  `patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
7255
7575
  );
7256
- const q = query15(calendarsRef, orderBy7("createdAt", "desc"));
7257
- const querySnapshot = await getDocs15(q);
7258
- return querySnapshot.docs.map((doc20) => doc20.data());
7576
+ const q = query16(calendarsRef, orderBy7("createdAt", "desc"));
7577
+ const querySnapshot = await getDocs16(q);
7578
+ return querySnapshot.docs.map((doc21) => doc21.data());
7259
7579
  }
7260
7580
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
7261
7581
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
7262
- const calendarDoc = await getDoc21(calendarRef);
7582
+ const calendarDoc = await getDoc22(calendarRef);
7263
7583
  if (!calendarDoc.exists()) {
7264
7584
  return null;
7265
7585
  }
7266
7586
  return calendarDoc.data();
7267
7587
  }
7268
7588
  async function getClinicSyncedCalendarsUtil(db, clinicId) {
7269
- const calendarsRef = collection16(
7589
+ const calendarsRef = collection17(
7270
7590
  db,
7271
7591
  `clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
7272
7592
  );
7273
- const q = query15(calendarsRef, orderBy7("createdAt", "desc"));
7274
- const querySnapshot = await getDocs15(q);
7275
- return querySnapshot.docs.map((doc20) => doc20.data());
7593
+ const q = query16(calendarsRef, orderBy7("createdAt", "desc"));
7594
+ const querySnapshot = await getDocs16(q);
7595
+ return querySnapshot.docs.map((doc21) => doc21.data());
7276
7596
  }
7277
7597
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
7278
7598
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -7282,10 +7602,10 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
7282
7602
  );
7283
7603
  const updates = {
7284
7604
  ...updateData,
7285
- updatedAt: serverTimestamp17()
7605
+ updatedAt: serverTimestamp18()
7286
7606
  };
7287
- await updateDoc19(calendarRef, updates);
7288
- const updatedDoc = await getDoc21(calendarRef);
7607
+ await updateDoc20(calendarRef, updates);
7608
+ const updatedDoc = await getDoc22(calendarRef);
7289
7609
  if (!updatedDoc.exists()) {
7290
7610
  throw new Error("Synced calendar not found after update");
7291
7611
  }
@@ -7295,10 +7615,10 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
7295
7615
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
7296
7616
  const updates = {
7297
7617
  ...updateData,
7298
- updatedAt: serverTimestamp17()
7618
+ updatedAt: serverTimestamp18()
7299
7619
  };
7300
- await updateDoc19(calendarRef, updates);
7301
- const updatedDoc = await getDoc21(calendarRef);
7620
+ await updateDoc20(calendarRef, updates);
7621
+ const updatedDoc = await getDoc22(calendarRef);
7302
7622
  if (!updatedDoc.exists()) {
7303
7623
  throw new Error("Synced calendar not found after update");
7304
7624
  }
@@ -7308,10 +7628,10 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
7308
7628
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
7309
7629
  const updates = {
7310
7630
  ...updateData,
7311
- updatedAt: serverTimestamp17()
7631
+ updatedAt: serverTimestamp18()
7312
7632
  };
7313
- await updateDoc19(calendarRef, updates);
7314
- const updatedDoc = await getDoc21(calendarRef);
7633
+ await updateDoc20(calendarRef, updates);
7634
+ const updatedDoc = await getDoc22(calendarRef);
7315
7635
  if (!updatedDoc.exists()) {
7316
7636
  throw new Error("Synced calendar not found after update");
7317
7637
  }
@@ -7323,19 +7643,19 @@ async function deletePractitionerSyncedCalendarUtil(db, practitionerId, calendar
7323
7643
  practitionerId,
7324
7644
  calendarId
7325
7645
  );
7326
- await deleteDoc11(calendarRef);
7646
+ await deleteDoc12(calendarRef);
7327
7647
  }
7328
7648
  async function deletePatientSyncedCalendarUtil(db, patientId, calendarId) {
7329
7649
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
7330
- await deleteDoc11(calendarRef);
7650
+ await deleteDoc12(calendarRef);
7331
7651
  }
7332
7652
  async function deleteClinicSyncedCalendarUtil(db, clinicId, calendarId) {
7333
7653
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
7334
- await deleteDoc11(calendarRef);
7654
+ await deleteDoc12(calendarRef);
7335
7655
  }
7336
7656
  async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarId) {
7337
7657
  const updateData = {
7338
- lastSyncedAt: Timestamp21.now()
7658
+ lastSyncedAt: Timestamp22.now()
7339
7659
  };
7340
7660
  switch (entityType) {
7341
7661
  case "practitioner":
@@ -7365,7 +7685,7 @@ async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarI
7365
7685
  }
7366
7686
 
7367
7687
  // src/services/calendar/utils/google-calendar.utils.ts
7368
- import { Timestamp as Timestamp22 } from "firebase/firestore";
7688
+ import { Timestamp as Timestamp23 } from "firebase/firestore";
7369
7689
  var GOOGLE_CALENDAR_API_URL = "https://www.googleapis.com/calendar/v3";
7370
7690
  var GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token";
7371
7691
  var CLIENT_ID = "your-client-id";
@@ -7485,7 +7805,7 @@ async function ensureValidToken(db, entityType, entityId, syncedCalendar) {
7485
7805
  tokenExpiry.setSeconds(tokenExpiry.getSeconds() + expiresIn);
7486
7806
  const updateData = {
7487
7807
  accessToken,
7488
- tokenExpiry: Timestamp22.fromDate(tokenExpiry)
7808
+ tokenExpiry: Timestamp23.fromDate(tokenExpiry)
7489
7809
  };
7490
7810
  switch (entityType) {
7491
7811
  case "practitioner":
@@ -7660,8 +7980,8 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
7660
7980
  eventName: googleEvent.summary || "External Event",
7661
7981
  eventLocation: googleEvent.location,
7662
7982
  eventTime: {
7663
- start: Timestamp22.fromDate(start),
7664
- end: Timestamp22.fromDate(end)
7983
+ start: Timestamp23.fromDate(start),
7984
+ end: Timestamp23.fromDate(end)
7665
7985
  },
7666
7986
  description: googleEvent.description || "",
7667
7987
  // External events are always set as CONFIRMED - status updates will happen externally
@@ -7675,7 +7995,7 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
7675
7995
  {
7676
7996
  eventId: googleEvent.id,
7677
7997
  syncedCalendarProvider: "google" /* GOOGLE */,
7678
- syncedAt: Timestamp22.now()
7998
+ syncedAt: Timestamp23.now()
7679
7999
  }
7680
8000
  ]
7681
8001
  };
@@ -8453,7 +8773,7 @@ var CalendarServiceV2 = class extends BaseService {
8453
8773
  return 0;
8454
8774
  }
8455
8775
  let importedEventsCount = 0;
8456
- const currentTime = Timestamp23.now();
8776
+ const currentTime = Timestamp24.now();
8457
8777
  for (const calendar of activeCalendars) {
8458
8778
  try {
8459
8779
  let externalEvents = [];
@@ -8520,7 +8840,7 @@ var CalendarServiceV2 = class extends BaseService {
8520
8840
  async createDoctorBlockingEvent(doctorId, eventData) {
8521
8841
  try {
8522
8842
  const eventId = this.generateId();
8523
- const eventRef = doc19(
8843
+ const eventRef = doc20(
8524
8844
  this.db,
8525
8845
  PRACTITIONERS_COLLECTION,
8526
8846
  doctorId,
@@ -8530,14 +8850,14 @@ var CalendarServiceV2 = class extends BaseService {
8530
8850
  const newEvent = {
8531
8851
  id: eventId,
8532
8852
  ...eventData,
8533
- createdAt: serverTimestamp18(),
8534
- updatedAt: serverTimestamp18()
8853
+ createdAt: serverTimestamp19(),
8854
+ updatedAt: serverTimestamp19()
8535
8855
  };
8536
- await setDoc19(eventRef, newEvent);
8856
+ await setDoc20(eventRef, newEvent);
8537
8857
  return {
8538
8858
  ...newEvent,
8539
- createdAt: Timestamp23.now(),
8540
- updatedAt: Timestamp23.now()
8859
+ createdAt: Timestamp24.now(),
8860
+ updatedAt: Timestamp24.now()
8541
8861
  };
8542
8862
  } catch (error) {
8543
8863
  console.error(
@@ -8555,8 +8875,8 @@ var CalendarServiceV2 = class extends BaseService {
8555
8875
  */
8556
8876
  async synchronizeExternalCalendars(lookbackDays = 7, lookforwardDays = 30) {
8557
8877
  try {
8558
- const practitionersRef = collection17(this.db, PRACTITIONERS_COLLECTION);
8559
- const practitionersSnapshot = await getDocs16(practitionersRef);
8878
+ const practitionersRef = collection18(this.db, PRACTITIONERS_COLLECTION);
8879
+ const practitionersSnapshot = await getDocs17(practitionersRef);
8560
8880
  const startDate = /* @__PURE__ */ new Date();
8561
8881
  startDate.setDate(startDate.getDate() - lookbackDays);
8562
8882
  const endDate = /* @__PURE__ */ new Date();
@@ -8614,22 +8934,22 @@ var CalendarServiceV2 = class extends BaseService {
8614
8934
  async updateExistingEventsFromExternalCalendars(doctorId, startDate, endDate) {
8615
8935
  var _a;
8616
8936
  try {
8617
- const eventsRef = collection17(
8937
+ const eventsRef = collection18(
8618
8938
  this.db,
8619
8939
  PRACTITIONERS_COLLECTION,
8620
8940
  doctorId,
8621
8941
  CALENDAR_COLLECTION
8622
8942
  );
8623
- const q = query16(
8943
+ const q = query17(
8624
8944
  eventsRef,
8625
- where16("syncStatus", "==", "external" /* EXTERNAL */),
8626
- where16("eventTime.start", ">=", Timestamp23.fromDate(startDate)),
8627
- where16("eventTime.start", "<=", Timestamp23.fromDate(endDate))
8945
+ where17("syncStatus", "==", "external" /* EXTERNAL */),
8946
+ where17("eventTime.start", ">=", Timestamp24.fromDate(startDate)),
8947
+ where17("eventTime.start", "<=", Timestamp24.fromDate(endDate))
8628
8948
  );
8629
- const eventsSnapshot = await getDocs16(q);
8630
- const events = eventsSnapshot.docs.map((doc20) => ({
8631
- id: doc20.id,
8632
- ...doc20.data()
8949
+ const eventsSnapshot = await getDocs17(q);
8950
+ const events = eventsSnapshot.docs.map((doc21) => ({
8951
+ id: doc21.id,
8952
+ ...doc21.data()
8633
8953
  }));
8634
8954
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
8635
8955
  doctorId
@@ -8733,21 +9053,21 @@ var CalendarServiceV2 = class extends BaseService {
8733
9053
  const endTime = new Date(
8734
9054
  externalEvent.end.dateTime || externalEvent.end.date
8735
9055
  );
8736
- const eventRef = doc19(
9056
+ const eventRef = doc20(
8737
9057
  this.db,
8738
9058
  PRACTITIONERS_COLLECTION,
8739
9059
  doctorId,
8740
9060
  CALENDAR_COLLECTION,
8741
9061
  eventId
8742
9062
  );
8743
- await updateDoc20(eventRef, {
9063
+ await updateDoc21(eventRef, {
8744
9064
  eventName: externalEvent.summary || "External Event",
8745
9065
  eventTime: {
8746
- start: Timestamp23.fromDate(startTime),
8747
- end: Timestamp23.fromDate(endTime)
9066
+ start: Timestamp24.fromDate(startTime),
9067
+ end: Timestamp24.fromDate(endTime)
8748
9068
  },
8749
9069
  description: externalEvent.description || "",
8750
- updatedAt: serverTimestamp18()
9070
+ updatedAt: serverTimestamp19()
8751
9071
  });
8752
9072
  console.log(`Updated local event ${eventId} from external event`);
8753
9073
  } catch (error) {
@@ -8765,16 +9085,16 @@ var CalendarServiceV2 = class extends BaseService {
8765
9085
  */
8766
9086
  async updateEventStatus(doctorId, eventId, status) {
8767
9087
  try {
8768
- const eventRef = doc19(
9088
+ const eventRef = doc20(
8769
9089
  this.db,
8770
9090
  PRACTITIONERS_COLLECTION,
8771
9091
  doctorId,
8772
9092
  CALENDAR_COLLECTION,
8773
9093
  eventId
8774
9094
  );
8775
- await updateDoc20(eventRef, {
9095
+ await updateDoc21(eventRef, {
8776
9096
  status,
8777
- updatedAt: serverTimestamp18()
9097
+ updatedAt: serverTimestamp19()
8778
9098
  });
8779
9099
  console.log(`Updated event ${eventId} status to ${status}`);
8780
9100
  } catch (error) {
@@ -8835,8 +9155,8 @@ var CalendarServiceV2 = class extends BaseService {
8835
9155
  const startDate = eventTime.start.toDate();
8836
9156
  const startTime = startDate;
8837
9157
  const endTime = eventTime.end.toDate();
8838
- const practitionerRef = doc19(this.db, PRACTITIONERS_COLLECTION, doctorId);
8839
- const practitionerDoc = await getDoc22(practitionerRef);
9158
+ const practitionerRef = doc20(this.db, PRACTITIONERS_COLLECTION, doctorId);
9159
+ const practitionerDoc = await getDoc23(practitionerRef);
8840
9160
  if (!practitionerDoc.exists()) {
8841
9161
  throw new Error(`Doctor with ID ${doctorId} not found`);
8842
9162
  }
@@ -8893,8 +9213,8 @@ var CalendarServiceV2 = class extends BaseService {
8893
9213
  * @returns Updated calendar event
8894
9214
  */
8895
9215
  async updateAppointmentStatus(appointmentId, clinicId, status) {
8896
- const appointmentRef = doc19(this.db, CALENDAR_COLLECTION, appointmentId);
8897
- const appointmentDoc = await getDoc22(appointmentRef);
9216
+ const appointmentRef = doc20(this.db, CALENDAR_COLLECTION, appointmentId);
9217
+ const appointmentDoc = await getDoc23(appointmentRef);
8898
9218
  if (!appointmentDoc.exists()) {
8899
9219
  throw new Error(`Appointment with ID ${appointmentId} not found`);
8900
9220
  }
@@ -9025,7 +9345,7 @@ var CalendarServiceV2 = class extends BaseService {
9025
9345
  const newSyncEvent = {
9026
9346
  eventId: result.eventIds[0],
9027
9347
  syncedCalendarProvider: calendar.provider,
9028
- syncedAt: Timestamp23.now()
9348
+ syncedAt: Timestamp24.now()
9029
9349
  };
9030
9350
  await this.updateEventWithSyncId(
9031
9351
  entityType === "doctor" ? appointment.practitionerProfileId : appointment.patientProfileId,
@@ -9049,8 +9369,8 @@ var CalendarServiceV2 = class extends BaseService {
9049
9369
  async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
9050
9370
  try {
9051
9371
  const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
9052
- const eventRef = doc19(this.db, collectionPath, eventId);
9053
- const eventDoc = await getDoc22(eventRef);
9372
+ const eventRef = doc20(this.db, collectionPath, eventId);
9373
+ const eventDoc = await getDoc23(eventRef);
9054
9374
  if (eventDoc.exists()) {
9055
9375
  const event = eventDoc.data();
9056
9376
  const syncIds = [...event.syncedCalendarEventId || []];
@@ -9062,9 +9382,9 @@ var CalendarServiceV2 = class extends BaseService {
9062
9382
  } else {
9063
9383
  syncIds.push(syncEvent);
9064
9384
  }
9065
- await updateDoc20(eventRef, {
9385
+ await updateDoc21(eventRef, {
9066
9386
  syncedCalendarEventId: syncIds,
9067
- updatedAt: serverTimestamp18()
9387
+ updatedAt: serverTimestamp19()
9068
9388
  });
9069
9389
  console.log(
9070
9390
  `Updated event ${eventId} with sync ID ${syncEvent.eventId}`
@@ -9088,8 +9408,8 @@ var CalendarServiceV2 = class extends BaseService {
9088
9408
  * @returns Working hours for the clinic
9089
9409
  */
9090
9410
  async getClinicWorkingHours(clinicId, date) {
9091
- const clinicRef = doc19(this.db, CLINICS_COLLECTION, clinicId);
9092
- const clinicDoc = await getDoc22(clinicRef);
9411
+ const clinicRef = doc20(this.db, CLINICS_COLLECTION, clinicId);
9412
+ const clinicDoc = await getDoc23(clinicRef);
9093
9413
  if (!clinicDoc.exists()) {
9094
9414
  throw new Error(`Clinic with ID ${clinicId} not found`);
9095
9415
  }
@@ -9117,8 +9437,8 @@ var CalendarServiceV2 = class extends BaseService {
9117
9437
  * @returns Doctor's schedule
9118
9438
  */
9119
9439
  async getDoctorSchedule(doctorId, date) {
9120
- const practitionerRef = doc19(this.db, PRACTITIONERS_COLLECTION, doctorId);
9121
- const practitionerDoc = await getDoc22(practitionerRef);
9440
+ const practitionerRef = doc20(this.db, PRACTITIONERS_COLLECTION, doctorId);
9441
+ const practitionerDoc = await getDoc23(practitionerRef);
9122
9442
  if (!practitionerDoc.exists()) {
9123
9443
  throw new Error(`Doctor with ID ${doctorId} not found`);
9124
9444
  }
@@ -9150,19 +9470,19 @@ var CalendarServiceV2 = class extends BaseService {
9150
9470
  startOfDay.setHours(0, 0, 0, 0);
9151
9471
  const endOfDay = new Date(date);
9152
9472
  endOfDay.setHours(23, 59, 59, 999);
9153
- const appointmentsRef = collection17(this.db, CALENDAR_COLLECTION);
9154
- const q = query16(
9473
+ const appointmentsRef = collection18(this.db, CALENDAR_COLLECTION);
9474
+ const q = query17(
9155
9475
  appointmentsRef,
9156
- where16("practitionerProfileId", "==", doctorId),
9157
- where16("eventTime.start", ">=", Timestamp23.fromDate(startOfDay)),
9158
- where16("eventTime.start", "<=", Timestamp23.fromDate(endOfDay)),
9159
- where16("status", "in", [
9476
+ where17("practitionerProfileId", "==", doctorId),
9477
+ where17("eventTime.start", ">=", Timestamp24.fromDate(startOfDay)),
9478
+ where17("eventTime.start", "<=", Timestamp24.fromDate(endOfDay)),
9479
+ where17("status", "in", [
9160
9480
  "confirmed" /* CONFIRMED */,
9161
9481
  "pending" /* PENDING */
9162
9482
  ])
9163
9483
  );
9164
- const querySnapshot = await getDocs16(q);
9165
- return querySnapshot.docs.map((doc20) => doc20.data());
9484
+ const querySnapshot = await getDocs17(q);
9485
+ return querySnapshot.docs.map((doc21) => doc21.data());
9166
9486
  }
9167
9487
  /**
9168
9488
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -9219,11 +9539,11 @@ var CalendarServiceV2 = class extends BaseService {
9219
9539
  var _a;
9220
9540
  try {
9221
9541
  const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
9222
- getDoc22(doc19(this.db, CLINICS_COLLECTION, clinicId)),
9223
- getDoc22(doc19(this.db, PRACTITIONERS_COLLECTION, doctorId)),
9224
- getDoc22(doc19(this.db, PATIENTS_COLLECTION, patientId)),
9225
- getDoc22(
9226
- doc19(
9542
+ getDoc23(doc20(this.db, CLINICS_COLLECTION, clinicId)),
9543
+ getDoc23(doc20(this.db, PRACTITIONERS_COLLECTION, doctorId)),
9544
+ getDoc23(doc20(this.db, PATIENTS_COLLECTION, patientId)),
9545
+ getDoc23(
9546
+ doc20(
9227
9547
  this.db,
9228
9548
  PATIENTS_COLLECTION,
9229
9549
  patientId,
@@ -9256,7 +9576,7 @@ var CalendarServiceV2 = class extends BaseService {
9256
9576
  fullName: `${sensitiveData.firstName} ${sensitiveData.lastName}`,
9257
9577
  email: sensitiveData.email || "",
9258
9578
  phone: sensitiveData.phoneNumber || null,
9259
- dateOfBirth: sensitiveData.dateOfBirth || Timestamp23.now(),
9579
+ dateOfBirth: sensitiveData.dateOfBirth || Timestamp24.now(),
9260
9580
  gender: sensitiveData.gender || "other" /* OTHER */
9261
9581
  };
9262
9582
  } else if (patientDoc.exists()) {
@@ -9265,7 +9585,7 @@ var CalendarServiceV2 = class extends BaseService {
9265
9585
  fullName: patientDoc.data().displayName,
9266
9586
  email: ((_a = patientDoc.data().contactInfo) == null ? void 0 : _a.email) || "",
9267
9587
  phone: patientDoc.data().phoneNumber || null,
9268
- dateOfBirth: patientDoc.data().dateOfBirth || Timestamp23.now(),
9588
+ dateOfBirth: patientDoc.data().dateOfBirth || Timestamp24.now(),
9269
9589
  gender: patientDoc.data().gender || "other" /* OTHER */
9270
9590
  };
9271
9591
  }
@@ -9287,54 +9607,54 @@ var CalendarServiceV2 = class extends BaseService {
9287
9607
  };
9288
9608
 
9289
9609
  // src/validations/notification.schema.ts
9290
- import { z as z18 } from "zod";
9291
- var baseNotificationSchema = z18.object({
9292
- id: z18.string().optional(),
9293
- userId: z18.string(),
9294
- notificationTime: z18.any(),
9610
+ import { z as z19 } from "zod";
9611
+ var baseNotificationSchema = z19.object({
9612
+ id: z19.string().optional(),
9613
+ userId: z19.string(),
9614
+ notificationTime: z19.any(),
9295
9615
  // Timestamp
9296
- notificationType: z18.nativeEnum(NotificationType),
9297
- notificationTokens: z18.array(z18.string()),
9298
- status: z18.nativeEnum(NotificationStatus),
9299
- createdAt: z18.any().optional(),
9616
+ notificationType: z19.nativeEnum(NotificationType),
9617
+ notificationTokens: z19.array(z19.string()),
9618
+ status: z19.nativeEnum(NotificationStatus),
9619
+ createdAt: z19.any().optional(),
9300
9620
  // Timestamp
9301
- updatedAt: z18.any().optional(),
9621
+ updatedAt: z19.any().optional(),
9302
9622
  // Timestamp
9303
- title: z18.string(),
9304
- body: z18.string(),
9305
- isRead: z18.boolean(),
9306
- userRole: z18.nativeEnum(UserRole)
9623
+ title: z19.string(),
9624
+ body: z19.string(),
9625
+ isRead: z19.boolean(),
9626
+ userRole: z19.nativeEnum(UserRole)
9307
9627
  });
9308
9628
  var preRequirementNotificationSchema = baseNotificationSchema.extend({
9309
- notificationType: z18.literal("preRequirement" /* PRE_REQUIREMENT */),
9310
- treatmentId: z18.string(),
9311
- requirements: z18.array(z18.string()),
9312
- deadline: z18.any()
9629
+ notificationType: z19.literal("preRequirement" /* PRE_REQUIREMENT */),
9630
+ treatmentId: z19.string(),
9631
+ requirements: z19.array(z19.string()),
9632
+ deadline: z19.any()
9313
9633
  // Timestamp
9314
9634
  });
9315
9635
  var postRequirementNotificationSchema = baseNotificationSchema.extend({
9316
- notificationType: z18.literal("postRequirement" /* POST_REQUIREMENT */),
9317
- treatmentId: z18.string(),
9318
- requirements: z18.array(z18.string()),
9319
- deadline: z18.any()
9636
+ notificationType: z19.literal("postRequirement" /* POST_REQUIREMENT */),
9637
+ treatmentId: z19.string(),
9638
+ requirements: z19.array(z19.string()),
9639
+ deadline: z19.any()
9320
9640
  // Timestamp
9321
9641
  });
9322
9642
  var appointmentReminderNotificationSchema = baseNotificationSchema.extend({
9323
- notificationType: z18.literal("appointmentReminder" /* APPOINTMENT_REMINDER */),
9324
- appointmentId: z18.string(),
9325
- appointmentTime: z18.any(),
9643
+ notificationType: z19.literal("appointmentReminder" /* APPOINTMENT_REMINDER */),
9644
+ appointmentId: z19.string(),
9645
+ appointmentTime: z19.any(),
9326
9646
  // Timestamp
9327
- treatmentType: z18.string(),
9328
- doctorName: z18.string()
9647
+ treatmentType: z19.string(),
9648
+ doctorName: z19.string()
9329
9649
  });
9330
9650
  var appointmentNotificationSchema = baseNotificationSchema.extend({
9331
- notificationType: z18.literal("appointmentNotification" /* APPOINTMENT_NOTIFICATION */),
9332
- appointmentId: z18.string(),
9333
- appointmentStatus: z18.string(),
9334
- previousStatus: z18.string(),
9335
- reason: z18.string().optional()
9651
+ notificationType: z19.literal("appointmentNotification" /* APPOINTMENT_NOTIFICATION */),
9652
+ appointmentId: z19.string(),
9653
+ appointmentStatus: z19.string(),
9654
+ previousStatus: z19.string(),
9655
+ reason: z19.string().optional()
9336
9656
  });
9337
- var notificationSchema = z18.discriminatedUnion("notificationType", [
9657
+ var notificationSchema = z19.discriminatedUnion("notificationType", [
9338
9658
  preRequirementNotificationSchema,
9339
9659
  postRequirementNotificationSchema,
9340
9660
  appointmentReminderNotificationSchema,
@@ -9396,6 +9716,7 @@ export {
9396
9716
  PractitionerTokenStatus,
9397
9717
  PricingMeasure,
9398
9718
  ProcedureFamily,
9719
+ ProcedureService,
9399
9720
  REGISTER_TOKENS_COLLECTION,
9400
9721
  SYNCED_CALENDARS_COLLECTION,
9401
9722
  SubscriptionModel,