@blackcode_sa/metaestetics-api 1.5.7 → 1.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  AllergyType: () => AllergyType,
26
26
  AuthService: () => AuthService,
27
27
  BlockingCondition: () => BlockingCondition,
28
+ BrandService: () => BrandService,
28
29
  CALENDAR_COLLECTION: () => CALENDAR_COLLECTION,
29
30
  CLINICS_COLLECTION: () => CLINICS_COLLECTION,
30
31
  CLINIC_ADMINS_COLLECTION: () => CLINIC_ADMINS_COLLECTION,
@@ -33,6 +34,7 @@ __export(index_exports, {
33
34
  CalendarEventType: () => CalendarEventType,
34
35
  CalendarServiceV2: () => CalendarServiceV2,
35
36
  CalendarSyncStatus: () => CalendarSyncStatus,
37
+ CategoryService: () => CategoryService,
36
38
  CertificationLevel: () => CertificationLevel,
37
39
  CertificationSpecialty: () => CertificationSpecialty,
38
40
  ClinicAdminService: () => ClinicAdminService,
@@ -68,6 +70,7 @@ __export(index_exports, {
68
70
  PATIENT_MEDICAL_INFO_COLLECTION: () => PATIENT_MEDICAL_INFO_COLLECTION,
69
71
  PATIENT_SENSITIVE_INFO_COLLECTION: () => PATIENT_SENSITIVE_INFO_COLLECTION,
70
72
  PRACTITIONERS_COLLECTION: () => PRACTITIONERS_COLLECTION,
73
+ PROCEDURES_COLLECTION: () => PROCEDURES_COLLECTION,
71
74
  PatientService: () => PatientService,
72
75
  PracticeType: () => PracticeType,
73
76
  PractitionerService: () => PractitionerService,
@@ -76,11 +79,14 @@ __export(index_exports, {
76
79
  PricingMeasure: () => PricingMeasure,
77
80
  ProcedureFamily: () => ProcedureFamily,
78
81
  ProcedureService: () => ProcedureService,
82
+ ProductService: () => ProductService,
79
83
  REGISTER_TOKENS_COLLECTION: () => REGISTER_TOKENS_COLLECTION,
80
84
  SYNCED_CALENDARS_COLLECTION: () => SYNCED_CALENDARS_COLLECTION,
85
+ SubcategoryService: () => SubcategoryService,
81
86
  SubscriptionModel: () => SubscriptionModel,
82
87
  SyncedCalendarProvider: () => SyncedCalendarProvider,
83
88
  SyncedCalendarsService: () => SyncedCalendarsService,
89
+ TechnologyService: () => TechnologyService,
84
90
  TreatmentBenefit: () => TreatmentBenefit,
85
91
  USER_ERRORS: () => USER_ERRORS,
86
92
  UserService: () => UserService,
@@ -1434,9 +1440,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
1434
1440
  var updateAllergyUtil = async (db, patientId, data, userRef) => {
1435
1441
  const validatedData = updateAllergySchema.parse(data);
1436
1442
  const { allergyIndex, ...updateData } = validatedData;
1437
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1438
- if (!doc21.exists()) throw new Error("Medical info not found");
1439
- const medicalInfo = doc21.data();
1443
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1444
+ if (!doc26.exists()) throw new Error("Medical info not found");
1445
+ const medicalInfo = doc26.data();
1440
1446
  if (allergyIndex >= medicalInfo.allergies.length) {
1441
1447
  throw new Error("Invalid allergy index");
1442
1448
  }
@@ -1452,9 +1458,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
1452
1458
  });
1453
1459
  };
1454
1460
  var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
1455
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1456
- if (!doc21.exists()) throw new Error("Medical info not found");
1457
- const medicalInfo = doc21.data();
1461
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1462
+ if (!doc26.exists()) throw new Error("Medical info not found");
1463
+ const medicalInfo = doc26.data();
1458
1464
  if (allergyIndex >= medicalInfo.allergies.length) {
1459
1465
  throw new Error("Invalid allergy index");
1460
1466
  }
@@ -1479,9 +1485,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
1479
1485
  var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1480
1486
  const validatedData = updateBlockingConditionSchema.parse(data);
1481
1487
  const { conditionIndex, ...updateData } = validatedData;
1482
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1483
- if (!doc21.exists()) throw new Error("Medical info not found");
1484
- const medicalInfo = doc21.data();
1488
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1489
+ if (!doc26.exists()) throw new Error("Medical info not found");
1490
+ const medicalInfo = doc26.data();
1485
1491
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1486
1492
  throw new Error("Invalid blocking condition index");
1487
1493
  }
@@ -1497,9 +1503,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
1497
1503
  });
1498
1504
  };
1499
1505
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
1500
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1501
- if (!doc21.exists()) throw new Error("Medical info not found");
1502
- const medicalInfo = doc21.data();
1506
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1507
+ if (!doc26.exists()) throw new Error("Medical info not found");
1508
+ const medicalInfo = doc26.data();
1503
1509
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
1504
1510
  throw new Error("Invalid blocking condition index");
1505
1511
  }
@@ -1524,9 +1530,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
1524
1530
  var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1525
1531
  const validatedData = updateContraindicationSchema.parse(data);
1526
1532
  const { contraindicationIndex, ...updateData } = validatedData;
1527
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1528
- if (!doc21.exists()) throw new Error("Medical info not found");
1529
- const medicalInfo = doc21.data();
1533
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1534
+ if (!doc26.exists()) throw new Error("Medical info not found");
1535
+ const medicalInfo = doc26.data();
1530
1536
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1531
1537
  throw new Error("Invalid contraindication index");
1532
1538
  }
@@ -1542,9 +1548,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
1542
1548
  });
1543
1549
  };
1544
1550
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
1545
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1546
- if (!doc21.exists()) throw new Error("Medical info not found");
1547
- const medicalInfo = doc21.data();
1551
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1552
+ if (!doc26.exists()) throw new Error("Medical info not found");
1553
+ const medicalInfo = doc26.data();
1548
1554
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
1549
1555
  throw new Error("Invalid contraindication index");
1550
1556
  }
@@ -1569,9 +1575,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
1569
1575
  var updateMedicationUtil = async (db, patientId, data, userRef) => {
1570
1576
  const validatedData = updateMedicationSchema.parse(data);
1571
1577
  const { medicationIndex, ...updateData } = validatedData;
1572
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1573
- if (!doc21.exists()) throw new Error("Medical info not found");
1574
- const medicalInfo = doc21.data();
1578
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1579
+ if (!doc26.exists()) throw new Error("Medical info not found");
1580
+ const medicalInfo = doc26.data();
1575
1581
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1576
1582
  throw new Error("Invalid medication index");
1577
1583
  }
@@ -1587,9 +1593,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
1587
1593
  });
1588
1594
  };
1589
1595
  var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
1590
- const doc21 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1591
- if (!doc21.exists()) throw new Error("Medical info not found");
1592
- const medicalInfo = doc21.data();
1596
+ const doc26 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
1597
+ if (!doc26.exists()) throw new Error("Medical info not found");
1598
+ const medicalInfo = doc26.data();
1593
1599
  if (medicationIndex >= medicalInfo.currentMedications.length) {
1594
1600
  throw new Error("Invalid medication index");
1595
1601
  }
@@ -2883,7 +2889,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
2883
2889
  (0, import_firestore11.where)("clinicGroupId", "==", clinicGroupId)
2884
2890
  );
2885
2891
  const querySnapshot = await (0, import_firestore11.getDocs)(q);
