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