@blackcode_sa/metaestetics-api 1.12.19 → 1.12.20

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;
@@ -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;
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;
@@ -6843,7 +6846,7 @@ declare class ReviewService extends BaseService {
6843
6846
  * @param appointmentId - ID of the completed appointment
6844
6847
  * @returns The created review
6845
6848
  */
6846
- createReview(data: Omit<Review, "id" | "createdAt" | "updatedAt" | "appointmentId" | "overallRating">, appointmentId: string): Promise<Review>;
6849
+ createReview(data: Omit<Review, 'id' | 'createdAt' | 'updatedAt' | 'appointmentId' | 'overallRating'>, appointmentId: string): Promise<Review>;
6847
6850
  /**
6848
6851
  * Gets a review by ID
6849
6852
  * @param reviewId The ID of the review to get
@@ -6851,9 +6854,9 @@ declare class ReviewService extends BaseService {
6851
6854
  */
6852
6855
  getReview(reviewId: string): Promise<Review | null>;
6853
6856
  /**
6854
- * Gets all reviews for a specific patient
6857
+ * Gets all reviews for a specific patient with enhanced entity names
6855
6858
  * @param patientId The ID of the patient
6856
- * @returns Array of reviews for the patient
6859
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
6857
6860
  */
6858
6861
  getReviewsByPatient(patientId: string): Promise<Review[]>;
6859
6862
  /**
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;
@@ -6843,7 +6846,7 @@ declare class ReviewService extends BaseService {
6843
6846
  * @param appointmentId - ID of the completed appointment
6844
6847
  * @returns The created review
6845
6848
  */
6846
- createReview(data: Omit<Review, "id" | "createdAt" | "updatedAt" | "appointmentId" | "overallRating">, appointmentId: string): Promise<Review>;
6849
+ createReview(data: Omit<Review, 'id' | 'createdAt' | 'updatedAt' | 'appointmentId' | 'overallRating'>, appointmentId: string): Promise<Review>;
6847
6850
  /**
6848
6851
  * Gets a review by ID
6849
6852
  * @param reviewId The ID of the review to get
@@ -6851,9 +6854,9 @@ declare class ReviewService extends BaseService {
6851
6854
  */
6852
6855
  getReview(reviewId: string): Promise<Review | null>;
6853
6856
  /**
6854
- * Gets all reviews for a specific patient
6857
+ * Gets all reviews for a specific patient with enhanced entity names
6855
6858
  * @param patientId The ID of the patient
6856
- * @returns Array of reviews for the patient
6859
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
6857
6860
  */
6858
6861
  getReviewsByPatient(patientId: string): Promise<Review[]>;
6859
6862
  /**
package/dist/index.js CHANGED
@@ -16089,17 +16089,51 @@ var ReviewService = class extends BaseService {
16089
16089
  return docSnap.data();
16090
16090
  }
16091
16091
  /**
16092
- * Gets all reviews for a specific patient
16092
+ * Gets all reviews for a specific patient with enhanced entity names
16093
16093
  * @param patientId The ID of the patient
16094
- * @returns Array of reviews for the patient
16094
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
16095
16095
  */
16096
16096
  async getReviewsByPatient(patientId) {
16097
- const q = (0, import_firestore48.query)(
16098
- (0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
16099
- (0, import_firestore48.where)("patientId", "==", patientId)
16100
- );
16097
+ const q = (0, import_firestore48.query)((0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION), (0, import_firestore48.where)("patientId", "==", patientId));
16101
16098
  const snapshot = await (0, import_firestore48.getDocs)(q);
16102
- return snapshot.docs.map((doc38) => doc38.data());
16099
+ const reviews = snapshot.docs.map((doc38) => doc38.data());
16100
+ const enhancedReviews = await Promise.all(
16101
+ reviews.map(async (review) => {
16102
+ try {
16103
+ const appointmentDoc = await (0, import_firestore48.getDoc)(
16104
+ (0, import_firestore48.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16105
+ );
16106
+ if (appointmentDoc.exists()) {
16107
+ const appointment = appointmentDoc.data();
16108
+ const enhancedReview = { ...review };
16109
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16110
+ enhancedReview.clinicReview = {
16111
+ ...enhancedReview.clinicReview,
16112
+ clinicName: appointment.clinicInfo.name
16113
+ };
16114
+ }
16115
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16116
+ enhancedReview.practitionerReview = {
16117
+ ...enhancedReview.practitionerReview,
16118
+ practitionerName: appointment.practitionerInfo.name
16119
+ };
16120
+ }
16121
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16122
+ enhancedReview.procedureReview = {
16123
+ ...enhancedReview.procedureReview,
16124
+ procedureName: appointment.procedureInfo.name
16125
+ };
16126
+ }
16127
+ return enhancedReview;
16128
+ }
16129
+ return review;
16130
+ } catch (error) {
16131
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
16132
+ return review;
16133
+ }
16134
+ })
16135
+ );
16136
+ return enhancedReviews;
16103
16137
  }