2886
- return querySnapshot.docs.map((doc21) => doc21.data());
2892
+ return querySnapshot.docs.map((doc26) => doc26.data());
2887
2893
  }
2888
2894
  async function updateClinicAdmin(db, adminId, data) {
2889
2895
  const admin = await getClinicAdmin(db, adminId);
@@ -3181,16 +3187,16 @@ var CertificationLevel = /* @__PURE__ */ ((CertificationLevel2) => {
3181
3187
  CertificationLevel2["PLASTIC_SURGEON"] = "plastic_surgeon";
3182
3188
  return CertificationLevel2;
3183
3189
  })(CertificationLevel || {});
3184
- var CertificationSpecialty = /* @__PURE__ */ ((CertificationSpecialty2) => {
3185
- CertificationSpecialty2["LASER"] = "laser";
3186
- CertificationSpecialty2["INJECTABLES"] = "injectables";
3187
- CertificationSpecialty2["CHEMICAL_PEELS"] = "chemical_peels";
3188
- CertificationSpecialty2["MICRODERMABRASION"] = "microdermabrasion";
3189
- CertificationSpecialty2["BODY_CONTOURING"] = "body_contouring";
3190
- CertificationSpecialty2["SKIN_CARE"] = "skin_care";
3191
- CertificationSpecialty2["WOUND_CARE"] = "wound_care";
3192
- CertificationSpecialty2["ANESTHESIA"] = "anesthesia";
3193
- return CertificationSpecialty2;
3190
+ var CertificationSpecialty = /* @__PURE__ */ ((CertificationSpecialty3) => {
3191
+ CertificationSpecialty3["LASER"] = "laser";
3192
+ CertificationSpecialty3["INJECTABLES"] = "injectables";
3193
+ CertificationSpecialty3["CHEMICAL_PEELS"] = "chemical_peels";
3194
+ CertificationSpecialty3["MICRODERMABRASION"] = "microdermabrasion";
3195
+ CertificationSpecialty3["BODY_CONTOURING"] = "body_contouring";
3196
+ CertificationSpecialty3["SKIN_CARE"] = "skin_care";
3197
+ CertificationSpecialty3["WOUND_CARE"] = "wound_care";
3198
+ CertificationSpecialty3["ANESTHESIA"] = "anesthesia";
3199
+ return CertificationSpecialty3;
3194
3200
  })(CertificationSpecialty || {});
3195
3201
 
3196
3202
  // src/validations/practitioner.schema.ts
@@ -3538,7 +3544,7 @@ var PractitionerService = class extends BaseService {
3538
3544
  (0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
3539
3545
  );
3540
3546
  const querySnapshot = await (0, import_firestore13.getDocs)(q);
3541
- return querySnapshot.docs.map((doc21) => doc21.data());
3547
+ return querySnapshot.docs.map((doc26) => doc26.data());
3542
3548
  }
3543
3549
  /**
3544
3550
  * Gets a token by its string value and validates it
@@ -3621,7 +3627,7 @@ var PractitionerService = class extends BaseService {
3621
3627
  (0, import_firestore13.where)("status", "==", "active" /* ACTIVE */)
3622
3628
  );
3623
3629
  const querySnapshot = await (0, import_firestore13.getDocs)(q);
3624
- return querySnapshot.docs.map((doc21) => doc21.data());
3630
+ return querySnapshot.docs.map((doc26) => doc26.data());
3625
3631
  }
3626
3632
  /**
3627
3633
  * Dohvata sve draft zdravstvene radnike za određenu kliniku
@@ -3633,7 +3639,7 @@ var PractitionerService = class extends BaseService {
3633
3639
  (0, import_firestore13.where)("status", "==", "draft" /* DRAFT */)
3634
3640
  );
3635
3641
  const querySnapshot = await (0, import_firestore13.getDocs)(q);
3636
- return querySnapshot.docs.map((doc21) => doc21.data());
3642
+ return querySnapshot.docs.map((doc26) => doc26.data());
3637
3643
  }
