@blackcode_sa/metaestetics-api 1.5.10 → 1.5.12

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
@@ -6419,11 +6419,7 @@ var ProcedureService = class extends BaseService {
6419
6419
  validatedData.categoryId,
6420
6420
  validatedData.subcategoryId
6421
6421
  ),
6422
- this.technologyService.getById(
6423
- validatedData.categoryId,
6424
- validatedData.subcategoryId,
6425
- validatedData.technologyId
6426
- ),
6422
+ this.technologyService.getById(validatedData.technologyId),
6427
6423
  this.productService.getById(
6428
6424
  validatedData.categoryId,
6429
6425
  validatedData.subcategoryId,
@@ -6535,6 +6531,48 @@ var ProcedureService = class extends BaseService {
6535
6531
  updatedAt: serverTimestamp13()
6536
6532
  });
6537
6533
  }
6534
+ /**
6535
+ * Gets all procedures that a practitioner is certified to perform
6536
+ * @param practitioner - The practitioner's profile
6537
+ * @returns Object containing:
6538
+ * - procedures: List of procedures the practitioner can perform
6539
+ * - families: List of procedure families the practitioner can perform
6540
+ * - categories: List of category IDs the practitioner can perform
6541
+ * - subcategories: List of subcategory IDs the practitioner can perform
6542
+ *
6543
+ * @example
6544
+ * const practitioner = {
6545
+ * certification: {
6546
+ * level: CertificationLevel.DOCTOR,
6547
+ * specialties: [CertificationSpecialty.INJECTABLES]
6548
+ * }
6549
+ * };
6550
+ * const allowedProcedures = await procedureService.getAllowedProcedures(practitioner);
6551
+ * console.log(allowedProcedures.families); // [ProcedureFamily.AESTHETICS]
6552
+ * console.log(allowedProcedures.categories); // ["category1", "category2"]
6553
+ * console.log(allowedProcedures.subcategories); // ["subcategory1", "subcategory2"]
6554
+ */
6555
+ async getAllowedProcedures(practitioner) {
6556
+ const { technologies, families, categories, subcategories } = await this.technologyService.getAllowedTechnologies(practitioner);
6557
+ const procedures = await Promise.all(
6558
+ technologies.map(async (technology) => {
6559
+ const q = query10(
6560
+ collection11(this.db, PROCEDURES_COLLECTION),
6561
+ where10("technologyId", "==", technology.id),
6562
+ where10("isActive", "==", true)
6563
+ );
6564
+ const snapshot = await getDocs10(q);
6565
+ return snapshot.docs.map((doc26) => doc26.data());
6566
+ })
6567
+ );
6568
+ const flattenedProcedures = procedures.flat();
6569
+ return {
6570
+ procedures: flattenedProcedures,
6571
+ families,
6572
+ categories,
6573
+ subcategories
6574
+ };
6575
+ }
6538
6576
  };
6539
6577
 
6540
6578
  // src/services/documentation-templates/documentation-template.service.ts
@@ -9881,60 +9919,97 @@ var DEFAULT_CERTIFICATION_REQUIREMENT = {
9881
9919
  };
