@blackcode_sa/metaestetics-api 1.14.50 → 1.14.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4839,10 +4839,49 @@ async function updateSubzonesUtil(db, appointmentId, zoneId, itemIndex, subzones
4839
4839
  }
4840
4840
 
4841
4841
  // src/services/appointment/utils/extended-procedure.utils.ts
4842
- import { updateDoc as updateDoc4, serverTimestamp as serverTimestamp4, doc as doc7, getDoc as getDoc7 } from "firebase/firestore";
4842
+ import { updateDoc as updateDoc5, serverTimestamp as serverTimestamp4, doc as doc7, getDoc as getDoc7 } from "firebase/firestore";
4843
4843
 
4844
4844
  // src/services/appointment/utils/form-initialization.utils.ts
4845
- import { collection as collection5, doc as doc6, addDoc, deleteDoc as deleteDoc2, getDocs as getDocs5, query as query5, where as where5, serverTimestamp as serverTimestamp3, getDoc as getDoc6 } from "firebase/firestore";
4845
+ import { collection as collection5, doc as doc6, addDoc, deleteDoc as deleteDoc2, getDocs as getDocs5, query as query5, where as where5, serverTimestamp as serverTimestamp3, getDoc as getDoc6, updateDoc as updateDoc4 } from "firebase/firestore";
4846
+ function isProcedureSpecificForm(template) {
4847
+ const tags = template.tags || [];
4848
+ const titleLower = template.title.toLowerCase();
4849
+ if (tags.includes("procedure-specific")) {
4850
+ return true;
4851
+ }
4852
+ if (tags.includes("shared")) {
4853
+ return false;
4854
+ }
4855
+ if (tags.some((tag) => {
4856
+ const tagLower = tag.toLowerCase();
4857
+ return tagLower.includes("consent") || tagLower === "consent-form";
4858
+ })) {
4859
+ return true;
4860
+ }
4861
+ if (titleLower.includes("consent")) {
4862
+ return true;
4863
+ }
4864
+ return false;
4865
+ }
4866
+ async function findExistingFormByTemplate(db, appointmentId, templateId, isUserForm) {
4867
+ const formSubcollection = isUserForm ? USER_FORMS_SUBCOLLECTION : DOCTOR_FORMS_SUBCOLLECTION;
4868
+ const appointmentRef = doc6(db, APPOINTMENTS_COLLECTION, appointmentId);
4869
+ const formsCollectionRef = collection5(appointmentRef, formSubcollection);
4870
+ const q = query5(
4871
+ formsCollectionRef,
4872
+ where5("templateId", "==", templateId)
4873
+ );
4874
+ const querySnapshot = await getDocs5(q);
4875
+ if (querySnapshot.empty) {
4876
+ return null;
4877
+ }
4878
+ const docSnap = querySnapshot.docs[0];
4879
+ const data = docSnap.data();
4880
+ if (!data.id) {
4881
+ data.id = docSnap.id;
4882
+ }
4883
+ return data;
4884
+ }
4846
4885
  async function initializeFormsForExtendedProcedure(db, appointmentId, procedureId, technologyTemplates, patientId, practitionerId, clinicId) {
4847
4886
  const initializedFormsInfo = [];
4848
4887
  const pendingUserFormsIds = [];
@@ -4885,6 +4924,49 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
4885
4924
  const isRequired = templateRef.isRequired;
4886
4925
  const isUserForm = templateRef.isUserForm || false;
4887
4926
  const formSubcollectionPath = isUserForm ? USER_FORMS_SUBCOLLECTION : DOCTOR_FORMS_SUBCOLLECTION;
4927
+ const isProcedureSpecific = isProcedureSpecificForm(template);
4928
+ let existingForm = null;
4929
+ if (!isProcedureSpecific) {
4930
+ try {
4931
+ existingForm = await findExistingFormByTemplate(
4932
+ db,
4933
+ appointmentId,
4934
+ templateRef.templateId,
4935
+ isUserForm
4936
+ );
4937
+ if (existingForm) {
4938
+ console.log(
4939
+ `[FormInit] Found existing shared form ${existingForm.id} (template: ${template.id}) for appointment ${appointmentId}. Reusing instead of creating duplicate.`
4940
+ );
4941
+ const linkedForm = {
4942
+ formId: existingForm.id,
4943
+ templateId: template.id,
4944
+ templateVersion: template.version,
4945
+ title: template.title,
4946
+ isUserForm,
4947
+ isRequired,
4948
+ sortingOrder: templateRef.sortingOrder,
4949
+ status: existingForm.status || "pending" /* PENDING */,
4950
+ path: `${APPOINTMENTS_COLLECTION}/${appointmentId}/${formSubcollectionPath}/${existingForm.id}`
4951
+ };
4952
+ initializedFormsInfo.push(linkedForm);
4953
+ if (!allLinkedFormIds.includes(existingForm.id)) {
4954
+ allLinkedFormIds.push(existingForm.id);
4955
+ }
4956
+ if (isUserForm && isRequired && existingForm.status === "pending" /* PENDING */) {
4957
+ if (!pendingUserFormsIds.includes(existingForm.id)) {
4958
+ pendingUserFormsIds.push(existingForm.id);
4959
+ }
4960
+ }
4961
+ continue;
4962
+ }
4963
+ } catch (error) {
4964
+ console.warn(
4965
+ `[FormInit] Error checking for existing form (template: ${templateRef.templateId}):`,
4966
+ error
4967
+ );
4968
+ }
4969
+ }
4888
4970
  const appointmentRef = doc6(db, APPOINTMENTS_COLLECTION, appointmentId);
4889
4971
  const formsCollectionRef = collection5(appointmentRef, formSubcollectionPath);
4890
4972
  const filledDocumentData = {
@@ -4905,6 +4987,7 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
4905
4987
  try {
4906
4988
  const docRef = await addDoc(formsCollectionRef, filledDocumentData);
4907
4989
  const filledDocumentId = docRef.id;
4990
+ await updateDoc4(docRef, { id: filledDocumentId });
4908
4991
  if (isUserForm && isRequired) {
4909
4992
  pendingUserFormsIds.push(filledDocumentId);
4910
4993
  }
@@ -4921,8 +5004,9 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
4921
5004
  path: docRef.path
4922
5005
  };
4923
5006
  initializedFormsInfo.push(linkedForm);
5007
+ const formType = isProcedureSpecific ? "procedure-specific" : "general/shared";
4924
5008
  console.log(
4925
- `[FormInit] Created FilledDocument ${filledDocumentId} (template: ${template.id}, isUserForm: ${isUserForm}) for extended procedure ${procedureId} in appointment ${appointmentId}.`
5009
+ `[FormInit] Created ${formType} FilledDocument ${filledDocumentId} (template: ${template.id}, isUserForm: ${isUserForm}) for extended procedure ${procedureId} in appointment ${appointmentId}.`
4926
5010
  );
4927
5011
  } catch (error) {
4928
5012
  console.error(
@@ -4934,8 +5018,28 @@ async function initializeFormsForExtendedProcedure(db, appointmentId, procedureI
4934
5018
  return { initializedFormsInfo, pendingUserFormsIds, allLinkedFormIds };
4935
5019
  }
4936
5020
  async function removeFormsForExtendedProcedure(db, appointmentId, procedureId) {
5021
+ var _a, _b;
4937
5022
  const removedFormIds = [];
4938
5023
  const appointmentRef = doc6(db, APPOINTMENTS_COLLECTION, appointmentId);
5024
+ const appointmentSnap = await getDoc6(appointmentRef);
5025
+ if (!appointmentSnap.exists()) {
5026
+ console.warn(
5027
+ `[FormInit] Appointment ${appointmentId} not found when removing forms for procedure ${procedureId}.`
5028
+ );
5029
+ return removedFormIds;
5030
+ }
5031
+ const appointment = appointmentSnap.data();
5032
+ const linkedForms = appointment.linkedForms || [];
5033
+ const mainProcedureId = appointment.procedureId;
5034
+ const extendedProcedureIds = ((_b = (_a = appointment.metadata) == null ? void 0 : _a.extendedProcedures) == null ? void 0 : _b.map(
5035
+ (ep) => ep.procedureId
5036
+ )) || [];
5037
+ const allProcedureIds = [mainProcedureId, ...extendedProcedureIds].filter(Boolean);
5038
+ const remainingProcedureIds = allProcedureIds.filter((id) => id !== procedureId);
5039
+ const isFormSharedAndReferenced = (formId) => {
5040
+ const formEntries = linkedForms.filter((form) => form.formId === formId);
5041
+ return formEntries.length > 1;
5042
+ };
4939
5043
  const doctorFormsRef = collection5(appointmentRef, DOCTOR_FORMS_SUBCOLLECTION);
4940
5044
  const doctorFormsQuery = query5(
4941
5045
  doctorFormsRef,
@@ -4944,11 +5048,42 @@ async function removeFormsForExtendedProcedure(db, appointmentId, procedureId) {
4944
5048
  const doctorFormsSnap = await getDocs5(doctorFormsQuery);
4945
5049
  for (const formDoc of doctorFormsSnap.docs) {
4946
5050
  try {
4947
- await deleteDoc2(formDoc.ref);
4948
- removedFormIds.push(formDoc.id);
4949
- console.log(
4950
- `[FormInit] Removed doctor form ${formDoc.id} for extended procedure ${procedureId} from appointment ${appointmentId}.`
4951
- );
5051
+ const formData = formDoc.data();
5052
+ let isShared = false;
5053
+ if (formData.templateId) {
5054
+ try {
5055
+ const templateDoc = doc6(db, DOCUMENTATION_TEMPLATES_COLLECTION, formData.templateId);
5056
+ const templateSnap = await getDoc6(templateDoc);
5057
+ if (templateSnap.exists()) {
5058
+ const template = templateSnap.data();
5059
+ isShared = !isProcedureSpecificForm(template);
5060
+ }
5061
+ } catch (error) {
5062
+ console.warn(
5063
+ `[FormInit] Could not check template for form ${formDoc.id}, assuming procedure-specific:`,
5064
+ error
5065
+ );
5066
+ }
5067
+ }
5068
+ if (!isShared) {
5069
+ await deleteDoc2(formDoc.ref);
5070
+ removedFormIds.push(formDoc.id);
5071
+ console.log(
5072
+ `[FormInit] Removed procedure-specific doctor form ${formDoc.id} for extended procedure ${procedureId} from appointment ${appointmentId}.`
5073
+ );
5074
+ } else {
5075
+ if (isFormSharedAndReferenced(formDoc.id)) {
5076
+ console.log(
5077
+ `[FormInit] Skipped deletion of shared doctor form ${formDoc.id} - still referenced by other procedures.`
5078
+ );
5079
+ } else {
5080
+ await deleteDoc2(formDoc.ref);
5081
+ removedFormIds.push(formDoc.id);
5082
+ console.log(
5083
+ `[FormInit] Removed shared doctor form ${formDoc.id} - no longer referenced by other procedures.`
5084
+ );
5085
+ }
5086
+ }
4952
5087
  } catch (error) {
4953
5088
  console.error(
4954
5089
  `[FormInit] Error removing doctor form ${formDoc.id}:`,
@@ -4964,11 +5099,42 @@ async function removeFormsForExtendedProcedure(db, appointmentId, procedureId) {
4964
5099
  const userFormsSnap = await getDocs5(userFormsQuery);
4965
5100
  for (const formDoc of userFormsSnap.docs) {
4966
5101
  try {
4967
- await deleteDoc2(formDoc.ref);
4968
- removedFormIds.push(formDoc.id);
4969
- console.log(
4970
- `[FormInit] Removed user form ${formDoc.id} for extended procedure ${procedureId} from appointment ${appointmentId}.`
4971
- );
5102
+ const formData = formDoc.data();
5103
+ let isShared = false;
5104
+ if (formData.templateId) {
5105
+ try {
5106
+ const templateDoc = doc6(db, DOCUMENTATION_TEMPLATES_COLLECTION, formData.templateId);
5107
+ const templateSnap = await getDoc6(templateDoc);
5108
+ if (templateSnap.exists()) {
5109
+ const template = templateSnap.data();
5110
+ isShared = !isProcedureSpecificForm(template);
5111
+ }
5112
+ } catch (error) {
5113
+ console.warn(
5114
+ `[FormInit] Could not check template for form ${formDoc.id}, assuming procedure-specific:`,
5115
+ error
5116
+ );
5117
+ }
5118
+ }
5119
+ if (!isShared) {
5120
+ await deleteDoc2(formDoc.ref);
5121
+ removedFormIds.push(formDoc.id);
5122
+ console.log(
5123
+ `[FormInit] Removed procedure-specific user form ${formDoc.id} for extended procedure ${procedureId} from appointment ${appointmentId}.`
5124
+ );
5125
+ } else {
5126
+ if (isFormSharedAndReferenced(formDoc.id)) {
5127
+ console.log(
5128
+ `[FormInit] Skipped deletion of shared user form ${formDoc.id} - still referenced by other procedures.`
5129
+ );
5130
+ } else {
5131
+ await deleteDoc2(formDoc.ref);
5132
+ removedFormIds.push(formDoc.id);
5133
+ console.log(
5134
+ `[FormInit] Removed shared user form ${formDoc.id} - no longer referenced by other procedures.`
5135
+ );
5136
+ }
5137
+ }
4972
5138
  } catch (error) {
4973
5139
  console.error(
4974
5140
  `[FormInit] Error removing user form ${formDoc.id}:`,
@@ -5095,7 +5261,7 @@ async function addExtendedProcedureUtil(db, appointmentId, procedureId) {
5095
5261
  }
5096
5262
  const extendedProcedures = [...metadata.extendedProcedures || [], extendedProcedureInfo];
5097
5263
  const appointmentRef = doc7(db, APPOINTMENTS_COLLECTION, appointmentId);
5098
- await updateDoc4(appointmentRef, {
5264
+ await updateDoc5(appointmentRef, {
5099
5265
  "metadata.extendedProcedures": extendedProcedures,
5100
5266
  "metadata.appointmentProducts": updatedProducts,
5101
5267
  linkedFormIds: updatedLinkedFormIds,
@@ -5144,7 +5310,7 @@ async function removeExtendedProcedureUtil(db, appointmentId, procedureId) {
5144
5310
  (formId) => !removedFormIds.includes(formId)
5145
5311
  );
5146
5312
  const appointmentRef = doc7(db, APPOINTMENTS_COLLECTION, appointmentId);
5147
- await updateDoc4(appointmentRef, {
5313
+ await updateDoc5(appointmentRef, {
5148
5314
  "metadata.extendedProcedures": metadata.extendedProcedures,
5149
5315
  "metadata.appointmentProducts": updatedProducts,
5150
5316
  "metadata.zonesData": updatedZonesData,
@@ -5167,7 +5333,7 @@ async function getAppointmentProductsUtil(db, appointmentId) {
5167
5333
  }
5168
5334
 
5169
5335
  // src/services/appointment/utils/recommended-procedure.utils.ts
5170
- import { updateDoc as updateDoc5, serverTimestamp as serverTimestamp5, doc as doc8 } from "firebase/firestore";
5336
+ import { updateDoc as updateDoc6, serverTimestamp as serverTimestamp5, doc as doc8 } from "firebase/firestore";
5171
5337
  import { getDoc as getDoc8 } from "firebase/firestore";
5172
5338
  async function createExtendedProcedureInfoForRecommended(db, procedureId) {
5173
5339
  const procedureRef = doc8(db, PROCEDURES_COLLECTION, procedureId);
@@ -5205,7 +5371,7 @@ async function addRecommendedProcedureUtil(db, appointmentId, procedureId, note,
5205
5371
  };
5206
5372
  const recommendedProcedures = [...metadata.recommendedProcedures || [], recommendedProcedure];
5207
5373
  const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
5208
- await updateDoc5(appointmentRef, {
5374
+ await updateDoc6(appointmentRef, {
5209
5375
  "metadata.recommendedProcedures": recommendedProcedures,
5210
5376
  updatedAt: serverTimestamp5()
5211
5377
  });
@@ -5223,7 +5389,7 @@ async function removeRecommendedProcedureUtil(db, appointmentId, recommendationI
5223
5389
  const updatedRecommendedProcedures = [...metadata.recommendedProcedures];
5224
5390
  updatedRecommendedProcedures.splice(recommendationIndex, 1);
5225
5391
  const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
5226
- await updateDoc5(appointmentRef, {
5392
+ await updateDoc6(appointmentRef, {
5227
5393
  "metadata.recommendedProcedures": updatedRecommendedProcedures,
5228
5394
  updatedAt: serverTimestamp5()
5229
5395
  });
@@ -5246,7 +5412,7 @@ async function updateRecommendedProcedureUtil(db, appointmentId, recommendationI
5246
5412
  ...updates.timeframe !== void 0 && { timeframe: updates.timeframe }
5247
5413
  };
5248
5414
  const appointmentRef = doc8(db, APPOINTMENTS_COLLECTION, appointmentId);
5249
- await updateDoc5(appointmentRef, {
5415
+ await updateDoc6(appointmentRef, {
5250
5416
  "metadata.recommendedProcedures": updatedRecommendedProcedures,
5251
5417
  updatedAt: serverTimestamp5()
5252
5418
  });
@@ -5259,7 +5425,7 @@ async function getRecommendedProceduresUtil(db, appointmentId) {
5259
5425
  }
5260
5426
 
5261
5427
  // src/services/appointment/utils/zone-photo.utils.ts
5262
- import { updateDoc as updateDoc6, serverTimestamp as serverTimestamp6, doc as doc9, Timestamp as Timestamp6 } from "firebase/firestore";
5428
+ import { updateDoc as updateDoc7, serverTimestamp as serverTimestamp6, doc as doc9, Timestamp as Timestamp6 } from "firebase/firestore";
5263
5429
  function addVisibilityAudit(updates, doctorId) {
5264
5430
  if (updates.showToPatient !== void 0 || updates.beforeNoteVisibleToPatient !== void 0 || updates.afterNoteVisibleToPatient !== void 0) {
5265
5431
  return {
@@ -5290,7 +5456,7 @@ async function updateZonePhotoEntryUtil(db, appointmentId, zoneId, photoIndex, u
5290
5456
  ...updatesWithAudit
5291
5457
  };
5292
5458
  const appointmentRef = doc9(db, APPOINTMENTS_COLLECTION, appointmentId);
5293
- await updateDoc6(appointmentRef, {
5459
+ await updateDoc7(appointmentRef, {
5294
5460
  "metadata.zonePhotos": updatedZonePhotos,
5295
5461
  updatedAt: serverTimestamp6()
5296
5462
  });
@@ -7758,7 +7924,7 @@ import {
7758
7924
  getDocs as getDocs14,
7759
7925
  query as query14,
7760
7926
  where as where14,
7761
- updateDoc as updateDoc17,
7927
+ updateDoc as updateDoc18,
7762
7928
  deleteDoc as deleteDoc5,
7763
7929
  Timestamp as Timestamp19,
7764
7930
  setDoc as setDoc12,
@@ -7865,7 +8031,7 @@ import {
7865
8031
  doc as doc19,
7866
8032
  getDoc as getDoc21,
7867
8033
  writeBatch,
7868
- updateDoc as updateDoc15,
8034
+ updateDoc as updateDoc16,
7869
8035
  serverTimestamp as serverTimestamp16
7870
8036
  } from "firebase/firestore";
7871
8037
  import { Timestamp as Timestamp16 } from "firebase/firestore";
@@ -7893,7 +8059,7 @@ import {
7893
8059
  } from "firebase/firestore";
7894
8060
 
7895
8061
  // src/services/patient/utils/sensitive.utils.ts
7896
- import { getDoc as getDoc12, updateDoc as updateDoc8, setDoc as setDoc4, serverTimestamp as serverTimestamp9 } from "firebase/firestore";
8062
+ import { getDoc as getDoc12, updateDoc as updateDoc9, setDoc as setDoc4, serverTimestamp as serverTimestamp9 } from "firebase/firestore";
7897
8063
 
7898
8064
  // src/validations/patient.schema.ts
7899
8065
  import { z as z7 } from "zod";
@@ -8363,7 +8529,7 @@ import {
8363
8529
  getDocs as getDocs8,
8364
8530
  query as query8,
8365
8531
  where as where8,
8366
- updateDoc as updateDoc7,
8532
+ updateDoc as updateDoc8,
8367
8533
  setDoc as setDoc3,
8368
8534
  deleteDoc as deleteDoc3,
8369
8535
  Timestamp as Timestamp11,
@@ -9098,7 +9264,7 @@ async function updateClinicAdmin(db, adminId, data) {
9098
9264
  ...data,
9099
9265
  updatedAt: serverTimestamp8()
9100
9266
  };
9101
- await updateDoc7(doc12(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
9267
+ await updateDoc8(doc12(db, CLINIC_ADMINS_COLLECTION, adminId), updatedData);
9102
9268
  const updatedAdmin = await getClinicAdmin(db, adminId);
9103
9269
  if (!updatedAdmin) {
9104
9270
  throw new Error("Failed to retrieve updated admin");
@@ -9340,7 +9506,7 @@ var updateSensitiveInfoUtil = async (db, patientId, data, requesterId, requester
9340
9506
  photoUrl: processedPhotoUrl,
9341
9507
  updatedAt: serverTimestamp9()
9342
9508
  };
9343
- await updateDoc8(getSensitiveInfoDocRef(db, patientId), updateData);
9509
+ await updateDoc9(getSensitiveInfoDocRef(db, patientId), updateData);
9344
9510
  const updatedDoc = await getDoc12(getSensitiveInfoDocRef(db, patientId));
9345
9511
  if (!updatedDoc.exists()) {
9346
9512
  throw new Error("Failed to retrieve updated sensitive information");
@@ -9367,7 +9533,7 @@ var claimPatientSensitiveInfoUtil = async (db, patientId, userId) => {
9367
9533
  if (sensitiveData.userRef) {
9368
9534
  throw new Error("Patient sensitive information has already been claimed");
9369
9535
  }
9370
- await updateDoc8(getSensitiveInfoDocRef(db, patientId), {
9536
+ await updateDoc9(getSensitiveInfoDocRef(db, patientId), {
9371
9537
  userRef: userId,
9372
9538
  updatedAt: serverTimestamp9()
9373
9539
  });
@@ -9565,7 +9731,7 @@ var getPatientsByClinicWithDetailsUtil = async (db, clinicId, options) => {
9565
9731
  // src/services/patient/utils/location.utils.ts
9566
9732
  import {
9567
9733
  getDoc as getDoc15,
9568
- updateDoc as updateDoc9,
9734
+ updateDoc as updateDoc10,
9569
9735
  setDoc as setDoc6,
9570
9736
  serverTimestamp as serverTimestamp11
9571
9737
  } from "firebase/firestore";
@@ -9581,7 +9747,7 @@ var updatePatientLocationUtil = async (db, patientId, latitude, longitude) => {
9581
9747
  locationData,
9582
9748
  updatedAt: serverTimestamp11()
9583
9749
  };
9584
- await updateDoc9(getLocationInfoDocRef(db, patientId), updateData);
9750
+ await updateDoc10(getLocationInfoDocRef(db, patientId), updateData);
9585
9751
  };
9586
9752
  var createLocationInfoUtil = async (db, data, requesterId) => {
9587
9753
  try {
@@ -9636,7 +9802,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
9636
9802
  };
9637
9803
  }
9638
9804
  updateData.updatedAt = serverTimestamp11();
9639
- await updateDoc9(getLocationInfoDocRef(db, patientId), updateData);
9805
+ await updateDoc10(getLocationInfoDocRef(db, patientId), updateData);
9640
9806
  const updatedInfo = await getLocationInfoUtil(db, patientId, requesterId);
9641
9807
  if (!updatedInfo) {
9642
9808
  throw new Error("Failed to retrieve updated location information");
@@ -9647,7 +9813,7 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
9647
9813
  // src/services/patient/utils/medical-stuff.utils.ts
9648
9814
  import {
9649
9815
  getDoc as getDoc16,
9650
- updateDoc as updateDoc10,
9816
+ updateDoc as updateDoc11,
9651
9817
  arrayUnion as arrayUnion2,
9652
9818
  arrayRemove as arrayRemove2,
9653
9819
  serverTimestamp as serverTimestamp12,
@@ -9683,7 +9849,7 @@ var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
9683
9849
  } else {
9684
9850
  updates.doctors = arrayUnion2(newDoctor);
9685
9851
  }
9686
- await updateDoc10(getPatientDocRef(db, patientId), updates);
9852
+ await updateDoc11(getPatientDocRef(db, patientId), updates);
9687
9853
  };
9688
9854
  var removeDoctorUtil = async (db, patientId, doctorRef) => {
9689
9855
  var _a;
@@ -9692,7 +9858,7 @@ var removeDoctorUtil = async (db, patientId, doctorRef) => {
9692
9858
  if (!patientDoc.exists()) throw new Error("Patient profile not found");
9693
9859
  const patientData = patientDoc.data();
9694
9860
  const updatedDoctors = ((_a = patientData.doctors) == null ? void 0 : _a.filter((doctor) => doctor.userRef !== doctorRef)) || [];
9695
- await updateDoc10(patientDocRef, {
9861
+ await updateDoc11(patientDocRef, {
9696
9862
  doctors: updatedDoctors,
9697
9863
  // Set the filtered array
9698
9864
  doctorIds: arrayRemove2(doctorRef),
@@ -9730,7 +9896,7 @@ var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
9730
9896
  } else {
9731
9897
  updates.clinics = arrayUnion2(newClinic);
9732
9898
  }
9733
- await updateDoc10(getPatientDocRef(db, patientId), updates);
9899
+ await updateDoc11(getPatientDocRef(db, patientId), updates);
9734
9900
  };
9735
9901
  var removeClinicUtil = async (db, patientId, clinicId) => {
9736
9902
  var _a;
@@ -9739,7 +9905,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
9739
9905
  if (!patientDoc.exists()) throw new Error("Patient profile not found");
9740
9906
  const patientData = patientDoc.data();
9741
9907
  const updatedClinics = ((_a = patientData.clinics) == null ? void 0 : _a.filter((clinic) => clinic.clinicId !== clinicId)) || [];
9742
- await updateDoc10(patientDocRef, {
9908
+ await updateDoc11(patientDocRef, {
9743
9909
  clinics: updatedClinics,
9744
9910
  // Set the filtered array
9745
9911
  clinicIds: arrayRemove2(clinicId),
@@ -9751,7 +9917,7 @@ var removeClinicUtil = async (db, patientId, clinicId) => {
9751
9917
  // src/services/patient/utils/medical.utils.ts
9752
9918
  import {
9753
9919
  getDoc as getDoc17,
9754
- updateDoc as updateDoc11,
9920
+ updateDoc as updateDoc12,
9755
9921
  setDoc as setDoc7,
9756
9922
  serverTimestamp as serverTimestamp13,
9757
9923
  arrayUnion as arrayUnion3
@@ -9834,7 +10000,7 @@ var updateVitalStatsUtil = async (db, patientId, data, requesterId, requesterRol
9834
10000
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
9835
10001
  await ensureMedicalInfoExists(db, patientId, requesterId);
9836
10002
  const validatedData = updateVitalStatsSchema.parse(data);
9837
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10003
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9838
10004
  vitalStats: validatedData,
9839
10005
  lastUpdated: serverTimestamp13(),
9840
10006
  updatedBy: requesterId
@@ -9844,7 +10010,7 @@ var addAllergyUtil = async (db, patientId, data, requesterId, requesterRoles) =>
9844
10010
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
9845
10011
  await ensureMedicalInfoExists(db, patientId, requesterId);
9846
10012
  const validatedData = addAllergySchema.parse(data);
9847
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10013
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9848
10014
  allergies: arrayUnion3(validatedData),
9849
10015
  lastUpdated: serverTimestamp13(),
9850
10016
  updatedBy: requesterId
@@ -9865,7 +10031,7 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
9865
10031
  ...updatedAllergies[allergyIndex],
9866
10032
  ...updateData
9867
10033
  };
9868
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10034
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9869
10035
  allergies: updatedAllergies,
9870
10036
  lastUpdated: serverTimestamp13(),
9871
10037
  updatedBy: requesterId
@@ -9882,7 +10048,7 @@ var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, request
9882
10048
  const updatedAllergies = medicalInfo.allergies.filter(
9883
10049
  (_, index) => index !== allergyIndex
9884
10050
  );
9885
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10051
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9886
10052
  allergies: updatedAllergies,
9887
10053
  lastUpdated: serverTimestamp13(),
9888
10054
  updatedBy: requesterId
@@ -9892,7 +10058,7 @@ var addBlockingConditionUtil = async (db, patientId, data, requesterId, requeste
9892
10058
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
9893
10059
  await ensureMedicalInfoExists(db, patientId, requesterId);
9894
10060
  const validatedData = addBlockingConditionSchema.parse(data);
9895
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10061
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9896
10062
  blockingConditions: arrayUnion3(validatedData),
9897
10063
  lastUpdated: serverTimestamp13(),
9898
10064
  updatedBy: requesterId
@@ -9913,7 +10079,7 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
9913
10079
  ...updatedConditions[conditionIndex],
9914
10080
  ...updateData
9915
10081
  };
9916
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10082
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9917
10083
  blockingConditions: updatedConditions,
9918
10084
  lastUpdated: serverTimestamp13(),
9919
10085
  updatedBy: requesterId
@@ -9930,7 +10096,7 @@ var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requeste
9930
10096
  const updatedConditions = medicalInfo.blockingConditions.filter(
9931
10097
  (_, index) => index !== conditionIndex
9932
10098
  );
9933
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10099
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9934
10100
  blockingConditions: updatedConditions,
9935
10101
  lastUpdated: serverTimestamp13(),
9936
10102
  updatedBy: requesterId
@@ -9940,7 +10106,7 @@ var addContraindicationUtil = async (db, patientId, data, requesterId, requester
9940
10106
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
9941
10107
  await ensureMedicalInfoExists(db, patientId, requesterId);
9942
10108
  const validatedData = addContraindicationSchema.parse(data);
9943
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10109
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9944
10110
  contraindications: arrayUnion3(validatedData),
9945
10111
  lastUpdated: serverTimestamp13(),
9946
10112
  updatedBy: requesterId
@@ -9961,7 +10127,7 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
9961
10127
  ...updatedContraindications[contraindicationIndex],
9962
10128
  ...updateData
9963
10129
  };
9964
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10130
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9965
10131
  contraindications: updatedContraindications,
9966
10132
  lastUpdated: serverTimestamp13(),
9967
10133
  updatedBy: requesterId
@@ -9978,7 +10144,7 @@ var removeContraindicationUtil = async (db, patientId, contraindicationIndex, re
9978
10144
  const updatedContraindications = medicalInfo.contraindications.filter(
9979
10145
  (_, index) => index !== contraindicationIndex
9980
10146
  );
9981
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10147
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9982
10148
  contraindications: updatedContraindications,
9983
10149
  lastUpdated: serverTimestamp13(),
9984
10150
  updatedBy: requesterId
@@ -9988,7 +10154,7 @@ var addMedicationUtil = async (db, patientId, data, requesterId, requesterRoles)
9988
10154
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
9989
10155
  await ensureMedicalInfoExists(db, patientId, requesterId);
9990
10156
  const validatedData = addMedicationSchema.parse(data);
9991
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10157
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
9992
10158
  currentMedications: arrayUnion3(validatedData),
9993
10159
  lastUpdated: serverTimestamp13(),
9994
10160
  updatedBy: requesterId
@@ -10009,7 +10175,7 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
10009
10175
  ...updatedMedications[medicationIndex],
10010
10176
  ...updateData
10011
10177
  };
10012
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10178
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
10013
10179
  currentMedications: updatedMedications,
10014
10180
  lastUpdated: serverTimestamp13(),
10015
10181
  updatedBy: requesterId
@@ -10026,7 +10192,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
10026
10192
  const updatedMedications = medicalInfo.currentMedications.filter(
10027
10193
  (_, index) => index !== medicationIndex
10028
10194
  );
10029
- await updateDoc11(getMedicalInfoDocRef(db, patientId), {
10195
+ await updateDoc12(getMedicalInfoDocRef(db, patientId), {
10030
10196
  currentMedications: updatedMedications,
10031
10197
  lastUpdated: serverTimestamp13(),
10032
10198
  updatedBy: requesterId
@@ -10037,7 +10203,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, r
10037
10203
  import {
10038
10204
  getDoc as getDoc18,
10039
10205
  setDoc as setDoc8,
10040
- updateDoc as updateDoc12,
10206
+ updateDoc as updateDoc13,
10041
10207
  arrayUnion as arrayUnion4,
10042
10208
  arrayRemove as arrayRemove4,
10043
10209
  serverTimestamp as serverTimestamp14,
@@ -10174,19 +10340,19 @@ var getPatientProfileByUserRefUtil = async (db, userRef) => {
10174
10340
  }
10175
10341
  };
10176
10342
  var addExpoTokenUtil = async (db, patientId, token) => {
10177
- await updateDoc12(getPatientDocRef(db, patientId), {
10343
+ await updateDoc13(getPatientDocRef(db, patientId), {
10178
10344
  expoTokens: arrayUnion4(token),
10179
10345
  updatedAt: serverTimestamp14()
10180
10346
  });
10181
10347
  };
10182
10348
  var removeExpoTokenUtil = async (db, patientId, token) => {
10183
- await updateDoc12(getPatientDocRef(db, patientId), {
10349
+ await updateDoc13(getPatientDocRef(db, patientId), {
10184
10350
  expoTokens: arrayRemove4(token),
10185
10351
  updatedAt: serverTimestamp14()
10186
10352
  });
10187
10353
  };
10188
10354
  var addPointsUtil = async (db, patientId, points) => {
10189
- await updateDoc12(getPatientDocRef(db, patientId), {
10355
+ await updateDoc13(getPatientDocRef(db, patientId), {
10190
10356
  "gamification.points": increment(points),
10191
10357
  updatedAt: serverTimestamp14()
10192
10358
  });
@@ -10197,7 +10363,7 @@ var updatePatientProfileUtil = async (db, patientId, data) => {
10197
10363
  ...data,
10198
10364
  updatedAt: serverTimestamp14()
10199
10365
  };
10200
- await updateDoc12(getPatientDocRef(db, patientId), updateData);
10366
+ await updateDoc13(getPatientDocRef(db, patientId), updateData);
10201
10367
  const updatedDoc = await getDoc18(getPatientDocRef(db, patientId));
10202
10368
  if (!updatedDoc.exists()) {
10203
10369
  throw new Error("Patient profile not found after update");
@@ -10376,7 +10542,7 @@ import {
10376
10542
  query as query12,
10377
10543
  where as where12,
10378
10544
  setDoc as setDoc9,
10379
- updateDoc as updateDoc13,
10545
+ updateDoc as updateDoc14,
10380
10546
  Timestamp as Timestamp15,
10381
10547
  collectionGroup
10382
10548
  } from "firebase/firestore";
@@ -10471,7 +10637,7 @@ var markPatientTokenAsUsedUtil = async (db, tokenId, patientId, userId) => {
10471
10637
  INVITE_TOKENS_COLLECTION,
10472
10638
  tokenId
10473
10639
  );
10474
- await updateDoc13(tokenRef, {
10640
+ await updateDoc14(tokenRef, {
10475
10641
  status: "used" /* USED */,
10476
10642
  usedBy: userId,
10477
10643
  usedAt: Timestamp15.now()
@@ -10510,7 +10676,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
10510
10676
  };
10511
10677
 
10512
10678
  // src/services/patient/utils/aesthetic-analysis.utils.ts
10513
- import { getDoc as getDoc20, updateDoc as updateDoc14, setDoc as setDoc10, serverTimestamp as serverTimestamp15, doc as doc18 } from "firebase/firestore";
10679
+ import { getDoc as getDoc20, updateDoc as updateDoc15, setDoc as setDoc10, serverTimestamp as serverTimestamp15, doc as doc18 } from "firebase/firestore";
10514
10680
 
10515
10681
  // src/validations/patient/aesthetic-analysis.schema.ts
10516
10682
  import { z as z15 } from "zod";
@@ -10665,7 +10831,7 @@ var createOrUpdateAestheticAnalysisUtil = async (db, patientId, data, requesterI
10665
10831
  updatedAt: serverTimestamp15()
10666
10832
  });
10667
10833
  } else {
10668
- await updateDoc14(docRef, {
10834
+ await updateDoc15(docRef, {
10669
10835
  ...validatedData,
10670
10836
  completionPercentage,
10671
10837
  status,
@@ -11011,7 +11177,7 @@ var PatientService = class extends BaseService {
11011
11177
  "patient_profile_photos",
11012
11178
  file instanceof File ? file.name : `profile_photo_${patientId}`
11013
11179
  );
11014
- await updateDoc15(getSensitiveInfoDocRef(this.db, patientId), {
11180
+ await updateDoc16(getSensitiveInfoDocRef(this.db, patientId), {
11015
11181
  photoUrl: mediaMetadata.url,
11016
11182
  updatedAt: serverTimestamp16()
11017
11183
  });
@@ -11066,7 +11232,7 @@ var PatientService = class extends BaseService {
11066
11232
  error
11067
11233
  );
11068
11234
  }
11069
- await updateDoc15(getSensitiveInfoDocRef(this.db, patientId), {
11235
+ await updateDoc16(getSensitiveInfoDocRef(this.db, patientId), {
11070
11236
  photoUrl: null,
11071
11237
  updatedAt: serverTimestamp16()
11072
11238
  });
@@ -11393,7 +11559,7 @@ import {
11393
11559
  getDocs as getDocs13,
11394
11560
  query as query13,
11395
11561
  where as where13,
11396
- updateDoc as updateDoc16,
11562
+ updateDoc as updateDoc17,
11397
11563
  setDoc as setDoc11,
11398
11564
  deleteDoc as deleteDoc4,
11399
11565
  Timestamp as Timestamp18,
@@ -11985,7 +12151,7 @@ var PractitionerService = class extends BaseService {
11985
12151
  this.db,
11986
12152
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
11987
12153
  );
11988
- await updateDoc16(tokenRef, {
12154
+ await updateDoc17(tokenRef, {
11989
12155
  status: "used" /* USED */,
11990
12156
  usedBy: userId,
11991
12157
  usedAt: Timestamp18.now()
@@ -12014,7 +12180,7 @@ var PractitionerService = class extends BaseService {
12014
12180
  if (tokenData.status !== "active" /* ACTIVE */) {
12015
12181
  throw new Error("Token is not active and cannot be revoked");
12016
12182
  }
12017
- await updateDoc16(tokenRef, {
12183
+ await updateDoc17(tokenRef, {
12018
12184
  status: "revoked" /* REVOKED */,
12019
12185
  updatedAt: serverTimestamp17()
12020
12186
  });
@@ -12412,7 +12578,7 @@ var PractitionerService = class extends BaseService {
12412
12578
  ...processedData,
12413
12579
  updatedAt: serverTimestamp17()
12414
12580
  };
12415
- await updateDoc16(practitionerRef, updateData);
12581
+ await updateDoc17(practitionerRef, updateData);
12416
12582
  const updatedPractitioner = await this.getPractitioner(practitionerId);
12417
12583
  if (!updatedPractitioner) {
12418
12584
  throw new Error(
@@ -12450,7 +12616,7 @@ var PractitionerService = class extends BaseService {
12450
12616
  );
12451
12617
  return;
12452
12618
  }
12453
- await updateDoc16(practitionerRef, {
12619
+ await updateDoc17(practitionerRef, {
12454
12620
  clinics: arrayUnion6(clinicId),
12455
12621
  updatedAt: serverTimestamp17()
12456
12622
  });
@@ -12476,7 +12642,7 @@ var PractitionerService = class extends BaseService {
12476
12642
  if (!practitionerDoc.exists()) {
12477
12643
  throw new Error(`Practitioner ${practitionerId} not found`);
12478
12644
  }
12479
- await updateDoc16(practitionerRef, {
12645
+ await updateDoc17(practitionerRef, {
12480
12646
  clinics: arrayRemove5(clinicId),
12481
12647
  updatedAt: serverTimestamp17()
12482
12648
  });
@@ -13293,7 +13459,7 @@ var UserService = class extends BaseService {
13293
13459
  return this.getUserById(userData.uid);
13294
13460
  }
13295
13461
  const profiles = await this.createProfilesForRoles(userData.uid, roles, options);
13296
- await updateDoc17(doc21(this.db, USERS_COLLECTION, userData.uid), profiles);
13462
+ await updateDoc18(doc21(this.db, USERS_COLLECTION, userData.uid), profiles);
13297
13463
  return this.getUserById(userData.uid);
13298
13464
  }
13299
13465
  /**
@@ -13460,7 +13626,7 @@ var UserService = class extends BaseService {
13460
13626
  if (!userDoc.exists()) {
13461
13627
  throw AUTH_ERRORS.USER_NOT_FOUND;
13462
13628
  }
13463
- await updateDoc17(userRef, {
13629
+ await updateDoc18(userRef, {
13464
13630
  lastLoginAt: serverTimestamp18(),
13465
13631
  updatedAt: serverTimestamp18()
13466
13632
  });
@@ -13472,7 +13638,7 @@ var UserService = class extends BaseService {
13472
13638
  if (!userDoc.exists()) {
13473
13639
  throw USER_ERRORS.NOT_FOUND;
13474
13640
  }
13475
- await updateDoc17(userRef, {
13641
+ await updateDoc18(userRef, {
13476
13642
  email,
13477
13643
  isAnonymous: false,
13478
13644
  updatedAt: serverTimestamp18()
@@ -13493,7 +13659,7 @@ var UserService = class extends BaseService {
13493
13659
  updatedAt: serverTimestamp18()
13494
13660
  };
13495
13661
  userSchema.parse(updatedUser);
13496
- await updateDoc17(userRef, {
13662
+ await updateDoc18(userRef, {
13497
13663
  ...updates,
13498
13664
  updatedAt: serverTimestamp18()
13499
13665
  });
@@ -13512,7 +13678,7 @@ var UserService = class extends BaseService {
13512
13678
  const user = await this.getUserById(uid);
13513
13679
  if (user.roles.includes(role)) return;
13514
13680
  const profiles = await this.createProfilesForRoles(uid, [role], options);
13515
- await updateDoc17(doc21(this.db, USERS_COLLECTION, uid), {
13681
+ await updateDoc18(doc21(this.db, USERS_COLLECTION, uid), {
13516
13682
  roles: [...user.roles, role],
13517
13683
  ...profiles,
13518
13684
  updatedAt: serverTimestamp18()
@@ -13541,7 +13707,7 @@ var UserService = class extends BaseService {
13541
13707
  }
13542
13708
  break;
13543
13709
  }
13544
- await updateDoc17(doc21(this.db, USERS_COLLECTION, uid), {
13710
+ await updateDoc18(doc21(this.db, USERS_COLLECTION, uid), {
13545
13711
  roles: user.roles.filter((r) => r !== role),
13546
13712
  updatedAt: serverTimestamp18()
13547
13713
  });
@@ -13567,7 +13733,7 @@ var UserService = class extends BaseService {
13567
13733
  } else {
13568
13734
  updateData.acquisitionSourceOther = null;
13569
13735
  }
13570
- await updateDoc17(userRef, updateData);
13736
+ await updateDoc18(userRef, updateData);
13571
13737
  }
13572
13738
  // Delete operations
13573
13739
  async deleteUser(uid) {
@@ -13745,7 +13911,7 @@ import {
13745
13911
  getDocs as getDocs16,
13746
13912
  query as query16,
13747
13913
  where as where16,
13748
- updateDoc as updateDoc18,
13914
+ updateDoc as updateDoc19,
13749
13915
  setDoc as setDoc13,
13750
13916
  Timestamp as Timestamp20
13751
13917
  } from "firebase/firestore";
@@ -14013,7 +14179,7 @@ async function updateClinicGroup(db, groupId, data, app) {
14013
14179
  updatedAt: Timestamp20.now()
14014
14180
  };
14015
14181
  console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
14016
- await updateDoc18(doc22(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
14182
+ await updateDoc19(doc22(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
14017
14183
  console.log("[CLINIC_GROUP] Clinic group updated successfully");
14018
14184
  const updatedGroup = await getClinicGroup(db, groupId);
14019
14185
  if (!updatedGroup) {
@@ -14398,7 +14564,7 @@ import {
14398
14564
  doc as doc24,
14399
14565
  getDoc as getDoc26,
14400
14566
  getDocs as getDocs20,
14401
- updateDoc as updateDoc20,
14567
+ updateDoc as updateDoc21,
14402
14568
  serverTimestamp as serverTimestamp20,
14403
14569
  writeBatch as writeBatch4,
14404
14570
  arrayUnion as arrayUnion7
@@ -14418,7 +14584,7 @@ import {
14418
14584
  getDocs as getDocs17,
14419
14585
  query as query17,
14420
14586
  where as where17,
14421
- updateDoc as updateDoc19,
14587
+ updateDoc as updateDoc20,
14422
14588
  setDoc as setDoc14,
14423
14589
  Timestamp as Timestamp21,
14424
14590
  limit as limit9,
@@ -14635,7 +14801,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
14635
14801
  };
14636
14802
  console.log("[CLINIC] Updating clinic in Firestore");
14637
14803
  try {
14638
- await updateDoc19(doc23(db, CLINICS_COLLECTION, clinicId), updatedData);
14804
+ await updateDoc20(doc23(db, CLINICS_COLLECTION, clinicId), updatedData);
14639
14805
  console.log("[CLINIC] Clinic updated successfully");
14640
14806
  } catch (updateError) {
14641
14807
  console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
@@ -15490,7 +15656,7 @@ var ClinicService = class extends BaseService {
15490
15656
  };
15491
15657
  }
15492
15658
  updatePayload.updatedAt = serverTimestamp20();
15493
- await updateDoc20(clinicRef, updatePayload);
15659
+ await updateDoc21(clinicRef, updatePayload);
15494
15660
  console.log(`[ClinicService] Clinic ${clinicId} updated successfully`);
15495
15661
  const updatedClinic = await this.getClinic(clinicId);
15496
15662
  if (!updatedClinic) throw new Error("Failed to retrieve updated clinic");
@@ -15508,7 +15674,7 @@ var ClinicService = class extends BaseService {
15508
15674
  */
15509
15675
  async deactivateClinic(clinicId, adminId) {
15510
15676
  const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
15511
- await updateDoc20(clinicRef, {
15677
+ await updateDoc21(clinicRef, {
15512
15678
  isActive: false,
15513
15679
  updatedAt: serverTimestamp20()
15514
15680
  });
@@ -15518,7 +15684,7 @@ var ClinicService = class extends BaseService {
15518
15684
  */
15519
15685
  async activateClinic(clinicId, adminId) {
15520
15686
  const clinicRef = doc24(this.db, CLINICS_COLLECTION, clinicId);
15521
- await updateDoc20(clinicRef, {
15687
+ await updateDoc21(clinicRef, {
15522
15688
  isActive: true,
15523
15689
  updatedAt: serverTimestamp20()
15524
15690
  });
@@ -16855,7 +17021,7 @@ import {
16855
17021
  where as where27,
16856
17022
  getDocs as getDocs27,
16857
17023
  setDoc as setDoc22,
16858
- updateDoc as updateDoc27
17024
+ updateDoc as updateDoc28
16859
17025
  } from "firebase/firestore";
16860
17026
 
16861
17027
  // src/services/calendar/utils/clinic.utils.ts
@@ -16865,7 +17031,7 @@ import {
16865
17031
  getDoc as getDoc28,
16866
17032
  getDocs as getDocs22,
16867
17033
  setDoc as setDoc17,
16868
- updateDoc as updateDoc22,
17034
+ updateDoc as updateDoc23,
16869
17035
  deleteDoc as deleteDoc10,
16870
17036
  query as query22,
16871
17037
  where as where22,
@@ -16936,7 +17102,7 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
16936
17102
  ...updateData,
16937
17103
  updatedAt: serverTimestamp21()
16938
17104
  };
16939
- await updateDoc22(eventRef, updates);
17105
+ await updateDoc23(eventRef, updates);
16940
17106
  const updatedDoc = await getDoc28(eventRef);
16941
17107
  if (!updatedDoc.exists()) {
16942
17108
  throw new Error("Event not found after update");
@@ -16969,7 +17135,7 @@ import {
16969
17135
  getDoc as getDoc29,
16970
17136
  getDocs as getDocs23,
16971
17137
  setDoc as setDoc18,
16972
- updateDoc as updateDoc23,
17138
+ updateDoc as updateDoc24,
16973
17139
  deleteDoc as deleteDoc11,
16974
17140
  query as query23,
16975
17141
  where as where23,
@@ -16999,7 +17165,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
16999
17165
  ...updateData,
17000
17166
  updatedAt: serverTimestamp22()
17001
17167
  };
17002
- await updateDoc23(eventRef, updates);
17168
+ await updateDoc24(eventRef, updates);
17003
17169
  const updatedDoc = await getDoc29(eventRef);
17004
17170
  if (!updatedDoc.exists()) {
17005
17171
  throw new Error("Event not found after update");
@@ -17013,7 +17179,7 @@ import {
17013
17179
  getDoc as getDoc30,
17014
17180
  getDocs as getDocs24,
17015
17181
  setDoc as setDoc19,
17016
- updateDoc as updateDoc24,
17182
+ updateDoc as updateDoc25,
17017
17183
  deleteDoc as deleteDoc12,
17018
17184
  query as query24,
17019
17185
  where as where24,
@@ -17051,7 +17217,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
17051
17217
  ...updateData,
17052
17218
  updatedAt: serverTimestamp23()
17053
17219
  };
17054
- await updateDoc24(eventRef, updates);
17220
+ await updateDoc25(eventRef, updates);
17055
17221
  const updatedDoc = await getDoc30(eventRef);
17056
17222
  if (!updatedDoc.exists()) {
17057
17223
  throw new Error("Event not found after update");
@@ -17116,7 +17282,7 @@ import {
17116
17282
  getDoc as getDoc31,
17117
17283
  getDocs as getDocs25,
17118
17284
  setDoc as setDoc20,
17119
- updateDoc as updateDoc25,
17285
+ updateDoc as updateDoc26,
17120
17286
  deleteDoc as deleteDoc13,
17121
17287
  query as query25,
17122
17288
  where as where25,
@@ -17244,7 +17410,7 @@ import {
17244
17410
  getDoc as getDoc32,
17245
17411
  getDocs as getDocs26,
17246
17412
  setDoc as setDoc21,
17247
- updateDoc as updateDoc26,
17413
+ updateDoc as updateDoc27,
17248
17414
  deleteDoc as deleteDoc14,
17249
17415
  query as query26,
17250
17416
  orderBy as orderBy12,
@@ -17368,7 +17534,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
17368
17534
  ...updateData,
17369
17535
  updatedAt: serverTimestamp25()
17370
17536
  };
17371
- await updateDoc26(calendarRef, updates);
17537
+ await updateDoc27(calendarRef, updates);
17372
17538
  const updatedDoc = await getDoc32(calendarRef);
17373
17539
  if (!updatedDoc.exists()) {
17374
17540
  throw new Error("Synced calendar not found after update");
@@ -17381,7 +17547,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
17381
17547
  ...updateData,
17382
17548
  updatedAt: serverTimestamp25()
17383
17549
  };
17384
- await updateDoc26(calendarRef, updates);
17550
+ await updateDoc27(calendarRef, updates);
17385
17551
  const updatedDoc = await getDoc32(calendarRef);
17386
17552
  if (!updatedDoc.exists()) {
17387
17553
  throw new Error("Synced calendar not found after update");
@@ -17394,7 +17560,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
17394
17560
  ...updateData,
17395
17561
  updatedAt: serverTimestamp25()
17396
17562
  };
17397
- await updateDoc26(calendarRef, updates);
17563
+ await updateDoc27(calendarRef, updates);
17398
17564
  const updatedDoc = await getDoc32(calendarRef);
17399
17565
  if (!updatedDoc.exists()) {
17400
17566
  throw new Error("Synced calendar not found after update");
@@ -18824,7 +18990,7 @@ var CalendarServiceV2 = class extends BaseService {
18824
18990
  CALENDAR_COLLECTION,
18825
18991
  eventId
18826
18992
  );
18827
- await updateDoc27(eventRef, {
18993
+ await updateDoc28(eventRef, {
18828
18994
  eventName: externalEvent.summary || "External Event",
18829
18995
  eventTime: {
18830
18996
  start: Timestamp30.fromDate(startTime),
@@ -18856,7 +19022,7 @@ var CalendarServiceV2 = class extends BaseService {
18856
19022
  CALENDAR_COLLECTION,
18857
19023
  eventId
18858
19024
  );
18859
- await updateDoc27(eventRef, {
19025
+ await updateDoc28(eventRef, {
18860
19026
  status,
18861
19027
  updatedAt: serverTimestamp26()
18862
19028
  });
@@ -19257,7 +19423,7 @@ var CalendarServiceV2 = class extends BaseService {
19257
19423
  } else {
19258
19424
  syncIds.push(syncEvent);
19259
19425
  }
19260
- await updateDoc27(eventRef, {
19426
+ await updateDoc28(eventRef, {
19261
19427
  syncedCalendarEventId: syncIds,
19262
19428
  updatedAt: serverTimestamp26()
19263
19429
  });
@@ -19483,7 +19649,7 @@ var CalendarServiceV2 = class extends BaseService {
19483
19649
 
19484
19650
  // src/services/calendar/calendar.v3.service.ts
19485
19651
  import { Timestamp as Timestamp31, serverTimestamp as serverTimestamp27 } from "firebase/firestore";
19486
- import { doc as doc33, getDoc as getDoc34, setDoc as setDoc23, updateDoc as updateDoc28, deleteDoc as deleteDoc15 } from "firebase/firestore";
19652
+ import { doc as doc33, getDoc as getDoc34, setDoc as setDoc23, updateDoc as updateDoc29, deleteDoc as deleteDoc15 } from "firebase/firestore";
19487
19653
  var CalendarServiceV3 = class extends BaseService {
19488
19654
  /**
19489
19655
  * Creates a new CalendarServiceV3 instance
@@ -19562,7 +19728,7 @@ var CalendarServiceV3 = class extends BaseService {
19562
19728
  if (params.status !== void 0) {
19563
19729
  updateData.status = params.status;
19564
19730
  }
19565
- await updateDoc28(eventRef, updateData);
19731
+ await updateDoc29(eventRef, updateData);
19566
19732
  const updatedEventDoc = await getDoc34(eventRef);
19567
19733
  return updatedEventDoc.data();
19568
19734
  }
@@ -19791,7 +19957,7 @@ import {
19791
19957
  getDocs as getDocs28,
19792
19958
  query as query28,
19793
19959
  where as where28,
19794
- updateDoc as updateDoc29,
19960
+ updateDoc as updateDoc30,
19795
19961
  setDoc as setDoc24,
19796
19962
  deleteDoc as deleteDoc16,
19797
19963
  Timestamp as Timestamp32,
@@ -19960,7 +20126,7 @@ var PractitionerInviteService = class extends BaseService {
19960
20126
  updatedAt: serverTimestamp28()
19961
20127
  };
19962
20128
  const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
19963
- await updateDoc29(docRef, updateData);
20129
+ await updateDoc30(docRef, updateData);
19964
20130
  return await this.getInviteById(inviteId);
19965
20131
  } catch (error) {
19966
20132
  console.error(
@@ -19992,7 +20158,7 @@ var PractitionerInviteService = class extends BaseService {
19992
20158
  updatedAt: serverTimestamp28()
19993
20159
  };
19994
20160
  const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
19995
- await updateDoc29(docRef, updateData);
20161
+ await updateDoc30(docRef, updateData);
19996
20162
  return await this.getInviteById(inviteId);
19997
20163
  } catch (error) {
19998
20164
  console.error(
@@ -20024,7 +20190,7 @@ var PractitionerInviteService = class extends BaseService {
20024
20190
  updatedAt: serverTimestamp28()
20025
20191
  };
20026
20192
  const docRef = doc34(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
20027
- await updateDoc29(docRef, updateData);
20193
+ await updateDoc30(docRef, updateData);
20028
20194
  return await this.getInviteById(inviteId);
20029
20195
  } catch (error) {
20030
20196
  console.error(
@@ -20195,7 +20361,7 @@ import {
20195
20361
  getDoc as getDoc36,
20196
20362
  getDocs as getDocs29,
20197
20363
  setDoc as setDoc25,
20198
- updateDoc as updateDoc30,
20364
+ updateDoc as updateDoc31,
20199
20365
  deleteDoc as deleteDoc17,
20200
20366
  query as query29,
20201
20367
  where as where29,
@@ -20325,7 +20491,7 @@ var DocumentationTemplateService = class extends BaseService {
20325
20491
  updatePayload.sortingOrder = (_c = validatedData.sortingOrder) != null ? _c : 0;
20326
20492
  const docRef = doc35(this.collectionRef, templateId);
20327
20493
  console.log("Update payload", updatePayload);
20328
- await updateDoc30(docRef, updatePayload);
20494
+ await updateDoc31(docRef, updatePayload);
20329
20495
  return { ...template, ...updatePayload };
20330
20496
  }
20331
20497
  /**
@@ -20573,7 +20739,7 @@ import {
20573
20739
  getDoc as getDoc37,
20574
20740
  getDocs as getDocs30,
20575
20741
  setDoc as setDoc26,
20576
- updateDoc as updateDoc31,
20742
+ updateDoc as updateDoc32,
20577
20743
  query as query30,
20578
20744
  orderBy as orderBy15,
20579
20745
  limit as limit14,
@@ -20665,7 +20831,11 @@ var FilledDocumentService = class extends BaseService {
20665
20831
  if (!docSnap.exists()) {
20666
20832
  return null;
20667
20833
  }
20668
- return docSnap.data();
20834
+ const data = docSnap.data();
20835
+ if (!data.id) {
20836
+ data.id = docSnap.id;
20837
+ }
20838
+ return data;
20669
20839
  }
20670
20840
  /**
20671
20841
  * Update values or status in a filled document within an appointment's subcollection.
@@ -20710,7 +20880,7 @@ var FilledDocumentService = class extends BaseService {
20710
20880
  }
20711
20881
  if (Object.keys(updatePayload).length === 1 && "updatedAt" in updatePayload) {
20712
20882
  }
20713
- await updateDoc31(docRef, updatePayload);
20883
+ await updateDoc32(docRef, updatePayload);
20714
20884
  return { ...existingDoc, ...updatePayload };
20715
20885
  }
20716
20886
  /**
@@ -20766,9 +20936,13 @@ var FilledDocumentService = class extends BaseService {
20766
20936
  const querySnapshot = await getDocs30(q);
20767
20937
  const documents = [];
20768
20938
  let lastVisible = null;
20769
- querySnapshot.forEach((doc47) => {
20770
- documents.push(doc47.data());
20771
- lastVisible = doc47;
20939
+ querySnapshot.forEach((docSnapshot) => {
20940
+ const data = docSnapshot.data();
20941
+ if (!data.id) {
20942
+ data.id = docSnapshot.id;
20943
+ }
20944
+ documents.push(data);
20945
+ lastVisible = docSnapshot;
20772
20946
  });
20773
20947
  return {
20774
20948
  documents,
@@ -20934,7 +21108,7 @@ import {
20934
21108
  getDocs as getDocs31,
20935
21109
  query as query31,
20936
21110
  where as where31,
20937
- updateDoc as updateDoc32,
21111
+ updateDoc as updateDoc33,
20938
21112
  deleteDoc as deleteDoc18,
20939
21113
  orderBy as orderBy16,
20940
21114
  Timestamp as Timestamp34,
@@ -21020,7 +21194,7 @@ var NotificationService = class extends BaseService {
21020
21194
  NOTIFICATIONS_COLLECTION,
21021
21195
  notificationId
21022
21196
  );
21023
- await updateDoc32(notificationRef, {
21197
+ await updateDoc33(notificationRef, {
21024
21198
  isRead: true,
21025
21199
  updatedAt: Timestamp34.now()
21026
21200
  });
@@ -21053,7 +21227,7 @@ var NotificationService = class extends BaseService {
21053
21227
  NOTIFICATIONS_COLLECTION,
21054
21228
  notificationId
21055
21229
  );
21056
- await updateDoc32(notificationRef, {
21230
+ await updateDoc33(notificationRef, {
21057
21231
  status,
21058
21232
  updatedAt: Timestamp34.now()
21059
21233
  });
@@ -21109,7 +21283,7 @@ import {
21109
21283
  query as query32,
21110
21284
  where as where32,
21111
21285
  doc as doc38,
21112
- updateDoc as updateDoc33,
21286
+ updateDoc as updateDoc34,
21113
21287
  Timestamp as Timestamp35,
21114
21288
  orderBy as orderBy17,
21115
21289
  limit as limit15,
@@ -21272,7 +21446,7 @@ var PatientRequirementsService = class extends BaseService {
21272
21446
  if (newOverallStatus !== instance.overallStatus) {
21273
21447
  updatePayload.overallStatus = newOverallStatus;
21274
21448
  }
21275
- await updateDoc33(instanceRef, updatePayload);
21449
+ await updateDoc34(instanceRef, updatePayload);
21276
21450
  return {
21277
21451
  ...instance,
21278
21452
  instructions: updatedInstructions,
@@ -21292,7 +21466,7 @@ import {
21292
21466
  getDocs as getDocs33,
21293
21467
  query as query33,
21294
21468
  where as where33,
21295
- updateDoc as updateDoc34,
21469
+ updateDoc as updateDoc35,
21296
21470
  setDoc as setDoc27,
21297
21471
  deleteDoc as deleteDoc19,
21298
21472
  serverTimestamp as serverTimestamp31,
@@ -22449,7 +22623,7 @@ var ProcedureService = class extends BaseService {
22449
22623
  } else if (validatedData.productId) {
22450
22624
  console.warn("Attempted to update product without a valid technologyId");
22451
22625
  }
22452
- await updateDoc34(procedureRef, {
22626
+ await updateDoc35(procedureRef, {
22453
22627
  ...updatedProcedureData,
22454
22628
  updatedAt: serverTimestamp31()
22455
22629
  });
@@ -22467,7 +22641,7 @@ var ProcedureService = class extends BaseService {
22467
22641
  console.warn(`Procedure ${id} not found for deactivation.`);
22468
22642
  return;
22469
22643
  }
22470
- await updateDoc34(procedureRef, {
22644
+ await updateDoc35(procedureRef, {
22471
22645
  isActive: false,
22472
22646
  updatedAt: serverTimestamp31()
22473
22647
  });
@@ -23855,7 +24029,7 @@ import {
23855
24029
  getDoc as getDoc42,
23856
24030
  getDocs as getDocs35,
23857
24031
  query as query35,
23858
- updateDoc as updateDoc35,
24032
+ updateDoc as updateDoc36,
23859
24033
  where as where35,
23860
24034
  limit as limit17,
23861
24035
  orderBy as orderBy19,
@@ -23968,7 +24142,7 @@ var BrandService = class extends BaseService {
23968
24142
  updateData.name_lowercase = brand.name.toLowerCase();
23969
24143
  }
23970
24144
  const docRef = doc41(this.getBrandsRef(), brandId);
23971
- await updateDoc35(docRef, updateData);
24145
+ await updateDoc36(docRef, updateData);
23972
24146
  return this.getById(brandId);
23973
24147
  }
23974
24148
  /**
@@ -24071,7 +24245,7 @@ import {
24071
24245
  orderBy as orderBy20,
24072
24246
  query as query36,
24073
24247
  startAfter as startAfter16,
24074
- updateDoc as updateDoc36,
24248
+ updateDoc as updateDoc37,
24075
24249
  where as where36
24076
24250
  } from "firebase/firestore";
24077
24251
 
@@ -24231,7 +24405,7 @@ var CategoryService = class extends BaseService {
24231
24405
  updatedAt: /* @__PURE__ */ new Date()
24232
24406
  };
24233
24407
  const docRef = doc42(this.categoriesRef, id);
24234
- await updateDoc36(docRef, updateData);
24408
+ await updateDoc37(docRef, updateData);
24235
24409
  return this.getById(id);
24236
24410
  }
24237
24411
  /**
@@ -24383,7 +24557,7 @@ import {
24383
24557
  query as query37,
24384
24558
  setDoc as setDoc29,
24385
24559
  startAfter as startAfter17,
24386
- updateDoc as updateDoc37,
24560
+ updateDoc as updateDoc38,
24387
24561
  where as where37
24388
24562
  } from "firebase/firestore";
24389
24563
 
@@ -24588,7 +24762,7 @@ var SubcategoryService = class extends BaseService {
24588
24762
  updatedAt: /* @__PURE__ */ new Date()
24589
24763
  };
24590
24764
  const docRef = doc43(this.getSubcategoriesRef(categoryId), subcategoryId);
24591
- await updateDoc37(docRef, updateData);
24765
+ await updateDoc38(docRef, updateData);
24592
24766
  return this.getById(categoryId, subcategoryId);
24593
24767
  }
24594
24768
  }
@@ -24744,7 +24918,7 @@ import {
24744
24918
  orderBy as orderBy22,
24745
24919
  query as query38,
24746
24920
  startAfter as startAfter18,
24747
- updateDoc as updateDoc38,
24921
+ updateDoc as updateDoc39,
24748
24922
  where as where38,
24749
24923
  arrayUnion as arrayUnion9,
24750
24924
  arrayRemove as arrayRemove8,
@@ -24941,7 +25115,7 @@ var TechnologyService = class extends BaseService {
24941
25115
  updateData.updatedAt = /* @__PURE__ */ new Date();
24942
25116
  const docRef = doc44(this.technologiesRef, id);
24943
25117
  const beforeTech = await this.getById(id);
24944
- await updateDoc38(docRef, updateData);
25118
+ await updateDoc39(docRef, updateData);
24945
25119
  const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
24946
25120
  const subcategoryChanged = beforeTech && updateData.subcategoryId && beforeTech.subcategoryId !== updateData.subcategoryId;
24947
25121
  const nameChanged = beforeTech && updateData.name && beforeTech.name !== updateData.name;
@@ -25028,7 +25202,7 @@ var TechnologyService = class extends BaseService {
25028
25202
  async addRequirement(technologyId, requirement) {
25029
25203
  const docRef = doc44(this.technologiesRef, technologyId);
25030
25204
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
25031
- await updateDoc38(docRef, {
25205
+ await updateDoc39(docRef, {
25032
25206
  [requirementType]: arrayUnion9(requirement),
25033
25207
  updatedAt: /* @__PURE__ */ new Date()
25034
25208
  });
@@ -25043,7 +25217,7 @@ var TechnologyService = class extends BaseService {
25043
25217
  async removeRequirement(technologyId, requirement) {
25044
25218
  const docRef = doc44(this.technologiesRef, technologyId);
25045
25219
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
25046
- await updateDoc38(docRef, {
25220
+ await updateDoc39(docRef, {
25047
25221
  [requirementType]: arrayRemove8(requirement),
25048
25222
  updatedAt: /* @__PURE__ */ new Date()
25049
25223
  });
@@ -25082,7 +25256,7 @@ var TechnologyService = class extends BaseService {
25082
25256
  */
25083
25257
  async addBlockingCondition(technologyId, condition) {
25084
25258
  const docRef = doc44(this.technologiesRef, technologyId);
25085
- await updateDoc38(docRef, {
25259
+ await updateDoc39(docRef, {
25086
25260
  blockingConditions: arrayUnion9(condition),
25087
25261
  updatedAt: /* @__PURE__ */ new Date()
25088
25262
  });
@@ -25096,7 +25270,7 @@ var TechnologyService = class extends BaseService {
25096
25270
  */
25097
25271
  async removeBlockingCondition(technologyId, condition) {
25098
25272
  const docRef = doc44(this.technologiesRef, technologyId);
25099
- await updateDoc38(docRef, {
25273
+ await updateDoc39(docRef, {
25100
25274
  blockingConditions: arrayRemove8(condition),
25101
25275
  updatedAt: /* @__PURE__ */ new Date()
25102
25276
  });
@@ -25118,7 +25292,7 @@ var TechnologyService = class extends BaseService {
25118
25292
  if (existingContraindications.some((c) => c.id === contraindication.id)) {
25119
25293
  return technology;
25120
25294
  }
25121
- await updateDoc38(docRef, {
25295
+ await updateDoc39(docRef, {
25122
25296
  contraindications: [...existingContraindications, contraindication],
25123
25297
  updatedAt: /* @__PURE__ */ new Date()
25124
25298
  });
@@ -25139,7 +25313,7 @@ var TechnologyService = class extends BaseService {
25139
25313
  const updatedContraindications = (technology.contraindications || []).filter(
25140
25314
  (c) => c.id !== contraindication.id
25141
25315
  );
25142
- await updateDoc38(docRef, {
25316
+ await updateDoc39(docRef, {
25143
25317
  contraindications: updatedContraindications,
25144
25318
  updatedAt: /* @__PURE__ */ new Date()
25145
25319
  });
@@ -25168,7 +25342,7 @@ var TechnologyService = class extends BaseService {
25168
25342
  }
25169
25343
  const updatedContraindications = [...contraindications];
25170
25344
  updatedContraindications[index] = contraindication;
25171
- await updateDoc38(docRef, {
25345
+ await updateDoc39(docRef, {
25172
25346
  contraindications: updatedContraindications,
25173
25347
  updatedAt: /* @__PURE__ */ new Date()
25174
25348
  });
@@ -25190,7 +25364,7 @@ var TechnologyService = class extends BaseService {
25190
25364
  if (existingBenefits.some((b) => b.id === benefit.id)) {
25191
25365
  return technology;
25192
25366
  }
25193
- await updateDoc38(docRef, {
25367
+ await updateDoc39(docRef, {
25194
25368
  benefits: [...existingBenefits, benefit],
25195
25369
  updatedAt: /* @__PURE__ */ new Date()
25196
25370
  });
@@ -25209,7 +25383,7 @@ var TechnologyService = class extends BaseService {
25209
25383
  throw new Error(`Technology with id ${technologyId} not found`);
25210
25384
  }
25211
25385
  const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
25212
- await updateDoc38(docRef, {
25386
+ await updateDoc39(docRef, {
25213
25387
  benefits: updatedBenefits,
25214
25388
  updatedAt: /* @__PURE__ */ new Date()
25215
25389
  });
@@ -25238,7 +25412,7 @@ var TechnologyService = class extends BaseService {
25238
25412
  }
25239
25413
  const updatedBenefits = [...benefits];
25240
25414
  updatedBenefits[index] = benefit;
25241
- await updateDoc38(docRef, {
25415
+ await updateDoc39(docRef, {
25242
25416
  benefits: updatedBenefits,
25243
25417
  updatedAt: /* @__PURE__ */ new Date()
25244
25418
  });
@@ -25279,7 +25453,7 @@ var TechnologyService = class extends BaseService {
25279
25453
  */
25280
25454
  async updateCertificationRequirement(technologyId, certificationRequirement) {
25281
25455
  const docRef = doc44(this.technologiesRef, technologyId);
25282
- await updateDoc38(docRef, {
25456
+ await updateDoc39(docRef, {
25283
25457
  certificationRequirement,
25284
25458
  updatedAt: /* @__PURE__ */ new Date()
25285
25459
  });
@@ -25659,7 +25833,7 @@ import {
25659
25833
  getDoc as getDoc46,
25660
25834
  getDocs as getDocs39,
25661
25835
  query as query39,
25662
- updateDoc as updateDoc39,
25836
+ updateDoc as updateDoc40,
25663
25837
  where as where39,
25664
25838
  limit as limit21,
25665
25839
  orderBy as orderBy23,
@@ -25828,7 +26002,7 @@ var ProductService = class extends BaseService {
25828
26002
  updatedAt: /* @__PURE__ */ new Date()
25829
26003
  };
25830
26004
  const docRef = doc45(this.getProductsRef(technologyId), productId);
25831
- await updateDoc39(docRef, updateData);
26005
+ await updateDoc40(docRef, updateData);
25832
26006
  return this.getById(technologyId, productId);
25833
26007
  }
25834
26008
  /**
@@ -25925,7 +26099,7 @@ var ProductService = class extends BaseService {
25925
26099
  updatedAt: /* @__PURE__ */ new Date()
25926
26100
  };
25927
26101
  const docRef = doc45(this.getTopLevelProductsRef(), productId);
25928
- await updateDoc39(docRef, updateData);
26102
+ await updateDoc40(docRef, updateData);
25929
26103
  return this.getByIdTopLevel(productId);
25930
26104
  }
25931
26105
  /**
@@ -25941,7 +26115,7 @@ var ProductService = class extends BaseService {
25941
26115
  */
25942
26116
  async assignToTechnology(productId, technologyId) {
25943
26117
  const docRef = doc45(this.getTopLevelProductsRef(), productId);
25944
- await updateDoc39(docRef, {
26118
+ await updateDoc40(docRef, {
25945
26119
  assignedTechnologyIds: arrayUnion10(technologyId),
25946
26120
  updatedAt: /* @__PURE__ */ new Date()
25947
26121
  });
@@ -25951,7 +26125,7 @@ var ProductService = class extends BaseService {
25951
26125
  */
25952
26126
  async unassignFromTechnology(productId, technologyId) {
25953
26127
  const docRef = doc45(this.getTopLevelProductsRef(), productId);
25954
- await updateDoc39(docRef, {
26128
+ await updateDoc40(docRef, {
25955
26129
  assignedTechnologyIds: arrayRemove9(technologyId),
25956
26130
  updatedAt: /* @__PURE__ */ new Date()
25957
26131
  });
@@ -26097,7 +26271,7 @@ import {
26097
26271
  doc as doc46,
26098
26272
  getDoc as getDoc47,
26099
26273
  setDoc as setDoc30,
26100
- updateDoc as updateDoc40
26274
+ updateDoc as updateDoc41
26101
26275
  } from "firebase/firestore";
26102
26276
  var ADMIN_CONSTANTS_COLLECTION = "admin-constants";
26103
26277
  var TREATMENT_BENEFITS_DOC = "treatment-benefits";
@@ -26160,7 +26334,7 @@ var ConstantsService = class extends BaseService {
26160
26334
  if (!docSnap.exists()) {
26161
26335
  await setDoc30(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
26162
26336
  } else {
26163
- await updateDoc40(this.treatmentBenefitsDocRef, {
26337
+ await updateDoc41(this.treatmentBenefitsDocRef, {
26164
26338
  benefits: arrayUnion11(newBenefit)
26165
26339
  });
26166
26340
  }
@@ -26200,7 +26374,7 @@ var ConstantsService = class extends BaseService {
26200
26374
  throw new Error("Treatment benefit not found.");
26201
26375
  }
26202
26376
  benefits[benefitIndex] = benefit;
26203
- await updateDoc40(this.treatmentBenefitsDocRef, { benefits });
26377
+ await updateDoc41(this.treatmentBenefitsDocRef, { benefits });
26204
26378
  return benefit;
26205
26379
  }
26206
26380
  /**
@@ -26214,7 +26388,7 @@ var ConstantsService = class extends BaseService {
26214
26388
  if (!benefitToRemove) {
26215
26389
  return;
26216
26390
  }
26217
- await updateDoc40(this.treatmentBenefitsDocRef, {
26391
+ await updateDoc41(this.treatmentBenefitsDocRef, {
26218
26392
  benefits: arrayRemove10(benefitToRemove)
26219
26393
  });
26220
26394
  }
@@ -26267,7 +26441,7 @@ var ConstantsService = class extends BaseService {
26267
26441
  contraindications: [newContraindication]
26268
26442
  });
26269
26443
  } else {
26270
- await updateDoc40(this.contraindicationsDocRef, {
26444
+ await updateDoc41(this.contraindicationsDocRef, {
26271
26445
  contraindications: arrayUnion11(newContraindication)
26272
26446
  });
26273
26447
  }
@@ -26309,7 +26483,7 @@ var ConstantsService = class extends BaseService {
26309
26483
  throw new Error("Contraindication not found.");
26310
26484
  }
26311
26485
  contraindications[index] = contraindication;
26312
- await updateDoc40(this.contraindicationsDocRef, { contraindications });
26486
+ await updateDoc41(this.contraindicationsDocRef, { contraindications });
26313
26487
  return contraindication;
26314
26488
  }
26315
26489
  /**
@@ -26323,7 +26497,7 @@ var ConstantsService = class extends BaseService {
26323
26497
  if (!toRemove) {
26324
26498
  return;
26325
26499
  }
26326
- await updateDoc40(this.contraindicationsDocRef, {
26500
+ await updateDoc41(this.contraindicationsDocRef, {
26327
26501
  contraindications: arrayRemove10(toRemove)
26328
26502
  });
26329
26503
  }