3638
3644
  /**
3639
3645
  * Ažurira profil zdravstvenog radnika
@@ -3942,7 +3948,7 @@ var UserService = class extends BaseService {
3942
3948
  ];
3943
3949
  const q = (0, import_firestore14.query)((0, import_firestore14.collection)(this.db, USERS_COLLECTION), ...constraints);
3944
3950
  const querySnapshot = await (0, import_firestore14.getDocs)(q);
3945
- const users = querySnapshot.docs.map((doc21) => doc21.data());
3951
+ const users = querySnapshot.docs.map((doc26) => doc26.data());
3946
3952
  return Promise.all(users.map((userData) => userSchema.parse(userData)));
3947
3953
  }
3948
3954
  /**
@@ -4306,7 +4312,7 @@ async function getAllActiveGroups(db) {
4306
4312
  (0, import_firestore15.where)("isActive", "==", true)
4307
4313
  );
4308
4314
  const querySnapshot = await (0, import_firestore15.getDocs)(q);
4309
- return querySnapshot.docs.map((doc21) => doc21.data());
4315
+ return querySnapshot.docs.map((doc26) => doc26.data());
4310
4316
  }
4311
4317
  async function updateClinicGroup(db, groupId, data, app) {
4312
4318
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -4966,7 +4972,7 @@ async function getClinicsByGroup(db, groupId) {
4966
4972
  (0, import_firestore16.where)("isActive", "==", true)
4967
4973
  );
4968
4974
  const querySnapshot = await (0, import_firestore16.getDocs)(q);
4969
- return querySnapshot.docs.map((doc21) => doc21.data());
4975
+ return querySnapshot.docs.map((doc26) => doc26.data());
4970
4976
  }
4971
4977
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
4972
4978
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -5178,7 +5184,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
5178
5184
  }
5179
5185
  const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
5180
5186
  const querySnapshot = await (0, import_firestore16.getDocs)(q);
5181
- return querySnapshot.docs.map((doc21) => doc21.data());
5187
+ return querySnapshot.docs.map((doc26) => doc26.data());
5182
5188
  }
5183
5189
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
5184
5190
  return getClinicsByAdmin(
@@ -5320,8 +5326,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
5320
5326
  }
5321
5327
  const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
5322
5328
  const querySnapshot = await (0, import_firestore18.getDocs)(q);
5323
- for (const doc21 of querySnapshot.docs) {
5324
- const clinic = doc21.data();
5329
+ for (const doc26 of querySnapshot.docs) {
5330
+ const clinic = doc26.data();
5325
5331
  const distance = (0, import_geofire_common4.distanceBetween)(
5326
5332
  [center.latitude, center.longitude],
5327
5333
  [clinic.location.latitude, clinic.location.longitude]
@@ -6253,9 +6259,9 @@ var NotificationService = class extends BaseService {
6253
6259
  (0, import_firestore20.orderBy)("notificationTime", "desc")
6254
6260
  );
6255
6261
  const querySnapshot = await (0, import_firestore20.getDocs)(q);
6256
- return querySnapshot.docs.map((doc21) => ({
6257
- id: doc21.id,
6258
- ...doc21.data()
6262
+ return querySnapshot.docs.map((doc26) => ({
6263
+ id: doc26.id,
6264
+ ...doc26.data()
6259
6265
  }));
6260
6266
  }
6261
6267
  /**
@@ -6269,9 +6275,9 @@ var NotificationService = class extends BaseService {
6269
6275
  (0, import_firestore20.orderBy)("notificationTime", "desc")
6270
6276
  );
6271
6277
  const querySnapshot = await (0, import_firestore20.getDocs)(q);
6272
- return querySnapshot.docs.map((doc21) => ({
6273
- id: doc21.id,
6274
- ...doc21.data()
6278
+ return querySnapshot.docs.map((doc26) => ({
6279
+ id: doc26.id,
6280
+ ...doc26.data()
6275
6281
  }));
6276
6282
  }
6277
6283
  /**
@@ -6343,9 +6349,9 @@ var NotificationService = class extends BaseService {
6343
6349
  (0, import_firestore20.orderBy)("notificationTime", "desc")
6344
6350
  );
6345
6351
  const querySnapshot = await (0, import_firestore20.getDocs)(q);
6346
- return querySnapshot.docs.map((doc21) => ({
6347
- id: doc21.id,
6348
- ...doc21.data()
6352
+ return querySnapshot.docs.map((doc26) => ({
6353
+ id: doc26.id,
6354
+ ...doc26.data()
6349
6355
  }));
6350
6356
  }
6351
6357
  /**
@@ -6358,9 +6364,9 @@ var NotificationService = class extends BaseService {
6358
6364
  (0, import_firestore20.orderBy)("notificationTime", "desc")
6359
6365
  );
6360
6366
  const querySnapshot = await (0, import_firestore20.getDocs)(q);
6361
- return querySnapshot.docs.map((doc21) => ({
6362
- id: doc21.id,
6363
- ...doc21.data()
6367
+ return querySnapshot.docs.map((doc26) => ({
6368
+ id: doc26.id,
6369
+ ...doc26.data()
6364
6370
  }));
6365
6371
  }
6366
6372
  };
@@ -6510,7 +6516,7 @@ var ProcedureService = class extends BaseService {
6510
6516
  (0, import_firestore21.where)("isActive", "==", true)
6511
6517
  );
6512
6518
  const snapshot = await (0, import_firestore21.getDocs)(q);
6513
- return snapshot.docs.map((doc21) => doc21.data());
6519
+ return snapshot.docs.map((doc26) => doc26.data());
6514
6520
  }
6515
6521
  /**
6516
6522
  * Gets all procedures for a practitioner
@@ -6524,7 +6530,7 @@ var ProcedureService = class extends BaseService {
6524
6530
  (0, import_firestore21.where)("isActive", "==", true)
6525
6531
  );
6526
6532
  const snapshot = await (0, import_firestore21.getDocs)(q);
6527
- return snapshot.docs.map((doc21) => doc21.data());
6533
+ return snapshot.docs.map((doc26) => doc26.data());
6528
6534
  }
6529
6535
  /**
6530
6536
  * Updates a procedure
@@ -6710,9 +6716,9 @@ var DocumentationTemplateService = class extends BaseService {
6710
6716
  const querySnapshot = await (0, import_firestore22.getDocs)(q);
6711
6717
  const templates = [];
6712
6718
  let lastVisible = null;
6713
- querySnapshot.forEach((doc21) => {
6714
- templates.push(doc21.data());
6715
- lastVisible = doc21;
6719
+ querySnapshot.forEach((doc26) => {
6720
+ templates.push(doc26.data());
6721
+ lastVisible = doc26;
6716
6722
  });
6717
6723
  return {
6718
6724
  templates,
@@ -6740,9 +6746,9 @@ var DocumentationTemplateService = class extends BaseService {
6740
6746
  const querySnapshot = await (0, import_firestore22.getDocs)(q);
6741
6747
  const templates = [];
6742
6748
  let lastVisible = null;
6743
- querySnapshot.forEach((doc21) => {
6744
- templates.push(doc21.data());
6745
- lastVisible = doc21;
6749
+ querySnapshot.forEach((doc26) => {
6750
+ templates.push(doc26.data());
6751
+ lastVisible = doc26;
6746
6752
  });
6747
6753
  return {
6748
6754
  templates,
@@ -6769,9 +6775,9 @@ var DocumentationTemplateService = class extends BaseService {
6769
6775
  const querySnapshot = await (0, import_firestore22.getDocs)(q);
6770
6776
  const templates = [];
6771
6777
  let lastVisible = null;
6772
- querySnapshot.forEach((doc21) => {
6773
- templates.push(doc21.data());
6774
- lastVisible = doc21;
6778
+ querySnapshot.forEach((doc26) => {
6779
+ templates.push(doc26.data());
6780
+ lastVisible = doc26;
6775
6781
  });
6776
6782
  return {
6777
6783
  templates,
@@ -6884,9 +6890,9 @@ var FilledDocumentService = class extends BaseService {
6884
6890
  const querySnapshot = await (0, import_firestore23.getDocs)(q);
6885
6891
  const documents = [];
6886
6892
  let lastVisible = null;
6887
- querySnapshot.forEach((doc21) => {
6888
- documents.push(doc21.data());
6889
- lastVisible = doc21;
6893
+ querySnapshot.forEach((doc26) => {
6894
+ documents.push(doc26.data());
6895
+ lastVisible = doc26;
6890
6896
  });
6891
6897
  return {
6892
6898
  documents,
@@ -6913,9 +6919,9 @@ var FilledDocumentService = class extends BaseService {
6913
6919
  const querySnapshot = await (0, import_firestore23.getDocs)(q);
6914
6920
  const documents = [];
6915
6921
  let lastVisible = null;
6916
- querySnapshot.forEach((doc21) => {
6917
- documents.push(doc21.data());
6918
- lastVisible = doc21;
6922
+ querySnapshot.forEach((doc26) => {
6923
+ documents.push(doc26.data());
6924
+ lastVisible = doc26;
6919
6925
  });
6920
6926
  return {
6921
6927
  documents,
@@ -6942,9 +6948,9 @@ var FilledDocumentService = class extends BaseService {
6942
6948
  const querySnapshot = await (0, import_firestore23.getDocs)(q);
6943
6949
  const documents = [];
6944
6950
  let lastVisible = null;
6945
- querySnapshot.forEach((doc21) => {
6946
- documents.push(doc21.data());
6947
- lastVisible = doc21;
6951
+ querySnapshot.forEach((doc26) => {
6952
+ documents.push(doc26.data());
6953
+ lastVisible = doc26;
6948
6954
  });
6949
6955
  return {
6950
6956
  documents,
@@ -6971,9 +6977,9 @@ var FilledDocumentService = class extends BaseService {
6971
6977
  const querySnapshot = await (0, import_firestore23.getDocs)(q);
6972
6978
  const documents = [];
6973
6979
  let lastVisible = null;
6974
- querySnapshot.forEach((doc21) => {
6975
- documents.push(doc21.data());
6976
- lastVisible = doc21;
6980
+ querySnapshot.forEach((doc26) => {
6981
+ documents.push(doc26.data());
6982
+ lastVisible = doc26;
6977
6983
  });
6978
6984
  return {
6979
6985
  documents,
@@ -7000,9 +7006,9 @@ var FilledDocumentService = class extends BaseService {
7000
7006
  const querySnapshot = await (0, import_firestore23.getDocs)(q);
7001
7007
  const documents = [];
7002
7008
  let lastVisible = null;
7003
- querySnapshot.forEach((doc21) => {
7004
- documents.push(doc21.data());
7005
- lastVisible = doc21;
7009
+ querySnapshot.forEach((doc26) => {
7010
+ documents.push(doc26.data());
7011
+ lastVisible = doc26;
7006
7012
  });
7007
7013
  return {
7008
7014
  documents,
@@ -7505,7 +7511,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
7505
7511
  );
7506
7512
  const q = (0, import_firestore30.query)(calendarsRef, (0, import_firestore30.orderBy)("createdAt", "desc"));
7507
7513
  const querySnapshot = await (0, import_firestore30.getDocs)(q);
7508
- return querySnapshot.docs.map((doc21) => doc21.data());
7514
+ return querySnapshot.docs.map((doc26) => doc26.data());
7509
7515
  }
7510
7516
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
7511
7517
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
@@ -7522,7 +7528,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
7522
7528
  );
7523
7529
  const q = (0, import_firestore30.query)(calendarsRef, (0, import_firestore30.orderBy)("createdAt", "desc"));
7524
7530
  const querySnapshot = await (0, import_firestore30.getDocs)(q);
7525
- return querySnapshot.docs.map((doc21) => doc21.data());
7531
+ return querySnapshot.docs.map((doc26) => doc26.data());
7526
7532
  }
7527
7533
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
7528
7534
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
@@ -7539,7 +7545,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
7539
7545
  );
7540
7546
  const q = (0, import_firestore30.query)(calendarsRef, (0, import_firestore30.orderBy)("createdAt", "desc"));
7541
7547
  const querySnapshot = await (0, import_firestore30.getDocs)(q);
7542
- return querySnapshot.docs.map((doc21) => doc21.data());
7548
+ return querySnapshot.docs.map((doc26) => doc26.data());
7543
7549
  }
7544
7550
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
7545
7551
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -8894,9 +8900,9 @@ var CalendarServiceV2 = class extends BaseService {
8894
8900
  (0, import_firestore33.where)("eventTime.start", "<=", import_firestore32.Timestamp.fromDate(endDate))
8895
8901
  );
8896
8902
  const eventsSnapshot = await (0, import_firestore33.getDocs)(q);
8897
- const events = eventsSnapshot.docs.map((doc21) => ({
8898
- id: doc21.id,
8899
- ...doc21.data()
8903
+ const events = eventsSnapshot.docs.map((doc26) => ({
8904
+ id: doc26.id,
8905
+ ...doc26.data()
8900
8906
  }));
8901
8907
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
8902
8908
  doctorId
@@ -9429,7 +9435,7 @@ var CalendarServiceV2 = class extends BaseService {
9429
9435
  ])
9430
9436
  );
9431
9437
  const querySnapshot = await (0, import_firestore33.getDocs)(q);
9432
- return querySnapshot.docs.map((doc21) => doc21.data());
9438
+ return querySnapshot.docs.map((doc26) => doc26.data());
9433
9439
  }
9434
9440
  /**
9435
9441
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -9553,6 +9559,758 @@ var CalendarServiceV2 = class extends BaseService {
9553
9559
  // #endregion
9554
9560
  };
9555
9561
 
9562
+ // src/backoffice/services/brand.service.ts
9563
+ var import_firestore34 = require("firebase/firestore");
9564
+
9565
+ // src/backoffice/types/brand.types.ts
9566
+ var BRANDS_COLLECTION = "brands";
9567
+
9568
+ // src/backoffice/services/brand.service.ts
9569
+ var BrandService = class extends BaseService {
9570
+ get brandsRef() {
9571
+ return (0, import_firestore34.collection)(this.db, BRANDS_COLLECTION);
9572
+ }
9573
+ async create(brand) {
9574
+ const now = /* @__PURE__ */ new Date();
9575
+ const newBrand = {
9576
+ ...brand,
9577
+ createdAt: now,
9578
+ updatedAt: now,
9579
+ isActive: true
9580
+ };
9581
+ const docRef = await (0, import_firestore34.addDoc)(this.brandsRef, newBrand);
9582
+ return { id: docRef.id, ...newBrand };
9583
+ }
9584
+ async getAll() {
9585
+ const q = (0, import_firestore34.query)(this.brandsRef, (0, import_firestore34.where)("isActive", "==", true));
9586
+ const snapshot = await (0, import_firestore34.getDocs)(q);
9587
+ return snapshot.docs.map(
9588
+ (doc26) => ({
9589
+ id: doc26.id,
9590
+ ...doc26.data()
9591
+ })
9592
+ );
9593
+ }
9594
+ async update(id, brand) {
9595
+ const updateData = {
9596
+ ...brand,
9597
+ updatedAt: /* @__PURE__ */ new Date()
9598
+ };
9599
+ const docRef = (0, import_firestore34.doc)(this.brandsRef, id);
9600
+ await (0, import_firestore34.updateDoc)(docRef, updateData);
9601
+ return this.getById(id);
9602
+ }
9603
+ async delete(id) {
9604
+ await this.update(id, { isActive: false });
9605
+ }
9606
+ async getById(id) {
9607
+ const docRef = (0, import_firestore34.doc)(this.brandsRef, id);
9608
+ const docSnap = await (0, import_firestore34.getDoc)(docRef);
9609
+ if (!docSnap.exists()) return null;
9610
+ return {
9611
+ id: docSnap.id,
9612
+ ...docSnap.data()
9613
+ };
9614
+ }
9615
+ };
9616
+
9617
+ // src/backoffice/services/category.service.ts
9618
+ var import_firestore35 = require("firebase/firestore");
9619
+ var CategoryService = class extends BaseService {
9620
+ /**
9621
+ * Referenca na Firestore kolekciju kategorija
9622
+ */
9623
+ get categoriesRef() {
9624
+ return (0, import_firestore35.collection)(this.db, CATEGORIES_COLLECTION);
9625
+ }
9626
+ /**
9627
+ * Kreira novu kategoriju u sistemu
9628
+ * @param category - Podaci za novu kategoriju
9629
+ * @returns Kreirana kategorija sa generisanim ID-em
9630
+ */
9631
+ async create(category) {
9632
+ const now = /* @__PURE__ */ new Date();
9633
+ const newCategory = {
9634
+ ...category,
9635
+ createdAt: now,
9636
+ updatedAt: now,
9637
+ isActive: true
9638
+ };
9639
+ const docRef = await (0, import_firestore35.addDoc)(this.categoriesRef, newCategory);
9640
+ return { id: docRef.id, ...newCategory };
9641
+ }
9642
+ /**
9643
+ * Vraća sve aktivne kategorije
9644
+ * @returns Lista aktivnih kategorija
9645
+ */
9646
+ async getAll() {
9647
+ const q = (0, import_firestore35.query)(this.categoriesRef, (0, import_firestore35.where)("isActive", "==", true));
9648
+ const snapshot = await (0, import_firestore35.getDocs)(q);
9649
+ return snapshot.docs.map(
9650
+ (doc26) => ({
9651
+ id: doc26.id,
9652
+ ...doc26.data()
9653
+ })
9654
+ );
9655
+ }
9656
+ /**
9657
+ * Vraća sve aktivne kategorije za određenu familiju procedura
9658
+ * @param family - Familija procedura (aesthetics/surgery)
9659
+ * @returns Lista kategorija koje pripadaju traženoj familiji
9660
+ */
9661
+ async getAllByFamily(family) {
9662
+ const q = (0, import_firestore35.query)(
9663
+ this.categoriesRef,
9664
+ (0, import_firestore35.where)("family", "==", family),
9665
+ (0, import_firestore35.where)("isActive", "==", true)
9666
+ );
9667
+ const snapshot = await (0, import_firestore35.getDocs)(q);
9668
+ return snapshot.docs.map(
9669
+ (doc26) => ({
9670
+ id: doc26.id,
9671
+ ...doc26.data()
9672
+ })
9673
+ );
9674
+ }
9675
+ /**
9676
+ * Ažurira postojeću kategoriju
9677
+ * @param id - ID kategorije koja se ažurira
9678
+ * @param category - Novi podaci za kategoriju
9679
+ * @returns Ažurirana kategorija
9680
+ */
9681
+ async update(id, category) {
9682
+ const updateData = {
9683
+ ...category,
9684
+ updatedAt: /* @__PURE__ */ new Date()
9685
+ };
9686
+ const docRef = (0, import_firestore35.doc)(this.categoriesRef, id);
9687
+ await (0, import_firestore35.updateDoc)(docRef, updateData);
9688
+ return this.getById(id);
9689
+ }
9690
+ /**
9691
+ * Soft delete kategorije (postavlja isActive na false)
9692
+ * @param id - ID kategorije koja se briše
9693
+ */
9694
+ async delete(id) {
9695
+ await this.update(id, { isActive: false });
9696
+ }
9697
+ /**
9698
+ * Vraća kategoriju po ID-u
9699
+ * @param id - ID tražene kategorije
9700
+ * @returns Kategorija ili null ako ne postoji
9701
+ */
9702
+ async getById(id) {
9703
+ const docRef = (0, import_firestore35.doc)(this.categoriesRef, id);
9704
+ const docSnap = await (0, import_firestore35.getDoc)(docRef);
9705
+ if (!docSnap.exists()) return null;
9706
+ return {
9707
+ id: docSnap.id,
9708
+ ...docSnap.data()
9709
+ };
9710
+ }
9711
+ };
9712
+
9713
+ // src/backoffice/services/subcategory.service.ts
9714
+ var import_firestore36 = require("firebase/firestore");
9715
+ var SubcategoryService = class extends BaseService {
9716
+ /**
9717
+ * Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
9718
+ * @param categoryId - ID roditeljske kategorije
9719
+ */
9720
+ getSubcategoriesRef(categoryId) {
9721
+ return (0, import_firestore36.collection)(
9722
+ this.db,
9723
+ CATEGORIES_COLLECTION,
9724
+ categoryId,
9725
+ SUBCATEGORIES_COLLECTION
9726
+ );
9727
+ }
9728
+ /**
9729
+ * Kreira novu podkategoriju u okviru kategorije
9730
+ * @param categoryId - ID kategorije kojoj će pripadati nova podkategorija
9731
+ * @param subcategory - Podaci za novu podkategoriju
9732
+ * @returns Kreirana podkategorija sa generisanim ID-em
9733
+ */
9734
+ async create(categoryId, subcategory) {
9735
+ const now = /* @__PURE__ */ new Date();
9736
+ const newSubcategory = {
9737
+ ...subcategory,
9738
+ categoryId,
9739
+ createdAt: now,
9740
+ updatedAt: now,
9741
+ isActive: true
9742
+ };
9743
+ const docRef = await (0, import_firestore36.addDoc)(
9744
+ this.getSubcategoriesRef(categoryId),
9745
+ newSubcategory
9746
+ );
9747
+ return { id: docRef.id, ...newSubcategory };
9748
+ }
9749
+ /**
9750
+ * Vraća sve aktivne podkategorije za određenu kategoriju
9751
+ * @param categoryId - ID kategorije čije podkategorije tražimo
9752
+ * @returns Lista aktivnih podkategorija
9753
+ */
9754
+ async getAllByCategoryId(categoryId) {
9755
+ const q = (0, import_firestore36.query)(
9756
+ this.getSubcategoriesRef(categoryId),
9757
+ (0, import_firestore36.where)("isActive", "==", true)
9758
+ );
9759
+ const snapshot = await (0, import_firestore36.getDocs)(q);
9760
+ return snapshot.docs.map(
9761
+ (doc26) => ({
9762
+ id: doc26.id,
9763
+ ...doc26.data()
9764
+ })
9765
+ );
9766
+ }
9767
+ /**
9768
+ * Ažurira postojeću podkategoriju
9769
+ * @param categoryId - ID kategorije kojoj pripada podkategorija
9770
+ * @param subcategoryId - ID podkategorije koja se ažurira
9771
+ * @param subcategory - Novi podaci za podkategoriju
9772
+ * @returns Ažurirana podkategorija
9773
+ */
9774
+ async update(categoryId, subcategoryId, subcategory) {
9775
+ const updateData = {
9776
+ ...subcategory,
9777
+ updatedAt: /* @__PURE__ */ new Date()
9778
+ };
9779
+ const docRef = (0, import_firestore36.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
9780
+ await (0, import_firestore36.updateDoc)(docRef, updateData);
9781
+ return this.getById(categoryId, subcategoryId);
9782
+ }
9783
+ /**
9784
+ * Soft delete podkategorije (postavlja isActive na false)
9785
+ * @param categoryId - ID kategorije kojoj pripada podkategorija
9786
+ * @param subcategoryId - ID podkategorije koja se briše
9787
+ */
9788
+ async delete(categoryId, subcategoryId) {
9789
+ await this.update(categoryId, subcategoryId, { isActive: false });
9790
+ }
9791
+ /**
9792
+ * Vraća podkategoriju po ID-u
9793
+ * @param categoryId - ID kategorije kojoj pripada podkategorija
9794
+ * @param subcategoryId - ID tražene podkategorije
9795
+ * @returns Podkategorija ili null ako ne postoji
9796
+ */
9797
+ async getById(categoryId, subcategoryId) {
9798
+ const docRef = (0, import_firestore36.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
9799
+ const docSnap = await (0, import_firestore36.getDoc)(docRef);
9800
+ if (!docSnap.exists()) return null;
9801
+ return {
9802
+ id: docSnap.id,
9803
+ ...docSnap.data()
9804
+ };
9805
+ }
9806
+ };
9807
+
9808
+ // src/backoffice/services/technology.service.ts
9809
+ var import_firestore37 = require("firebase/firestore");
9810
+ var DEFAULT_CERTIFICATION_REQUIREMENT = {
9811
+ minimumLevel: "aesthetician" /* AESTHETICIAN */,
9812
+ requiredSpecialties: []
9813
+ };
9814
+ var TechnologyService = class extends BaseService {
9815
+ /**
9816
+ * Vraća referencu na Firestore kolekciju tehnologija za određenu podkategoriju
9817
+ * @param categoryId - ID kategorije
9818
+ * @param subcategoryId - ID podkategorije
9819
+ */
9820
+ getTechnologiesRef(categoryId, subcategoryId) {
9821
+ return (0, import_firestore37.collection)(
9822
+ this.db,
9823
+ CATEGORIES_COLLECTION,
9824
+ categoryId,
9825
+ SUBCATEGORIES_COLLECTION,
9826
+ subcategoryId,
9827
+ TECHNOLOGIES_COLLECTION
9828
+ );
9829
+ }
9830
+ /**
9831
+ * Kreira novu tehnologiju u okviru podkategorije
9832
+ * @param categoryId - ID kategorije
9833
+ * @param subcategoryId - ID podkategorije
9834
+ * @param technology - Podaci za novu tehnologiju
9835
+ * @returns Kreirana tehnologija sa generisanim ID-em
9836
+ */
9837
+ async create(categoryId, subcategoryId, technology) {
9838
+ const now = /* @__PURE__ */ new Date();
9839
+ const newTechnology = {
9840
+ ...technology,
9841
+ subcategoryId,
9842
+ createdAt: now,
9843
+ updatedAt: now,
9844
+ isActive: true,
9845
+ requirements: {
9846
+ pre: [],
9847
+ post: []
9848
+ },
9849
+ blockingConditions: [],
9850
+ contraindications: [],
9851
+ benefits: [],
9852
+ certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
9853
+ };
9854
+ const docRef = await (0, import_firestore37.addDoc)(
9855
+ this.getTechnologiesRef(categoryId, subcategoryId),
9856
+ newTechnology
9857
+ );
9858
+ return { id: docRef.id, ...newTechnology };
9859
+ }
9860
+ /**
9861
+ * Vraća sve aktivne tehnologije za određenu podkategoriju
9862
+ * @param categoryId - ID kategorije
9863
+ * @param subcategoryId - ID podkategorije
9864
+ * @returns Lista aktivnih tehnologija
9865
+ */
9866
+ async getAllBySubcategoryId(categoryId, subcategoryId) {
9867
+ const q = (0, import_firestore37.query)(
9868
+ this.getTechnologiesRef(categoryId, subcategoryId),
9869
+ (0, import_firestore37.where)("isActive", "==", true)
9870
+ );
9871
+ const snapshot = await (0, import_firestore37.getDocs)(q);
9872
+ return snapshot.docs.map(
9873
+ (doc26) => ({
9874
+ id: doc26.id,
9875
+ ...doc26.data()
9876
+ })
9877
+ );
9878
+ }
9879
+ /**
9880
+ * Ažurira postojeću tehnologiju
9881
+ * @param categoryId - ID kategorije
9882
+ * @param subcategoryId - ID podkategorije
9883
+ * @param technologyId - ID tehnologije
9884
+ * @param technology - Novi podaci za tehnologiju
9885
+ * @returns Ažurirana tehnologija
9886
+ */
9887
+ async update(categoryId, subcategoryId, technologyId, technology) {
9888
+ const updateData = {
9889
+ ...technology,
9890
+ updatedAt: /* @__PURE__ */ new Date()
9891
+ };
9892
+ const docRef = (0, import_firestore37.doc)(
9893
+ this.getTechnologiesRef(categoryId, subcategoryId),
9894
+ technologyId
9895
+ );
9896
+ await (0, import_firestore37.updateDoc)(docRef, updateData);
9897
+ return this.getById(categoryId, subcategoryId, technologyId);
9898
+ }
9899
+ /**
9900
+ * Soft delete tehnologije (postavlja isActive na false)
9901
+ * @param categoryId - ID kategorije
9902
+ * @param subcategoryId - ID podkategorije
9903
+ * @param technologyId - ID tehnologije koja se briše
9904
+ */
9905
+ async delete(categoryId, subcategoryId, technologyId) {
9906
+ await this.update(categoryId, subcategoryId, technologyId, {
9907
+ isActive: false
9908
+ });
9909
+ }
9910
+ /**
9911
+ * Vraća tehnologiju po ID-u
9912
+ * @param categoryId - ID kategorije
9913
+ * @param subcategoryId - ID podkategorije
9914
+ * @param technologyId - ID tražene tehnologije
9915
+ * @returns Tehnologija ili null ako ne postoji
9916
+ */
9917
+ async getById(categoryId, subcategoryId, technologyId) {
9918
+ const docRef = (0, import_firestore37.doc)(
9919
+ this.getTechnologiesRef(categoryId, subcategoryId),
9920
+ technologyId
9921
+ );
9922
+ const docSnap = await (0, import_firestore37.getDoc)(docRef);
9923
+ if (!docSnap.exists()) return null;
9924
+ return {
9925
+ id: docSnap.id,
9926
+ ...docSnap.data()
9927
+ };
9928
+ }
9929
+ /**
9930
+ * Dodaje novi zahtev tehnologiji
9931
+ * @param categoryId - ID kategorije
9932
+ * @param subcategoryId - ID podkategorije
9933
+ * @param technologyId - ID tehnologije
9934
+ * @param requirement - Zahtev koji se dodaje
9935
+ * @returns Ažurirana tehnologija sa novim zahtevom
9936
+ */
9937
+ async addRequirement(categoryId, subcategoryId, technologyId, requirement) {
9938
+ const docRef = (0, import_firestore37.doc)(
9939
+ this.getTechnologiesRef(categoryId, subcategoryId),
9940
+ technologyId
9941
+ );
9942
+ const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
9943
+ await (0, import_firestore37.updateDoc)(docRef, {
9944
+ [requirementType]: (0, import_firestore37.arrayUnion)(requirement),
9945
+ updatedAt: /* @__PURE__ */ new Date()
9946
+ });
9947
+ return this.getById(categoryId, subcategoryId, technologyId);
9948
+ }
9949
+ /**
9950
+ * Uklanja zahtev iz tehnologije
9951
+ * @param categoryId - ID kategorije
9952
+ * @param subcategoryId - ID podkategorije
9953
+ * @param technologyId - ID tehnologije
9954
+ * @param requirement - Zahtev koji se uklanja
9955
+ * @returns Ažurirana tehnologija bez uklonjenog zahteva
9956
+ */
9957
+ async removeRequirement(categoryId, subcategoryId, technologyId, requirement) {
9958
+ const docRef = (0, import_firestore37.doc)(
9959
+ this.getTechnologiesRef(categoryId, subcategoryId),
9960
+ technologyId
9961
+ );
9962
+ const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
9963
+ await (0, import_firestore37.updateDoc)(docRef, {
9964
+ [requirementType]: (0, import_firestore37.arrayRemove)(requirement),
9965
+ updatedAt: /* @__PURE__ */ new Date()
9966
+ });
9967
+ return this.getById(categoryId, subcategoryId, technologyId);
9968
+ }
9969
+ /**
9970
+ * Vraća sve zahteve za tehnologiju
9971
+ * @param categoryId - ID kategorije
9972
+ * @param subcategoryId - ID podkategorije
9973
+ * @param technologyId - ID tehnologije
9974
+ * @param type - Opcioni filter za tip zahteva (pre/post)
9975
+ * @returns Lista zahteva
9976
+ */
9977
+ async getRequirements(categoryId, subcategoryId, technologyId, type) {
9978
+ const technology = await this.getById(
9979
+ categoryId,
9980
+ subcategoryId,
9981
+ technologyId
9982
+ );
9983
+ if (!technology || !technology.requirements) return [];
9984
+ if (type) {
9985
+ return technology.requirements[type];
9986
+ }
9987
+ return [...technology.requirements.pre, ...technology.requirements.post];
9988
+ }
9989
+ /**
9990
+ * Ažurira postojeći zahtev
9991
+ * @param categoryId - ID kategorije
9992
+ * @param subcategoryId - ID podkategorije
9993
+ * @param technologyId - ID tehnologije
9994
+ * @param oldRequirement - Stari zahtev koji se menja
9995
+ * @param newRequirement - Novi zahtev koji zamenjuje stari
9996
+ * @returns Ažurirana tehnologija
9997
+ */
9998
+ async updateRequirement(categoryId, subcategoryId, technologyId, oldRequirement, newRequirement) {
9999
+ await this.removeRequirement(
10000
+ categoryId,
10001
+ subcategoryId,
10002
+ technologyId,
10003
+ oldRequirement
10004
+ );
10005
+ return this.addRequirement(
10006
+ categoryId,
10007
+ subcategoryId,
10008
+ technologyId,
10009
+ newRequirement
10010
+ );
10011
+ }
10012
+ /**
10013
+ * Dodaje blokirajući uslov tehnologiji
10014
+ * @param categoryId - ID kategorije
10015
+ * @param subcategoryId - ID podkategorije
10016
+ * @param technologyId - ID tehnologije
10017
+ * @param condition - Blokirajući uslov koji se dodaje
10018
+ * @returns Ažurirana tehnologija
10019
+ */
10020
+ async addBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
10021
+ const docRef = (0, import_firestore37.doc)(
10022
+ this.getTechnologiesRef(categoryId, subcategoryId),
10023
+ technologyId
10024
+ );
10025
+ await (0, import_firestore37.updateDoc)(docRef, {
10026
+ blockingConditions: (0, import_firestore37.arrayUnion)(condition),
10027
+ updatedAt: /* @__PURE__ */ new Date()
10028
+ });
10029
+ return this.getById(categoryId, subcategoryId, technologyId);
10030
+ }
10031
+ /**
10032
+ * Uklanja blokirajući uslov iz tehnologije
10033
+ * @param categoryId - ID kategorije
10034
+ * @param subcategoryId - ID podkategorije
10035
+ * @param technologyId - ID tehnologije
10036
+ * @param condition - Blokirajući uslov koji se uklanja
10037
+ * @returns Ažurirana tehnologija
10038
+ */
10039
+ async removeBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
10040
+ const docRef = (0, import_firestore37.doc)(
10041
+ this.getTechnologiesRef(categoryId, subcategoryId),
10042
+ technologyId
10043
+ );
10044
+ await (0, import_firestore37.updateDoc)(docRef, {
10045
+ blockingConditions: (0, import_firestore37.arrayRemove)(condition),
10046
+ updatedAt: /* @__PURE__ */ new Date()
10047
+ });
10048
+ return this.getById(categoryId, subcategoryId, technologyId);
10049
+ }
10050
+ /**
10051
+ * Dodaje kontraindikaciju tehnologiji
10052
+ * @param categoryId - ID kategorije
10053
+ * @param subcategoryId - ID podkategorije
10054
+ * @param technologyId - ID tehnologije
10055
+ * @param contraindication - Kontraindikacija koja se dodaje
10056
+ * @returns Ažurirana tehnologija
10057
+ */
10058
+ async addContraindication(categoryId, subcategoryId, technologyId, contraindication) {
10059
+ const docRef = (0, import_firestore37.doc)(
10060
+ this.getTechnologiesRef(categoryId, subcategoryId),
10061
+ technologyId
10062
+ );
10063
+ await (0, import_firestore37.updateDoc)(docRef, {
10064
+ contraindications: (0, import_firestore37.arrayUnion)(contraindication),
10065
+ updatedAt: /* @__PURE__ */ new Date()
10066
+ });
10067
+ return this.getById(categoryId, subcategoryId, technologyId);
10068
+ }
10069
+ /**
10070
+ * Uklanja kontraindikaciju iz tehnologije
10071
+ * @param categoryId - ID kategorije
10072
+ * @param subcategoryId - ID podkategorije
10073
+ * @param technologyId - ID tehnologije
10074
+ * @param contraindication - Kontraindikacija koja se uklanja
10075
+ * @returns Ažurirana tehnologija
10076
+ */
10077
+ async removeContraindication(categoryId, subcategoryId, technologyId, contraindication) {
10078
+ const docRef = (0, import_firestore37.doc)(
10079
+ this.getTechnologiesRef(categoryId, subcategoryId),
10080
+ technologyId
10081
+ );
10082
+ await (0, import_firestore37.updateDoc)(docRef, {
10083
+ contraindications: (0, import_firestore37.arrayRemove)(contraindication),
10084
+ updatedAt: /* @__PURE__ */ new Date()
10085
+ });
10086
+ return this.getById(categoryId, subcategoryId, technologyId);
10087
+ }
10088
+ /**
10089
+ * Dodaje benefit tehnologiji
10090
+ * @param categoryId - ID kategorije
10091
+ * @param subcategoryId - ID podkategorije
10092
+ * @param technologyId - ID tehnologije
10093
+ * @param benefit - Benefit koji se dodaje
10094
+ * @returns Ažurirana tehnologija
10095
+ */
10096
+ async addBenefit(categoryId, subcategoryId, technologyId, benefit) {
10097
+ const docRef = (0, import_firestore37.doc)(
10098
+ this.getTechnologiesRef(categoryId, subcategoryId),
10099
+ technologyId
10100
+ );
10101
+ await (0, import_firestore37.updateDoc)(docRef, {
10102
+ benefits: (0, import_firestore37.arrayUnion)(benefit),
10103
+ updatedAt: /* @__PURE__ */ new Date()
10104
+ });
10105
+ return this.getById(categoryId, subcategoryId, technologyId);
10106
+ }
10107
+ /**
10108
+ * Uklanja benefit iz tehnologije
10109
+ * @param categoryId - ID kategorije
10110
+ * @param subcategoryId - ID podkategorije
10111
+ * @param technologyId - ID tehnologije
10112
+ * @param benefit - Benefit koji se uklanja
10113
+ * @returns Ažurirana tehnologija
10114
+ */
10115
+ async removeBenefit(categoryId, subcategoryId, technologyId, benefit) {
10116
+ const docRef = (0, import_firestore37.doc)(
10117
+ this.getTechnologiesRef(categoryId, subcategoryId),
10118
+ technologyId
10119
+ );
10120
+ await (0, import_firestore37.updateDoc)(docRef, {
10121
+ benefits: (0, import_firestore37.arrayRemove)(benefit),
10122
+ updatedAt: /* @__PURE__ */ new Date()
10123
+ });
10124
+ return this.getById(categoryId, subcategoryId, technologyId);
10125
+ }
10126
+ /**
10127
+ * Vraća sve blokirajuće uslove za tehnologiju
10128
+ * @param categoryId - ID kategorije
10129
+ * @param subcategoryId - ID podkategorije
10130
+ * @param technologyId - ID tehnologije
10131
+ * @returns Lista blokirajućih uslova
10132
+ */
10133
+ async getBlockingConditions(categoryId, subcategoryId, technologyId) {
10134
+ const technology = await this.getById(
10135
+ categoryId,
10136
+ subcategoryId,
10137
+ technologyId
10138
+ );
10139
+ return (technology == null ? void 0 : technology.blockingConditions) || [];
10140
+ }
10141
+ /**
10142
+ * Vraća sve kontraindikacije za tehnologiju
10143
+ * @param categoryId - ID kategorije
10144
+ * @param subcategoryId - ID podkategorije
10145
+ * @param technologyId - ID tehnologije
10146
+ * @returns Lista kontraindikacija
10147
+ */
10148
+ async getContraindications(categoryId, subcategoryId, technologyId) {
10149
+ const technology = await this.getById(
10150
+ categoryId,
10151
+ subcategoryId,
10152
+ technologyId
10153
+ );
10154
+ return (technology == null ? void 0 : technology.contraindications) || [];
10155
+ }
10156
+ /**
10157
+ * Vraća sve benefite za tehnologiju
10158
+ * @param categoryId - ID kategorije
10159
+ * @param subcategoryId - ID podkategorije
10160
+ * @param technologyId - ID tehnologije
10161
+ * @returns Lista benefita
10162
+ */
10163
+ async getBenefits(categoryId, subcategoryId, technologyId) {
10164
+ const technology = await this.getById(
10165
+ categoryId,
10166
+ subcategoryId,
10167
+ technologyId
10168
+ );
10169
+ return (technology == null ? void 0 : technology.benefits) || [];
10170
+ }
10171
+ /**
10172
+ * Ažurira zahteve sertifikacije za tehnologiju
10173
+ * @param categoryId - ID kategorije
10174
+ * @param subcategoryId - ID podkategorije
10175
+ * @param technologyId - ID tehnologije
10176
+ * @param certificationRequirement - Novi zahtevi sertifikacije
10177
+ * @returns Ažurirana tehnologija
10178
+ */
10179
+ async updateCertificationRequirement(categoryId, subcategoryId, technologyId, certificationRequirement) {
10180
+ const docRef = (0, import_firestore37.doc)(
10181
+ this.getTechnologiesRef(categoryId, subcategoryId),
10182
+ technologyId
10183
+ );
10184
+ await (0, import_firestore37.updateDoc)(docRef, {
10185
+ certificationRequirement,
10186
+ updatedAt: /* @__PURE__ */ new Date()
10187
+ });
10188
+ return this.getById(categoryId, subcategoryId, technologyId);
10189
+ }
10190
+ /**
10191
+ * Vraća zahteve sertifikacije za tehnologiju
10192
+ * @param categoryId - ID kategorije
10193
+ * @param subcategoryId - ID podkategorije
10194
+ * @param technologyId - ID tehnologije
10195
+ * @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
10196
+ */
10197
+ async getCertificationRequirement(categoryId, subcategoryId, technologyId) {
10198
+ const technology = await this.getById(
10199
+ categoryId,
10200
+ subcategoryId,
10201
+ technologyId
10202
+ );
10203
+ return (technology == null ? void 0 : technology.certificationRequirement) || null;
10204
+ }
10205
+ };
10206
+
10207
+ // src/backoffice/services/product.service.ts
10208
+ var import_firestore38 = require("firebase/firestore");
10209
+ var ProductService = class extends BaseService {
10210
+ getProductsRefByTechnology(categoryId, subcategoryId, technologyId) {
10211
+ return (0, import_firestore38.collection)(
10212
+ this.db,
10213
+ CATEGORIES_COLLECTION,
10214
+ categoryId,
10215
+ SUBCATEGORIES_COLLECTION,
10216
+ subcategoryId,
10217
+ TECHNOLOGIES_COLLECTION,
10218
+ technologyId,
10219
+ PRODUCTS_COLLECTION
10220
+ );
10221
+ }
10222
+ getProductsRefByBrand(brandId) {
10223
+ return (0, import_firestore38.collection)(this.db, BRANDS_COLLECTION, brandId, PRODUCTS_COLLECTION);
10224
+ }
10225
+ async create(categoryId, subcategoryId, technologyId, brandId, product) {
10226
+ const now = /* @__PURE__ */ new Date();
10227
+ const newProduct = {
10228
+ ...product,
10229
+ brandId,
10230
+ technologyId,
10231
+ createdAt: now,
10232
+ updatedAt: now,
10233
+ isActive: true
10234
+ };
10235
+ const techProductRef = await (0, import_firestore38.addDoc)(
10236
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10237
+ newProduct
10238
+ );
10239
+ await (0, import_firestore38.addDoc)(this.getProductsRefByBrand(brandId), {
10240
+ ...newProduct,
10241
+ id: techProductRef.id,
10242
+ // Store the original ID for reference
10243
+ categoryId,
10244
+ subcategoryId,
10245
+ technologyId
10246
+ });
10247
+ return { id: techProductRef.id, ...newProduct };
10248
+ }
10249
+ async getAllByTechnology(categoryId, subcategoryId, technologyId) {
10250
+ const q = (0, import_firestore38.query)(
10251
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10252
+ (0, import_firestore38.where)("isActive", "==", true)
10253
+ );
10254
+ const snapshot = await (0, import_firestore38.getDocs)(q);
10255
+ return snapshot.docs.map(
10256
+ (doc26) => ({
10257
+ id: doc26.id,
10258
+ ...doc26.data()
10259
+ })
10260
+ );
10261
+ }
10262
+ async getAllByBrand(brandId) {
10263
+ const q = (0, import_firestore38.query)(
10264
+ this.getProductsRefByBrand(brandId),
10265
+ (0, import_firestore38.where)("isActive", "==", true)
10266
+ );
10267
+ const snapshot = await (0, import_firestore38.getDocs)(q);
10268
+ return snapshot.docs.map(
10269
+ (doc26) => ({
10270
+ id: doc26.id,
10271
+ ...doc26.data()
10272
+ })
10273
+ );
10274
+ }
10275
+ async update(categoryId, subcategoryId, technologyId, productId, product) {
10276
+ const updateData = {
10277
+ ...product,
10278
+ updatedAt: /* @__PURE__ */ new Date()
10279
+ };
10280
+ const techDocRef = (0, import_firestore38.doc)(
10281
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10282
+ productId
10283
+ );
10284
+ await (0, import_firestore38.updateDoc)(techDocRef, updateData);
10285
+ const brandProductsQuery = (0, import_firestore38.query)(
10286
+ (0, import_firestore38.collectionGroup)(this.db, PRODUCTS_COLLECTION),
10287
+ (0, import_firestore38.where)("id", "==", productId)
10288
+ );
10289
+ const brandProductsSnapshot = await (0, import_firestore38.getDocs)(brandProductsQuery);
10290
+ for (const doc26 of brandProductsSnapshot.docs) {
10291
+ await (0, import_firestore38.updateDoc)(doc26.ref, updateData);
10292
+ }
10293
+ return this.getById(categoryId, subcategoryId, technologyId, productId);
10294
+ }
10295
+ async delete(categoryId, subcategoryId, technologyId, productId) {
10296
+ await this.update(categoryId, subcategoryId, technologyId, productId, {
10297
+ isActive: false
10298
+ });
10299
+ }
10300
+ async getById(categoryId, subcategoryId, technologyId, productId) {
10301
+ const docRef = (0, import_firestore38.doc)(
10302
+ this.getProductsRefByTechnology(categoryId, subcategoryId, technologyId),
10303
+ productId
10304
+ );
10305
+ const docSnap = await (0, import_firestore38.getDoc)(docRef);
10306
+ if (!docSnap.exists()) return null;
10307
+ return {
10308
+ id: docSnap.id,
10309
+ ...docSnap.data()
10310
+ };
10311
+ }
10312
+ };
10313
+
9556
10314
  // src/validations/notification.schema.ts