9882
9920
  var TechnologyService = class extends BaseService {
9883
9921
  /**
9884
- * Vraća referencu na Firestore kolekciju tehnologija za određenu podkategoriju
9885
- * @param categoryId - ID kategorije
9886
- * @param subcategoryId - ID podkategorije
9922
+ * Vraća referencu na Firestore kolekciju tehnologija
9887
9923
  */
9888
- getTechnologiesRef(categoryId, subcategoryId) {
9889
- return collection22(
9890
- this.db,
9891
- CATEGORIES_COLLECTION,
9892
- categoryId,
9893
- SUBCATEGORIES_COLLECTION,
9894
- subcategoryId,
9895
- TECHNOLOGIES_COLLECTION
9896
- );
9924
+ getTechnologiesRef() {
9925
+ return collection22(this.db, TECHNOLOGIES_COLLECTION);
9897
9926
  }
9898
9927
  /**
9899
- * Kreira novu tehnologiju u okviru podkategorije
9900
- * @param categoryId - ID kategorije
9901
- * @param subcategoryId - ID podkategorije
9928
+ * Kreira novu tehnologiju
9902
9929
  * @param technology - Podaci za novu tehnologiju
9903
9930
  * @returns Kreirana tehnologija sa generisanim ID-em
9904
9931
  */
9905
- async create(categoryId, subcategoryId, technology) {
9932
+ async create(technology) {
9906
9933
  const now = /* @__PURE__ */ new Date();
9907
9934
  const newTechnology = {
9908
9935
  ...technology,
9909
- subcategoryId,
9910
9936
  createdAt: now,
9911
9937
  updatedAt: now,
9912
9938
  isActive: true,
9913
- requirements: {
9939
+ requirements: technology.requirements || {
9914
9940
  pre: [],
9915
9941
  post: []
9916
9942
  },
9917
- blockingConditions: [],
9918
- contraindications: [],
9919
- benefits: [],
9943
+ blockingConditions: technology.blockingConditions || [],
9944
+ contraindications: technology.contraindications || [],
9945
+ benefits: technology.benefits || [],
9920
9946
  certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
9921
9947
  };
9922
- const docRef = await addDoc7(
9923
- this.getTechnologiesRef(categoryId, subcategoryId),
9924
- newTechnology
9925
- );
9948
+ const docRef = await addDoc7(this.getTechnologiesRef(), newTechnology);
9926
9949
  return { id: docRef.id, ...newTechnology };
9927
9950
  }
9928
9951
  /**
9929
- * Vraća sve aktivne tehnologije za određenu podkategoriju
9952
+ * Vraća sve aktivne tehnologije
9953
+ * @returns Lista aktivnih tehnologija
9954
+ */
9955
+ async getAll() {
9956
+ const q = query21(this.getTechnologiesRef(), where21("isActive", "==", true));
9957
+ const snapshot = await getDocs21(q);
9958
+ return snapshot.docs.map(
9959
+ (doc26) => ({
9960
+ id: doc26.id,
9961
+ ...doc26.data()
9962
+ })
9963
+ );
9964
+ }
9965
+ /**
9966
+ * Vraća sve aktivne tehnologije za određenu familiju
9967
+ * @param family - Familija procedura
9968
+ * @returns Lista aktivnih tehnologija
9969
+ */
9970
+ async getAllByFamily(family) {
9971
+ const q = query21(
9972
+ this.getTechnologiesRef(),
9973
+ where21("isActive", "==", true),
9974
+ where21("family", "==", family)
9975
+ );
9976
+ const snapshot = await getDocs21(q);
9977
+ return snapshot.docs.map(
9978
+ (doc26) => ({
9979
+ id: doc26.id,
9980
+ ...doc26.data()
9981
+ })
9982
+ );
9983
+ }
9984
+ /**
9985
+ * Vraća sve aktivne tehnologije za određenu kategoriju
9930
9986
  * @param categoryId - ID kategorije
9987
+ * @returns Lista aktivnih tehnologija
9988
+ */
9989
+ async getAllByCategoryId(categoryId) {
9990
+ const q = query21(
9991
+ this.getTechnologiesRef(),
9992
+ where21("isActive", "==", true),
9993
+ where21("categoryId", "==", categoryId)
9994
+ );
9995
+ const snapshot = await getDocs21(q);
9996
+ return snapshot.docs.map(
9997
+ (doc26) => ({
9998
+ id: doc26.id,
9999
+ ...doc26.data()
10000
+ })
10001
+ );
10002
+ }
10003
+ /**
10004
+ * Vraća sve aktivne tehnologije za određenu podkategoriju
9931
10005
  * @param subcategoryId - ID podkategorije
9932
10006
  * @returns Lista aktivnih tehnologija
9933
10007
  */
9934
- async getAllBySubcategoryId(categoryId, subcategoryId) {
10008
+ async getAllBySubcategoryId(subcategoryId) {
9935
10009
  const q = query21(
9936
- this.getTechnologiesRef(categoryId, subcategoryId),
9937
- where21("isActive", "==", true)
10010
+ this.getTechnologiesRef(),
10011
+ where21("isActive", "==", true),
10012
+ where21("subcategoryId", "==", subcategoryId)
9938
10013
  );
9939
10014
  const snapshot = await getDocs21(q);
9940
10015
  return snapshot.docs.map(
@@ -9946,47 +10021,35 @@ var TechnologyService = class extends BaseService {
9946
10021
  }
9947
10022
  /**
9948
10023
  * Ažurira postojeću tehnologiju
9949
- * @param categoryId - ID kategorije
9950
- * @param subcategoryId - ID podkategorije
9951
10024
  * @param technologyId - ID tehnologije
9952
10025
  * @param technology - Novi podaci za tehnologiju
9953
10026
  * @returns Ažurirana tehnologija
9954
10027
  */
9955
- async update(categoryId, subcategoryId, technologyId, technology) {
10028
+ async update(technologyId, technology) {
9956
10029
  const updateData = {
9957
10030
  ...technology,
9958
10031
  updatedAt: /* @__PURE__ */ new Date()
9959
10032
  };
9960
- const docRef = doc24(
9961
- this.getTechnologiesRef(categoryId, subcategoryId),
9962
- technologyId
9963
- );
10033
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
9964
10034
  await updateDoc25(docRef, updateData);
9965
- return this.getById(categoryId, subcategoryId, technologyId);
10035
+ return this.getById(technologyId);
9966
10036
  }
9967
10037
  /**
9968
10038
  * Soft delete tehnologije (postavlja isActive na false)
9969
- * @param categoryId - ID kategorije
9970
- * @param subcategoryId - ID podkategorije
9971
10039
  * @param technologyId - ID tehnologije koja se briše
9972
10040
  */
9973
- async delete(categoryId, subcategoryId, technologyId) {
9974
- await this.update(categoryId, subcategoryId, technologyId, {
10041
+ async delete(technologyId) {
10042
+ await this.update(technologyId, {
9975
10043
  isActive: false
9976
10044
  });
9977
10045
  }
9978
10046
  /**
9979
10047
  * Vraća tehnologiju po ID-u
9980
- * @param categoryId - ID kategorije
9981
- * @param subcategoryId - ID podkategorije
9982
10048
  * @param technologyId - ID tražene tehnologije
9983
10049
  * @returns Tehnologija ili null ako ne postoji
9984
10050
  */
9985
- async getById(categoryId, subcategoryId, technologyId) {
9986
- const docRef = doc24(
9987
- this.getTechnologiesRef(categoryId, subcategoryId),
9988
- technologyId
9989
- );
10051
+ async getById(technologyId) {
10052
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
9990
10053
  const docSnap = await getDoc27(docRef);
9991
10054
  if (!docSnap.exists()) return null;
9992
10055
  return {
@@ -9996,58 +10059,42 @@ var TechnologyService = class extends BaseService {
9996
10059
  }
9997
10060
  /**
9998
10061
  * Dodaje novi zahtev tehnologiji
9999
- * @param categoryId - ID kategorije
10000
- * @param subcategoryId - ID podkategorije
10001
10062
  * @param technologyId - ID tehnologije
10002
10063
  * @param requirement - Zahtev koji se dodaje
10003
10064
  * @returns Ažurirana tehnologija sa novim zahtevom
10004
10065
  */
10005
- async addRequirement(categoryId, subcategoryId, technologyId, requirement) {
10006
- const docRef = doc24(
10007
- this.getTechnologiesRef(categoryId, subcategoryId),
10008
- technologyId
10009
- );
10066
+ async addRequirement(technologyId, requirement) {
10067
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10010
10068
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
10011
10069
  await updateDoc25(docRef, {
10012
10070
  [requirementType]: arrayUnion5(requirement),
10013
10071
  updatedAt: /* @__PURE__ */ new Date()
10014
10072
  });
10015
- return this.getById(categoryId, subcategoryId, technologyId);
10073
+ return this.getById(technologyId);
10016
10074
  }
10017
10075
  /**
10018
10076
  * Uklanja zahtev iz tehnologije
10019
- * @param categoryId - ID kategorije
10020
- * @param subcategoryId - ID podkategorije
10021
10077
  * @param technologyId - ID tehnologije
10022
10078
  * @param requirement - Zahtev koji se uklanja
10023
10079
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
10024
10080
  */
10025
- async removeRequirement(categoryId, subcategoryId, technologyId, requirement) {
10026
- const docRef = doc24(
10027
- this.getTechnologiesRef(categoryId, subcategoryId),
10028
- technologyId
10029
- );
10081
+ async removeRequirement(technologyId, requirement) {
10082
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10030
10083
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
10031
10084
  await updateDoc25(docRef, {
10032
10085
  [requirementType]: arrayRemove3(requirement),
10033
10086
  updatedAt: /* @__PURE__ */ new Date()
10034
10087
  });
10035
- return this.getById(categoryId, subcategoryId, technologyId);
10088
+ return this.getById(technologyId);
10036
10089
  }
10037
10090
  /**
10038
10091
  * Vraća sve zahteve za tehnologiju
10039
- * @param categoryId - ID kategorije
10040
- * @param subcategoryId - ID podkategorije
10041
10092
  * @param technologyId - ID tehnologije
10042
10093
  * @param type - Opcioni filter za tip zahteva (pre/post)
10043
10094
  * @returns Lista zahteva
10044
10095
  */
10045
- async getRequirements(categoryId, subcategoryId, technologyId, type) {
10046
- const technology = await this.getById(
10047
- categoryId,
10048
- subcategoryId,
10049
- technologyId
10050
- );
10096
+ async getRequirements(technologyId, type) {
10097
+ const technology = await this.getById(technologyId);
10051
10098
  if (!technology || !technology.requirements) return [];
10052
10099
  if (type) {
10053
10100
  return technology.requirements[type];
@@ -10056,220 +10103,231 @@ var TechnologyService = class extends BaseService {
10056
10103
  }
10057
10104
  /**
10058
10105
  * Ažurira postojeći zahtev
10059
- * @param categoryId - ID kategorije
10060
- * @param subcategoryId - ID podkategorije
10061
10106
  * @param technologyId - ID tehnologije
10062
10107
  * @param oldRequirement - Stari zahtev koji se menja
10063
10108
  * @param newRequirement - Novi zahtev koji zamenjuje stari
10064
10109
  * @returns Ažurirana tehnologija
10065
10110
  */
10066
- async updateRequirement(categoryId, subcategoryId, technologyId, oldRequirement, newRequirement) {
10067
- await this.removeRequirement(
10068
- categoryId,
10069
- subcategoryId,
10070
- technologyId,
10071
- oldRequirement
10072
- );
10073
- return this.addRequirement(
10074
- categoryId,
10075
- subcategoryId,
10076
- technologyId,
10077
- newRequirement
10078
- );
10111
+ async updateRequirement(technologyId, oldRequirement, newRequirement) {
10112
+ await this.removeRequirement(technologyId, oldRequirement);
10113
+ return this.addRequirement(technologyId, newRequirement);
10079
10114
  }
10080
10115
  /**
10081
10116
  * Dodaje blokirajući uslov tehnologiji
10082
- * @param categoryId - ID kategorije
10083
- * @param subcategoryId - ID podkategorije
10084
10117
  * @param technologyId - ID tehnologije
10085
10118
  * @param condition - Blokirajući uslov koji se dodaje
10086
10119
  * @returns Ažurirana tehnologija
10087
10120
  */
10088
- async addBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
10089
- const docRef = doc24(
10090
- this.getTechnologiesRef(categoryId, subcategoryId),
10091
- technologyId
10092
- );
10121
+ async addBlockingCondition(technologyId, condition) {
10122
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10093
10123
  await updateDoc25(docRef, {
10094
10124
  blockingConditions: arrayUnion5(condition),
10095
10125
  updatedAt: /* @__PURE__ */ new Date()
10096
10126
  });
10097
- return this.getById(categoryId, subcategoryId, technologyId);
10127
+ return this.getById(technologyId);
10098
10128
  }
10099
10129
  /**
10100
10130
  * Uklanja blokirajući uslov iz tehnologije
10101
- * @param categoryId - ID kategorije
10102
- * @param subcategoryId - ID podkategorije
10103
10131
  * @param technologyId - ID tehnologije
10104
10132
  * @param condition - Blokirajući uslov koji se uklanja
10105
10133
  * @returns Ažurirana tehnologija
10106
10134
  */
10107
- async removeBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
10108
- const docRef = doc24(
10109
- this.getTechnologiesRef(categoryId, subcategoryId),
10110
- technologyId
10111
- );
10135
+ async removeBlockingCondition(technologyId, condition) {
10136
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10112
10137
  await updateDoc25(docRef, {
10113
10138
  blockingConditions: arrayRemove3(condition),
10114
10139
  updatedAt: /* @__PURE__ */ new Date()
10115
10140
  });
10116
- return this.getById(categoryId, subcategoryId, technologyId);
10141
+ return this.getById(technologyId);
10117
10142
  }
10118
10143
  /**
10119
10144
  * Dodaje kontraindikaciju tehnologiji
10120
- * @param categoryId - ID kategorije
10121
- * @param subcategoryId - ID podkategorije
10122
10145
  * @param technologyId - ID tehnologije
10123
10146
  * @param contraindication - Kontraindikacija koja se dodaje
10124
10147
  * @returns Ažurirana tehnologija
10125
10148
  */
10126
- async addContraindication(categoryId, subcategoryId, technologyId, contraindication) {
10127
- const docRef = doc24(
10128
- this.getTechnologiesRef(categoryId, subcategoryId),
10129
- technologyId
10130
- );
10149
+ async addContraindication(technologyId, contraindication) {
10150
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10131
10151
  await updateDoc25(docRef, {
10132
10152
  contraindications: arrayUnion5(contraindication),
10133
10153
  updatedAt: /* @__PURE__ */ new Date()
10134
10154
  });
10135
- return this.getById(categoryId, subcategoryId, technologyId);
10155
+ return this.getById(technologyId);
10136
10156
  }
10137
10157
  /**
10138
10158
  * Uklanja kontraindikaciju iz tehnologije
10139
- * @param categoryId - ID kategorije
10140
- * @param subcategoryId - ID podkategorije
10141
10159
  * @param technologyId - ID tehnologije
10142
10160
  * @param contraindication - Kontraindikacija koja se uklanja
10143
10161
  * @returns Ažurirana tehnologija
10144
10162
  */
10145
- async removeContraindication(categoryId, subcategoryId, technologyId, contraindication) {
10146
- const docRef = doc24(
10147
- this.getTechnologiesRef(categoryId, subcategoryId),
10148
- technologyId
10149
- );
10163
+ async removeContraindication(technologyId, contraindication) {
10164
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10150
10165
  await updateDoc25(docRef, {
10151
10166
  contraindications: arrayRemove3(contraindication),
10152
10167
  updatedAt: /* @__PURE__ */ new Date()
10153
10168
  });
10154
- return this.getById(categoryId, subcategoryId, technologyId);
10169
+ return this.getById(technologyId);
10155
10170
  }
10156
10171
  /**
10157
10172
  * Dodaje benefit tehnologiji
10158
- * @param categoryId - ID kategorije
10159
- * @param subcategoryId - ID podkategorije
10160
10173
  * @param technologyId - ID tehnologije
10161
10174
  * @param benefit - Benefit koji se dodaje
10162
10175
  * @returns Ažurirana tehnologija
10163
10176
  */
10164
- async addBenefit(categoryId, subcategoryId, technologyId, benefit) {
10165
- const docRef = doc24(
10166
- this.getTechnologiesRef(categoryId, subcategoryId),
10167
- technologyId
10168
- );
10177
+ async addBenefit(technologyId, benefit) {
10178
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10169
10179
  await updateDoc25(docRef, {
10170
10180
  benefits: arrayUnion5(benefit),
10171
10181
  updatedAt: /* @__PURE__ */ new Date()
10172
10182
  });
10173
- return this.getById(categoryId, subcategoryId, technologyId);
10183
+ return this.getById(technologyId);
10174
10184
  }
10175
10185
  /**
10176
10186
  * Uklanja benefit iz tehnologije
10177
- * @param categoryId - ID kategorije
10178
- * @param subcategoryId - ID podkategorije
10179
10187
  * @param technologyId - ID tehnologije
10180
10188
  * @param benefit - Benefit koji se uklanja
10181
10189
  * @returns Ažurirana tehnologija
10182
10190
  */
10183
- async removeBenefit(categoryId, subcategoryId, technologyId, benefit) {
10184
- const docRef = doc24(
10185
- this.getTechnologiesRef(categoryId, subcategoryId),
10186
- technologyId
10187
- );
10191
+ async removeBenefit(technologyId, benefit) {
10192
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10188
10193
  await updateDoc25(docRef, {
10189
10194
  benefits: arrayRemove3(benefit),
10190
10195
  updatedAt: /* @__PURE__ */ new Date()
10191
10196
  });
10192
- return this.getById(categoryId, subcategoryId, technologyId);
10197
+ return this.getById(technologyId);
10193
10198
  }
10194
10199
  /**
10195
10200
  * Vraća sve blokirajuće uslove za tehnologiju
10196
- * @param categoryId - ID kategorije
10197
- * @param subcategoryId - ID podkategorije
10198
10201
  * @param technologyId - ID tehnologije
10199
10202
  * @returns Lista blokirajućih uslova
10200
10203
  */
10201
- async getBlockingConditions(categoryId, subcategoryId, technologyId) {
10202
- const technology = await this.getById(
10203
- categoryId,
10204
- subcategoryId,
10205
- technologyId
10206
- );
10204
+ async getBlockingConditions(technologyId) {
10205
+ const technology = await this.getById(technologyId);
10207
10206
  return (technology == null ? void 0 : technology.blockingConditions) || [];
10208
10207
  }
10209
10208
  /**
10210
10209
  * Vraća sve kontraindikacije za tehnologiju
10211
- * @param categoryId - ID kategorije
10212
- * @param subcategoryId - ID podkategorije
10213
10210
  * @param technologyId - ID tehnologije
10214
10211
  * @returns Lista kontraindikacija
10215
10212
  */
10216
- async getContraindications(categoryId, subcategoryId, technologyId) {
10217
- const technology = await this.getById(
10218
- categoryId,
10219
- subcategoryId,
10220
- technologyId
10221
- );
10213
+ async getContraindications(technologyId) {
10214
+ const technology = await this.getById(technologyId);
10222
10215
  return (technology == null ? void 0 : technology.contraindications) || [];
10223
10216
  }
10224
10217
  /**
10225
10218
  * Vraća sve benefite za tehnologiju
10226
- * @param categoryId - ID kategorije
10227
- * @param subcategoryId - ID podkategorije
10228
10219
  * @param technologyId - ID tehnologije
10229
10220
  * @returns Lista benefita
10230
10221
  */
10231
- async getBenefits(categoryId, subcategoryId, technologyId) {
10232
- const technology = await this.getById(
10233
- categoryId,
10234
- subcategoryId,
10235
- technologyId
10236
- );
10222
+ async getBenefits(technologyId) {
10223
+ const technology = await this.getById(technologyId);
10237
10224
  return (technology == null ? void 0 : technology.benefits) || [];
10238
10225
  }
10239
10226
  /**
10240
10227
  * Ažurira zahteve sertifikacije za tehnologiju
10241
- * @param categoryId - ID kategorije
10242
- * @param subcategoryId - ID podkategorije
10243
10228
  * @param technologyId - ID tehnologije
10244
10229
  * @param certificationRequirement - Novi zahtevi sertifikacije
10245
10230
  * @returns Ažurirana tehnologija
10246
10231
  */
10247
- async updateCertificationRequirement(categoryId, subcategoryId, technologyId, certificationRequirement) {
10248
- const docRef = doc24(
10249
- this.getTechnologiesRef(categoryId, subcategoryId),
10250
- technologyId
10251
- );
10232
+ async updateCertificationRequirement(technologyId, certificationRequirement) {
10233
+ const docRef = doc24(this.getTechnologiesRef(), technologyId);
10252
10234
  await updateDoc25(docRef, {
10253
10235
  certificationRequirement,
10254
10236
  updatedAt: /* @__PURE__ */ new Date()
10255
10237
  });
10256
- return this.getById(categoryId, subcategoryId, technologyId);
10238
+ return this.getById(technologyId);
10257
10239
  }
10258
10240
  /**
10259
10241
  * Vraća zahteve sertifikacije za tehnologiju
10260
- * @param categoryId - ID kategorije
10261
- * @param subcategoryId - ID podkategorije
10262
10242
  * @param technologyId - ID tehnologije
10263
10243
  * @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
10264
10244
  */
10265
- async getCertificationRequirement(categoryId, subcategoryId, technologyId) {
10266
- const technology = await this.getById(
10267
- categoryId,
10268
- subcategoryId,
10269
- technologyId
10270
- );
10245
+ async getCertificationRequirement(technologyId) {
10246
+ const technology = await this.getById(technologyId);
10271
10247
  return (technology == null ? void 0 : technology.certificationRequirement) || null;
10272
10248
  }
10249
+ /**
10250
+ * Proverava da li doktor ima odgovarajuću sertifikaciju za izvođenje tehnologije
10251
+ *
10252
+ * @param requiredCertification - Zahtevana sertifikacija za tehnologiju
10253
+ * @param practitionerCertification - Sertifikacija zdravstvenog radnika
10254
+ * @returns true ako zdravstveni radnik ima odgovarajuću sertifikaciju, false ako nema
10255
+ *
10256
+ * @example
10257
+ * const isValid = technologyService.validateCertification(
10258
+ * {
10259
+ * minimumLevel: CertificationLevel.DOCTOR,
10260
+ * requiredSpecialties: [CertificationSpecialty.INJECTABLES]
10261
+ * },
10262
+ * {
10263
+ * level: CertificationLevel.SPECIALIST,
10264
+ * specialties: [CertificationSpecialty.INJECTABLES, CertificationSpecialty.LASER]
10265
+ * }
10266
+ * );
10267
+ */
10268
+ validateCertification(requiredCertification, practitionerCertification) {
10269
+ const doctorLevel = Object.values(CertificationLevel).indexOf(
10270
+ practitionerCertification.level
10271
+ );
10272
+ const requiredLevel = Object.values(CertificationLevel).indexOf(
10273
+ requiredCertification.minimumLevel
10274
+ );
10275
+ if (doctorLevel < requiredLevel) return false;
10276
+ const requiredSpecialties = requiredCertification.requiredSpecialties || [];
10277
+ if (requiredSpecialties.length > 0) {
10278
+ const doctorSpecialties = practitionerCertification.specialties;
10279
+ const hasAllRequiredSpecialties = requiredSpecialties.every(
10280
+ (requiredSpecialty) => doctorSpecialties.includes(requiredSpecialty)
10281
+ );
10282
+ if (!hasAllRequiredSpecialties) return false;
10283
+ }
10284
+ return true;
10285
+ }
10286
+ /**
10287
+ * Vraća sve tehnologije koje je zdravstveni radnik sertifikovan da izvodi
10288
+ * zajedno sa listama dozvoljenih familija, kategorija i podkategorija
10289
+ *
10290
+ * @param practitioner - Profil zdravstvenog radnika
10291
+ * @returns Objekat koji sadrži:
10292
+ * - technologies: Lista tehnologija koje zdravstveni radnik može da izvodi
10293
+ * - families: Lista familija procedura koje zdravstveni radnik može da izvodi
10294
+ * - categories: Lista ID-eva kategorija koje zdravstveni radnik može da izvodi
10295
+ * - subcategories: Lista ID-eva podkategorija koje zdravstveni radnik može da izvodi
10296
+ *
10297
+ * @example
10298
+ * const practitioner = {
10299
+ * certification: {
10300
+ * level: CertificationLevel.DOCTOR,
10301
+ * specialties: [CertificationSpecialty.INJECTABLES]
10302
+ * }
10303
+ * };
10304
+ * const allowedTechnologies = await technologyService.getAllowedTechnologies(practitioner);
10305
+ * console.log(allowedTechnologies.families); // [ProcedureFamily.AESTHETICS]
10306
+ * console.log(allowedTechnologies.categories); // ["category1", "category2"]
10307
+ * console.log(allowedTechnologies.subcategories); // ["subcategory1", "subcategory2"]
10308
+ */
10309
+ async getAllowedTechnologies(practitioner) {
10310
+ const allTechnologies = await this.getAll();
10311
+ const allowedTechnologies = allTechnologies.filter(
10312
+ (technology) => this.validateCertification(
10313
+ technology.certificationRequirement,
10314
+ practitioner.certification
10315
+ )
10316
+ );
10317
+ const families = [...new Set(allowedTechnologies.map((t) => t.family))];
10318
+ const categories = [
10319
+ ...new Set(allowedTechnologies.map((t) => t.categoryId))
10320
+ ];
10321
+ const subcategories = [
10322
+ ...new Set(allowedTechnologies.map((t) => t.subcategoryId))
10323
+ ];
10324
+ return {
10325
+ technologies: allowedTechnologies,
10326
+ families,
10327
+ categories,
10328
+ subcategories
10329
+ };
10330
+ }
10273
10331
  };
10274
10332
 
10275
10333
  // src/backoffice/services/product.service.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.5.10",
4
+ "version": "1.5.12",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",