@blackcode_sa/metaestetics-api 1.13.17 → 1.13.19

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.
@@ -1882,6 +1882,8 @@ declare enum SyncedCalendarProvider {
1882
1882
  declare enum CalendarEventStatus {
1883
1883
  PENDING = "pending",// When event is created, but not confirmed
1884
1884
  CONFIRMED = "confirmed",// When event is confirmed and ready to be used
1885
+ CHECKED_IN = "checked_in",// Patient has arrived and checked in
1886
+ IN_PROGRESS = "in_progress",// Procedure has started
1885
1887
  REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
1886
1888
  CANCELED = "canceled",// When event is canceled by the patient
1887
1889
  RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
@@ -1882,6 +1882,8 @@ declare enum SyncedCalendarProvider {
1882
1882
  declare enum CalendarEventStatus {
1883
1883
  PENDING = "pending",// When event is created, but not confirmed
1884
1884
  CONFIRMED = "confirmed",// When event is confirmed and ready to be used
1885
+ CHECKED_IN = "checked_in",// Patient has arrived and checked in
1886
+ IN_PROGRESS = "in_progress",// Procedure has started
1885
1887
  REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
1886
1888
  CANCELED = "canceled",// When event is canceled by the patient
1887
1889
  RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
package/dist/index.d.mts CHANGED
@@ -2756,6 +2756,8 @@ declare const SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
2756
2756
  declare enum CalendarEventStatus {
2757
2757
  PENDING = "pending",// When event is created, but not confirmed
2758
2758
  CONFIRMED = "confirmed",// When event is confirmed and ready to be used
2759
+ CHECKED_IN = "checked_in",// Patient has arrived and checked in
2760
+ IN_PROGRESS = "in_progress",// Procedure has started
2759
2761
  REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
2760
2762
  CANCELED = "canceled",// When event is canceled by the patient
2761
2763
  RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
@@ -6793,9 +6795,10 @@ declare class ProcedureService extends BaseService {
6793
6795
  /**
6794
6796
  * Gets all procedures for a clinic branch
6795
6797
  * @param clinicBranchId - The ID of the clinic branch
6798
+ * @param excludeDraftPractitioners - Whether to exclude procedures if the practitioner is in DRAFT status (default: false for admin views)
6796
6799
  * @returns List of procedures
6797
6800
  */
6798
- getProceduresByClinicBranch(clinicBranchId: string): Promise<Procedure[]>;
6801
+ getProceduresByClinicBranch(clinicBranchId: string, excludeDraftPractitioners?: boolean): Promise<Procedure[]>;
6799
6802
  /**
6800
6803
  * Gets all procedures for a practitioner
6801
6804
  * @param practitionerId - The ID of the practitioner
package/dist/index.d.ts CHANGED
@@ -2756,6 +2756,8 @@ declare const SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
2756
2756
  declare enum CalendarEventStatus {
2757
2757
  PENDING = "pending",// When event is created, but not confirmed
2758
2758
  CONFIRMED = "confirmed",// When event is confirmed and ready to be used
2759
+ CHECKED_IN = "checked_in",// Patient has arrived and checked in
2760
+ IN_PROGRESS = "in_progress",// Procedure has started
2759
2761
  REJECTED = "rejected",// When event is rejected by the clinic administrator or patient
2760
2762
  CANCELED = "canceled",// When event is canceled by the patient
2761
2763
  RESCHEDULED = "rescheduled",// When event is rescheduled by the clinic administrator
@@ -6793,9 +6795,10 @@ declare class ProcedureService extends BaseService {
6793
6795
  /**
6794
6796
  * Gets all procedures for a clinic branch
6795
6797
  * @param clinicBranchId - The ID of the clinic branch
6798
+ * @param excludeDraftPractitioners - Whether to exclude procedures if the practitioner is in DRAFT status (default: false for admin views)
6796
6799
  * @returns List of procedures
6797
6800
  */
6798
- getProceduresByClinicBranch(clinicBranchId: string): Promise<Procedure[]>;
6801
+ getProceduresByClinicBranch(clinicBranchId: string, excludeDraftPractitioners?: boolean): Promise<Procedure[]>;
6799
6802
  /**
6800
6803
  * Gets all procedures for a practitioner
6801
6804
  * @param practitionerId - The ID of the practitioner
package/dist/index.js CHANGED
@@ -4473,6 +4473,8 @@ var import_firestore6 = require("firebase/firestore");
4473
4473
  var CalendarEventStatus = /* @__PURE__ */ ((CalendarEventStatus4) => {
4474
4474
  CalendarEventStatus4["PENDING"] = "pending";
4475
4475
  CalendarEventStatus4["CONFIRMED"] = "confirmed";
4476
+ CalendarEventStatus4["CHECKED_IN"] = "checked_in";
4477
+ CalendarEventStatus4["IN_PROGRESS"] = "in_progress";
4476
4478
  CalendarEventStatus4["REJECTED"] = "rejected";
4477
4479
  CalendarEventStatus4["CANCELED"] = "canceled";
4478
4480
  CalendarEventStatus4["RESCHEDULED"] = "rescheduled";
@@ -4628,11 +4630,21 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
4628
4630
  }
4629
4631
  let calendarStatus;
4630
4632
  switch (appointmentStatus) {
4633
+ case "pending" /* PENDING */:
4634
+ calendarStatus = "pending";
4635
+ break;
4631
4636
  case "confirmed" /* CONFIRMED */:
4632
4637
  calendarStatus = "confirmed";
4633
4638
  break;
4639
+ case "checked_in" /* CHECKED_IN */:
4640
+ calendarStatus = "checked_in";
4641
+ break;
4642
+ case "in_progress" /* IN_PROGRESS */:
4643
+ calendarStatus = "in_progress";
4644
+ break;
4634
4645
  case "canceled_patient" /* CANCELED_PATIENT */:
4635
4646
  case "canceled_clinic" /* CANCELED_CLINIC */:
4647
+ case "canceled_patient_rescheduled" /* CANCELED_PATIENT_RESCHEDULED */:
4636
4648
  calendarStatus = "canceled";
4637
4649
  break;
4638
4650
  case "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */:
@@ -4641,7 +4653,11 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
4641
4653
  case "completed" /* COMPLETED */:
4642
4654
  calendarStatus = "completed";
4643
4655
  break;
4656
+ case "no_show" /* NO_SHOW */:
4657
+ calendarStatus = "no_show";
4658
+ break;
4644
4659
  default:
4660
+ console.warn(`Unknown appointment status: ${appointmentStatus}, not updating calendar event`);
4645
4661
  return;
4646
4662
  }
4647
4663
  await (0, import_firestore6.updateDoc)(calendarEventRef, {
@@ -17830,10 +17846,20 @@ var CalendarServiceV2 = class extends BaseService {
17830
17846
  ],
17831
17847
  ["confirmed" /* CONFIRMED */]: [
17832
17848
  "canceled" /* CANCELED */,
17849
+ "checked_in" /* CHECKED_IN */,
17833
17850
  "completed" /* COMPLETED */,
17834
17851
  "rescheduled" /* RESCHEDULED */,
17835
17852
  "no_show" /* NO_SHOW */
17836
17853
  ],
17854
+ ["checked_in" /* CHECKED_IN */]: [
17855
+ "in_progress" /* IN_PROGRESS */,
17856
+ "completed" /* COMPLETED */,
17857
+ "canceled" /* CANCELED */
17858
+ ],
17859
+ ["in_progress" /* IN_PROGRESS */]: [
17860
+ "completed" /* COMPLETED */,
17861
+ "canceled" /* CANCELED */
17862
+ ],
17837
17863
  ["rejected" /* REJECTED */]: [],
17838
17864
  ["canceled" /* CANCELED */]: [],
17839
17865
  ["rescheduled" /* RESCHEDULED */]: [
@@ -20878,9 +20904,10 @@ var ProcedureService = class extends BaseService {
20878
20904
  /**
20879
20905
  * Gets all procedures for a clinic branch
20880
20906
  * @param clinicBranchId - The ID of the clinic branch
20907
+ * @param excludeDraftPractitioners - Whether to exclude procedures if the practitioner is in DRAFT status (default: false for admin views)
20881
20908
  * @returns List of procedures
20882
20909
  */
20883
- async getProceduresByClinicBranch(clinicBranchId) {
20910
+ async getProceduresByClinicBranch(clinicBranchId, excludeDraftPractitioners = false) {
20884
20911
  const q = (0, import_firestore58.query)(
20885
20912
  (0, import_firestore58.collection)(this.db, PROCEDURES_COLLECTION),
20886
20913
  (0, import_firestore58.where)("clinicBranchId", "==", clinicBranchId),
@@ -20888,7 +20915,10 @@ var ProcedureService = class extends BaseService {
20888
20915
  );
20889
20916
  const snapshot = await (0, import_firestore58.getDocs)(q);
20890
20917
  const procedures = snapshot.docs.map((doc47) => doc47.data());
20891
- return await this.filterDraftPractitionerProcedures(procedures);
20918
+ if (excludeDraftPractitioners) {
20919
+ return await this.filterDraftPractitionerProcedures(procedures);
20920
+ }
20921
+ return procedures;
20892
20922
  }
20893
20923
  /**
20894
20924
  * Gets all procedures for a practitioner
@@ -21998,12 +22028,18 @@ var ReviewService = class extends BaseService {
21998
22028
  updatedAt: now
21999
22029
  };
22000
22030
  reviewSchema.parse(review);
22001
- const docRef = (0, import_firestore59.doc)(this.db, REVIEWS_COLLECTION, reviewId);
22002
- await (0, import_firestore59.setDoc)(docRef, {
22031
+ const firestoreData = {
22003
22032
  ...review,
22004
22033
  createdAt: (0, import_firestore59.serverTimestamp)(),
22005
22034
  updatedAt: (0, import_firestore59.serverTimestamp)()
22035
+ };
22036
+ Object.keys(firestoreData).forEach((key) => {
22037
+ if (firestoreData[key] === void 0) {
22038
+ delete firestoreData[key];
22039
+ }
22006
22040
  });
22041
+ const docRef = (0, import_firestore59.doc)(this.db, REVIEWS_COLLECTION, reviewId);
22042
+ await (0, import_firestore59.setDoc)(docRef, firestoreData);
22007
22043
  console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
22008
22044
  reviewId,
22009
22045
  practitionerId: (_e = review.practitionerReview) == null ? void 0 : _e.practitionerId,
package/dist/index.mjs CHANGED
@@ -4360,6 +4360,8 @@ import {
4360
4360
  var CalendarEventStatus = /* @__PURE__ */ ((CalendarEventStatus4) => {
4361
4361
  CalendarEventStatus4["PENDING"] = "pending";
4362
4362
  CalendarEventStatus4["CONFIRMED"] = "confirmed";
4363
+ CalendarEventStatus4["CHECKED_IN"] = "checked_in";
4364
+ CalendarEventStatus4["IN_PROGRESS"] = "in_progress";
4363
4365
  CalendarEventStatus4["REJECTED"] = "rejected";
4364
4366
  CalendarEventStatus4["CANCELED"] = "canceled";
4365
4367
  CalendarEventStatus4["RESCHEDULED"] = "rescheduled";
@@ -4515,11 +4517,21 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
4515
4517
  }
4516
4518
  let calendarStatus;
4517
4519
  switch (appointmentStatus) {
4520
+ case "pending" /* PENDING */:
4521
+ calendarStatus = "pending";
4522
+ break;
4518
4523
  case "confirmed" /* CONFIRMED */:
4519
4524
  calendarStatus = "confirmed";
4520
4525
  break;
4526
+ case "checked_in" /* CHECKED_IN */:
4527
+ calendarStatus = "checked_in";
4528
+ break;
4529
+ case "in_progress" /* IN_PROGRESS */:
4530
+ calendarStatus = "in_progress";
4531
+ break;
4521
4532
  case "canceled_patient" /* CANCELED_PATIENT */:
4522
4533
  case "canceled_clinic" /* CANCELED_CLINIC */:
4534
+ case "canceled_patient_rescheduled" /* CANCELED_PATIENT_RESCHEDULED */:
4523
4535
  calendarStatus = "canceled";
4524
4536
  break;
4525
4537
  case "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */:
@@ -4528,7 +4540,11 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
4528
4540
  case "completed" /* COMPLETED */:
4529
4541
  calendarStatus = "completed";
4530
4542
  break;
4543
+ case "no_show" /* NO_SHOW */:
4544
+ calendarStatus = "no_show";
4545
+ break;
4531
4546
  default:
4547
+ console.warn(`Unknown appointment status: ${appointmentStatus}, not updating calendar event`);
4532
4548
  return;
4533
4549
  }
4534
4550
  await updateDoc2(calendarEventRef, {
@@ -17987,10 +18003,20 @@ var CalendarServiceV2 = class extends BaseService {
17987
18003
  ],
17988
18004
  ["confirmed" /* CONFIRMED */]: [
17989
18005
  "canceled" /* CANCELED */,
18006
+ "checked_in" /* CHECKED_IN */,
17990
18007
  "completed" /* COMPLETED */,
17991
18008
  "rescheduled" /* RESCHEDULED */,
17992
18009
  "no_show" /* NO_SHOW */
17993
18010
  ],
18011
+ ["checked_in" /* CHECKED_IN */]: [
18012
+ "in_progress" /* IN_PROGRESS */,
18013
+ "completed" /* COMPLETED */,
18014
+ "canceled" /* CANCELED */
18015
+ ],
18016
+ ["in_progress" /* IN_PROGRESS */]: [
18017
+ "completed" /* COMPLETED */,
18018
+ "canceled" /* CANCELED */
18019
+ ],
17994
18020
  ["rejected" /* REJECTED */]: [],
17995
18021
  ["canceled" /* CANCELED */]: [],
17996
18022
  ["rescheduled" /* RESCHEDULED */]: [
@@ -21114,9 +21140,10 @@ var ProcedureService = class extends BaseService {
21114
21140
  /**
21115
21141
  * Gets all procedures for a clinic branch
21116
21142
  * @param clinicBranchId - The ID of the clinic branch
21143
+ * @param excludeDraftPractitioners - Whether to exclude procedures if the practitioner is in DRAFT status (default: false for admin views)
21117
21144
  * @returns List of procedures
21118
21145
  */
21119
- async getProceduresByClinicBranch(clinicBranchId) {
21146
+ async getProceduresByClinicBranch(clinicBranchId, excludeDraftPractitioners = false) {
21120
21147
  const q = query33(
21121
21148
  collection33(this.db, PROCEDURES_COLLECTION),
21122
21149
  where33("clinicBranchId", "==", clinicBranchId),
@@ -21124,7 +21151,10 @@ var ProcedureService = class extends BaseService {
21124
21151
  );
21125
21152
  const snapshot = await getDocs33(q);
21126
21153
  const procedures = snapshot.docs.map((doc47) => doc47.data());
21127
- return await this.filterDraftPractitionerProcedures(procedures);
21154
+ if (excludeDraftPractitioners) {
21155
+ return await this.filterDraftPractitionerProcedures(procedures);
21156
+ }
21157
+ return procedures;
21128
21158
  }
21129
21159
  /**
21130
21160
  * Gets all procedures for a practitioner
@@ -22244,12 +22274,18 @@ var ReviewService = class extends BaseService {
22244
22274
  updatedAt: now
22245
22275
  };
22246
22276
  reviewSchema.parse(review);
22247
- const docRef = doc40(this.db, REVIEWS_COLLECTION, reviewId);
22248
- await setDoc28(docRef, {
22277
+ const firestoreData = {
22249
22278
  ...review,
22250
22279
  createdAt: serverTimestamp32(),
22251
22280
  updatedAt: serverTimestamp32()
22281
+ };
22282
+ Object.keys(firestoreData).forEach((key) => {
22283
+ if (firestoreData[key] === void 0) {
22284
+ delete firestoreData[key];
22285
+ }
22252
22286
  });
22287
+ const docRef = doc40(this.db, REVIEWS_COLLECTION, reviewId);
22288
+ await setDoc28(docRef, firestoreData);
22253
22289
  console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
22254
22290
  reviewId,
22255
22291
  practitionerId: (_e = review.practitionerReview) == null ? void 0 : _e.practitionerId,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.13.17",
4
+ "version": "1.13.19",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -423,11 +423,21 @@ async function updateCalendarEventStatus(
423
423
  // Map appointment status to calendar event status
424
424
  let calendarStatus;
425
425
  switch (appointmentStatus) {
426
+ case AppointmentStatus.PENDING:
427
+ calendarStatus = 'pending';
428
+ break;
426
429
  case AppointmentStatus.CONFIRMED:
427
430
  calendarStatus = 'confirmed';
428
431
  break;
432
+ case AppointmentStatus.CHECKED_IN:
433
+ calendarStatus = 'checked_in';
434
+ break;
435
+ case AppointmentStatus.IN_PROGRESS:
436
+ calendarStatus = 'in_progress';
437
+ break;
429
438
  case AppointmentStatus.CANCELED_PATIENT:
430
439
  case AppointmentStatus.CANCELED_CLINIC:
440
+ case AppointmentStatus.CANCELED_PATIENT_RESCHEDULED:
431
441
  calendarStatus = 'canceled';
432
442
  break;
433
443
  case AppointmentStatus.RESCHEDULED_BY_CLINIC:
@@ -436,8 +446,12 @@ async function updateCalendarEventStatus(
436
446
  case AppointmentStatus.COMPLETED:
437
447
  calendarStatus = 'completed';
438
448
  break;
449
+ case AppointmentStatus.NO_SHOW:
450
+ calendarStatus = 'no_show';
451
+ break;
439
452
  default:
440
- // For other states, don't update the calendar status
453
+ // For unknown states, don't update the calendar status
454
+ console.warn(`Unknown appointment status: ${appointmentStatus}, not updating calendar event`);
441
455
  return;
442
456
  }
443
457
 
@@ -1140,10 +1140,20 @@ export class CalendarServiceV2 extends BaseService {
1140
1140
  ],
1141
1141
  [CalendarEventStatus.CONFIRMED]: [
1142
1142
  CalendarEventStatus.CANCELED,
1143
+ CalendarEventStatus.CHECKED_IN,
1143
1144
  CalendarEventStatus.COMPLETED,
1144
1145
  CalendarEventStatus.RESCHEDULED,
1145
1146
  CalendarEventStatus.NO_SHOW,
1146
1147
  ],
1148
+ [CalendarEventStatus.CHECKED_IN]: [
1149
+ CalendarEventStatus.IN_PROGRESS,
1150
+ CalendarEventStatus.COMPLETED,
1151
+ CalendarEventStatus.CANCELED,
1152
+ ],
1153
+ [CalendarEventStatus.IN_PROGRESS]: [
1154
+ CalendarEventStatus.COMPLETED,
1155
+ CalendarEventStatus.CANCELED,
1156
+ ],
1147
1157
  [CalendarEventStatus.REJECTED]: [],
1148
1158
  [CalendarEventStatus.CANCELED]: [],
1149
1159
  [CalendarEventStatus.RESCHEDULED]: [
@@ -1109,9 +1109,13 @@ export class ProcedureService extends BaseService {
1109
1109
  /**
1110
1110
  * Gets all procedures for a clinic branch
1111
1111
  * @param clinicBranchId - The ID of the clinic branch
1112
+ * @param excludeDraftPractitioners - Whether to exclude procedures if the practitioner is in DRAFT status (default: false for admin views)
1112
1113
  * @returns List of procedures
1113
1114
  */
1114
- async getProceduresByClinicBranch(clinicBranchId: string): Promise<Procedure[]> {
1115
+ async getProceduresByClinicBranch(
1116
+ clinicBranchId: string,
1117
+ excludeDraftPractitioners: boolean = false
1118
+ ): Promise<Procedure[]> {
1115
1119
  const q = query(
1116
1120
  collection(this.db, PROCEDURES_COLLECTION),
1117
1121
  where('clinicBranchId', '==', clinicBranchId),
@@ -1120,8 +1124,12 @@ export class ProcedureService extends BaseService {
1120
1124
  const snapshot = await getDocs(q);
1121
1125
  const procedures = snapshot.docs.map(doc => doc.data() as Procedure);
1122
1126
 
1123
- // Filter out procedures from draft practitioners
1124
- return await this.filterDraftPractitionerProcedures(procedures);
1127
+ // Filter out procedures from draft practitioners only if explicitly requested (for patient-facing apps)
1128
+ if (excludeDraftPractitioners) {
1129
+ return await this.filterDraftPractitionerProcedures(procedures);
1130
+ }
1131
+
1132
+ return procedures;
1125
1133
  }
1126
1134
 
1127
1135
  /**
@@ -213,14 +213,25 @@ export class ReviewService extends BaseService {
213
213
  // Validate complete review object
214
214
  reviewSchema.parse(review);
215
215
 
216
- // Save the review to Firestore
217
- const docRef = doc(this.db, REVIEWS_COLLECTION, reviewId);
218
- await setDoc(docRef, {
216
+ // Prepare Firestore document, filtering out undefined values
217
+ // Firebase doesn't accept undefined values, so we omit them
218
+ const firestoreData: any = {
219
219
  ...review,
220
220
  createdAt: serverTimestamp(),
221
221
  updatedAt: serverTimestamp(),
222
+ };
223
+
224
+ // Remove undefined fields to prevent Firebase errors
225
+ Object.keys(firestoreData).forEach((key) => {
226
+ if (firestoreData[key] === undefined) {
227
+ delete firestoreData[key];
228
+ }
222
229
  });
223
230
 
231
+ // Save the review to Firestore
232
+ const docRef = doc(this.db, REVIEWS_COLLECTION, reviewId);
233
+ await setDoc(docRef, firestoreData);
234
+
224
235
  console.log('✅ ReviewService.createReview - Review saved to Firestore:', {
225
236
  reviewId,
226
237
  practitionerId: review.practitionerReview?.practitionerId,
@@ -23,6 +23,8 @@ import type {
23
23
  export enum CalendarEventStatus {
24
24
  PENDING = "pending", // When event is created, but not confirmed
25
25
  CONFIRMED = "confirmed", // When event is confirmed and ready to be used
26
+ CHECKED_IN = "checked_in", // Patient has arrived and checked in
27
+ IN_PROGRESS = "in_progress", // Procedure has started
26
28
  REJECTED = "rejected", // When event is rejected by the clinic administrator or patient
27
29
  CANCELED = "canceled", // When event is canceled by the patient
28
30
  RESCHEDULED = "rescheduled", // When event is rescheduled by the clinic administrator