@blackcode_sa/metaestetics-api 1.12.21 → 1.12.22

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.
@@ -43,6 +43,7 @@ interface BaseReview {
43
43
  */
44
44
  interface ClinicReview extends BaseReview {
45
45
  clinicId: string;
46
+ clinicName?: string;
46
47
  cleanliness: number;
47
48
  facilities: number;
48
49
  staffFriendliness: number;
@@ -57,6 +58,7 @@ interface ClinicReview extends BaseReview {
57
58
  */
58
59
  interface PractitionerReview extends BaseReview {
59
60
  practitionerId: string;
61
+ practitionerName?: string;
60
62
  knowledgeAndExpertise: number;
61
63
  communicationSkills: number;
62
64
  bedSideManner: number;
@@ -71,6 +73,7 @@ interface PractitionerReview extends BaseReview {
71
73
  */
72
74
  interface ProcedureReview extends BaseReview {
73
75
  procedureId: string;
76
+ procedureName?: string;
74
77
  effectivenessOfTreatment: number;
75
78
  outcomeExplanation: number;
76
79
  painManagement: number;
@@ -129,6 +132,7 @@ interface Review {
129
132
  id: string;
130
133
  appointmentId: string;
131
134
  patientId: string;
135
+ patientName?: string;
132
136
  createdAt: Date;
133
137
  updatedAt: Date;
134
138
  clinicReview?: ClinicReview;
@@ -43,6 +43,7 @@ interface BaseReview {
43
43
  */
44
44
  interface ClinicReview extends BaseReview {
45
45
  clinicId: string;
46
+ clinicName?: string;
46
47
  cleanliness: number;
47
48
  facilities: number;
48
49
  staffFriendliness: number;
@@ -57,6 +58,7 @@ interface ClinicReview extends BaseReview {
57
58
  */
58
59
  interface PractitionerReview extends BaseReview {
59
60
  practitionerId: string;
61
+ practitionerName?: string;
60
62
  knowledgeAndExpertise: number;
61
63
  communicationSkills: number;
62
64
  bedSideManner: number;
@@ -71,6 +73,7 @@ interface PractitionerReview extends BaseReview {
71
73
  */
72
74
  interface ProcedureReview extends BaseReview {
73
75
  procedureId: string;
76
+ procedureName?: string;
74
77
  effectivenessOfTreatment: number;
75
78
  outcomeExplanation: number;
76
79
  painManagement: number;
@@ -129,6 +132,7 @@ interface Review {
129
132
  id: string;
130
133
  appointmentId: string;
131
134
  patientId: string;
135
+ patientName?: string;
132
136
  createdAt: Date;
133
137
  updatedAt: Date;
134
138
  clinicReview?: ClinicReview;
package/dist/index.d.mts CHANGED
@@ -43,6 +43,7 @@ interface BaseReview {
43
43
  */
44
44
  interface ClinicReview extends BaseReview {
45
45
  clinicId: string;
46
+ clinicName?: string;
46
47
  cleanliness: number;
47
48
  facilities: number;
48
49
  staffFriendliness: number;
@@ -57,6 +58,7 @@ interface ClinicReview extends BaseReview {
57
58
  */
58
59
  interface PractitionerReview extends BaseReview {
59
60
  practitionerId: string;
61
+ practitionerName?: string;
60
62
  knowledgeAndExpertise: number;
61
63
  communicationSkills: number;
62
64
  bedSideManner: number;
@@ -71,6 +73,7 @@ interface PractitionerReview extends BaseReview {
71
73
  */
72
74
  interface ProcedureReview extends BaseReview {
73
75
  procedureId: string;
76
+ procedureName?: string;
74
77
  effectivenessOfTreatment: number;
75
78
  outcomeExplanation: number;
76
79
  painManagement: number;
@@ -129,6 +132,7 @@ interface Review {
129
132
  id: string;
130
133
  appointmentId: string;
131
134
  patientId: string;
135
+ patientName?: string;
132
136
  createdAt: Date;
133
137
  updatedAt: Date;
134
138
  clinicReview?: ClinicReview;
@@ -6890,35 +6894,35 @@ declare class ReviewService extends BaseService {
6890
6894
  * @param appointmentId - ID of the completed appointment
6891
6895
  * @returns The created review
6892
6896
  */
6893
- createReview(data: Omit<Review, "id" | "createdAt" | "updatedAt" | "appointmentId" | "overallRating">, appointmentId: string): Promise<Review>;
6897
+ createReview(data: Omit<Review, 'id' | 'createdAt' | 'updatedAt' | 'appointmentId' | 'overallRating'>, appointmentId: string): Promise<Review>;
6894
6898
  /**
6895
- * Gets a review by ID
6899
+ * Gets a review by ID with enhanced entity names
6896
6900
  * @param reviewId The ID of the review to get
6897
- * @returns The review if found, null otherwise
6901
+ * @returns The review with entity names if found, null otherwise
6898
6902
  */
6899
6903
  getReview(reviewId: string): Promise<Review | null>;
6900
6904
  /**
6901
- * Gets all reviews for a specific patient
6905
+ * Gets all reviews for a specific patient with enhanced entity names
6902
6906
  * @param patientId The ID of the patient
6903
- * @returns Array of reviews for the patient
6907
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
6904
6908
  */
6905
6909
  getReviewsByPatient(patientId: string): Promise<Review[]>;
6906
6910
  /**
6907
- * Gets all reviews for a specific clinic
6911
+ * Gets all reviews for a specific clinic with enhanced entity names
6908
6912
  * @param clinicId The ID of the clinic
6909
- * @returns Array of reviews containing clinic reviews
6913
+ * @returns Array of reviews containing clinic reviews with clinic, practitioner, and procedure names
6910
6914
  */
6911
6915
  getReviewsByClinic(clinicId: string): Promise<Review[]>;
6912
6916
  /**
6913
- * Gets all reviews for a specific practitioner
6917
+ * Gets all reviews for a specific practitioner with enhanced entity names
6914
6918
  * @param practitionerId The ID of the practitioner
6915
- * @returns Array of reviews containing practitioner reviews
6919
+ * @returns Array of reviews containing practitioner reviews with clinic, practitioner, and procedure names
6916
6920
  */
6917
6921
  getReviewsByPractitioner(practitionerId: string): Promise<Review[]>;
6918
6922
  /**
6919
- * Gets all reviews for a specific procedure
6923
+ * Gets all reviews for a specific procedure with enhanced entity names
6920
6924
  * @param procedureId The ID of the procedure
6921
- * @returns Array of reviews containing procedure reviews
6925
+ * @returns Array of reviews containing procedure reviews with clinic, practitioner, and procedure names
6922
6926
  */
6923
6927
  getReviewsByProcedure(procedureId: string): Promise<Review[]>;
6924
6928
  /**
package/dist/index.d.ts CHANGED
@@ -43,6 +43,7 @@ interface BaseReview {
43
43
  */
44
44
  interface ClinicReview extends BaseReview {
45
45
  clinicId: string;
46
+ clinicName?: string;
46
47
  cleanliness: number;
47
48
  facilities: number;
48
49
  staffFriendliness: number;
@@ -57,6 +58,7 @@ interface ClinicReview extends BaseReview {
57
58
  */
58
59
  interface PractitionerReview extends BaseReview {
59
60
  practitionerId: string;
61
+ practitionerName?: string;
60
62
  knowledgeAndExpertise: number;
61
63
  communicationSkills: number;
62
64
  bedSideManner: number;
@@ -71,6 +73,7 @@ interface PractitionerReview extends BaseReview {
71
73
  */
72
74
  interface ProcedureReview extends BaseReview {
73
75
  procedureId: string;
76
+ procedureName?: string;
74
77
  effectivenessOfTreatment: number;
75
78
  outcomeExplanation: number;
76
79
  painManagement: number;
@@ -129,6 +132,7 @@ interface Review {
129
132
  id: string;
130
133
  appointmentId: string;
131
134
  patientId: string;
135
+ patientName?: string;
132
136
  createdAt: Date;
133
137
  updatedAt: Date;
134
138
  clinicReview?: ClinicReview;
@@ -6890,35 +6894,35 @@ declare class ReviewService extends BaseService {
6890
6894
  * @param appointmentId - ID of the completed appointment
6891
6895
  * @returns The created review
6892
6896
  */
6893
- createReview(data: Omit<Review, "id" | "createdAt" | "updatedAt" | "appointmentId" | "overallRating">, appointmentId: string): Promise<Review>;
6897
+ createReview(data: Omit<Review, 'id' | 'createdAt' | 'updatedAt' | 'appointmentId' | 'overallRating'>, appointmentId: string): Promise<Review>;
6894
6898
  /**
6895
- * Gets a review by ID
6899
+ * Gets a review by ID with enhanced entity names
6896
6900
  * @param reviewId The ID of the review to get
6897
- * @returns The review if found, null otherwise
6901
+ * @returns The review with entity names if found, null otherwise
6898
6902
  */
6899
6903
  getReview(reviewId: string): Promise<Review | null>;
6900
6904
  /**
6901
- * Gets all reviews for a specific patient
6905
+ * Gets all reviews for a specific patient with enhanced entity names
6902
6906
  * @param patientId The ID of the patient
6903
- * @returns Array of reviews for the patient
6907
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
6904
6908
  */
6905
6909
  getReviewsByPatient(patientId: string): Promise<Review[]>;
6906
6910
  /**
6907
- * Gets all reviews for a specific clinic
6911
+ * Gets all reviews for a specific clinic with enhanced entity names
6908
6912
  * @param clinicId The ID of the clinic
6909
- * @returns Array of reviews containing clinic reviews
6913
+ * @returns Array of reviews containing clinic reviews with clinic, practitioner, and procedure names
6910
6914
  */
6911
6915
  getReviewsByClinic(clinicId: string): Promise<Review[]>;
6912
6916
  /**
6913
- * Gets all reviews for a specific practitioner
6917
+ * Gets all reviews for a specific practitioner with enhanced entity names
6914
6918
  * @param practitionerId The ID of the practitioner
6915
- * @returns Array of reviews containing practitioner reviews
6919
+ * @returns Array of reviews containing practitioner reviews with clinic, practitioner, and procedure names
6916
6920
  */
6917
6921
  getReviewsByPractitioner(practitionerId: string): Promise<Review[]>;
6918
6922
  /**
6919
- * Gets all reviews for a specific procedure
6923
+ * Gets all reviews for a specific procedure with enhanced entity names
6920
6924
  * @param procedureId The ID of the procedure
6921
- * @returns Array of reviews containing procedure reviews
6925
+ * @returns Array of reviews containing procedure reviews with clinic, practitioner, and procedure names
6922
6926
  */
6923
6927
  getReviewsByProcedure(procedureId: string): Promise<Review[]>;
6924
6928
  /**
package/dist/index.js CHANGED
@@ -16227,7 +16227,17 @@ var ReviewService = class extends BaseService {
16227
16227
  * @returns The created review
16228
16228
  */
16229
16229
  async createReview(data, appointmentId) {
16230
+ var _a, _b, _c, _d, _e, _f;
16230
16231
  try {
16232
+ console.log("\u{1F50D} ReviewService.createReview - Input data:", {
16233
+ appointmentId,
16234
+ hasClinicReview: !!data.clinicReview,
16235
+ hasPractitionerReview: !!data.practitionerReview,
16236
+ hasProcedureReview: !!data.procedureReview,
16237
+ practitionerId: (_a = data.practitionerReview) == null ? void 0 : _a.practitionerId,
16238
+ clinicId: (_b = data.clinicReview) == null ? void 0 : _b.clinicId,
16239
+ procedureId: (_c = data.procedureReview) == null ? void 0 : _c.procedureId
16240
+ });
16231
16241
  const validatedData = createReviewSchema.parse(data);
16232
16242
  const ratings = [];
16233
16243
  if (data.clinicReview) {
@@ -16300,6 +16310,12 @@ var ReviewService = class extends BaseService {
16300
16310
  createdAt: (0, import_firestore48.serverTimestamp)(),
16301
16311
  updatedAt: (0, import_firestore48.serverTimestamp)()
16302
16312
  });
16313
+ console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
16314
+ reviewId,
16315
+ practitionerId: (_d = review.practitionerReview) == null ? void 0 : _d.practitionerId,
16316
+ clinicId: (_e = review.clinicReview) == null ? void 0 : _e.clinicId,
16317
+ procedureId: (_f = review.procedureReview) == null ? void 0 : _f.procedureId
16318
+ });
16303
16319
  return review;
16304
16320
  } catch (error) {
16305
16321
  if (error instanceof import_zod26.z.ZodError) {
@@ -16309,69 +16325,332 @@ var ReviewService = class extends BaseService {
16309
16325
  }
16310
16326
  }
16311
16327
  /**
16312
- * Gets a review by ID
16328
+ * Gets a review by ID with enhanced entity names
16313
16329
  * @param reviewId The ID of the review to get
16314
- * @returns The review if found, null otherwise
16330
+ * @returns The review with entity names if found, null otherwise
16315
16331
  */
16316
16332
  async getReview(reviewId) {
16333
+ var _a, _b, _c;
16334
+ console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
16317
16335
  const docRef = (0, import_firestore48.doc)(this.db, REVIEWS_COLLECTION, reviewId);
16318
16336
  const docSnap = await (0, import_firestore48.getDoc)(docRef);
16319
16337
  if (!docSnap.exists()) {
16338
+ console.log("\u274C ReviewService.getReview - Review not found:", reviewId);
16320
16339
  return null;
16321
16340
  }
16322
- return docSnap.data();
16341
+ const review = { ...docSnap.data(), id: reviewId };
16342
+ try {
16343
+ const appointmentDoc = await (0, import_firestore48.getDoc)(
16344
+ (0, import_firestore48.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16345
+ );
16346
+ if (appointmentDoc.exists()) {
16347
+ const appointment = appointmentDoc.data();
16348
+ const enhancedReview = { ...review };
16349
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16350
+ enhancedReview.clinicReview = {
16351
+ ...enhancedReview.clinicReview,
16352
+ clinicName: appointment.clinicInfo.name
16353
+ };
16354
+ }
16355
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16356
+ enhancedReview.practitionerReview = {
16357
+ ...enhancedReview.practitionerReview,
16358
+ practitionerName: appointment.practitionerInfo.name
16359
+ };
16360
+ }
16361
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16362
+ enhancedReview.procedureReview = {
16363
+ ...enhancedReview.procedureReview,
16364
+ procedureName: appointment.procedureInfo.name
16365
+ };
16366
+ }
16367
+ if (appointment.patientInfo) {
16368
+ enhancedReview.patientName = appointment.patientInfo.fullName;
16369
+ }
16370
+ console.log("\u2705 ReviewService.getReview - Enhanced review:", {
16371
+ reviewId,
16372
+ hasEntityNames: !!(((_a = enhancedReview.clinicReview) == null ? void 0 : _a.clinicName) || ((_b = enhancedReview.practitionerReview) == null ? void 0 : _b.practitionerName) || ((_c = enhancedReview.procedureReview) == null ? void 0 : _c.procedureName) || enhancedReview.patientName)
16373
+ });
16374
+ return enhancedReview;
16375
+ }
16376
+ console.log("\u26A0\uFE0F ReviewService.getReview - Appointment not found for review:", reviewId);
16377
+ return review;
16378
+ } catch (error) {
16379
+ console.warn(`Failed to enhance review ${reviewId} with entity names:`, error);
16380
+ return review;
16381
+ }
16323
16382
  }
16324
16383
  /**
16325
- * Gets all reviews for a specific patient
16384
+ * Gets all reviews for a specific patient with enhanced entity names
16326
16385
  * @param patientId The ID of the patient
16327
- * @returns Array of reviews for the patient
16386
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
16328
16387
  */
16329
16388
  async getReviewsByPatient(patientId) {
16330
- const q = (0, import_firestore48.query)(
16331
- (0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
16332
- (0, import_firestore48.where)("patientId", "==", patientId)
16333
- );
16389
+ const q = (0, import_firestore48.query)((0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION), (0, import_firestore48.where)("patientId", "==", patientId));
16334
16390
  const snapshot = await (0, import_firestore48.getDocs)(q);
16335
- return snapshot.docs.map((doc38) => doc38.data());
16391
+ const reviews = snapshot.docs.map((doc38) => doc38.data());
16392
+ const enhancedReviews = await Promise.all(
16393
+ reviews.map(async (review) => {
16394
+ try {
16395
+ const appointmentDoc = await (0, import_firestore48.getDoc)(
16396
+ (0, import_firestore48.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16397
+ );
16398
+ if (appointmentDoc.exists()) {
16399
+ const appointment = appointmentDoc.data();
16400
+ const enhancedReview = { ...review };
16401
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16402
+ enhancedReview.clinicReview = {
16403
+ ...enhancedReview.clinicReview,
16404
+ clinicName: appointment.clinicInfo.name
16405
+ };
16406
+ }
16407
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16408
+ enhancedReview.practitionerReview = {
16409
+ ...enhancedReview.practitionerReview,
16410
+ practitionerName: appointment.practitionerInfo.name
16411
+ };
16412
+ }
16413
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16414
+ enhancedReview.procedureReview = {
16415
+ ...enhancedReview.procedureReview,
16416
+ procedureName: appointment.procedureInfo.name
16417
+ };
16418
+ }
16419
+ if (appointment.patientInfo) {
16420
+ enhancedReview.patientName = appointment.patientInfo.fullName;
16421
+ }
16422
+ return enhancedReview;
16423
+ }
16424
+ return review;
16425
+ } catch (error) {
16426
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
16427
+ return review;
16428
+ }
16429
+ })
16430
+ );
16431
+ return enhancedReviews;
16336
16432
  }
16337
16433
  /**
16338
- * Gets all reviews for a specific clinic
16434
+ * Gets all reviews for a specific clinic with enhanced entity names
16339
16435
  * @param clinicId The ID of the clinic
16340
- * @returns Array of reviews containing clinic reviews
16436
+ * @returns Array of reviews containing clinic reviews with clinic, practitioner, and procedure names
16341
16437
  */
16342
16438
  async getReviewsByClinic(clinicId) {
16439
+ console.log("\u{1F50D} ReviewService.getReviewsByClinic - Querying for clinic:", clinicId);
16343
16440
  const q = (0, import_firestore48.query)(
16344
16441
  (0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
16345
16442
  (0, import_firestore48.where)("clinicReview.clinicId", "==", clinicId)
16346
16443
  );
16347
16444
  const snapshot = await (0, import_firestore48.getDocs)(q);
16348
- return snapshot.docs.map((doc38) => doc38.data());
16445
+ const reviews = snapshot.docs.map((doc38) => {
16446
+ const data = doc38.data();
16447
+ return { ...data, id: doc38.id };
16448
+ });
16449
+ console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
16450
+ clinicId,
16451
+ reviewCount: reviews.length,
16452
+ reviewIds: reviews.map((r) => r.id)
16453
+ });
16454
+ const enhancedReviews = await Promise.all(
16455
+ reviews.map(async (review) => {
16456
+ try {
16457
+ const appointmentDoc = await (0, import_firestore48.getDoc)(
16458
+ (0, import_firestore48.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16459
+ );
16460
+ if (appointmentDoc.exists()) {
16461
+ const appointment = appointmentDoc.data();
16462
+ const enhancedReview = { ...review };
16463
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16464
+ enhancedReview.clinicReview = {
16465
+ ...enhancedReview.clinicReview,
16466
+ clinicName: appointment.clinicInfo.name
16467
+ };
16468
+ }
16469
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16470
+ enhancedReview.practitionerReview = {
16471
+ ...enhancedReview.practitionerReview,
16472
+ practitionerName: appointment.practitionerInfo.name
16473
+ };
16474
+ }
16475
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16476
+ enhancedReview.procedureReview = {
16477
+ ...enhancedReview.procedureReview,
16478
+ procedureName: appointment.procedureInfo.name
16479
+ };
16480
+ }
16481
+ if (appointment.patientInfo) {
16482
+ enhancedReview.patientName = appointment.patientInfo.fullName;
16483
+ }
16484
+ return enhancedReview;
16485
+ }
16486
+ return review;
16487
+ } catch (error) {
16488
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
16489
+ return review;
16490
+ }
16491
+ })
16492
+ );
16493
+ console.log("\u2705 ReviewService.getReviewsByClinic - Enhanced reviews:", {
16494
+ clinicId,
16495
+ reviewCount: enhancedReviews.length,
16496
+ reviewIds: enhancedReviews.map((r) => r.id),
16497
+ hasEntityNames: enhancedReviews.some(
16498
+ (r) => {
16499
+ var _a, _b, _c;
16500
+ return ((_a = r.clinicReview) == null ? void 0 : _a.clinicName) || ((_b = r.practitionerReview) == null ? void 0 : _b.practitionerName) || ((_c = r.procedureReview) == null ? void 0 : _c.procedureName) || r.patientName;
16501
+ }
16502
+ )
16503
+ });
16504
+ return enhancedReviews;
16349
16505
  }
16350
16506
  /**
16351
- * Gets all reviews for a specific practitioner
16507
+ * Gets all reviews for a specific practitioner with enhanced entity names
16352
16508
  * @param practitionerId The ID of the practitioner
16353
- * @returns Array of reviews containing practitioner reviews
16509
+ * @returns Array of reviews containing practitioner reviews with clinic, practitioner, and procedure names
16354
16510
  */
16355
16511
  async getReviewsByPractitioner(practitionerId) {
16512
+ console.log(
16513
+ "\u{1F50D} ReviewService.getReviewsByPractitioner - Querying for practitioner:",
16514
+ practitionerId
16515
+ );
16356
16516
  const q = (0, import_firestore48.query)(
16357
16517
  (0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
16358
16518
  (0, import_firestore48.where)("practitionerReview.practitionerId", "==", practitionerId)
16359
16519
  );
16360
16520
  const snapshot = await (0, import_firestore48.getDocs)(q);
16361
- return snapshot.docs.map((doc38) => doc38.data());
16521
+ const reviews = snapshot.docs.map((doc38) => {
16522
+ const data = doc38.data();
16523
+ return { ...data, id: doc38.id };
16524
+ });
16525
+ console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
16526
+ practitionerId,
16527
+ reviewCount: reviews.length,
16528
+ reviewIds: reviews.map((r) => r.id)
16529
+ });
16530
+ const enhancedReviews = await Promise.all(
16531
+ reviews.map(async (review) => {
16532
+ try {
16533
+ const appointmentDoc = await (0, import_firestore48.getDoc)(
16534
+ (0, import_firestore48.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16535
+ );
16536
+ if (appointmentDoc.exists()) {
16537
+ const appointment = appointmentDoc.data();
16538
+ const enhancedReview = { ...review };
16539
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16540
+ enhancedReview.clinicReview = {
16541
+ ...enhancedReview.clinicReview,
16542
+ clinicName: appointment.clinicInfo.name
16543
+ };
16544
+ }
16545
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16546
+ enhancedReview.practitionerReview = {
16547
+ ...enhancedReview.practitionerReview,
16548
+ practitionerName: appointment.practitionerInfo.name
16549
+ };
16550
+ }
16551
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16552
+ enhancedReview.procedureReview = {
16553
+ ...enhancedReview.procedureReview,
16554
+ procedureName: appointment.procedureInfo.name
16555
+ };
16556
+ }
16557
+ if (appointment.patientInfo) {
16558
+ enhancedReview.patientName = appointment.patientInfo.fullName;
16559
+ }
16560
+ return enhancedReview;
16561
+ }
16562
+ return review;
16563
+ } catch (error) {
16564
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
16565
+ return review;
16566
+ }
16567
+ })
16568
+ );
16569
+ console.log("\u2705 ReviewService.getReviewsByPractitioner - Enhanced reviews:", {
16570
+ practitionerId,
16571
+ reviewCount: enhancedReviews.length,
16572
+ reviewIds: enhancedReviews.map((r) => r.id),
16573
+ hasEntityNames: enhancedReviews.some(
16574
+ (r) => {
16575
+ var _a, _b, _c;
16576
+ return ((_a = r.clinicReview) == null ? void 0 : _a.clinicName) || ((_b = r.practitionerReview) == null ? void 0 : _b.practitionerName) || ((_c = r.procedureReview) == null ? void 0 : _c.procedureName);
16577
+ }
16578
+ )
16579
+ });
16580
+ return enhancedReviews;
16362
16581
  }
16363
16582
  /**
16364
- * Gets all reviews for a specific procedure
16583
+ * Gets all reviews for a specific procedure with enhanced entity names
16365
16584
  * @param procedureId The ID of the procedure
16366
- * @returns Array of reviews containing procedure reviews
16585
+ * @returns Array of reviews containing procedure reviews with clinic, practitioner, and procedure names
16367
16586
  */
16368
16587
  async getReviewsByProcedure(procedureId) {
16588
+ console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Querying for procedure:", procedureId);
16369
16589
  const q = (0, import_firestore48.query)(
16370
16590
  (0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
16371
16591
  (0, import_firestore48.where)("procedureReview.procedureId", "==", procedureId)
16372
16592
  );
16373
16593
  const snapshot = await (0, import_firestore48.getDocs)(q);
16374
- return snapshot.docs.map((doc38) => doc38.data());
16594
+ const reviews = snapshot.docs.map((doc38) => {
16595
+ const data = doc38.data();
16596
+ return { ...data, id: doc38.id };
16597
+ });
16598
+ console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
16599
+ procedureId,
16600
+ reviewCount: reviews.length,
16601
+ reviewIds: reviews.map((r) => r.id)
16602
+ });
16603
+ const enhancedReviews = await Promise.all(
16604
+ reviews.map(async (review) => {
16605
+ try {
16606
+ const appointmentDoc = await (0, import_firestore48.getDoc)(
16607
+ (0, import_firestore48.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16608
+ );
16609
+ if (appointmentDoc.exists()) {
16610
+ const appointment = appointmentDoc.data();
16611
+ const enhancedReview = { ...review };
16612
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16613
+ enhancedReview.clinicReview = {
16614
+ ...enhancedReview.clinicReview,
16615
+ clinicName: appointment.clinicInfo.name
16616
+ };
16617
+ }
16618
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16619
+ enhancedReview.practitionerReview = {
16620
+ ...enhancedReview.practitionerReview,
16621
+ practitionerName: appointment.practitionerInfo.name
16622
+ };
16623
+ }
16624
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16625
+ enhancedReview.procedureReview = {
16626
+ ...enhancedReview.procedureReview,
16627
+ procedureName: appointment.procedureInfo.name
16628
+ };
16629
+ }
16630
+ if (appointment.patientInfo) {
16631
+ enhancedReview.patientName = appointment.patientInfo.fullName;
16632
+ }
16633
+ return enhancedReview;
16634
+ }
16635
+ return review;
16636
+ } catch (error) {
16637
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
16638
+ return review;
16639
+ }
16640
+ })
16641
+ );
16642
+ console.log("\u2705 ReviewService.getReviewsByProcedure - Enhanced reviews:", {
16643
+ procedureId,
16644
+ reviewCount: enhancedReviews.length,
16645
+ reviewIds: enhancedReviews.map((r) => r.id),
16646
+ hasEntityNames: enhancedReviews.some(
16647
+ (r) => {
16648
+ var _a, _b, _c;
16649
+ return ((_a = r.clinicReview) == null ? void 0 : _a.clinicName) || ((_b = r.practitionerReview) == null ? void 0 : _b.practitionerName) || ((_c = r.procedureReview) == null ? void 0 : _c.procedureName) || r.patientName;
16650
+ }
16651
+ )
16652
+ });
16653
+ return enhancedReviews;
16375
16654
  }
16376
16655
  /**
16377
16656
  * Gets all reviews for a specific appointment