16104
16138
  /**
16105
16139
  * Gets all reviews for a specific clinic
package/dist/index.mjs CHANGED
@@ -16353,17 +16353,51 @@ var ReviewService = class extends BaseService {
16353
16353
  return docSnap.data();
16354
16354
  }
16355
16355
  /**
16356
- * Gets all reviews for a specific patient
16356
+ * Gets all reviews for a specific patient with enhanced entity names
16357
16357
  * @param patientId The ID of the patient
16358
- * @returns Array of reviews for the patient
16358
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
16359
16359
  */
16360
16360
  async getReviewsByPatient(patientId) {
16361
- const q = query31(
16362
- collection31(this.db, REVIEWS_COLLECTION),
16363
- where31("patientId", "==", patientId)
16364
- );
16361
+ const q = query31(collection31(this.db, REVIEWS_COLLECTION), where31("patientId", "==", patientId));
16365
16362
  const snapshot = await getDocs31(q);
16366
- return snapshot.docs.map((doc38) => doc38.data());
16363
+ const reviews = snapshot.docs.map((doc38) => doc38.data());
16364
+ const enhancedReviews = await Promise.all(
16365
+ reviews.map(async (review) => {
16366
+ try {
16367
+ const appointmentDoc = await getDoc33(
16368
+ doc31(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
16369
+ );
16370
+ if (appointmentDoc.exists()) {
16371
+ const appointment = appointmentDoc.data();
16372
+ const enhancedReview = { ...review };
16373
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
16374
+ enhancedReview.clinicReview = {
16375
+ ...enhancedReview.clinicReview,
16376
+ clinicName: appointment.clinicInfo.name
16377
+ };
16378
+ }
16379
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
16380
+ enhancedReview.practitionerReview = {
16381
+ ...enhancedReview.practitionerReview,
16382
+ practitionerName: appointment.practitionerInfo.name
16383
+ };
16384
+ }
16385
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
16386
+ enhancedReview.procedureReview = {
16387
+ ...enhancedReview.procedureReview,
16388
+ procedureName: appointment.procedureInfo.name
16389
+ };
16390
+ }
16391
+ return enhancedReview;
16392
+ }
16393
+ return review;
16394
+ } catch (error) {
16395
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
16396
+ return review;
16397
+ }
16398
+ })
16399
+ );
16400
+ return enhancedReviews;
16367
16401
  }
