@blackcode_sa/metaestetics-api 1.5.10 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backoffice/index.d.mts +209 -71
- package/dist/backoffice/index.d.ts +209 -71
- package/dist/backoffice/index.js +197 -175
- package/dist/backoffice/index.mjs +197 -175
- package/dist/index.d.mts +133 -70
- package/dist/index.d.ts +133 -70
- package/dist/index.js +238 -180
- package/dist/index.mjs +238 -180
- 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/backoffice/validations/schemas.ts +2 -0
- package/src/services/procedure/procedure.service.ts +62 -5
package/dist/index.js
CHANGED
|
@@ -6454,11 +6454,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6454
6454
|
validatedData.categoryId,
|
|
6455
6455
|
validatedData.subcategoryId
|
|
6456
6456
|
),
|
|
6457
|
-
this.technologyService.getById(
|
|
6458
|
-
validatedData.categoryId,
|
|
6459
|
-
validatedData.subcategoryId,
|
|
6460
|
-
validatedData.technologyId
|
|
6461
|
-
),
|
|
6457
|
+
this.technologyService.getById(validatedData.technologyId),
|
|
6462
6458
|
this.productService.getById(
|
|
6463
6459
|
validatedData.categoryId,
|
|
6464
6460
|
validatedData.subcategoryId,
|
|
@@ -6570,6 +6566,48 @@ var ProcedureService = class extends BaseService {
|
|
|
6570
6566
|
updatedAt: (0, import_firestore21.serverTimestamp)()
|
|
6571
6567
|
});
|
|
6572
6568
|
}
|
|
6569
|
+
/**
|
|
6570
|
+
* Gets all procedures that a practitioner is certified to perform
|
|
6571
|
+
* @param practitioner - The practitioner's profile
|
|
6572
|
+
* @returns Object containing:
|
|
6573
|
+
* - procedures: List of procedures the practitioner can perform
|
|
6574
|
+
* - families: List of procedure families the practitioner can perform
|
|
6575
|
+
* - categories: List of category IDs the practitioner can perform
|
|
6576
|
+
* - subcategories: List of subcategory IDs the practitioner can perform
|
|
6577
|
+
*
|
|
6578
|
+
* @example
|
|
6579
|
+
* const practitioner = {
|
|
6580
|
+
* certification: {
|
|
6581
|
+
* level: CertificationLevel.DOCTOR,
|
|
6582
|
+
* specialties: [CertificationSpecialty.INJECTABLES]
|
|
6583
|
+
* }
|
|
6584
|
+
* };
|
|
6585
|
+
* const allowedProcedures = await procedureService.getAllowedProcedures(practitioner);
|
|
6586
|
+
* console.log(allowedProcedures.families); // [ProcedureFamily.AESTHETICS]
|
|
6587
|
+
* console.log(allowedProcedures.categories); // ["category1", "category2"]
|
|
6588
|
+
* console.log(allowedProcedures.subcategories); // ["subcategory1", "subcategory2"]
|
|
6589
|
+
*/
|
|
6590
|
+
async getAllowedProcedures(practitioner) {
|
|
6591
|
+
const { technologies, families, categories, subcategories } = await this.technologyService.getAllowedTechnologies(practitioner);
|
|
6592
|
+
const procedures = await Promise.all(
|
|
6593
|
+
technologies.map(async (technology) => {
|
|
6594
|
+
const q = (0, import_firestore21.query)(
|
|
6595
|
+
(0, import_firestore21.collection)(this.db, PROCEDURES_COLLECTION),
|
|
6596
|
+
(0, import_firestore21.where)("technologyId", "==", technology.id),
|
|
6597
|
+
(0, import_firestore21.where)("isActive", "==", true)
|
|
6598
|
+
);
|
|
6599
|
+
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6600
|
+
return snapshot.docs.map((doc26) => doc26.data());
|
|
6601
|
+
})
|
|
6602
|
+
);
|
|
6603
|
+
const flattenedProcedures = procedures.flat();
|
|
6604
|
+
return {
|
|
6605
|
+
procedures: flattenedProcedures,
|
|
6606
|
+
families,
|
|
6607
|
+
categories,
|
|
6608
|
+
subcategories
|
|
6609
|
+
};
|
|
6610
|
+
}
|
|
6573
6611
|
};
|
|
6574
6612
|
|
|
6575
6613
|
// src/services/documentation-templates/documentation-template.service.ts
|
|
@@ -9796,60 +9834,97 @@ var DEFAULT_CERTIFICATION_REQUIREMENT = {
|
|
|
9796
9834
|
};
|
|
9797
9835
|
var TechnologyService = class extends BaseService {
|
|
9798
9836
|
/**
|
|
9799
|
-
* Vraća referencu na Firestore kolekciju tehnologija
|
|
9800
|
-
* @param categoryId - ID kategorije
|
|
9801
|
-
* @param subcategoryId - ID podkategorije
|
|
9837
|
+
* Vraća referencu na Firestore kolekciju tehnologija
|
|
9802
9838
|
*/
|
|
9803
|
-
getTechnologiesRef(
|
|
9804
|
-
return (0, import_firestore37.collection)(
|
|
9805
|
-
this.db,
|
|
9806
|
-
CATEGORIES_COLLECTION,
|
|
9807
|
-
categoryId,
|
|
9808
|
-
SUBCATEGORIES_COLLECTION,
|
|
9809
|
-
subcategoryId,
|
|
9810
|
-
TECHNOLOGIES_COLLECTION
|
|
9811
|
-
);
|
|
9839
|
+
getTechnologiesRef() {
|
|
9840
|
+
return (0, import_firestore37.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
9812
9841
|
}
|
|
9813
9842
|
/**
|
|
9814
|
-
* Kreira novu tehnologiju
|
|
9815
|
-
* @param categoryId - ID kategorije
|
|
9816
|
-
* @param subcategoryId - ID podkategorije
|
|
9843
|
+
* Kreira novu tehnologiju
|
|
9817
9844
|
* @param technology - Podaci za novu tehnologiju
|
|
9818
9845
|
* @returns Kreirana tehnologija sa generisanim ID-em
|
|
9819
9846
|
*/
|
|
9820
|
-
async create(
|
|
9847
|
+
async create(technology) {
|
|
9821
9848
|
const now = /* @__PURE__ */ new Date();
|
|
9822
9849
|
const newTechnology = {
|
|
9823
9850
|
...technology,
|
|
9824
|
-
subcategoryId,
|
|
9825
9851
|
createdAt: now,
|
|
9826
9852
|
updatedAt: now,
|
|
9827
9853
|
isActive: true,
|
|
9828
|
-
requirements: {
|
|
9854
|
+
requirements: technology.requirements || {
|
|
9829
9855
|
pre: [],
|
|
9830
9856
|
post: []
|
|
9831
9857
|
},
|
|
9832
|
-
blockingConditions: [],
|
|
9833
|
-
contraindications: [],
|
|
9834
|
-
benefits: [],
|
|
9858
|
+
blockingConditions: technology.blockingConditions || [],
|
|
9859
|
+
contraindications: technology.contraindications || [],
|
|
9860
|
+
benefits: technology.benefits || [],
|
|
9835
9861
|
certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
|
|
9836
9862
|
};
|
|
9837
|
-
const docRef = await (0, import_firestore37.addDoc)(
|
|
9838
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9839
|
-
newTechnology
|
|
9840
|
-
);
|
|
9863
|
+
const docRef = await (0, import_firestore37.addDoc)(this.getTechnologiesRef(), newTechnology);
|
|
9841
9864
|
return { id: docRef.id, ...newTechnology };
|
|
9842
9865
|
}
|
|
9843
9866
|
/**
|
|
9844
|
-
* Vraća sve aktivne tehnologije
|
|
9867
|
+
* Vraća sve aktivne tehnologije
|
|
9868
|
+
* @returns Lista aktivnih tehnologija
|
|
9869
|
+
*/
|
|
9870
|
+
async getAll() {
|
|
9871
|
+
const q = (0, import_firestore37.query)(this.getTechnologiesRef(), (0, import_firestore37.where)("isActive", "==", true));
|
|
9872
|
+
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
9873
|
+
return snapshot.docs.map(
|
|
9874
|
+
(doc26) => ({
|
|
9875
|
+
id: doc26.id,
|
|
9876
|
+
...doc26.data()
|
|
9877
|
+
})
|
|
9878
|
+
);
|
|
9879
|
+
}
|
|
9880
|
+
/**
|
|
9881
|
+
* Vraća sve aktivne tehnologije za određenu familiju
|
|
9882
|
+
* @param family - Familija procedura
|
|
9883
|
+
* @returns Lista aktivnih tehnologija
|
|
9884
|
+
*/
|
|
9885
|
+
async getAllByFamily(family) {
|
|
9886
|
+
const q = (0, import_firestore37.query)(
|
|
9887
|
+
this.getTechnologiesRef(),
|
|
9888
|
+
(0, import_firestore37.where)("isActive", "==", true),
|
|
9889
|
+
(0, import_firestore37.where)("family", "==", family)
|
|
9890
|
+
);
|
|
9891
|
+
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
9892
|
+
return snapshot.docs.map(
|
|
9893
|
+
(doc26) => ({
|
|
9894
|
+
id: doc26.id,
|
|
9895
|
+
...doc26.data()
|
|
9896
|
+
})
|
|
9897
|
+
);
|
|
9898
|
+
}
|
|
9899
|
+
/**
|
|
9900
|
+
* Vraća sve aktivne tehnologije za određenu kategoriju
|
|
9845
9901
|
* @param categoryId - ID kategorije
|
|
9902
|
+
* @returns Lista aktivnih tehnologija
|
|
9903
|
+
*/
|
|
9904
|
+
async getAllByCategoryId(categoryId) {
|
|
9905
|
+
const q = (0, import_firestore37.query)(
|
|
9906
|
+
this.getTechnologiesRef(),
|
|
9907
|
+
(0, import_firestore37.where)("isActive", "==", true),
|
|
9908
|
+
(0, import_firestore37.where)("categoryId", "==", categoryId)
|
|
9909
|
+
);
|
|
9910
|
+
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
9911
|
+
return snapshot.docs.map(
|
|
9912
|
+
(doc26) => ({
|
|
9913
|
+
id: doc26.id,
|
|
9914
|
+
...doc26.data()
|
|
9915
|
+
})
|
|
9916
|
+
);
|
|
9917
|
+
}
|
|
9918
|
+
/**
|
|
9919
|
+
* Vraća sve aktivne tehnologije za određenu podkategoriju
|
|
9846
9920
|
* @param subcategoryId - ID podkategorije
|
|
9847
9921
|
* @returns Lista aktivnih tehnologija
|
|
9848
9922
|
*/
|
|
9849
|
-
async getAllBySubcategoryId(
|
|
9923
|
+
async getAllBySubcategoryId(subcategoryId) {
|
|
9850
9924
|
const q = (0, import_firestore37.query)(
|
|
9851
|
-
this.getTechnologiesRef(
|
|
9852
|
-
(0, import_firestore37.where)("isActive", "==", true)
|
|
9925
|
+
this.getTechnologiesRef(),
|
|
9926
|
+
(0, import_firestore37.where)("isActive", "==", true),
|
|
9927
|
+
(0, import_firestore37.where)("subcategoryId", "==", subcategoryId)
|
|
9853
9928
|
);
|
|
9854
9929
|
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
9855
9930
|
return snapshot.docs.map(
|
|
@@ -9861,47 +9936,35 @@ var TechnologyService = class extends BaseService {
|
|
|
9861
9936
|
}
|
|
9862
9937
|
/**
|
|
9863
9938
|
* Ažurira postojeću tehnologiju
|
|
9864
|
-
* @param categoryId - ID kategorije
|
|
9865
|
-
* @param subcategoryId - ID podkategorije
|
|
9866
9939
|
* @param technologyId - ID tehnologije
|
|
9867
9940
|
* @param technology - Novi podaci za tehnologiju
|
|
9868
9941
|
* @returns Ažurirana tehnologija
|
|
9869
9942
|
*/
|
|
9870
|
-
async update(
|
|
9943
|
+
async update(technologyId, technology) {
|
|
9871
9944
|
const updateData = {
|
|
9872
9945
|
...technology,
|
|
9873
9946
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9874
9947
|
};
|
|
9875
|
-
const docRef = (0, import_firestore37.doc)(
|
|
9876
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9877
|
-
technologyId
|
|
9878
|
-
);
|
|
9948
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
9879
9949
|
await (0, import_firestore37.updateDoc)(docRef, updateData);
|
|
9880
|
-
return this.getById(
|
|
9950
|
+
return this.getById(technologyId);
|
|
9881
9951
|
}
|
|
9882
9952
|
/**
|
|
9883
9953
|
* Soft delete tehnologije (postavlja isActive na false)
|
|
9884
|
-
* @param categoryId - ID kategorije
|
|
9885
|
-
* @param subcategoryId - ID podkategorije
|
|
9886
9954
|
* @param technologyId - ID tehnologije koja se briše
|
|
9887
9955
|
*/
|
|
9888
|
-
async delete(
|
|
9889
|
-
await this.update(
|
|
9956
|
+
async delete(technologyId) {
|
|
9957
|
+
await this.update(technologyId, {
|
|
9890
9958
|
isActive: false
|
|
9891
9959
|
});
|
|
9892
9960
|
}
|
|
9893
9961
|
/**
|
|
9894
9962
|
* Vraća tehnologiju po ID-u
|
|
9895
|
-
* @param categoryId - ID kategorije
|
|
9896
|
-
* @param subcategoryId - ID podkategorije
|
|
9897
9963
|
* @param technologyId - ID tražene tehnologije
|
|
9898
9964
|
* @returns Tehnologija ili null ako ne postoji
|
|
9899
9965
|
*/
|
|
9900
|
-
async getById(
|
|
9901
|
-
const docRef = (0, import_firestore37.doc)(
|
|
9902
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9903
|
-
technologyId
|
|
9904
|
-
);
|
|
9966
|
+
async getById(technologyId) {
|
|
9967
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
9905
9968
|
const docSnap = await (0, import_firestore37.getDoc)(docRef);
|
|
9906
9969
|
if (!docSnap.exists()) return null;
|
|
9907
9970
|
return {
|
|
@@ -9911,58 +9974,42 @@ var TechnologyService = class extends BaseService {
|
|
|
9911
9974
|
}
|
|
9912
9975
|
/**
|
|
9913
9976
|
* Dodaje novi zahtev tehnologiji
|
|
9914
|
-
* @param categoryId - ID kategorije
|
|
9915
|
-
* @param subcategoryId - ID podkategorije
|
|
9916
9977
|
* @param technologyId - ID tehnologije
|
|
9917
9978
|
* @param requirement - Zahtev koji se dodaje
|
|
9918
9979
|
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
9919
9980
|
*/
|
|
9920
|
-
async addRequirement(
|
|
9921
|
-
const docRef = (0, import_firestore37.doc)(
|
|
9922
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9923
|
-
technologyId
|
|
9924
|
-
);
|
|
9981
|
+
async addRequirement(technologyId, requirement) {
|
|
9982
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
9925
9983
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
9926
9984
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
9927
9985
|
[requirementType]: (0, import_firestore37.arrayUnion)(requirement),
|
|
9928
9986
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9929
9987
|
});
|
|
9930
|
-
return this.getById(
|
|
9988
|
+
return this.getById(technologyId);
|
|
9931
9989
|
}
|
|
9932
9990
|
/**
|
|
9933
9991
|
* Uklanja zahtev iz tehnologije
|
|
9934
|
-
* @param categoryId - ID kategorije
|
|
9935
|
-
* @param subcategoryId - ID podkategorije
|
|
9936
9992
|
* @param technologyId - ID tehnologije
|
|
9937
9993
|
* @param requirement - Zahtev koji se uklanja
|
|
9938
9994
|
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
9939
9995
|
*/
|
|
9940
|
-
async removeRequirement(
|
|
9941
|
-
const docRef = (0, import_firestore37.doc)(
|
|
9942
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
9943
|
-
technologyId
|
|
9944
|
-
);
|
|
9996
|
+
async removeRequirement(technologyId, requirement) {
|
|
9997
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
9945
9998
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
9946
9999
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
9947
10000
|
[requirementType]: (0, import_firestore37.arrayRemove)(requirement),
|
|
9948
10001
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9949
10002
|
});
|
|
9950
|
-
return this.getById(
|
|
10003
|
+
return this.getById(technologyId);
|
|
9951
10004
|
}
|
|
9952
10005
|
/**
|
|
9953
10006
|
* Vraća sve zahteve za tehnologiju
|
|
9954
|
-
* @param categoryId - ID kategorije
|
|
9955
|
-
* @param subcategoryId - ID podkategorije
|
|
9956
10007
|
* @param technologyId - ID tehnologije
|
|
9957
10008
|
* @param type - Opcioni filter za tip zahteva (pre/post)
|
|
9958
10009
|
* @returns Lista zahteva
|
|
9959
10010
|
*/
|
|
9960
|
-
async getRequirements(
|
|
9961
|
-
const technology = await this.getById(
|
|
9962
|
-
categoryId,
|
|
9963
|
-
subcategoryId,
|
|
9964
|
-
technologyId
|
|
9965
|
-
);
|
|
10011
|
+
async getRequirements(technologyId, type) {
|
|
10012
|
+
const technology = await this.getById(technologyId);
|
|
9966
10013
|
if (!technology || !technology.requirements) return [];
|
|
9967
10014
|
if (type) {
|
|
9968
10015
|
return technology.requirements[type];
|
|
@@ -9971,220 +10018,231 @@ var TechnologyService = class extends BaseService {
|
|
|
9971
10018
|
}
|
|
9972
10019
|
/**
|
|
9973
10020
|
* Ažurira postojeći zahtev
|
|
9974
|
-
* @param categoryId - ID kategorije
|
|
9975
|
-
* @param subcategoryId - ID podkategorije
|
|
9976
10021
|
* @param technologyId - ID tehnologije
|
|
9977
10022
|
* @param oldRequirement - Stari zahtev koji se menja
|
|
9978
10023
|
* @param newRequirement - Novi zahtev koji zamenjuje stari
|
|
9979
10024
|
* @returns Ažurirana tehnologija
|
|
9980
10025
|
*/
|
|
9981
|
-
async updateRequirement(
|
|
9982
|
-
await this.removeRequirement(
|
|
9983
|
-
|
|
9984
|
-
subcategoryId,
|
|
9985
|
-
technologyId,
|
|
9986
|
-
oldRequirement
|
|
9987
|
-
);
|
|
9988
|
-
return this.addRequirement(
|
|
9989
|
-
categoryId,
|
|
9990
|
-
subcategoryId,
|
|
9991
|
-
technologyId,
|
|
9992
|
-
newRequirement
|
|
9993
|
-
);
|
|
10026
|
+
async updateRequirement(technologyId, oldRequirement, newRequirement) {
|
|
10027
|
+
await this.removeRequirement(technologyId, oldRequirement);
|
|
10028
|
+
return this.addRequirement(technologyId, newRequirement);
|
|
9994
10029
|
}
|
|
9995
10030
|
/**
|
|
9996
10031
|
* Dodaje blokirajući uslov tehnologiji
|
|
9997
|
-
* @param categoryId - ID kategorije
|
|
9998
|
-
* @param subcategoryId - ID podkategorije
|
|
9999
10032
|
* @param technologyId - ID tehnologije
|
|
10000
10033
|
* @param condition - Blokirajući uslov koji se dodaje
|
|
10001
10034
|
* @returns Ažurirana tehnologija
|
|
10002
10035
|
*/
|
|
10003
|
-
async addBlockingCondition(
|
|
10004
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10005
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10006
|
-
technologyId
|
|
10007
|
-
);
|
|
10036
|
+
async addBlockingCondition(technologyId, condition) {
|
|
10037
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10008
10038
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10009
10039
|
blockingConditions: (0, import_firestore37.arrayUnion)(condition),
|
|
10010
10040
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10011
10041
|
});
|
|
10012
|
-
return this.getById(
|
|
10042
|
+
return this.getById(technologyId);
|
|
10013
10043
|
}
|
|
10014
10044
|
/**
|
|
10015
10045
|
* Uklanja blokirajući uslov iz tehnologije
|
|
10016
|
-
* @param categoryId - ID kategorije
|
|
10017
|
-
* @param subcategoryId - ID podkategorije
|
|
10018
10046
|
* @param technologyId - ID tehnologije
|
|
10019
10047
|
* @param condition - Blokirajući uslov koji se uklanja
|
|
10020
10048
|
* @returns Ažurirana tehnologija
|
|
10021
10049
|
*/
|
|
10022
|
-
async removeBlockingCondition(
|
|
10023
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10024
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10025
|
-
technologyId
|
|
10026
|
-
);
|
|
10050
|
+
async removeBlockingCondition(technologyId, condition) {
|
|
10051
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10027
10052
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10028
10053
|
blockingConditions: (0, import_firestore37.arrayRemove)(condition),
|
|
10029
10054
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10030
10055
|
});
|
|
10031
|
-
return this.getById(
|
|
10056
|
+
return this.getById(technologyId);
|
|
10032
10057
|
}
|
|
10033
10058
|
/**
|
|
10034
10059
|
* Dodaje kontraindikaciju tehnologiji
|
|
10035
|
-
* @param categoryId - ID kategorije
|
|
10036
|
-
* @param subcategoryId - ID podkategorije
|
|
10037
10060
|
* @param technologyId - ID tehnologije
|
|
10038
10061
|
* @param contraindication - Kontraindikacija koja se dodaje
|
|
10039
10062
|
* @returns Ažurirana tehnologija
|
|
10040
10063
|
*/
|
|
10041
|
-
async addContraindication(
|
|
10042
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10043
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10044
|
-
technologyId
|
|
10045
|
-
);
|
|
10064
|
+
async addContraindication(technologyId, contraindication) {
|
|
10065
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10046
10066
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10047
10067
|
contraindications: (0, import_firestore37.arrayUnion)(contraindication),
|
|
10048
10068
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10049
10069
|
});
|
|
10050
|
-
return this.getById(
|
|
10070
|
+
return this.getById(technologyId);
|
|
10051
10071
|
}
|
|
10052
10072
|
/**
|
|
10053
10073
|
* Uklanja kontraindikaciju iz tehnologije
|
|
10054
|
-
* @param categoryId - ID kategorije
|
|
10055
|
-
* @param subcategoryId - ID podkategorije
|
|
10056
10074
|
* @param technologyId - ID tehnologije
|
|
10057
10075
|
* @param contraindication - Kontraindikacija koja se uklanja
|
|
10058
10076
|
* @returns Ažurirana tehnologija
|
|
10059
10077
|
*/
|
|
10060
|
-
async removeContraindication(
|
|
10061
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10062
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10063
|
-
technologyId
|
|
10064
|
-
);
|
|
10078
|
+
async removeContraindication(technologyId, contraindication) {
|
|
10079
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10065
10080
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10066
10081
|
contraindications: (0, import_firestore37.arrayRemove)(contraindication),
|
|
10067
10082
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10068
10083
|
});
|
|
10069
|
-
return this.getById(
|
|
10084
|
+
return this.getById(technologyId);
|
|
10070
10085
|
}
|
|
10071
10086
|
/**
|
|
10072
10087
|
* Dodaje benefit tehnologiji
|
|
10073
|
-
* @param categoryId - ID kategorije
|
|
10074
|
-
* @param subcategoryId - ID podkategorije
|
|
10075
10088
|
* @param technologyId - ID tehnologije
|
|
10076
10089
|
* @param benefit - Benefit koji se dodaje
|
|
10077
10090
|
* @returns Ažurirana tehnologija
|
|
10078
10091
|
*/
|
|
10079
|
-
async addBenefit(
|
|
10080
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10081
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10082
|
-
technologyId
|
|
10083
|
-
);
|
|
10092
|
+
async addBenefit(technologyId, benefit) {
|
|
10093
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10084
10094
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10085
10095
|
benefits: (0, import_firestore37.arrayUnion)(benefit),
|
|
10086
10096
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10087
10097
|
});
|
|
10088
|
-
return this.getById(
|
|
10098
|
+
return this.getById(technologyId);
|
|
10089
10099
|
}
|
|
10090
10100
|
/**
|
|
10091
10101
|
* Uklanja benefit iz tehnologije
|
|
10092
|
-
* @param categoryId - ID kategorije
|
|
10093
|
-
* @param subcategoryId - ID podkategorije
|
|
10094
10102
|
* @param technologyId - ID tehnologije
|
|
10095
10103
|
* @param benefit - Benefit koji se uklanja
|
|
10096
10104
|
* @returns Ažurirana tehnologija
|
|
10097
10105
|
*/
|
|
10098
|
-
async removeBenefit(
|
|
10099
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10100
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10101
|
-
technologyId
|
|
10102
|
-
);
|
|
10106
|
+
async removeBenefit(technologyId, benefit) {
|
|
10107
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10103
10108
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10104
10109
|
benefits: (0, import_firestore37.arrayRemove)(benefit),
|
|
10105
10110
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10106
10111
|
});
|
|
10107
|
-
return this.getById(
|
|
10112
|
+
return this.getById(technologyId);
|
|
10108
10113
|
}
|
|
10109
10114
|
/**
|
|
10110
10115
|
* Vraća sve blokirajuće uslove za tehnologiju
|
|
10111
|
-
* @param categoryId - ID kategorije
|
|
10112
|
-
* @param subcategoryId - ID podkategorije
|
|
10113
10116
|
* @param technologyId - ID tehnologije
|
|
10114
10117
|
* @returns Lista blokirajućih uslova
|
|
10115
10118
|
*/
|
|
10116
|
-
async getBlockingConditions(
|
|
10117
|
-
const technology = await this.getById(
|
|
10118
|
-
categoryId,
|
|
10119
|
-
subcategoryId,
|
|
10120
|
-
technologyId
|
|
10121
|
-
);
|
|
10119
|
+
async getBlockingConditions(technologyId) {
|
|
10120
|
+
const technology = await this.getById(technologyId);
|
|
10122
10121
|
return (technology == null ? void 0 : technology.blockingConditions) || [];
|
|
10123
10122
|
}
|
|
10124
10123
|
/**
|
|
10125
10124
|
* Vraća sve kontraindikacije za tehnologiju
|
|
10126
|
-
* @param categoryId - ID kategorije
|
|
10127
|
-
* @param subcategoryId - ID podkategorije
|
|
10128
10125
|
* @param technologyId - ID tehnologije
|
|
10129
10126
|
* @returns Lista kontraindikacija
|
|
10130
10127
|
*/
|
|
10131
|
-
async getContraindications(
|
|
10132
|
-
const technology = await this.getById(
|
|
10133
|
-
categoryId,
|
|
10134
|
-
subcategoryId,
|
|
10135
|
-
technologyId
|
|
10136
|
-
);
|
|
10128
|
+
async getContraindications(technologyId) {
|
|
10129
|
+
const technology = await this.getById(technologyId);
|
|
10137
10130
|
return (technology == null ? void 0 : technology.contraindications) || [];
|
|
10138
10131
|
}
|
|
10139
10132
|
/**
|
|
10140
10133
|
* Vraća sve benefite za tehnologiju
|
|
10141
|
-
* @param categoryId - ID kategorije
|
|
10142
|
-
* @param subcategoryId - ID podkategorije
|
|
10143
10134
|
* @param technologyId - ID tehnologije
|
|
10144
10135
|
* @returns Lista benefita
|
|
10145
10136
|
*/
|
|
10146
|
-
async getBenefits(
|
|
10147
|
-
const technology = await this.getById(
|
|
10148
|
-
categoryId,
|
|
10149
|
-
subcategoryId,
|
|
10150
|
-
technologyId
|
|
10151
|
-
);
|
|
10137
|
+
async getBenefits(technologyId) {
|
|
10138
|
+
const technology = await this.getById(technologyId);
|
|
10152
10139
|
return (technology == null ? void 0 : technology.benefits) || [];
|
|
10153
10140
|
}
|
|
10154
10141
|
/**
|
|
10155
10142
|
* Ažurira zahteve sertifikacije za tehnologiju
|
|
10156
|
-
* @param categoryId - ID kategorije
|
|
10157
|
-
* @param subcategoryId - ID podkategorije
|
|
10158
10143
|
* @param technologyId - ID tehnologije
|
|
10159
10144
|
* @param certificationRequirement - Novi zahtevi sertifikacije
|
|
10160
10145
|
* @returns Ažurirana tehnologija
|
|
10161
10146
|
*/
|
|
10162
|
-
async updateCertificationRequirement(
|
|
10163
|
-
const docRef = (0, import_firestore37.doc)(
|
|
10164
|
-
this.getTechnologiesRef(categoryId, subcategoryId),
|
|
10165
|
-
technologyId
|
|
10166
|
-
);
|
|
10147
|
+
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
10148
|
+
const docRef = (0, import_firestore37.doc)(this.getTechnologiesRef(), technologyId);
|
|
10167
10149
|
await (0, import_firestore37.updateDoc)(docRef, {
|
|
10168
10150
|
certificationRequirement,
|
|
10169
10151
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10170
10152
|
});
|
|
10171
|
-
return this.getById(
|
|
10153
|
+
return this.getById(technologyId);
|
|
10172
10154
|
}
|
|
10173
10155
|
/**
|
|
10174
10156
|
* Vraća zahteve sertifikacije za tehnologiju
|
|
10175
|
-
* @param categoryId - ID kategorije
|
|
10176
|
-
* @param subcategoryId - ID podkategorije
|
|
10177
10157
|
* @param technologyId - ID tehnologije
|
|
10178
10158
|
* @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
|
|
10179
10159
|
*/
|
|
10180
|
-
async getCertificationRequirement(
|
|
10181
|
-
const technology = await this.getById(
|
|
10182
|
-
categoryId,
|
|
10183
|
-
subcategoryId,
|
|
10184
|
-
technologyId
|
|
10185
|
-
);
|
|
10160
|
+
async getCertificationRequirement(technologyId) {
|
|
10161
|
+
const technology = await this.getById(technologyId);
|
|
10186
10162
|
return (technology == null ? void 0 : technology.certificationRequirement) || null;
|
|
10187
10163
|
}
|
|
10164
|
+
/**
|
|
10165
|
+
* Proverava da li doktor ima odgovarajuću sertifikaciju za izvođenje tehnologije
|
|
10166
|
+
*
|
|
10167
|
+
* @param requiredCertification - Zahtevana sertifikacija za tehnologiju
|
|
10168
|
+
* @param practitionerCertification - Sertifikacija zdravstvenog radnika
|
|
10169
|
+
* @returns true ako zdravstveni radnik ima odgovarajuću sertifikaciju, false ako nema
|
|
10170
|
+
*
|
|
10171
|
+
* @example
|
|
10172
|
+
* const isValid = technologyService.validateCertification(
|
|
10173
|
+
* {
|
|
10174
|
+
* minimumLevel: CertificationLevel.DOCTOR,
|
|
10175
|
+
* requiredSpecialties: [CertificationSpecialty.INJECTABLES]
|
|
10176
|
+
* },
|
|
10177
|
+
* {
|
|
10178
|
+
* level: CertificationLevel.SPECIALIST,
|
|
10179
|
+
* specialties: [CertificationSpecialty.INJECTABLES, CertificationSpecialty.LASER]
|
|
10180
|
+
* }
|
|
10181
|
+
* );
|
|
10182
|
+
*/
|
|
10183
|
+
validateCertification(requiredCertification, practitionerCertification) {
|
|
10184
|
+
const doctorLevel = Object.values(CertificationLevel).indexOf(
|
|
10185
|
+
practitionerCertification.level
|
|
10186
|
+
);
|
|
10187
|
+
const requiredLevel = Object.values(CertificationLevel).indexOf(
|
|
10188
|
+
requiredCertification.minimumLevel
|
|
10189
|
+
);
|
|
10190
|
+
if (doctorLevel < requiredLevel) return false;
|
|
10191
|
+
const requiredSpecialties = requiredCertification.requiredSpecialties || [];
|
|
10192
|
+
if (requiredSpecialties.length > 0) {
|
|
10193
|
+
const doctorSpecialties = practitionerCertification.specialties;
|
|
10194
|
+
const hasAllRequiredSpecialties = requiredSpecialties.every(
|
|
10195
|
+
(requiredSpecialty) => doctorSpecialties.includes(requiredSpecialty)
|
|
10196
|
+
);
|
|
10197
|
+
if (!hasAllRequiredSpecialties) return false;
|
|
10198
|
+
}
|
|
10199
|
+
return true;
|
|
10200
|
+
}
|
|
10201
|
+
/**
|
|
10202
|
+
* Vraća sve tehnologije koje je zdravstveni radnik sertifikovan da izvodi
|
|
10203
|
+
* zajedno sa listama dozvoljenih familija, kategorija i podkategorija
|
|
10204
|
+
*
|
|
10205
|
+
* @param practitioner - Profil zdravstvenog radnika
|
|
10206
|
+
* @returns Objekat koji sadrži:
|
|
10207
|
+
* - technologies: Lista tehnologija koje zdravstveni radnik može da izvodi
|
|
10208
|
+
* - families: Lista familija procedura koje zdravstveni radnik može da izvodi
|
|
10209
|
+
* - categories: Lista ID-eva kategorija koje zdravstveni radnik može da izvodi
|
|
10210
|
+
* - subcategories: Lista ID-eva podkategorija koje zdravstveni radnik može da izvodi
|
|
10211
|
+
*
|
|
10212
|
+
* @example
|
|
10213
|
+
* const practitioner = {
|
|
10214
|
+
* certification: {
|
|
10215
|
+
* level: CertificationLevel.DOCTOR,
|
|
10216
|
+
* specialties: [CertificationSpecialty.INJECTABLES]
|
|
10217
|
+
* }
|
|
10218
|
+
* };
|
|
10219
|
+
* const allowedTechnologies = await technologyService.getAllowedTechnologies(practitioner);
|
|
10220
|
+
* console.log(allowedTechnologies.families); // [ProcedureFamily.AESTHETICS]
|
|
10221
|
+
* console.log(allowedTechnologies.categories); // ["category1", "category2"]
|
|
10222
|
+
* console.log(allowedTechnologies.subcategories); // ["subcategory1", "subcategory2"]
|
|
10223
|
+
*/
|
|
10224
|
+
async getAllowedTechnologies(practitioner) {
|
|
10225
|
+
const allTechnologies = await this.getAll();
|
|
10226
|
+
const allowedTechnologies = allTechnologies.filter(
|
|
10227
|
+
(technology) => this.validateCertification(
|
|
10228
|
+
technology.certificationRequirement,
|
|
10229
|
+
practitioner.certification
|
|
10230
|
+
)
|
|
10231
|
+
);
|
|
10232
|
+
const families = [...new Set(allowedTechnologies.map((t) => t.family))];
|
|
10233
|
+
const categories = [
|
|
10234
|
+
...new Set(allowedTechnologies.map((t) => t.categoryId))
|
|
10235
|
+
];
|
|
10236
|
+
const subcategories = [
|
|
10237
|
+
...new Set(allowedTechnologies.map((t) => t.subcategoryId))
|
|
10238
|
+
];
|
|
10239
|
+
return {
|
|
10240
|
+
technologies: allowedTechnologies,
|
|
10241
|
+
families,
|
|
10242
|
+
categories,
|
|
10243
|
+
subcategories
|
|
10244
|
+
};
|
|
10245
|
+
}
|
|
10188
10246
|
};
|
|
10189
10247
|
|
|
10190
10248
|
// src/backoffice/services/product.service.ts
|