@blackcode_sa/metaestetics-api 1.12.53 → 1.12.55
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/index.js +34 -8
- package/dist/index.mjs +34 -8
- package/package.json +1 -1
- package/src/admin/booking/booking.admin.ts +15 -15
- package/src/services/appointment/utils/extended-procedure.utils.ts +19 -19
- package/src/services/appointment/utils/recommended-procedure.utils.ts +5 -5
- package/src/services/procedure/procedure.service.ts +44 -4
package/dist/index.js
CHANGED
|
@@ -16492,7 +16492,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16492
16492
|
* @returns The created procedure
|
|
16493
16493
|
*/
|
|
16494
16494
|
async createProcedure(data) {
|
|
16495
|
-
var _a, _b
|
|
16495
|
+
var _a, _b;
|
|
16496
16496
|
const validatedData = createProcedureSchema.parse(data);
|
|
16497
16497
|
const isProductFree = !validatedData.productId;
|
|
16498
16498
|
const procedureId = this.generateId();
|
|
@@ -16577,7 +16577,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16577
16577
|
contraindications: technology.contraindications || [],
|
|
16578
16578
|
contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
|
|
16579
16579
|
treatmentBenefits: technology.benefits,
|
|
16580
|
-
treatmentBenefitIds: (
|
|
16580
|
+
treatmentBenefitIds: Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [],
|
|
16581
16581
|
preRequirements: technology.requirements.pre,
|
|
16582
16582
|
postRequirements: technology.requirements.post,
|
|
16583
16583
|
certificationRequirement: technology.certificationRequirement,
|
|
@@ -16600,6 +16600,19 @@ var ProcedureService = class extends BaseService {
|
|
|
16600
16600
|
isActive: true
|
|
16601
16601
|
// Default to active
|
|
16602
16602
|
};
|
|
16603
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} CREATE PROCEDURE - Processing procedure:", procedureId);
|
|
16604
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} FULL PROCEDURE OBJECT:", JSON.stringify(newProcedure, null, 2));
|
|
16605
|
+
const undefinedFields = [];
|
|
16606
|
+
Object.entries(newProcedure).forEach(([key, value]) => {
|
|
16607
|
+
if (value === void 0) {
|
|
16608
|
+
undefinedFields.push(key);
|
|
16609
|
+
}
|
|
16610
|
+
});
|
|
16611
|
+
if (undefinedFields.length > 0) {
|
|
16612
|
+
console.error("\u{1F525}\u{1F525}\u{1F525} UNDEFINED FIELDS DETECTED:", undefinedFields);
|
|
16613
|
+
throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(", ")}`);
|
|
16614
|
+
}
|
|
16615
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with setDoc");
|
|
16603
16616
|
const procedureRef = (0, import_firestore55.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
16604
16617
|
await (0, import_firestore55.setDoc)(procedureRef, {
|
|
16605
16618
|
...newProcedure,
|
|
@@ -16618,7 +16631,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16618
16631
|
* @returns A promise that resolves to an array of the newly created procedures.
|
|
16619
16632
|
*/
|
|
16620
16633
|
async bulkCreateProcedures(baseData, practitionerIds) {
|
|
16621
|
-
var _a, _b
|
|
16634
|
+
var _a, _b;
|
|
16622
16635
|
if (!practitionerIds || practitionerIds.length === 0) {
|
|
16623
16636
|
throw new Error("Practitioner IDs array cannot be empty.");
|
|
16624
16637
|
}
|
|
@@ -16726,7 +16739,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16726
16739
|
contraindications: technology.contraindications || [],
|
|
16727
16740
|
contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
|
|
16728
16741
|
treatmentBenefits: technology.benefits,
|
|
16729
|
-
treatmentBenefitIds: (
|
|
16742
|
+
treatmentBenefitIds: Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [],
|
|
16730
16743
|
preRequirements: technology.requirements.pre,
|
|
16731
16744
|
postRequirements: technology.requirements.post,
|
|
16732
16745
|
certificationRequirement: technology.certificationRequirement,
|
|
@@ -16746,6 +16759,19 @@ var ProcedureService = class extends BaseService {
|
|
|
16746
16759
|
},
|
|
16747
16760
|
isActive: true
|
|
16748
16761
|
};
|
|
16762
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} BULK CREATE - Processing procedure:", procedureId, "for practitioner:", practitionerId);
|
|
16763
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} FULL PROCEDURE OBJECT:", JSON.stringify(newProcedure, null, 2));
|
|
16764
|
+
const undefinedFields = [];
|
|
16765
|
+
Object.entries(newProcedure).forEach(([key, value]) => {
|
|
16766
|
+
if (value === void 0) {
|
|
16767
|
+
undefinedFields.push(key);
|
|
16768
|
+
}
|
|
16769
|
+
});
|
|
16770
|
+
if (undefinedFields.length > 0) {
|
|
16771
|
+
console.error("\u{1F525}\u{1F525}\u{1F525} UNDEFINED FIELDS DETECTED:", undefinedFields);
|
|
16772
|
+
throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(", ")}`);
|
|
16773
|
+
}
|
|
16774
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with batch.set");
|
|
16749
16775
|
batch.set(procedureRef, {
|
|
16750
16776
|
...newProcedure,
|
|
16751
16777
|
createdAt: (0, import_firestore55.serverTimestamp)(),
|
|
@@ -16826,7 +16852,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16826
16852
|
* @returns The updated procedure
|
|
16827
16853
|
*/
|
|
16828
16854
|
async updateProcedure(id, data) {
|
|
16829
|
-
var _a, _b, _c
|
|
16855
|
+
var _a, _b, _c;
|
|
16830
16856
|
const validatedData = updateProcedureSchema.parse(data);
|
|
16831
16857
|
const procedureRef = (0, import_firestore55.doc)(this.db, PROCEDURES_COLLECTION, id);
|
|
16832
16858
|
const procedureSnapshot = await (0, import_firestore55.getDoc)(procedureRef);
|
|
@@ -16940,7 +16966,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16940
16966
|
updatedProcedureData.contraindications = technology.contraindications || [];
|
|
16941
16967
|
updatedProcedureData.contraindicationIds = ((_c = technology.contraindications) == null ? void 0 : _c.map((c) => c.id)) || [];
|
|
16942
16968
|
updatedProcedureData.treatmentBenefits = technology.benefits;
|
|
16943
|
-
updatedProcedureData.treatmentBenefitIds = (
|
|
16969
|
+
updatedProcedureData.treatmentBenefitIds = Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [];
|
|
16944
16970
|
updatedProcedureData.preRequirements = technology.requirements.pre;
|
|
16945
16971
|
updatedProcedureData.postRequirements = technology.requirements.post;
|
|
16946
16972
|
updatedProcedureData.certificationRequirement = technology.certificationRequirement;
|
|
@@ -17460,7 +17486,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17460
17486
|
* @returns The created procedure
|
|
17461
17487
|
*/
|
|
17462
17488
|
async createConsultationProcedure(data) {
|
|
17463
|
-
var _a, _b
|
|
17489
|
+
var _a, _b;
|
|
17464
17490
|
const procedureId = this.generateId();
|
|
17465
17491
|
const [category, subcategory, technology] = await Promise.all([
|
|
17466
17492
|
this.categoryService.getById(data.categoryId),
|
|
@@ -17522,7 +17548,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17522
17548
|
contraindications: technology.contraindications || [],
|
|
17523
17549
|
contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
|
|
17524
17550
|
treatmentBenefits: technology.benefits,
|
|
17525
|
-
treatmentBenefitIds: (
|
|
17551
|
+
treatmentBenefitIds: Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [],
|
|
17526
17552
|
preRequirements: technology.requirements.pre,
|
|
17527
17553
|
postRequirements: technology.requirements.post,
|
|
17528
17554
|
certificationRequirement: technology.certificationRequirement,
|
package/dist/index.mjs
CHANGED
|
@@ -16740,7 +16740,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16740
16740
|
* @returns The created procedure
|
|
16741
16741
|
*/
|
|
16742
16742
|
async createProcedure(data) {
|
|
16743
|
-
var _a, _b
|
|
16743
|
+
var _a, _b;
|
|
16744
16744
|
const validatedData = createProcedureSchema.parse(data);
|
|
16745
16745
|
const isProductFree = !validatedData.productId;
|
|
16746
16746
|
const procedureId = this.generateId();
|
|
@@ -16825,7 +16825,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16825
16825
|
contraindications: technology.contraindications || [],
|
|
16826
16826
|
contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
|
|
16827
16827
|
treatmentBenefits: technology.benefits,
|
|
16828
|
-
treatmentBenefitIds: (
|
|
16828
|
+
treatmentBenefitIds: Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [],
|
|
16829
16829
|
preRequirements: technology.requirements.pre,
|
|
16830
16830
|
postRequirements: technology.requirements.post,
|
|
16831
16831
|
certificationRequirement: technology.certificationRequirement,
|
|
@@ -16848,6 +16848,19 @@ var ProcedureService = class extends BaseService {
|
|
|
16848
16848
|
isActive: true
|
|
16849
16849
|
// Default to active
|
|
16850
16850
|
};
|
|
16851
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} CREATE PROCEDURE - Processing procedure:", procedureId);
|
|
16852
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} FULL PROCEDURE OBJECT:", JSON.stringify(newProcedure, null, 2));
|
|
16853
|
+
const undefinedFields = [];
|
|
16854
|
+
Object.entries(newProcedure).forEach(([key, value]) => {
|
|
16855
|
+
if (value === void 0) {
|
|
16856
|
+
undefinedFields.push(key);
|
|
16857
|
+
}
|
|
16858
|
+
});
|
|
16859
|
+
if (undefinedFields.length > 0) {
|
|
16860
|
+
console.error("\u{1F525}\u{1F525}\u{1F525} UNDEFINED FIELDS DETECTED:", undefinedFields);
|
|
16861
|
+
throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(", ")}`);
|
|
16862
|
+
}
|
|
16863
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with setDoc");
|
|
16851
16864
|
const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
16852
16865
|
await setDoc27(procedureRef, {
|
|
16853
16866
|
...newProcedure,
|
|
@@ -16866,7 +16879,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16866
16879
|
* @returns A promise that resolves to an array of the newly created procedures.
|
|
16867
16880
|
*/
|
|
16868
16881
|
async bulkCreateProcedures(baseData, practitionerIds) {
|
|
16869
|
-
var _a, _b
|
|
16882
|
+
var _a, _b;
|
|
16870
16883
|
if (!practitionerIds || practitionerIds.length === 0) {
|
|
16871
16884
|
throw new Error("Practitioner IDs array cannot be empty.");
|
|
16872
16885
|
}
|
|
@@ -16974,7 +16987,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16974
16987
|
contraindications: technology.contraindications || [],
|
|
16975
16988
|
contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
|
|
16976
16989
|
treatmentBenefits: technology.benefits,
|
|
16977
|
-
treatmentBenefitIds: (
|
|
16990
|
+
treatmentBenefitIds: Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [],
|
|
16978
16991
|
preRequirements: technology.requirements.pre,
|
|
16979
16992
|
postRequirements: technology.requirements.post,
|
|
16980
16993
|
certificationRequirement: technology.certificationRequirement,
|
|
@@ -16994,6 +17007,19 @@ var ProcedureService = class extends BaseService {
|
|
|
16994
17007
|
},
|
|
16995
17008
|
isActive: true
|
|
16996
17009
|
};
|
|
17010
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} BULK CREATE - Processing procedure:", procedureId, "for practitioner:", practitionerId);
|
|
17011
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} FULL PROCEDURE OBJECT:", JSON.stringify(newProcedure, null, 2));
|
|
17012
|
+
const undefinedFields = [];
|
|
17013
|
+
Object.entries(newProcedure).forEach(([key, value]) => {
|
|
17014
|
+
if (value === void 0) {
|
|
17015
|
+
undefinedFields.push(key);
|
|
17016
|
+
}
|
|
17017
|
+
});
|
|
17018
|
+
if (undefinedFields.length > 0) {
|
|
17019
|
+
console.error("\u{1F525}\u{1F525}\u{1F525} UNDEFINED FIELDS DETECTED:", undefinedFields);
|
|
17020
|
+
throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(", ")}`);
|
|
17021
|
+
}
|
|
17022
|
+
console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with batch.set");
|
|
16997
17023
|
batch.set(procedureRef, {
|
|
16998
17024
|
...newProcedure,
|
|
16999
17025
|
createdAt: serverTimestamp31(),
|
|
@@ -17074,7 +17100,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17074
17100
|
* @returns The updated procedure
|
|
17075
17101
|
*/
|
|
17076
17102
|
async updateProcedure(id, data) {
|
|
17077
|
-
var _a, _b, _c
|
|
17103
|
+
var _a, _b, _c;
|
|
17078
17104
|
const validatedData = updateProcedureSchema.parse(data);
|
|
17079
17105
|
const procedureRef = doc36(this.db, PROCEDURES_COLLECTION, id);
|
|
17080
17106
|
const procedureSnapshot = await getDoc37(procedureRef);
|
|
@@ -17188,7 +17214,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17188
17214
|
updatedProcedureData.contraindications = technology.contraindications || [];
|
|
17189
17215
|
updatedProcedureData.contraindicationIds = ((_c = technology.contraindications) == null ? void 0 : _c.map((c) => c.id)) || [];
|
|
17190
17216
|
updatedProcedureData.treatmentBenefits = technology.benefits;
|
|
17191
|
-
updatedProcedureData.treatmentBenefitIds = (
|
|
17217
|
+
updatedProcedureData.treatmentBenefitIds = Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [];
|
|
17192
17218
|
updatedProcedureData.preRequirements = technology.requirements.pre;
|
|
17193
17219
|
updatedProcedureData.postRequirements = technology.requirements.post;
|
|
17194
17220
|
updatedProcedureData.certificationRequirement = technology.certificationRequirement;
|
|
@@ -17708,7 +17734,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17708
17734
|
* @returns The created procedure
|
|
17709
17735
|
*/
|
|
17710
17736
|
async createConsultationProcedure(data) {
|
|
17711
|
-
var _a, _b
|
|
17737
|
+
var _a, _b;
|
|
17712
17738
|
const procedureId = this.generateId();
|
|
17713
17739
|
const [category, subcategory, technology] = await Promise.all([
|
|
17714
17740
|
this.categoryService.getById(data.categoryId),
|
|
@@ -17770,7 +17796,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17770
17796
|
contraindications: technology.contraindications || [],
|
|
17771
17797
|
contraindicationIds: ((_b = technology.contraindications) == null ? void 0 : _b.map((c) => c.id)) || [],
|
|
17772
17798
|
treatmentBenefits: technology.benefits,
|
|
17773
|
-
treatmentBenefitIds: (
|
|
17799
|
+
treatmentBenefitIds: Array.isArray(technology.benefits) ? technology.benefits.map((b) => typeof b === "string" ? b : b.id) : [],
|
|
17774
17800
|
preRequirements: technology.requirements.pre,
|
|
17775
17801
|
postRequirements: technology.requirements.post,
|
|
17776
17802
|
certificationRequirement: technology.certificationRequirement,
|
package/package.json
CHANGED
|
@@ -1007,11 +1007,11 @@ export class BookingAdmin {
|
|
|
1007
1007
|
procedureProducts: productsMetadata
|
|
1008
1008
|
.filter((pp: any) => pp && pp.product) // Safety check for product-free procedures
|
|
1009
1009
|
.map((pp: any) => ({
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1010
|
+
productId: pp.product.id,
|
|
1011
|
+
productName: pp.product.name,
|
|
1012
|
+
brandId: pp.product.brandId,
|
|
1013
|
+
brandName: pp.product.brandName,
|
|
1014
|
+
})),
|
|
1015
1015
|
};
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
@@ -1021,16 +1021,16 @@ export class BookingAdmin {
|
|
|
1021
1021
|
return productsMetadata
|
|
1022
1022
|
.filter((pp: any) => pp && pp.product) // Safety check for product-free procedures
|
|
1023
1023
|
.map((pp: any) => {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1024
|
+
const product = pp.product;
|
|
1025
|
+
return {
|
|
1026
|
+
productId: product.id,
|
|
1027
|
+
productName: product.name,
|
|
1028
|
+
brandId: product.brandId,
|
|
1029
|
+
brandName: product.brandName,
|
|
1030
|
+
procedureId: procedure.id,
|
|
1031
|
+
price: pp.price,
|
|
1032
|
+
currency: pp.currency,
|
|
1033
|
+
unitOfMeasurement: pp.pricingMeasure,
|
|
1034
1034
|
};
|
|
1035
1035
|
});
|
|
1036
1036
|
}
|
|
@@ -41,20 +41,20 @@ async function aggregateProductsFromProcedure(
|
|
|
41
41
|
const newProducts: AppointmentProductMetadata[] = productsMetadata
|
|
42
42
|
.filter((pp: any) => pp && pp.product)
|
|
43
43
|
.map((pp: any) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
// Each item in productsMetadata is a ProcedureProduct with embedded Product
|
|
45
|
+
const product = pp.product;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
productId: product.id,
|
|
49
|
+
productName: product.name,
|
|
50
|
+
brandId: product.brandId,
|
|
51
|
+
brandName: product.brandName,
|
|
52
|
+
procedureId: procedureId,
|
|
53
|
+
price: pp.price, // Price from ProcedureProduct
|
|
54
|
+
currency: pp.currency, // Currency from ProcedureProduct
|
|
55
|
+
unitOfMeasurement: pp.pricingMeasure, // PricingMeasure from ProcedureProduct
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
58
|
|
|
59
59
|
// Merge with existing products, avoiding duplicates
|
|
60
60
|
const productMap = new Map<string, AppointmentProductMetadata>();
|
|
@@ -108,11 +108,11 @@ async function createExtendedProcedureInfo(
|
|
|
108
108
|
procedureProducts: (data.productsMetadata || [])
|
|
109
109
|
.filter((pp: any) => pp && pp.product) // Safety check for product-free procedures
|
|
110
110
|
.map((pp: any) => ({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
productId: pp.product.id, // Access embedded product
|
|
112
|
+
productName: pp.product.name, // Access embedded product
|
|
113
|
+
brandId: pp.product.brandId, // Access embedded product
|
|
114
|
+
brandName: pp.product.brandName, // Access embedded product
|
|
115
|
+
})),
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -41,11 +41,11 @@ async function createExtendedProcedureInfoForRecommended(
|
|
|
41
41
|
procedureProducts: (data.productsMetadata || [])
|
|
42
42
|
.filter((pp: any) => pp && pp.product) // Safety check for product-free procedures
|
|
43
43
|
.map((pp: any) => ({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
productId: pp.product.id,
|
|
45
|
+
productName: pp.product.name,
|
|
46
|
+
brandId: pp.product.brandId,
|
|
47
|
+
brandName: pp.product.brandName,
|
|
48
|
+
})),
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -307,7 +307,9 @@ export class ProcedureService extends BaseService {
|
|
|
307
307
|
contraindications: technology.contraindications || [],
|
|
308
308
|
contraindicationIds: technology.contraindications?.map(c => c.id) || [],
|
|
309
309
|
treatmentBenefits: technology.benefits,
|
|
310
|
-
treatmentBenefitIds: technology.benefits
|
|
310
|
+
treatmentBenefitIds: Array.isArray(technology.benefits)
|
|
311
|
+
? technology.benefits.map(b => typeof b === 'string' ? b : b.id)
|
|
312
|
+
: [],
|
|
311
313
|
preRequirements: technology.requirements.pre,
|
|
312
314
|
postRequirements: technology.requirements.post,
|
|
313
315
|
certificationRequirement: technology.certificationRequirement,
|
|
@@ -328,6 +330,22 @@ export class ProcedureService extends BaseService {
|
|
|
328
330
|
isActive: true, // Default to active
|
|
329
331
|
};
|
|
330
332
|
|
|
333
|
+
// 🔥 DEBUG: Find undefined fields before writing to Firestore
|
|
334
|
+
console.log('🔥🔥🔥 CREATE PROCEDURE - Processing procedure:', procedureId);
|
|
335
|
+
console.log('🔥🔥🔥 FULL PROCEDURE OBJECT:', JSON.stringify(newProcedure, null, 2));
|
|
336
|
+
|
|
337
|
+
const undefinedFields: string[] = [];
|
|
338
|
+
Object.entries(newProcedure).forEach(([key, value]) => {
|
|
339
|
+
if (value === undefined) {
|
|
340
|
+
undefinedFields.push(key);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
if (undefinedFields.length > 0) {
|
|
344
|
+
console.error('🔥🔥🔥 UNDEFINED FIELDS DETECTED:', undefinedFields);
|
|
345
|
+
throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(', ')}`);
|
|
346
|
+
}
|
|
347
|
+
console.log('🔥🔥🔥 NO UNDEFINED FIELDS - Proceeding with setDoc');
|
|
348
|
+
|
|
331
349
|
// Create the procedure document
|
|
332
350
|
const procedureRef = doc(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
333
351
|
await setDoc(procedureRef, {
|
|
@@ -500,7 +518,9 @@ export class ProcedureService extends BaseService {
|
|
|
500
518
|
contraindications: technology.contraindications || [],
|
|
501
519
|
contraindicationIds: technology.contraindications?.map(c => c.id) || [],
|
|
502
520
|
treatmentBenefits: technology.benefits,
|
|
503
|
-
treatmentBenefitIds: technology.benefits
|
|
521
|
+
treatmentBenefitIds: Array.isArray(technology.benefits)
|
|
522
|
+
? technology.benefits.map(b => typeof b === 'string' ? b : b.id)
|
|
523
|
+
: [],
|
|
504
524
|
preRequirements: technology.requirements.pre,
|
|
505
525
|
postRequirements: technology.requirements.post,
|
|
506
526
|
certificationRequirement: technology.certificationRequirement,
|
|
@@ -520,6 +540,22 @@ export class ProcedureService extends BaseService {
|
|
|
520
540
|
isActive: true,
|
|
521
541
|
};
|
|
522
542
|
|
|
543
|
+
// 🔥 DEBUG: Find undefined fields before writing to Firestore
|
|
544
|
+
console.log('🔥🔥🔥 BULK CREATE - Processing procedure:', procedureId, 'for practitioner:', practitionerId);
|
|
545
|
+
console.log('🔥🔥🔥 FULL PROCEDURE OBJECT:', JSON.stringify(newProcedure, null, 2));
|
|
546
|
+
|
|
547
|
+
const undefinedFields: string[] = [];
|
|
548
|
+
Object.entries(newProcedure).forEach(([key, value]) => {
|
|
549
|
+
if (value === undefined) {
|
|
550
|
+
undefinedFields.push(key);
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
if (undefinedFields.length > 0) {
|
|
554
|
+
console.error('🔥🔥🔥 UNDEFINED FIELDS DETECTED:', undefinedFields);
|
|
555
|
+
throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(', ')}`);
|
|
556
|
+
}
|
|
557
|
+
console.log('🔥🔥🔥 NO UNDEFINED FIELDS - Proceeding with batch.set');
|
|
558
|
+
|
|
523
559
|
batch.set(procedureRef, {
|
|
524
560
|
...newProcedure,
|
|
525
561
|
createdAt: serverTimestamp(),
|
|
@@ -757,7 +793,9 @@ export class ProcedureService extends BaseService {
|
|
|
757
793
|
updatedProcedureData.contraindications = technology.contraindications || [];
|
|
758
794
|
updatedProcedureData.contraindicationIds = technology.contraindications?.map(c => c.id) || [];
|
|
759
795
|
updatedProcedureData.treatmentBenefits = technology.benefits;
|
|
760
|
-
updatedProcedureData.treatmentBenefitIds = technology.benefits
|
|
796
|
+
updatedProcedureData.treatmentBenefitIds = Array.isArray(technology.benefits)
|
|
797
|
+
? technology.benefits.map(b => typeof b === 'string' ? b : b.id)
|
|
798
|
+
: [];
|
|
761
799
|
updatedProcedureData.preRequirements = technology.requirements.pre;
|
|
762
800
|
updatedProcedureData.postRequirements = technology.requirements.post;
|
|
763
801
|
updatedProcedureData.certificationRequirement = technology.certificationRequirement;
|
|
@@ -1520,7 +1558,9 @@ export class ProcedureService extends BaseService {
|
|
|
1520
1558
|
contraindications: technology.contraindications || [],
|
|
1521
1559
|
contraindicationIds: technology.contraindications?.map(c => c.id) || [],
|
|
1522
1560
|
treatmentBenefits: technology.benefits,
|
|
1523
|
-
treatmentBenefitIds: technology.benefits
|
|
1561
|
+
treatmentBenefitIds: Array.isArray(technology.benefits)
|
|
1562
|
+
? technology.benefits.map(b => typeof b === 'string' ? b : b.id)
|
|
1563
|
+
: [],
|
|
1524
1564
|
preRequirements: technology.requirements.pre,
|
|
1525
1565
|
postRequirements: technology.requirements.post,
|
|
1526
1566
|
certificationRequirement: technology.certificationRequirement,
|