16368
16402
  /**
16369
16403
  * Gets all reviews for a specific clinic
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.12.19",
4
+ "version": "1.12.20",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -8,23 +8,21 @@ import {
8
8
  setDoc,
9
9
  deleteDoc,
10
10
  serverTimestamp,
11
- } from "firebase/firestore";
12
- import { BaseService } from "../base.service";
11
+ } from 'firebase/firestore';
12
+ import { BaseService } from '../base.service';
13
13
  import {
14
14
  Review,
15
15
  ClinicReview,
16
16
  PractitionerReview,
17
17
  ProcedureReview,
18
18
  REVIEWS_COLLECTION,
19
- } from "../../types/reviews";
20
- import {
21
- createReviewSchema,
22
- reviewSchema,
23
- } from "../../validations/reviews.schema";
24
- import { z } from "zod";
25
- import { Auth } from "firebase/auth";
26
- import { Firestore } from "firebase/firestore";
27
- import { FirebaseApp } from "firebase/app";
19
+ } from '../../types/reviews';
20
+ import { createReviewSchema, reviewSchema } from '../../validations/reviews.schema';
21
+ import { z } from 'zod';
22
+ import { Auth } from 'firebase/auth';
23
+ import { Firestore } from 'firebase/firestore';
24
+ import { FirebaseApp } from 'firebase/app';
25
+ import { Appointment, APPOINTMENTS_COLLECTION } from '../../types/appointment';
28
26
 
29
27
  export class ReviewService extends BaseService {
30
28
  constructor(db: Firestore, auth: Auth, app: FirebaseApp) {
@@ -38,11 +36,8 @@ export class ReviewService extends BaseService {
38
36
  * @returns The created review
39
37
  */
