@blackcode_sa/metaestetics-api 1.12.62 → 1.12.64

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 (273) hide show
  1. package/dist/admin/index.d.mts +4 -2
  2. package/dist/admin/index.d.ts +4 -2
  3. package/dist/admin/index.js +4 -45
  4. package/dist/admin/index.mjs +4 -45
  5. package/dist/backoffice/index.d.mts +86 -1
  6. package/dist/backoffice/index.d.ts +86 -1
  7. package/dist/backoffice/index.js +308 -0
  8. package/dist/backoffice/index.mjs +306 -0
  9. package/dist/index.d.mts +99 -3
  10. package/dist/index.d.ts +99 -3
  11. package/dist/index.js +545 -281
  12. package/dist/index.mjs +867 -603
  13. package/package.json +119 -119
  14. package/src/__mocks__/firstore.ts +10 -10
  15. package/src/admin/aggregation/README.md +79 -79
  16. package/src/admin/aggregation/appointment/README.md +128 -128
  17. package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +1844 -1844
  18. package/src/admin/aggregation/appointment/index.ts +1 -1
  19. package/src/admin/aggregation/clinic/README.md +52 -52
  20. package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +703 -703
  21. package/src/admin/aggregation/clinic/index.ts +1 -1
  22. package/src/admin/aggregation/forms/README.md +13 -13
  23. package/src/admin/aggregation/forms/filled-forms.aggregation.service.ts +322 -322
  24. package/src/admin/aggregation/forms/index.ts +1 -1
  25. package/src/admin/aggregation/index.ts +8 -8
  26. package/src/admin/aggregation/patient/README.md +27 -27
  27. package/src/admin/aggregation/patient/index.ts +1 -1
  28. package/src/admin/aggregation/patient/patient.aggregation.service.ts +141 -141
  29. package/src/admin/aggregation/practitioner/README.md +42 -42
  30. package/src/admin/aggregation/practitioner/index.ts +1 -1
  31. package/src/admin/aggregation/practitioner/practitioner.aggregation.service.ts +433 -433
  32. package/src/admin/aggregation/practitioner-invite/index.ts +1 -1
  33. package/src/admin/aggregation/practitioner-invite/practitioner-invite.aggregation.service.ts +961 -961
  34. package/src/admin/aggregation/procedure/README.md +43 -43
  35. package/src/admin/aggregation/procedure/index.ts +1 -1
  36. package/src/admin/aggregation/procedure/procedure.aggregation.service.ts +702 -702
  37. package/src/admin/aggregation/reviews/index.ts +1 -1
  38. package/src/admin/aggregation/reviews/reviews.aggregation.service.ts +641 -689
  39. package/src/admin/booking/README.md +125 -125
  40. package/src/admin/booking/booking.admin.ts +1037 -1037
  41. package/src/admin/booking/booking.calculator.ts +712 -712
  42. package/src/admin/booking/booking.types.ts +59 -59
  43. package/src/admin/booking/index.ts +3 -3
  44. package/src/admin/booking/timezones-problem.md +185 -185
  45. package/src/admin/calendar/README.md +7 -7
  46. package/src/admin/calendar/calendar.admin.service.ts +345 -345
  47. package/src/admin/calendar/index.ts +1 -1
  48. package/src/admin/documentation-templates/document-manager.admin.ts +260 -260
  49. package/src/admin/documentation-templates/index.ts +1 -1
  50. package/src/admin/free-consultation/free-consultation-utils.admin.ts +148 -148
  51. package/src/admin/free-consultation/index.ts +1 -1
  52. package/src/admin/index.ts +75 -75
  53. package/src/admin/logger/index.ts +78 -78
  54. package/src/admin/mailing/README.md +95 -95
  55. package/src/admin/mailing/appointment/appointment.mailing.service.ts +732 -732
  56. package/src/admin/mailing/appointment/index.ts +1 -1
  57. package/src/admin/mailing/appointment/templates/patient/appointment-confirmed.html +40 -40
  58. package/src/admin/mailing/base.mailing.service.ts +208 -208
  59. package/src/admin/mailing/index.ts +3 -3
  60. package/src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts +611 -611
  61. package/src/admin/mailing/practitionerInvite/index.ts +2 -2
  62. package/src/admin/mailing/practitionerInvite/practitionerInvite.mailing.ts +395 -395
  63. package/src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts +155 -155
  64. package/src/admin/mailing/practitionerInvite/templates/invitation.template.ts +101 -101
  65. package/src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts +228 -228
  66. package/src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts +242 -242
  67. package/src/admin/notifications/index.ts +1 -1
  68. package/src/admin/notifications/notifications.admin.ts +710 -710
  69. package/src/admin/requirements/README.md +128 -128
  70. package/src/admin/requirements/index.ts +1 -1
  71. package/src/admin/requirements/patient-requirements.admin.service.ts +475 -475
  72. package/src/admin/users/index.ts +1 -1
  73. package/src/admin/users/user-profile.admin.ts +405 -405
  74. package/src/backoffice/constants/certification.constants.ts +13 -13
  75. package/src/backoffice/constants/index.ts +1 -1
  76. package/src/backoffice/errors/backoffice.errors.ts +181 -181
  77. package/src/backoffice/errors/index.ts +1 -1
  78. package/src/backoffice/expo-safe/README.md +26 -26
  79. package/src/backoffice/expo-safe/index.ts +41 -41
  80. package/src/backoffice/index.ts +5 -5
  81. package/src/backoffice/services/FIXES_README.md +102 -102
  82. package/src/backoffice/services/README.md +40 -40
  83. package/src/backoffice/services/brand.service.ts +256 -256
  84. package/src/backoffice/services/category.service.ts +318 -318
  85. package/src/backoffice/services/constants.service.ts +385 -385
  86. package/src/backoffice/services/documentation-template.service.ts +202 -202
  87. package/src/backoffice/services/index.ts +11 -8
  88. package/src/backoffice/services/migrate-products.ts +116 -116
  89. package/src/backoffice/services/product.service.ts +553 -553
  90. package/src/backoffice/services/requirement.service.ts +235 -235
  91. package/src/backoffice/services/subcategory.service.ts +395 -395
  92. package/src/backoffice/services/technology.service.ts +1083 -1070
  93. package/src/backoffice/types/README.md +12 -12
  94. package/src/backoffice/types/admin-constants.types.ts +69 -69
  95. package/src/backoffice/types/brand.types.ts +29 -29
  96. package/src/backoffice/types/category.types.ts +62 -62
  97. package/src/backoffice/types/documentation-templates.types.ts +28 -28
  98. package/src/backoffice/types/index.ts +10 -10
  99. package/src/backoffice/types/procedure-product.types.ts +38 -38
  100. package/src/backoffice/types/product.types.ts +240 -240
  101. package/src/backoffice/types/requirement.types.ts +63 -63
  102. package/src/backoffice/types/static/README.md +18 -18
  103. package/src/backoffice/types/static/blocking-condition.types.ts +21 -21
  104. package/src/backoffice/types/static/certification.types.ts +37 -37
  105. package/src/backoffice/types/static/contraindication.types.ts +19 -19
  106. package/src/backoffice/types/static/index.ts +6 -6
  107. package/src/backoffice/types/static/pricing.types.ts +16 -16
  108. package/src/backoffice/types/static/procedure-family.types.ts +14 -14
  109. package/src/backoffice/types/static/treatment-benefit.types.ts +22 -22
  110. package/src/backoffice/types/subcategory.types.ts +34 -34
  111. package/src/backoffice/types/technology.types.ts +163 -161
  112. package/src/backoffice/validations/index.ts +1 -1
  113. package/src/backoffice/validations/schemas.ts +164 -163
  114. package/src/config/__mocks__/firebase.ts +99 -99
  115. package/src/config/firebase.ts +78 -78
  116. package/src/config/index.ts +9 -9
  117. package/src/errors/auth.error.ts +6 -6
  118. package/src/errors/auth.errors.ts +200 -200
  119. package/src/errors/clinic.errors.ts +32 -32
  120. package/src/errors/firebase.errors.ts +47 -47
  121. package/src/errors/user.errors.ts +99 -99
  122. package/src/index.backup.ts +407 -407
  123. package/src/index.ts +6 -6
  124. package/src/locales/en.ts +31 -31
  125. package/src/recommender/admin/index.ts +1 -1
  126. package/src/recommender/admin/services/recommender.service.admin.ts +5 -5
  127. package/src/recommender/front/index.ts +1 -1
  128. package/src/recommender/front/services/onboarding.service.ts +5 -5
  129. package/src/recommender/front/services/recommender.service.ts +3 -3
  130. package/src/recommender/index.ts +1 -1
  131. package/src/services/PATIENTAUTH.MD +197 -197
  132. package/src/services/README.md +106 -106
  133. package/src/services/__tests__/auth/auth.mock.test.ts +17 -17
  134. package/src/services/__tests__/auth/auth.setup.ts +293 -293
  135. package/src/services/__tests__/auth.service.test.ts +346 -346
  136. package/src/services/__tests__/base.service.test.ts +77 -77
  137. package/src/services/__tests__/user.service.test.ts +528 -528
  138. package/src/services/appointment/README.md +17 -17
  139. package/src/services/appointment/appointment.service.ts +2505 -2082
  140. package/src/services/appointment/index.ts +1 -1
  141. package/src/services/appointment/utils/appointment.utils.ts +552 -552
  142. package/src/services/appointment/utils/extended-procedure.utils.ts +314 -314
  143. package/src/services/appointment/utils/form-initialization.utils.ts +225 -225
  144. package/src/services/appointment/utils/recommended-procedure.utils.ts +195 -195
  145. package/src/services/appointment/utils/zone-management.utils.ts +353 -353
  146. package/src/services/appointment/utils/zone-photo.utils.ts +152 -152
  147. package/src/services/auth/auth.service.ts +989 -989
  148. package/src/services/auth/auth.v2.service.ts +961 -961
  149. package/src/services/auth/index.ts +7 -7
  150. package/src/services/auth/utils/error.utils.ts +90 -90
  151. package/src/services/auth/utils/firebase.utils.ts +49 -49
  152. package/src/services/auth/utils/index.ts +21 -21
  153. package/src/services/auth/utils/practitioner.utils.ts +125 -125
  154. package/src/services/base.service.ts +41 -41
  155. package/src/services/calendar/calendar.service.ts +1077 -1077
  156. package/src/services/calendar/calendar.v2.service.ts +1683 -1683
  157. package/src/services/calendar/calendar.v3.service.ts +313 -313
  158. package/src/services/calendar/externalCalendar.service.ts +178 -178
  159. package/src/services/calendar/index.ts +5 -5
  160. package/src/services/calendar/synced-calendars.service.ts +743 -743
  161. package/src/services/calendar/utils/appointment.utils.ts +265 -265
  162. package/src/services/calendar/utils/calendar-event.utils.ts +646 -646
  163. package/src/services/calendar/utils/clinic.utils.ts +237 -237
  164. package/src/services/calendar/utils/docs.utils.ts +157 -157
  165. package/src/services/calendar/utils/google-calendar.utils.ts +697 -697
  166. package/src/services/calendar/utils/index.ts +8 -8
  167. package/src/services/calendar/utils/patient.utils.ts +198 -198
  168. package/src/services/calendar/utils/practitioner.utils.ts +221 -221
  169. package/src/services/calendar/utils/synced-calendar.utils.ts +472 -472
  170. package/src/services/clinic/README.md +204 -204
  171. package/src/services/clinic/__tests__/clinic-admin.service.test.ts +287 -287
  172. package/src/services/clinic/__tests__/clinic-group.service.test.ts +352 -352
  173. package/src/services/clinic/__tests__/clinic.service.test.ts +354 -354
  174. package/src/services/clinic/billing-transactions.service.ts +217 -217
  175. package/src/services/clinic/clinic-admin.service.ts +202 -202
  176. package/src/services/clinic/clinic-group.service.ts +310 -310
  177. package/src/services/clinic/clinic.service.ts +708 -708
  178. package/src/services/clinic/index.ts +5 -5
  179. package/src/services/clinic/practitioner-invite.service.ts +519 -519
  180. package/src/services/clinic/utils/admin.utils.ts +551 -551
  181. package/src/services/clinic/utils/clinic-group.utils.ts +646 -646
  182. package/src/services/clinic/utils/clinic.utils.ts +949 -949
  183. package/src/services/clinic/utils/filter.utils.d.ts +23 -23
  184. package/src/services/clinic/utils/filter.utils.ts +446 -446
  185. package/src/services/clinic/utils/index.ts +11 -11
  186. package/src/services/clinic/utils/photos.utils.ts +188 -188
  187. package/src/services/clinic/utils/search.utils.ts +84 -84
  188. package/src/services/clinic/utils/tag.utils.ts +124 -124
  189. package/src/services/documentation-templates/documentation-template.service.ts +537 -537
  190. package/src/services/documentation-templates/filled-document.service.ts +587 -587
  191. package/src/services/documentation-templates/index.ts +2 -2
  192. package/src/services/index.ts +13 -13
  193. package/src/services/media/index.ts +1 -1
  194. package/src/services/media/media.service.ts +418 -418
  195. package/src/services/notifications/__tests__/notification.service.test.ts +242 -242
  196. package/src/services/notifications/index.ts +1 -1
  197. package/src/services/notifications/notification.service.ts +215 -215
  198. package/src/services/patient/README.md +48 -48
  199. package/src/services/patient/To-Do.md +43 -43
  200. package/src/services/patient/__tests__/patient.service.test.ts +294 -294
  201. package/src/services/patient/index.ts +2 -2
  202. package/src/services/patient/patient.service.ts +883 -883
  203. package/src/services/patient/patientRequirements.service.ts +285 -285
  204. package/src/services/patient/utils/aesthetic-analysis.utils.ts +176 -176
  205. package/src/services/patient/utils/clinic.utils.ts +80 -80
  206. package/src/services/patient/utils/docs.utils.ts +142 -142
  207. package/src/services/patient/utils/index.ts +9 -9
  208. package/src/services/patient/utils/location.utils.ts +126 -126
  209. package/src/services/patient/utils/medical-stuff.utils.ts +143 -143
  210. package/src/services/patient/utils/medical.utils.ts +458 -458
  211. package/src/services/patient/utils/practitioner.utils.ts +260 -260
  212. package/src/services/patient/utils/profile.utils.ts +510 -510
  213. package/src/services/patient/utils/sensitive.utils.ts +260 -260
  214. package/src/services/patient/utils/token.utils.ts +211 -211
  215. package/src/services/practitioner/README.md +145 -145
  216. package/src/services/practitioner/index.ts +1 -1
  217. package/src/services/practitioner/practitioner.service.ts +1742 -1742
  218. package/src/services/procedure/README.md +163 -163
  219. package/src/services/procedure/index.ts +1 -1
  220. package/src/services/procedure/procedure.service.ts +1682 -1682
  221. package/src/services/reviews/index.ts +1 -1
  222. package/src/services/reviews/reviews.service.ts +636 -683
  223. package/src/services/user/index.ts +1 -1
  224. package/src/services/user/user.service.ts +489 -489
  225. package/src/services/user/user.v2.service.ts +466 -466
  226. package/src/types/appointment/index.ts +481 -453
  227. package/src/types/calendar/index.ts +258 -258
  228. package/src/types/calendar/synced-calendar.types.ts +66 -66
  229. package/src/types/clinic/index.ts +489 -489
  230. package/src/types/clinic/practitioner-invite.types.ts +91 -91
  231. package/src/types/clinic/preferences.types.ts +159 -159
  232. package/src/types/clinic/to-do +3 -3
  233. package/src/types/documentation-templates/index.ts +308 -308
  234. package/src/types/index.ts +44 -44
  235. package/src/types/notifications/README.md +77 -77
  236. package/src/types/notifications/index.ts +265 -265
  237. package/src/types/patient/aesthetic-analysis.types.ts +66 -66
  238. package/src/types/patient/allergies.ts +58 -58
  239. package/src/types/patient/index.ts +275 -273
  240. package/src/types/patient/medical-info.types.ts +152 -152
  241. package/src/types/patient/patient-requirements.ts +92 -92
  242. package/src/types/patient/token.types.ts +61 -61
  243. package/src/types/practitioner/index.ts +206 -206
  244. package/src/types/procedure/index.ts +181 -181
  245. package/src/types/profile/index.ts +39 -39
  246. package/src/types/reviews/index.ts +130 -132
  247. package/src/types/tz-lookup.d.ts +4 -4
  248. package/src/types/user/index.ts +38 -38
  249. package/src/utils/TIMESTAMPS.md +176 -176
  250. package/src/utils/TimestampUtils.ts +241 -241
  251. package/src/utils/index.ts +1 -1
  252. package/src/validations/appointment.schema.ts +574 -574
  253. package/src/validations/calendar.schema.ts +225 -225
  254. package/src/validations/clinic.schema.ts +493 -493
  255. package/src/validations/common.schema.ts +25 -25
  256. package/src/validations/documentation-templates/index.ts +1 -1
  257. package/src/validations/documentation-templates/template.schema.ts +220 -220
  258. package/src/validations/documentation-templates.schema.ts +10 -10
  259. package/src/validations/index.ts +20 -20
  260. package/src/validations/media.schema.ts +10 -10
  261. package/src/validations/notification.schema.ts +90 -90
  262. package/src/validations/patient/aesthetic-analysis.schema.ts +55 -55
  263. package/src/validations/patient/medical-info.schema.ts +125 -125
  264. package/src/validations/patient/patient-requirements.schema.ts +84 -84
  265. package/src/validations/patient/token.schema.ts +29 -29
  266. package/src/validations/patient.schema.ts +217 -216
  267. package/src/validations/practitioner.schema.ts +222 -222
  268. package/src/validations/procedure-product.schema.ts +41 -41
  269. package/src/validations/procedure.schema.ts +124 -124
  270. package/src/validations/profile-info.schema.ts +41 -41
  271. package/src/validations/reviews.schema.ts +189 -195
  272. package/src/validations/schemas.ts +104 -104
  273. package/src/validations/shared.schema.ts +78 -78
package/dist/index.mjs CHANGED
@@ -73,6 +73,9 @@ var MediaType = /* @__PURE__ */ ((MediaType2) => {
73
73
  })(MediaType || {});
74
74
  var APPOINTMENTS_COLLECTION = "appointments";
75
75
 
76
+ // src/types/procedure/index.ts
77
+ var PROCEDURES_COLLECTION = "procedures";
78
+
76
79
  // src/validations/appointment.schema.ts
77
80
  import { z as z3 } from "zod";
78
81
 
@@ -979,7 +982,7 @@ var MediaService = class extends BaseService {
979
982
  try {
980
983
  const querySnapshot = await getDocs(finalQuery);
981
984
  const mediaList = querySnapshot.docs.map(
982
- (doc44) => doc44.data()
985
+ (doc45) => doc45.data()
983
986
  );
984
987
  console.log(`[MediaService] Found ${mediaList.length} media items.`);
985
988
  return mediaList;
@@ -1267,9 +1270,6 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
1267
1270
  return Gender2;
1268
1271
  })(Gender || {});
1269
1272
 
1270
- // src/types/procedure/index.ts
1271
- var PROCEDURES_COLLECTION = "procedures";
1272
-
1273
1273
  // src/backoffice/types/technology.types.ts
1274
1274
  var TECHNOLOGIES_COLLECTION = "technologies";
1275
1275
 
@@ -1422,7 +1422,7 @@ async function searchAppointmentsUtil(db, params) {
1422
1422
  }
1423
1423
  const q = query2(collection2(db, APPOINTMENTS_COLLECTION), ...constraints);
1424
1424
  const querySnapshot = await getDocs2(q);
1425
- const appointments = querySnapshot.docs.map((doc44) => doc44.data());
1425
+ const appointments = querySnapshot.docs.map((doc45) => doc45.data());
1426
1426
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
1427
1427
  return { appointments, lastDoc };
