@blackcode_sa/metaestetics-api 1.12.2 → 1.12.4
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 +64 -14
- package/dist/backoffice/index.d.ts +64 -14
- package/dist/backoffice/index.js +72 -53
- package/dist/backoffice/index.mjs +72 -53
- package/dist/index.d.mts +212 -18
- package/dist/index.d.ts +212 -18
- package/dist/index.js +139 -53
- package/dist/index.mjs +137 -53
- package/package.json +1 -1
- package/src/backoffice/services/FIXES_README.md +102 -0
- package/src/backoffice/services/category.service.ts +46 -27
- package/src/backoffice/services/product.service.ts +52 -74
- package/src/backoffice/services/technology.service.ts +99 -116
- package/src/backoffice/types/category.types.ts +28 -2
- package/src/backoffice/types/product.types.ts +10 -9
- package/src/backoffice/types/technology.types.ts +31 -59
- package/src/types/clinic/index.ts +89 -0
- package/src/validations/clinic.schema.ts +68 -0
|
@@ -148,6 +148,35 @@ interface Category {
|
|
|
148
148
|
* Kolekcija u Firestore bazi gde se čuvaju kategorije
|
|
149
149
|
*/
|
|
150
150
|
declare const CATEGORIES_COLLECTION = "backoffice_categories";
|
|
151
|
+
/**
|
|
152
|
+
* Interface for the CategoryService class
|
|
153
|
+
*/
|
|
154
|
+
interface ICategoryService {
|
|
155
|
+
create(category: Omit<Category, 'id' | 'createdAt' | 'updatedAt'>): Promise<Category>;
|
|
156
|
+
getCategoryCounts(active?: boolean): Promise<Record<string, number>>;
|
|
157
|
+
getAllForFilter(): Promise<Category[]>;
|
|
158
|
+
getAllForFilterByFamily(family: ProcedureFamily): Promise<Category[]>;
|
|
159
|
+
getAll(options?: {
|
|
160
|
+
active?: boolean;
|
|
161
|
+
limit?: number;
|
|
162
|
+
lastVisible?: any;
|
|
163
|
+
}): Promise<{
|
|
164
|
+
categories: Category[];
|
|
165
|
+
lastVisible: any;
|
|
166
|
+
}>;
|
|
167
|
+
getAllByFamily(family: ProcedureFamily, options?: {
|
|
168
|
+
active?: boolean;
|
|
169
|
+
limit?: number;
|
|
170
|
+
lastVisible?: any;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
categories: Category[];
|
|
173
|
+
lastVisible: any;
|
|
174
|
+
}>;
|
|
175
|
+
update(id: string, category: Partial<Omit<Category, 'id' | 'createdAt'>>): Promise<Category | null>;
|
|
176
|
+
delete(id: string): Promise<void>;
|
|
177
|
+
reactivate(id: string): Promise<void>;
|
|
178
|
+
getById(id: string): Promise<Category | null>;
|
|
179
|
+
}
|
|
151
180
|
|
|
152
181
|
/**
|
|
153
182
|
* Servis za upravljanje kategorijama procedura.
|
|
@@ -162,7 +191,7 @@ declare const CATEGORIES_COLLECTION = "backoffice_categories";
|
|
|
162
191
|
* family: ProcedureFamily.AESTHETICS
|
|
163
192
|
* });
|
|
164
193
|
*/
|
|
165
|
-
declare class CategoryService extends BaseService {
|
|
194
|
+
declare class CategoryService extends BaseService implements ICategoryService {
|
|
166
195
|
/**
|
|
167
196
|
* Referenca na Firestore kolekciju kategorija
|
|
168
197
|
*/
|
|
@@ -172,7 +201,7 @@ declare class CategoryService extends BaseService {
|
|
|
172
201
|
* @param category - Podaci za novu kategoriju
|
|
173
202
|
* @returns Kreirana kategorija sa generisanim ID-em
|
|
174
203
|
*/
|
|
175
|
-
create(category: Omit<Category,
|
|
204
|
+
create(category: Omit<Category, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
176
205
|
createdAt: Date;
|
|
177
206
|
updatedAt: Date;
|
|
178
207
|
name: string;
|
|
@@ -192,6 +221,12 @@ declare class CategoryService extends BaseService {
|
|
|
192
221
|
* @returns Lista svih aktivnih kategorija
|
|
193
222
|
*/
|
|
194
223
|
getAllForFilter(): Promise<Category[]>;
|
|
224
|
+
/**
|
|
225
|
+
* Vraća sve kategorije za određenu familiju za potrebe filtera (bez paginacije)
|
|
226
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
227
|
+
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
228
|
+
*/
|
|
229
|
+
getAllForFilterByFamily(family: ProcedureFamily): Promise<Category[]>;
|
|
195
230
|
/**
|
|
196
231
|
* Vraća sve kategorije sa paginacijom
|
|
197
232
|
* @param options - Pagination and filter options
|
|
@@ -225,7 +260,7 @@ declare class CategoryService extends BaseService {
|
|
|
225
260
|
* @param category - Novi podaci za kategoriju
|
|
226
261
|
* @returns Ažurirana kategorija
|
|
227
262
|
*/
|
|
228
|
-
update(id: string, category: Partial<Omit<Category,
|
|
263
|
+
update(id: string, category: Partial<Omit<Category, 'id' | 'createdAt'>>): Promise<Category | null>;
|
|
229
264
|
/**
|
|
230
265
|
* Soft delete kategorije (postavlja isActive na false)
|
|
231
266
|
* @param id - ID kategorije koja se briše
|
|
@@ -593,7 +628,7 @@ interface IProductService {
|
|
|
593
628
|
* @param brandId - ID of the brand that manufactures this product
|
|
594
629
|
* @param product - Product data
|
|
595
630
|
*/
|
|
596
|
-
create(technologyId: string, brandId: string, product: Omit<Product,
|
|
631
|
+
create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
|
|
597
632
|
/**
|
|
598
633
|
* Gets a paginated list of all products, with optional filters.
|
|
599
634
|
*/
|
|
@@ -623,6 +658,11 @@ interface IProductService {
|
|
|
623
658
|
bySubcategory: Record<string, number>;
|
|
624
659
|
byTechnology: Record<string, number>;
|
|
625
660
|
}>;
|
|
661
|
+
/**
|
|
662
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
663
|
+
* @param technologyId - ID of the technology
|
|
664
|
+
*/
|
|
665
|
+
getAllByTechnology(technologyId: string): Promise<Product[]>;
|
|
626
666
|
/**
|
|
627
667
|
* Gets all products for a brand
|
|
628
668
|
* @param brandId - ID of the brand
|
|
@@ -634,7 +674,7 @@ interface IProductService {
|
|
|
634
674
|
* @param productId - ID of the product to update
|
|
635
675
|
* @param product - Updated product data
|
|
636
676
|
*/
|
|
637
|
-
update(technologyId: string, productId: string, product: Partial<Omit<Product,
|
|
677
|
+
update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
|
|
638
678
|
/**
|
|
639
679
|
* Deletes a product (soft delete)
|
|
640
680
|
* @param technologyId - ID of the technology
|
|
@@ -873,7 +913,7 @@ declare const TECHNOLOGIES_COLLECTION = "technologies";
|
|
|
873
913
|
* Interface for the TechnologyService class
|
|
874
914
|
*/
|
|
875
915
|
interface ITechnologyService {
|
|
876
|
-
create(technology: Omit<Technology,
|
|
916
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<Technology>;
|
|
877
917
|
getTechnologyCounts(active?: boolean): Promise<Record<string, number>>;
|
|
878
918
|
getTechnologyCountsByCategory(active?: boolean): Promise<Record<string, number>>;
|
|
879
919
|
getAll(options?: {
|
|
@@ -900,13 +940,13 @@ interface ITechnologyService {
|
|
|
900
940
|
technologies: Technology[];
|
|
901
941
|
lastVisible: any;
|
|
902
942
|
}>;
|
|
903
|
-
update(id: string, technology: Partial<Omit<Technology,
|
|
943
|
+
update(id: string, technology: Partial<Omit<Technology, 'id' | 'createdAt'>>): Promise<Technology | null>;
|
|
904
944
|
delete(id: string): Promise<void>;
|
|
905
945
|
reactivate(id: string): Promise<void>;
|
|
906
946
|
getById(id: string): Promise<Technology | null>;
|
|
907
947
|
addRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
908
948
|
removeRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
909
|
-
getRequirements(technologyId: string, type?:
|
|
949
|
+
getRequirements(technologyId: string, type?: 'pre' | 'post'): Promise<Requirement[]>;
|
|
910
950
|
updateRequirement(technologyId: string, oldRequirement: Requirement, newRequirement: Requirement): Promise<Technology | null>;
|
|
911
951
|
addBlockingCondition(technologyId: string, condition: BlockingCondition): Promise<Technology | null>;
|
|
912
952
|
removeBlockingCondition(technologyId: string, condition: BlockingCondition): Promise<Technology | null>;
|
|
@@ -928,6 +968,7 @@ interface ITechnologyService {
|
|
|
928
968
|
categories: string[];
|
|
929
969
|
subcategories: string[];
|
|
930
970
|
}>;
|
|
971
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
931
972
|
getAllForFilterBySubcategoryId(categoryId: string, subcategoryId: string): Promise<Technology[]>;
|
|
932
973
|
getAllForFilter(): Promise<Technology[]>;
|
|
933
974
|
}
|
|
@@ -1435,7 +1476,7 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1435
1476
|
/**
|
|
1436
1477
|
* Creates a new product under technology
|
|
1437
1478
|
*/
|
|
1438
|
-
create(technologyId: string, brandId: string, product: Omit<Product,
|
|
1479
|
+
create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
|
|
1439
1480
|
/**
|
|
1440
1481
|
* Gets a paginated list of all products, with optional filters.
|
|
1441
1482
|
* This uses a collectionGroup query to search across all technologies.
|
|
@@ -1467,6 +1508,10 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1467
1508
|
bySubcategory: Record<string, number>;
|
|
1468
1509
|
byTechnology: Record<string, number>;
|
|
1469
1510
|
}>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
1513
|
+
*/
|
|
1514
|
+
getAllByTechnology(technologyId: string): Promise<Product[]>;
|
|
1470
1515
|
/**
|
|
1471
1516
|
* Gets all products for a brand by filtering through all technologies
|
|
1472
1517
|
*/
|
|
@@ -1474,7 +1519,7 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1474
1519
|
/**
|
|
1475
1520
|
* Updates a product
|
|
1476
1521
|
*/
|
|
1477
|
-
update(technologyId: string, productId: string, product: Partial<Omit<Product,
|
|
1522
|
+
update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
|
|
1478
1523
|
/**
|
|
1479
1524
|
* Soft deletes a product
|
|
1480
1525
|
*/
|
|
@@ -1678,7 +1723,7 @@ declare class SubcategoryService extends BaseService {
|
|
|
1678
1723
|
/**
|
|
1679
1724
|
* Service for managing technologies.
|
|
1680
1725
|
*/
|
|
1681
|
-
declare class TechnologyService extends BaseService {
|
|
1726
|
+
declare class TechnologyService extends BaseService implements ITechnologyService {
|
|
1682
1727
|
/**
|
|
1683
1728
|
* Reference to the Firestore collection of technologies.
|
|
1684
1729
|
*/
|
|
@@ -1688,7 +1733,7 @@ declare class TechnologyService extends BaseService {
|
|
|
1688
1733
|
* @param technology - Data for the new technology.
|
|
1689
1734
|
* @returns The created technology with its generated ID.
|
|
1690
1735
|
*/
|
|
1691
|
-
create(technology: Omit<Technology,
|
|
1736
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
1692
1737
|
createdAt: Date;
|
|
1693
1738
|
updatedAt: Date;
|
|
1694
1739
|
name: string;
|
|
@@ -1768,7 +1813,7 @@ declare class TechnologyService extends BaseService {
|
|
|
1768
1813
|
* @param technology - New data for the technology.
|
|
1769
1814
|
* @returns The updated technology.
|
|
1770
1815
|
*/
|
|
1771
|
-
update(id: string, technology: Partial<Omit<Technology,
|
|
1816
|
+
update(id: string, technology: Partial<Omit<Technology, 'id' | 'createdAt'>>): Promise<Technology | null>;
|
|
1772
1817
|
/**
|
|
1773
1818
|
* Soft deletes a technology.
|
|
1774
1819
|
* @param id - The ID of the technology to delete.
|
|
@@ -1952,6 +1997,11 @@ declare class TechnologyService extends BaseService {
|
|
|
1952
1997
|
categories: string[];
|
|
1953
1998
|
subcategories: string[];
|
|
1954
1999
|
}>;
|
|
2000
|
+
/**
|
|
2001
|
+
* Gets all active technologies for a subcategory for filter dropdowns (by subcategory only).
|
|
2002
|
+
* @param subcategoryId - The ID of the subcategory.
|
|
2003
|
+
*/
|
|
2004
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
1955
2005
|
/**
|
|
1956
2006
|
* Gets all active technologies for a subcategory for filter dropdowns.
|
|
1957
2007
|
* @param categoryId - The ID of the parent category.
|
|
@@ -6214,4 +6264,4 @@ declare class InvalidTreatmentBenefitError extends TreatmentBenefitError {
|
|
|
6214
6264
|
constructor(benefit: string);
|
|
6215
6265
|
}
|
|
6216
6266
|
|
|
6217
|
-
export { BRANDS_COLLECTION, BackofficeError, BlockingCondition, BlockingConditionError, type Brand, BrandService, CATEGORIES_COLLECTION, type Category, CategoryError, CategoryNotFoundError, CategoryService, CertificationLevel, type CertificationRequirement, CertificationSpecialty, CircularReferenceError, ConstantsService, Contraindication, type ContraindicationDynamic, ContraindicationError, type ContraindicationsDocument, type CreateDocumentTemplateData, Currency, DEFAULT_CERTIFICATION_REQUIREMENT, DOCUMENTATION_TEMPLATES_COLLECTION, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateServiceBackoffice, DynamicVariable, FILLED_DOCUMENTS_COLLECTION, HeadingLevel, type IProductService, type ITechnologyService, InvalidBlockingConditionError, InvalidCategoryDataError, InvalidContraindicationError, InvalidHierarchyError, InvalidRequirementDataError, InvalidSubcategoryDataError, InvalidTechnologyDataError, InvalidTimeframeError, InvalidTreatmentBenefitError, ListType, PRODUCTS_COLLECTION, PricingMeasure, ProcedureFamily, type ProcedureProduct, type Product, ProductService, REQUIREMENTS_COLLECTION, RelationshipError, type Requirement, RequirementError, type RequirementImportance, RequirementNotFoundError, RequirementService, RequirementType, SUBCATEGORIES_COLLECTION, type Subcategory, SubcategoryError, SubcategoryNotFoundError, SubcategoryService, TECHNOLOGIES_COLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyError, TechnologyNotFoundError, type TechnologyRequirements, TechnologyService, type TimeFrame, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, TreatmentBenefitError, type TreatmentBenefitsDocument, type UpdateDocumentTemplateData, blockingConditionSchemaBackoffice, categorySchema, categoryUpdateSchema, certificationLevelSchema, certificationRequirementSchema, certificationSpecialtySchema, contraindicationDynamicSchema, contraindicationSchemaBackoffice, createDocumentTemplateSchema, documentElementSchema, documentElementWithoutIdSchema, documentTemplateSchema, procedureFamilySchemaBackoffice, requirementSchema, requirementTypeSchema, requirementUpdateSchema, subcategorySchema, subcategoryUpdateSchema, technologyRequirementsSchema, technologySchema, technologyUpdateSchema, timeUnitSchemaBackoffice, timeframeSchema, treatmentBenefitDynamicSchema, treatmentBenefitSchemaBackoffice, updateDocumentTemplateSchema };
|
|
6267
|
+
export { BRANDS_COLLECTION, BackofficeError, BlockingCondition, BlockingConditionError, type Brand, BrandService, CATEGORIES_COLLECTION, type Category, CategoryError, CategoryNotFoundError, CategoryService, CertificationLevel, type CertificationRequirement, CertificationSpecialty, CircularReferenceError, ConstantsService, Contraindication, type ContraindicationDynamic, ContraindicationError, type ContraindicationsDocument, type CreateDocumentTemplateData, Currency, DEFAULT_CERTIFICATION_REQUIREMENT, DOCUMENTATION_TEMPLATES_COLLECTION, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateServiceBackoffice, DynamicVariable, FILLED_DOCUMENTS_COLLECTION, HeadingLevel, type ICategoryService, type IProductService, type ITechnologyService, InvalidBlockingConditionError, InvalidCategoryDataError, InvalidContraindicationError, InvalidHierarchyError, InvalidRequirementDataError, InvalidSubcategoryDataError, InvalidTechnologyDataError, InvalidTimeframeError, InvalidTreatmentBenefitError, ListType, PRODUCTS_COLLECTION, PricingMeasure, ProcedureFamily, type ProcedureProduct, type Product, ProductService, REQUIREMENTS_COLLECTION, RelationshipError, type Requirement, RequirementError, type RequirementImportance, RequirementNotFoundError, RequirementService, RequirementType, SUBCATEGORIES_COLLECTION, type Subcategory, SubcategoryError, SubcategoryNotFoundError, SubcategoryService, TECHNOLOGIES_COLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyError, TechnologyNotFoundError, type TechnologyRequirements, TechnologyService, type TimeFrame, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, TreatmentBenefitError, type TreatmentBenefitsDocument, type UpdateDocumentTemplateData, blockingConditionSchemaBackoffice, categorySchema, categoryUpdateSchema, certificationLevelSchema, certificationRequirementSchema, certificationSpecialtySchema, contraindicationDynamicSchema, contraindicationSchemaBackoffice, createDocumentTemplateSchema, documentElementSchema, documentElementWithoutIdSchema, documentTemplateSchema, procedureFamilySchemaBackoffice, requirementSchema, requirementTypeSchema, requirementUpdateSchema, subcategorySchema, subcategoryUpdateSchema, technologyRequirementsSchema, technologySchema, technologyUpdateSchema, timeUnitSchemaBackoffice, timeframeSchema, treatmentBenefitDynamicSchema, treatmentBenefitSchemaBackoffice, updateDocumentTemplateSchema };
|
|
@@ -148,6 +148,35 @@ interface Category {
|
|
|
148
148
|
* Kolekcija u Firestore bazi gde se čuvaju kategorije
|
|
149
149
|
*/
|
|
150
150
|
declare const CATEGORIES_COLLECTION = "backoffice_categories";
|
|
151
|
+
/**
|
|
152
|
+
* Interface for the CategoryService class
|
|
153
|
+
*/
|
|
154
|
+
interface ICategoryService {
|
|
155
|
+
create(category: Omit<Category, 'id' | 'createdAt' | 'updatedAt'>): Promise<Category>;
|
|
156
|
+
getCategoryCounts(active?: boolean): Promise<Record<string, number>>;
|
|
157
|
+
getAllForFilter(): Promise<Category[]>;
|
|
158
|
+
getAllForFilterByFamily(family: ProcedureFamily): Promise<Category[]>;
|
|
159
|
+
getAll(options?: {
|
|
160
|
+
active?: boolean;
|
|
161
|
+
limit?: number;
|
|
162
|
+
lastVisible?: any;
|
|
163
|
+
}): Promise<{
|
|
164
|
+
categories: Category[];
|
|
165
|
+
lastVisible: any;
|
|
166
|
+
}>;
|
|
167
|
+
getAllByFamily(family: ProcedureFamily, options?: {
|
|
168
|
+
active?: boolean;
|
|
169
|
+
limit?: number;
|
|
170
|
+
lastVisible?: any;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
categories: Category[];
|
|
173
|
+
lastVisible: any;
|
|
174
|
+
}>;
|
|
175
|
+
update(id: string, category: Partial<Omit<Category, 'id' | 'createdAt'>>): Promise<Category | null>;
|
|
176
|
+
delete(id: string): Promise<void>;
|
|
177
|
+
reactivate(id: string): Promise<void>;
|
|
178
|
+
getById(id: string): Promise<Category | null>;
|
|
179
|
+
}
|
|
151
180
|
|
|
152
181
|
/**
|
|
153
182
|
* Servis za upravljanje kategorijama procedura.
|
|
@@ -162,7 +191,7 @@ declare const CATEGORIES_COLLECTION = "backoffice_categories";
|
|
|
162
191
|
* family: ProcedureFamily.AESTHETICS
|
|
163
192
|
* });
|
|
164
193
|
*/
|
|
165
|
-
declare class CategoryService extends BaseService {
|
|
194
|
+
declare class CategoryService extends BaseService implements ICategoryService {
|
|
166
195
|
/**
|
|
167
196
|
* Referenca na Firestore kolekciju kategorija
|
|
168
197
|
*/
|
|
@@ -172,7 +201,7 @@ declare class CategoryService extends BaseService {
|
|
|
172
201
|
* @param category - Podaci za novu kategoriju
|
|
173
202
|
* @returns Kreirana kategorija sa generisanim ID-em
|
|
174
203
|
*/
|
|
175
|
-
create(category: Omit<Category,
|
|
204
|
+
create(category: Omit<Category, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
176
205
|
createdAt: Date;
|
|
177
206
|
updatedAt: Date;
|
|
178
207
|
name: string;
|
|
@@ -192,6 +221,12 @@ declare class CategoryService extends BaseService {
|
|
|
192
221
|
* @returns Lista svih aktivnih kategorija
|
|
193
222
|
*/
|
|
194
223
|
getAllForFilter(): Promise<Category[]>;
|
|
224
|
+
/**
|
|
225
|
+
* Vraća sve kategorije za određenu familiju za potrebe filtera (bez paginacije)
|
|
226
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
227
|
+
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
228
|
+
*/
|
|
229
|
+
getAllForFilterByFamily(family: ProcedureFamily): Promise<Category[]>;
|
|
195
230
|
/**
|
|
196
231
|
* Vraća sve kategorije sa paginacijom
|
|
197
232
|
* @param options - Pagination and filter options
|
|
@@ -225,7 +260,7 @@ declare class CategoryService extends BaseService {
|
|
|
225
260
|
* @param category - Novi podaci za kategoriju
|
|
226
261
|
* @returns Ažurirana kategorija
|
|
227
262
|
*/
|
|
228
|
-
update(id: string, category: Partial<Omit<Category,
|
|
263
|
+
update(id: string, category: Partial<Omit<Category, 'id' | 'createdAt'>>): Promise<Category | null>;
|
|
229
264
|
/**
|
|
230
265
|
* Soft delete kategorije (postavlja isActive na false)
|
|
231
266
|
* @param id - ID kategorije koja se briše
|
|
@@ -593,7 +628,7 @@ interface IProductService {
|
|
|
593
628
|
* @param brandId - ID of the brand that manufactures this product
|
|
594
629
|
* @param product - Product data
|
|
595
630
|
*/
|
|
596
|
-
create(technologyId: string, brandId: string, product: Omit<Product,
|
|
631
|
+
create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
|
|
597
632
|
/**
|
|
598
633
|
* Gets a paginated list of all products, with optional filters.
|
|
599
634
|
*/
|
|
@@ -623,6 +658,11 @@ interface IProductService {
|
|
|
623
658
|
bySubcategory: Record<string, number>;
|
|
624
659
|
byTechnology: Record<string, number>;
|
|
625
660
|
}>;
|
|
661
|
+
/**
|
|
662
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
663
|
+
* @param technologyId - ID of the technology
|
|
664
|
+
*/
|
|
665
|
+
getAllByTechnology(technologyId: string): Promise<Product[]>;
|
|
626
666
|
/**
|
|
627
667
|
* Gets all products for a brand
|
|
628
668
|
* @param brandId - ID of the brand
|
|
@@ -634,7 +674,7 @@ interface IProductService {
|
|
|
634
674
|
* @param productId - ID of the product to update
|
|
635
675
|
* @param product - Updated product data
|
|
636
676
|
*/
|
|
637
|
-
update(technologyId: string, productId: string, product: Partial<Omit<Product,
|
|
677
|
+
update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
|
|
638
678
|
/**
|
|
639
679
|
* Deletes a product (soft delete)
|
|
640
680
|
* @param technologyId - ID of the technology
|
|
@@ -873,7 +913,7 @@ declare const TECHNOLOGIES_COLLECTION = "technologies";
|
|
|
873
913
|
* Interface for the TechnologyService class
|
|
874
914
|
*/
|
|
875
915
|
interface ITechnologyService {
|
|
876
|
-
create(technology: Omit<Technology,
|
|
916
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<Technology>;
|
|
877
917
|
getTechnologyCounts(active?: boolean): Promise<Record<string, number>>;
|
|
878
918
|
getTechnologyCountsByCategory(active?: boolean): Promise<Record<string, number>>;
|
|
879
919
|
getAll(options?: {
|
|
@@ -900,13 +940,13 @@ interface ITechnologyService {
|
|
|
900
940
|
technologies: Technology[];
|
|
901
941
|
lastVisible: any;
|
|
902
942
|
}>;
|
|
903
|
-
update(id: string, technology: Partial<Omit<Technology,
|
|
943
|
+
update(id: string, technology: Partial<Omit<Technology, 'id' | 'createdAt'>>): Promise<Technology | null>;
|
|
904
944
|
delete(id: string): Promise<void>;
|
|
905
945
|
reactivate(id: string): Promise<void>;
|
|
906
946
|
getById(id: string): Promise<Technology | null>;
|
|
907
947
|
addRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
908
948
|
removeRequirement(technologyId: string, requirement: Requirement): Promise<Technology | null>;
|
|
909
|
-
getRequirements(technologyId: string, type?:
|
|
949
|
+
getRequirements(technologyId: string, type?: 'pre' | 'post'): Promise<Requirement[]>;
|
|
910
950
|
updateRequirement(technologyId: string, oldRequirement: Requirement, newRequirement: Requirement): Promise<Technology | null>;
|
|
911
951
|
addBlockingCondition(technologyId: string, condition: BlockingCondition): Promise<Technology | null>;
|
|
912
952
|
removeBlockingCondition(technologyId: string, condition: BlockingCondition): Promise<Technology | null>;
|
|
@@ -928,6 +968,7 @@ interface ITechnologyService {
|
|
|
928
968
|
categories: string[];
|
|
929
969
|
subcategories: string[];
|
|
930
970
|
}>;
|
|
971
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
931
972
|
getAllForFilterBySubcategoryId(categoryId: string, subcategoryId: string): Promise<Technology[]>;
|
|
932
973
|
getAllForFilter(): Promise<Technology[]>;
|
|
933
974
|
}
|
|
@@ -1435,7 +1476,7 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1435
1476
|
/**
|
|
1436
1477
|
* Creates a new product under technology
|
|
1437
1478
|
*/
|
|
1438
|
-
create(technologyId: string, brandId: string, product: Omit<Product,
|
|
1479
|
+
create(technologyId: string, brandId: string, product: Omit<Product, 'id' | 'createdAt' | 'updatedAt' | 'brandId' | 'technologyId'>): Promise<Product>;
|
|
1439
1480
|
/**
|
|
1440
1481
|
* Gets a paginated list of all products, with optional filters.
|
|
1441
1482
|
* This uses a collectionGroup query to search across all technologies.
|
|
@@ -1467,6 +1508,10 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1467
1508
|
bySubcategory: Record<string, number>;
|
|
1468
1509
|
byTechnology: Record<string, number>;
|
|
1469
1510
|
}>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
1513
|
+
*/
|
|
1514
|
+
getAllByTechnology(technologyId: string): Promise<Product[]>;
|
|
1470
1515
|
/**
|
|
1471
1516
|
* Gets all products for a brand by filtering through all technologies
|
|
1472
1517
|
*/
|
|
@@ -1474,7 +1519,7 @@ declare class ProductService extends BaseService implements IProductService {
|
|
|
1474
1519
|
/**
|
|
1475
1520
|
* Updates a product
|
|
1476
1521
|
*/
|
|
1477
|
-
update(technologyId: string, productId: string, product: Partial<Omit<Product,
|
|
1522
|
+
update(technologyId: string, productId: string, product: Partial<Omit<Product, 'id' | 'createdAt' | 'brandId' | 'technologyId'>>): Promise<Product | null>;
|
|
1478
1523
|
/**
|
|
1479
1524
|
* Soft deletes a product
|
|
1480
1525
|
*/
|
|
@@ -1678,7 +1723,7 @@ declare class SubcategoryService extends BaseService {
|
|
|
1678
1723
|
/**
|
|
1679
1724
|
* Service for managing technologies.
|
|
1680
1725
|
*/
|
|
1681
|
-
declare class TechnologyService extends BaseService {
|
|
1726
|
+
declare class TechnologyService extends BaseService implements ITechnologyService {
|
|
1682
1727
|
/**
|
|
1683
1728
|
* Reference to the Firestore collection of technologies.
|
|
1684
1729
|
*/
|
|
@@ -1688,7 +1733,7 @@ declare class TechnologyService extends BaseService {
|
|
|
1688
1733
|
* @param technology - Data for the new technology.
|
|
1689
1734
|
* @returns The created technology with its generated ID.
|
|
1690
1735
|
*/
|
|
1691
|
-
create(technology: Omit<Technology,
|
|
1736
|
+
create(technology: Omit<Technology, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
1692
1737
|
createdAt: Date;
|
|
1693
1738
|
updatedAt: Date;
|
|
1694
1739
|
name: string;
|
|
@@ -1768,7 +1813,7 @@ declare class TechnologyService extends BaseService {
|
|
|
1768
1813
|
* @param technology - New data for the technology.
|
|
1769
1814
|
* @returns The updated technology.
|
|
1770
1815
|
*/
|
|
1771
|
-
update(id: string, technology: Partial<Omit<Technology,
|
|
1816
|
+
update(id: string, technology: Partial<Omit<Technology, 'id' | 'createdAt'>>): Promise<Technology | null>;
|
|
1772
1817
|
/**
|
|
1773
1818
|
* Soft deletes a technology.
|
|
1774
1819
|
* @param id - The ID of the technology to delete.
|
|
@@ -1952,6 +1997,11 @@ declare class TechnologyService extends BaseService {
|
|
|
1952
1997
|
categories: string[];
|
|
1953
1998
|
subcategories: string[];
|
|
1954
1999
|
}>;
|
|
2000
|
+
/**
|
|
2001
|
+
* Gets all active technologies for a subcategory for filter dropdowns (by subcategory only).
|
|
2002
|
+
* @param subcategoryId - The ID of the subcategory.
|
|
2003
|
+
*/
|
|
2004
|
+
getAllForFilterBySubcategory(subcategoryId: string): Promise<Technology[]>;
|
|
1955
2005
|
/**
|
|
1956
2006
|
* Gets all active technologies for a subcategory for filter dropdowns.
|
|
1957
2007
|
* @param categoryId - The ID of the parent category.
|
|
@@ -6214,4 +6264,4 @@ declare class InvalidTreatmentBenefitError extends TreatmentBenefitError {
|
|
|
6214
6264
|
constructor(benefit: string);
|
|
6215
6265
|
}
|
|
6216
6266
|
|
|
6217
|
-
export { BRANDS_COLLECTION, BackofficeError, BlockingCondition, BlockingConditionError, type Brand, BrandService, CATEGORIES_COLLECTION, type Category, CategoryError, CategoryNotFoundError, CategoryService, CertificationLevel, type CertificationRequirement, CertificationSpecialty, CircularReferenceError, ConstantsService, Contraindication, type ContraindicationDynamic, ContraindicationError, type ContraindicationsDocument, type CreateDocumentTemplateData, Currency, DEFAULT_CERTIFICATION_REQUIREMENT, DOCUMENTATION_TEMPLATES_COLLECTION, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateServiceBackoffice, DynamicVariable, FILLED_DOCUMENTS_COLLECTION, HeadingLevel, type IProductService, type ITechnologyService, InvalidBlockingConditionError, InvalidCategoryDataError, InvalidContraindicationError, InvalidHierarchyError, InvalidRequirementDataError, InvalidSubcategoryDataError, InvalidTechnologyDataError, InvalidTimeframeError, InvalidTreatmentBenefitError, ListType, PRODUCTS_COLLECTION, PricingMeasure, ProcedureFamily, type ProcedureProduct, type Product, ProductService, REQUIREMENTS_COLLECTION, RelationshipError, type Requirement, RequirementError, type RequirementImportance, RequirementNotFoundError, RequirementService, RequirementType, SUBCATEGORIES_COLLECTION, type Subcategory, SubcategoryError, SubcategoryNotFoundError, SubcategoryService, TECHNOLOGIES_COLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyError, TechnologyNotFoundError, type TechnologyRequirements, TechnologyService, type TimeFrame, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, TreatmentBenefitError, type TreatmentBenefitsDocument, type UpdateDocumentTemplateData, blockingConditionSchemaBackoffice, categorySchema, categoryUpdateSchema, certificationLevelSchema, certificationRequirementSchema, certificationSpecialtySchema, contraindicationDynamicSchema, contraindicationSchemaBackoffice, createDocumentTemplateSchema, documentElementSchema, documentElementWithoutIdSchema, documentTemplateSchema, procedureFamilySchemaBackoffice, requirementSchema, requirementTypeSchema, requirementUpdateSchema, subcategorySchema, subcategoryUpdateSchema, technologyRequirementsSchema, technologySchema, technologyUpdateSchema, timeUnitSchemaBackoffice, timeframeSchema, treatmentBenefitDynamicSchema, treatmentBenefitSchemaBackoffice, updateDocumentTemplateSchema };
|
|
6267
|
+
export { BRANDS_COLLECTION, BackofficeError, BlockingCondition, BlockingConditionError, type Brand, BrandService, CATEGORIES_COLLECTION, type Category, CategoryError, CategoryNotFoundError, CategoryService, CertificationLevel, type CertificationRequirement, CertificationSpecialty, CircularReferenceError, ConstantsService, Contraindication, type ContraindicationDynamic, ContraindicationError, type ContraindicationsDocument, type CreateDocumentTemplateData, Currency, DEFAULT_CERTIFICATION_REQUIREMENT, DOCUMENTATION_TEMPLATES_COLLECTION, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateServiceBackoffice, DynamicVariable, FILLED_DOCUMENTS_COLLECTION, HeadingLevel, type ICategoryService, type IProductService, type ITechnologyService, InvalidBlockingConditionError, InvalidCategoryDataError, InvalidContraindicationError, InvalidHierarchyError, InvalidRequirementDataError, InvalidSubcategoryDataError, InvalidTechnologyDataError, InvalidTimeframeError, InvalidTreatmentBenefitError, ListType, PRODUCTS_COLLECTION, PricingMeasure, ProcedureFamily, type ProcedureProduct, type Product, ProductService, REQUIREMENTS_COLLECTION, RelationshipError, type Requirement, RequirementError, type RequirementImportance, RequirementNotFoundError, RequirementService, RequirementType, SUBCATEGORIES_COLLECTION, type Subcategory, SubcategoryError, SubcategoryNotFoundError, SubcategoryService, TECHNOLOGIES_COLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyError, TechnologyNotFoundError, type TechnologyRequirements, TechnologyService, type TimeFrame, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, TreatmentBenefitError, type TreatmentBenefitsDocument, type UpdateDocumentTemplateData, blockingConditionSchemaBackoffice, categorySchema, categoryUpdateSchema, certificationLevelSchema, certificationRequirementSchema, certificationSpecialtySchema, contraindicationDynamicSchema, contraindicationSchemaBackoffice, createDocumentTemplateSchema, documentElementSchema, documentElementWithoutIdSchema, documentTemplateSchema, procedureFamilySchemaBackoffice, requirementSchema, requirementTypeSchema, requirementUpdateSchema, subcategorySchema, subcategoryUpdateSchema, technologyRequirementsSchema, technologySchema, technologyUpdateSchema, timeUnitSchemaBackoffice, timeframeSchema, treatmentBenefitDynamicSchema, treatmentBenefitSchemaBackoffice, updateDocumentTemplateSchema };
|
package/dist/backoffice/index.js
CHANGED
|
@@ -333,6 +333,26 @@ var CategoryService = class extends BaseService {
|
|
|
333
333
|
})
|
|
334
334
|
);
|
|
335
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Vraća sve kategorije za određenu familiju za potrebe filtera (bez paginacije)
|
|
338
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
339
|
+
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
340
|
+
*/
|
|
341
|
+
async getAllForFilterByFamily(family) {
|
|
342
|
+
const q = (0, import_firestore2.query)(
|
|
343
|
+
this.categoriesRef,
|
|
344
|
+
(0, import_firestore2.where)("family", "==", family),
|
|
345
|
+
(0, import_firestore2.where)("isActive", "==", true),
|
|
346
|
+
(0, import_firestore2.orderBy)("name")
|
|
347
|
+
);
|
|
348
|
+
const snapshot = await (0, import_firestore2.getDocs)(q);
|
|
349
|
+
return snapshot.docs.map(
|
|
350
|
+
(doc11) => ({
|
|
351
|
+
id: doc11.id,
|
|
352
|
+
...doc11.data()
|
|
353
|
+
})
|
|
354
|
+
);
|
|
355
|
+
}
|
|
336
356
|
/**
|
|
337
357
|
* Vraća sve kategorije sa paginacijom
|
|
338
358
|
* @param options - Pagination and filter options
|
|
@@ -1178,12 +1198,7 @@ var ProductService = class extends BaseService {
|
|
|
1178
1198
|
* @returns Firestore collection reference
|
|
1179
1199
|
*/
|
|
1180
1200
|
getProductsRef(technologyId) {
|
|
1181
|
-
return (0, import_firestore8.collection)(
|
|
1182
|
-
this.db,
|
|
1183
|
-
TECHNOLOGIES_COLLECTION,
|
|
1184
|
-
technologyId,
|
|
1185
|
-
PRODUCTS_COLLECTION
|
|
1186
|
-
);
|
|
1201
|
+
return (0, import_firestore8.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
1187
1202
|
}
|
|
1188
1203
|
/**
|
|
1189
1204
|
* Creates a new product under technology
|
|
@@ -1198,10 +1213,7 @@ var ProductService = class extends BaseService {
|
|
|
1198
1213
|
updatedAt: now,
|
|
1199
1214
|
isActive: true
|
|
1200
1215
|
};
|
|
1201
|
-
const productRef = await (0, import_firestore8.addDoc)(
|
|
1202
|
-
this.getProductsRef(technologyId),
|
|
1203
|
-
newProduct
|
|
1204
|
-
);
|
|
1216
|
+
const productRef = await (0, import_firestore8.addDoc)(this.getProductsRef(technologyId), newProduct);
|
|
1205
1217
|
return { id: productRef.id, ...newProduct };
|
|
1206
1218
|
}
|
|
1207
1219
|
/**
|
|
@@ -1209,17 +1221,8 @@ var ProductService = class extends BaseService {
|
|
|
1209
1221
|
* This uses a collectionGroup query to search across all technologies.
|
|
1210
1222
|
*/
|
|
1211
1223
|
async getAll(options) {
|
|
1212
|
-
const {
|
|
1213
|
-
|
|
1214
|
-
lastVisible,
|
|
1215
|
-
categoryId,
|
|
1216
|
-
subcategoryId,
|
|
1217
|
-
technologyId
|
|
1218
|
-
} = options;
|
|
1219
|
-
const constraints = [
|
|
1220
|
-
(0, import_firestore8.where)("isActive", "==", true),
|
|
1221
|
-
(0, import_firestore8.orderBy)("name")
|
|
1222
|
-
];
|
|
1224
|
+
const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
|
|
1225
|
+
const constraints = [(0, import_firestore8.where)("isActive", "==", true), (0, import_firestore8.orderBy)("name")];
|
|
1223
1226
|
if (categoryId) {
|
|
1224
1227
|
constraints.push((0, import_firestore8.where)("categoryId", "==", categoryId));
|
|
1225
1228
|
}
|
|
@@ -1233,10 +1236,7 @@ var ProductService = class extends BaseService {
|
|
|
1233
1236
|
constraints.push((0, import_firestore8.startAfter)(lastVisible));
|
|
1234
1237
|
}
|
|
1235
1238
|
constraints.push((0, import_firestore8.limit)(rowsPerPage));
|
|
1236
|
-
const q = (0, import_firestore8.query)(
|
|
1237
|
-
(0, import_firestore8.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
1238
|
-
...constraints
|
|
1239
|
-
);
|
|
1239
|
+
const q = (0, import_firestore8.query)((0, import_firestore8.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
1240
1240
|
const snapshot = await (0, import_firestore8.getDocs)(q);
|
|
1241
1241
|
const products = snapshot.docs.map(
|
|
1242
1242
|
(doc11) => ({
|
|
@@ -1262,10 +1262,7 @@ var ProductService = class extends BaseService {
|
|
|
1262
1262
|
if (technologyId) {
|
|
1263
1263
|
constraints.push((0, import_firestore8.where)("technologyId", "==", technologyId));
|
|
1264
1264
|
}
|
|
1265
|
-
const q = (0, import_firestore8.query)(
|
|
1266
|
-
(0, import_firestore8.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
1267
|
-
...constraints
|
|
1268
|
-
);
|
|
1265
|
+
const q = (0, import_firestore8.query)((0, import_firestore8.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
1269
1266
|
const snapshot = await (0, import_firestore8.getCountFromServer)(q);
|
|
1270
1267
|
return snapshot.data().count;
|
|
1271
1268
|
}
|
|
@@ -1274,10 +1271,7 @@ var ProductService = class extends BaseService {
|
|
|
1274
1271
|
* This uses a single collectionGroup query for efficiency.
|
|
1275
1272
|
*/
|
|
1276
1273
|
async getProductCounts() {
|
|
1277
|
-
const q = (0, import_firestore8.query)(
|
|
1278
|
-
(0, import_firestore8.collectionGroup)(this.db, PRODUCTS_COLLECTION),
|
|
1279
|
-
(0, import_firestore8.where)("isActive", "==", true)
|
|
1280
|
-
);
|
|
1274
|
+
const q = (0, import_firestore8.query)((0, import_firestore8.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore8.where)("isActive", "==", true));
|
|
1281
1275
|
const snapshot = await (0, import_firestore8.getDocs)(q);
|
|
1282
1276
|
const counts = {
|
|
1283
1277
|
byCategory: {},
|
|
@@ -1302,6 +1296,23 @@ var ProductService = class extends BaseService {
|
|
|
1302
1296
|
});
|
|
1303
1297
|
return counts;
|
|
1304
1298
|
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
1301
|
+
*/
|
|
1302
|
+
async getAllByTechnology(technologyId) {
|
|
1303
|
+
const q = (0, import_firestore8.query)(
|
|
1304
|
+
this.getProductsRef(technologyId),
|
|
1305
|
+
(0, import_firestore8.where)("isActive", "==", true),
|
|
1306
|
+
(0, import_firestore8.orderBy)("name")
|
|
1307
|
+
);
|
|
1308
|
+
const snapshot = await (0, import_firestore8.getDocs)(q);
|
|
1309
|
+
return snapshot.docs.map(
|
|
1310
|
+
(doc11) => ({
|
|
1311
|
+
id: doc11.id,
|
|
1312
|
+
...doc11.data()
|
|
1313
|
+
})
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1305
1316
|
/**
|
|
1306
1317
|
* Gets all products for a brand by filtering through all technologies
|
|
1307
1318
|
*/
|
|
@@ -2048,7 +2059,9 @@ var TechnologyService = class extends BaseService {
|
|
|
2048
2059
|
if (!technology) {
|
|
2049
2060
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
2050
2061
|
}
|
|
2051
|
-
const updatedContraindications = (technology.contraindications || []).filter(
|
|
2062
|
+
const updatedContraindications = (technology.contraindications || []).filter(
|
|
2063
|
+
(c) => c.id !== contraindication.id
|
|
2064
|
+
);
|
|
2052
2065
|
await (0, import_firestore11.updateDoc)(docRef, {
|
|
2053
2066
|
contraindications: updatedContraindications,
|
|
2054
2067
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -2069,9 +2082,7 @@ var TechnologyService = class extends BaseService {
|
|
|
2069
2082
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
2070
2083
|
}
|
|
2071
2084
|
const contraindications = technology.contraindications || [];
|
|
2072
|
-
const index = contraindications.findIndex(
|
|
2073
|
-
(c) => c.id === contraindication.id
|
|
2074
|
-
);
|
|
2085
|
+
const index = contraindications.findIndex((c) => c.id === contraindication.id);
|
|
2075
2086
|
if (index === -1) {
|
|
2076
2087
|
console.warn(
|
|
2077
2088
|
`Contraindication with id ${contraindication.id} not found for technology ${technologyId}. No update performed.`
|
|
@@ -2120,9 +2131,7 @@ var TechnologyService = class extends BaseService {
|
|
|
2120
2131
|
if (!technology) {
|
|
2121
2132
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
2122
2133
|
}
|
|
2123
|
-
const updatedBenefits = (technology.benefits || []).filter(
|
|
2124
|
-
(b) => b.id !== benefit.id
|
|
2125
|
-
);
|
|
2134
|
+
const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
|
|
2126
2135
|
await (0, import_firestore11.updateDoc)(docRef, {
|
|
2127
2136
|
benefits: updatedBenefits,
|
|
2128
2137
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -2228,9 +2237,7 @@ var TechnologyService = class extends BaseService {
|
|
|
2228
2237
|
* );
|
|
2229
2238
|
*/
|
|
2230
2239
|
validateCertification(requiredCertification, practitionerCertification) {
|
|
2231
|
-
const doctorLevel = Object.values(CertificationLevel).indexOf(
|
|
2232
|
-
practitionerCertification.level
|
|
2233
|
-
);
|
|
2240
|
+
const doctorLevel = Object.values(CertificationLevel).indexOf(practitionerCertification.level);
|
|
2234
2241
|
const requiredLevel = Object.values(CertificationLevel).indexOf(
|
|
2235
2242
|
requiredCertification.minimumLevel
|
|
2236
2243
|
);
|
|
@@ -2271,18 +2278,11 @@ var TechnologyService = class extends BaseService {
|
|
|
2271
2278
|
async getAllowedTechnologies(practitioner) {
|
|
2272
2279
|
const allTechnologies = await this.getAll();
|
|
2273
2280
|
const allowedTechnologies = allTechnologies.technologies.filter(
|
|
2274
|
-
(technology) => this.validateCertification(
|
|
2275
|
-
technology.certificationRequirement,
|
|
2276
|
-
practitioner.certification
|
|
2277
|
-
)
|
|
2281
|
+
(technology) => this.validateCertification(technology.certificationRequirement, practitioner.certification)
|
|
2278
2282
|
);
|
|
2279
2283
|
const families = [...new Set(allowedTechnologies.map((t) => t.family))];
|
|
2280
|
-
const categories = [
|
|
2281
|
-
|
|
2282
|
-
];
|
|
2283
|
-
const subcategories = [
|
|
2284
|
-
...new Set(allowedTechnologies.map((t) => t.subcategoryId))
|
|
2285
|
-
];
|
|
2284
|
+
const categories = [...new Set(allowedTechnologies.map((t) => t.categoryId))];
|
|
2285
|
+
const subcategories = [...new Set(allowedTechnologies.map((t) => t.subcategoryId))];
|
|
2286
2286
|
return {
|
|
2287
2287
|
technologies: allowedTechnologies,
|
|
2288
2288
|
families,
|
|
@@ -2290,6 +2290,25 @@ var TechnologyService = class extends BaseService {
|
|
|
2290
2290
|
subcategories
|
|
2291
2291
|
};
|
|
2292
2292
|
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Gets all active technologies for a subcategory for filter dropdowns (by subcategory only).
|
|
2295
|
+
* @param subcategoryId - The ID of the subcategory.
|
|
2296
|
+
*/
|
|
2297
|
+
async getAllForFilterBySubcategory(subcategoryId) {
|
|
2298
|
+
const q = (0, import_firestore11.query)(
|
|
2299
|
+
(0, import_firestore11.collection)(this.db, TECHNOLOGIES_COLLECTION),
|
|
2300
|
+
(0, import_firestore11.where)("isActive", "==", true),
|
|
2301
|
+
(0, import_firestore11.where)("subcategoryId", "==", subcategoryId),
|
|
2302
|
+
(0, import_firestore11.orderBy)("name")
|
|
2303
|
+
);
|
|
2304
|
+
const snapshot = await (0, import_firestore11.getDocs)(q);
|
|
2305
|
+
return snapshot.docs.map(
|
|
2306
|
+
(doc11) => ({
|
|
2307
|
+
id: doc11.id,
|
|
2308
|
+
...doc11.data()
|
|
2309
|
+
})
|
|
2310
|
+
);
|
|
2311
|
+
}
|
|
2293
2312
|
/**
|
|
2294
2313
|
* Gets all active technologies for a subcategory for filter dropdowns.
|
|
2295
2314
|
* @param categoryId - The ID of the parent category.
|