@blackcode_sa/metaestetics-api 1.11.0 → 1.11.1

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 (35) hide show
  1. package/dist/admin/index.d.mts +328 -319
  2. package/dist/admin/index.d.ts +328 -319
  3. package/dist/backoffice/index.d.mts +283 -67
  4. package/dist/backoffice/index.d.ts +283 -67
  5. package/dist/backoffice/index.js +114 -6
  6. package/dist/backoffice/index.mjs +112 -6
  7. package/dist/index.d.mts +3872 -3806
  8. package/dist/index.d.ts +3872 -3806
  9. package/dist/index.js +369 -123
  10. package/dist/index.mjs +369 -124
  11. package/package.json +1 -1
  12. package/src/backoffice/expo-safe/index.ts +2 -0
  13. package/src/backoffice/services/README.md +40 -0
  14. package/src/backoffice/services/constants.service.ts +268 -0
  15. package/src/backoffice/services/technology.service.ts +122 -10
  16. package/src/backoffice/types/admin-constants.types.ts +69 -0
  17. package/src/backoffice/types/index.ts +1 -0
  18. package/src/backoffice/types/product.types.ts +3 -1
  19. package/src/backoffice/types/technology.types.ts +4 -4
  20. package/src/backoffice/validations/schemas.ts +35 -9
  21. package/src/services/appointment/appointment.service.ts +0 -5
  22. package/src/services/appointment/utils/appointment.utils.ts +124 -113
  23. package/src/services/procedure/procedure.service.ts +434 -234
  24. package/src/types/appointment/index.ts +5 -3
  25. package/src/types/clinic/index.ts +1 -6
  26. package/src/types/patient/medical-info.types.ts +3 -3
  27. package/src/types/procedure/index.ts +20 -17
  28. package/src/validations/clinic.schema.ts +1 -6
  29. package/src/validations/patient/medical-info.schema.ts +7 -2
  30. package/src/backoffice/services/__tests__/brand.service.test.ts +0 -196
  31. package/src/backoffice/services/__tests__/category.service.test.ts +0 -201
  32. package/src/backoffice/services/__tests__/product.service.test.ts +0 -358
  33. package/src/backoffice/services/__tests__/requirement.service.test.ts +0 -226
  34. package/src/backoffice/services/__tests__/subcategory.service.test.ts +0 -181
  35. package/src/backoffice/services/__tests__/technology.service.test.ts +0 -1097
package/dist/index.mjs CHANGED
@@ -53,13 +53,13 @@ var AppointmentStatus = /* @__PURE__ */ ((AppointmentStatus2) => {
53
53
  AppointmentStatus2["RESCHEDULED_BY_CLINIC"] = "rescheduled_by_clinic";
54
54
  return AppointmentStatus2;
55
55
  })(AppointmentStatus || {});