1428
1428
  } catch (error) {
@@ -2756,7 +2756,7 @@ var AppointmentService = class extends BaseService {
2756
2756
  }
2757
2757
  const q = query4(collection4(this.db, APPOINTMENTS_COLLECTION), ...constraints);
2758
2758
  const querySnapshot = await getDocs4(q);
2759
- const appointments = querySnapshot.docs.map((doc44) => doc44.data());
2759
+ const appointments = querySnapshot.docs.map((doc45) => doc45.data());
2760
2760
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
2761
2761
  console.log(
2762
2762
  `[APPOINTMENT_SERVICE] Found ${appointments.length} upcoming appointments for patient ${patientId}`
@@ -2812,7 +2812,7 @@ var AppointmentService = class extends BaseService {
2812
2812
  }
2813
2813
  const q = query4(collection4(this.db, APPOINTMENTS_COLLECTION), ...constraints);
2814
2814
  const querySnapshot = await getDocs4(q);
2815
- const appointments = querySnapshot.docs.map((doc44) => doc44.data());
2815
+ const appointments = querySnapshot.docs.map((doc45) => doc45.data());
2816
2816
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
2817
2817
  console.log(
2818
2818
  `[APPOINTMENT_SERVICE] Found ${appointments.length} past appointments for patient ${patientId}`
@@ -3534,6 +3534,301 @@ var AppointmentService = class extends BaseService {
3534
3534
  throw error;
3535
3535
  }
3536
3536
  }
3537
+ /**
3538
+ * Gets all next steps recommendations for a patient from their past appointments.
3539
+ * Returns recommendations with context about which appointment, practitioner, and clinic suggested them.
3540
+ *
3541
+ * @param patientId ID of the patient
3542
+ * @param options Optional parameters for filtering
3543
+ * @returns Array of next steps recommendations with context
3544
+ */
3545
+ async getPatientNextStepsRecommendations(patientId, options) {
3546
+ var _a, _b, _c;
3547
+ try {
3548
+ console.log(
3549
+ `[APPOINTMENT_SERVICE] Getting next steps recommendations for patient: ${patientId}`,
3550
+ options
3551
+ );
3552
+ const patientProfile = await this.patientService.getPatientProfile(patientId);
3553
+ const dismissedIds = new Set(
3554
+ (patientProfile == null ? void 0 : patientProfile.dismissedNextStepsRecommendations) || []
3555
+ );
3556
+ const pastAppointments = await this.getPastPatientAppointments(patientId, {
3557
+ showCanceled: false,
3558
+ showNoShow: false
3559
+ });
3560
+ const recommendations = [];
3561
+ for (const appointment of pastAppointments.appointments) {
3562
+ if ((options == null ? void 0 : options.clinicBranchId) && appointment.clinicBranchId !== options.clinicBranchId) {
3563
+ continue;
3564
+ }
3565
+ if ((options == null ? void 0 : options.practitionerId) && appointment.practitionerId !== options.practitionerId) {
3566
+ continue;
3567
+ }
3568
+ const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
3569
+ for (let index = 0; index < recommendedProcedures.length; index++) {
3570
+ const recommendedProcedure = recommendedProcedures[index];
3571
+ const recommendationId = `${appointment.id}:${index}`;
3572
+ if (!(options == null ? void 0 : options.includeDismissed) && dismissedIds.has(recommendationId)) {
3573
+ continue;
3574
+ }
3575
+ const nextStepsRecommendation = {
3576
+ id: recommendationId,
3577
+ recommendedProcedure,
3578
+ appointmentId: appointment.id,
3579
+ appointmentDate: appointment.appointmentStartTime,
3580
+ practitionerId: appointment.practitionerId,
3581
+ practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
3582
+ clinicBranchId: appointment.clinicBranchId,
3583
+ clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
3584
+ appointmentStatus: appointment.status,
3585
+ isDismissed: dismissedIds.has(recommendationId),
3586
+ dismissedAt: null
3587
+ // We don't track when it was dismissed, just that it was
3588
+ };
3589
+ recommendations.push(nextStepsRecommendation);
3590
+ }
3591
+ }
3592
+ recommendations.sort((a, b) => {
3593
+ const dateA = a.appointmentDate.toMillis();
3594
+ const dateB = b.appointmentDate.toMillis();
3595
+ return dateB - dateA;
3596
+ });
3597
+ const limitedRecommendations = (options == null ? void 0 : options.limit) ? recommendations.slice(0, options.limit) : recommendations;
3598
+ console.log(
3599
+ `[APPOINTMENT_SERVICE] Found ${limitedRecommendations.length} next steps recommendations for patient ${patientId}`
3600
+ );
3601
+ return limitedRecommendations;
3602
+ } catch (error) {
3603
+ console.error(
3604
+ `[APPOINTMENT_SERVICE] Error getting next steps recommendations for patient ${patientId}:`,
3605
+ error
3606
+ );
3607
+ throw error;
3608
+ }
3609
+ }
3610
+ /**
3611
+ * Dismisses a next steps recommendation for a patient.
3612
+ * This prevents the recommendation from showing up in the default view.
3613
+ *
3614
+ * @param patientId ID of the patient
3615
+ * @param recommendationId ID of the recommendation to dismiss (format: appointmentId:recommendationIndex)
3616
+ * @returns Updated patient profile
3617
+ */
3618
+ async dismissNextStepsRecommendation(patientId, recommendationId) {
3619
+ try {
3620
+ console.log(
3621
+ `[APPOINTMENT_SERVICE] Dismissing recommendation ${recommendationId} for patient ${patientId}`
3622
+ );
3623
+ const patientProfile = await this.patientService.getPatientProfile(patientId);
3624
+ if (!patientProfile) {
3625
+ throw new Error(`Patient profile not found for patient ${patientId}`);
3626
+ }
3627
+ const dismissedRecommendations = patientProfile.dismissedNextStepsRecommendations || [];
3628
+ if (dismissedRecommendations.includes(recommendationId)) {
3629
+ console.log(
3630
+ `[APPOINTMENT_SERVICE] Recommendation ${recommendationId} already dismissed`
3631
+ );
3632
+ return;
3633
+ }
3634
+ const updatedDismissed = [...dismissedRecommendations, recommendationId];
3635
+ await this.patientService.updatePatientProfile(patientId, {
3636
+ dismissedNextStepsRecommendations: updatedDismissed
3637
+ });
3638
+ console.log(
3639
+ `[APPOINTMENT_SERVICE] Successfully dismissed recommendation ${recommendationId} for patient ${patientId}`
3640
+ );
3641
+ } catch (error) {
3642
+ console.error(
3643
+ `[APPOINTMENT_SERVICE] Error dismissing recommendation for patient ${patientId}:`,
3644
+ error
3645
+ );
3646
+ throw error;
3647
+ }
3648
+ }
3649
+ /**
3650
+ * Undismisses a next steps recommendation for a patient.
3651
+ * This makes the recommendation visible again in the default view.
3652
+ *
3653
+ * @param patientId ID of the patient
3654
+ * @param recommendationId ID of the recommendation to undismiss (format: appointmentId:recommendationIndex)
3655
+ * @returns Updated patient profile
3656
+ */
3657
+ async undismissNextStepsRecommendation(patientId, recommendationId) {
3658
+ try {
3659
+ console.log(
3660
+ `[APPOINTMENT_SERVICE] Undismissing recommendation ${recommendationId} for patient ${patientId}`
3661
+ );
3662
+ const patientProfile = await this.patientService.getPatientProfile(patientId);
3663
+ if (!patientProfile) {
3664
+ throw new Error(`Patient profile not found for patient ${patientId}`);
3665
+ }
3666
+ const dismissedRecommendations = patientProfile.dismissedNextStepsRecommendations || [];
3667
+ if (!dismissedRecommendations.includes(recommendationId)) {
3668
+ console.log(
3669
+ `[APPOINTMENT_SERVICE] Recommendation ${recommendationId} is not dismissed`
3670
+ );
3671
+ return;
3672
+ }
3673
+ const updatedDismissed = dismissedRecommendations.filter(
3674
+ (id) => id !== recommendationId
3675
+ );
3676
+ await this.patientService.updatePatientProfile(patientId, {
3677
+ dismissedNextStepsRecommendations: updatedDismissed
3678
+ });
3679
+ console.log(
3680
+ `[APPOINTMENT_SERVICE] Successfully undismissed recommendation ${recommendationId} for patient ${patientId}`
3681
+ );
3682
+ } catch (error) {
3683
+ console.error(
3684
+ `[APPOINTMENT_SERVICE] Error undismissing recommendation for patient ${patientId}:`,
3685
+ error
3686
+ );
3687
+ throw error;
3688
+ }
3689
+ }
3690
+ /**
3691
+ * Gets next steps recommendations for a clinic.
3692
+ * Returns all recommendations from appointments at the specified clinic.
3693
+ * This is useful for clinic admins to see what treatments have been recommended to their patients.
3694
+ *
3695
+ * @param clinicBranchId ID of the clinic branch
3696
+ * @param options Optional parameters for filtering
3697
+ * @returns Array of next steps recommendations with context
3698
+ */
3699
+ async getClinicNextStepsRecommendations(clinicBranchId, options) {
3700
+ var _a, _b, _c;
3701
+ try {
3702
+ console.log(
3703
+ `[APPOINTMENT_SERVICE] Getting next steps recommendations for clinic: ${clinicBranchId}`,
3704
+ options
3705
+ );
3706
+ const searchParams = {
3707
+ clinicBranchId,
3708
+ patientId: options == null ? void 0 : options.patientId,
3709
+ practitionerId: options == null ? void 0 : options.practitionerId,
3710
+ status: "completed" /* COMPLETED */
3711
+ };
3712
+ const { appointments } = await this.searchAppointments(searchParams);
3713
+ const recommendations = [];
3714
+ for (const appointment of appointments) {
3715
+ const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
3716
+ for (let index = 0; index < recommendedProcedures.length; index++) {
3717
+ const recommendedProcedure = recommendedProcedures[index];
3718
+ const recommendationId = `${appointment.id}:${index}`;
3719
+ const nextStepsRecommendation = {
3720
+ id: recommendationId,
3721
+ recommendedProcedure,
3722
+ appointmentId: appointment.id,
3723
+ appointmentDate: appointment.appointmentStartTime,
3724
+ practitionerId: appointment.practitionerId,
3725
+ practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
3726
+ clinicBranchId: appointment.clinicBranchId,
3727
+ clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
3728
+ appointmentStatus: appointment.status,
3729
+ isDismissed: false,
3730
+ // Clinic view doesn't track dismissals
3731
+ dismissedAt: null
3732
+ };
3733
+ recommendations.push(nextStepsRecommendation);
3734
+ }
3735
+ }
3736
+ recommendations.sort((a, b) => {
3737
+ const dateA = a.appointmentDate.toMillis();
3738
+ const dateB = b.appointmentDate.toMillis();
3739
+ return dateB - dateA;
3740
+ });
3741
+ const limitedRecommendations = (options == null ? void 0 : options.limit) ? recommendations.slice(0, options.limit) : recommendations;
3742
+ console.log(
3743
+ `[APPOINTMENT_SERVICE] Found ${limitedRecommendations.length} next steps recommendations for clinic ${clinicBranchId}`
3744
+ );
3745
+ return limitedRecommendations;
3746
+ } catch (error) {
3747
+ console.error(
3748
+ `[APPOINTMENT_SERVICE] Error getting next steps recommendations for clinic ${clinicBranchId}:`,
3749
+ error
3750
+ );
3751
+ throw error;
3752
+ }
3753
+ }
3754
+ /**
3755
+ * Gets next steps recommendations from a specific appointment.
3756
+ * This is useful when viewing an appointment detail page in the clinic app
3757
+ * to see what procedures were recommended during that appointment.
3758
+ *
3759
+ * @param appointmentId ID of the appointment
3760
+ * @param options Optional parameters for filtering
3761
+ * @returns Array of next steps recommendations from that appointment
3762
+ */
3763
+ async getAppointmentNextStepsRecommendations(appointmentId, options) {
3764
+ var _a, _b, _c;
3765
+ try {
3766
+ console.log(
3767
+ `[APPOINTMENT_SERVICE] Getting next steps recommendations for appointment: ${appointmentId}`,
3768
+ options
3769
+ );
3770
+ const appointment = await this.getAppointmentById(appointmentId);
3771
+ if (!appointment) {
3772
+ throw new Error(`Appointment with ID ${appointmentId} not found`);
3773
+ }
3774
+ const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
3775
+ const recommendations = [];
3776
+ let availableProcedureIds = null;
3777
+ if (options == null ? void 0 : options.clinicBranchId) {
3778
+ const proceduresQuery = query4(
3779
+ collection4(this.db, PROCEDURES_COLLECTION),
3780
+ where4("clinicBranchId", "==", options.clinicBranchId),
3781
+ where4("isActive", "==", true)
3782
+ );
3783
+ const proceduresSnapshot = await getDocs4(proceduresQuery);
3784
+ availableProcedureIds = new Set(
3785
+ proceduresSnapshot.docs.map((doc45) => doc45.id)
3786
+ );
3787
+ console.log(
3788
+ `[APPOINTMENT_SERVICE] Found ${availableProcedureIds.size} procedures available at clinic ${options.clinicBranchId}`
3789
+ );
3790
+ }
3791
+ for (let index = 0; index < recommendedProcedures.length; index++) {
3792
+ const recommendedProcedure = recommendedProcedures[index];
3793
+ const procedureId = recommendedProcedure.procedure.procedureId;
3794
+ if ((options == null ? void 0 : options.clinicBranchId) && availableProcedureIds) {
3795
+ if (!availableProcedureIds.has(procedureId)) {
3796
+ console.log(
3797
+ `[APPOINTMENT_SERVICE] Skipping recommendation for procedure ${procedureId} - not available at clinic ${options.clinicBranchId}`
3798
+ );
3799
+ continue;
3800
+ }
3801
+ }
3802
+ const recommendationId = `${appointment.id}:${index}`;
3803
+ const nextStepsRecommendation = {
3804
+ id: recommendationId,
3805
+ recommendedProcedure,
3806
+ appointmentId: appointment.id,
3807
+ appointmentDate: appointment.appointmentStartTime,
3808
+ practitionerId: appointment.practitionerId,
3809
+ practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
3810
+ clinicBranchId: appointment.clinicBranchId,
3811
+ clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
3812
+ appointmentStatus: appointment.status,
3813
+ isDismissed: false,
3814
+ // Clinic view doesn't track dismissals
3815
+ dismissedAt: null
3816
+ };
3817
+ recommendations.push(nextStepsRecommendation);
3818
+ }
3819
+ console.log(
3820
+ `[APPOINTMENT_SERVICE] Found ${recommendations.length} next steps recommendations for appointment ${appointmentId}`,
3821
+ (options == null ? void 0 : options.clinicBranchId) ? `(filtered to procedures available at clinic ${options.clinicBranchId})` : ""
3822
+ );
3823
+ return recommendations;
3824
+ } catch (error) {
3825
+ console.error(
3826
+ `[APPOINTMENT_SERVICE] Error getting next steps recommendations for appointment ${appointmentId}:`,
3827
+ error
3828
+ );
3829
+ throw error;
3830
+ }
3831
+ }
3537
3832
  };
3538
3833
 
3539
3834
  // src/services/auth/auth.service.ts
@@ -3929,8 +4224,8 @@ var AUTH_ERRORS = {
3929
4224
  // src/services/user/user.service.ts
3930
4225
  import {
3931
4226
  collection as collection12,
3932
- doc as doc18,
3933
- getDoc as getDoc20,
4227
+ doc as doc19,
4228
+ getDoc as getDoc21,
3934
4229
  getDocs as getDocs12,
3935
4230
  query as query12,
3936
4231
  where as where12,
@@ -4038,8 +4333,8 @@ import { z as z18 } from "zod";
4038
4333
 
4039
4334
  // src/services/patient/patient.service.ts
4040
4335
  import {
4041
- doc as doc16,
4042
- getDoc as getDoc18,
4336
+ doc as doc17,
4337
+ getDoc as getDoc19,
4043
4338
  writeBatch,
4044
4339
  updateDoc as updateDoc15,
4045
4340
  serverTimestamp as serverTimestamp16
@@ -4054,8 +4349,8 @@ import {
4054
4349
  getDocs as getDocs5,
4055
4350
  limit as limit4,
4056
4351
  startAfter as startAfter3,
4057
- doc as doc8,
4058
- getDoc as getDoc7
4352
+ doc as doc9,
4353
+ getDoc as getDoc8
4059
4354
  } from "firebase/firestore";
4060
4355
  var getPatientsByClinicUtil = async (db, clinicId, options) => {
4061
4356
  try {
@@ -4072,8 +4367,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
4072
4367
  q = query5(q, limit4(options.limit));
4073
4368
  }
4074
4369
  if (options == null ? void 0 : options.startAfter) {
4075
- const startAfterDoc = await getDoc7(
4076
- doc8(db, PATIENTS_COLLECTION, options.startAfter)
4370
+ const startAfterDoc = await getDoc8(
4371
+ doc9(db, PATIENTS_COLLECTION, options.startAfter)
4077
4372
  );
4078
4373
  if (startAfterDoc.exists()) {
4079
4374
  q = query5(q, startAfter3(startAfterDoc));
@@ -4081,8 +4376,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
4081
4376
  }
4082
4377
  const patientsSnapshot = await getDocs5(q);
4083
4378
  const patients = [];
4084
- patientsSnapshot.forEach((doc44) => {
4085
- patients.push(doc44.data());
4379
+ patientsSnapshot.forEach((doc45) => {
4380
+ patients.push(doc45.data());
4086
4381
  });
4087
4382
  console.log(
4088
4383
  `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
@@ -4101,16 +4396,16 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
4101
4396
 
4102
4397
  // src/services/patient/utils/docs.utils.ts
4103
4398
  import {
4104
- doc as doc11,
4399
+ doc as doc12,
4105
4400
  collection as collection8,
4106
4401
  query as query8,
4107
4402
  where as where8,
4108
4403
  getDocs as getDocs8,
4109
- getDoc as getDoc11
4404
+ getDoc as getDoc12
4110
4405
  } from "firebase/firestore";
4111
4406
 
4112
4407
  // src/services/patient/utils/sensitive.utils.ts
4113
- import { getDoc as getDoc10, updateDoc as updateDoc8, setDoc as setDoc4, serverTimestamp as serverTimestamp9 } from "firebase/firestore";
4408
+ import { getDoc as getDoc11, updateDoc as updateDoc8, setDoc as setDoc4, serverTimestamp as serverTimestamp9 } from "firebase/firestore";
4114
4409
 
4115
4410
  // src/validations/patient.schema.ts
4116
4411
  import { z as z7 } from "zod";
@@ -4332,6 +4627,7 @@ var patientProfileSchema = z7.object({
4332
4627
  clinics: z7.array(patientClinicSchema),
4333
4628
  doctorIds: z7.array(z7.string()),
4334
4629
  clinicIds: z7.array(z7.string()),
4630
+ dismissedNextStepsRecommendations: z7.array(z7.string()).optional(),
4335
4631
  createdAt: z7.instanceof(Timestamp5),
4336
4632
  updatedAt: z7.instanceof(Timestamp5)
4337
4633
  });
@@ -4412,8 +4708,8 @@ import {
4412
4708
  getDocs as getDocs6,
4413
4709
  limit as limit5,
4414
4710
  startAfter as startAfter4,
4415
- doc as doc9,
4416
- getDoc as getDoc8
4711
+ doc as doc10,
4712
+ getDoc as getDoc9
4417
4713
  } from "firebase/firestore";
4418
4714
  var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
4419
4715
  try {
@@ -4430,8 +4726,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
4430
4726
  q = query6(q, limit5(options.limit));
4431
4727
  }
4432
4728
  if (options == null ? void 0 : options.startAfter) {
4433
- const startAfterDoc = await getDoc8(
4434
- doc9(db, PATIENTS_COLLECTION, options.startAfter)
4729
+ const startAfterDoc = await getDoc9(
4730
+ doc10(db, PATIENTS_COLLECTION, options.startAfter)
4435
4731
  );
4436
4732
  if (startAfterDoc.exists()) {
4437
4733
  q = query6(q, startAfter4(startAfterDoc));
@@ -4439,8 +4735,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
4439
4735
  }
4440
4736
  const patientsSnapshot = await getDocs6(q);
4441
4737
  const patients = [];
4442
- patientsSnapshot.forEach((doc44) => {
4443
- patients.push(doc44.data());
4738
+ patientsSnapshot.forEach((doc45) => {
4739
+ patients.push(doc45.data());
4444
4740
  });
4445
4741
  console.log(
4446
4742
  `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
@@ -4470,7 +4766,7 @@ var getPatientsByPractitionerWithDetailsUtil = async (db, practitionerId, option
4470
4766
  const patientProfilesWithDetails = await Promise.all(
4471
4767
  patientProfiles.map(async (profile) => {
4472
4768
  try {
4473
- const sensitiveInfoDoc = await getDoc8(
4769
+ const sensitiveInfoDoc = await getDoc9(
4474
4770
  getSensitiveInfoDocRef(db, profile.id)
4475
4771
  );
4476
4772
  const sensitiveInfo = sensitiveInfoDoc.exists() ? sensitiveInfoDoc.data() : void 0;
@@ -4539,8 +4835,8 @@ var getPractitionerProfileByUserRef = async (db, userRef) => {
4539
4835
  // src/services/clinic/utils/admin.utils.ts
4540
4836
  import {
4541
4837
  collection as collection7,
4542
- doc as doc10,
4543
- getDoc as getDoc9,
4838
+ doc as doc11,
4839
+ getDoc as getDoc10,
4544
4840
  getDocs as getDocs7,
4545
4841
  query as query7,
4546
4842
  where as where7,
@@ -4669,7 +4965,6 @@ var reviewSchema = z8.object({
4669
4965
  clinicReview: clinicReviewSchema.optional(),
4670
4966
  practitionerReview: practitionerReviewSchema.optional(),
4671
4967
  procedureReview: procedureReviewSchema.optional(),
4672
- extendedProcedureReviews: z8.array(procedureReviewSchema).optional(),
4673
4968
  overallComment: z8.string().min(1).max(2e3),
4674
4969
  overallRating: z8.number().min(1).max(5)
4675
4970
  });
@@ -4678,14 +4973,13 @@ var createReviewSchema = z8.object({
4678
4973
  clinicReview: createClinicReviewSchema.optional(),
4679
4974
  practitionerReview: createPractitionerReviewSchema.optional(),
4680
4975
  procedureReview: createProcedureReviewSchema.optional(),
4681
- extendedProcedureReviews: z8.array(createProcedureReviewSchema).optional(),
4682
4976
  overallComment: z8.string().min(1).max(2e3)
4683
4977
  }).refine(
4684
4978
  (data) => {
4685
- return data.clinicReview || data.practitionerReview || data.procedureReview || data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0;
4979
+ return data.clinicReview || data.practitionerReview || data.procedureReview;
4686
4980
  },
4687
4981
  {
4688
- message: "At least one review type (clinic, practitioner, procedure, or extended procedure) must be provided",
4982
+ message: "At least one review type (clinic, practitioner, or procedure) must be provided",
4689
4983
  path: ["reviewType"]
4690
4984
  }
4691
4985
  );
@@ -5159,7 +5453,7 @@ async function createClinicAdmin(db, data, clinicGroupService) {
5159
5453
  }
5160
5454
  console.log("[CLINIC_ADMIN] Preparing admin data object");
5161
5455
  const adminData = {
5162
- id: doc10(collection7(db, CLINIC_ADMINS_COLLECTION)).id,
5456
+ id: doc11(collection7(db, CLINIC_ADMINS_COLLECTION)).id,
5163
5457
  // Generate a new ID for the admin document
5164
5458
  userRef: validatedData.userRef,
5165
5459
  clinicGroupId: clinicGroupId || "",
@@ -5194,7 +5488,7 @@ async function createClinicAdmin(db, data, clinicGroupService) {
5194
5488
  adminId: adminData.id
5195
5489
  });
5196
5490
  try {
5197
- await setDoc3(doc10(db, CLINIC_ADMINS_COLLECTION, adminData.id), adminData);
5491
+ await setDoc3(doc11(db, CLINIC_ADMINS_COLLECTION, adminData.id), adminData);
5198
5492
  console.log("[CLINIC_ADMIN] Admin saved successfully");
5199
5493
  } catch (firestoreError) {
5200
5494
  console.error(
@@ -5243,8 +5537,8 @@ async function checkClinicGroupExists(db, groupId, clinicGroupService) {
5243
5537
  return !!group;
5244
5538
  }
5245
5539
  async function getClinicAdmin(db, adminId) {
5246
- const docRef = doc10(db, CLINIC_ADMINS_COLLECTION, adminId);
5247
- const docSnap = await getDoc9(docRef);
5540
+ const docRef = doc11(db, CLINIC_ADMINS_COLLECTION, adminId);
5541
+ const docSnap = await getDoc10(docRef);
5248
5542
  if (docSnap.exists()) {
5249
5543
  return docSnap.data();
5250
5544
  }
@@ -5267,7 +5561,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
5267
5561
  where7("clinicGroupId", "==", clinicGroupId)
5268
5562
  );
5269
5563
  const querySnapshot = await getDocs7(q);
5270
- return querySnapshot.docs.map((doc44) => doc44.data());
5564
+ return querySnapshot.docs.map((doc45) => doc45.data());
5271
5565
  }
5272
5566
  async function updateClinicAdmin(db, adminId, data) {
5273
5567
  const admin = await getClinicAdmin(db, adminId);
@@ -5278,7 +5572,7 @@ async function updateClinicAdmin(db, adminId, data) {
5278
5572
  ...data,
5279
5573
  updatedAt: serverTimestamp8()
5280
5574
  };
5281
- await updateDoc7(doc10(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
5575
+ await updateDoc7(doc11(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
5282
5576
  const updatedAdmin = await getClinicAdmin(db, adminId);
5283
5577
  if (!updatedAdmin) {
5284
5578
  throw new Error("Failed to retrieve updated admin");
@@ -5290,7 +5584,7 @@ async function deleteClinicAdmin(db, adminId) {
5290
5584
  if (!admin) {
5291
5585
  throw new Error("Clinic admin not found");
5292
5586
  }
5293
- await deleteDoc3(doc10(db, CLINIC_ADMINS_COLLECTION, adminId));
5587
+ await deleteDoc3(doc11(db, CLINIC_ADMINS_COLLECTION, adminId));
5294
5588
  }
5295
5589
  async function addClinicToManaged(db, adminId, clinicId, requesterId, clinicService) {
5296
5590
  const admin = await getClinicAdmin(db, adminId);
@@ -5404,7 +5698,7 @@ async function syncOwnerClinics(db, adminId, clinicService, clinicGroupService)
5404
5698
  // src/services/patient/utils/sensitive.utils.ts
5405
5699
  var checkSensitiveAccessUtil = async (db, patientId, requesterId, requesterRoles) => {
5406
5700
  var _a;
5407
- const patientDoc = await getDoc10(getPatientDocRef(db, patientId));
5701
+ const patientDoc = await getDoc11(getPatientDocRef(db, patientId));
5408
5702
  if (!patientDoc.exists()) {
5409
5703
  throw new Error("Patient profile not found");
5410
5704
  }
@@ -5463,7 +5757,7 @@ var createSensitiveInfoUtil = async (db, data, requesterId, requesterRoles, medi
5463
5757
  try {
5464
5758
  await checkSensitiveAccessUtil(db, data.patientId, requesterId, requesterRoles);
5465
5759
  const validatedData = createPatientSensitiveInfoSchema.parse(data);
5466
- const sensitiveDoc = await getDoc10(getSensitiveInfoDocRef(db, data.patientId));
5760
+ const sensitiveDoc = await getDoc11(getSensitiveInfoDocRef(db, data.patientId));
5467
5761
  if (sensitiveDoc.exists()) {
5468
5762
  throw new Error("Sensitive information already exists for this patient");
5469
5763
  }
@@ -5484,7 +5778,7 @@ var createSensitiveInfoUtil = async (db, data, requesterId, requesterRoles, medi
5484
5778
  updatedAt: serverTimestamp9()
5485
5779
  };
5486
5780
  await setDoc4(getSensitiveInfoDocRef(db, data.patientId), sensitiveInfoData);
5487
- const createdDoc = await getDoc10(getSensitiveInfoDocRef(db, data.patientId));
5781
+ const createdDoc = await getDoc11(getSensitiveInfoDocRef(db, data.patientId));
5488
5782
  if (!createdDoc.exists()) {
5489
5783
  throw new Error("Failed to create sensitive information");
5490
5784
  }
@@ -5499,7 +5793,7 @@ var createSensitiveInfoUtil = async (db, data, requesterId, requesterRoles, medi
5499
5793
  var getSensitiveInfoUtil = async (db, patientId, requesterId, requesterRoles) => {
5500
5794
  await checkSensitiveAccessUtil(db, patientId, requesterId, requesterRoles);
5501
5795
  await initSensitiveInfoDocIfNotExists(db, patientId, requesterId);
5502
- const sensitiveDoc = await getDoc10(getSensitiveInfoDocRef(db, patientId));
5796
+ const sensitiveDoc = await getDoc11(getSensitiveInfoDocRef(db, patientId));
5503
5797
  return sensitiveDoc.exists() ? sensitiveDoc.data() : null;
5504
5798
  };
5505
5799
  var updateSensitiveInfoUtil = async (db, patientId, data, requesterId, requesterRoles, mediaService) => {
@@ -5521,14 +5815,14 @@ var updateSensitiveInfoUtil = async (db, patientId, data, requesterId, requester
5521
5815
  updatedAt: serverTimestamp9()
5522
5816
  };
5523
5817
  await updateDoc8(getSensitiveInfoDocRef(db, patientId), updateData);
5524
- const updatedDoc = await getDoc10(getSensitiveInfoDocRef(db, patientId));
5818
+ const updatedDoc = await getDoc11(getSensitiveInfoDocRef(db, patientId));
5525
5819
  if (!updatedDoc.exists()) {
5526
5820
  throw new Error("Failed to retrieve updated sensitive information");
5527
5821
  }
5528
5822
  return updatedDoc.data();
5529
5823
  };
5530
5824
  var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
5531
- const patientDoc = await getDoc10(getPatientDocRef(db, patientId));
5825
+ const patientDoc = await getDoc11(getPatientDocRef(db, patientId));
5532
5826
  if (!patientDoc.exists()) {
5533
5827
  throw new Error("Patient profile not found");
5534
5828
  }
@@ -5539,7 +5833,7 @@ var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
5539
5833
  if (patientData.userRef) {
5540
5834
  throw new Error("Patient profile has already been claimed");
5541
5835
  }
5542
- const sensitiveDoc = await getDoc10(getSensitiveInfoDocRef(db, patientId));
5836
+ const sensitiveDoc = await getDoc11(getSensitiveInfoDocRef(db, patientId));
5543
5837
  if (!sensitiveDoc.exists()) {
5544
5838
  throw new Error("Patient sensitive information not found");
5545
5839
  }
@@ -5551,7 +5845,7 @@ var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
5551
5845
  userRef: userId,
5552
5846
  updatedAt: serverTimestamp9()
5553
5847
  });
5554
- const updatedDoc = await getDoc10(getSensitiveInfoDocRef(db, patientId));
5848
+ const updatedDoc = await getDoc11(getSensitiveInfoDocRef(db, patientId));
5555
5849
  if (!updatedDoc.exists()) {
5556
5850
  throw new Error("Failed to retrieve updated sensitive information");
5557
5851
  }
@@ -5560,7 +5854,7 @@ var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
5560
5854
 
5561
5855
  // src/services/patient/utils/docs.utils.ts
5562
5856
  var getPatientDocRef = (db, patientId) => {
5563
- return doc11(db, PATIENTS_COLLECTION, patientId);
5857
+ return doc12(db, PATIENTS_COLLECTION, patientId);
5564
5858
  };
5565
5859
  var getPatientDocRefByUserRef = async (db, userRef) => {
5566
5860
  const patientsRef = collection8(db, PATIENTS_COLLECTION);
@@ -5569,12 +5863,12 @@ var getPatientDocRefByUserRef = async (db, userRef) => {
5569
5863
  if (querySnapshot.empty) {
5570
5864
  throw new Error("Patient profile not found");
5571
5865
  }
5572
- return doc11(db, PATIENTS_COLLECTION, querySnapshot.docs[0].id);
5866
+ return doc12(db, PATIENTS_COLLECTION, querySnapshot.docs[0].id);
5573
5867
  };
5574
5868
  var getSensitiveInfoDocRef = (db, patientId) => {
5575
5869
  const path = `${PATIENTS_COLLECTION}/${patientId}/${PATIENT_SENSITIVE_INFO_COLLECTION}/${patientId}`;
5576
5870
  console.log(`[getSensitiveInfoDocRef] Creating reference with path: ${path}`);
5577
- return doc11(
5871
+ return doc12(
5578
5872
  db,
5579
5873
  PATIENTS_COLLECTION,
5580
5874
  patientId,
@@ -5585,7 +5879,7 @@ var getSensitiveInfoDocRef = (db, patientId) => {
5585
5879
  var getLocationInfoDocRef = (db, patientId) => {
5586
5880
  const path = `${PATIENTS_COLLECTION}/${patientId}/${PATIENT_LOCATION_INFO_COLLECTION}/${patientId}`;
5587
5881
  console.log(`[getLocationInfoDocRef] Creating reference with path: ${path}`);
5588
- return doc11(
5882
+ return doc12(
5589
5883
  db,
5590
5884
  PATIENTS_COLLECTION,
5591
5885
  patientId,
@@ -5596,7 +5890,7 @@ var getLocationInfoDocRef = (db, patientId) => {
5596
5890
  var getMedicalInfoDocRef = (db, patientId) => {
5597
5891
  const path = `${PATIENTS_COLLECTION}/${patientId}/${PATIENT_MEDICAL_INFO_COLLECTION}/${patientId}`;
5598
5892
  console.log(`[getMedicalInfoDocRef] Creating reference with path: ${path}`);
5599
- return doc11(
5893
+ return doc12(
5600
5894
  db,
5601
5895
  PATIENTS_COLLECTION,
5602
5896
  patientId,
@@ -5613,7 +5907,7 @@ var initSensitiveInfoDocIfNotExists = async (db, patientId, userRef) => {
5613
5907
  console.log(
5614
5908
  `[initSensitiveInfoDocIfNotExists] Got document reference: ${sensitiveInfoRef.path}`
5615
5909
  );
5616
- const sensitiveDoc = await getDoc11(sensitiveInfoRef);
5910
+ const sensitiveDoc = await getDoc12(sensitiveInfoRef);
5617
5911
  console.log(
5618
5912
  `[initSensitiveInfoDocIfNotExists] Document exists: ${sensitiveDoc.exists()}`
5619
5913
  );
@@ -5637,7 +5931,7 @@ var initSensitiveInfoDocIfNotExists = async (db, patientId, userRef) => {
5637
5931
  )
5638
5932
  );
5639
5933
  await createSensitiveInfoUtil(db, defaultSensitiveInfo, userRef);
5640
- const verifyDoc = await getDoc11(sensitiveInfoRef);
5934
+ const verifyDoc = await getDoc12(sensitiveInfoRef);
5641
5935
  console.log(
5642
5936
  `[initSensitiveInfoDocIfNotExists] Verification - document exists: ${verifyDoc.exists()}`
5643
5937
  );
@@ -5655,7 +5949,7 @@ var initSensitiveInfoDocIfNotExists = async (db, patientId, userRef) => {
5655
5949
 
5656
5950
  // src/services/patient/utils/location.utils.ts
5657
5951
  import {
5658
- getDoc as getDoc12,
5952
+ getDoc as getDoc13,
5659
5953
  updateDoc as updateDoc9,
5660
5954
  setDoc as setDoc6,
5661
5955
  serverTimestamp as serverTimestamp11
@@ -5693,7 +5987,7 @@ var createLocationInfoUtil = async (db, data, requesterId) => {
5693
5987
  updatedAt: serverTimestamp11()
5694
5988
  };
5695
5989
  await setDoc6(getLocationInfoDocRef(db, data.patientId), locationData);
5696
- const locationDoc = await getDoc12(getLocationInfoDocRef(db, data.patientId));
5990
+ const locationDoc = await getDoc13(getLocationInfoDocRef(db, data.patientId));
5697
5991
  if (!locationDoc.exists()) {
5698
5992
  throw new Error("Failed to create location information");
5699
5993
  }
@@ -5709,7 +6003,7 @@ var getLocationInfoUtil = async (db, patientId, requesterId) => {
5709
6003
  if (patientId !== requesterId) {
5710
6004
  throw new Error("Unauthorized access to location information");
5711
6005
  }
5712
- const locationDoc = await getDoc12(getLocationInfoDocRef(db, patientId));
6006
+ const locationDoc = await getDoc13(getLocationInfoDocRef(db, patientId));
5713
6007
  return locationDoc.exists() ? locationDoc.data() : null;
5714
6008
  };
5715
6009
  var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
@@ -5737,7 +6031,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
5737
6031
 
5738
6032
  // src/services/patient/utils/medical-stuff.utils.ts
5739
6033
  import {
5740
- getDoc as getDoc13,
6034
+ getDoc as getDoc14,
5741
6035
  updateDoc as updateDoc10,
5742
6036
  arrayUnion as arrayUnion2,
5743
6037
  arrayRemove as arrayRemove2,
@@ -5752,7 +6046,7 @@ var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
5752
6046
  assignedBy,
5753
6047
  isActive: true
5754
6048
  };
5755
- const patientDoc = await getDoc13(getPatientDocRef(db, patientId));
6049
+ const patientDoc = await getDoc14(getPatientDocRef(db, patientId));
5756
6050
  if (!patientDoc.exists()) throw new Error("Patient profile not found");
5757
6051
  const patientData = patientDoc.data();
5758
6052
  const existingDoctorIndex = (_a = patientData.doctors) == null ? void 0 : _a.findIndex(
@@ -5779,7 +6073,7 @@ var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
5779
6073
  var removeDoctorUtil = async (db, patientId, doctorRef) => {
5780
6074
  var _a;
5781
6075
  const patientDocRef = getPatientDocRef(db, patientId);
5782
- const patientDoc = await getDoc13(patientDocRef);
6076
+ const patientDoc = await getDoc14(patientDocRef);
5783
6077
  if (!patientDoc.exists()) throw new Error("Patient profile not found");
5784
6078
  const patientData = patientDoc.data();
5785
6079
  const updatedDoctors = ((_a = patientData.doctors) == null ? void 0 : _a.filter((doctor) => doctor.userRef !== doctorRef)) || [];
@@ -5799,7 +6093,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
5799
6093
  assignedBy,
5800
6094
  isActive: true
5801
6095
  };
5802
- const patientDoc = await getDoc13(getPatientDocRef(db, patientId));
6096
+ const patientDoc = await getDoc14(getPatientDocRef(db, patientId));
5803
6097
  if (!patientDoc.exists()) throw new Error("Patient profile not found");
5804
6098
  const patientData = patientDoc.data();
5805
6099
  const existingClinicIndex = (_a = patientData.clinics) == null ? void 0 : _a.findIndex(
@@ -5826,7 +6120,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
5826
6120
  var removeClinicUtil = async (db, patientId, clinicId) => {
5827
6121
  var _a;
5828
6122
  const patientDocRef = getPatientDocRef(db, patientId);
5829
- const patientDoc = await getDoc13(patientDocRef);
6123
+ const patientDoc = await getDoc14(patientDocRef);
5830
6124
  if (!patientDoc.exists()) throw new Error("Patient profile not found");
5831
6125
  const patientData = patientDoc.data();
5832
6126
  const updatedClinics = ((_a = patientData.clinics) == null ? void 0 : _a.filter((clinic) => clinic.clinicId !== clinicId)) || [];
@@ -5841,7 +6135,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
5841
6135
 
5842
6136
  // src/services/patient/utils/medical.utils.ts
5843
6137
  import {
5844
- getDoc as getDoc14,
6138
+ getDoc as getDoc15,
5845
6139
  updateDoc as updateDoc11,
5846
6140
  setDoc as setDoc7,
5847
6141
  serverTimestamp as serverTimestamp13,
@@ -5849,7 +6143,7 @@ import {
5849
6143
  } from "firebase/firestore";
5850
6144
  var ensureMedicalInfoExists = async (db, patientId, requesterId) => {
5851
6145
  const medicalInfoRef = getMedicalInfoDocRef(db, patientId);
5852
- const medicalInfoDoc = await getDoc14(medicalInfoRef);
6146
+ const medicalInfoDoc = await getDoc15(medicalInfoRef);
5853
6147
  if (!medicalInfoDoc.exists()) {
5854
6148
  const defaultData = {
5855
6149
  ...DEFAULT_MEDICAL_INFO,
@@ -5863,7 +6157,7 @@ var ensureMedicalInfoExists = async (db, patientId, requesterId) => {
5863
6157
  };
5864
6158
  var checkMedicalAccessUtil = async (db, patientId, requesterId, requesterRoles) => {
5865
6159
  var _a;
5866
- const patientDoc = await getDoc14(getPatientDocRef(db, patientId));
6160
+ const patientDoc = await getDoc15(getPatientDocRef(db, patientId));
5867
6161
  if (!patientDoc.exists()) {
5868
6162
  throw new Error("Patient profile not found");
5869
6163
  }
@@ -5913,10 +6207,10 @@ var createMedicalInfoUtil = async (db, patientId, data, requesterId, requesterRo
5913
6207
  var getMedicalInfoUtil = async (db, patientId, requesterId, requesterRoles) => {
5914
6208
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
5915
6209
  const docRef = getMedicalInfoDocRef(db, patientId);
5916
- const snapshot = await getDoc14(docRef);
6210
+ const snapshot = await getDoc15(docRef);
5917
6211
  if (!snapshot.exists()) {
5918
6212
  await ensureMedicalInfoExists(db, patientId, requesterId);
5919
- const newSnapshot = await getDoc14(docRef);
6213
+ const newSnapshot = await getDoc15(docRef);
5920
6214
  return patientMedicalInfoSchema.parse(newSnapshot.data());
5921
6215
  }
5922
6216
  return patientMedicalInfoSchema.parse(snapshot.data());
@@ -5945,7 +6239,7 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
5945
6239
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
5946
6240
  const validatedData = updateAllergySchema.parse(data);
5947
6241
  const { allergyIndex, ...updateData } = validatedData;
5948
- const docSnapshot = await getDoc14(getMedicalInfoDocRef(db, patientId));
6242
+ const docSnapshot = await getDoc15(getMedicalInfoDocRef(db, patientId));
5949
6243
  if (!docSnapshot.exists()) throw new Error("Medical info not found");
5950
6244
  const medicalInfo = patientMedicalInfoSchema.parse(docSnapshot.data());
5951
6245
  if (allergyIndex >= medicalInfo.allergies.length) {
@@ -5964,9 +6258,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
5964
6258
  };
5965
6259
  var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
5966
6260
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
5967
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
5968
- if (!doc44.exists()) throw new Error("Medical info not found");
5969
- const medicalInfo = doc44.data();
6261
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6262
+ if (!doc45.exists()) throw new Error("Medical info not found");
6263
+ const medicalInfo = doc45.data();
5970
6264
  if (allergyIndex >= medicalInfo.allergies.length) {
5971
6265
  throw new Error("Invalid allergy index");
5972
6266
  }
@@ -5993,9 +6287,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
5993
6287
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
5994
6288
  const validatedData = updateBlockingConditionSchema.parse(data);
5995
6289
  const { conditionIndex, ...updateData } = validatedData;
5996
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
5997
- if (!doc44.exists()) throw new Error("Medical info not found");
5998
- const medicalInfo = doc44.data();
6290
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6291
+ if (!doc45.exists()) throw new Error("Medical info not found");
6292
+ const medicalInfo = doc45.data();
5999
6293
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
6000
6294
  throw new Error("Invalid blocking condition index");
6001
6295
  }
@@ -6012,9 +6306,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
6012
6306
  };
6013
6307
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
6014
6308
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6015
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
6016
- if (!doc44.exists()) throw new Error("Medical info not found");
6017
- const medicalInfo = doc44.data();
6309
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6310
+ if (!doc45.exists()) throw new Error("Medical info not found");
6311
+ const medicalInfo = doc45.data();
6018
6312
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
6019
6313
  throw new Error("Invalid blocking condition index");
6020
6314
  }
@@ -6041,9 +6335,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
6041
6335
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6042
6336
  const validatedData = updateContraindicationSchema.parse(data);
6043
6337
  const { contraindicationIndex, ...updateData } = validatedData;
6044
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
6045
- if (!doc44.exists()) throw new Error("Medical info not found");
6046
- const medicalInfo = doc44.data();
6338
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6339
+ if (!doc45.exists()) throw new Error("Medical info not found");
6340
+ const medicalInfo = doc45.data();
6047
6341
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
6048
6342
  throw new Error("Invalid contraindication index");
6049
6343
  }
@@ -6060,9 +6354,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
6060
6354
  };
6061
6355
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
6062
6356
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6063
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
6064
- if (!doc44.exists()) throw new Error("Medical info not found");
6065
- const medicalInfo = doc44.data();
6357
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6358
+ if (!doc45.exists()) throw new Error("Medical info not found");
6359
+ const medicalInfo = doc45.data();
6066
6360
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
6067
6361
  throw new Error("Invalid contraindication index");
6068
6362
  }
@@ -6089,9 +6383,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
6089
6383
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6090
6384
  const validatedData = updateMedicationSchema.parse(data);
6091
6385
  const { medicationIndex, ...updateData } = validatedData;
6092
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
6093
- if (!doc44.exists()) throw new Error("Medical info not found");
6094
- const medicalInfo = doc44.data();
6386
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6387
+ if (!doc45.exists()) throw new Error("Medical info not found");
6388
+ const medicalInfo = doc45.data();
6095
6389
  if (medicationIndex >= medicalInfo.currentMedications.length) {
6096
6390
  throw new Error("Invalid medication index");
6097
6391
  }
@@ -6108,9 +6402,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
6108
6402
  };
6109
6403
  var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
6110
6404
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
6111
- const doc44 = await getDoc14(getMedicalInfoDocRef(db, patientId));
6112
- if (!doc44.exists()) throw new Error("Medical info not found");
6113
- const medicalInfo = doc44.data();
6405
+ const doc45 = await getDoc15(getMedicalInfoDocRef(db, patientId));
6406
+ if (!doc45.exists()) throw new Error("Medical info not found");
6407
+ const medicalInfo = doc45.data();
6114
6408
  if (medicationIndex >= medicalInfo.currentMedications.length) {
6115
6409
  throw new Error("Invalid medication index");
6116
6410
  }
@@ -6126,7 +6420,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
6126
6420
 
6127
6421
  // src/services/patient/utils/profile.utils.ts
6128
6422
  import {
6129
- getDoc as getDoc15,
6423
+ getDoc as getDoc16,
6130
6424
  setDoc as setDoc8,
6131
6425
  updateDoc as updateDoc12,
6132
6426
  arrayUnion as arrayUnion4,
@@ -6140,7 +6434,7 @@ import {
6140
6434
  getDocs as getDocs9,
6141
6435
  limit as limit6,
6142
6436
  startAfter as startAfter5,
6143
- doc as doc13
6437
+ doc as doc14
6144
6438
  } from "firebase/firestore";
6145
6439
  import { z as z13 } from "zod";
6146
6440
  var createPatientProfileUtil = async (db, data, generateId2) => {
@@ -6229,7 +6523,7 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
6229
6523
  }
6230
6524
  }
6231
6525
  console.log(`[createPatientProfileUtil] Verifying patient document exists`);
6232
- const patientDoc = await getDoc15(getPatientDocRef(db, patientId));
6526
+ const patientDoc = await getDoc16(getPatientDocRef(db, patientId));
6233
6527
  if (!patientDoc.exists()) {
6234
6528
  console.error(
6235
6529
  `[createPatientProfileUtil] Patient document not found after creation`
@@ -6252,13 +6546,13 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
6252
6546
  }
6253
6547
  };
6254
6548
  var getPatientProfileUtil = async (db, patientId) => {
6255
- const patientDoc = await getDoc15(getPatientDocRef(db, patientId));
6549
+ const patientDoc = await getDoc16(getPatientDocRef(db, patientId));
6256
6550
  return patientDoc.exists() ? patientDoc.data() : null;
6257
6551
  };
6258
6552
  var getPatientProfileByUserRefUtil = async (db, userRef) => {
6259
6553
  try {
6260
6554
  const docRef = await getPatientDocRefByUserRef(db, userRef);
6261
- const patientDoc = await getDoc15(docRef);
6555
+ const patientDoc = await getDoc16(docRef);
6262
6556
  return patientDoc.exists() ? patientDoc.data() : null;
6263
6557
  } catch (error) {
6264
6558
  return null;
@@ -6289,7 +6583,7 @@ var updatePatientProfileUtil = async (db, patientId, data) => {
6289
6583
  updatedAt: serverTimestamp14()
6290
6584
  };
6291
6585
  await updateDoc12(getPatientDocRef(db, patientId), updateData);
6292
- const updatedDoc = await getDoc15(getPatientDocRef(db, patientId));
6586
+ const updatedDoc = await getDoc16(getPatientDocRef(db, patientId));
6293
6587
  if (!updatedDoc.exists()) {
6294
6588
  throw new Error("Patient profile not found after update");
6295
6589
  }
@@ -6302,7 +6596,7 @@ var updatePatientProfileUtil = async (db, patientId, data) => {
6302
6596
  var updatePatientProfileByUserRefUtil = async (db, userRef, data) => {
6303
6597
  try {
6304
6598
  const docRef = await getPatientDocRefByUserRef(db, userRef);
6305
- const patientDoc = await getDoc15(docRef);
6599
+ const patientDoc = await getDoc16(docRef);
6306
6600
  if (!patientDoc.exists()) {
6307
6601
  throw new Error("Patient profile not found");
6308
6602
  }
@@ -6413,7 +6707,7 @@ var searchPatientsUtil = async (db, params, requester) => {
6413
6707
  const finalQuery = query9(patientsCollectionRef, ...constraints);
6414
6708
  const querySnapshot = await getDocs9(finalQuery);
6415
6709
  const patients = querySnapshot.docs.map(
6416
- (doc44) => doc44.data()
6710
+ (doc45) => doc45.data()
6417
6711
  );
6418
6712
  console.log(
6419
6713
  `[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
@@ -6436,8 +6730,8 @@ var getAllPatientsUtil = async (db, options) => {
6436
6730
  q = query9(q, limit6(options.limit));
6437
6731
  }
6438
6732
  if (options == null ? void 0 : options.startAfter) {
6439
- const startAfterDoc = await getDoc15(
6440
- doc13(db, PATIENTS_COLLECTION, options.startAfter)
6733
+ const startAfterDoc = await getDoc16(
6734
+ doc14(db, PATIENTS_COLLECTION, options.startAfter)
6441
6735
  );
6442
6736
  if (startAfterDoc.exists()) {
6443
6737
  q = query9(q, startAfter5(startAfterDoc));
@@ -6445,8 +6739,8 @@ var getAllPatientsUtil = async (db, options) => {
6445
6739
  }
6446
6740
  const patientsSnapshot = await getDocs9(q);
6447
6741
  const patients = [];
6448
- patientsSnapshot.forEach((doc44) => {
6449
- patients.push(doc44.data());
6742
+ patientsSnapshot.forEach((doc45) => {
6743
+ patients.push(doc45.data());
6450
6744
  });
6451
6745
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
6452
6746
  return patients;
@@ -6461,8 +6755,8 @@ var getAllPatientsUtil = async (db, options) => {
6461
6755
  // src/services/patient/utils/token.utils.ts
6462
6756
  import {
6463
6757
  collection as collection10,
6464
- doc as doc14,
6465
- getDoc as getDoc16,
6758
+ doc as doc15,
6759
+ getDoc as getDoc17,
6466
6760
  getDocs as getDocs10,
6467
6761
  query as query10,
6468
6762
  where as where10,
@@ -6502,7 +6796,7 @@ var createPatientTokenUtil = async (db, data, createdBy, generateId2) => {
6502
6796
  var _a;
6503
6797
  const validatedData = createPatientTokenSchema.parse(data);
6504
6798
  const patientRef = getPatientDocRef(db, validatedData.patientId);
6505
- const patientDoc = await getDoc16(patientRef);
6799
+ const patientDoc = await getDoc17(patientRef);
6506
6800
  if (!patientDoc.exists() || !((_a = patientDoc.data()) == null ? void 0 : _a.isManual)) {
6507
6801
  throw new Error(
6508
6802
  "Patient profile not found or is not a manually created profile."
@@ -6522,7 +6816,7 @@ var createPatientTokenUtil = async (db, data, createdBy, generateId2) => {
6522
6816
  expiresAt: Timestamp11.fromDate(expiration)
6523
6817
  };
6524
6818
  patientTokenSchema.parse(token);
6525
- const tokenRef = doc14(
6819
+ const tokenRef = doc15(
6526
6820
  db,
6527
6821
  PATIENTS_COLLECTION,
6528
6822
  validatedData.patientId,
@@ -6555,7 +6849,7 @@ var validatePatientTokenUtil = async (db, tokenString) => {
6555
6849
  return null;
6556
6850
  };
6557
6851
  var markPatientTokenAsUsedUtil = async (db, tokenId, patientId, userId) => {
6558
- const tokenRef = doc14(
6852
+ const tokenRef = doc15(
6559
6853
  db,
6560
6854
  PATIENTS_COLLECTION,
6561
6855
  patientId,
@@ -6579,7 +6873,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
6579
6873
  if (querySnapshot.empty) {
6580
6874
  return [];
6581
6875
  }
6582
- return querySnapshot.docs.map((doc44) => doc44.data());
6876
+ return querySnapshot.docs.map((doc45) => doc45.data());
6583
6877
  };
6584
6878
  var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
6585
6879
  const tokensRef = collection10(
@@ -6597,11 +6891,11 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
6597
6891
  if (querySnapshot.empty) {
6598
6892
  return [];
6599
6893
  }
6600
- return querySnapshot.docs.map((doc44) => doc44.data());
6894
+ return querySnapshot.docs.map((doc45) => doc45.data());
6601
6895
  };
6602
6896
 
6603
6897
  // src/services/patient/utils/aesthetic-analysis.utils.ts
6604
- import { getDoc as getDoc17, updateDoc as updateDoc14, setDoc as setDoc10, serverTimestamp as serverTimestamp15, doc as doc15 } from "firebase/firestore";
6898
+ import { getDoc as getDoc18, updateDoc as updateDoc14, setDoc as setDoc10, serverTimestamp as serverTimestamp15, doc as doc16 } from "firebase/firestore";
6605
6899
 
6606
6900
  // src/validations/patient/aesthetic-analysis.schema.ts
6607
6901
  import { z as z15 } from "zod";
@@ -6655,11 +6949,11 @@ var aestheticAnalysisSchema = z15.object({
6655
6949
 
6656
6950
  // src/services/patient/utils/aesthetic-analysis.utils.ts
6657
6951
  var getAestheticAnalysisDocRef = (db, patientId) => {
6658
- return doc15(db, PATIENTS_COLLECTION, patientId, AESTHETIC_ANALYSIS_COLLECTION, patientId);
6952
+ return doc16(db, PATIENTS_COLLECTION, patientId, AESTHETIC_ANALYSIS_COLLECTION, patientId);
6659
6953
  };
6660
6954
  var checkAestheticAnalysisAccessUtil = async (db, patientId, requesterId, requesterRoles) => {
6661
6955
  var _a;
6662
- const patientDoc = await getDoc17(getPatientDocRef(db, patientId));
6956
+ const patientDoc = await getDoc18(getPatientDocRef(db, patientId));
6663
6957
  if (!patientDoc.exists()) {
6664
6958
  throw new Error("Patient profile not found");
6665
6959
  }
@@ -6714,7 +7008,7 @@ var determineStatus = (completionPercentage, selectedConcerns) => {
6714
7008
  var getAestheticAnalysisUtil = async (db, patientId, requesterId, requesterRoles) => {
6715
7009
  await checkAestheticAnalysisAccessUtil(db, patientId, requesterId, requesterRoles);
6716
7010
  const docRef = getAestheticAnalysisDocRef(db, patientId);
6717
- const snapshot = await getDoc17(docRef);
7011
+ const snapshot = await getDoc18(docRef);
6718
7012
  if (!snapshot.exists()) {
6719
7013
  return null;
6720
7014
  }
@@ -6728,7 +7022,7 @@ var createOrUpdateAestheticAnalysisUtil = async (db, patientId, data, requesterI
6728
7022
  await checkAestheticAnalysisAccessUtil(db, patientId, requesterId, requesterRoles);
6729
7023
  const validatedData = isUpdate ? updateAestheticAnalysisSchema.parse(data) : createAestheticAnalysisSchema.parse(data);
6730
7024
  const docRef = getAestheticAnalysisDocRef(db, patientId);
6731
- const snapshot = await getDoc17(docRef);
7025
+ const snapshot = await getDoc18(docRef);
6732
7026
  const requesterRole = requesterRoles.includes("practitioner" /* PRACTITIONER */) ? "PRACTITIONER" : "PATIENT";
6733
7027
  const existingData = snapshot.exists() ? snapshot.data() : null;
6734
7028
  const mergedData = {
@@ -7051,7 +7345,7 @@ var PatientService = class extends BaseService {
7051
7345
  if (!this.auth.currentUser) {
7052
7346
  throw new Error("No authenticated user");
7053
7347
  }
7054
- const userDoc = await getDoc18(doc16(this.db, "users", this.auth.currentUser.uid));
7348
+ const userDoc = await getDoc19(doc17(this.db, "users", this.auth.currentUser.uid));
7055
7349
  if (!userDoc.exists()) {
7056
7350
  throw new Error("User not found");
7057
7351
  }
@@ -7478,8 +7772,8 @@ var ClinicAdminService = class extends BaseService {
7478
7772
  // src/services/practitioner/practitioner.service.ts
7479
7773
  import {
7480
7774
  collection as collection11,
7481
- doc as doc17,
7482
- getDoc as getDoc19,
7775
+ doc as doc18,
7776
+ getDoc as getDoc20,
7483
7777
  getDocs as getDocs11,
7484
7778
  query as query11,
7485
7779
  where as where11,
@@ -7775,7 +8069,7 @@ var PractitionerService = class extends BaseService {
7775
8069
  createdAt: Timestamp14.now(),
7776
8070
  updatedAt: Timestamp14.now()
7777
8071
  });
7778
- const practitionerRef = doc17(
8072
+ const practitionerRef = doc18(
7779
8073
  this.db,
7780
8074
  PRACTITIONERS_COLLECTION,
7781
8075
  practitionerId
@@ -7883,7 +8177,7 @@ var PractitionerService = class extends BaseService {
7883
8177
  updatedAt: Timestamp14.now()
7884
8178
  });
7885
8179
  await setDoc11(
7886
- doc17(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
8180
+ doc18(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
7887
8181
  practitionerData
7888
8182
  );
7889
8183
  const savedPractitioner = await this.getPractitioner(practitionerData.id);
@@ -7905,7 +8199,7 @@ var PractitionerService = class extends BaseService {
7905
8199
  };
7906
8200
  practitionerTokenSchema.parse(token);
7907
8201
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
7908
- await setDoc11(doc17(this.db, tokenPath), token);
8202
+ await setDoc11(doc18(this.db, tokenPath), token);
7909
8203
  return { practitioner: savedPractitioner, token };
7910
8204
  } catch (error) {
7911
8205
  if (error instanceof z17.ZodError) {
@@ -7958,7 +8252,7 @@ var PractitionerService = class extends BaseService {
7958
8252
  };
7959
8253
  practitionerTokenSchema.parse(token);
7960
8254
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${validatedData.practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
7961
- await setDoc11(doc17(this.db, tokenPath), token);
8255
+ await setDoc11(doc18(this.db, tokenPath), token);
7962
8256
  return token;
7963
8257
  } catch (error) {
7964
8258
  if (error instanceof z17.ZodError) {
@@ -7983,7 +8277,7 @@ var PractitionerService = class extends BaseService {
7983
8277
  where11("expiresAt", ">", Timestamp14.now())
7984
8278
  );
7985
8279
  const querySnapshot = await getDocs11(q);
7986
- return querySnapshot.docs.map((doc44) => doc44.data());
8280
+ return querySnapshot.docs.map((doc45) => doc45.data());
7987
8281
  }
7988
8282
  /**
7989
8283
  * Gets a token by its string value and validates it
@@ -8046,7 +8340,7 @@ var PractitionerService = class extends BaseService {
8046
8340
  * @param userId ID of the user using the token
8047
8341
  */
8048
8342
  async markTokenAsUsed(tokenId, practitionerId, userId) {
8049
- const tokenRef = doc17(
8343
+ const tokenRef = doc18(
8050
8344
  this.db,
8051
8345
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
8052
8346
  );
@@ -8060,8 +8354,8 @@ var PractitionerService = class extends BaseService {
8060
8354
  * Dohvata zdravstvenog radnika po ID-u
8061
8355
  */
8062
8356
  async getPractitioner(practitionerId) {
8063
- const practitionerDoc = await getDoc19(
8064
- doc17(this.db, PRACTITIONERS_COLLECTION, practitionerId)
8357
+ const practitionerDoc = await getDoc20(
8358
+ doc18(this.db, PRACTITIONERS_COLLECTION, practitionerId)
8065
8359
  );
8066
8360
  if (!practitionerDoc.exists()) {
8067
8361
  return null;
@@ -8093,7 +8387,7 @@ var PractitionerService = class extends BaseService {
8093
8387
  where11("status", "==", "active" /* ACTIVE */)
8094
8388
  );
8095
8389
  const querySnapshot = await getDocs11(q);
8096
- return querySnapshot.docs.map((doc44) => doc44.data());
8390
+ return querySnapshot.docs.map((doc45) => doc45.data());
8097
8391
  }
8098
8392
  /**
8099
8393
  * Dohvata sve zdravstvene radnike za određenu kliniku
@@ -8105,7 +8399,7 @@ var PractitionerService = class extends BaseService {
8105
8399
  where11("isActive", "==", true)
8106
8400
  );
8107
8401
  const querySnapshot = await getDocs11(q);
8108
- return querySnapshot.docs.map((doc44) => doc44.data());
8402
+ return querySnapshot.docs.map((doc45) => doc45.data());
8109
8403
  }
8110
8404
  /**
8111
8405
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
@@ -8117,7 +8411,7 @@ var PractitionerService = class extends BaseService {
8117
8411
  where11("status", "==", "draft" /* DRAFT */)
8118
8412
  );
8119
8413
  const querySnapshot = await getDocs11(q);
8120
- return querySnapshot.docs.map((doc44) => doc44.data());
8414
+ return querySnapshot.docs.map((doc45) => doc45.data());
8121
8415
  }
8122
8416
  /**
8123
8417
  * Updates a practitioner
@@ -8125,12 +8419,12 @@ var PractitionerService = class extends BaseService {
8125
8419
  async updatePractitioner(practitionerId, data) {
8126
8420
  try {
8127
8421
  const validData = data;
8128
- const practitionerRef = doc17(
8422
+ const practitionerRef = doc18(
8129
8423
  this.db,
8130
8424
  PRACTITIONERS_COLLECTION,
8131
8425
  practitionerId
8132
8426
  );
8133
- const practitionerDoc = await getDoc19(practitionerRef);
8427
+ const practitionerDoc = await getDoc20(practitionerRef);
8134
8428
  if (!practitionerDoc.exists()) {
8135
8429
  throw new Error(`Practitioner ${practitionerId} not found`);
8136
8430
  }
@@ -8171,12 +8465,12 @@ var PractitionerService = class extends BaseService {
8171
8465
  async addClinic(practitionerId, clinicId) {
8172
8466
  var _a;
8173
8467
  try {
8174
- const practitionerRef = doc17(
8468
+ const practitionerRef = doc18(
8175
8469
  this.db,
8176
8470
  PRACTITIONERS_COLLECTION,
8177
8471
  practitionerId
8178
8472
  );
8179
- const practitionerDoc = await getDoc19(practitionerRef);
8473
+ const practitionerDoc = await getDoc20(practitionerRef);
8180
8474
  if (!practitionerDoc.exists()) {
8181
8475
  throw new Error(`Practitioner ${practitionerId} not found`);
8182
8476
  }
@@ -8204,12 +8498,12 @@ var PractitionerService = class extends BaseService {
8204
8498
  */
8205
8499
  async removeClinic(practitionerId, clinicId) {
8206
8500
  try {
8207
- const practitionerRef = doc17(
8501
+ const practitionerRef = doc18(
8208
8502
  this.db,
8209
8503
  PRACTITIONERS_COLLECTION,
8210
8504
  practitionerId
8211
8505
  );
8212
- const practitionerDoc = await getDoc19(practitionerRef);
8506
+ const practitionerDoc = await getDoc20(practitionerRef);
8213
8507
  if (!practitionerDoc.exists()) {
8214
8508
  throw new Error(`Practitioner ${practitionerId} not found`);
8215
8509
  }
@@ -8249,7 +8543,7 @@ var PractitionerService = class extends BaseService {
8249
8543
  if (!practitioner) {
8250
8544
  throw new Error("Practitioner not found");
8251
8545
  }
8252
- await deleteDoc4(doc17(this.db, PRACTITIONERS_COLLECTION, practitionerId));
8546
+ await deleteDoc4(doc18(this.db, PRACTITIONERS_COLLECTION, practitionerId));
8253
8547
  }
8254
8548
  /**
8255
8549
  * Validates a registration token and claims the associated draft practitioner profile
@@ -8334,7 +8628,7 @@ var PractitionerService = class extends BaseService {
8334
8628
  );
8335
8629
  const querySnapshot = await getDocs11(q);
8336
8630
  const practitioners = querySnapshot.docs.map(
8337
- (doc44) => doc44.data()
8631
+ (doc45) => doc45.data()
8338
8632
  );
8339
8633
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8340
8634
  return {
@@ -8419,7 +8713,7 @@ var PractitionerService = class extends BaseService {
8419
8713
  );
8420
8714
  const querySnapshot = await getDocs11(q);
8421
8715
  const practitioners = querySnapshot.docs.map(
8422
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8716
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8423
8717
  );
8424
8718
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8425
8719
  console.log(
@@ -8483,7 +8777,7 @@ var PractitionerService = class extends BaseService {
8483
8777
  );
8484
8778
  const querySnapshot = await getDocs11(q);
8485
8779
  let practitioners = querySnapshot.docs.map(
8486
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8780
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8487
8781
  );
8488
8782
  if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
8489
8783
  const location = filters.location;
@@ -8528,7 +8822,7 @@ var PractitionerService = class extends BaseService {
8528
8822
  );
8529
8823
  const querySnapshot = await getDocs11(q);
8530
8824
  let practitioners = querySnapshot.docs.map(
8531
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8825
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8532
8826
  );
8533
8827
  practitioners = this.applyInMemoryFilters(practitioners, filters);
8534
8828
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -8558,7 +8852,7 @@ var PractitionerService = class extends BaseService {
8558
8852
  );
8559
8853
  const querySnapshot = await getDocs11(q);
8560
8854
  let practitioners = querySnapshot.docs.map(
8561
- (doc44) => ({ ...doc44.data(), id: doc44.id })
8855
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
8562
8856
  );
8563
8857
  practitioners = this.applyInMemoryFilters(practitioners, filters);
8564
8858
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -8945,12 +9239,12 @@ var UserService = class extends BaseService {
8945
9239
  updatedAt: serverTimestamp18(),
8946
9240
  lastLoginAt: serverTimestamp18()
8947
9241
  };
8948
- await setDoc12(doc18(this.db, USERS_COLLECTION, userData.uid), userData);
9242
+ await setDoc12(doc19(this.db, USERS_COLLECTION, userData.uid), userData);
8949
9243
  if (options == null ? void 0 : options.skipProfileCreation) {
8950
9244
  return this.getUserById(userData.uid);
8951
9245
  }
8952
9246
  const profiles = await this.createProfilesForRoles(userData.uid, roles, options);
8953
- await updateDoc17(doc18(this.db, USERS_COLLECTION, userData.uid), profiles);
9247
+ await updateDoc17(doc19(this.db, USERS_COLLECTION, userData.uid), profiles);
8954
9248
  return this.getUserById(userData.uid);
8955
9249
  }
8956
9250
  /**
@@ -9083,7 +9377,7 @@ var UserService = class extends BaseService {
9083
9377
  * Dohvata korisnika po ID-u
9084
9378
  */
9085
9379
  async getUserById(uid) {
9086
- const userDoc = await getDoc20(doc18(this.db, USERS_COLLECTION, uid));
9380
+ const userDoc = await getDoc21(doc19(this.db, USERS_COLLECTION, uid));
9087
9381
  if (!userDoc.exists()) {
9088
9382
  throw USER_ERRORS.NOT_FOUND;
9089
9383
  }
@@ -9105,15 +9399,15 @@ var UserService = class extends BaseService {
9105
9399
  const constraints = [where12("roles", "array-contains", role)];
9106
9400
  const q = query12(collection12(this.db, USERS_COLLECTION), ...constraints);
9107
9401
  const querySnapshot = await getDocs12(q);
9108
- const users = querySnapshot.docs.map((doc44) => doc44.data());
9402
+ const users = querySnapshot.docs.map((doc45) => doc45.data());
9109
9403
  return users.map((userData) => userSchema.parse(userData));
9110
9404
  }
9111
9405
  /**
9112
9406
  * Ažurira timestamp poslednjeg logovanja
9113
9407
  */
9114
9408
  async updateUserLoginTimestamp(uid) {
9115
- const userRef = doc18(this.db, USERS_COLLECTION, uid);
9116
- const userDoc = await getDoc20(userRef);
9409
+ const userRef = doc19(this.db, USERS_COLLECTION, uid);
9410
+ const userDoc = await getDoc21(userRef);
9117
9411
  if (!userDoc.exists()) {
9118
9412
  throw AUTH_ERRORS.USER_NOT_FOUND;
9119
9413
  }
@@ -9124,8 +9418,8 @@ var UserService = class extends BaseService {
9124
9418
  return this.getUserById(uid);
9125
9419
  }
9126
9420
  async upgradeAnonymousUser(uid, email) {
9127
- const userRef = doc18(this.db, USERS_COLLECTION, uid);
9128
- const userDoc = await getDoc20(userRef);
9421
+ const userRef = doc19(this.db, USERS_COLLECTION, uid);
9422
+ const userDoc = await getDoc21(userRef);
9129
9423
  if (!userDoc.exists()) {
9130
9424
  throw USER_ERRORS.NOT_FOUND;
9131
9425
  }
@@ -9137,8 +9431,8 @@ var UserService = class extends BaseService {
9137
9431
  return this.getUserById(uid);
9138
9432
  }
9139
9433
  async updateUser(uid, updates) {
9140
- const userRef = doc18(this.db, USERS_COLLECTION, uid);
9141
- const userDoc = await getDoc20(userRef);
9434
+ const userRef = doc19(this.db, USERS_COLLECTION, uid);
9435
+ const userDoc = await getDoc21(userRef);
9142
9436
  if (!userDoc.exists()) {
9143
9437
  throw USER_ERRORS.NOT_FOUND;
9144
9438
  }
@@ -9169,7 +9463,7 @@ var UserService = class extends BaseService {
9169
9463
  const user = await this.getUserById(uid);
9170
9464
  if (user.roles.includes(role)) return;
9171
9465
  const profiles = await this.createProfilesForRoles(uid, [role], options);
9172
- await updateDoc17(doc18(this.db, USERS_COLLECTION, uid), {
9466
+ await updateDoc17(doc19(this.db, USERS_COLLECTION, uid), {
9173
9467
  roles: [...user.roles, role],
9174
9468
  ...profiles,
9175
9469
  updatedAt: serverTimestamp18()
@@ -9198,15 +9492,15 @@ var UserService = class extends BaseService {
9198
9492
  }
9199
9493
  break;
9200
9494
  }
9201
- await updateDoc17(doc18(this.db, USERS_COLLECTION, uid), {
9495
+ await updateDoc17(doc19(this.db, USERS_COLLECTION, uid), {
9202
9496
  roles: user.roles.filter((r) => r !== role),
9203
9497
  updatedAt: serverTimestamp18()
9204
9498
  });
9205
9499
  }
9206
9500
  // Delete operations
9207
9501
  async deleteUser(uid) {
9208
- const userRef = doc18(this.db, USERS_COLLECTION, uid);
9209
- const userDoc = await getDoc20(userRef);
9502
+ const userRef = doc19(this.db, USERS_COLLECTION, uid);
9503
+ const userDoc = await getDoc21(userRef);
9210
9504
  if (!userDoc.exists()) {
9211
9505
  throw USER_ERRORS.NOT_FOUND;
9212
9506
  }
@@ -9271,9 +9565,9 @@ var BillingTransactionsService = class extends BaseService {
9271
9565
  const querySnapshot = await getDocs13(q);
9272
9566
  const docs = querySnapshot.docs;
9273
9567
  const hasMore = docs.length > queryLimit;
9274
- const transactions = docs.slice(0, queryLimit).map((doc44) => ({
9275
- id: doc44.id,
9276
- ...doc44.data()
9568
+ const transactions = docs.slice(0, queryLimit).map((doc45) => ({
9569
+ id: doc45.id,
9570
+ ...doc45.data()
9277
9571
  }));
9278
9572
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
9279
9573
  return {
@@ -9349,9 +9643,9 @@ var BillingTransactionsService = class extends BaseService {
9349
9643
  const querySnapshot = await getDocs13(q);
9350
9644
  const docs = querySnapshot.docs;
9351
9645
  const hasMore = docs.length > queryLimit;
9352
- const transactions = docs.slice(0, queryLimit).map((doc44) => ({
9353
- id: doc44.id,
9354
- ...doc44.data()
9646
+ const transactions = docs.slice(0, queryLimit).map((doc45) => ({
9647
+ id: doc45.id,
9648
+ ...doc45.data()
9355
9649
  }));
9356
9650
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
9357
9651
  return {
@@ -9374,8 +9668,8 @@ var BillingTransactionsService = class extends BaseService {
9374
9668
  // src/services/clinic/utils/clinic-group.utils.ts
9375
9669
  import {
9376
9670
  collection as collection14,
9377
- doc as doc19,
9378
- getDoc as getDoc21,
9671
+ doc as doc20,
9672
+ getDoc as getDoc22,
9379
9673
  getDocs as getDocs14,
9380
9674
  query as query14,
9381
9675
  where as where14,
@@ -9507,7 +9801,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
9507
9801
  }
9508
9802
  const now = Timestamp16.now();
9509
9803
  console.log("[CLINIC_GROUP] Preparing clinic group data object");
9510
- const groupId = doc19(collection14(db, CLINIC_GROUPS_COLLECTION)).id;
9804
+ const groupId = doc20(collection14(db, CLINIC_GROUPS_COLLECTION)).id;
9511
9805
  console.log("[CLINIC_GROUP] Logo value:", {
9512
9806
  logoValue: validatedData.logo,
9513
9807
  logoType: validatedData.logo === null ? "null" : typeof validatedData.logo
@@ -9557,7 +9851,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
9557
9851
  groupId: groupData.id
9558
9852
  });
9559
9853
  try {
9560
- await setDoc13(doc19(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
9854
+ await setDoc13(doc20(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
9561
9855
  console.log("[CLINIC_GROUP] Clinic group saved successfully");
9562
9856
  } catch (firestoreError) {
9563
9857
  console.error(
@@ -9603,8 +9897,8 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
9603
9897
  }
9604
9898
  }
9605
9899
  async function getClinicGroup(db, groupId) {
9606
- const docRef = doc19(db, CLINIC_GROUPS_COLLECTION, groupId);
9607
- const docSnap = await getDoc21(docRef);
9900
+ const docRef = doc20(db, CLINIC_GROUPS_COLLECTION, groupId);
9901
+ const docSnap = await getDoc22(docRef);
9608
9902
  if (docSnap.exists()) {
9609
9903
  return docSnap.data();
9610
9904
  }
@@ -9616,7 +9910,7 @@ async function getAllActiveGroups(db) {
9616
9910
  where14("isActive", "==", true)
9617
9911
  );
9618
9912
  const querySnapshot = await getDocs14(q);
9619
- return querySnapshot.docs.map((doc44) => doc44.data());
9913
+ return querySnapshot.docs.map((doc45) => doc45.data());
9620
9914
  }
9621
9915
  async function updateClinicGroup(db, groupId, data, app) {
9622
9916
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -9647,7 +9941,7 @@ async function updateClinicGroup(db, groupId, data, app) {
9647
9941
  updatedAt: Timestamp16.now()
9648
9942
  };
9649
9943
  console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
9650
- await updateDoc18(doc19(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
9944
+ await updateDoc18(doc20(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
9651
9945
  console.log("[CLINIC_GROUP] Clinic group updated successfully");
9652
9946
  const updatedGroup = await getClinicGroup(db, groupId);
9653
9947
  if (!updatedGroup) {
@@ -10029,8 +10323,8 @@ var ClinicGroupService = class extends BaseService {
10029
10323
  // src/services/clinic/clinic.service.ts
10030
10324
  import {
10031
10325
  collection as collection18,
10032
- doc as doc21,
10033
- getDoc as getDoc23,
10326
+ doc as doc22,
10327
+ getDoc as getDoc24,
10034
10328
  getDocs as getDocs18,
10035
10329
  updateDoc as updateDoc20,
10036
10330
  serverTimestamp as serverTimestamp20,
@@ -10047,8 +10341,8 @@ import { z as z21 } from "zod";
10047
10341
  // src/services/clinic/utils/clinic.utils.ts
10048
10342
  import {
10049
10343
  collection as collection15,
10050
- doc as doc20,
10051
- getDoc as getDoc22,
10344
+ doc as doc21,
10345
+ getDoc as getDoc23,
10052
10346
  getDocs as getDocs15,
10053
10347
  query as query15,
10054
10348
  where as where15,
@@ -10065,8 +10359,8 @@ import {
10065
10359
  } from "geofire-common";
10066
10360
  import { z as z20 } from "zod";
10067
10361
  async function getClinic(db, clinicId) {
10068
- const docRef = doc20(db, CLINICS_COLLECTION, clinicId);
10069
- const docSnap = await getDoc22(docRef);
10362
+ const docRef = doc21(db, CLINICS_COLLECTION, clinicId);
10363
+ const docSnap = await getDoc23(docRef);
10070
10364
  if (docSnap.exists()) {
10071
10365
  return docSnap.data();
10072
10366
  }
@@ -10079,7 +10373,7 @@ async function getClinicsByGroup(db, groupId) {
10079
10373
  where15("isActive", "==", true)
10080
10374
  );
10081
10375
  const querySnapshot = await getDocs15(q);
10082
- return querySnapshot.docs.map((doc44) => doc44.data());
10376
+ return querySnapshot.docs.map((doc45) => doc45.data());
10083
10377
  }
10084
10378
  async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
10085
10379
  console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
@@ -10238,7 +10532,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
10238
10532
  };
10239
10533
  console.log("[CLINIC] Updating clinic in Firestore");
10240
10534
  try {
10241
- await updateDoc19(doc20(db, CLINICS_COLLECTION, clinicId), updatedData);
10535
+ await updateDoc19(doc21(db, CLINICS_COLLECTION, clinicId), updatedData);
10242
10536
  console.log("[CLINIC] Clinic updated successfully");
10243
10537
  } catch (updateError) {
10244
10538
  console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
@@ -10273,7 +10567,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
10273
10567
  }
10274
10568
  const q = query15(collection15(db, CLINICS_COLLECTION), ...constraints);
10275
10569
  const querySnapshot = await getDocs15(q);
10276
- return querySnapshot.docs.map((doc44) => doc44.data());
10570
+ return querySnapshot.docs.map((doc45) => doc45.data());
10277
10571
  }
10278
10572
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
10279
10573
  return getClinicsByAdmin(
@@ -10286,8 +10580,8 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
10286
10580
  }
10287
10581
  async function getClinicById(db, clinicId) {
10288
10582
  try {
10289
- const clinicRef = doc20(db, CLINICS_COLLECTION, clinicId);
10290
- const clinicSnapshot = await getDoc22(clinicRef);
10583
+ const clinicRef = doc21(db, CLINICS_COLLECTION, clinicId);
10584
+ const clinicSnapshot = await getDoc23(clinicRef);
10291
10585
  if (!clinicSnapshot.exists()) {
10292
10586
  return null;
10293
10587
  }
@@ -10318,11 +10612,11 @@ async function getAllClinics(db, pagination, lastDoc) {
10318
10612
  }
10319
10613
  const clinicsSnapshot = await getDocs15(clinicsQuery);
10320
10614
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
10321
- const clinics = clinicsSnapshot.docs.map((doc44) => {
10322
- const data = doc44.data();
10615
+ const clinics = clinicsSnapshot.docs.map((doc45) => {
10616
+ const data = doc45.data();
10323
10617
  return {
10324
10618
  ...data,
10325
- id: doc44.id
10619
+ id: doc45.id
10326
10620
  };
10327
10621
  });
10328
10622
  return {
@@ -10349,8 +10643,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
10349
10643
  ];
10350
10644
  const q = query15(collection15(db, CLINICS_COLLECTION), ...constraints);
10351
10645
  const querySnapshot = await getDocs15(q);
10352
- for (const doc44 of querySnapshot.docs) {
10353
- const clinic = doc44.data();
10646
+ for (const doc45 of querySnapshot.docs) {
10647
+ const clinic = doc45.data();
10354
10648
  const distance = distanceBetween2(
10355
10649
  [center.latitude, center.longitude],
10356
10650
  [clinic.location.latitude, clinic.location.longitude]
@@ -10472,8 +10766,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
10472
10766
  }
10473
10767
  const q = query16(collection16(db, CLINICS_COLLECTION), ...constraints);
10474
10768
  const querySnapshot = await getDocs16(q);
10475
- for (const doc44 of querySnapshot.docs) {
10476
- const clinic = doc44.data();
10769
+ for (const doc45 of querySnapshot.docs) {
10770
+ const clinic = doc45.data();
10477
10771
  const distance = distanceBetween3(
10478
10772
  [center.latitude, center.longitude],
10479
10773
  [clinic.location.latitude, clinic.location.longitude]
@@ -10602,7 +10896,7 @@ async function getClinicsByFilters(db, filters) {
10602
10896
  constraints.push(limit10(filters.pagination || 5));
10603
10897
  const q = query17(collection17(db, CLINICS_COLLECTION), ...constraints);
10604
10898
  const querySnapshot = await getDocs17(q);
10605
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10899
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10606
10900
  clinics = applyInMemoryFilters(clinics, filters);
10607
10901
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10608
10902
  console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
@@ -10634,7 +10928,7 @@ async function getClinicsByFilters(db, filters) {
10634
10928
  constraints.push(limit10(filters.pagination || 5));
10635
10929
  const q = query17(collection17(db, CLINICS_COLLECTION), ...constraints);
10636
10930
  const querySnapshot = await getDocs17(q);
10637
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10931
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10638
10932
  clinics = applyInMemoryFilters(clinics, filters);
10639
10933
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10640
10934
  console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
@@ -10664,7 +10958,7 @@ async function getClinicsByFilters(db, filters) {
10664
10958
  constraints.push(limit10(filters.pagination || 5));
10665
10959
  const q = query17(collection17(db, CLINICS_COLLECTION), ...constraints);
10666
10960
  const querySnapshot = await getDocs17(q);
10667
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10961
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10668
10962
  clinics = applyInMemoryFilters(clinics, filters);
10669
10963
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10670
10964
  console.log(`[CLINIC_SERVICE] Strategy 3 success: ${clinics.length} clinics`);
@@ -10684,7 +10978,7 @@ async function getClinicsByFilters(db, filters) {
10684
10978
  ];
10685
10979
  const q = query17(collection17(db, CLINICS_COLLECTION), ...constraints);
10686
10980
  const querySnapshot = await getDocs17(q);
10687
- let clinics = querySnapshot.docs.map((doc44) => ({ ...doc44.data(), id: doc44.id }));
10981
+ let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
10688
10982
  clinics = applyInMemoryFilters(clinics, filters);
10689
10983
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
10690
10984
  console.log(`[CLINIC_SERVICE] Strategy 4 success: ${clinics.length} clinics`);
@@ -10989,9 +11283,9 @@ var ClinicService = class extends BaseService {
10989
11283
  updatedAt: serverTimestamp20()
10990
11284
  };
10991
11285
  const batch = writeBatch4(this.db);
10992
- const clinicRef = doc21(this.db, CLINICS_COLLECTION, clinicId);
11286
+ const clinicRef = doc22(this.db, CLINICS_COLLECTION, clinicId);
10993
11287
  batch.set(clinicRef, clinicData);
10994
- const adminRef = doc21(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
11288
+ const adminRef = doc22(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
10995
11289
  batch.update(adminRef, {
10996
11290
  clinicsManaged: arrayUnion7(clinicId),
10997
11291
  updatedAt: serverTimestamp20()
@@ -11015,8 +11309,8 @@ var ClinicService = class extends BaseService {
11015
11309
  */
11016
11310
  async updateClinic(clinicId, data, adminId) {
11017
11311
  try {
11018
- const clinicRef = doc21(this.db, CLINICS_COLLECTION, clinicId);
11019
- const clinicDoc = await getDoc23(clinicRef);
11312
+ const clinicRef = doc22(this.db, CLINICS_COLLECTION, clinicId);
11313
+ const clinicDoc = await getDoc24(clinicRef);
11020
11314
  if (!clinicDoc.exists()) {
11021
11315
  throw new Error(`Clinic ${clinicId} not found`);
11022
11316
  }
@@ -11098,7 +11392,7 @@ var ClinicService = class extends BaseService {
11098
11392
  * Deactivates a clinic.
11099
11393
  */
11100
11394
  async deactivateClinic(clinicId, adminId) {
11101
- const clinicRef = doc21(this.db, CLINICS_COLLECTION, clinicId);
11395
+ const clinicRef = doc22(this.db, CLINICS_COLLECTION, clinicId);
11102
11396
  await updateDoc20(clinicRef, {
11103
11397
  isActive: false,
11104
11398
  updatedAt: serverTimestamp20()
@@ -11108,7 +11402,7 @@ var ClinicService = class extends BaseService {
11108
11402
  * Activates a clinic.
11109
11403
  */
11110
11404
  async activateClinic(clinicId, adminId) {
11111
- const clinicRef = doc21(this.db, CLINICS_COLLECTION, clinicId);
11405
+ const clinicRef = doc22(this.db, CLINICS_COLLECTION, clinicId);
11112
11406
  await updateDoc20(clinicRef, {
11113
11407
  isActive: true,
11114
11408
  updatedAt: serverTimestamp20()
@@ -11256,11 +11550,11 @@ var ClinicService = class extends BaseService {
11256
11550
  async getClinicsForMap() {
11257
11551
  const clinicsRef = collection18(this.db, CLINICS_COLLECTION);
11258
11552
  const snapshot = await getDocs18(clinicsRef);
11259
- const clinicsForMap = snapshot.docs.map((doc44) => {
11553
+ const clinicsForMap = snapshot.docs.map((doc45) => {
11260
11554
  var _a, _b, _c;
11261
- const data = doc44.data();
11555
+ const data = doc45.data();
11262
11556
  return {
11263
- id: doc44.id,
11557
+ id: doc45.id,
11264
11558
  name: data.name,
11265
11559
  address: ((_a = data.location) == null ? void 0 : _a.address) || "",
11266
11560
  latitude: (_b = data.location) == null ? void 0 : _b.latitude,
@@ -12088,8 +12382,8 @@ var AuthService = class extends BaseService {
12088
12382
  // src/services/calendar/calendar.v2.service.ts
12089
12383
  import { Timestamp as Timestamp26, serverTimestamp as serverTimestamp26 } from "firebase/firestore";
12090
12384
  import {
12091
- doc as doc29,
12092
- getDoc as getDoc30,
12385
+ doc as doc30,
12386
+ getDoc as getDoc31,
12093
12387
  collection as collection25,
12094
12388
  query as query25,
12095
12389
  where as where25,
@@ -12101,8 +12395,8 @@ import {
12101
12395
  // src/services/calendar/utils/clinic.utils.ts
12102
12396
  import {
12103
12397
  collection as collection20,
12104
- doc as doc24,
12105
- getDoc as getDoc25,
12398
+ doc as doc25,
12399
+ getDoc as getDoc26,
12106
12400
  getDocs as getDocs20,
12107
12401
  setDoc as setDoc17,
12108
12402
  updateDoc as updateDoc22,
@@ -12115,39 +12409,39 @@ import {
12115
12409
  } from "firebase/firestore";
12116
12410
 
12117
12411
  // src/services/calendar/utils/docs.utils.ts
12118
- import { doc as doc23 } from "firebase/firestore";
12412
+ import { doc as doc24 } from "firebase/firestore";
12119
12413
  function getPractitionerCalendarEventDocRef(db, practitionerId, eventId) {
12120
- return doc23(
12414
+ return doc24(
12121
12415
  db,
12122
12416
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${CALENDAR_COLLECTION}/${eventId}`
12123
12417
  );
12124
12418
  }
12125
12419
  function getPatientCalendarEventDocRef(db, patientId, eventId) {
12126
- return doc23(
12420
+ return doc24(
12127
12421
  db,
12128
12422
  `${PATIENTS_COLLECTION}/${patientId}/${CALENDAR_COLLECTION}/${eventId}`
12129
12423
  );
12130
12424
  }
12131
12425
  function getClinicCalendarEventDocRef(db, clinicId, eventId) {
12132
- return doc23(
12426
+ return doc24(
12133
12427
  db,
12134
12428
  `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}/${eventId}`
12135
12429
  );
12136
12430
  }
12137
12431
  function getPractitionerSyncedCalendarDocRef(db, practitionerId, syncedCalendarId) {
12138
- return doc23(
12432
+ return doc24(
12139
12433
  db,
12140
12434
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/syncedCalendars/${syncedCalendarId}`
12141
12435
  );
12142
12436
  }
12143
12437
  function getPatientSyncedCalendarDocRef(db, patientId, syncedCalendarId) {
12144
- return doc23(
12438
+ return doc24(
12145
12439
  db,
12146
12440
  `${PATIENTS_COLLECTION}/${patientId}/syncedCalendars/${syncedCalendarId}`
12147
12441
  );
12148
12442
  }
12149
12443
  function getClinicSyncedCalendarDocRef(db, clinicId, syncedCalendarId) {
12150
- return doc23(
12444
+ return doc24(
12151
12445
  db,
12152
12446
  `${CLINICS_COLLECTION}/${clinicId}/syncedCalendars/${syncedCalendarId}`
12153
12447
  );
@@ -12177,14 +12471,14 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
12177
12471
  updatedAt: serverTimestamp21()
12178
12472
  };
12179
12473
  await updateDoc22(eventRef, updates);
12180
- const updatedDoc = await getDoc25(eventRef);
12474
+ const updatedDoc = await getDoc26(eventRef);
12181
12475
  if (!updatedDoc.exists()) {
12182
12476
  throw new Error("Event not found after update");
12183
12477
  }
12184
12478
  return updatedDoc.data();
12185
12479
  }
12186
12480
  async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
12187
- const clinicDoc = await getDoc25(doc24(db, `clinics/${clinicId}`));
12481
+ const clinicDoc = await getDoc26(doc25(db, `clinics/${clinicId}`));
12188
12482
  if (!clinicDoc.exists()) {
12189
12483
  throw new Error(`Clinic with ID ${clinicId} not found`);
12190
12484
  }
@@ -12193,8 +12487,8 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
12193
12487
  if (!clinicGroupId) {
12194
12488
  return false;
12195
12489
  }
12196
- const clinicGroupDoc = await getDoc25(
12197
- doc24(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
12490
+ const clinicGroupDoc = await getDoc26(
12491
+ doc25(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
12198
12492
  );
12199
12493
  if (!clinicGroupDoc.exists()) {
12200
12494
  return false;
@@ -12206,7 +12500,7 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
12206
12500
  // src/services/calendar/utils/patient.utils.ts
12207
12501
  import {
12208
12502
  collection as collection21,
12209
- getDoc as getDoc26,
12503
+ getDoc as getDoc27,
12210
12504
  getDocs as getDocs21,
12211
12505
  setDoc as setDoc18,
12212
12506
  updateDoc as updateDoc23,
@@ -12240,7 +12534,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
12240
12534
  updatedAt: serverTimestamp22()
12241
12535
  };
12242
12536
  await updateDoc23(eventRef, updates);
12243
- const updatedDoc = await getDoc26(eventRef);
12537
+ const updatedDoc = await getDoc27(eventRef);
12244
12538
  if (!updatedDoc.exists()) {
12245
12539
  throw new Error("Event not found after update");
12246
12540
  }
@@ -12250,7 +12544,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
12250
12544
  // src/services/calendar/utils/practitioner.utils.ts
12251
12545
  import {
12252
12546
  collection as collection22,
12253
- getDoc as getDoc27,
12547
+ getDoc as getDoc28,
12254
12548
  getDocs as getDocs22,
12255
12549
  setDoc as setDoc19,
12256
12550
  updateDoc as updateDoc24,
@@ -12292,7 +12586,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
12292
12586
  updatedAt: serverTimestamp23()
12293
12587
  };
12294
12588
  await updateDoc24(eventRef, updates);
12295
- const updatedDoc = await getDoc27(eventRef);
12589
+ const updatedDoc = await getDoc28(eventRef);
12296
12590
  if (!updatedDoc.exists()) {
12297
12591
  throw new Error("Event not found after update");
12298
12592
  }
@@ -12352,8 +12646,8 @@ async function updateAppointmentUtil2(db, clinicId, practitionerId, patientId, e
12352
12646
  // src/services/calendar/utils/calendar-event.utils.ts
12353
12647
  import {
12354
12648
  collection as collection23,
12355
- doc as doc27,
12356
- getDoc as getDoc28,
12649
+ doc as doc28,
12650
+ getDoc as getDoc29,
12357
12651
  getDocs as getDocs23,
12358
12652
  setDoc as setDoc20,
12359
12653
  updateDoc as updateDoc25,
@@ -12447,7 +12741,7 @@ async function searchCalendarEventsUtil(db, params) {
12447
12741
  const finalQuery = query23(collectionRef, ...constraints);
12448
12742
  const querySnapshot = await getDocs23(finalQuery);
12449
12743
  const events = querySnapshot.docs.map(
12450
- (doc44) => ({ id: doc44.id, ...doc44.data() })
12744
+ (doc45) => ({ id: doc45.id, ...doc45.data() })
12451
12745
  );
12452
12746
  return events;
12453
12747
  } catch (error) {
@@ -12459,7 +12753,7 @@ async function searchCalendarEventsUtil(db, params) {
12459
12753
  // src/services/calendar/utils/synced-calendar.utils.ts
12460
12754
  import {
12461
12755
  collection as collection24,
12462
- getDoc as getDoc29,
12756
+ getDoc as getDoc30,
12463
12757
  getDocs as getDocs24,
12464
12758
  setDoc as setDoc21,
12465
12759
  updateDoc as updateDoc26,
@@ -12527,7 +12821,7 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
12527
12821
  practitionerId,
12528
12822
  calendarId
12529
12823
  );
12530
- const calendarDoc = await getDoc29(calendarRef);
12824
+ const calendarDoc = await getDoc30(calendarRef);
12531
12825
  if (!calendarDoc.exists()) {
12532
12826
  return null;
12533
12827
  }
@@ -12540,11 +12834,11 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
12540
12834
  );
12541
12835
  const q = query24(calendarsRef, orderBy12("createdAt", "desc"));
12542
12836
  const querySnapshot = await getDocs24(q);
12543
- return querySnapshot.docs.map((doc44) => doc44.data());
12837
+ return querySnapshot.docs.map((doc45) => doc45.data());
12544
12838
  }
12545
12839
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
12546
12840
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
12547
- const calendarDoc = await getDoc29(calendarRef);
12841
+ const calendarDoc = await getDoc30(calendarRef);
12548
12842
  if (!calendarDoc.exists()) {
12549
12843
  return null;
12550
12844
  }
@@ -12557,11 +12851,11 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
12557
12851
  );
12558
12852
  const q = query24(calendarsRef, orderBy12("createdAt", "desc"));
12559
12853
  const querySnapshot = await getDocs24(q);
12560
- return querySnapshot.docs.map((doc44) => doc44.data());
12854
+ return querySnapshot.docs.map((doc45) => doc45.data());
12561
12855
  }
12562
12856
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
12563
12857
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
12564
- const calendarDoc = await getDoc29(calendarRef);
12858
+ const calendarDoc = await getDoc30(calendarRef);
12565
12859
  if (!calendarDoc.exists()) {
12566
12860
  return null;
12567
12861
  }
@@ -12574,7 +12868,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
12574
12868
  );
12575
12869
  const q = query24(calendarsRef, orderBy12("createdAt", "desc"));
12576
12870
  const querySnapshot = await getDocs24(q);
12577
- return querySnapshot.docs.map((doc44) => doc44.data());
12871
+ return querySnapshot.docs.map((doc45) => doc45.data());
12578
12872
  }
12579
12873
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
12580
12874
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -12587,7 +12881,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
12587
12881
  updatedAt: serverTimestamp25()
12588
12882
  };
12589
12883
  await updateDoc26(calendarRef, updates);
12590
- const updatedDoc = await getDoc29(calendarRef);
12884
+ const updatedDoc = await getDoc30(calendarRef);
12591
12885
  if (!updatedDoc.exists()) {
12592
12886
  throw new Error("Synced calendar not found after update");
12593
12887
  }
@@ -12600,7 +12894,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
12600
12894
  updatedAt: serverTimestamp25()
12601
12895
  };
12602
12896
  await updateDoc26(calendarRef, updates);
12603
- const updatedDoc = await getDoc29(calendarRef);
12897
+ const updatedDoc = await getDoc30(calendarRef);
12604
12898
  if (!updatedDoc.exists()) {
12605
12899
  throw new Error("Synced calendar not found after update");
12606
12900
  }
@@ -12613,7 +12907,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
12613
12907
  updatedAt: serverTimestamp25()
12614
12908
  };
12615
12909
  await updateDoc26(calendarRef, updates);
12616
- const updatedDoc = await getDoc29(calendarRef);
12910
+ const updatedDoc = await getDoc30(calendarRef);
12617
12911
  if (!updatedDoc.exists()) {
12618
12912
  throw new Error("Synced calendar not found after update");
12619
12913
  }
@@ -13822,7 +14116,7 @@ var CalendarServiceV2 = class extends BaseService {
13822
14116
  async createDoctorBlockingEvent(doctorId, eventData) {
13823
14117
  try {
13824
14118
  const eventId = this.generateId();
13825
- const eventRef = doc29(
14119
+ const eventRef = doc30(
13826
14120
  this.db,
13827
14121
  PRACTITIONERS_COLLECTION,
13828
14122
  doctorId,
@@ -13929,9 +14223,9 @@ var CalendarServiceV2 = class extends BaseService {
13929
14223
  where25("eventTime.start", "<=", Timestamp26.fromDate(endDate))
13930
14224
  );
13931
14225
  const eventsSnapshot = await getDocs25(q);
13932
- const events = eventsSnapshot.docs.map((doc44) => ({
13933
- id: doc44.id,
13934
- ...doc44.data()
14226
+ const events = eventsSnapshot.docs.map((doc45) => ({
14227
+ id: doc45.id,
14228
+ ...doc45.data()
13935
14229
  }));
13936
14230
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
13937
14231
  doctorId
@@ -14035,7 +14329,7 @@ var CalendarServiceV2 = class extends BaseService {
14035
14329
  const endTime = new Date(
14036
14330
  externalEvent.end.dateTime || externalEvent.end.date
14037
14331
  );
14038
- const eventRef = doc29(
14332
+ const eventRef = doc30(
14039
14333
  this.db,
14040
14334
  PRACTITIONERS_COLLECTION,
14041
14335
  doctorId,
@@ -14067,7 +14361,7 @@ var CalendarServiceV2 = class extends BaseService {
14067
14361
  */
14068
14362
  async updateEventStatus(doctorId, eventId, status) {
14069
14363
  try {
14070
- const eventRef = doc29(
14364
+ const eventRef = doc30(
14071
14365
  this.db,
14072
14366
  PRACTITIONERS_COLLECTION,
14073
14367
  doctorId,
@@ -14233,8 +14527,8 @@ var CalendarServiceV2 = class extends BaseService {
14233
14527
  const startDate = eventTime.start.toDate();
14234
14528
  const startTime = startDate;
14235
14529
  const endTime = eventTime.end.toDate();
14236
- const practitionerRef = doc29(this.db, PRACTITIONERS_COLLECTION, doctorId);
14237
- const practitionerDoc = await getDoc30(practitionerRef);
14530
+ const practitionerRef = doc30(this.db, PRACTITIONERS_COLLECTION, doctorId);
14531
+ const practitionerDoc = await getDoc31(practitionerRef);
14238
14532
  if (!practitionerDoc.exists()) {
14239
14533
  throw new Error(`Doctor with ID ${doctorId} not found`);
14240
14534
  }
@@ -14292,8 +14586,8 @@ var CalendarServiceV2 = class extends BaseService {
14292
14586
  */
14293
14587
  async updateAppointmentStatus(appointmentId, clinicId, status) {
14294
14588
  const baseCollectionPath = `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}`;
14295
- const appointmentRef = doc29(this.db, baseCollectionPath, appointmentId);
14296
- const appointmentDoc = await getDoc30(appointmentRef);
14589
+ const appointmentRef = doc30(this.db, baseCollectionPath, appointmentId);
14590
+ const appointmentDoc = await getDoc31(appointmentRef);
14297
14591
  if (!appointmentDoc.exists()) {
14298
14592
  throw new Error(`Appointment with ID ${appointmentId} not found`);
14299
14593
  }
@@ -14452,8 +14746,8 @@ var CalendarServiceV2 = class extends BaseService {
14452
14746
  async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
14453
14747
  try {
14454
14748
  const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
14455
- const eventRef = doc29(this.db, collectionPath, eventId);
14456
- const eventDoc = await getDoc30(eventRef);
14749
+ const eventRef = doc30(this.db, collectionPath, eventId);
14750
+ const eventDoc = await getDoc31(eventRef);
14457
14751
  if (eventDoc.exists()) {
14458
14752
  const event = eventDoc.data();
14459
14753
  const syncIds = [...event.syncedCalendarEventId || []];
@@ -14491,8 +14785,8 @@ var CalendarServiceV2 = class extends BaseService {
14491
14785
  * @returns Working hours for the clinic
14492
14786
  */
14493
14787
  async getClinicWorkingHours(clinicId, date) {
14494
- const clinicRef = doc29(this.db, CLINICS_COLLECTION, clinicId);
14495
- const clinicDoc = await getDoc30(clinicRef);
14788
+ const clinicRef = doc30(this.db, CLINICS_COLLECTION, clinicId);
14789
+ const clinicDoc = await getDoc31(clinicRef);
14496
14790
  if (!clinicDoc.exists()) {
14497
14791
  throw new Error(`Clinic with ID ${clinicId} not found`);
14498
14792
  }
@@ -14520,8 +14814,8 @@ var CalendarServiceV2 = class extends BaseService {
14520
14814
  * @returns Doctor's schedule
14521
14815
  */
14522
14816
  async getDoctorSchedule(doctorId, date) {
14523
- const practitionerRef = doc29(this.db, PRACTITIONERS_COLLECTION, doctorId);
14524
- const practitionerDoc = await getDoc30(practitionerRef);
14817
+ const practitionerRef = doc30(this.db, PRACTITIONERS_COLLECTION, doctorId);
14818
+ const practitionerDoc = await getDoc31(practitionerRef);
14525
14819
  if (!practitionerDoc.exists()) {
14526
14820
  throw new Error(`Doctor with ID ${doctorId} not found`);
14527
14821
  }
@@ -14565,7 +14859,7 @@ var CalendarServiceV2 = class extends BaseService {
14565
14859
  ])
14566
14860
  );
14567
14861
  const querySnapshot = await getDocs25(q);
14568
- return querySnapshot.docs.map((doc44) => doc44.data());
14862
+ return querySnapshot.docs.map((doc45) => doc45.data());
14569
14863
  }
14570
14864
  /**
14571
14865
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -14622,11 +14916,11 @@ var CalendarServiceV2 = class extends BaseService {
14622
14916
  var _a;
14623
14917
  try {
14624
14918
  const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
14625
- getDoc30(doc29(this.db, CLINICS_COLLECTION, clinicId)),
14626
- getDoc30(doc29(this.db, PRACTITIONERS_COLLECTION, doctorId)),
14627
- getDoc30(doc29(this.db, PATIENTS_COLLECTION, patientId)),
14628
- getDoc30(
14629
- doc29(
14919
+ getDoc31(doc30(this.db, CLINICS_COLLECTION, clinicId)),
14920
+ getDoc31(doc30(this.db, PRACTITIONERS_COLLECTION, doctorId)),
14921
+ getDoc31(doc30(this.db, PATIENTS_COLLECTION, patientId)),
14922
+ getDoc31(
14923
+ doc30(
14630
14924
  this.db,
14631
14925
  PATIENTS_COLLECTION,
14632
14926
  patientId,
@@ -14691,7 +14985,7 @@ var CalendarServiceV2 = class extends BaseService {
14691
14985
 
14692
14986
  // src/services/calendar/calendar.v3.service.ts
14693
14987
  import { Timestamp as Timestamp27, serverTimestamp as serverTimestamp27 } from "firebase/firestore";
14694
- import { doc as doc30, getDoc as getDoc31, setDoc as setDoc23, updateDoc as updateDoc28, deleteDoc as deleteDoc15 } from "firebase/firestore";
14988
+ import { doc as doc31, getDoc as getDoc32, setDoc as setDoc23, updateDoc as updateDoc28, deleteDoc as deleteDoc15 } from "firebase/firestore";
14695
14989
  var CalendarServiceV3 = class extends BaseService {
14696
14990
  /**
14697
14991
  * Creates a new CalendarServiceV3 instance
@@ -14715,7 +15009,7 @@ var CalendarServiceV3 = class extends BaseService {
14715
15009
  params.entityType,
14716
15010
  params.entityId
14717
15011
  );
14718
- const eventRef = doc30(this.db, collectionPath, eventId);
15012
+ const eventRef = doc31(this.db, collectionPath, eventId);
14719
15013
  const eventData = {
14720
15014
  id: eventId,
14721
15015
  eventName: params.eventName,
@@ -14750,8 +15044,8 @@ var CalendarServiceV3 = class extends BaseService {
14750
15044
  params.entityType,
14751
15045
  params.entityId
14752
15046
  );
14753
- const eventRef = doc30(this.db, collectionPath, params.eventId);
14754
- const eventDoc = await getDoc31(eventRef);
15047
+ const eventRef = doc31(this.db, collectionPath, params.eventId);
15048
+ const eventDoc = await getDoc32(eventRef);
14755
15049
  if (!eventDoc.exists()) {
14756
15050
  throw new Error(`Blocking event with ID ${params.eventId} not found`);
14757
15051
  }
@@ -14771,7 +15065,7 @@ var CalendarServiceV3 = class extends BaseService {
14771
15065
  updateData.status = params.status;
14772
15066
  }
14773
15067
  await updateDoc28(eventRef, updateData);
14774
- const updatedEventDoc = await getDoc31(eventRef);
15068
+ const updatedEventDoc = await getDoc32(eventRef);
14775
15069
  return updatedEventDoc.data();
14776
15070
  }
14777
15071
  /**
@@ -14782,8 +15076,8 @@ var CalendarServiceV3 = class extends BaseService {
14782
15076
  */
14783
15077
  async deleteBlockingEvent(entityType, entityId, eventId) {
14784
15078
  const collectionPath = this.getEntityCalendarPath(entityType, entityId);
14785
- const eventRef = doc30(this.db, collectionPath, eventId);
14786
- const eventDoc = await getDoc31(eventRef);
15079
+ const eventRef = doc31(this.db, collectionPath, eventId);
15080
+ const eventDoc = await getDoc32(eventRef);
14787
15081
  if (!eventDoc.exists()) {
14788
15082
  throw new Error(`Blocking event with ID ${eventId} not found`);
14789
15083
  }
@@ -14798,8 +15092,8 @@ var CalendarServiceV3 = class extends BaseService {
14798
15092
  */
14799
15093
  async getBlockingEvent(entityType, entityId, eventId) {
14800
15094
  const collectionPath = this.getEntityCalendarPath(entityType, entityId);
14801
- const eventRef = doc30(this.db, collectionPath, eventId);
14802
- const eventDoc = await getDoc31(eventRef);
15095
+ const eventRef = doc31(this.db, collectionPath, eventId);
15096
+ const eventDoc = await getDoc32(eventRef);
14803
15097
  if (!eventDoc.exists()) {
14804
15098
  return null;
14805
15099
  }
@@ -14994,8 +15288,8 @@ var ExternalCalendarService = class extends BaseService {
14994
15288
  // src/services/clinic/practitioner-invite.service.ts
14995
15289
  import {
14996
15290
  collection as collection26,
14997
- doc as doc31,
14998
- getDoc as getDoc32,
15291
+ doc as doc32,
15292
+ getDoc as getDoc33,
14999
15293
  getDocs as getDocs26,
15000
15294
  query as query26,
15001
15295
  where as where26,
@@ -15079,7 +15373,7 @@ var PractitionerInviteService = class extends BaseService {
15079
15373
  rejectedAt: null,
15080
15374
  cancelledAt: null
15081
15375
  };
15082
- const docRef = doc31(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15376
+ const docRef = doc32(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15083
15377
  await setDoc24(docRef, invite);
15084
15378
  return invite;
15085
15379
  } catch (error) {
@@ -15110,7 +15404,7 @@ var PractitionerInviteService = class extends BaseService {
15110
15404
  ...constraints
15111
15405
  );
15112
15406
  const querySnapshot = await getDocs26(q);
15113
- return querySnapshot.docs.map((doc44) => doc44.data());
15407
+ return querySnapshot.docs.map((doc45) => doc45.data());
15114
15408
  } catch (error) {
15115
15409
  console.error(
15116
15410
  "[PractitionerInviteService] Error getting doctor invites:",
@@ -15139,7 +15433,7 @@ var PractitionerInviteService = class extends BaseService {
15139
15433
  ...constraints
15140
15434
  );
15141
15435
  const querySnapshot = await getDocs26(q);
15142
- return querySnapshot.docs.map((doc44) => doc44.data());
15436
+ return querySnapshot.docs.map((doc45) => doc45.data());
15143
15437
  } catch (error) {
15144
15438
  console.error(
15145
15439
  "[PractitionerInviteService] Error getting clinic invites:",
@@ -15167,7 +15461,7 @@ var PractitionerInviteService = class extends BaseService {
15167
15461
  acceptedAt: Timestamp28.now(),
15168
15462
  updatedAt: serverTimestamp28()
15169
15463
  };
15170
- const docRef = doc31(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15464
+ const docRef = doc32(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15171
15465
  await updateDoc29(docRef, updateData);
15172
15466
  return await this.getInviteById(inviteId);
15173
15467
  } catch (error) {
@@ -15199,7 +15493,7 @@ var PractitionerInviteService = class extends BaseService {
15199
15493
  rejectedAt: Timestamp28.now(),
15200
15494
  updatedAt: serverTimestamp28()
15201
15495
  };
15202
- const docRef = doc31(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15496
+ const docRef = doc32(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15203
15497
  await updateDoc29(docRef, updateData);
15204
15498
  return await this.getInviteById(inviteId);
15205
15499
  } catch (error) {
@@ -15231,7 +15525,7 @@ var PractitionerInviteService = class extends BaseService {
15231
15525
  cancelledAt: Timestamp28.now(),
15232
15526
  updatedAt: serverTimestamp28()
15233
15527
  };
15234
- const docRef = doc31(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15528
+ const docRef = doc32(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15235
15529
  await updateDoc29(docRef, updateData);
15236
15530
  return await this.getInviteById(inviteId);
15237
15531
  } catch (error) {
@@ -15249,8 +15543,8 @@ var PractitionerInviteService = class extends BaseService {
15249
15543
  */
15250
15544
  async getInviteById(inviteId) {
15251
15545
  try {
15252
- const docRef = doc31(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15253
- const docSnap = await getDoc32(docRef);
15546
+ const docRef = doc32(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15547
+ const docSnap = await getDoc33(docRef);
15254
15548
  if (docSnap.exists()) {
15255
15549
  return docSnap.data();
15256
15550
  }
@@ -15295,7 +15589,7 @@ var PractitionerInviteService = class extends BaseService {
15295
15589
  );
15296
15590
  const querySnapshot = await getDocs26(q);
15297
15591
  let invites = querySnapshot.docs.map(
15298
- (doc44) => doc44.data()
15592
+ (doc45) => doc45.data()
15299
15593
  );
15300
15594
  if (filters.fromDate) {
15301
15595
  invites = invites.filter(
@@ -15322,7 +15616,7 @@ var PractitionerInviteService = class extends BaseService {
15322
15616
  */
15323
15617
  async deleteInvite(inviteId) {
15324
15618
  try {
15325
- const docRef = doc31(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15619
+ const docRef = doc32(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
15326
15620
  await deleteDoc16(docRef);
15327
15621
  } catch (error) {
15328
15622
  console.error(
@@ -15340,8 +15634,8 @@ var PractitionerInviteService = class extends BaseService {
15340
15634
  */
15341
15635
  async getPractitionerById(practitionerId) {
15342
15636
  try {
15343
- const docRef = doc31(this.db, PRACTITIONERS_COLLECTION, practitionerId);
15344
- const docSnap = await getDoc32(docRef);
15637
+ const docRef = doc32(this.db, PRACTITIONERS_COLLECTION, practitionerId);
15638
+ const docSnap = await getDoc33(docRef);
15345
15639
  return docSnap.exists() ? docSnap.data() : null;
15346
15640
  } catch (error) {
15347
15641
  console.error(
@@ -15358,8 +15652,8 @@ var PractitionerInviteService = class extends BaseService {
15358
15652
  */
15359
15653
  async getClinicById(clinicId) {
15360
15654
  try {
15361
- const docRef = doc31(this.db, CLINICS_COLLECTION, clinicId);
15362
- const docSnap = await getDoc32(docRef);
15655
+ const docRef = doc32(this.db, CLINICS_COLLECTION, clinicId);
15656
+ const docSnap = await getDoc33(docRef);
15363
15657
  return docSnap.exists() ? docSnap.data() : null;
15364
15658
  } catch (error) {
15365
15659
  console.error("[PractitionerInviteService] Error getting clinic:", error);
@@ -15399,8 +15693,8 @@ var PractitionerInviteService = class extends BaseService {
15399
15693
  // src/services/documentation-templates/documentation-template.service.ts
15400
15694
  import {
15401
15695
  collection as collection27,
15402
- doc as doc32,
15403
- getDoc as getDoc33,
15696
+ doc as doc33,
15697
+ getDoc as getDoc34,
15404
15698
  getDocs as getDocs27,
15405
15699
  setDoc as setDoc25,
15406
15700
  updateDoc as updateDoc30,
@@ -15449,7 +15743,7 @@ var DocumentationTemplateService = class extends BaseService {
15449
15743
  isRequired: validatedData.isRequired || false,
15450
15744
  sortingOrder: validatedData.sortingOrder || 0
15451
15745
  };
15452
- const docRef = doc32(this.collectionRef, templateId);
15746
+ const docRef = doc33(this.collectionRef, templateId);
15453
15747
  await setDoc25(docRef, template);
15454
15748
  return template;
15455
15749
  }
@@ -15460,8 +15754,8 @@ var DocumentationTemplateService = class extends BaseService {
15460
15754
  * @returns The template or null if not found
15461
15755
  */
15462
15756
  async getTemplateById(templateId, version) {
15463
- const docRef = doc32(this.collectionRef, templateId);
15464
- const docSnap = await getDoc33(docRef);
15757
+ const docRef = doc33(this.collectionRef, templateId);
15758
+ const docSnap = await getDoc34(docRef);
15465
15759
  if (!docSnap.exists()) {
15466
15760
  return null;
15467
15761
  }
@@ -15503,7 +15797,7 @@ var DocumentationTemplateService = class extends BaseService {
15503
15797
  this.db,
15504
15798
  `${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions`
15505
15799
  );
15506
- const versionDocRef = doc32(
15800
+ const versionDocRef = doc33(
15507
15801
  versionsCollectionRef,
15508
15802
  template.version.toString()
15509
15803
  );
@@ -15531,7 +15825,7 @@ var DocumentationTemplateService = class extends BaseService {
15531
15825
  updatePayload.isUserForm = (_a = validatedData.isUserForm) != null ? _a : false;
15532
15826
  updatePayload.isRequired = (_b = validatedData.isRequired) != null ? _b : false;
15533
15827
  updatePayload.sortingOrder = (_c = validatedData.sortingOrder) != null ? _c : 0;
15534
- const docRef = doc32(this.collectionRef, templateId);
15828
+ const docRef = doc33(this.collectionRef, templateId);
15535
15829
  console.log("Update payload", updatePayload);
15536
15830
  await updateDoc30(docRef, updatePayload);
15537
15831
  return { ...template, ...updatePayload };
@@ -15543,11 +15837,11 @@ var DocumentationTemplateService = class extends BaseService {
15543
15837
  * @returns The template version or null if not found
15544
15838
  */
15545
15839
  async getTemplateVersion(templateId, versionNumber) {
15546
- const versionDocRef = doc32(
15840
+ const versionDocRef = doc33(
15547
15841
  this.db,
15548
15842
  `${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions/${versionNumber}`
15549
15843
  );
15550
- const versionDocSnap = await getDoc33(versionDocRef);
15844
+ const versionDocSnap = await getDoc34(versionDocRef);
15551
15845
  if (!versionDocSnap.exists()) {
15552
15846
  return null;
15553
15847
  }
@@ -15566,8 +15860,8 @@ var DocumentationTemplateService = class extends BaseService {
15566
15860
  const q = query27(versionsCollectionRef, orderBy14("version", "desc"));
15567
15861
  const querySnapshot = await getDocs27(q);
15568
15862
  const versions = [];
15569
- querySnapshot.forEach((doc44) => {
15570
- versions.push(doc44.data());
15863
+ querySnapshot.forEach((doc45) => {
15864
+ versions.push(doc45.data());
15571
15865
  });
15572
15866
  return versions;
15573
15867
  }
@@ -15576,7 +15870,7 @@ var DocumentationTemplateService = class extends BaseService {
15576
15870
  * @param templateId - ID of the template to delete
15577
15871
  */
15578
15872
  async deleteTemplate(templateId) {
15579
- const docRef = doc32(this.collectionRef, templateId);
15873
+ const docRef = doc33(this.collectionRef, templateId);
15580
15874
  await deleteDoc17(docRef);
15581
15875
  }
15582
15876
  /**
@@ -15598,9 +15892,9 @@ var DocumentationTemplateService = class extends BaseService {
15598
15892
  const querySnapshot = await getDocs27(q);
15599
15893
  const templates = [];
15600
15894
  let lastVisible = null;
15601
- querySnapshot.forEach((doc44) => {
15602
- templates.push(doc44.data());
15603
- lastVisible = doc44;
15895
+ querySnapshot.forEach((doc45) => {
15896
+ templates.push(doc45.data());
15897
+ lastVisible = doc45;
15604
15898
  });
15605
15899
  return {
15606
15900
  templates,
@@ -15642,9 +15936,9 @@ var DocumentationTemplateService = class extends BaseService {
15642
15936
  const querySnapshot = await getDocs27(q);
15643
15937
  const templates = [];
15644
15938
  let lastVisible = null;
15645
- querySnapshot.forEach((doc44) => {
15646
- templates.push(doc44.data());
15647
- lastVisible = doc44;
15939
+ querySnapshot.forEach((doc45) => {
15940
+ templates.push(doc45.data());
15941
+ lastVisible = doc45;
15648
15942
  });
15649
15943
  return {
15650
15944
  templates,
@@ -15684,8 +15978,8 @@ var DocumentationTemplateService = class extends BaseService {
15684
15978
  );
15685
15979
  const querySnapshot = await getDocs27(q);
15686
15980
  const templates = [];
15687
- querySnapshot.forEach((doc44) => {
15688
- templates.push(doc44.data());
15981
+ querySnapshot.forEach((doc45) => {
15982
+ templates.push(doc45.data());
15689
15983
  });
15690
15984
  return templates;
15691
15985
  }
@@ -15710,9 +16004,9 @@ var DocumentationTemplateService = class extends BaseService {
15710
16004
  const querySnapshot = await getDocs27(q);
15711
16005
  const templates = [];
15712
16006
  let lastVisible = null;
15713
- querySnapshot.forEach((doc44) => {
15714
- templates.push(doc44.data());
15715
- lastVisible = doc44;
16007
+ querySnapshot.forEach((doc45) => {
16008
+ templates.push(doc45.data());
16009
+ lastVisible = doc45;
15716
16010
  });
15717
16011
  return {
15718
16012
  templates,
@@ -15739,9 +16033,9 @@ var DocumentationTemplateService = class extends BaseService {
15739
16033
  const querySnapshot = await getDocs27(q);
15740
16034
  const templates = [];
15741
16035
  let lastVisible = null;
15742
- querySnapshot.forEach((doc44) => {
15743
- templates.push(doc44.data());
15744
- lastVisible = doc44;
16036
+ querySnapshot.forEach((doc45) => {
16037
+ templates.push(doc45.data());
16038
+ lastVisible = doc45;
15745
16039
  });
15746
16040
  return {
15747
16041
  templates,
@@ -15767,8 +16061,8 @@ var DocumentationTemplateService = class extends BaseService {
15767
16061
  }
15768
16062
  const querySnapshot = await getDocs27(q);
15769
16063
  const templates = [];
15770
- querySnapshot.forEach((doc44) => {
15771
- templates.push(doc44.data());
16064
+ querySnapshot.forEach((doc45) => {
16065
+ templates.push(doc45.data());
15772
16066
  });
15773
16067
  return templates;
15774
16068
  }
@@ -15777,8 +16071,8 @@ var DocumentationTemplateService = class extends BaseService {
15777
16071
  // src/services/documentation-templates/filled-document.service.ts
15778
16072
  import {
15779
16073
  collection as collection28,
15780
- doc as doc33,
15781
- getDoc as getDoc34,
16074
+ doc as doc34,
16075
+ getDoc as getDoc35,
15782
16076
  getDocs as getDocs28,
15783
16077
  setDoc as setDoc26,
15784
16078
  updateDoc as updateDoc31,
@@ -15841,7 +16135,7 @@ var FilledDocumentService = class extends BaseService {
15841
16135
  values: initialValues,
15842
16136
  status: initialStatus
15843
16137
  };
15844
- const docRef = doc33(
16138
+ const docRef = doc34(
15845
16139
  this.db,
15846
16140
  APPOINTMENTS_COLLECTION,
15847
16141
  // Replaced "appointments"
@@ -15861,7 +16155,7 @@ var FilledDocumentService = class extends BaseService {
15861
16155
  */
15862
16156
  async getFilledDocumentFromAppointmentById(appointmentId, formId, isUserForm) {
15863
16157
  const formSubcollection = this.getFormSubcollectionPath(isUserForm);
15864
- const docRef = doc33(
16158
+ const docRef = doc34(
15865
16159
  this.db,
15866
16160
  APPOINTMENTS_COLLECTION,
15867
16161
  // Replaced "appointments"
@@ -15869,7 +16163,7 @@ var FilledDocumentService = class extends BaseService {
15869
16163
  formSubcollection,
15870
16164
  formId
15871
16165
  );
15872
- const docSnap = await getDoc34(docRef);
16166
+ const docSnap = await getDoc35(docRef);
15873
16167
  if (!docSnap.exists()) {
15874
16168
  return null;
15875
16169
  }
@@ -15886,7 +16180,7 @@ var FilledDocumentService = class extends BaseService {
15886
16180
  */
15887
16181
  async updateFilledDocumentInAppointment(appointmentId, formId, isUserForm, values, status) {
15888
16182
  const formSubcollection = this.getFormSubcollectionPath(isUserForm);
15889
- const docRef = doc33(
16183
+ const docRef = doc34(
15890
16184
  this.db,
15891
16185
  APPOINTMENTS_COLLECTION,
15892
16186
  // Replaced "appointments"
@@ -15974,9 +16268,9 @@ var FilledDocumentService = class extends BaseService {
15974
16268
  const querySnapshot = await getDocs28(q);
15975
16269
  const documents = [];
15976
16270
  let lastVisible = null;
15977
- querySnapshot.forEach((doc44) => {
15978
- documents.push(doc44.data());
15979
- lastVisible = doc44;
16271
+ querySnapshot.forEach((doc45) => {
16272
+ documents.push(doc45.data());
16273
+ lastVisible = doc45;
15980
16274
  });
15981
16275
  return {
15982
16276
  documents,
@@ -16137,8 +16431,8 @@ var FilledDocumentService = class extends BaseService {
16137
16431
  // src/services/notifications/notification.service.ts
16138
16432
  import {
16139
16433
  collection as collection29,
16140
- doc as doc34,
16141
- getDoc as getDoc35,
16434
+ doc as doc35,
16435
+ getDoc as getDoc36,
16142
16436
  getDocs as getDocs29,
16143
16437
  query as query29,
16144
16438
  where as where29,
@@ -16174,12 +16468,12 @@ var NotificationService = class extends BaseService {
16174
16468
  * Dohvata notifikaciju po ID-u
16175
16469
  */
16176
16470
  async getNotification(notificationId) {
16177
- const notificationRef = doc34(
16471
+ const notificationRef = doc35(
16178
16472
  this.db,
16179
16473
  NOTIFICATIONS_COLLECTION,
16180
16474
  notificationId
16181
16475
  );
16182
- const notificationDoc = await getDoc35(notificationRef);
16476
+ const notificationDoc = await getDoc36(notificationRef);
16183
16477
  if (!notificationDoc.exists()) {
16184
16478
  return null;
16185
16479
  }
@@ -16198,9 +16492,9 @@ var NotificationService = class extends BaseService {
16198
16492
  orderBy16("notificationTime", "desc")
16199
16493
  );
16200
16494
  const querySnapshot = await getDocs29(q);
16201
- return querySnapshot.docs.map((doc44) => ({
16202
- id: doc44.id,
16203
- ...doc44.data()
16495
+ return querySnapshot.docs.map((doc45) => ({
16496
+ id: doc45.id,
16497
+ ...doc45.data()
16204
16498
  }));
16205
16499
  }
16206
16500
  /**
@@ -16214,16 +16508,16 @@ var NotificationService = class extends BaseService {
16214
16508
  orderBy16("notificationTime", "desc")
16215
16509
  );
16216
16510
  const querySnapshot = await getDocs29(q);
16217
- return querySnapshot.docs.map((doc44) => ({
16218
- id: doc44.id,
16219
- ...doc44.data()
16511
+ return querySnapshot.docs.map((doc45) => ({
16512
+ id: doc45.id,
16513
+ ...doc45.data()
16220
16514
  }));
16221
16515
  }
16222
16516
  /**
16223
16517
  * Označava notifikaciju kao pročitanu
16224
16518
  */
16225
16519
  async markAsRead(notificationId) {
16226
- const notificationRef = doc34(
16520
+ const notificationRef = doc35(
16227
16521
  this.db,
16228
16522
  NOTIFICATIONS_COLLECTION,
16229
16523
  notificationId
@@ -16240,7 +16534,7 @@ var NotificationService = class extends BaseService {
16240
16534
  const notifications = await this.getUnreadNotifications(userId);
16241
16535
  const batch = writeBatch5(this.db);
16242
16536
  notifications.forEach((notification) => {
16243
- const notificationRef = doc34(
16537
+ const notificationRef = doc35(
16244
16538
  this.db,
16245
16539
  NOTIFICATIONS_COLLECTION,
16246
16540
  notification.id
@@ -16256,7 +16550,7 @@ var NotificationService = class extends BaseService {
16256
16550
  * Ažurira status notifikacije
16257
16551
  */
16258
16552
  async updateNotificationStatus(notificationId, status) {
16259
- const notificationRef = doc34(
16553
+ const notificationRef = doc35(
16260
16554
  this.db,
16261
16555
  NOTIFICATIONS_COLLECTION,
16262
16556
  notificationId
@@ -16270,7 +16564,7 @@ var NotificationService = class extends BaseService {
16270
16564
  * Briše notifikaciju
16271
16565
  */
16272
16566
  async deleteNotification(notificationId) {
16273
- const notificationRef = doc34(
16567
+ const notificationRef = doc35(
16274
16568
  this.db,
16275
16569
  NOTIFICATIONS_COLLECTION,
16276
16570
  notificationId
@@ -16288,9 +16582,9 @@ var NotificationService = class extends BaseService {
16288
16582
  orderBy16("notificationTime", "desc")
16289
16583
  );
16290
16584
  const querySnapshot = await getDocs29(q);
16291
- return querySnapshot.docs.map((doc44) => ({
16292
- id: doc44.id,
16293
- ...doc44.data()
16585
+ return querySnapshot.docs.map((doc45) => ({
16586
+ id: doc45.id,
16587
+ ...doc45.data()
16294
16588
  }));
16295
16589
  }
16296
16590
  /**
@@ -16303,9 +16597,9 @@ var NotificationService = class extends BaseService {
16303
16597
  orderBy16("notificationTime", "desc")
16304
16598
  );
16305
16599
  const querySnapshot = await getDocs29(q);
16306
- return querySnapshot.docs.map((doc44) => ({
16307
- id: doc44.id,
16308
- ...doc44.data()
16600
+ return querySnapshot.docs.map((doc45) => ({
16601
+ id: doc45.id,
16602
+ ...doc45.data()
16309
16603
  }));
16310
16604
  }
16311
16605
  };
@@ -16316,13 +16610,13 @@ import {
16316
16610
  getDocs as getDocs30,
16317
16611
  query as query30,
16318
16612
  where as where30,
16319
- doc as doc35,
16613
+ doc as doc36,
16320
16614
  updateDoc as updateDoc33,
16321
16615
  Timestamp as Timestamp31,
16322
16616
  orderBy as orderBy17,
16323
16617
  limit as limit15,
16324
16618
  startAfter as startAfter13,
16325
- getDoc as getDoc36
16619
+ getDoc as getDoc37
16326
16620
  } from "firebase/firestore";
16327
16621
  var PatientRequirementsService = class extends BaseService {
16328
16622
  constructor(db, auth, app) {
@@ -16335,7 +16629,7 @@ var PatientRequirementsService = class extends BaseService {
16335
16629
  );
16336
16630
  }
16337
16631
  getPatientRequirementDocRef(patientId, instanceId) {
16338
- return doc35(
16632
+ return doc36(
16339
16633
  this.getPatientRequirementsCollectionRef(patientId),
16340
16634
  instanceId
16341
16635
  );
@@ -16348,7 +16642,7 @@ var PatientRequirementsService = class extends BaseService {
16348
16642
  */
16349
16643
  async getPatientRequirementInstance(patientId, instanceId) {
16350
16644
  const docRef = this.getPatientRequirementDocRef(patientId, instanceId);
16351
- const docSnap = await getDoc36(docRef);
16645
+ const docSnap = await getDoc37(docRef);
16352
16646
  if (!docSnap.exists()) {
16353
16647
  return null;
16354
16648
  }
@@ -16425,7 +16719,7 @@ var PatientRequirementsService = class extends BaseService {
16425
16719
  */
16426
16720
  async completeInstruction(patientId, instanceId, instructionId) {
16427
16721
  const instanceRef = this.getPatientRequirementDocRef(patientId, instanceId);
16428
- const instanceSnap = await getDoc36(instanceRef);
16722
+ const instanceSnap = await getDoc37(instanceRef);
16429
16723
  if (!instanceSnap.exists()) {
16430
16724
  throw new Error(
16431
16725
  `PatientRequirementInstance ${instanceId} not found for patient ${patientId}.`
@@ -16495,8 +16789,8 @@ var PatientRequirementsService = class extends BaseService {
16495
16789
  // src/services/procedure/procedure.service.ts
16496
16790
  import {
16497
16791
  collection as collection31,
16498
- doc as doc36,
16499
- getDoc as getDoc37,
16792
+ doc as doc37,
16793
+ getDoc as getDoc38,
16500
16794
  getDocs as getDocs31,
16501
16795
  query as query31,
16502
16796
  where as where31,
@@ -16773,14 +17067,14 @@ var ProcedureService = class extends BaseService {
16773
17067
  if (!isProductFree && !product) {
16774
17068
  throw new Error("Product not found for regular procedure");
16775
17069
  }
16776
- const clinicRef = doc36(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
16777
- const clinicSnapshot = await getDoc37(clinicRef);
17070
+ const clinicRef = doc37(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
17071
+ const clinicSnapshot = await getDoc38(clinicRef);
16778
17072
  if (!clinicSnapshot.exists()) {
16779
17073
  throw new Error(`Clinic with ID ${validatedData.clinicBranchId} not found`);
16780
17074
  }
16781
17075
  const clinic = clinicSnapshot.data();
16782
- const practitionerRef = doc36(this.db, PRACTITIONERS_COLLECTION, validatedData.practitionerId);
16783
- const practitionerSnapshot = await getDoc37(practitionerRef);
17076
+ const practitionerRef = doc37(this.db, PRACTITIONERS_COLLECTION, validatedData.practitionerId);
17077
+ const practitionerSnapshot = await getDoc38(practitionerRef);
16784
17078
  if (!practitionerSnapshot.exists()) {
16785
17079
  throw new Error(`Practitioner with ID ${validatedData.practitionerId} not found`);
16786
17080
  }
@@ -16869,13 +17163,13 @@ var ProcedureService = class extends BaseService {
16869
17163
  throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(", ")}`);
16870
17164
  }
16871
17165
  console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with setDoc");
16872
- const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, procedureId);
17166
+ const procedureRef = doc37(this.db, PROCEDURES_COLLECTION, procedureId);
16873
17167
  await setDoc27(procedureRef, {
16874
17168
  ...newProcedure,
16875
17169
  createdAt: serverTimestamp31(),
16876
17170
  updatedAt: serverTimestamp31()
16877
17171
  });
16878
- const savedDoc = await getDoc37(procedureRef);
17172
+ const savedDoc = await getDoc38(procedureRef);
16879
17173
  return savedDoc.data();
16880
17174
  }
16881
17175
  /**
@@ -16904,7 +17198,7 @@ var ProcedureService = class extends BaseService {
16904
17198
  this.productService.getById(validatedData.technologyId, validatedData.productId)
16905
17199
  );
16906
17200
  }
16907
- const clinicSnapshotPromise = getDoc37(doc36(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId));
17201
+ const clinicSnapshotPromise = getDoc38(doc37(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId));
16908
17202
  const [baseResults, clinicSnapshot] = await Promise.all([
16909
17203
  Promise.all(baseEntitiesPromises),
16910
17204
  clinicSnapshotPromise
@@ -16944,8 +17238,8 @@ var ProcedureService = class extends BaseService {
16944
17238
  where31(documentId2(), "in", chunk)
16945
17239
  );
16946
17240
  const practitionersSnapshot = await getDocs31(practitionersQuery);
16947
- practitionersSnapshot.docs.forEach((doc44) => {
16948
- practitionersMap.set(doc44.id, doc44.data());
17241
+ practitionersSnapshot.docs.forEach((doc45) => {
17242
+ practitionersMap.set(doc45.id, doc45.data());
16949
17243
  });
16950
17244
  }
16951
17245
  if (practitionersMap.size !== practitionerIds.length) {
@@ -16975,7 +17269,7 @@ var ProcedureService = class extends BaseService {
16975
17269
  };
16976
17270
  const procedureId = this.generateId();
16977
17271
  createdProcedureIds.push(procedureId);
16978
- const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, procedureId);
17272
+ const procedureRef = doc37(this.db, PROCEDURES_COLLECTION, procedureId);
16979
17273
  const { productsMetadata: _, productId: __, photos: ___, ...validatedDataWithoutProductsMetadata } = validatedData;
16980
17274
  const newProcedure = {
16981
17275
  id: procedureId,
@@ -17040,8 +17334,8 @@ var ProcedureService = class extends BaseService {
17040
17334
  const chunk = createdProcedureIds.slice(i, i + 30);
17041
17335
  const q = query31(collection31(this.db, PROCEDURES_COLLECTION), where31(documentId2(), "in", chunk));
17042
17336
  const snapshot = await getDocs31(q);
17043
- snapshot.forEach((doc44) => {
17044
- fetchedProcedures.push(doc44.data());
17337
+ snapshot.forEach((doc45) => {
17338
+ fetchedProcedures.push(doc45.data());
17045
17339
  });
17046
17340
  }
17047
17341
  return fetchedProcedures;
@@ -17052,8 +17346,8 @@ var ProcedureService = class extends BaseService {
17052
17346
  * @returns The procedure if found, null otherwise
17053
17347
  */
17054
17348
  async getProcedure(id) {
17055
- const docRef = doc36(this.db, PROCEDURES_COLLECTION, id);
17056
- const docSnap = await getDoc37(docRef);
17349
+ const docRef = doc37(this.db, PROCEDURES_COLLECTION, id);
17350
+ const docSnap = await getDoc38(docRef);
17057
17351
  if (!docSnap.exists()) {
17058
17352
  return null;
17059
17353
  }
@@ -17071,7 +17365,7 @@ var ProcedureService = class extends BaseService {
17071
17365
  where31("isActive", "==", true)
17072
17366
  );
17073
17367
  const snapshot = await getDocs31(q);
17074
- return snapshot.docs.map((doc44) => doc44.data());
17368
+ return snapshot.docs.map((doc45) => doc45.data());
17075
17369
  }
17076
17370
  /**
17077
17371
  * Gets all procedures for a practitioner
@@ -17085,7 +17379,7 @@ var ProcedureService = class extends BaseService {
17085
17379
  where31("isActive", "==", true)
17086
17380
  );
17087
17381
  const snapshot = await getDocs31(q);
17088
- return snapshot.docs.map((doc44) => doc44.data());
17382
+ return snapshot.docs.map((doc45) => doc45.data());
17089
17383
  }
17090
17384
  /**
17091
17385
  * Gets all inactive procedures for a practitioner
@@ -17099,7 +17393,7 @@ var ProcedureService = class extends BaseService {
17099
17393
  where31("isActive", "==", false)
17100
17394
  );
17101
17395
  const snapshot = await getDocs31(q);
17102
- return snapshot.docs.map((doc44) => doc44.data());
17396
+ return snapshot.docs.map((doc45) => doc45.data());
17103
17397
  }
17104
17398
  /**
17105
17399
  * Updates a procedure
@@ -17110,8 +17404,8 @@ var ProcedureService = class extends BaseService {
17110
17404
  async updateProcedure(id, data) {
17111
17405
  var _a, _b, _c;
17112
17406
  const validatedData = updateProcedureSchema.parse(data);
17113
- const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, id);
17114
- const procedureSnapshot = await getDoc37(procedureRef);
17407
+ const procedureRef = doc37(this.db, PROCEDURES_COLLECTION, id);
17408
+ const procedureSnapshot = await getDoc38(procedureRef);
17115
17409
  if (!procedureSnapshot.exists()) {
17116
17410
  throw new Error(`Procedure with ID ${id} not found`);
17117
17411
  }
@@ -17154,12 +17448,12 @@ var ProcedureService = class extends BaseService {
17154
17448
  }
17155
17449
  if (validatedData.practitionerId && validatedData.practitionerId !== oldPractitionerId) {
17156
17450
  practitionerChanged = true;
17157
- const newPractitionerRef = doc36(
17451
+ const newPractitionerRef = doc37(
17158
17452
  this.db,
17159
17453
  PRACTITIONERS_COLLECTION,
17160
17454
  validatedData.practitionerId
17161
17455
  );
17162
- const newPractitionerSnap = await getDoc37(newPractitionerRef);
17456
+ const newPractitionerSnap = await getDoc38(newPractitionerRef);
17163
17457
  if (!newPractitionerSnap.exists())
17164
17458
  throw new Error(`New Practitioner ${validatedData.practitionerId} not found`);
17165
17459
  newPractitioner = newPractitionerSnap.data();
@@ -17175,8 +17469,8 @@ var ProcedureService = class extends BaseService {
17175
17469
  }
17176
17470
  if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
17177
17471
  clinicChanged = true;
17178
- const newClinicRef = doc36(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
17179
- const newClinicSnap = await getDoc37(newClinicRef);
17472
+ const newClinicRef = doc37(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
17473
+ const newClinicSnap = await getDoc38(newClinicRef);
17180
17474
  if (!newClinicSnap.exists())
17181
17475
  throw new Error(`New Clinic ${validatedData.clinicBranchId} not found`);
17182
17476
  newClinic = newClinicSnap.data();
@@ -17242,7 +17536,7 @@ var ProcedureService = class extends BaseService {
17242
17536
  ...updatedProcedureData,
17243
17537
  updatedAt: serverTimestamp31()
17244
17538
  });
17245
- const updatedSnapshot = await getDoc37(procedureRef);
17539
+ const updatedSnapshot = await getDoc38(procedureRef);
17246
17540
  return updatedSnapshot.data();
17247
17541
  }
17248
17542
  /**
@@ -17250,8 +17544,8 @@ var ProcedureService = class extends BaseService {
17250
17544
  * @param id - The ID of the procedure to deactivate
17251
17545
  */
17252
17546
  async deactivateProcedure(id) {
17253
- const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, id);
17254
- const procedureSnap = await getDoc37(procedureRef);
17547
+ const procedureRef = doc37(this.db, PROCEDURES_COLLECTION, id);
17548
+ const procedureSnap = await getDoc38(procedureRef);
17255
17549
  if (!procedureSnap.exists()) {
17256
17550
  console.warn(`Procedure ${id} not found for deactivation.`);
17257
17551
  return;
@@ -17267,8 +17561,8 @@ var ProcedureService = class extends BaseService {
17267
17561
  * @returns A boolean indicating if the deletion was successful
17268
17562
  */
17269
17563
  async deleteProcedure(id) {
17270
- const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, id);
17271
- const procedureSnapshot = await getDoc37(procedureRef);
17564
+ const procedureRef = doc37(this.db, PROCEDURES_COLLECTION, id);
17565
+ const procedureSnapshot = await getDoc38(procedureRef);
17272
17566
  if (!procedureSnapshot.exists()) {
17273
17567
  return false;
17274
17568
  }
@@ -17318,11 +17612,11 @@ var ProcedureService = class extends BaseService {
17318
17612
  }
17319
17613
  const proceduresSnapshot = await getDocs31(proceduresQuery);
17320
17614
  const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
17321
- const procedures = proceduresSnapshot.docs.map((doc44) => {
17322
- const data = doc44.data();
17615
+ const procedures = proceduresSnapshot.docs.map((doc45) => {
17616
+ const data = doc45.data();
17323
17617
  return {
17324
17618
  ...data,
17325
- id: doc44.id
17619
+ id: doc45.id
17326
17620
  // Ensure ID is present
17327
17621
  };
17328
17622
  });
@@ -17441,7 +17735,7 @@ var ProcedureService = class extends BaseService {
17441
17735
  const q = query31(collection31(this.db, PROCEDURES_COLLECTION), ...constraints);
17442
17736
  const querySnapshot = await getDocs31(q);
17443
17737
  const procedures = querySnapshot.docs.map(
17444
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17738
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17445
17739
  );
17446
17740
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
17447
17741
  console.log(`[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`);
@@ -17474,7 +17768,7 @@ var ProcedureService = class extends BaseService {
17474
17768
  const q = query31(collection31(this.db, PROCEDURES_COLLECTION), ...constraints);
17475
17769
  const querySnapshot = await getDocs31(q);
17476
17770
  const procedures = querySnapshot.docs.map(
17477
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17771
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17478
17772
  );
17479
17773
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
17480
17774
  console.log(`[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`);
@@ -17505,7 +17799,7 @@ var ProcedureService = class extends BaseService {
17505
17799
  const q = query31(collection31(this.db, PROCEDURES_COLLECTION), ...constraints);
17506
17800
  const querySnapshot = await getDocs31(q);
17507
17801
  let procedures = querySnapshot.docs.map(
17508
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17802
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17509
17803
  );
17510
17804
  procedures = this.applyInMemoryFilters(procedures, filters);
17511
17805
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -17533,7 +17827,7 @@ var ProcedureService = class extends BaseService {
17533
17827
  const q = query31(collection31(this.db, PROCEDURES_COLLECTION), ...constraints);
17534
17828
  const querySnapshot = await getDocs31(q);
17535
17829
  let procedures = querySnapshot.docs.map(
17536
- (doc44) => ({ ...doc44.data(), id: doc44.id })
17830
+ (doc45) => ({ ...doc45.data(), id: doc45.id })
17537
17831
  );
17538
17832
  procedures = this.applyInMemoryFilters(procedures, filters);
17539
17833
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -17752,14 +18046,14 @@ var ProcedureService = class extends BaseService {
17752
18046
  if (!category || !subcategory || !technology) {
17753
18047
  throw new Error("One or more required base entities not found");
17754
18048
  }
17755
- const clinicRef = doc36(this.db, CLINICS_COLLECTION, data.clinicBranchId);
17756
- const clinicSnapshot = await getDoc37(clinicRef);
18049
+ const clinicRef = doc37(this.db, CLINICS_COLLECTION, data.clinicBranchId);
18050
+ const clinicSnapshot = await getDoc38(clinicRef);
17757
18051
  if (!clinicSnapshot.exists()) {
17758
18052
  throw new Error(`Clinic with ID ${data.clinicBranchId} not found`);
17759
18053
  }
17760
18054
  const clinic = clinicSnapshot.data();
17761
- const practitionerRef = doc36(this.db, PRACTITIONERS_COLLECTION, data.practitionerId);
17762
- const practitionerSnapshot = await getDoc37(practitionerRef);
18055
+ const practitionerRef = doc37(this.db, PRACTITIONERS_COLLECTION, data.practitionerId);
18056
+ const practitionerSnapshot = await getDoc38(practitionerRef);
17763
18057
  if (!practitionerSnapshot.exists()) {
17764
18058
  throw new Error(`Practitioner with ID ${data.practitionerId} not found`);
17765
18059
  }
@@ -17823,13 +18117,13 @@ var ProcedureService = class extends BaseService {
17823
18117
  },
17824
18118
  isActive: true
17825
18119
  };
17826
- const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, procedureId);
18120
+ const procedureRef = doc37(this.db, PROCEDURES_COLLECTION, procedureId);
17827
18121
  await setDoc27(procedureRef, {
17828
18122
  ...newProcedure,
17829
18123
  createdAt: serverTimestamp31(),
17830
18124
  updatedAt: serverTimestamp31()
17831
18125
  });
17832
- const savedDoc = await getDoc37(procedureRef);
18126
+ const savedDoc = await getDoc38(procedureRef);
17833
18127
  return savedDoc.data();
17834
18128
  }
17835
18129
  /**
@@ -17840,11 +18134,11 @@ var ProcedureService = class extends BaseService {
17840
18134
  async getProceduresForMap() {
17841
18135
  const proceduresRef = collection31(this.db, PROCEDURES_COLLECTION);
17842
18136
  const snapshot = await getDocs31(proceduresRef);
17843
- const proceduresForMap = snapshot.docs.map((doc44) => {
18137
+ const proceduresForMap = snapshot.docs.map((doc45) => {
17844
18138
  var _a, _b, _c, _d, _e, _f, _g, _h;
17845
- const data = doc44.data();
18139
+ const data = doc45.data();
17846
18140
  return {
17847
- id: doc44.id,
18141
+ id: doc45.id,
17848
18142
  name: data.name,
17849
18143
  clinicId: (_a = data.clinicInfo) == null ? void 0 : _a.id,
17850
18144
  clinicName: (_b = data.clinicInfo) == null ? void 0 : _b.name,
@@ -17866,8 +18160,8 @@ var ProcedureService = class extends BaseService {
17866
18160
  async getProceduresForConsultation(clinicBranchId, practitionerId, filterByFamily = true, defaultProcedureId) {
17867
18161
  let familyToFilter = null;
17868
18162
  if (filterByFamily && defaultProcedureId) {
17869
- const defaultProcedureRef = doc36(this.db, PROCEDURES_COLLECTION, defaultProcedureId);
17870
- const defaultProcedureSnap = await getDoc37(defaultProcedureRef);
18163
+ const defaultProcedureRef = doc37(this.db, PROCEDURES_COLLECTION, defaultProcedureId);
18164
+ const defaultProcedureSnap = await getDoc38(defaultProcedureRef);
17871
18165
  if (defaultProcedureSnap.exists()) {
17872
18166
  const defaultProcedure = defaultProcedureSnap.data();
17873
18167
  familyToFilter = defaultProcedure.family;
@@ -17887,9 +18181,9 @@ var ProcedureService = class extends BaseService {
17887
18181
  orderBy18("name", "asc")
17888
18182
  );
17889
18183
  const querySnapshot = await getDocs31(proceduresQuery);
17890
- return querySnapshot.docs.map((doc44) => ({
17891
- id: doc44.id,
17892
- ...doc44.data()
18184
+ return querySnapshot.docs.map((doc45) => ({
18185
+ id: doc45.id,
18186
+ ...doc45.data()
17893
18187
  }));
17894
18188
  }
17895
18189
  };
@@ -17897,8 +18191,8 @@ var ProcedureService = class extends BaseService {
17897
18191
  // src/services/reviews/reviews.service.ts
17898
18192
  import {
17899
18193
  collection as collection32,
17900
- doc as doc37,
17901
- getDoc as getDoc38,
18194
+ doc as doc38,
18195
+ getDoc as getDoc39,
17902
18196
  getDocs as getDocs32,
17903
18197
  query as query32,
17904
18198
  where as where32,
@@ -17918,17 +18212,16 @@ var ReviewService = class extends BaseService {
17918
18212
  * @returns The created review
17919
18213
  */
17920
18214
  async createReview(data, appointmentId) {
17921
- var _a, _b, _c, _d, _e, _f, _g, _h;
18215
+ var _a, _b, _c, _d, _e, _f;
17922
18216
  try {
17923
18217
  console.log("\u{1F50D} ReviewService.createReview - Input data:", {
17924
18218
  appointmentId,
17925
18219
  hasClinicReview: !!data.clinicReview,
17926
18220
  hasPractitionerReview: !!data.practitionerReview,
17927
18221
  hasProcedureReview: !!data.procedureReview,
17928
- extendedProcedureReviewsCount: ((_a = data.extendedProcedureReviews) == null ? void 0 : _a.length) || 0,
17929
- practitionerId: (_b = data.practitionerReview) == null ? void 0 : _b.practitionerId,
17930
- clinicId: (_c = data.clinicReview) == null ? void 0 : _c.clinicId,
17931
- procedureId: (_d = data.procedureReview) == null ? void 0 : _d.procedureId
18222
+ practitionerId: (_a = data.practitionerReview) == null ? void 0 : _a.practitionerId,
18223
+ clinicId: (_b = data.clinicReview) == null ? void 0 : _b.clinicId,
18224
+ procedureId: (_c = data.procedureReview) == null ? void 0 : _c.procedureId
17932
18225
  });
17933
18226
  const validatedData = createReviewSchema.parse(data);
17934
18227
  const ratings = [];
@@ -17968,20 +18261,6 @@ var ReviewService = class extends BaseService {
17968
18261
  data.procedureReview.overallRating = procedureAverage;
17969
18262
  ratings.push(procedureAverage);
17970
18263
  }
17971
- if (data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0) {
17972
- data.extendedProcedureReviews.forEach((extendedReview) => {
17973
- const extendedRatings = [
17974
- extendedReview.effectivenessOfTreatment,
17975
- extendedReview.outcomeExplanation,
17976
- extendedReview.painManagement,
17977
- extendedReview.followUpCare,
17978
- extendedReview.valueForMoney
17979
- ];
17980
- const extendedAverage = this.calculateAverage(extendedRatings);
17981
- extendedReview.overallRating = extendedAverage;
17982
- ratings.push(extendedAverage);
17983
- });
17984
- }
17985
18264
  const overallRating = this.calculateAverage(ratings);
17986
18265
  const reviewId = this.generateId();
17987
18266
  if (data.clinicReview) {
@@ -17997,14 +18276,6 @@ var ReviewService = class extends BaseService {
17997
18276
  data.procedureReview.fullReviewId = reviewId;
17998
18277
  }
17999
18278
  const now = /* @__PURE__ */ new Date();
18000
- if (data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0) {
18001
- data.extendedProcedureReviews.forEach((extendedReview) => {
18002
- extendedReview.id = this.generateId();
18003
- extendedReview.fullReviewId = reviewId;
18004
- extendedReview.createdAt = now;
18005
- extendedReview.updatedAt = now;
18006
- });
18007
- }
18008
18279
  const review = {
18009
18280
  id: reviewId,
18010
18281
  appointmentId,
@@ -18012,14 +18283,13 @@ var ReviewService = class extends BaseService {
18012
18283
  clinicReview: data.clinicReview,
18013
18284
  practitionerReview: data.practitionerReview,
18014
18285
  procedureReview: data.procedureReview,
18015
- extendedProcedureReviews: data.extendedProcedureReviews,
18016
18286
  overallComment: data.overallComment,
18017
18287
  overallRating,
18018
18288
  createdAt: now,
18019
18289
  updatedAt: now
18020
18290
  };
18021
18291
  reviewSchema.parse(review);
18022
- const docRef = doc37(this.db, REVIEWS_COLLECTION, reviewId);
18292
+ const docRef = doc38(this.db, REVIEWS_COLLECTION, reviewId);
18023
18293
  await setDoc28(docRef, {
18024
18294
  ...review,
18025
18295
  createdAt: serverTimestamp32(),
@@ -18027,10 +18297,9 @@ var ReviewService = class extends BaseService {
18027
18297
  });
18028
18298
  console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
18029
18299
  reviewId,
18030
- practitionerId: (_e = review.practitionerReview) == null ? void 0 : _e.practitionerId,
18031
- clinicId: (_f = review.clinicReview) == null ? void 0 : _f.clinicId,
18032
- procedureId: (_g = review.procedureReview) == null ? void 0 : _g.procedureId,
18033
- extendedProcedureReviewsCount: ((_h = review.extendedProcedureReviews) == null ? void 0 : _h.length) || 0
18300
+ practitionerId: (_d = review.practitionerReview) == null ? void 0 : _d.practitionerId,
18301
+ clinicId: (_e = review.clinicReview) == null ? void 0 : _e.clinicId,
18302
+ procedureId: (_f = review.procedureReview) == null ? void 0 : _f.procedureId
18034
18303
  });
18035
18304
  return review;
18036
18305
  } catch (error) {
@@ -18046,18 +18315,18 @@ var ReviewService = class extends BaseService {
18046
18315
  * @returns The review with entity names if found, null otherwise
18047
18316
  */
18048
18317
  async getReview(reviewId) {
18049
- var _a, _b, _c, _d, _e;
18318
+ var _a, _b, _c;
18050
18319
  console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
18051
- const docRef = doc37(this.db, REVIEWS_COLLECTION, reviewId);
18052
- const docSnap = await getDoc38(docRef);
18320
+ const docRef = doc38(this.db, REVIEWS_COLLECTION, reviewId);
18321
+ const docSnap = await getDoc39(docRef);
18053
18322
  if (!docSnap.exists()) {
18054
18323
  console.log("\u274C ReviewService.getReview - Review not found:", reviewId);
18055
18324
  return null;
18056
18325
  }
18057
18326
  const review = { ...docSnap.data(), id: reviewId };
18058
18327
  try {
18059
- const appointmentDoc = await getDoc38(
18060
- doc37(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18328
+ const appointmentDoc = await getDoc39(
18329
+ doc38(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18061
18330
  );
18062
18331
  if (appointmentDoc.exists()) {
18063
18332
  const appointment = appointmentDoc.data();
@@ -18080,27 +18349,12 @@ var ReviewService = class extends BaseService {
18080
18349
  procedureName: appointment.procedureInfo.name
18081
18350
  };
18082
18351
  }
18083
- if (enhancedReview.extendedProcedureReviews && enhancedReview.extendedProcedureReviews.length > 0) {
18084
- const extendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.extendedProcedures) || [];
18085
- enhancedReview.extendedProcedureReviews = enhancedReview.extendedProcedureReviews.map((extendedReview) => {
18086
- const procedureInfo = extendedProcedures.find(
18087
- (ep) => ep.procedureId === extendedReview.procedureId
18088
- );
18089
- if (procedureInfo) {
18090
- return {
18091
- ...extendedReview,
18092
- procedureName: procedureInfo.procedureName
18093
- };
18094
- }
18095
- return extendedReview;
18096
- });
18097
- }
18098
18352
  if (appointment.patientInfo) {
18099
18353
  enhancedReview.patientName = appointment.patientInfo.fullName;
18100
18354
  }
18101
18355
  console.log("\u2705 ReviewService.getReview - Enhanced review:", {
18102
18356
  reviewId,
18103
- hasEntityNames: !!(((_b = enhancedReview.clinicReview) == null ? void 0 : _b.clinicName) || ((_c = enhancedReview.practitionerReview) == null ? void 0 : _c.practitionerName) || ((_d = enhancedReview.procedureReview) == null ? void 0 : _d.procedureName) || enhancedReview.patientName || ((_e = enhancedReview.extendedProcedureReviews) == null ? void 0 : _e.some((epr) => epr.procedureName)))
18357
+ hasEntityNames: !!(((_a = enhancedReview.clinicReview) == null ? void 0 : _a.clinicName) || ((_b = enhancedReview.practitionerReview) == null ? void 0 : _b.practitionerName) || ((_c = enhancedReview.procedureReview) == null ? void 0 : _c.procedureName) || enhancedReview.patientName)
18104
18358
  });
18105
18359
  return enhancedReview;
18106
18360
  }
@@ -18119,12 +18373,12 @@ var ReviewService = class extends BaseService {
18119
18373
  async getReviewsByPatient(patientId) {
18120
18374
  const q = query32(collection32(this.db, REVIEWS_COLLECTION), where32("patientId", "==", patientId));
18121
18375
  const snapshot = await getDocs32(q);
18122
- const reviews = snapshot.docs.map((doc44) => doc44.data());
18376
+ const reviews = snapshot.docs.map((doc45) => doc45.data());
18123
18377
  const enhancedReviews = await Promise.all(
18124
18378
  reviews.map(async (review) => {
18125
18379
  try {
18126
- const appointmentDoc = await getDoc38(
18127
- doc37(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18380
+ const appointmentDoc = await getDoc39(
18381
+ doc38(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18128
18382
  );
18129
18383
  if (appointmentDoc.exists()) {
18130
18384
  const appointment = appointmentDoc.data();
@@ -18173,9 +18427,9 @@ var ReviewService = class extends BaseService {
18173
18427
  where32("clinicReview.clinicId", "==", clinicId)
18174
18428
  );
18175
18429
  const snapshot = await getDocs32(q);
18176
- const reviews = snapshot.docs.map((doc44) => {
18177
- const data = doc44.data();
18178
- return { ...data, id: doc44.id };
18430
+ const reviews = snapshot.docs.map((doc45) => {
18431
+ const data = doc45.data();
18432
+ return { ...data, id: doc45.id };
18179
18433
  });
18180
18434
  console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
18181
18435
  clinicId,
@@ -18185,8 +18439,8 @@ var ReviewService = class extends BaseService {
18185
18439
  const enhancedReviews = await Promise.all(
18186
18440
  reviews.map(async (review) => {
18187
18441
  try {
18188
- const appointmentDoc = await getDoc38(
18189
- doc37(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18442
+ const appointmentDoc = await getDoc39(
18443
+ doc38(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18190
18444
  );
18191
18445
  if (appointmentDoc.exists()) {
18192
18446
  const appointment = appointmentDoc.data();
@@ -18249,9 +18503,9 @@ var ReviewService = class extends BaseService {
18249
18503
  where32("practitionerReview.practitionerId", "==", practitionerId)
18250
18504
  );
18251
18505
  const snapshot = await getDocs32(q);
18252
- const reviews = snapshot.docs.map((doc44) => {
18253
- const data = doc44.data();
18254
- return { ...data, id: doc44.id };
18506
+ const reviews = snapshot.docs.map((doc45) => {
18507
+ const data = doc45.data();
18508
+ return { ...data, id: doc45.id };
18255
18509
  });
18256
18510
  console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
18257
18511
  practitionerId,
@@ -18261,8 +18515,8 @@ var ReviewService = class extends BaseService {
18261
18515
  const enhancedReviews = await Promise.all(
18262
18516
  reviews.map(async (review) => {
18263
18517
  try {
18264
- const appointmentDoc = await getDoc38(
18265
- doc37(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18518
+ const appointmentDoc = await getDoc39(
18519
+ doc38(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18266
18520
  );
18267
18521
  if (appointmentDoc.exists()) {
18268
18522
  const appointment = appointmentDoc.data();
@@ -18322,9 +18576,9 @@ var ReviewService = class extends BaseService {
18322
18576
  where32("procedureReview.procedureId", "==", procedureId)
18323
18577
  );
18324
18578
  const snapshot = await getDocs32(q);
18325
- const reviews = snapshot.docs.map((doc44) => {
18326
- const data = doc44.data();
18327
- return { ...data, id: doc44.id };
18579
+ const reviews = snapshot.docs.map((doc45) => {
18580
+ const data = doc45.data();
18581
+ return { ...data, id: doc45.id };
18328
18582
  });
18329
18583
  console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
18330
18584
  procedureId,
@@ -18334,8 +18588,8 @@ var ReviewService = class extends BaseService {
18334
18588
  const enhancedReviews = await Promise.all(
18335
18589
  reviews.map(async (review) => {
18336
18590
  try {
18337
- const appointmentDoc = await getDoc38(
18338
- doc37(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18591
+ const appointmentDoc = await getDoc39(
18592
+ doc38(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
18339
18593
  );
18340
18594
  if (appointmentDoc.exists()) {
18341
18595
  const appointment = appointmentDoc.data();
@@ -18408,7 +18662,7 @@ var ReviewService = class extends BaseService {
18408
18662
  if (!review) {
18409
18663
  throw new Error(`Review with ID ${reviewId} not found`);
18410
18664
  }
18411
- await deleteDoc20(doc37(this.db, REVIEWS_COLLECTION, reviewId));
18665
+ await deleteDoc20(doc38(this.db, REVIEWS_COLLECTION, reviewId));
18412
18666
  }
18413
18667
  /**
18414
18668
  * Calculates the average of an array of numbers
@@ -18482,8 +18736,8 @@ var getFirebaseFunctions = async () => {
18482
18736
  import {
18483
18737
  addDoc as addDoc4,
18484
18738
  collection as collection33,
18485
- doc as doc38,
18486
- getDoc as getDoc39,
18739
+ doc as doc39,
18740
+ getDoc as getDoc40,
18487
18741
  getDocs as getDocs33,
18488
18742
  query as query33,
18489
18743
  updateDoc as updateDoc35,
@@ -18545,9 +18799,9 @@ var BrandService = class extends BaseService {
18545
18799
  const q = query33(this.getBrandsRef(), ...constraints);
18546
18800
  const snapshot = await getDocs33(q);
18547
18801
  const brands = snapshot.docs.map(
18548
- (doc44) => ({
18549
- id: doc44.id,
18550
- ...doc44.data()
18802
+ (doc45) => ({
18803
+ id: doc45.id,
18804
+ ...doc45.data()
18551
18805
  })
18552
18806
  );
18553
18807
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -18581,9 +18835,9 @@ var BrandService = class extends BaseService {
18581
18835
  );
18582
18836
  const snapshot = await getDocs33(q);
18583
18837
  return snapshot.docs.map(
18584
- (doc44) => ({
18585
- id: doc44.id,
18586
- ...doc44.data()
18838
+ (doc45) => ({
18839
+ id: doc45.id,
18840
+ ...doc45.data()
18587
18841
  })
18588
18842
  );
18589
18843
  }
@@ -18598,7 +18852,7 @@ var BrandService = class extends BaseService {
18598
18852
  if (brand.name) {
18599
18853
  updateData.name_lowercase = brand.name.toLowerCase();
18600
18854
  }
18601
- const docRef = doc38(this.getBrandsRef(), brandId);
18855
+ const docRef = doc39(this.getBrandsRef(), brandId);
18602
18856
  await updateDoc35(docRef, updateData);
18603
18857
  return this.getById(brandId);
18604
18858
  }
@@ -18614,8 +18868,8 @@ var BrandService = class extends BaseService {
18614
18868
  * Gets a brand by ID
18615
18869
  */
18616
18870
  async getById(brandId) {
18617
- const docRef = doc38(this.getBrandsRef(), brandId);
18618
- const docSnap = await getDoc39(docRef);
18871
+ const docRef = doc39(this.getBrandsRef(), brandId);
18872
+ const docSnap = await getDoc40(docRef);
18619
18873
  if (!docSnap.exists()) return null;
18620
18874
  return {
18621
18875
  id: docSnap.id,
@@ -18695,9 +18949,9 @@ var BrandService = class extends BaseService {
18695
18949
  import {
18696
18950
  addDoc as addDoc5,
18697
18951
  collection as collection34,
18698
- doc as doc39,
18952
+ doc as doc40,
18699
18953
  getCountFromServer as getCountFromServer4,
18700
- getDoc as getDoc40,
18954
+ getDoc as getDoc41,
18701
18955
  getDocs as getDocs34,
18702
18956
  limit as limit18,
18703
18957
  orderBy as orderBy20,
@@ -18761,9 +19015,9 @@ var CategoryService = class extends BaseService {
18761
19015
  const q = query34(this.categoriesRef, where34("isActive", "==", true));
18762
19016
  const snapshot = await getDocs34(q);
18763
19017
  return snapshot.docs.map(
18764
- (doc44) => ({
18765
- id: doc44.id,
18766
- ...doc44.data()
19018
+ (doc45) => ({
19019
+ id: doc45.id,
19020
+ ...doc45.data()
18767
19021
  })
18768
19022
  );
18769
19023
  }
@@ -18781,9 +19035,9 @@ var CategoryService = class extends BaseService {
18781
19035
  );
18782
19036
  const snapshot = await getDocs34(q);
18783
19037
  return snapshot.docs.map(
18784
- (doc44) => ({
18785
- id: doc44.id,
18786
- ...doc44.data()
19038
+ (doc45) => ({
19039
+ id: doc45.id,
19040
+ ...doc45.data()
18787
19041
  })
18788
19042
  );
18789
19043
  }
@@ -18803,9 +19057,9 @@ var CategoryService = class extends BaseService {
18803
19057
  const q = query34(this.categoriesRef, ...constraints);
18804
19058
  const snapshot = await getDocs34(q);
18805
19059
  const categories = snapshot.docs.map(
18806
- (doc44) => ({
18807
- id: doc44.id,
18808
- ...doc44.data()
19060
+ (doc45) => ({
19061
+ id: doc45.id,
19062
+ ...doc45.data()
18809
19063
  })
18810
19064
  );
18811
19065
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -18829,9 +19083,9 @@ var CategoryService = class extends BaseService {
18829
19083
  const q = query34(this.categoriesRef, ...constraints);
18830
19084
  const snapshot = await getDocs34(q);
18831
19085
  const categories = snapshot.docs.map(
18832
- (doc44) => ({
18833
- id: doc44.id,
18834
- ...doc44.data()
19086
+ (doc45) => ({
19087
+ id: doc45.id,
19088
+ ...doc45.data()
18835
19089
  })
18836
19090
  );
18837
19091
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -18848,7 +19102,7 @@ var CategoryService = class extends BaseService {
18848
19102
  ...category,
18849
19103
  updatedAt: /* @__PURE__ */ new Date()
18850
19104
  };
18851
- const docRef = doc39(this.categoriesRef, id);
19105
+ const docRef = doc40(this.categoriesRef, id);
18852
19106
  await updateDoc36(docRef, updateData);
18853
19107
  return this.getById(id);
18854
19108
  }
@@ -18872,8 +19126,8 @@ var CategoryService = class extends BaseService {
18872
19126
  * @returns Kategorija ili null ako ne postoji
18873
19127
  */
18874
19128
  async getById(id) {
18875
- const docRef = doc39(this.categoriesRef, id);
18876
- const docSnap = await getDoc40(docRef);
19129
+ const docRef = doc40(this.categoriesRef, id);
19130
+ const docSnap = await getDoc41(docRef);
18877
19131
  if (!docSnap.exists()) return null;
18878
19132
  return {
18879
19133
  id: docSnap.id,
@@ -18953,9 +19207,9 @@ import {
18953
19207
  collection as collection35,
18954
19208
  collectionGroup as collectionGroup2,
18955
19209
  deleteDoc as deleteDoc21,
18956
- doc as doc40,
19210
+ doc as doc41,
18957
19211
  getCountFromServer as getCountFromServer5,
18958
- getDoc as getDoc41,
19212
+ getDoc as getDoc42,
18959
19213
  getDocs as getDocs35,
18960
19214
  limit as limit19,
18961
19215
  orderBy as orderBy21,
@@ -19039,9 +19293,9 @@ var SubcategoryService = class extends BaseService {
19039
19293
  const q = query35(this.getSubcategoriesRef(categoryId), ...constraints);
19040
19294
  const querySnapshot = await getDocs35(q);
19041
19295
  const subcategories = querySnapshot.docs.map(
19042
- (doc44) => ({
19043
- id: doc44.id,
19044
- ...doc44.data()
19296
+ (doc45) => ({
19297
+ id: doc45.id,
19298
+ ...doc45.data()
19045
19299
  })
19046
19300
  );
19047
19301
  const newLastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
@@ -19069,9 +19323,9 @@ var SubcategoryService = class extends BaseService {
19069
19323
  );
19070
19324
  const querySnapshot = await getDocs35(q);
19071
19325
  const subcategories = querySnapshot.docs.map(
19072
- (doc44) => ({
19073
- id: doc44.id,
19074
- ...doc44.data()
19326
+ (doc45) => ({
19327
+ id: doc45.id,
19328
+ ...doc45.data()
19075
19329
  })
19076
19330
  );
19077
19331
  const newLastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
@@ -19089,9 +19343,9 @@ var SubcategoryService = class extends BaseService {
19089
19343
  );
19090
19344
  const querySnapshot = await getDocs35(q);
19091
19345
  return querySnapshot.docs.map(
19092
- (doc44) => ({
19093
- id: doc44.id,
19094
- ...doc44.data()
19346
+ (doc45) => ({
19347
+ id: doc45.id,
19348
+ ...doc45.data()
19095
19349
  })
19096
19350
  );
19097
19351
  }
@@ -19106,9 +19360,9 @@ var SubcategoryService = class extends BaseService {
19106
19360
  );
19107
19361
  const querySnapshot = await getDocs35(q);
19108
19362
  return querySnapshot.docs.map(
19109
- (doc44) => ({
19110
- id: doc44.id,
19111
- ...doc44.data()
19363
+ (doc45) => ({
19364
+ id: doc45.id,
19365
+ ...doc45.data()
19112
19366
  })
19113
19367
  );
19114
19368
  }
@@ -19122,11 +19376,11 @@ var SubcategoryService = class extends BaseService {
19122
19376
  async update(categoryId, subcategoryId, subcategory) {
19123
19377
  const newCategoryId = subcategory.categoryId;
19124
19378
  if (newCategoryId && newCategoryId !== categoryId) {
19125
- const oldDocRef = doc40(
19379
+ const oldDocRef = doc41(
19126
19380
  this.getSubcategoriesRef(categoryId),
19127
19381
  subcategoryId
19128
19382
  );
19129
- const docSnap = await getDoc41(oldDocRef);
19383
+ const docSnap = await getDoc42(oldDocRef);
19130
19384
  if (!docSnap.exists()) {
19131
19385
  throw new Error("Subcategory to update does not exist.");
19132
19386
  }
@@ -19140,7 +19394,7 @@ var SubcategoryService = class extends BaseService {
19140
19394
  // Preserve original creation date
19141
19395
  updatedAt: /* @__PURE__ */ new Date()
19142
19396
  };
19143
- const newDocRef = doc40(
19397
+ const newDocRef = doc41(
19144
19398
  this.getSubcategoriesRef(newCategoryId),
19145
19399
  subcategoryId
19146
19400
  );
@@ -19152,7 +19406,7 @@ var SubcategoryService = class extends BaseService {
19152
19406
  ...subcategory,
19153
19407
  updatedAt: /* @__PURE__ */ new Date()
19154
19408
  };
19155
- const docRef = doc40(this.getSubcategoriesRef(categoryId), subcategoryId);
19409
+ const docRef = doc41(this.getSubcategoriesRef(categoryId), subcategoryId);
19156
19410
  await updateDoc37(docRef, updateData);
19157
19411
  return this.getById(categoryId, subcategoryId);
19158
19412
  }
@@ -19180,8 +19434,8 @@ var SubcategoryService = class extends BaseService {
19180
19434
  * @returns Podkategorija ili null ako ne postoji
19181
19435
  */
19182
19436
  async getById(categoryId, subcategoryId) {
19183
- const docRef = doc40(this.getSubcategoriesRef(categoryId), subcategoryId);
19184
- const docSnap = await getDoc41(docRef);
19437
+ const docRef = doc41(this.getSubcategoriesRef(categoryId), subcategoryId);
19438
+ const docSnap = await getDoc42(docRef);
19185
19439
  if (!docSnap.exists()) return null;
19186
19440
  return {
19187
19441
  id: docSnap.id,
@@ -19262,8 +19516,8 @@ var SubcategoryService = class extends BaseService {
19262
19516
  import {
19263
19517
  addDoc as addDoc7,
19264
19518
  collection as collection36,
19265
- doc as doc41,
19266
- getDoc as getDoc42,
19519
+ doc as doc42,
19520
+ getDoc as getDoc43,
19267
19521
  getDocs as getDocs36,
19268
19522
  limit as limit20,
19269
19523
  orderBy as orderBy22,
@@ -19317,6 +19571,9 @@ var TechnologyService = class extends BaseService {
19317
19571
  if (technology.technicalDetails) {
19318
19572
  newTechnology.technicalDetails = technology.technicalDetails;
19319
19573
  }
19574
+ if (technology.photoTemplate) {
19575
+ newTechnology.photoTemplate = technology.photoTemplate;
19576
+ }
19320
19577
  const docRef = await addDoc7(this.technologiesRef, newTechnology);
19321
19578
  return { id: docRef.id, ...newTechnology };
19322
19579
  }
@@ -19329,8 +19586,8 @@ var TechnologyService = class extends BaseService {
19329
19586
  const q = query36(this.technologiesRef, where36("isActive", "==", active));
19330
19587
  const snapshot = await getDocs36(q);
19331
19588
  const counts = {};
19332
- snapshot.docs.forEach((doc44) => {
19333
- const tech = doc44.data();
19589
+ snapshot.docs.forEach((doc45) => {
19590
+ const tech = doc45.data();
19334
19591
  counts[tech.subcategoryId] = (counts[tech.subcategoryId] || 0) + 1;
19335
19592
  });
19336
19593
  return counts;
@@ -19344,8 +19601,8 @@ var TechnologyService = class extends BaseService {
19344
19601
  const q = query36(this.technologiesRef, where36("isActive", "==", active));
19345
19602
  const snapshot = await getDocs36(q);
19346
19603
  const counts = {};
19347
- snapshot.docs.forEach((doc44) => {
19348
- const tech = doc44.data();
19604
+ snapshot.docs.forEach((doc45) => {
19605
+ const tech = doc45.data();
19349
19606
  counts[tech.categoryId] = (counts[tech.categoryId] || 0) + 1;
19350
19607
  });
19351
19608
  return counts;
@@ -19366,9 +19623,9 @@ var TechnologyService = class extends BaseService {
19366
19623
  const q = query36(this.technologiesRef, ...constraints);
19367
19624
  const snapshot = await getDocs36(q);
19368
19625
  const technologies = snapshot.docs.map(
19369
- (doc44) => ({
19370
- id: doc44.id,
19371
- ...doc44.data()
19626
+ (doc45) => ({
19627
+ id: doc45.id,
19628
+ ...doc45.data()
19372
19629
  })
19373
19630
  );
19374
19631
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19392,9 +19649,9 @@ var TechnologyService = class extends BaseService {
19392
19649
  const q = query36(this.technologiesRef, ...constraints);
19393
19650
  const snapshot = await getDocs36(q);
19394
19651
  const technologies = snapshot.docs.map(
19395
- (doc44) => ({
19396
- id: doc44.id,
19397
- ...doc44.data()
19652
+ (doc45) => ({
19653
+ id: doc45.id,
19654
+ ...doc45.data()
19398
19655
  })
19399
19656
  );
19400
19657
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19418,9 +19675,9 @@ var TechnologyService = class extends BaseService {
19418
19675
  const q = query36(this.technologiesRef, ...constraints);
19419
19676
  const snapshot = await getDocs36(q);
19420
19677
  const technologies = snapshot.docs.map(
19421
- (doc44) => ({
19422
- id: doc44.id,
19423
- ...doc44.data()
19678
+ (doc45) => ({
19679
+ id: doc45.id,
19680
+ ...doc45.data()
19424
19681
  })
19425
19682
  );
19426
19683
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -19439,8 +19696,15 @@ var TechnologyService = class extends BaseService {
19439
19696
  delete updateData[key];
19440
19697
  }
19441
19698
  });
19699
+ if ("photoTemplate" in technology) {
19700
+ if (technology.photoTemplate === null || technology.photoTemplate === "") {
19701
+ updateData.photoTemplate = null;
19702
+ } else if (technology.photoTemplate !== void 0) {
19703
+ updateData.photoTemplate = technology.photoTemplate;
19704
+ }
19705
+ }
19442
19706
  updateData.updatedAt = /* @__PURE__ */ new Date();
19443
- const docRef = doc41(this.technologiesRef, id);
19707
+ const docRef = doc42(this.technologiesRef, id);
19444
19708
  const beforeTech = await this.getById(id);
19445
19709
  await updateDoc38(docRef, updateData);
19446
19710
  const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
@@ -19475,8 +19739,8 @@ var TechnologyService = class extends BaseService {
19475
19739
  * @returns The technology or null if it doesn't exist.
19476
19740
  */
19477
19741
  async getById(id) {
19478
- const docRef = doc41(this.technologiesRef, id);
19479
- const docSnap = await getDoc42(docRef);
19742
+ const docRef = doc42(this.technologiesRef, id);
19743
+ const docSnap = await getDoc43(docRef);
19480
19744
  if (!docSnap.exists()) return null;
19481
19745
  return {
19482
19746
  id: docSnap.id,
@@ -19490,7 +19754,7 @@ var TechnologyService = class extends BaseService {
19490
19754
  * @returns Ažurirana tehnologija sa novim zahtevom
19491
19755
  */
19492
19756
  async addRequirement(technologyId, requirement) {
19493
- const docRef = doc41(this.technologiesRef, technologyId);
19757
+ const docRef = doc42(this.technologiesRef, technologyId);
19494
19758
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
19495
19759
  await updateDoc38(docRef, {
19496
19760
  [requirementType]: arrayUnion9(requirement),
@@ -19505,7 +19769,7 @@ var TechnologyService = class extends BaseService {
19505
19769
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
19506
19770
  */
19507
19771
  async removeRequirement(technologyId, requirement) {
19508
- const docRef = doc41(this.technologiesRef, technologyId);
19772
+ const docRef = doc42(this.technologiesRef, technologyId);
19509
19773
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
19510
19774
  await updateDoc38(docRef, {
19511
19775
  [requirementType]: arrayRemove8(requirement),
@@ -19545,7 +19809,7 @@ var TechnologyService = class extends BaseService {
19545
19809
  * @returns Ažurirana tehnologija
19546
19810
  */
19547
19811
  async addBlockingCondition(technologyId, condition) {
19548
- const docRef = doc41(this.technologiesRef, technologyId);
19812
+ const docRef = doc42(this.technologiesRef, technologyId);
19549
19813
  await updateDoc38(docRef, {
19550
19814
  blockingConditions: arrayUnion9(condition),
19551
19815
  updatedAt: /* @__PURE__ */ new Date()
@@ -19559,7 +19823,7 @@ var TechnologyService = class extends BaseService {
19559
19823
  * @returns Ažurirana tehnologija
19560
19824
  */
19561
19825
  async removeBlockingCondition(technologyId, condition) {
19562
- const docRef = doc41(this.technologiesRef, technologyId);
19826
+ const docRef = doc42(this.technologiesRef, technologyId);
19563
19827
  await updateDoc38(docRef, {
19564
19828
  blockingConditions: arrayRemove8(condition),
19565
19829
  updatedAt: /* @__PURE__ */ new Date()
@@ -19573,7 +19837,7 @@ var TechnologyService = class extends BaseService {
19573
19837
  * @returns Ažurirana tehnologija
19574
19838
  */
19575
19839
  async addContraindication(technologyId, contraindication) {
19576
- const docRef = doc41(this.technologiesRef, technologyId);
19840
+ const docRef = doc42(this.technologiesRef, technologyId);
19577
19841
  const technology = await this.getById(technologyId);
19578
19842
  if (!technology) {
19579
19843
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -19595,7 +19859,7 @@ var TechnologyService = class extends BaseService {
19595
19859
  * @returns Ažurirana tehnologija
19596
19860
  */
19597
19861
  async removeContraindication(technologyId, contraindication) {
19598
- const docRef = doc41(this.technologiesRef, technologyId);
19862
+ const docRef = doc42(this.technologiesRef, technologyId);
19599
19863
  const technology = await this.getById(technologyId);
19600
19864
  if (!technology) {
19601
19865
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -19617,7 +19881,7 @@ var TechnologyService = class extends BaseService {
19617
19881
  * @returns The updated technology
19618
19882
  */
19619
19883
  async updateContraindication(technologyId, contraindication) {
19620
- const docRef = doc41(this.technologiesRef, technologyId);
19884
+ const docRef = doc42(this.technologiesRef, technologyId);
19621
19885
  const technology = await this.getById(technologyId);
19622
19886
  if (!technology) {
19623
19887
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -19645,7 +19909,7 @@ var TechnologyService = class extends BaseService {
19645
19909
  * @returns Ažurirana tehnologija
19646
19910
  */
19647
19911
  async addBenefit(technologyId, benefit) {
19648
- const docRef = doc41(this.technologiesRef, technologyId);
19912
+ const docRef = doc42(this.technologiesRef, technologyId);
19649
19913
  const technology = await this.getById(technologyId);
19650
19914
  if (!technology) {
19651
19915
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -19667,7 +19931,7 @@ var TechnologyService = class extends BaseService {
19667
19931
  * @returns Ažurirana tehnologija
19668
19932
  */
19669
19933
  async removeBenefit(technologyId, benefit) {
19670
- const docRef = doc41(this.technologiesRef, technologyId);
19934
+ const docRef = doc42(this.technologiesRef, technologyId);
19671
19935
  const technology = await this.getById(technologyId);
19672
19936
  if (!technology) {
19673
19937
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -19687,7 +19951,7 @@ var TechnologyService = class extends BaseService {
19687
19951
  * @returns The updated technology
19688
19952
  */
19689
19953
  async updateBenefit(technologyId, benefit) {
19690
- const docRef = doc41(this.technologiesRef, technologyId);
19954
+ const docRef = doc42(this.technologiesRef, technologyId);
19691
19955
  const technology = await this.getById(technologyId);
19692
19956
  if (!technology) {
19693
19957
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -19742,7 +20006,7 @@ var TechnologyService = class extends BaseService {
19742
20006
  * @returns Ažurirana tehnologija
19743
20007
  */
19744
20008
  async updateCertificationRequirement(technologyId, certificationRequirement) {
19745
- const docRef = doc41(this.technologiesRef, technologyId);
20009
+ const docRef = doc42(this.technologiesRef, technologyId);
19746
20010
  await updateDoc38(docRef, {
19747
20011
  certificationRequirement,
19748
20012
  updatedAt: /* @__PURE__ */ new Date()
@@ -19844,9 +20108,9 @@ var TechnologyService = class extends BaseService {
19844
20108
  );
19845
20109
  const snapshot = await getDocs36(q);
19846
20110
  return snapshot.docs.map(
19847
- (doc44) => ({
19848
- id: doc44.id,
19849
- ...doc44.data()
20111
+ (doc45) => ({
20112
+ id: doc45.id,
20113
+ ...doc45.data()
19850
20114
  })
19851
20115
  );
19852
20116
  }
@@ -19865,9 +20129,9 @@ var TechnologyService = class extends BaseService {
19865
20129
  );
19866
20130
  const snapshot = await getDocs36(q);
19867
20131
  return snapshot.docs.map(
19868
- (doc44) => ({
19869
- id: doc44.id,
19870
- ...doc44.data()
20132
+ (doc45) => ({
20133
+ id: doc45.id,
20134
+ ...doc45.data()
19871
20135
  })
19872
20136
  );
19873
20137
  }
@@ -19882,9 +20146,9 @@ var TechnologyService = class extends BaseService {
19882
20146
  );
19883
20147
  const snapshot = await getDocs36(q);
19884
20148
  return snapshot.docs.map(
19885
- (doc44) => ({
19886
- id: doc44.id,
19887
- ...doc44.data()
20149
+ (doc45) => ({
20150
+ id: doc45.id,
20151
+ ...doc45.data()
19888
20152
  })
19889
20153
  );
19890
20154
  }
@@ -19898,7 +20162,7 @@ var TechnologyService = class extends BaseService {
19898
20162
  async assignProducts(technologyId, productIds) {
19899
20163
  const batch = writeBatch7(this.db);
19900
20164
  for (const productId of productIds) {
19901
- const productRef = doc41(this.db, PRODUCTS_COLLECTION, productId);
20165
+ const productRef = doc42(this.db, PRODUCTS_COLLECTION, productId);
19902
20166
  batch.update(productRef, {
19903
20167
  assignedTechnologyIds: arrayUnion9(technologyId),
19904
20168
  updatedAt: /* @__PURE__ */ new Date()
@@ -19913,7 +20177,7 @@ var TechnologyService = class extends BaseService {
19913
20177
  async unassignProducts(technologyId, productIds) {
19914
20178
  const batch = writeBatch7(this.db);
19915
20179
  for (const productId of productIds) {
19916
- const productRef = doc41(this.db, PRODUCTS_COLLECTION, productId);
20180
+ const productRef = doc42(this.db, PRODUCTS_COLLECTION, productId);
19917
20181
  batch.update(productRef, {
19918
20182
  assignedTechnologyIds: arrayRemove8(technologyId),
19919
20183
  updatedAt: /* @__PURE__ */ new Date()
@@ -19934,9 +20198,9 @@ var TechnologyService = class extends BaseService {
19934
20198
  );
19935
20199
  const snapshot = await getDocs36(q);
19936
20200
  return snapshot.docs.map(
19937
- (doc44) => ({
19938
- id: doc44.id,
19939
- ...doc44.data()
20201
+ (doc45) => ({
20202
+ id: doc45.id,
20203
+ ...doc45.data()
19940
20204
  })
19941
20205
  );
19942
20206
  }
@@ -19951,9 +20215,9 @@ var TechnologyService = class extends BaseService {
19951
20215
  );
19952
20216
  const snapshot = await getDocs36(q);
19953
20217
  const allProducts = snapshot.docs.map(
19954
- (doc44) => ({
19955
- id: doc44.id,
19956
- ...doc44.data()
20218
+ (doc45) => ({
20219
+ id: doc45.id,
20220
+ ...doc45.data()
19957
20221
  })
19958
20222
  );
19959
20223
  return allProducts.filter(
@@ -20070,8 +20334,8 @@ var TechnologyService = class extends BaseService {
20070
20334
  const productsRef = collection36(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
20071
20335
  const q = query36(productsRef, where36("isActive", "==", true));
20072
20336
  const snapshot = await getDocs36(q);
20073
- return snapshot.docs.map((doc44) => {
20074
- const product = doc44.data();
20337
+ return snapshot.docs.map((doc45) => {
20338
+ const product = doc45.data();
20075
20339
  return product.name || "";
20076
20340
  }).filter((name) => name);
20077
20341
  } catch (error) {
@@ -20114,8 +20378,8 @@ import {
20114
20378
  addDoc as addDoc8,
20115
20379
  collection as collection37,
20116
20380
  collectionGroup as collectionGroup3,
20117
- doc as doc42,
20118
- getDoc as getDoc43,
20381
+ doc as doc43,
20382
+ getDoc as getDoc44,
20119
20383
  getDocs as getDocs37,
20120
20384
  query as query37,
20121
20385
  updateDoc as updateDoc39,
@@ -20183,9 +20447,9 @@ var ProductService = class extends BaseService {
20183
20447
  const q = query37(collectionGroup3(this.db, PRODUCTS_COLLECTION), ...constraints);
20184
20448
  const snapshot = await getDocs37(q);
20185
20449
  const products = snapshot.docs.map(
20186
- (doc44) => ({
20187
- id: doc44.id,
20188
- ...doc44.data()
20450
+ (doc45) => ({
20451
+ id: doc45.id,
20452
+ ...doc45.data()
20189
20453
  })
20190
20454
  );
20191
20455
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -20222,8 +20486,8 @@ var ProductService = class extends BaseService {
20222
20486
  };
20223
20487
  const q = query37(collectionGroup3(this.db, PRODUCTS_COLLECTION), where37("isActive", "==", true));
20224
20488
  const snapshot = await getDocs37(q);
20225
- snapshot.docs.forEach((doc44) => {
20226
- const product = doc44.data();
20489
+ snapshot.docs.forEach((doc45) => {
20490
+ const product = doc45.data();
20227
20491
  if (product.categoryId) {
20228
20492
  counts.byCategory[product.categoryId] = (counts.byCategory[product.categoryId] || 0) + 1;
20229
20493
  }
@@ -20247,9 +20511,9 @@ var ProductService = class extends BaseService {
20247
20511
  );
20248
20512
  const snapshot = await getDocs37(q);
20249
20513
  return snapshot.docs.map(
20250
- (doc44) => ({
20251
- id: doc44.id,
20252
- ...doc44.data()
20514
+ (doc45) => ({
20515
+ id: doc45.id,
20516
+ ...doc45.data()
20253
20517
  })
20254
20518
  );
20255
20519
  }
@@ -20269,9 +20533,9 @@ var ProductService = class extends BaseService {
20269
20533
  const snapshot = await getDocs37(q);
20270
20534
  products.push(
20271
20535
  ...snapshot.docs.map(
20272
- (doc44) => ({
20273
- id: doc44.id,
20274
- ...doc44.data()
20536
+ (doc45) => ({
20537
+ id: doc45.id,
20538
+ ...doc45.data()
20275
20539
  })
20276
20540
  )
20277
20541
  );
@@ -20286,7 +20550,7 @@ var ProductService = class extends BaseService {
20286
20550
  ...product,
20287
20551
  updatedAt: /* @__PURE__ */ new Date()
20288
20552
  };
20289
- const docRef = doc42(this.getProductsRef(technologyId), productId);
20553
+ const docRef = doc43(this.getProductsRef(technologyId), productId);
20290
20554
  await updateDoc39(docRef, updateData);
20291
20555
  return this.getById(technologyId, productId);
20292
20556
  }
@@ -20302,8 +20566,8 @@ var ProductService = class extends BaseService {
20302
20566
  * Gets a product by ID
20303
20567
  */
20304
20568
  async getById(technologyId, productId) {
20305
- const docRef = doc42(this.getProductsRef(technologyId), productId);
20306
- const docSnap = await getDoc43(docRef);
20569
+ const docRef = doc43(this.getProductsRef(technologyId), productId);
20570
+ const docSnap = await getDoc44(docRef);
20307
20571
  if (!docSnap.exists()) return null;
20308
20572
  return {
20309
20573
  id: docSnap.id,
@@ -20345,9 +20609,9 @@ var ProductService = class extends BaseService {
20345
20609
  const q = query37(this.getTopLevelProductsRef(), ...constraints);
20346
20610
  const snapshot = await getDocs37(q);
20347
20611
  const products = snapshot.docs.map(
20348
- (doc44) => ({
20349
- id: doc44.id,
20350
- ...doc44.data()
20612
+ (doc45) => ({
20613
+ id: doc45.id,
20614
+ ...doc45.data()
20351
20615
  })
20352
20616
  );
20353
20617
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -20357,8 +20621,8 @@ var ProductService = class extends BaseService {
20357
20621
  * Gets a product by ID from the top-level collection
20358
20622
  */
20359
20623
  async getByIdTopLevel(productId) {
20360
- const docRef = doc42(this.getTopLevelProductsRef(), productId);
20361
- const docSnap = await getDoc43(docRef);
20624
+ const docRef = doc43(this.getTopLevelProductsRef(), productId);
20625
+ const docSnap = await getDoc44(docRef);
20362
20626
  if (!docSnap.exists()) return null;
20363
20627
  return {
20364
20628
  id: docSnap.id,
@@ -20373,7 +20637,7 @@ var ProductService = class extends BaseService {
20373
20637
  ...product,
20374
20638
  updatedAt: /* @__PURE__ */ new Date()
20375
20639
  };
20376
- const docRef = doc42(this.getTopLevelProductsRef(), productId);
20640
+ const docRef = doc43(this.getTopLevelProductsRef(), productId);
20377
20641
  await updateDoc39(docRef, updateData);
20378
20642
  return this.getByIdTopLevel(productId);
20379
20643
  }
@@ -20389,7 +20653,7 @@ var ProductService = class extends BaseService {
20389
20653
  * Assigns a product to a technology
20390
20654
  */
20391
20655
  async assignToTechnology(productId, technologyId) {
20392
- const docRef = doc42(this.getTopLevelProductsRef(), productId);
20656
+ const docRef = doc43(this.getTopLevelProductsRef(), productId);
20393
20657
  await updateDoc39(docRef, {
20394
20658
  assignedTechnologyIds: arrayUnion10(technologyId),
20395
20659
  updatedAt: /* @__PURE__ */ new Date()
@@ -20399,7 +20663,7 @@ var ProductService = class extends BaseService {
20399
20663
  * Unassigns a product from a technology
20400
20664
  */
20401
20665
  async unassignFromTechnology(productId, technologyId) {
20402
- const docRef = doc42(this.getTopLevelProductsRef(), productId);
20666
+ const docRef = doc43(this.getTopLevelProductsRef(), productId);
20403
20667
  await updateDoc39(docRef, {
20404
20668
  assignedTechnologyIds: arrayRemove9(technologyId),
20405
20669
  updatedAt: /* @__PURE__ */ new Date()
@@ -20417,9 +20681,9 @@ var ProductService = class extends BaseService {
20417
20681
  );
20418
20682
  const snapshot = await getDocs37(q);
20419
20683
  return snapshot.docs.map(
20420
- (doc44) => ({
20421
- id: doc44.id,
20422
- ...doc44.data()
20684
+ (doc45) => ({
20685
+ id: doc45.id,
20686
+ ...doc45.data()
20423
20687
  })
20424
20688
  );
20425
20689
  }
@@ -20434,9 +20698,9 @@ var ProductService = class extends BaseService {
20434
20698
  );
20435
20699
  const snapshot = await getDocs37(q);
20436
20700
  const allProducts = snapshot.docs.map(
20437
- (doc44) => ({
20438
- id: doc44.id,
20439
- ...doc44.data()
20701
+ (doc45) => ({
20702
+ id: doc45.id,
20703
+ ...doc45.data()
20440
20704
  })
20441
20705
  );
20442
20706
  return allProducts.filter(
@@ -20458,9 +20722,9 @@ var ProductService = class extends BaseService {
20458
20722
  );
20459
20723
  const snapshot = await getDocs37(q);
20460
20724
  return snapshot.docs.map(
20461
- (doc44) => ({
20462
- id: doc44.id,
20463
- ...doc44.data()
20725
+ (doc45) => ({
20726
+ id: doc45.id,
20727
+ ...doc45.data()
20464
20728
  })
20465
20729
  );
20466
20730
  }
@@ -20551,8 +20815,8 @@ var ProductService = class extends BaseService {
20551
20815
  import {
20552
20816
  arrayRemove as arrayRemove10,
20553
20817
  arrayUnion as arrayUnion11,
20554
- doc as doc43,
20555
- getDoc as getDoc44,
20818
+ doc as doc44,
20819
+ getDoc as getDoc45,
20556
20820
  setDoc as setDoc30,
20557
20821
  updateDoc as updateDoc40
20558
20822
  } from "firebase/firestore";
@@ -20566,7 +20830,7 @@ var ConstantsService = class extends BaseService {
20566
20830
  * @type {DocumentReference}
20567
20831
  */
20568
20832
  get treatmentBenefitsDocRef() {
20569
- return doc43(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
20833
+ return doc44(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
20570
20834
  }
20571
20835
  /**
20572
20836
  * @description Gets the reference to the document holding contraindications.
@@ -20574,7 +20838,7 @@ var ConstantsService = class extends BaseService {
20574
20838
  * @type {DocumentReference}
20575
20839
  */
20576
20840
  get contraindicationsDocRef() {
20577
- return doc43(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
20841
+ return doc44(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
20578
20842
  }
20579
20843
  // =================================================================
20580
20844
  // Treatment Benefits
@@ -20584,7 +20848,7 @@ var ConstantsService = class extends BaseService {
20584
20848
  * @returns {Promise<TreatmentBenefitDynamic[]>} An array of all treatment benefits.
20585
20849
  */
20586
20850
  async getAllBenefitsForFilter() {
20587
- const docSnap = await getDoc44(this.treatmentBenefitsDocRef);
20851
+ const docSnap = await getDoc45(this.treatmentBenefitsDocRef);
20588
20852
  if (!docSnap.exists()) {
20589
20853
  return [];
20590
20854
  }
@@ -20613,7 +20877,7 @@ var ConstantsService = class extends BaseService {
20613
20877
  id: this.generateId(),
20614
20878
  ...benefit
20615
20879
  };
20616
- const docSnap = await getDoc44(this.treatmentBenefitsDocRef);
20880
+ const docSnap = await getDoc45(this.treatmentBenefitsDocRef);
20617
20881
  if (!docSnap.exists()) {
20618
20882
  await setDoc30(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
20619
20883
  } else {
@@ -20683,7 +20947,7 @@ var ConstantsService = class extends BaseService {
20683
20947
  * @returns {Promise<ContraindicationDynamic[]>} An array of all contraindications.
20684
20948
  */
20685
20949
  async getAllContraindicationsForFilter() {
20686
- const docSnap = await getDoc44(this.contraindicationsDocRef);
20950
+ const docSnap = await getDoc45(this.contraindicationsDocRef);
20687
20951
  if (!docSnap.exists()) {
20688
20952
  return [];
20689
20953
  }
@@ -20718,7 +20982,7 @@ var ConstantsService = class extends BaseService {
20718
20982
  id: this.generateId(),
20719
20983
  ...contraindication
20720
20984
  };
20721
- const docSnap = await getDoc44(this.contraindicationsDocRef);
20985
+ const docSnap = await getDoc45(this.contraindicationsDocRef);
20722
20986
  if (!docSnap.exists()) {
20723
20987
  await setDoc30(this.contraindicationsDocRef, {
20724
20988
  contraindications: [newContraindication]