@blackcode_sa/metaestetics-api 1.6.0 → 1.6.1
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 +20 -4
- package/dist/index.mjs +20 -4
- package/package.json +1 -1
- package/src/services/practitioner/practitioner.service.ts +36 -6
package/dist/index.js
CHANGED
|
@@ -3928,8 +3928,8 @@ var PractitionerService = class extends BaseService {
|
|
|
3928
3928
|
if (!clinic) {
|
|
3929
3929
|
throw new Error(`Clinic ${clinicId} not found`);
|
|
3930
3930
|
}
|
|
3931
|
-
const
|
|
3932
|
-
if (data.clinics) {
|
|
3931
|
+
const clinicsToAdd = /* @__PURE__ */ new Set([clinicId]);
|
|
3932
|
+
if (data.clinics && data.clinics.length > 0) {
|
|
3933
3933
|
for (const cId of data.clinics) {
|
|
3934
3934
|
if (cId !== clinicId) {
|
|
3935
3935
|
const otherClinic = await this.getClinicService().getClinic(cId);
|
|
@@ -3937,8 +3937,10 @@ var PractitionerService = class extends BaseService {
|
|
|
3937
3937
|
throw new Error(`Clinic ${cId} not found`);
|
|
3938
3938
|
}
|
|
3939
3939
|
}
|
|
3940
|
+
clinicsToAdd.add(cId);
|
|
3940
3941
|
}
|
|
3941
3942
|
}
|
|
3943
|
+
const clinics = Array.from(clinicsToAdd);
|
|
3942
3944
|
const defaultReviewInfo = {
|
|
3943
3945
|
totalReviews: 0,
|
|
3944
3946
|
averageRating: 0,
|
|
@@ -3950,7 +3952,21 @@ var PractitionerService = class extends BaseService {
|
|
|
3950
3952
|
recommendationPercentage: 0
|
|
3951
3953
|
};
|
|
3952
3954
|
const practitionerId = this.generateId();
|
|
3953
|
-
const clinicsInfo =
|
|
3955
|
+
const clinicsInfo = [];
|
|
3956
|
+
for (const cId of clinics) {
|
|
3957
|
+
const clinicData = await this.getClinicService().getClinic(cId);
|
|
3958
|
+
if (clinicData) {
|
|
3959
|
+
clinicsInfo.push({
|
|
3960
|
+
id: clinicData.id,
|
|
3961
|
+
name: clinicData.name,
|
|
3962
|
+
location: clinicData.location,
|
|
3963
|
+
contactInfo: clinicData.contactInfo,
|
|
3964
|
+
featuredPhoto: clinicData.coverPhoto || "",
|
|
3965
|
+
description: clinicData.description || null
|
|
3966
|
+
});
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
const finalClinicsInfo = validatedData.clinicsInfo && validatedData.clinicsInfo.length > 0 ? validatedData.clinicsInfo : clinicsInfo;
|
|
3954
3970
|
const proceduresInfo = [];
|
|
3955
3971
|
const practitionerData = {
|
|
3956
3972
|
id: practitionerId,
|
|
@@ -3960,7 +3976,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3960
3976
|
certification: validatedData.certification,
|
|
3961
3977
|
clinics,
|
|
3962
3978
|
clinicWorkingHours: validatedData.clinicWorkingHours || [],
|
|
3963
|
-
clinicsInfo,
|
|
3979
|
+
clinicsInfo: finalClinicsInfo,
|
|
3964
3980
|
procedures: [],
|
|
3965
3981
|
proceduresInfo,
|
|
3966
3982
|
reviewInfo: defaultReviewInfo,
|
package/dist/index.mjs
CHANGED
|
@@ -3829,8 +3829,8 @@ var PractitionerService = class extends BaseService {
|
|
|
3829
3829
|
if (!clinic) {
|
|
3830
3830
|
throw new Error(`Clinic ${clinicId} not found`);
|
|
3831
3831
|
}
|
|
3832
|
-
const
|
|
3833
|
-
if (data.clinics) {
|
|
3832
|
+
const clinicsToAdd = /* @__PURE__ */ new Set([clinicId]);
|
|
3833
|
+
if (data.clinics && data.clinics.length > 0) {
|
|
3834
3834
|
for (const cId of data.clinics) {
|
|
3835
3835
|
if (cId !== clinicId) {
|
|
3836
3836
|
const otherClinic = await this.getClinicService().getClinic(cId);
|
|
@@ -3838,8 +3838,10 @@ var PractitionerService = class extends BaseService {
|
|
|
3838
3838
|
throw new Error(`Clinic ${cId} not found`);
|
|
3839
3839
|
}
|
|
3840
3840
|
}
|
|
3841
|
+
clinicsToAdd.add(cId);
|
|
3841
3842
|
}
|
|
3842
3843
|
}
|
|
3844
|
+
const clinics = Array.from(clinicsToAdd);
|
|
3843
3845
|
const defaultReviewInfo = {
|
|
3844
3846
|
totalReviews: 0,
|
|
3845
3847
|
averageRating: 0,
|
|
@@ -3851,7 +3853,21 @@ var PractitionerService = class extends BaseService {
|
|
|
3851
3853
|
recommendationPercentage: 0
|
|
3852
3854
|
};
|
|
3853
3855
|
const practitionerId = this.generateId();
|
|
3854
|
-
const clinicsInfo =
|
|
3856
|
+
const clinicsInfo = [];
|
|
3857
|
+
for (const cId of clinics) {
|
|
3858
|
+
const clinicData = await this.getClinicService().getClinic(cId);
|
|
3859
|
+
if (clinicData) {
|
|
3860
|
+
clinicsInfo.push({
|
|
3861
|
+
id: clinicData.id,
|
|
3862
|
+
name: clinicData.name,
|
|
3863
|
+
location: clinicData.location,
|
|
3864
|
+
contactInfo: clinicData.contactInfo,
|
|
3865
|
+
featuredPhoto: clinicData.coverPhoto || "",
|
|
3866
|
+
description: clinicData.description || null
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
const finalClinicsInfo = validatedData.clinicsInfo && validatedData.clinicsInfo.length > 0 ? validatedData.clinicsInfo : clinicsInfo;
|
|
3855
3871
|
const proceduresInfo = [];
|
|
3856
3872
|
const practitionerData = {
|
|
3857
3873
|
id: practitionerId,
|
|
@@ -3861,7 +3877,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3861
3877
|
certification: validatedData.certification,
|
|
3862
3878
|
clinics,
|
|
3863
3879
|
clinicWorkingHours: validatedData.clinicWorkingHours || [],
|
|
3864
|
-
clinicsInfo,
|
|
3880
|
+
clinicsInfo: finalClinicsInfo,
|
|
3865
3881
|
procedures: [],
|
|
3866
3882
|
proceduresInfo,
|
|
3867
3883
|
reviewInfo: defaultReviewInfo,
|
package/package.json
CHANGED
|
@@ -176,21 +176,28 @@ export class PractitionerService extends BaseService {
|
|
|
176
176
|
throw new Error(`Clinic ${clinicId} not found`);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
//
|
|
180
|
-
|
|
179
|
+
// Make sure the primary clinic (clinicId) is always included
|
|
180
|
+
// Merge the clinics array with the primary clinicId, avoiding duplicates
|
|
181
|
+
const clinicsToAdd = new Set<string>([clinicId]);
|
|
181
182
|
|
|
182
|
-
//
|
|
183
|
-
if (data.clinics) {
|
|
183
|
+
// Add additional clinics if provided
|
|
184
|
+
if (data.clinics && data.clinics.length > 0) {
|
|
184
185
|
for (const cId of data.clinics) {
|
|
186
|
+
// Verify each additional clinic exists
|
|
185
187
|
if (cId !== clinicId) {
|
|
188
|
+
// Skip checking the primary clinic again
|
|
186
189
|
const otherClinic = await this.getClinicService().getClinic(cId);
|
|
187
190
|
if (!otherClinic) {
|
|
188
191
|
throw new Error(`Clinic ${cId} not found`);
|
|
189
192
|
}
|
|
190
193
|
}
|
|
194
|
+
clinicsToAdd.add(cId);
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
|
|
198
|
+
// Convert Set to Array
|
|
199
|
+
const clinics = Array.from(clinicsToAdd);
|
|
200
|
+
|
|
194
201
|
// Initialize default review info for new practitioners
|
|
195
202
|
const defaultReviewInfo: PractitionerReviewInfo = {
|
|
196
203
|
totalReviews: 0,
|
|
@@ -206,7 +213,30 @@ export class PractitionerService extends BaseService {
|
|
|
206
213
|
// Generate ID for the new practitioner
|
|
207
214
|
const practitionerId = this.generateId();
|
|
208
215
|
|
|
209
|
-
|
|
216
|
+
// Create clinicsInfo from the merged clinics array
|
|
217
|
+
const clinicsInfo: ClinicInfo[] = [];
|
|
218
|
+
|
|
219
|
+
// Populate clinicsInfo for each clinic
|
|
220
|
+
for (const cId of clinics) {
|
|
221
|
+
const clinicData = await this.getClinicService().getClinic(cId);
|
|
222
|
+
if (clinicData) {
|
|
223
|
+
clinicsInfo.push({
|
|
224
|
+
id: clinicData.id,
|
|
225
|
+
name: clinicData.name,
|
|
226
|
+
location: clinicData.location,
|
|
227
|
+
contactInfo: clinicData.contactInfo,
|
|
228
|
+
featuredPhoto: clinicData.coverPhoto || "",
|
|
229
|
+
description: clinicData.description || null,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Use provided clinicsInfo if available, otherwise use the ones we just created
|
|
235
|
+
const finalClinicsInfo =
|
|
236
|
+
validatedData.clinicsInfo && validatedData.clinicsInfo.length > 0
|
|
237
|
+
? validatedData.clinicsInfo
|
|
238
|
+
: clinicsInfo;
|
|
239
|
+
|
|
210
240
|
const proceduresInfo: ProcedureSummaryInfo[] = [];
|
|
211
241
|
|
|
212
242
|
const practitionerData: Omit<Practitioner, "createdAt" | "updatedAt"> & {
|
|
@@ -219,7 +249,7 @@ export class PractitionerService extends BaseService {
|
|
|
219
249
|
certification: validatedData.certification,
|
|
220
250
|
clinics: clinics,
|
|
221
251
|
clinicWorkingHours: validatedData.clinicWorkingHours || [],
|
|
222
|
-
clinicsInfo:
|
|
252
|
+
clinicsInfo: finalClinicsInfo,
|
|
223
253
|
procedures: [],
|
|
224
254
|
proceduresInfo: proceduresInfo,
|
|
225
255
|
reviewInfo: defaultReviewInfo,
|