@blackcode_sa/metaestetics-api 1.5.9 → 1.5.11

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.
@@ -752,60 +752,97 @@ var DEFAULT_CERTIFICATION_REQUIREMENT2 = {
752
752
  };
753
753
  var TechnologyService = class extends BaseService {
754
754
  /**
755
- * Vraća referencu na Firestore kolekciju tehnologija za određenu podkategoriju
756
- * @param categoryId - ID kategorije
757
- * @param subcategoryId - ID podkategorije
755
+ * Vraća referencu na Firestore kolekciju tehnologija
758
756
  */
759
- getTechnologiesRef(categoryId, subcategoryId) {
760
- return collection3(
761
- this.db,
762
- CATEGORIES_COLLECTION,
763
- categoryId,
764
- SUBCATEGORIES_COLLECTION,
765
- subcategoryId,
766
- TECHNOLOGIES_COLLECTION
767
- );
757
+ getTechnologiesRef() {
758
+ return collection3(this.db, TECHNOLOGIES_COLLECTION);
768
759
  }
769
760
  /**
770
- * Kreira novu tehnologiju u okviru podkategorije
771
- * @param categoryId - ID kategorije
772
- * @param subcategoryId - ID podkategorije
761
+ * Kreira novu tehnologiju
773
762
  * @param technology - Podaci za novu tehnologiju
774
763
  * @returns Kreirana tehnologija sa generisanim ID-em
775
764
  */
776
- async create(categoryId, subcategoryId, technology) {
765
+ async create(technology) {
777
766
  const now = /* @__PURE__ */ new Date();
778
767
  const newTechnology = {
779
768
  ...technology,
780
- subcategoryId,
781
769
  createdAt: now,
782
770
  updatedAt: now,
783
771
  isActive: true,
784
- requirements: {
772
+ requirements: technology.requirements || {
785
773
  pre: [],
786
774
  post: []
787
775
  },
788
- blockingConditions: [],
789
- contraindications: [],
790
- benefits: [],
776
+ blockingConditions: technology.blockingConditions || [],
777
+ contraindications: technology.contraindications || [],
778
+ benefits: technology.benefits || [],
791
779
  certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT2
792
780
  };
793
- const docRef = await addDoc3(
794
- this.getTechnologiesRef(categoryId, subcategoryId),
795
- newTechnology
796
- );
781
+ const docRef = await addDoc3(this.getTechnologiesRef(), newTechnology);
797
782
  return { id: docRef.id, ...newTechnology };
798
783
  }
799
784
  /**
800
- * Vraća sve aktivne tehnologije za određenu podkategoriju
785
+ * Vraća sve aktivne tehnologije
786
+ * @returns Lista aktivnih tehnologija
787
+ */
788
+ async getAll() {
789
+ const q = query3(this.getTechnologiesRef(), where3("isActive", "==", true));
790
+ const snapshot = await getDocs3(q);
791
+ return snapshot.docs.map(
792
+ (doc9) => ({
793
+ id: doc9.id,
794
+ ...doc9.data()
795
+ })
796
+ );
797
+ }
798
+ /**
799
+ * Vraća sve aktivne tehnologije za određenu familiju
800
+ * @param family - Familija procedura
801
+ * @returns Lista aktivnih tehnologija
802
+ */
803
+ async getAllByFamily(family) {
804
+ const q = query3(
805
+ this.getTechnologiesRef(),
806
+ where3("isActive", "==", true),
807
+ where3("family", "==", family)
808
+ );
809
+ const snapshot = await getDocs3(q);
810
+ return snapshot.docs.map(
811
+ (doc9) => ({
812
+ id: doc9.id,
813
+ ...doc9.data()
814
+ })
815
+ );
816
+ }
817
+ /**
818
+ * Vraća sve aktivne tehnologije za određenu kategoriju
801
819
  * @param categoryId - ID kategorije
820
+ * @returns Lista aktivnih tehnologija
821
+ */
822
+ async getAllByCategoryId(categoryId) {
823
+ const q = query3(
824
+ this.getTechnologiesRef(),
825
+ where3("isActive", "==", true),
826
+ where3("categoryId", "==", categoryId)
827
+ );
828
+ const snapshot = await getDocs3(q);
829
+ return snapshot.docs.map(
830
+ (doc9) => ({
831
+ id: doc9.id,
832
+ ...doc9.data()
833
+ })
834
+ );
835
+ }
836
+ /**
837
+ * Vraća sve aktivne tehnologije za određenu podkategoriju
802
838
  * @param subcategoryId - ID podkategorije
803
839
  * @returns Lista aktivnih tehnologija
804
840
  */
805
- async getAllBySubcategoryId(categoryId, subcategoryId) {
841
+ async getAllBySubcategoryId(subcategoryId) {
806
842
  const q = query3(
807
- this.getTechnologiesRef(categoryId, subcategoryId),
808
- where3("isActive", "==", true)
843
+ this.getTechnologiesRef(),
844
+ where3("isActive", "==", true),
845
+ where3("subcategoryId", "==", subcategoryId)
809
846
  );
810
847
  const snapshot = await getDocs3(q);
811
848
  return snapshot.docs.map(
@@ -817,47 +854,35 @@ var TechnologyService = class extends BaseService {
817
854
  }
818
855
  /**
819
856
  * Ažurira postojeću tehnologiju
820
- * @param categoryId - ID kategorije
821
- * @param subcategoryId - ID podkategorije
822
857
  * @param technologyId - ID tehnologije
823
858
  * @param technology - Novi podaci za tehnologiju
824
859
  * @returns Ažurirana tehnologija
825
860
  */
826
- async update(categoryId, subcategoryId, technologyId, technology) {
861
+ async update(technologyId, technology) {
827
862
  const updateData = {
828
863
  ...technology,
829
864
  updatedAt: /* @__PURE__ */ new Date()
830
865
  };
831
- const docRef = doc3(
832
- this.getTechnologiesRef(categoryId, subcategoryId),
833
- technologyId
834
- );
866
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
835
867
  await updateDoc3(docRef, updateData);
836
- return this.getById(categoryId, subcategoryId, technologyId);
868
+ return this.getById(technologyId);
837
869
  }
838
870
  /**
839
871
  * Soft delete tehnologije (postavlja isActive na false)
840
- * @param categoryId - ID kategorije
841
- * @param subcategoryId - ID podkategorije
842
872
  * @param technologyId - ID tehnologije koja se briše
843
873
  */
844
- async delete(categoryId, subcategoryId, technologyId) {
845
- await this.update(categoryId, subcategoryId, technologyId, {
874
+ async delete(technologyId) {
875
+ await this.update(technologyId, {
846
876
  isActive: false
847
877
  });
848
878
  }
849
879
  /**
850
880
  * Vraća tehnologiju po ID-u
851
- * @param categoryId - ID kategorije
852
- * @param subcategoryId - ID podkategorije
853
881
  * @param technologyId - ID tražene tehnologije
854
882
  * @returns Tehnologija ili null ako ne postoji
855
883
  */
856
- async getById(categoryId, subcategoryId, technologyId) {
857
- const docRef = doc3(
858
- this.getTechnologiesRef(categoryId, subcategoryId),
859
- technologyId
860
- );
884
+ async getById(technologyId) {
885
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
861
886
  const docSnap = await getDoc3(docRef);
862
887
  if (!docSnap.exists()) return null;
863
888
  return {
@@ -867,58 +892,42 @@ var TechnologyService = class extends BaseService {
867
892
  }
868
893
  /**
869
894
  * Dodaje novi zahtev tehnologiji
870
- * @param categoryId - ID kategorije
871
- * @param subcategoryId - ID podkategorije
872
895
  * @param technologyId - ID tehnologije
873
896
  * @param requirement - Zahtev koji se dodaje
874
897
  * @returns Ažurirana tehnologija sa novim zahtevom
875
898
  */
876
- async addRequirement(categoryId, subcategoryId, technologyId, requirement) {
877
- const docRef = doc3(
878
- this.getTechnologiesRef(categoryId, subcategoryId),
879
- technologyId
880
- );
899
+ async addRequirement(technologyId, requirement) {
900
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
881
901
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
882
902
  await updateDoc3(docRef, {
883
903
  [requirementType]: arrayUnion(requirement),
884
904
  updatedAt: /* @__PURE__ */ new Date()
885
905
  });
886
- return this.getById(categoryId, subcategoryId, technologyId);
906
+ return this.getById(technologyId);
887
907
  }
888
908
  /**
889
909
  * Uklanja zahtev iz tehnologije
890
- * @param categoryId - ID kategorije
891
- * @param subcategoryId - ID podkategorije
892
910
  * @param technologyId - ID tehnologije
893
911
  * @param requirement - Zahtev koji se uklanja
894
912
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
895
913
  */
896
- async removeRequirement(categoryId, subcategoryId, technologyId, requirement) {
897
- const docRef = doc3(
898
- this.getTechnologiesRef(categoryId, subcategoryId),
899
- technologyId
900
- );
914
+ async removeRequirement(technologyId, requirement) {
915
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
901
916
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
902
917
  await updateDoc3(docRef, {
903
918
  [requirementType]: arrayRemove(requirement),
904
919
  updatedAt: /* @__PURE__ */ new Date()
905
920
  });
906
- return this.getById(categoryId, subcategoryId, technologyId);
921
+ return this.getById(technologyId);
907
922
  }
908
923
  /**
909
924
  * Vraća sve zahteve za tehnologiju
910
- * @param categoryId - ID kategorije
911
- * @param subcategoryId - ID podkategorije
912
925
  * @param technologyId - ID tehnologije
913
926
  * @param type - Opcioni filter za tip zahteva (pre/post)
914
927
  * @returns Lista zahteva
915
928
  */
916
- async getRequirements(categoryId, subcategoryId, technologyId, type) {
917
- const technology = await this.getById(
918
- categoryId,
919
- subcategoryId,
920
- technologyId
921
- );
929
+ async getRequirements(technologyId, type) {
930
+ const technology = await this.getById(technologyId);
922
931
  if (!technology || !technology.requirements) return [];
923
932
  if (type) {
924
933
  return technology.requirements[type];
@@ -927,220 +936,231 @@ var TechnologyService = class extends BaseService {
927
936
  }
928
937
  /**
929
938
  * Ažurira postojeći zahtev
930
- * @param categoryId - ID kategorije
931
- * @param subcategoryId - ID podkategorije
932
939
  * @param technologyId - ID tehnologije
933
940
  * @param oldRequirement - Stari zahtev koji se menja
934
941
  * @param newRequirement - Novi zahtev koji zamenjuje stari
935
942
  * @returns Ažurirana tehnologija
936
943
  */
937
- async updateRequirement(categoryId, subcategoryId, technologyId, oldRequirement, newRequirement) {
938
- await this.removeRequirement(
939
- categoryId,
940
- subcategoryId,
941
- technologyId,
942
- oldRequirement
943
- );
944
- return this.addRequirement(
945
- categoryId,
946
- subcategoryId,
947
- technologyId,
948
- newRequirement
949
- );
944
+ async updateRequirement(technologyId, oldRequirement, newRequirement) {
945
+ await this.removeRequirement(technologyId, oldRequirement);
946
+ return this.addRequirement(technologyId, newRequirement);
950
947
  }
951
948
  /**
952
949
  * Dodaje blokirajući uslov tehnologiji
953
- * @param categoryId - ID kategorije
954
- * @param subcategoryId - ID podkategorije
955
950
  * @param technologyId - ID tehnologije
956
951
  * @param condition - Blokirajući uslov koji se dodaje
957
952
  * @returns Ažurirana tehnologija
958
953
  */
959
- async addBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
960
- const docRef = doc3(
961
- this.getTechnologiesRef(categoryId, subcategoryId),
962
- technologyId
963
- );
954
+ async addBlockingCondition(technologyId, condition) {
955
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
964
956
  await updateDoc3(docRef, {
965
957
  blockingConditions: arrayUnion(condition),
966
958
  updatedAt: /* @__PURE__ */ new Date()
967
959
  });
968
- return this.getById(categoryId, subcategoryId, technologyId);
960
+ return this.getById(technologyId);
969
961
  }
970
962
  /**
971
963
  * Uklanja blokirajući uslov iz tehnologije
972
- * @param categoryId - ID kategorije
973
- * @param subcategoryId - ID podkategorije
974
964
  * @param technologyId - ID tehnologije
975
965
  * @param condition - Blokirajući uslov koji se uklanja
976
966
  * @returns Ažurirana tehnologija
977
967
  */
978
- async removeBlockingCondition(categoryId, subcategoryId, technologyId, condition) {
979
- const docRef = doc3(
980
- this.getTechnologiesRef(categoryId, subcategoryId),
981
- technologyId
982
- );
968
+ async removeBlockingCondition(technologyId, condition) {
969
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
983
970
  await updateDoc3(docRef, {
984
971
  blockingConditions: arrayRemove(condition),
985
972
  updatedAt: /* @__PURE__ */ new Date()
986
973
  });
987
- return this.getById(categoryId, subcategoryId, technologyId);
974
+ return this.getById(technologyId);
988
975
  }
989
976
  /**
990
977
  * Dodaje kontraindikaciju tehnologiji
991
- * @param categoryId - ID kategorije
992
- * @param subcategoryId - ID podkategorije
993
978
  * @param technologyId - ID tehnologije
994
979
  * @param contraindication - Kontraindikacija koja se dodaje
995
980
  * @returns Ažurirana tehnologija
996
981
  */
997
- async addContraindication(categoryId, subcategoryId, technologyId, contraindication) {
998
- const docRef = doc3(
999
- this.getTechnologiesRef(categoryId, subcategoryId),
1000
- technologyId
1001
- );
982
+ async addContraindication(technologyId, contraindication) {
983
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
1002
984
  await updateDoc3(docRef, {
1003
985
  contraindications: arrayUnion(contraindication),
1004
986
  updatedAt: /* @__PURE__ */ new Date()
1005
987
  });
1006
- return this.getById(categoryId, subcategoryId, technologyId);
988
+ return this.getById(technologyId);
1007
989
  }
1008
990
  /**
1009
991
  * Uklanja kontraindikaciju iz tehnologije
1010
- * @param categoryId - ID kategorije
1011
- * @param subcategoryId - ID podkategorije
1012
992
  * @param technologyId - ID tehnologije
1013
993
  * @param contraindication - Kontraindikacija koja se uklanja
1014
994
  * @returns Ažurirana tehnologija
1015
995
  */
1016
- async removeContraindication(categoryId, subcategoryId, technologyId, contraindication) {
1017
- const docRef = doc3(
1018
- this.getTechnologiesRef(categoryId, subcategoryId),
1019
- technologyId
1020
- );
996
+ async removeContraindication(technologyId, contraindication) {
997
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
1021
998
  await updateDoc3(docRef, {
1022
999
  contraindications: arrayRemove(contraindication),
1023
1000
  updatedAt: /* @__PURE__ */ new Date()
1024
1001
  });
1025
- return this.getById(categoryId, subcategoryId, technologyId);
1002
+ return this.getById(technologyId);
1026
1003
  }
1027
1004
  /**
1028
1005
  * Dodaje benefit tehnologiji
1029
- * @param categoryId - ID kategorije
1030
- * @param subcategoryId - ID podkategorije
1031
1006
  * @param technologyId - ID tehnologije
1032
1007
  * @param benefit - Benefit koji se dodaje
1033
1008
  * @returns Ažurirana tehnologija
1034
1009
  */
1035
- async addBenefit(categoryId, subcategoryId, technologyId, benefit) {
1036
- const docRef = doc3(
1037
- this.getTechnologiesRef(categoryId, subcategoryId),
1038
- technologyId
1039
- );
1010
+ async addBenefit(technologyId, benefit) {
1011
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
1040
1012
  await updateDoc3(docRef, {
1041
1013
  benefits: arrayUnion(benefit),
1042
1014
  updatedAt: /* @__PURE__ */ new Date()
1043
1015
  });
1044
- return this.getById(categoryId, subcategoryId, technologyId);
1016
+ return this.getById(technologyId);
1045
1017
  }
1046
1018
  /**
1047
1019
  * Uklanja benefit iz tehnologije
1048
- * @param categoryId - ID kategorije
1049
- * @param subcategoryId - ID podkategorije
1050
1020
  * @param technologyId - ID tehnologije
1051
1021
  * @param benefit - Benefit koji se uklanja
1052
1022
  * @returns Ažurirana tehnologija
1053
1023
  */
1054
- async removeBenefit(categoryId, subcategoryId, technologyId, benefit) {
1055
- const docRef = doc3(
1056
- this.getTechnologiesRef(categoryId, subcategoryId),
1057
- technologyId
1058
- );
1024
+ async removeBenefit(technologyId, benefit) {
1025
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
1059
1026
  await updateDoc3(docRef, {
1060
1027
  benefits: arrayRemove(benefit),
1061
1028
  updatedAt: /* @__PURE__ */ new Date()
1062
1029
  });
1063
- return this.getById(categoryId, subcategoryId, technologyId);
1030
+ return this.getById(technologyId);
1064
1031
  }
1065
1032
  /**
1066
1033
  * Vraća sve blokirajuće uslove za tehnologiju
1067
- * @param categoryId - ID kategorije
1068
- * @param subcategoryId - ID podkategorije
1069
1034
  * @param technologyId - ID tehnologije
1070
1035
  * @returns Lista blokirajućih uslova
1071
1036
  */
1072
- async getBlockingConditions(categoryId, subcategoryId, technologyId) {
1073
- const technology = await this.getById(
1074
- categoryId,
1075
- subcategoryId,
1076
- technologyId
1077
- );
1037
+ async getBlockingConditions(technologyId) {
1038
+ const technology = await this.getById(technologyId);
1078
1039
  return (technology == null ? void 0 : technology.blockingConditions) || [];
1079
1040
  }
1080
1041
  /**
1081
1042
  * Vraća sve kontraindikacije za tehnologiju
1082
- * @param categoryId - ID kategorije
1083
- * @param subcategoryId - ID podkategorije
1084
1043
  * @param technologyId - ID tehnologije
1085
1044
  * @returns Lista kontraindikacija
1086
1045
  */
1087
- async getContraindications(categoryId, subcategoryId, technologyId) {
1088
- const technology = await this.getById(
1089
- categoryId,
1090
- subcategoryId,
1091
- technologyId
1092
- );
1046
+ async getContraindications(technologyId) {
1047
+ const technology = await this.getById(technologyId);
1093
1048
  return (technology == null ? void 0 : technology.contraindications) || [];
1094
1049
  }
1095
1050
  /**
1096
1051
  * Vraća sve benefite za tehnologiju
1097
- * @param categoryId - ID kategorije
1098
- * @param subcategoryId - ID podkategorije
1099
1052
  * @param technologyId - ID tehnologije
1100
1053
  * @returns Lista benefita
1101
1054
  */
1102
- async getBenefits(categoryId, subcategoryId, technologyId) {
1103
- const technology = await this.getById(
1104
- categoryId,
1105
- subcategoryId,
1106
- technologyId
1107
- );
1055
+ async getBenefits(technologyId) {
1056
+ const technology = await this.getById(technologyId);
1108
1057
  return (technology == null ? void 0 : technology.benefits) || [];
1109
1058
  }
1110
1059
  /**
1111
1060
  * Ažurira zahteve sertifikacije za tehnologiju
1112
- * @param categoryId - ID kategorije
1113
- * @param subcategoryId - ID podkategorije
1114
1061
  * @param technologyId - ID tehnologije
1115
1062
  * @param certificationRequirement - Novi zahtevi sertifikacije
1116
1063
  * @returns Ažurirana tehnologija
1117
1064
  */
1118
- async updateCertificationRequirement(categoryId, subcategoryId, technologyId, certificationRequirement) {
1119
- const docRef = doc3(
1120
- this.getTechnologiesRef(categoryId, subcategoryId),
1121
- technologyId
1122
- );
1065
+ async updateCertificationRequirement(technologyId, certificationRequirement) {
1066
+ const docRef = doc3(this.getTechnologiesRef(), technologyId);
1123
1067
  await updateDoc3(docRef, {
1124
1068
  certificationRequirement,
1125
1069
  updatedAt: /* @__PURE__ */ new Date()
1126
1070
  });
1127
- return this.getById(categoryId, subcategoryId, technologyId);
1071
+ return this.getById(technologyId);
1128
1072
  }
1129
1073
  /**
1130
1074
  * Vraća zahteve sertifikacije za tehnologiju
1131
- * @param categoryId - ID kategorije
1132
- * @param subcategoryId - ID podkategorije
1133
1075
  * @param technologyId - ID tehnologije
1134
1076
  * @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
1135
1077
  */
1136
- async getCertificationRequirement(categoryId, subcategoryId, technologyId) {
1137
- const technology = await this.getById(
1138
- categoryId,
1139
- subcategoryId,
1140
- technologyId
1141
- );
1078
+ async getCertificationRequirement(technologyId) {
1079
+ const technology = await this.getById(technologyId);
1142
1080
  return (technology == null ? void 0 : technology.certificationRequirement) || null;
1143
1081
  }
1082
+ /**
1083
+ * Proverava da li doktor ima odgovarajuću sertifikaciju za izvođenje tehnologije
1084
+ *
1085
+ * @param requiredCertification - Zahtevana sertifikacija za tehnologiju
1086
+ * @param practitionerCertification - Sertifikacija zdravstvenog radnika
1087
+ * @returns true ako zdravstveni radnik ima odgovarajuću sertifikaciju, false ako nema
1088
+ *
1089
+ * @example
1090
+ * const isValid = technologyService.validateCertification(
1091
+ * {
1092
+ * minimumLevel: CertificationLevel.DOCTOR,
1093
+ * requiredSpecialties: [CertificationSpecialty.INJECTABLES]
1094
+ * },
1095
+ * {
1096
+ * level: CertificationLevel.SPECIALIST,
1097
+ * specialties: [CertificationSpecialty.INJECTABLES, CertificationSpecialty.LASER]
1098
+ * }
1099
+ * );
1100
+ */
1101
+ validateCertification(requiredCertification, practitionerCertification) {
1102
+ const doctorLevel = Object.values(CertificationLevel).indexOf(
1103
+ practitionerCertification.level
1104
+ );
1105
+ const requiredLevel = Object.values(CertificationLevel).indexOf(
1106
+ requiredCertification.minimumLevel
1107
+ );
1108
+ if (doctorLevel < requiredLevel) return false;
1109
+ const requiredSpecialties = requiredCertification.requiredSpecialties || [];
1110
+ if (requiredSpecialties.length > 0) {
1111
+ const doctorSpecialties = practitionerCertification.specialties;
1112
+ const hasAllRequiredSpecialties = requiredSpecialties.every(
1113
+ (requiredSpecialty) => doctorSpecialties.includes(requiredSpecialty)
1114
+ );
1115
+ if (!hasAllRequiredSpecialties) return false;
1116
+ }
1117
+ return true;
1118
+ }
1119
+ /**
1120
+ * Vraća sve tehnologije koje je zdravstveni radnik sertifikovan da izvodi
1121
+ * zajedno sa listama dozvoljenih familija, kategorija i podkategorija
1122
+ *
1123
+ * @param practitioner - Profil zdravstvenog radnika
1124
+ * @returns Objekat koji sadrži:
1125
+ * - technologies: Lista tehnologija koje zdravstveni radnik može da izvodi
1126
+ * - families: Lista familija procedura koje zdravstveni radnik može da izvodi
1127
+ * - categories: Lista ID-eva kategorija koje zdravstveni radnik može da izvodi
1128
+ * - subcategories: Lista ID-eva podkategorija koje zdravstveni radnik može da izvodi
1129
+ *
1130
+ * @example
1131
+ * const practitioner = {
1132
+ * certification: {
1133
+ * level: CertificationLevel.DOCTOR,
1134
+ * specialties: [CertificationSpecialty.INJECTABLES]
1135
+ * }
1136
+ * };
1137
+ * const allowedTechnologies = await technologyService.getAllowedTechnologies(practitioner);
1138
+ * console.log(allowedTechnologies.families); // [ProcedureFamily.AESTHETICS]
1139
+ * console.log(allowedTechnologies.categories); // ["category1", "category2"]
1140
+ * console.log(allowedTechnologies.subcategories); // ["subcategory1", "subcategory2"]
1141
+ */
1142
+ async getAllowedTechnologies(practitioner) {
1143
+ const allTechnologies = await this.getAll();
1144
+ const allowedTechnologies = allTechnologies.filter(
1145
+ (technology) => this.validateCertification(
1146
+ technology.certificationRequirement,
1147
+ practitioner.certification
1148
+ )
1149
+ );
1150
+ const families = [...new Set(allowedTechnologies.map((t) => t.family))];
1151
+ const categories = [
1152
+ ...new Set(allowedTechnologies.map((t) => t.categoryId))
1153
+ ];
1154
+ const subcategories = [
1155
+ ...new Set(allowedTechnologies.map((t) => t.subcategoryId))
1156
+ ];
1157
+ return {
1158
+ technologies: allowedTechnologies,
1159
+ families,
1160
+ categories,
1161
+ subcategories
1162
+ };
1163
+ }
1144
1164
  };
1145
1165
 
1146
1166
  // src/backoffice/services/requirement.service.ts