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