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