40
38
  async createReview(
41
- data: Omit<
42
- Review,
43
- "id" | "createdAt" | "updatedAt" | "appointmentId" | "overallRating"
44
- >,
45
- appointmentId: string
39
+ data: Omit<Review, 'id' | 'createdAt' | 'updatedAt' | 'appointmentId' | 'overallRating'>,
40
+ appointmentId: string,
46
41
  ): Promise<Review> {
47
42
  try {
48
43
  // Validate input data
@@ -166,17 +161,63 @@ export class ReviewService extends BaseService {
166
161
  }
167
162
 
168
163
  /**
169
- * Gets all reviews for a specific patient
164
+ * Gets all reviews for a specific patient with enhanced entity names
170
165
  * @param patientId The ID of the patient
171
- * @returns Array of reviews for the patient
166
+ * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
172
167
  */
173
168
  async getReviewsByPatient(patientId: string): Promise<Review[]> {
174
- const q = query(
175
- collection(this.db, REVIEWS_COLLECTION),
176
- where("patientId", "==", patientId)
177
- );
169
+ const q = query(collection(this.db, REVIEWS_COLLECTION), where('patientId', '==', patientId));
178
170
  const snapshot = await getDocs(q);
179
- return snapshot.docs.map((doc) => doc.data() as Review);
171
+ const reviews = snapshot.docs.map(doc => doc.data() as Review);
172
+
173
+ // Enhance reviews with entity names from appointments
174
+ const enhancedReviews = await Promise.all(
175
+ reviews.map(async review => {
176
+ try {
177
+ // Fetch the associated appointment
178
+ const appointmentDoc = await getDoc(
179
+ doc(this.db, APPOINTMENTS_COLLECTION, review.appointmentId),
180
+ );
181
+
182
+ if (appointmentDoc.exists()) {
183
+ const appointment = appointmentDoc.data() as Appointment;
184
+
185
+ // Create enhanced review with entity names
186
+ const enhancedReview = { ...review };
187
+
188
+ if (enhancedReview.clinicReview && appointment.clinicInfo) {
189
+ enhancedReview.clinicReview = {
190
+ ...enhancedReview.clinicReview,
191
+ clinicName: appointment.clinicInfo.name,
192
+ };
193
+ }
194
+
195
+ if (enhancedReview.practitionerReview && appointment.practitionerInfo) {
196
+ enhancedReview.practitionerReview = {
197
+ ...enhancedReview.practitionerReview,
198
+ practitionerName: appointment.practitionerInfo.name,
199
+ };
200
+ }
201
+
202
+ if (enhancedReview.procedureReview && appointment.procedureInfo) {
203
+ enhancedReview.procedureReview = {
204
+ ...enhancedReview.procedureReview,
205
+ procedureName: appointment.procedureInfo.name,
206
+ };
207
+ }
208
+
209
+ return enhancedReview;
210
+ }
211
+
212
+ return review;
213
+ } catch (error) {
214
+ console.warn(`Failed to enhance review ${review.id} with entity names:`, error);
215
+ return review;
216
+ }
217
+ }),
218
+ );
219
+
220
+ return enhancedReviews;
180
221
  }
181
222
 
182
223
  /**
@@ -187,10 +228,10 @@ export class ReviewService extends BaseService {
187
228
  async getReviewsByClinic(clinicId: string): Promise<Review[]> {
188
229
  const q = query(
189
230
  collection(this.db, REVIEWS_COLLECTION),
190
- where("clinicReview.clinicId", "==", clinicId)
231
+ where('clinicReview.clinicId', '==', clinicId),
191
232
  );
192
233
  const snapshot = await getDocs(q);
193
- return snapshot.docs.map((doc) => doc.data() as Review);
234
+ return snapshot.docs.map(doc => doc.data() as Review);
194
235
  }
195
236
 
196
237
  /**
@@ -201,10 +242,10 @@ export class ReviewService extends BaseService {
201
242
  async getReviewsByPractitioner(practitionerId: string): Promise<Review[]> {
202
243
  const q = query(
203
244
  collection(this.db, REVIEWS_COLLECTION),
204
- where("practitionerReview.practitionerId", "==", practitionerId)
245
+ where('practitionerReview.practitionerId', '==', practitionerId),
205
246
  );
206
247
  const snapshot = await getDocs(q);
207
- return snapshot.docs.map((doc) => doc.data() as Review);
248
+ return snapshot.docs.map(doc => doc.data() as Review);
208
249
  }
209
250
 
210
251
  /**
@@ -215,10 +256,10 @@ export class ReviewService extends BaseService {
215
256
  async getReviewsByProcedure(procedureId: string): Promise<Review[]> {
216
257
  const q = query(
217
258
  collection(this.db, REVIEWS_COLLECTION),
218
- where("procedureReview.procedureId", "==", procedureId)
259
+ where('procedureReview.procedureId', '==', procedureId),
219
260
  );
220
261
  const snapshot = await getDocs(q);
221
- return snapshot.docs.map((doc) => doc.data() as Review);
262
+ return snapshot.docs.map(doc => doc.data() as Review);
222
263
  }
223
264
 
224
265
  /**
@@ -229,7 +270,7 @@ export class ReviewService extends BaseService {
229
270
  async getReviewByAppointment(appointmentId: string): Promise<Review | null> {
230
271
  const q = query(
231
272
  collection(this.db, REVIEWS_COLLECTION),
232
- where("appointmentId", "==", appointmentId)
273
+ where('appointmentId', '==', appointmentId),
233
274
  );
234
275
  const snapshot = await getDocs(q);
235
276
 
@@ -22,6 +22,7 @@ interface BaseReview {
22
22
  */
23
23
  export interface ClinicReview extends BaseReview {
24
24
  clinicId: string;
25
+ clinicName?: string; // Enhanced field: clinic name from appointment
25
26
  cleanliness: number; // 1-5 stars
26
27
  facilities: number; // 1-5 stars
27
28
  staffFriendliness: number; // 1-5 stars
@@ -37,6 +38,7 @@ export interface ClinicReview extends BaseReview {
37
38
  */
38
39
  export interface PractitionerReview extends BaseReview {
39
40
  practitionerId: string;
41
+ practitionerName?: string; // Enhanced field: practitioner name from appointment
40
42
  knowledgeAndExpertise: number; // 1-5 stars
41
43
  communicationSkills: number; // 1-5 stars
42
44
  bedSideManner: number; // 1-5 stars
@@ -52,6 +54,7 @@ export interface PractitionerReview extends BaseReview {
52
54
  */
53
55
  export interface ProcedureReview extends BaseReview {
54
56
  procedureId: string;
57
+ procedureName?: string; // Enhanced field: procedure name from appointment
55
58
  effectivenessOfTreatment: number; // 1-5 stars
56
59
  outcomeExplanation: number; // 1-5 stars
57
60
  painManagement: number; // 1-5 stars