56
- var PaymentStatus = /* @__PURE__ */ ((PaymentStatus3) => {
57
- PaymentStatus3["UNPAID"] = "unpaid";
58
- PaymentStatus3["PAID"] = "paid";
59
- PaymentStatus3["PARTIALLY_PAID"] = "partially_paid";
60
- PaymentStatus3["REFUNDED"] = "refunded";
61
- PaymentStatus3["NOT_APPLICABLE"] = "not_applicable";
62
- return PaymentStatus3;
56
+ var PaymentStatus = /* @__PURE__ */ ((PaymentStatus4) => {
57
+ PaymentStatus4["UNPAID"] = "unpaid";
58
+ PaymentStatus4["PAID"] = "paid";
59
+ PaymentStatus4["PARTIALLY_PAID"] = "partially_paid";
60
+ PaymentStatus4["REFUNDED"] = "refunded";
61
+ PaymentStatus4["NOT_APPLICABLE"] = "not_applicable";
62
+ return PaymentStatus4;
63
63
  })(PaymentStatus || {});
64
64
  var MediaType = /* @__PURE__ */ ((MediaType2) => {
65
65
  MediaType2["BEFORE_PHOTO"] = "before_photo";
@@ -585,7 +585,6 @@ import {
585
585
  getDocs,
586
586
  query,
587
587
  where,
588
- setDoc,
589
588
  updateDoc,
590
589
  serverTimestamp,
591
590
  Timestamp,
@@ -822,44 +821,48 @@ async function updateAppointmentUtil(db, appointmentId, data) {
822
821
  const validPreReqIds = currentAppointment.preProcedureRequirements.map(
823
822
  (req) => req.id
824
823
  );
825
- const invalidPreReqIds = data.completedPreRequirements.filter(
826
- (id) => !validPreReqIds.includes(id)
827
- );
828
- if (invalidPreReqIds.length > 0) {
829
- throw new Error(
830
- `Invalid pre-requirement IDs: ${invalidPreReqIds.join(", ")}`
824
+ if (Array.isArray(data.completedPreRequirements)) {
825
+ const invalidPreReqIds = data.completedPreRequirements.filter(
826
+ (id) => !validPreReqIds.includes(id)
831
827
  );
828
+ if (invalidPreReqIds.length > 0) {
829
+ throw new Error(
830
+ `Invalid pre-requirement IDs: ${invalidPreReqIds.join(", ")}`
831
+ );
832
+ }
833
+ completedPreRequirements = [
834
+ .../* @__PURE__ */ new Set([
835
+ ...completedPreRequirements,
836
+ ...data.completedPreRequirements
837
+ ])
838
+ ];
832
839
  }
833
- completedPreRequirements = [
834
- .../* @__PURE__ */ new Set([
835
- ...completedPreRequirements,
836
- ...data.completedPreRequirements
837
- ])
838
- ];
839
840
  }
840
841
  if (data.completedPostRequirements) {
841
842
  const validPostReqIds = currentAppointment.postProcedureRequirements.map(
842
843
  (req) => req.id
843
844
  );
844
- const invalidPostReqIds = data.completedPostRequirements.filter(
845
- (id) => !validPostReqIds.includes(id)
846
- );
847
- if (invalidPostReqIds.length > 0) {
848
- throw new Error(
849
- `Invalid post-requirement IDs: ${invalidPostReqIds.join(", ")}`
845
+ if (Array.isArray(data.completedPostRequirements)) {
846
+ const invalidPostReqIds = data.completedPostRequirements.filter(
847
+ (id) => !validPostReqIds.includes(id)
850
848
  );
849
+ if (invalidPostReqIds.length > 0) {
850
+ throw new Error(
851
+ `Invalid post-requirement IDs: ${invalidPostReqIds.join(", ")}`
852
+ );
853
+ }
854
+ completedPostRequirements = [
855
+ .../* @__PURE__ */ new Set([
856
+ ...completedPostRequirements,
857
+ ...data.completedPostRequirements
858
+ ])
859
+ ];
851
860
  }
852
- completedPostRequirements = [
853
- .../* @__PURE__ */ new Set([
854
- ...completedPostRequirements,
855
- ...data.completedPostRequirements
856
- ])
857
- ];
858
861
  }
859
862
  const updateData = {
860
863
  ...data,
861
- completedPreRequirements,
862
- completedPostRequirements,
864
+ completedPreRequirements: Array.isArray(data.completedPreRequirements) ? completedPreRequirements : data.completedPreRequirements,
865
+ completedPostRequirements: Array.isArray(data.completedPostRequirements) ? completedPostRequirements : data.completedPostRequirements,
863
866
  updatedAt: serverTimestamp()
864
867
  };
865
868
  Object.keys(updateData).forEach((key) => {
@@ -909,7 +912,7 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
909
912
  case "canceled_clinic" /* CANCELED_CLINIC */:
910
913
  calendarStatus = "canceled";
911
914
  break;
912
- case AppointmentStatus.RESCHEDULED:
915
+ case "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */:
913
916
  calendarStatus = "rescheduled";
914
917
  break;
915
918
  case "completed" /* COMPLETED */:
@@ -2802,23 +2805,6 @@ var BlockingCondition = /* @__PURE__ */ ((BlockingCondition2) => {
2802
2805
  return BlockingCondition2;
2803
2806
  })(BlockingCondition || {});
2804
2807
 
2805
- // src/backoffice/types/static/contraindication.types.ts
2806
- var Contraindication = /* @__PURE__ */ ((Contraindication2) => {
2807
- Contraindication2["SENSITIVE_SKIN"] = "sensitive_skin";
2808
- Contraindication2["RECENT_TANNING"] = "recent_tanning";
2809
- Contraindication2["RECENT_BOTOX"] = "recent_botox";
2810
- Contraindication2["RECENT_FILLERS"] = "recent_fillers";
2811
- Contraindication2["SKIN_ALLERGIES"] = "skin_allergies";
2812
- Contraindication2["MEDICATIONS"] = "medications";
2813
- Contraindication2["RECENT_CHEMICAL_PEEL"] = "recent_chemical_peel";
2814
- Contraindication2["RECENT_LASER"] = "recent_laser";
2815
- Contraindication2["SKIN_INFLAMMATION"] = "skin_inflammation";
2816
- Contraindication2["OPEN_WOUNDS"] = "open_wounds";
2817
- Contraindication2["HERPES_SIMPLEX"] = "herpes_simplex";
2818
- Contraindication2["COLD_SORES"] = "cold_sores";
2819
- return Contraindication2;
2820
- })(Contraindication || {});
2821
-
2822
2808
  // src/validations/common.schema.ts
2823
2809
  import { z as z5 } from "zod";
2824
2810
  import { Timestamp as Timestamp4 } from "firebase/firestore";
@@ -2873,8 +2859,13 @@ var blockingConditionSchema = z6.object({
2873
2859
  notes: z6.string().optional().nullable(),
2874
2860
  isActive: z6.boolean()
2875
2861
  });
2862
+ var contraindicationDynamicSchema = z6.object({
2863
+ id: z6.string(),
2864
+ name: z6.string(),
2865
+ description: z6.string().optional()
2866
+ });
2876
2867
  var contraindicationSchema = z6.object({
2877
- condition: z6.nativeEnum(Contraindication),
2868
+ condition: contraindicationDynamicSchema,
2878
2869
  lastOccurrence: timestampSchema,
2879
2870
  frequency: z6.enum(["rare", "occasional", "frequent"]),
2880
2871
  notes: z6.string().optional().nullable(),
@@ -10779,7 +10770,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
10779
10770
  }
10780
10771
 
10781
10772
  // src/services/calendar/utils/appointment.utils.ts
10782
- async function createAppointmentUtil2(db, clinicId, practitionerId, patientId, eventData, generateId2) {
10773
+ async function createAppointmentUtil(db, clinicId, practitionerId, patientId, eventData, generateId2) {
10783
10774
  const eventId = generateId2();
10784
10775
  const autoConfirm = await checkAutoConfirmAppointmentsUtil(db, clinicId);
10785
10776
  const initialStatus = autoConfirm ? "confirmed" /* CONFIRMED */ : "pending" /* PENDING */;
@@ -12121,7 +12112,7 @@ var CalendarServiceV2 = class extends BaseService {
12121
12112
  syncStatus: "internal" /* INTERNAL */,
12122
12113
  eventType: "appointment" /* APPOINTMENT */
12123
12114
  };
12124
- const appointment = await createAppointmentUtil2(
12115
+ const appointment = await createAppointmentUtil(
12125
12116
  this.db,
12126
12117
  params.clinicId,
12127
12118
  params.doctorId,
@@ -15005,7 +14996,9 @@ var ProcedureService = class extends BaseService {
15005
14996
  return media;
15006
14997
  }
15007
14998
  if (media instanceof File || media instanceof Blob) {
15008
- console.log(`[ProcedureService] Uploading ${collectionName} media for ${ownerId}`);
14999
+ console.log(
15000
+ `[ProcedureService] Uploading ${collectionName} media for ${ownerId}`
15001
+ );
15009
15002
  const metadata = await this.mediaService.uploadMedia(
15010
15003
  media,
15011
15004
  ownerId,
@@ -15027,7 +15020,11 @@ var ProcedureService = class extends BaseService {
15027
15020
  if (!mediaArray || mediaArray.length === 0) return [];
15028
15021
  const result = [];
15029
15022
  for (const media of mediaArray) {
15030
- const processedUrl = await this.processMedia(media, ownerId, collectionName);
15023
+ const processedUrl = await this.processMedia(
15024
+ media,
15025
+ ownerId,
15026
+ collectionName
15027
+ );
15031
15028
  if (processedUrl) {
15032
15029
  result.push(processedUrl);
15033
15030
  }
@@ -15040,28 +15037,46 @@ var ProcedureService = class extends BaseService {
15040
15037
  * @returns The created procedure
15041
15038
  */
15042
15039
  async createProcedure(data) {
15043
- var _a;
15040
+ var _a, _b, _c;
15044
15041
  const validatedData = createProcedureSchema.parse(data);
15045
15042
  const procedureId = this.generateId();
15046
15043
  const [category, subcategory, technology, product] = await Promise.all([
15047
15044
  this.categoryService.getById(validatedData.categoryId),
15048
- this.subcategoryService.getById(validatedData.categoryId, validatedData.subcategoryId),
15045
+ this.subcategoryService.getById(
15046
+ validatedData.categoryId,
15047
+ validatedData.subcategoryId
15048
+ ),
15049
15049
  this.technologyService.getById(validatedData.technologyId),
15050
- this.productService.getById(validatedData.technologyId, validatedData.productId)
15050
+ this.productService.getById(
15051
+ validatedData.technologyId,
15052
+ validatedData.productId
15053
+ )
15051
15054
  ]);
15052
15055
  if (!category || !subcategory || !technology || !product) {
15053
15056
  throw new Error("One or more required base entities not found");
15054
15057
  }
15055
- const clinicRef = doc30(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
15058
+ const clinicRef = doc30(
15059
+ this.db,
15060
+ CLINICS_COLLECTION,
15061
+ validatedData.clinicBranchId
15062
+ );
15056
15063
  const clinicSnapshot = await getDoc32(clinicRef);
15057
15064
  if (!clinicSnapshot.exists()) {
15058
- throw new Error(`Clinic with ID ${validatedData.clinicBranchId} not found`);
15065
+ throw new Error(
15066
+ `Clinic with ID ${validatedData.clinicBranchId} not found`
15067
+ );
15059
15068
  }
15060
15069
  const clinic = clinicSnapshot.data();
15061
- const practitionerRef = doc30(this.db, PRACTITIONERS_COLLECTION, validatedData.practitionerId);
15070
+ const practitionerRef = doc30(
15071
+ this.db,
15072
+ PRACTITIONERS_COLLECTION,
15073
+ validatedData.practitionerId
15074
+ );
15062
15075
  const practitionerSnapshot = await getDoc32(practitionerRef);
15063
15076
  if (!practitionerSnapshot.exists()) {
15064
- throw new Error(`Practitioner with ID ${validatedData.practitionerId} not found`);
15077
+ throw new Error(
15078
+ `Practitioner with ID ${validatedData.practitionerId} not found`
15079
+ );
15065
15080
  }
15066
15081
  const practitioner = practitionerSnapshot.data();
15067
15082
  let processedPhotos = [];
@@ -15102,7 +15117,9 @@ var ProcedureService = class extends BaseService {
15102
15117
  product,
15103
15118
  blockingConditions: technology.blockingConditions,
15104
15119
  contraindications: technology.contraindications || [],
15120
+ contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
15105
15121
  treatmentBenefits: technology.benefits,
15122
+ treatmentBenefitIds: ((_c = technology.benefits) == null ? void 0 : _c.map((b) => b.id)) || [],
15106
15123
  preRequirements: technology.requirements.pre,
15107
15124
  postRequirements: technology.requirements.post,
15108
15125
  certificationRequirement: technology.certificationRequirement,
@@ -15143,7 +15160,7 @@ var ProcedureService = class extends BaseService {
15143
15160
  * @returns A promise that resolves to an array of the newly created procedures.
15144
15161
  */
15145
15162
  async bulkCreateProcedures(baseData, practitionerIds) {
15146
- var _a;
15163
+ var _a, _b, _c;
15147
15164
  if (!practitionerIds || practitionerIds.length === 0) {
15148
15165
  throw new Error("Practitioner IDs array cannot be empty.");
15149
15166
  }
@@ -15151,16 +15168,24 @@ var ProcedureService = class extends BaseService {
15151
15168
  const validatedData = createProcedureSchema.parse(validationData);
15152
15169
  const [category, subcategory, technology, product, clinicSnapshot] = await Promise.all([
15153
15170
  this.categoryService.getById(validatedData.categoryId),
15154
- this.subcategoryService.getById(validatedData.categoryId, validatedData.subcategoryId),
15171
+ this.subcategoryService.getById(
15172
+ validatedData.categoryId,
15173
+ validatedData.subcategoryId
15174
+ ),
15155
15175
  this.technologyService.getById(validatedData.technologyId),
15156
- this.productService.getById(validatedData.technologyId, validatedData.productId),
15176
+ this.productService.getById(
15177
+ validatedData.technologyId,
15178
+ validatedData.productId
15179
+ ),
15157
15180
  getDoc32(doc30(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId))
15158
15181
  ]);
15159
15182
  if (!category || !subcategory || !technology || !product) {
15160
15183
  throw new Error("One or more required base entities not found");
15161
15184
  }
15162
15185
  if (!clinicSnapshot.exists()) {
15163
- throw new Error(`Clinic with ID ${validatedData.clinicBranchId} not found`);
15186
+ throw new Error(
15187
+ `Clinic with ID ${validatedData.clinicBranchId} not found`
15188
+ );
15164
15189
  }
15165
15190
  const clinic = clinicSnapshot.data();
15166
15191
  let processedPhotos = [];
@@ -15186,8 +15211,12 @@ var ProcedureService = class extends BaseService {
15186
15211
  }
15187
15212
  if (practitionersMap.size !== practitionerIds.length) {
15188
15213
  const foundIds = Array.from(practitionersMap.keys());
15189
- const notFoundIds = practitionerIds.filter((id) => !foundIds.includes(id));
15190
- throw new Error(`The following practitioners were not found: ${notFoundIds.join(", ")}`);
15214
+ const notFoundIds = practitionerIds.filter(
15215
+ (id) => !foundIds.includes(id)
15216
+ );
15217
+ throw new Error(
15218
+ `The following practitioners were not found: ${notFoundIds.join(", ")}`
15219
+ );
15191
15220
  }
15192
15221
  const batch = writeBatch6(this.db);
15193
15222
  const createdProcedureIds = [];
@@ -15225,7 +15254,9 @@ var ProcedureService = class extends BaseService {
15225
15254
  product,
15226
15255
  blockingConditions: technology.blockingConditions,
15227
15256
  contraindications: technology.contraindications || [],
15257
+ contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
15228
15258
  treatmentBenefits: technology.benefits,
15259
+ treatmentBenefitIds: ((_c = technology.benefits) == null ? void 0 : _c.map((b) => b.id)) || [],
15229
15260
  preRequirements: technology.requirements.pre,
15230
15261
  postRequirements: technology.requirements.post,
15231
15262
  certificationRequirement: technology.certificationRequirement,
@@ -15255,7 +15286,10 @@ var ProcedureService = class extends BaseService {
15255
15286
  const fetchedProcedures = [];
15256
15287
  for (let i = 0; i < createdProcedureIds.length; i += 30) {
15257
15288
  const chunk = createdProcedureIds.slice(i, i + 30);
15258
- const q = query29(collection29(this.db, PROCEDURES_COLLECTION), where29(documentId2(), "in", chunk));
15289
+ const q = query29(
15290
+ collection29(this.db, PROCEDURES_COLLECTION),
15291
+ where29(documentId2(), "in", chunk)
15292
+ );
15259
15293
  const snapshot = await getDocs29(q);
15260
15294
  snapshot.forEach((doc37) => {
15261
15295
  fetchedProcedures.push(doc37.data());
@@ -15325,7 +15359,7 @@ var ProcedureService = class extends BaseService {
15325
15359
  * @returns The updated procedure
15326
15360
  */
15327
15361
  async updateProcedure(id, data) {
15328
- var _a;
15362
+ var _a, _b, _c;
15329
15363
  const validatedData = updateProcedureSchema.parse(data);
15330
15364
  const procedureRef = doc30(this.db, PROCEDURES_COLLECTION, id);
15331
15365
  const procedureSnapshot = await getDoc32(procedureRef);
@@ -15356,7 +15390,9 @@ var ProcedureService = class extends BaseService {
15356
15390
  );
15357
15391
  const newPractitionerSnap = await getDoc32(newPractitionerRef);
15358
15392
  if (!newPractitionerSnap.exists())
15359
- throw new Error(`New Practitioner ${validatedData.practitionerId} not found`);
15393
+ throw new Error(
15394
+ `New Practitioner ${validatedData.practitionerId} not found`
15395
+ );
15360
15396
  newPractitioner = newPractitionerSnap.data();
15361
15397
  updatedProcedureData.doctorInfo = {
15362
15398
  id: newPractitioner.id,
@@ -15370,7 +15406,11 @@ var ProcedureService = class extends BaseService {
15370
15406
  }
15371
15407
  if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
15372
15408
  clinicChanged = true;
15373
- const newClinicRef = doc30(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
15409
+ const newClinicRef = doc30(
15410
+ this.db,
15411
+ CLINICS_COLLECTION,
15412
+ validatedData.clinicBranchId
15413
+ );
15374
15414
  const newClinicSnap = await getDoc32(newClinicRef);
15375
15415
  if (!newClinicSnap.exists())
15376
15416
  throw new Error(`New Clinic ${validatedData.clinicBranchId} not found`);
@@ -15389,8 +15429,11 @@ var ProcedureService = class extends BaseService {
15389
15429
  updatedProcedureData.nameLower = validatedData.name.toLowerCase();
15390
15430
  }
15391
15431
  if (validatedData.categoryId) {
15392
- const category = await this.categoryService.getById(validatedData.categoryId);
15393
- if (!category) throw new Error(`Category ${validatedData.categoryId} not found`);
15432
+ const category = await this.categoryService.getById(
15433
+ validatedData.categoryId
15434
+ );
15435
+ if (!category)
15436
+ throw new Error(`Category ${validatedData.categoryId} not found`);
15394
15437
  updatedProcedureData.category = category;
15395
15438
  finalCategoryId = category.id;
15396
15439
  }
@@ -15405,23 +15448,34 @@ var ProcedureService = class extends BaseService {
15405
15448
  );
15406
15449
  updatedProcedureData.subcategory = subcategory;
15407
15450
  } else if (validatedData.subcategoryId) {
15408
- console.warn("Attempted to update subcategory without a valid categoryId");
15451
+ console.warn(
15452
+ "Attempted to update subcategory without a valid categoryId"
15453
+ );
15409
15454
  }
15410
15455
  let finalTechnologyId = existingProcedure.technology.id;
15411
15456
  if (validatedData.technologyId) {
15412
- const technology = await this.technologyService.getById(validatedData.technologyId);
15413
- if (!technology) throw new Error(`Technology ${validatedData.technologyId} not found`);
15457
+ const technology = await this.technologyService.getById(
15458
+ validatedData.technologyId
15459
+ );
15460
+ if (!technology)
15461
+ throw new Error(`Technology ${validatedData.technologyId} not found`);
15414
15462
  updatedProcedureData.technology = technology;
15415
15463
  finalTechnologyId = technology.id;
15416
15464
  updatedProcedureData.blockingConditions = technology.blockingConditions;
15465
+ updatedProcedureData.contraindications = technology.contraindications || [];
15466
+ updatedProcedureData.contraindicationIds = ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [];
15417
15467
  updatedProcedureData.treatmentBenefits = technology.benefits;
15468
+ updatedProcedureData.treatmentBenefitIds = ((_c = technology.benefits) == null ? void 0 : _c.map((b) => b.id)) || [];
15418
15469
  updatedProcedureData.preRequirements = technology.requirements.pre;
15419
15470
  updatedProcedureData.postRequirements = technology.requirements.post;
15420
15471
  updatedProcedureData.certificationRequirement = technology.certificationRequirement;
15421
15472
  updatedProcedureData.documentationTemplates = technology.documentationTemplates || [];
15422
15473
  }
15423
15474
  if (validatedData.productId && finalTechnologyId) {
15424
- const product = await this.productService.getById(finalTechnologyId, validatedData.productId);
15475
+ const product = await this.productService.getById(
15476
+ finalTechnologyId,
15477
+ validatedData.productId
15478
+ );
15425
15479
  if (!product)
15426
15480
  throw new Error(
15427
15481
  `Product ${validatedData.productId} not found for technology ${finalTechnologyId}`
@@ -15503,7 +15557,11 @@ var ProcedureService = class extends BaseService {
15503
15557
  limit16(pagination)
15504
15558
  );
15505
15559
  } else {
15506
- proceduresQuery = query29(proceduresCollection, orderBy17("name"), limit16(pagination));
15560
+ proceduresQuery = query29(
15561
+ proceduresCollection,
15562
+ orderBy17("name"),
15563
+ limit16(pagination)
15564
+ );
15507
15565
  }
15508
15566
  } else {
15509
15567
  proceduresQuery = query29(proceduresCollection, orderBy17("name"));
@@ -15534,7 +15592,7 @@ var ProcedureService = class extends BaseService {
15534
15592
  *
15535
15593
  * @param filters - Various filters to apply
15536
15594
  * @param filters.nameSearch - Optional search text for procedure name
15537
- * @param filters.treatmentBenefits - Optional array of treatment benefits to filter by
15595
+ * @param filters.treatmentBenefitIds - Optional array of treatment benefits to filter by
15538
15596
  * @param filters.procedureFamily - Optional procedure family to filter by
15539
15597
  * @param filters.procedureCategory - Optional procedure category to filter by
15540
15598
  * @param filters.procedureSubcategory - Optional procedure subcategory to filter by
@@ -15552,7 +15610,9 @@ var ProcedureService = class extends BaseService {
15552
15610
  */
15553
15611
  async getProceduresByFilters(filters) {
15554
15612
  try {
15555
- console.log("[PROCEDURE_SERVICE] Starting procedure filtering with multiple strategies");
15613
+ console.log(
15614
+ "[PROCEDURE_SERVICE] Starting procedure filtering with multiple strategies"
15615
+ );
15556
15616
  if (filters.location && filters.radiusInKm) {
15557
15617
  console.log("[PROCEDURE_SERVICE] Executing geo query:", {
15558
15618
  location: filters.location,
@@ -15560,7 +15620,10 @@ var ProcedureService = class extends BaseService {
15560
15620
  serviceName: "ProcedureService"
15561
15621
  });
15562
15622
  if (!filters.location.latitude || !filters.location.longitude) {
15563
- console.warn("[PROCEDURE_SERVICE] Invalid location data:", filters.location);
15623
+ console.warn(
15624
+ "[PROCEDURE_SERVICE] Invalid location data:",
15625
+ filters.location
15626
+ );
15564
15627
  filters.location = void 0;
15565
15628
  filters.radiusInKm = void 0;
15566
15629
  }
@@ -15580,13 +15643,19 @@ var ProcedureService = class extends BaseService {
15580
15643
  constraints.push(where29("family", "==", filters.procedureFamily));
15581
15644
  }
15582
15645
  if (filters.procedureCategory) {
15583
- constraints.push(where29("category.id", "==", filters.procedureCategory));
15646
+ constraints.push(
15647
+ where29("category.id", "==", filters.procedureCategory)
15648
+ );
15584
15649
  }
15585
15650
  if (filters.procedureSubcategory) {
15586
- constraints.push(where29("subcategory.id", "==", filters.procedureSubcategory));
15651
+ constraints.push(
15652
+ where29("subcategory.id", "==", filters.procedureSubcategory)
15653
+ );
15587
15654
  }
15588
15655
  if (filters.procedureTechnology) {
15589
- constraints.push(where29("technology.id", "==", filters.procedureTechnology));
15656
+ constraints.push(
15657
+ where29("technology.id", "==", filters.procedureTechnology)
15658
+ );
15590
15659
  }
15591
15660
  if (filters.minPrice !== void 0) {
15592
15661
  constraints.push(where29("price", ">=", filters.minPrice));
@@ -15595,20 +15664,32 @@ var ProcedureService = class extends BaseService {
15595
15664
  constraints.push(where29("price", "<=", filters.maxPrice));
15596
15665
  }
15597
15666
  if (filters.minRating !== void 0) {
15598
- constraints.push(where29("reviewInfo.averageRating", ">=", filters.minRating));
15667
+ constraints.push(
15668
+ where29("reviewInfo.averageRating", ">=", filters.minRating)
15669
+ );
15599
15670
  }
15600
15671
  if (filters.maxRating !== void 0) {
15601
- constraints.push(where29("reviewInfo.averageRating", "<=", filters.maxRating));
15672
+ constraints.push(
15673
+ where29("reviewInfo.averageRating", "<=", filters.maxRating)
15674
+ );
15602
15675
  }
15603
15676
  if (filters.treatmentBenefits && filters.treatmentBenefits.length > 0) {
15604
- const benefitsToMatch = filters.treatmentBenefits;
15605
- constraints.push(where29("treatmentBenefits", "array-contains-any", benefitsToMatch));
15677
+ const benefitIdsToMatch = filters.treatmentBenefits;
15678
+ constraints.push(
15679
+ where29(
15680
+ "treatmentBenefitIds",
15681
+ "array-contains-any",
15682
+ benefitIdsToMatch
15683
+ )
15684
+ );
15606
15685
  }
15607
15686
  return constraints;
15608
15687
  };
15609
15688
  if (filters.nameSearch && filters.nameSearch.trim()) {
15610
15689
  try {
15611
- console.log("[PROCEDURE_SERVICE] Strategy 1: Trying nameLower search");
15690
+ console.log(
15691
+ "[PROCEDURE_SERVICE] Strategy 1: Trying nameLower search"
15692
+ );
15612
15693
  const searchTerm = filters.nameSearch.trim().toLowerCase();
15613
15694
  const constraints = getBaseConstraints();
15614
15695
  constraints.push(where29("nameLower", ">=", searchTerm));
@@ -15624,13 +15705,18 @@ var ProcedureService = class extends BaseService {
15624
15705
  }
15625
15706
  }
15626
15707
  constraints.push(limit15(filters.pagination || 10));
15627
- const q = query29(collection29(this.db, PROCEDURES_COLLECTION), ...constraints);
15708
+ const q = query29(
15709
+ collection29(this.db, PROCEDURES_COLLECTION),
15710
+ ...constraints
15711
+ );
15628
15712
  const querySnapshot = await getDocs29(q);
15629
15713
  const procedures = querySnapshot.docs.map(
15630
15714
  (doc37) => ({ ...doc37.data(), id: doc37.id })
15631
15715
  );
15632
15716
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
15633
- console.log(`[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`);
15717
+ console.log(
15718
+ `[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`
15719
+ );
15634
15720
  if (procedures.length < (filters.pagination || 10)) {
15635
15721
  return { procedures, lastDoc: null };
15636
15722
  }
@@ -15641,7 +15727,9 @@ var ProcedureService = class extends BaseService {
15641
15727
  }
15642
15728
  if (filters.nameSearch && filters.nameSearch.trim()) {
15643
15729
  try {
15644
- console.log("[PROCEDURE_SERVICE] Strategy 2: Trying name field search");
15730
+ console.log(
15731
+ "[PROCEDURE_SERVICE] Strategy 2: Trying name field search"
15732
+ );
15645
15733
  const searchTerm = filters.nameSearch.trim().toLowerCase();
15646
15734
  const constraints = getBaseConstraints();
15647
15735
  constraints.push(where29("name", ">=", searchTerm));
@@ -15657,13 +15745,18 @@ var ProcedureService = class extends BaseService {
15657
15745
  }
15658
15746
  }
15659
15747
  constraints.push(limit15(filters.pagination || 10));
15660
- const q = query29(collection29(this.db, PROCEDURES_COLLECTION), ...constraints);
15748
+ const q = query29(
15749
+ collection29(this.db, PROCEDURES_COLLECTION),
15750
+ ...constraints
15751
+ );
15661
15752
  const querySnapshot = await getDocs29(q);
15662
15753
  const procedures = querySnapshot.docs.map(
15663
15754
  (doc37) => ({ ...doc37.data(), id: doc37.id })
15664
15755
  );
15665
15756
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
15666
- console.log(`[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`);
15757
+ console.log(
15758
+ `[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`
15759
+ );
15667
15760
  if (procedures.length < (filters.pagination || 10)) {
15668
15761
  return { procedures, lastDoc: null };
15669
15762
  }
@@ -15688,14 +15781,19 @@ var ProcedureService = class extends BaseService {
15688
15781
  }
15689
15782
  }
15690
15783
  constraints.push(limit15(filters.pagination || 10));
15691
- const q = query29(collection29(this.db, PROCEDURES_COLLECTION), ...constraints);
15784
+ const q = query29(
15785
+ collection29(this.db, PROCEDURES_COLLECTION),
15786
+ ...constraints
15787
+ );
15692
15788
  const querySnapshot = await getDocs29(q);
15693
15789
  let procedures = querySnapshot.docs.map(
15694
15790
  (doc37) => ({ ...doc37.data(), id: doc37.id })
15695
15791
  );
15696
15792
  procedures = this.applyInMemoryFilters(procedures, filters);
15697
15793
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
15698
- console.log(`[PROCEDURE_SERVICE] Strategy 3 success: ${procedures.length} procedures`);
15794
+ console.log(
15795
+ `[PROCEDURE_SERVICE] Strategy 3 success: ${procedures.length} procedures`
15796
+ );
15699
15797
  if (procedures.length < (filters.pagination || 10)) {
15700
15798
  return { procedures, lastDoc: null };
15701
15799
  }
@@ -15710,14 +15808,19 @@ var ProcedureService = class extends BaseService {
15710
15808
  orderBy17("createdAt", "desc"),
15711
15809
  limit15(filters.pagination || 10)
15712
15810
  ];
15713
- const q = query29(collection29(this.db, PROCEDURES_COLLECTION), ...constraints);
15811
+ const q = query29(
15812
+ collection29(this.db, PROCEDURES_COLLECTION),
15813
+ ...constraints
15814
+ );
15714
15815
  const querySnapshot = await getDocs29(q);
15715
15816
  let procedures = querySnapshot.docs.map(
15716
15817
  (doc37) => ({ ...doc37.data(), id: doc37.id })
15717
15818
  );
15718
15819
  procedures = this.applyInMemoryFilters(procedures, filters);
15719
15820
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
15720
- console.log(`[PROCEDURE_SERVICE] Strategy 4 success: ${procedures.length} procedures`);
15821
+ console.log(
15822
+ `[PROCEDURE_SERVICE] Strategy 4 success: ${procedures.length} procedures`
15823
+ );
15721
15824
  if (procedures.length < (filters.pagination || 10)) {
15722
15825
  return { procedures, lastDoc: null };
15723
15826
  }
@@ -15725,7 +15828,9 @@ var ProcedureService = class extends BaseService {
15725
15828
  } catch (error) {
15726
15829
  console.log("[PROCEDURE_SERVICE] Strategy 4 failed:", error);
15727
15830
  }
15728
- console.log("[PROCEDURE_SERVICE] All strategies failed, returning empty result");
15831
+ console.log(
15832
+ "[PROCEDURE_SERVICE] All strategies failed, returning empty result"
15833
+ );
15729
15834
  return { procedures: [], lastDoc: null };
15730
15835
  } catch (error) {
15731
15836
  console.error("[PROCEDURE_SERVICE] Error filtering procedures:", error);
@@ -15745,13 +15850,17 @@ var ProcedureService = class extends BaseService {
15745
15850
  const nameLower = procedure.nameLower || "";
15746
15851
  return name.includes(searchTerm) || nameLower.includes(searchTerm);
15747
15852
  });
15748
- console.log(`[PROCEDURE_SERVICE] Applied name filter, results: ${filteredProcedures.length}`);
15853
+ console.log(
15854
+ `[PROCEDURE_SERVICE] Applied name filter, results: ${filteredProcedures.length}`
15855
+ );
15749
15856
  }
15750
15857
  if (filters.minPrice !== void 0 || filters.maxPrice !== void 0) {
15751
15858
  filteredProcedures = filteredProcedures.filter((procedure) => {
15752
15859
  const price = procedure.price || 0;
15753
- if (filters.minPrice !== void 0 && price < filters.minPrice) return false;
15754
- if (filters.maxPrice !== void 0 && price > filters.maxPrice) return false;
15860
+ if (filters.minPrice !== void 0 && price < filters.minPrice)
15861
+ return false;
15862
+ if (filters.maxPrice !== void 0 && price > filters.maxPrice)
15863
+ return false;
15755
15864
  return true;
15756
15865
  });
15757
15866
  console.log(
@@ -15762,8 +15871,10 @@ var ProcedureService = class extends BaseService {
15762
15871
  filteredProcedures = filteredProcedures.filter((procedure) => {
15763
15872
  var _a;
15764
15873
  const rating = ((_a = procedure.reviewInfo) == null ? void 0 : _a.averageRating) || 0;
15765
- if (filters.minRating !== void 0 && rating < filters.minRating) return false;
15766
- if (filters.maxRating !== void 0 && rating > filters.maxRating) return false;
15874
+ if (filters.minRating !== void 0 && rating < filters.minRating)
15875
+ return false;
15876
+ if (filters.maxRating !== void 0 && rating > filters.maxRating)
15877
+ return false;
15767
15878
  return true;
15768
15879
  });
15769
15880
  console.log(
@@ -15771,10 +15882,12 @@ var ProcedureService = class extends BaseService {
15771
15882
  );
15772
15883
  }
15773
15884
  if (filters.treatmentBenefits && filters.treatmentBenefits.length > 0) {
15774
- const benefitsToMatch = filters.treatmentBenefits;
15885
+ const benefitIdsToMatch = filters.treatmentBenefits;
15775
15886
  filteredProcedures = filteredProcedures.filter((procedure) => {
15776
- const procedureBenefits = procedure.treatmentBenefits || [];
15777
- return benefitsToMatch.some((benefit) => procedureBenefits.includes(benefit));
15887
+ const procedureBenefitIds = procedure.treatmentBenefitIds || [];
15888
+ return benefitIdsToMatch.some(
15889
+ (benefitId) => procedureBenefitIds.includes(benefitId)
15890
+ );
15778
15891
  });
15779
15892
  console.log(
15780
15893
  `[PROCEDURE_SERVICE] Applied benefits filter, results: ${filteredProcedures.length}`
@@ -15837,8 +15950,12 @@ var ProcedureService = class extends BaseService {
15837
15950
  procedure.distance = distance;
15838
15951
  return distance <= radiusInKm;
15839
15952
  });
15840
- console.log(`[PROCEDURE_SERVICE] Applied geo filter, results: ${filteredProcedures.length}`);
15841
- filteredProcedures.sort((a, b) => (a.distance || 0) - (b.distance || 0));
15953
+ console.log(
15954
+ `[PROCEDURE_SERVICE] Applied geo filter, results: ${filteredProcedures.length}`
15955
+ );
15956
+ filteredProcedures.sort(
15957
+ (a, b) => (a.distance || 0) - (b.distance || 0)
15958
+ );
15842
15959
  }
15843
15960
  return filteredProcedures;
15844
15961
  }
@@ -15850,19 +15967,30 @@ var ProcedureService = class extends BaseService {
15850
15967
  if (!location || !radiusInKm) {
15851
15968
  return Promise.resolve({ procedures: [], lastDoc: null });
15852
15969
  }
15853
- const bounds = geohashQueryBounds5([location.latitude, location.longitude], radiusInKm * 1e3);
15970
+ const bounds = geohashQueryBounds5(
15971
+ [location.latitude, location.longitude],
15972
+ radiusInKm * 1e3
15973
+ );
15854
15974
  const fetches = bounds.map((b) => {
15855
15975
  const constraints = [
15856
15976
  where29("clinicInfo.location.geohash", ">=", b[0]),
15857
15977
  where29("clinicInfo.location.geohash", "<=", b[1]),
15858
- where29("isActive", "==", filters.isActive !== void 0 ? filters.isActive : true)
15978
+ where29(
15979
+ "isActive",
15980
+ "==",
15981
+ filters.isActive !== void 0 ? filters.isActive : true
15982
+ )
15859
15983
  ];
15860
- return getDocs29(query29(collection29(this.db, PROCEDURES_COLLECTION), ...constraints));
15984
+ return getDocs29(
15985
+ query29(collection29(this.db, PROCEDURES_COLLECTION), ...constraints)
15986
+ );
15861
15987
  });
15862
15988
  return Promise.all(fetches).then((snaps) => {
15863
15989
  const collected = [];
15864
15990
  snaps.forEach((snap) => {
15865
- snap.docs.forEach((d) => collected.push({ ...d.data(), id: d.id }));
15991
+ snap.docs.forEach(
15992
+ (d) => collected.push({ ...d.data(), id: d.id })
15993
+ );
15866
15994
  });
15867
15995
  const uniqueMap = /* @__PURE__ */ new Map();
15868
15996
  for (const p of collected) {
@@ -15873,7 +16001,9 @@ var ProcedureService = class extends BaseService {
15873
16001
  const pageSize = filters.pagination || 10;
15874
16002
  let startIndex = 0;
15875
16003
  if (filters.lastDoc && typeof filters.lastDoc === "object" && filters.lastDoc.id) {
15876
- const idx = procedures.findIndex((p) => p.id === filters.lastDoc.id);
16004
+ const idx = procedures.findIndex(
16005
+ (p) => p.id === filters.lastDoc.id
16006
+ );
15877
16007
  if (idx >= 0) startIndex = idx + 1;
15878
16008
  }
15879
16009
  const page = procedures.slice(startIndex, startIndex + pageSize);
@@ -15898,7 +16028,7 @@ var ProcedureService = class extends BaseService {
15898
16028
  * @returns The created procedure
15899
16029
  */
15900
16030
  async createConsultationProcedure(data) {
15901
- var _a;
16031
+ var _a, _b, _c;
15902
16032
  const procedureId = this.generateId();
15903
16033
  const [category, subcategory, technology] = await Promise.all([
15904
16034
  this.categoryService.getById(data.categoryId),
@@ -15914,7 +16044,11 @@ var ProcedureService = class extends BaseService {
15914
16044
  throw new Error(`Clinic with ID ${data.clinicBranchId} not found`);
15915
16045
  }
15916
16046
  const clinic = clinicSnapshot.data();
15917
- const practitionerRef = doc30(this.db, PRACTITIONERS_COLLECTION, data.practitionerId);
16047
+ const practitionerRef = doc30(
16048
+ this.db,
16049
+ PRACTITIONERS_COLLECTION,
16050
+ data.practitionerId
16051
+ );
15918
16052
  const practitionerSnapshot = await getDoc32(practitionerRef);
15919
16053
  if (!practitionerSnapshot.exists()) {
15920
16054
  throw new Error(`Practitioner with ID ${data.practitionerId} not found`);
@@ -15922,7 +16056,11 @@ var ProcedureService = class extends BaseService {
15922
16056
  const practitioner = practitionerSnapshot.data();
15923
16057
  let processedPhotos = [];
15924
16058
  if (data.photos && data.photos.length > 0) {
15925
- processedPhotos = await this.processMediaArray(data.photos, procedureId, "procedure-photos");
16059
+ processedPhotos = await this.processMediaArray(
16060
+ data.photos,
16061
+ procedureId,
16062
+ "procedure-photos"
16063
+ );
15926
16064
  }
15927
16065
  const clinicInfo = {
15928
16066
  id: clinicSnapshot.id,
@@ -15964,7 +16102,9 @@ var ProcedureService = class extends BaseService {
15964
16102
  // Use placeholder product
15965
16103
  blockingConditions: technology.blockingConditions,
15966
16104
  contraindications: technology.contraindications || [],
16105
+ contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
15967
16106
  treatmentBenefits: technology.benefits,
16107
+ treatmentBenefitIds: ((_c = technology.benefits) == null ? void 0 : _c.map((b) => b.id)) || [],
15968
16108
  preRequirements: technology.requirements.pre,
15969
16109
  postRequirements: technology.requirements.post,
15970
16110
  certificationRequirement: technology.certificationRequirement,
@@ -16833,8 +16973,16 @@ var TechnologyService = class extends BaseService {
16833
16973
  */
16834
16974
  async addContraindication(technologyId, contraindication) {
16835
16975
  const docRef = doc35(this.getTechnologiesRef(), technologyId);
16976
+ const technology = await this.getById(technologyId);
16977
+ if (!technology) {
16978
+ throw new Error(`Technology with id ${technologyId} not found`);
16979
+ }
16980
+ const existingContraindications = technology.contraindications || [];
16981
+ if (existingContraindications.some((c) => c.id === contraindication.id)) {
16982
+ return technology;
16983
+ }
16836
16984
  await updateDoc33(docRef, {
16837
- contraindications: arrayUnion9(contraindication),
16985
+ contraindications: [...existingContraindications, contraindication],
16838
16986
  updatedAt: /* @__PURE__ */ new Date()
16839
16987
  });
16840
16988
  return this.getById(technologyId);
@@ -16847,8 +16995,44 @@ var TechnologyService = class extends BaseService {
16847
16995
  */
16848
16996
  async removeContraindication(technologyId, contraindication) {
16849
16997
  const docRef = doc35(this.getTechnologiesRef(), technologyId);
16998
+ const technology = await this.getById(technologyId);
16999
+ if (!technology) {
17000
+ throw new Error(`Technology with id ${technologyId} not found`);
17001
+ }
17002
+ const updatedContraindications = (technology.contraindications || []).filter((c) => c.id !== contraindication.id);
17003
+ await updateDoc33(docRef, {
17004
+ contraindications: updatedContraindications,
17005
+ updatedAt: /* @__PURE__ */ new Date()
17006
+ });
17007
+ return this.getById(technologyId);
17008
+ }
17009
+ /**
17010
+ * Updates an existing contraindication in a technology's list.
17011
+ * If the contraindication does not exist, it will not be added.
17012
+ * @param technologyId - ID of the technology
17013
+ * @param contraindication - The updated contraindication object
17014
+ * @returns The updated technology
17015
+ */
17016
+ async updateContraindication(technologyId, contraindication) {
17017
+ const docRef = doc35(this.getTechnologiesRef(), technologyId);
17018
+ const technology = await this.getById(technologyId);
17019
+ if (!technology) {
17020
+ throw new Error(`Technology with id ${technologyId} not found`);
17021
+ }
17022
+ const contraindications = technology.contraindications || [];
17023
+ const index = contraindications.findIndex(
17024
+ (c) => c.id === contraindication.id
17025
+ );
17026
+ if (index === -1) {
17027
+ console.warn(
17028
+ `Contraindication with id ${contraindication.id} not found for technology ${technologyId}. No update performed.`
17029
+ );
17030
+ return technology;
17031
+ }
17032
+ const updatedContraindications = [...contraindications];
17033
+ updatedContraindications[index] = contraindication;
16850
17034
  await updateDoc33(docRef, {
16851
- contraindications: arrayRemove8(contraindication),
17035
+ contraindications: updatedContraindications,
16852
17036
  updatedAt: /* @__PURE__ */ new Date()
16853
17037
  });
16854
17038
  return this.getById(technologyId);
@@ -16861,8 +17045,16 @@ var TechnologyService = class extends BaseService {
16861
17045
  */
16862
17046
  async addBenefit(technologyId, benefit) {
16863
17047
  const docRef = doc35(this.getTechnologiesRef(), technologyId);
17048
+ const technology = await this.getById(technologyId);
17049
+ if (!technology) {
17050
+ throw new Error(`Technology with id ${technologyId} not found`);
17051
+ }
17052
+ const existingBenefits = technology.benefits || [];
17053
+ if (existingBenefits.some((b) => b.id === benefit.id)) {
17054
+ return technology;
17055
+ }
16864
17056
  await updateDoc33(docRef, {
16865
- benefits: arrayUnion9(benefit),
17057
+ benefits: [...existingBenefits, benefit],
16866
17058
  updatedAt: /* @__PURE__ */ new Date()
16867
17059
  });
16868
17060
  return this.getById(technologyId);
@@ -16875,8 +17067,44 @@ var TechnologyService = class extends BaseService {
16875
17067
  */
16876
17068
  async removeBenefit(technologyId, benefit) {
16877
17069
  const docRef = doc35(this.getTechnologiesRef(), technologyId);
17070
+ const technology = await this.getById(technologyId);
17071
+ if (!technology) {
17072
+ throw new Error(`Technology with id ${technologyId} not found`);
17073
+ }
17074
+ const updatedBenefits = (technology.benefits || []).filter(
17075
+ (b) => b.id !== benefit.id
17076
+ );
16878
17077
  await updateDoc33(docRef, {
16879
- benefits: arrayRemove8(benefit),
17078
+ benefits: updatedBenefits,
17079
+ updatedAt: /* @__PURE__ */ new Date()
17080
+ });
17081
+ return this.getById(technologyId);
17082
+ }
17083
+ /**
17084
+ * Updates an existing benefit in a technology's list.
17085
+ * If the benefit does not exist, it will not be added.
17086
+ * @param technologyId - ID of the technology
17087
+ * @param benefit - The updated benefit object
17088
+ * @returns The updated technology
17089
+ */
17090
+ async updateBenefit(technologyId, benefit) {
17091
+ const docRef = doc35(this.getTechnologiesRef(), technologyId);
17092
+ const technology = await this.getById(technologyId);
17093
+ if (!technology) {
17094
+ throw new Error(`Technology with id ${technologyId} not found`);
17095
+ }
17096
+ const benefits = technology.benefits || [];
17097
+ const index = benefits.findIndex((b) => b.id === benefit.id);
17098
+ if (index === -1) {
17099
+ console.warn(
17100
+ `Benefit with id ${benefit.id} not found for technology ${technologyId}. No update performed.`
17101
+ );
17102
+ return technology;
17103
+ }
17104
+ const updatedBenefits = [...benefits];
17105
+ updatedBenefits[index] = benefit;
17106
+ await updateDoc33(docRef, {
17107
+ benefits: updatedBenefits,
16880
17108
  updatedAt: /* @__PURE__ */ new Date()
16881
17109
  });
16882
17110
  return this.getById(technologyId);
@@ -17139,6 +17367,23 @@ var ProductService = class extends BaseService {
17139
17367
  }
17140
17368
  };
17141
17369
 
17370
+ // src/backoffice/types/static/contraindication.types.ts
17371
+ var Contraindication = /* @__PURE__ */ ((Contraindication2) => {
17372
+ Contraindication2["SENSITIVE_SKIN"] = "sensitive_skin";
17373
+ Contraindication2["RECENT_TANNING"] = "recent_tanning";
17374
+ Contraindication2["RECENT_BOTOX"] = "recent_botox";
17375
+ Contraindication2["RECENT_FILLERS"] = "recent_fillers";
17376
+ Contraindication2["SKIN_ALLERGIES"] = "skin_allergies";
17377
+ Contraindication2["MEDICATIONS"] = "medications";
17378
+ Contraindication2["RECENT_CHEMICAL_PEEL"] = "recent_chemical_peel";
17379
+ Contraindication2["RECENT_LASER"] = "recent_laser";
17380
+ Contraindication2["SKIN_INFLAMMATION"] = "skin_inflammation";
17381
+ Contraindication2["OPEN_WOUNDS"] = "open_wounds";
17382
+ Contraindication2["HERPES_SIMPLEX"] = "herpes_simplex";
17383
+ Contraindication2["COLD_SORES"] = "cold_sores";
17384
+ return Contraindication2;
17385
+ })(Contraindication || {});
17386
+
17142
17387
  // src/backoffice/types/static/treatment-benefit.types.ts
17143
17388
  var TreatmentBenefit = /* @__PURE__ */ ((TreatmentBenefit2) => {
17144
17389
  TreatmentBenefit2["WRINKLE_REDUCTION"] = "wrinkle_reduction";