9557
10315
  var import_zod19 = require("zod");
9558
10316
  var baseNotificationSchema = import_zod19.z.object({
@@ -9614,6 +10372,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
9614
10372
  AllergyType,
9615
10373
  AuthService,
9616
10374
  BlockingCondition,
10375
+ BrandService,
9617
10376
  CALENDAR_COLLECTION,
9618
10377
  CLINICS_COLLECTION,
9619
10378
  CLINIC_ADMINS_COLLECTION,
@@ -9622,6 +10381,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
9622
10381
  CalendarEventType,
9623
10382
  CalendarServiceV2,
9624
10383
  CalendarSyncStatus,
10384
+ CategoryService,
9625
10385
  CertificationLevel,
9626
10386
  CertificationSpecialty,
9627
10387
  ClinicAdminService,
@@ -9657,6 +10417,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
9657
10417
  PATIENT_MEDICAL_INFO_COLLECTION,
9658
10418
  PATIENT_SENSITIVE_INFO_COLLECTION,
9659
10419
  PRACTITIONERS_COLLECTION,
10420
+ PROCEDURES_COLLECTION,
9660
10421
  PatientService,
9661
10422
  PracticeType,
9662
10423
  PractitionerService,
@@ -9665,11 +10426,14 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
9665
10426
  PricingMeasure,
9666
10427
  ProcedureFamily,
9667
10428
  ProcedureService,
10429
+ ProductService,
9668
10430
  REGISTER_TOKENS_COLLECTION,
9669
10431
  SYNCED_CALENDARS_COLLECTION,
10432
+ SubcategoryService,
9670
10433
  SubscriptionModel,
9671
10434
  SyncedCalendarProvider,
9672
10435
  SyncedCalendarsService,
10436
+ TechnologyService,
9673
10437
  TreatmentBenefit,
9674
10438
  USER_ERRORS,
9675
10439
  UserService,