@blackcode_sa/metaestetics-api 1.12.62 → 1.12.64
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/admin/index.d.mts +4 -2
- package/dist/admin/index.d.ts +4 -2
- package/dist/admin/index.js +4 -45
- package/dist/admin/index.mjs +4 -45
- package/dist/backoffice/index.d.mts +86 -1
- package/dist/backoffice/index.d.ts +86 -1
- package/dist/backoffice/index.js +308 -0
- package/dist/backoffice/index.mjs +306 -0
- package/dist/index.d.mts +99 -3
- package/dist/index.d.ts +99 -3
- package/dist/index.js +545 -281
- package/dist/index.mjs +867 -603
- package/package.json +119 -119
- package/src/__mocks__/firstore.ts +10 -10
- package/src/admin/aggregation/README.md +79 -79
- package/src/admin/aggregation/appointment/README.md +128 -128
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +1844 -1844
- package/src/admin/aggregation/appointment/index.ts +1 -1
- package/src/admin/aggregation/clinic/README.md +52 -52
- package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +703 -703
- package/src/admin/aggregation/clinic/index.ts +1 -1
- package/src/admin/aggregation/forms/README.md +13 -13
- package/src/admin/aggregation/forms/filled-forms.aggregation.service.ts +322 -322
- package/src/admin/aggregation/forms/index.ts +1 -1
- package/src/admin/aggregation/index.ts +8 -8
- package/src/admin/aggregation/patient/README.md +27 -27
- package/src/admin/aggregation/patient/index.ts +1 -1
- package/src/admin/aggregation/patient/patient.aggregation.service.ts +141 -141
- package/src/admin/aggregation/practitioner/README.md +42 -42
- package/src/admin/aggregation/practitioner/index.ts +1 -1
- package/src/admin/aggregation/practitioner/practitioner.aggregation.service.ts +433 -433
- package/src/admin/aggregation/practitioner-invite/index.ts +1 -1
- package/src/admin/aggregation/practitioner-invite/practitioner-invite.aggregation.service.ts +961 -961
- package/src/admin/aggregation/procedure/README.md +43 -43
- package/src/admin/aggregation/procedure/index.ts +1 -1
- package/src/admin/aggregation/procedure/procedure.aggregation.service.ts +702 -702
- package/src/admin/aggregation/reviews/index.ts +1 -1
- package/src/admin/aggregation/reviews/reviews.aggregation.service.ts +641 -689
- package/src/admin/booking/README.md +125 -125
- package/src/admin/booking/booking.admin.ts +1037 -1037
- package/src/admin/booking/booking.calculator.ts +712 -712
- package/src/admin/booking/booking.types.ts +59 -59
- package/src/admin/booking/index.ts +3 -3
- package/src/admin/booking/timezones-problem.md +185 -185
- package/src/admin/calendar/README.md +7 -7
- package/src/admin/calendar/calendar.admin.service.ts +345 -345
- package/src/admin/calendar/index.ts +1 -1
- package/src/admin/documentation-templates/document-manager.admin.ts +260 -260
- package/src/admin/documentation-templates/index.ts +1 -1
- package/src/admin/free-consultation/free-consultation-utils.admin.ts +148 -148
- package/src/admin/free-consultation/index.ts +1 -1
- package/src/admin/index.ts +75 -75
- package/src/admin/logger/index.ts +78 -78
- package/src/admin/mailing/README.md +95 -95
- package/src/admin/mailing/appointment/appointment.mailing.service.ts +732 -732
- package/src/admin/mailing/appointment/index.ts +1 -1
- package/src/admin/mailing/appointment/templates/patient/appointment-confirmed.html +40 -40
- package/src/admin/mailing/base.mailing.service.ts +208 -208
- package/src/admin/mailing/index.ts +3 -3
- package/src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts +611 -611
- package/src/admin/mailing/practitionerInvite/index.ts +2 -2
- package/src/admin/mailing/practitionerInvite/practitionerInvite.mailing.ts +395 -395
- package/src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts +155 -155
- package/src/admin/mailing/practitionerInvite/templates/invitation.template.ts +101 -101
- package/src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts +228 -228
- package/src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts +242 -242
- package/src/admin/notifications/index.ts +1 -1
- package/src/admin/notifications/notifications.admin.ts +710 -710
- package/src/admin/requirements/README.md +128 -128
- package/src/admin/requirements/index.ts +1 -1
- package/src/admin/requirements/patient-requirements.admin.service.ts +475 -475
- package/src/admin/users/index.ts +1 -1
- package/src/admin/users/user-profile.admin.ts +405 -405
- package/src/backoffice/constants/certification.constants.ts +13 -13
- package/src/backoffice/constants/index.ts +1 -1
- package/src/backoffice/errors/backoffice.errors.ts +181 -181
- package/src/backoffice/errors/index.ts +1 -1
- package/src/backoffice/expo-safe/README.md +26 -26
- package/src/backoffice/expo-safe/index.ts +41 -41
- package/src/backoffice/index.ts +5 -5
- package/src/backoffice/services/FIXES_README.md +102 -102
- package/src/backoffice/services/README.md +40 -40
- package/src/backoffice/services/brand.service.ts +256 -256
- package/src/backoffice/services/category.service.ts +318 -318
- package/src/backoffice/services/constants.service.ts +385 -385
- package/src/backoffice/services/documentation-template.service.ts +202 -202
- package/src/backoffice/services/index.ts +11 -8
- package/src/backoffice/services/migrate-products.ts +116 -116
- package/src/backoffice/services/product.service.ts +553 -553
- package/src/backoffice/services/requirement.service.ts +235 -235
- package/src/backoffice/services/subcategory.service.ts +395 -395
- package/src/backoffice/services/technology.service.ts +1083 -1070
- package/src/backoffice/types/README.md +12 -12
- package/src/backoffice/types/admin-constants.types.ts +69 -69
- package/src/backoffice/types/brand.types.ts +29 -29
- package/src/backoffice/types/category.types.ts +62 -62
- package/src/backoffice/types/documentation-templates.types.ts +28 -28
- package/src/backoffice/types/index.ts +10 -10
- package/src/backoffice/types/procedure-product.types.ts +38 -38
- package/src/backoffice/types/product.types.ts +240 -240
- package/src/backoffice/types/requirement.types.ts +63 -63
- package/src/backoffice/types/static/README.md +18 -18
- package/src/backoffice/types/static/blocking-condition.types.ts +21 -21
- package/src/backoffice/types/static/certification.types.ts +37 -37
- package/src/backoffice/types/static/contraindication.types.ts +19 -19
- package/src/backoffice/types/static/index.ts +6 -6
- package/src/backoffice/types/static/pricing.types.ts +16 -16
- package/src/backoffice/types/static/procedure-family.types.ts +14 -14
- package/src/backoffice/types/static/treatment-benefit.types.ts +22 -22
- package/src/backoffice/types/subcategory.types.ts +34 -34
- package/src/backoffice/types/technology.types.ts +163 -161
- package/src/backoffice/validations/index.ts +1 -1
- package/src/backoffice/validations/schemas.ts +164 -163
- package/src/config/__mocks__/firebase.ts +99 -99
- package/src/config/firebase.ts +78 -78
- package/src/config/index.ts +9 -9
- package/src/errors/auth.error.ts +6 -6
- package/src/errors/auth.errors.ts +200 -200
- package/src/errors/clinic.errors.ts +32 -32
- package/src/errors/firebase.errors.ts +47 -47
- package/src/errors/user.errors.ts +99 -99
- package/src/index.backup.ts +407 -407
- package/src/index.ts +6 -6
- package/src/locales/en.ts +31 -31
- package/src/recommender/admin/index.ts +1 -1
- package/src/recommender/admin/services/recommender.service.admin.ts +5 -5
- package/src/recommender/front/index.ts +1 -1
- package/src/recommender/front/services/onboarding.service.ts +5 -5
- package/src/recommender/front/services/recommender.service.ts +3 -3
- package/src/recommender/index.ts +1 -1
- package/src/services/PATIENTAUTH.MD +197 -197
- package/src/services/README.md +106 -106
- package/src/services/__tests__/auth/auth.mock.test.ts +17 -17
- package/src/services/__tests__/auth/auth.setup.ts +293 -293
- package/src/services/__tests__/auth.service.test.ts +346 -346
- package/src/services/__tests__/base.service.test.ts +77 -77
- package/src/services/__tests__/user.service.test.ts +528 -528
- package/src/services/appointment/README.md +17 -17
- package/src/services/appointment/appointment.service.ts +2505 -2082
- package/src/services/appointment/index.ts +1 -1
- package/src/services/appointment/utils/appointment.utils.ts +552 -552
- package/src/services/appointment/utils/extended-procedure.utils.ts +314 -314
- package/src/services/appointment/utils/form-initialization.utils.ts +225 -225
- package/src/services/appointment/utils/recommended-procedure.utils.ts +195 -195
- package/src/services/appointment/utils/zone-management.utils.ts +353 -353
- package/src/services/appointment/utils/zone-photo.utils.ts +152 -152
- package/src/services/auth/auth.service.ts +989 -989
- package/src/services/auth/auth.v2.service.ts +961 -961
- package/src/services/auth/index.ts +7 -7
- package/src/services/auth/utils/error.utils.ts +90 -90
- package/src/services/auth/utils/firebase.utils.ts +49 -49
- package/src/services/auth/utils/index.ts +21 -21
- package/src/services/auth/utils/practitioner.utils.ts +125 -125
- package/src/services/base.service.ts +41 -41
- package/src/services/calendar/calendar.service.ts +1077 -1077
- package/src/services/calendar/calendar.v2.service.ts +1683 -1683
- package/src/services/calendar/calendar.v3.service.ts +313 -313
- package/src/services/calendar/externalCalendar.service.ts +178 -178
- package/src/services/calendar/index.ts +5 -5
- package/src/services/calendar/synced-calendars.service.ts +743 -743
- package/src/services/calendar/utils/appointment.utils.ts +265 -265
- package/src/services/calendar/utils/calendar-event.utils.ts +646 -646
- package/src/services/calendar/utils/clinic.utils.ts +237 -237
- package/src/services/calendar/utils/docs.utils.ts +157 -157
- package/src/services/calendar/utils/google-calendar.utils.ts +697 -697
- package/src/services/calendar/utils/index.ts +8 -8
- package/src/services/calendar/utils/patient.utils.ts +198 -198
- package/src/services/calendar/utils/practitioner.utils.ts +221 -221
- package/src/services/calendar/utils/synced-calendar.utils.ts +472 -472
- package/src/services/clinic/README.md +204 -204
- package/src/services/clinic/__tests__/clinic-admin.service.test.ts +287 -287
- package/src/services/clinic/__tests__/clinic-group.service.test.ts +352 -352
- package/src/services/clinic/__tests__/clinic.service.test.ts +354 -354
- package/src/services/clinic/billing-transactions.service.ts +217 -217
- package/src/services/clinic/clinic-admin.service.ts +202 -202
- package/src/services/clinic/clinic-group.service.ts +310 -310
- package/src/services/clinic/clinic.service.ts +708 -708
- package/src/services/clinic/index.ts +5 -5
- package/src/services/clinic/practitioner-invite.service.ts +519 -519
- package/src/services/clinic/utils/admin.utils.ts +551 -551
- package/src/services/clinic/utils/clinic-group.utils.ts +646 -646
- package/src/services/clinic/utils/clinic.utils.ts +949 -949
- package/src/services/clinic/utils/filter.utils.d.ts +23 -23
- package/src/services/clinic/utils/filter.utils.ts +446 -446
- package/src/services/clinic/utils/index.ts +11 -11
- package/src/services/clinic/utils/photos.utils.ts +188 -188
- package/src/services/clinic/utils/search.utils.ts +84 -84
- package/src/services/clinic/utils/tag.utils.ts +124 -124
- package/src/services/documentation-templates/documentation-template.service.ts +537 -537
- package/src/services/documentation-templates/filled-document.service.ts +587 -587
- package/src/services/documentation-templates/index.ts +2 -2
- package/src/services/index.ts +13 -13
- package/src/services/media/index.ts +1 -1
- package/src/services/media/media.service.ts +418 -418
- package/src/services/notifications/__tests__/notification.service.test.ts +242 -242
- package/src/services/notifications/index.ts +1 -1
- package/src/services/notifications/notification.service.ts +215 -215
- package/src/services/patient/README.md +48 -48
- package/src/services/patient/To-Do.md +43 -43
- package/src/services/patient/__tests__/patient.service.test.ts +294 -294
- package/src/services/patient/index.ts +2 -2
- package/src/services/patient/patient.service.ts +883 -883
- package/src/services/patient/patientRequirements.service.ts +285 -285
- package/src/services/patient/utils/aesthetic-analysis.utils.ts +176 -176
- package/src/services/patient/utils/clinic.utils.ts +80 -80
- package/src/services/patient/utils/docs.utils.ts +142 -142
- package/src/services/patient/utils/index.ts +9 -9
- package/src/services/patient/utils/location.utils.ts +126 -126
- package/src/services/patient/utils/medical-stuff.utils.ts +143 -143
- package/src/services/patient/utils/medical.utils.ts +458 -458
- package/src/services/patient/utils/practitioner.utils.ts +260 -260
- package/src/services/patient/utils/profile.utils.ts +510 -510
- package/src/services/patient/utils/sensitive.utils.ts +260 -260
- package/src/services/patient/utils/token.utils.ts +211 -211
- package/src/services/practitioner/README.md +145 -145
- package/src/services/practitioner/index.ts +1 -1
- package/src/services/practitioner/practitioner.service.ts +1742 -1742
- package/src/services/procedure/README.md +163 -163
- package/src/services/procedure/index.ts +1 -1
- package/src/services/procedure/procedure.service.ts +1682 -1682
- package/src/services/reviews/index.ts +1 -1
- package/src/services/reviews/reviews.service.ts +636 -683
- package/src/services/user/index.ts +1 -1
- package/src/services/user/user.service.ts +489 -489
- package/src/services/user/user.v2.service.ts +466 -466
- package/src/types/appointment/index.ts +481 -453
- package/src/types/calendar/index.ts +258 -258
- package/src/types/calendar/synced-calendar.types.ts +66 -66
- package/src/types/clinic/index.ts +489 -489
- package/src/types/clinic/practitioner-invite.types.ts +91 -91
- package/src/types/clinic/preferences.types.ts +159 -159
- package/src/types/clinic/to-do +3 -3
- package/src/types/documentation-templates/index.ts +308 -308
- package/src/types/index.ts +44 -44
- package/src/types/notifications/README.md +77 -77
- package/src/types/notifications/index.ts +265 -265
- package/src/types/patient/aesthetic-analysis.types.ts +66 -66
- package/src/types/patient/allergies.ts +58 -58
- package/src/types/patient/index.ts +275 -273
- package/src/types/patient/medical-info.types.ts +152 -152
- package/src/types/patient/patient-requirements.ts +92 -92
- package/src/types/patient/token.types.ts +61 -61
- package/src/types/practitioner/index.ts +206 -206
- package/src/types/procedure/index.ts +181 -181
- package/src/types/profile/index.ts +39 -39
- package/src/types/reviews/index.ts +130 -132
- package/src/types/tz-lookup.d.ts +4 -4
- package/src/types/user/index.ts +38 -38
- package/src/utils/TIMESTAMPS.md +176 -176
- package/src/utils/TimestampUtils.ts +241 -241
- package/src/utils/index.ts +1 -1
- package/src/validations/appointment.schema.ts +574 -574
- package/src/validations/calendar.schema.ts +225 -225
- package/src/validations/clinic.schema.ts +493 -493
- package/src/validations/common.schema.ts +25 -25
- package/src/validations/documentation-templates/index.ts +1 -1
- package/src/validations/documentation-templates/template.schema.ts +220 -220
- package/src/validations/documentation-templates.schema.ts +10 -10
- package/src/validations/index.ts +20 -20
- package/src/validations/media.schema.ts +10 -10
- package/src/validations/notification.schema.ts +90 -90
- package/src/validations/patient/aesthetic-analysis.schema.ts +55 -55
- package/src/validations/patient/medical-info.schema.ts +125 -125
- package/src/validations/patient/patient-requirements.schema.ts +84 -84
- package/src/validations/patient/token.schema.ts +29 -29
- package/src/validations/patient.schema.ts +217 -216
- package/src/validations/practitioner.schema.ts +222 -222
- package/src/validations/procedure-product.schema.ts +41 -41
- package/src/validations/procedure.schema.ts +124 -124
- package/src/validations/profile-info.schema.ts +41 -41
- package/src/validations/reviews.schema.ts +189 -195
- package/src/validations/schemas.ts +104 -104
- package/src/validations/shared.schema.ts +78 -78
package/dist/index.js
CHANGED
|
@@ -205,6 +205,9 @@ var MediaType = /* @__PURE__ */ ((MediaType2) => {
|
|
|
205
205
|
})(MediaType || {});
|
|
206
206
|
var APPOINTMENTS_COLLECTION = "appointments";
|
|
207
207
|
|
|
208
|
+
// src/types/procedure/index.ts
|
|
209
|
+
var PROCEDURES_COLLECTION = "procedures";
|
|
210
|
+
|
|
208
211
|
// src/validations/appointment.schema.ts
|
|
209
212
|
var import_zod3 = require("zod");
|
|
210
213
|
|
|
@@ -1093,7 +1096,7 @@ var MediaService = class extends BaseService {
|
|
|
1093
1096
|
try {
|
|
1094
1097
|
const querySnapshot = await (0, import_firestore2.getDocs)(finalQuery);
|
|
1095
1098
|
const mediaList = querySnapshot.docs.map(
|
|
1096
|
-
(
|
|
1099
|
+
(doc45) => doc45.data()
|
|
1097
1100
|
);
|
|
1098
1101
|
console.log(`[MediaService] Found ${mediaList.length} media items.`);
|
|
1099
1102
|
return mediaList;
|
|
@@ -1368,9 +1371,6 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
|
|
1368
1371
|
return Gender2;
|
|
1369
1372
|
})(Gender || {});
|
|
1370
1373
|
|
|
1371
|
-
// src/types/procedure/index.ts
|
|
1372
|
-
var PROCEDURES_COLLECTION = "procedures";
|
|
1373
|
-
|
|
1374
1374
|
// src/backoffice/types/technology.types.ts
|
|
1375
1375
|
var TECHNOLOGIES_COLLECTION = "technologies";
|
|
1376
1376
|
|
|
@@ -1523,7 +1523,7 @@ async function searchAppointmentsUtil(db, params) {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
const q = (0, import_firestore3.query)((0, import_firestore3.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
1525
1525
|
const querySnapshot = await (0, import_firestore3.getDocs)(q);
|
|
1526
|
-
const appointments = querySnapshot.docs.map((
|
|
1526
|
+
const appointments = querySnapshot.docs.map((doc45) => doc45.data());
|
|
1527
1527
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
1528
1528
|
return { appointments, lastDoc };
|
|
1529
1529
|
} catch (error) {
|
|
@@ -2857,7 +2857,7 @@ var AppointmentService = class extends BaseService {
|
|
|
2857
2857
|
}
|
|
2858
2858
|
const q = (0, import_firestore11.query)((0, import_firestore11.collection)(this.db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
2859
2859
|
const querySnapshot = await (0, import_firestore11.getDocs)(q);
|
|
2860
|
-
const appointments = querySnapshot.docs.map((
|
|
2860
|
+
const appointments = querySnapshot.docs.map((doc45) => doc45.data());
|
|
2861
2861
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
2862
2862
|
console.log(
|
|
2863
2863
|
`[APPOINTMENT_SERVICE] Found ${appointments.length} upcoming appointments for patient ${patientId}`
|
|
@@ -2913,7 +2913,7 @@ var AppointmentService = class extends BaseService {
|
|
|
2913
2913
|
}
|
|
2914
2914
|
const q = (0, import_firestore11.query)((0, import_firestore11.collection)(this.db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
2915
2915
|
const querySnapshot = await (0, import_firestore11.getDocs)(q);
|
|
2916
|
-
const appointments = querySnapshot.docs.map((
|
|
2916
|
+
const appointments = querySnapshot.docs.map((doc45) => doc45.data());
|
|
2917
2917
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
2918
2918
|
console.log(
|
|
2919
2919
|
`[APPOINTMENT_SERVICE] Found ${appointments.length} past appointments for patient ${patientId}`
|
|
@@ -3635,6 +3635,301 @@ var AppointmentService = class extends BaseService {
|
|
|
3635
3635
|
throw error;
|
|
3636
3636
|
}
|
|
3637
3637
|
}
|
|
3638
|
+
/**
|
|
3639
|
+
* Gets all next steps recommendations for a patient from their past appointments.
|
|
3640
|
+
* Returns recommendations with context about which appointment, practitioner, and clinic suggested them.
|
|
3641
|
+
*
|
|
3642
|
+
* @param patientId ID of the patient
|
|
3643
|
+
* @param options Optional parameters for filtering
|
|
3644
|
+
* @returns Array of next steps recommendations with context
|
|
3645
|
+
*/
|
|
3646
|
+
async getPatientNextStepsRecommendations(patientId, options) {
|
|
3647
|
+
var _a, _b, _c;
|
|
3648
|
+
try {
|
|
3649
|
+
console.log(
|
|
3650
|
+
`[APPOINTMENT_SERVICE] Getting next steps recommendations for patient: ${patientId}`,
|
|
3651
|
+
options
|
|
3652
|
+
);
|
|
3653
|
+
const patientProfile = await this.patientService.getPatientProfile(patientId);
|
|
3654
|
+
const dismissedIds = new Set(
|
|
3655
|
+
(patientProfile == null ? void 0 : patientProfile.dismissedNextStepsRecommendations) || []
|
|
3656
|
+
);
|
|
3657
|
+
const pastAppointments = await this.getPastPatientAppointments(patientId, {
|
|
3658
|
+
showCanceled: false,
|
|
3659
|
+
showNoShow: false
|
|
3660
|
+
});
|
|
3661
|
+
const recommendations = [];
|
|
3662
|
+
for (const appointment of pastAppointments.appointments) {
|
|
3663
|
+
if ((options == null ? void 0 : options.clinicBranchId) && appointment.clinicBranchId !== options.clinicBranchId) {
|
|
3664
|
+
continue;
|
|
3665
|
+
}
|
|
3666
|
+
if ((options == null ? void 0 : options.practitionerId) && appointment.practitionerId !== options.practitionerId) {
|
|
3667
|
+
continue;
|
|
3668
|
+
}
|
|
3669
|
+
const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
|
|
3670
|
+
for (let index = 0; index < recommendedProcedures.length; index++) {
|
|
3671
|
+
const recommendedProcedure = recommendedProcedures[index];
|
|
3672
|
+
const recommendationId = `${appointment.id}:${index}`;
|
|
3673
|
+
if (!(options == null ? void 0 : options.includeDismissed) && dismissedIds.has(recommendationId)) {
|
|
3674
|
+
continue;
|
|
3675
|
+
}
|
|
3676
|
+
const nextStepsRecommendation = {
|
|
3677
|
+
id: recommendationId,
|
|
3678
|
+
recommendedProcedure,
|
|
3679
|
+
appointmentId: appointment.id,
|
|
3680
|
+
appointmentDate: appointment.appointmentStartTime,
|
|
3681
|
+
practitionerId: appointment.practitionerId,
|
|
3682
|
+
practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
|
|
3683
|
+
clinicBranchId: appointment.clinicBranchId,
|
|
3684
|
+
clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
|
|
3685
|
+
appointmentStatus: appointment.status,
|
|
3686
|
+
isDismissed: dismissedIds.has(recommendationId),
|
|
3687
|
+
dismissedAt: null
|
|
3688
|
+
// We don't track when it was dismissed, just that it was
|
|
3689
|
+
};
|
|
3690
|
+
recommendations.push(nextStepsRecommendation);
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
recommendations.sort((a, b) => {
|
|
3694
|
+
const dateA = a.appointmentDate.toMillis();
|
|
3695
|
+
const dateB = b.appointmentDate.toMillis();
|
|
3696
|
+
return dateB - dateA;
|
|
3697
|
+
});
|
|
3698
|
+
const limitedRecommendations = (options == null ? void 0 : options.limit) ? recommendations.slice(0, options.limit) : recommendations;
|
|
3699
|
+
console.log(
|
|
3700
|
+
`[APPOINTMENT_SERVICE] Found ${limitedRecommendations.length} next steps recommendations for patient ${patientId}`
|
|
3701
|
+
);
|
|
3702
|
+
return limitedRecommendations;
|
|
3703
|
+
} catch (error) {
|
|
3704
|
+
console.error(
|
|
3705
|
+
`[APPOINTMENT_SERVICE] Error getting next steps recommendations for patient ${patientId}:`,
|
|
3706
|
+
error
|
|
3707
|
+
);
|
|
3708
|
+
throw error;
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
/**
|
|
3712
|
+
* Dismisses a next steps recommendation for a patient.
|
|
3713
|
+
* This prevents the recommendation from showing up in the default view.
|
|
3714
|
+
*
|
|
3715
|
+
* @param patientId ID of the patient
|
|
3716
|
+
* @param recommendationId ID of the recommendation to dismiss (format: appointmentId:recommendationIndex)
|
|
3717
|
+
* @returns Updated patient profile
|
|
3718
|
+
*/
|
|
3719
|
+
async dismissNextStepsRecommendation(patientId, recommendationId) {
|
|
3720
|
+
try {
|
|
3721
|
+
console.log(
|
|
3722
|
+
`[APPOINTMENT_SERVICE] Dismissing recommendation ${recommendationId} for patient ${patientId}`
|
|
3723
|
+
);
|
|
3724
|
+
const patientProfile = await this.patientService.getPatientProfile(patientId);
|
|
3725
|
+
if (!patientProfile) {
|
|
3726
|
+
throw new Error(`Patient profile not found for patient ${patientId}`);
|
|
3727
|
+
}
|
|
3728
|
+
const dismissedRecommendations = patientProfile.dismissedNextStepsRecommendations || [];
|
|
3729
|
+
if (dismissedRecommendations.includes(recommendationId)) {
|
|
3730
|
+
console.log(
|
|
3731
|
+
`[APPOINTMENT_SERVICE] Recommendation ${recommendationId} already dismissed`
|
|
3732
|
+
);
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
const updatedDismissed = [...dismissedRecommendations, recommendationId];
|
|
3736
|
+
await this.patientService.updatePatientProfile(patientId, {
|
|
3737
|
+
dismissedNextStepsRecommendations: updatedDismissed
|
|
3738
|
+
});
|
|
3739
|
+
console.log(
|
|
3740
|
+
`[APPOINTMENT_SERVICE] Successfully dismissed recommendation ${recommendationId} for patient ${patientId}`
|
|
3741
|
+
);
|
|
3742
|
+
} catch (error) {
|
|
3743
|
+
console.error(
|
|
3744
|
+
`[APPOINTMENT_SERVICE] Error dismissing recommendation for patient ${patientId}:`,
|
|
3745
|
+
error
|
|
3746
|
+
);
|
|
3747
|
+
throw error;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
/**
|
|
3751
|
+
* Undismisses a next steps recommendation for a patient.
|
|
3752
|
+
* This makes the recommendation visible again in the default view.
|
|
3753
|
+
*
|
|
3754
|
+
* @param patientId ID of the patient
|
|
3755
|
+
* @param recommendationId ID of the recommendation to undismiss (format: appointmentId:recommendationIndex)
|
|
3756
|
+
* @returns Updated patient profile
|
|
3757
|
+
*/
|
|
3758
|
+
async undismissNextStepsRecommendation(patientId, recommendationId) {
|
|
3759
|
+
try {
|
|
3760
|
+
console.log(
|
|
3761
|
+
`[APPOINTMENT_SERVICE] Undismissing recommendation ${recommendationId} for patient ${patientId}`
|
|
3762
|
+
);
|
|
3763
|
+
const patientProfile = await this.patientService.getPatientProfile(patientId);
|
|
3764
|
+
if (!patientProfile) {
|
|
3765
|
+
throw new Error(`Patient profile not found for patient ${patientId}`);
|
|
3766
|
+
}
|
|
3767
|
+
const dismissedRecommendations = patientProfile.dismissedNextStepsRecommendations || [];
|
|
3768
|
+
if (!dismissedRecommendations.includes(recommendationId)) {
|
|
3769
|
+
console.log(
|
|
3770
|
+
`[APPOINTMENT_SERVICE] Recommendation ${recommendationId} is not dismissed`
|
|
3771
|
+
);
|
|
3772
|
+
return;
|
|
3773
|
+
}
|
|
3774
|
+
const updatedDismissed = dismissedRecommendations.filter(
|
|
3775
|
+
(id) => id !== recommendationId
|
|
3776
|
+
);
|
|
3777
|
+
await this.patientService.updatePatientProfile(patientId, {
|
|
3778
|
+
dismissedNextStepsRecommendations: updatedDismissed
|
|
3779
|
+
});
|
|
3780
|
+
console.log(
|
|
3781
|
+
`[APPOINTMENT_SERVICE] Successfully undismissed recommendation ${recommendationId} for patient ${patientId}`
|
|
3782
|
+
);
|
|
3783
|
+
} catch (error) {
|
|
3784
|
+
console.error(
|
|
3785
|
+
`[APPOINTMENT_SERVICE] Error undismissing recommendation for patient ${patientId}:`,
|
|
3786
|
+
error
|
|
3787
|
+
);
|
|
3788
|
+
throw error;
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
/**
|
|
3792
|
+
* Gets next steps recommendations for a clinic.
|
|
3793
|
+
* Returns all recommendations from appointments at the specified clinic.
|
|
3794
|
+
* This is useful for clinic admins to see what treatments have been recommended to their patients.
|
|
3795
|
+
*
|
|
3796
|
+
* @param clinicBranchId ID of the clinic branch
|
|
3797
|
+
* @param options Optional parameters for filtering
|
|
3798
|
+
* @returns Array of next steps recommendations with context
|
|
3799
|
+
*/
|
|
3800
|
+
async getClinicNextStepsRecommendations(clinicBranchId, options) {
|
|
3801
|
+
var _a, _b, _c;
|
|
3802
|
+
try {
|
|
3803
|
+
console.log(
|
|
3804
|
+
`[APPOINTMENT_SERVICE] Getting next steps recommendations for clinic: ${clinicBranchId}`,
|
|
3805
|
+
options
|
|
3806
|
+
);
|
|
3807
|
+
const searchParams = {
|
|
3808
|
+
clinicBranchId,
|
|
3809
|
+
patientId: options == null ? void 0 : options.patientId,
|
|
3810
|
+
practitionerId: options == null ? void 0 : options.practitionerId,
|
|
3811
|
+
status: "completed" /* COMPLETED */
|
|
3812
|
+
};
|
|
3813
|
+
const { appointments } = await this.searchAppointments(searchParams);
|
|
3814
|
+
const recommendations = [];
|
|
3815
|
+
for (const appointment of appointments) {
|
|
3816
|
+
const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
|
|
3817
|
+
for (let index = 0; index < recommendedProcedures.length; index++) {
|
|
3818
|
+
const recommendedProcedure = recommendedProcedures[index];
|
|
3819
|
+
const recommendationId = `${appointment.id}:${index}`;
|
|
3820
|
+
const nextStepsRecommendation = {
|
|
3821
|
+
id: recommendationId,
|
|
3822
|
+
recommendedProcedure,
|
|
3823
|
+
appointmentId: appointment.id,
|
|
3824
|
+
appointmentDate: appointment.appointmentStartTime,
|
|
3825
|
+
practitionerId: appointment.practitionerId,
|
|
3826
|
+
practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
|
|
3827
|
+
clinicBranchId: appointment.clinicBranchId,
|
|
3828
|
+
clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
|
|
3829
|
+
appointmentStatus: appointment.status,
|
|
3830
|
+
isDismissed: false,
|
|
3831
|
+
// Clinic view doesn't track dismissals
|
|
3832
|
+
dismissedAt: null
|
|
3833
|
+
};
|
|
3834
|
+
recommendations.push(nextStepsRecommendation);
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
recommendations.sort((a, b) => {
|
|
3838
|
+
const dateA = a.appointmentDate.toMillis();
|
|
3839
|
+
const dateB = b.appointmentDate.toMillis();
|
|
3840
|
+
return dateB - dateA;
|
|
3841
|
+
});
|
|
3842
|
+
const limitedRecommendations = (options == null ? void 0 : options.limit) ? recommendations.slice(0, options.limit) : recommendations;
|
|
3843
|
+
console.log(
|
|
3844
|
+
`[APPOINTMENT_SERVICE] Found ${limitedRecommendations.length} next steps recommendations for clinic ${clinicBranchId}`
|
|
3845
|
+
);
|
|
3846
|
+
return limitedRecommendations;
|
|
3847
|
+
} catch (error) {
|
|
3848
|
+
console.error(
|
|
3849
|
+
`[APPOINTMENT_SERVICE] Error getting next steps recommendations for clinic ${clinicBranchId}:`,
|
|
3850
|
+
error
|
|
3851
|
+
);
|
|
3852
|
+
throw error;
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
/**
|
|
3856
|
+
* Gets next steps recommendations from a specific appointment.
|
|
3857
|
+
* This is useful when viewing an appointment detail page in the clinic app
|
|
3858
|
+
* to see what procedures were recommended during that appointment.
|
|
3859
|
+
*
|
|
3860
|
+
* @param appointmentId ID of the appointment
|
|
3861
|
+
* @param options Optional parameters for filtering
|
|
3862
|
+
* @returns Array of next steps recommendations from that appointment
|
|
3863
|
+
*/
|
|
3864
|
+
async getAppointmentNextStepsRecommendations(appointmentId, options) {
|
|
3865
|
+
var _a, _b, _c;
|
|
3866
|
+
try {
|
|
3867
|
+
console.log(
|
|
3868
|
+
`[APPOINTMENT_SERVICE] Getting next steps recommendations for appointment: ${appointmentId}`,
|
|
3869
|
+
options
|
|
3870
|
+
);
|
|
3871
|
+
const appointment = await this.getAppointmentById(appointmentId);
|
|
3872
|
+
if (!appointment) {
|
|
3873
|
+
throw new Error(`Appointment with ID ${appointmentId} not found`);
|
|
3874
|
+
}
|
|
3875
|
+
const recommendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.recommendedProcedures) || [];
|
|
3876
|
+
const recommendations = [];
|
|
3877
|
+
let availableProcedureIds = null;
|
|
3878
|
+
if (options == null ? void 0 : options.clinicBranchId) {
|
|
3879
|
+
const proceduresQuery = (0, import_firestore11.query)(
|
|
3880
|
+
(0, import_firestore11.collection)(this.db, PROCEDURES_COLLECTION),
|
|
3881
|
+
(0, import_firestore11.where)("clinicBranchId", "==", options.clinicBranchId),
|
|
3882
|
+
(0, import_firestore11.where)("isActive", "==", true)
|
|
3883
|
+
);
|
|
3884
|
+
const proceduresSnapshot = await (0, import_firestore11.getDocs)(proceduresQuery);
|
|
3885
|
+
availableProcedureIds = new Set(
|
|
3886
|
+
proceduresSnapshot.docs.map((doc45) => doc45.id)
|
|
3887
|
+
);
|
|
3888
|
+
console.log(
|
|
3889
|
+
`[APPOINTMENT_SERVICE] Found ${availableProcedureIds.size} procedures available at clinic ${options.clinicBranchId}`
|
|
3890
|
+
);
|
|
3891
|
+
}
|
|
3892
|
+
for (let index = 0; index < recommendedProcedures.length; index++) {
|
|
3893
|
+
const recommendedProcedure = recommendedProcedures[index];
|
|
3894
|
+
const procedureId = recommendedProcedure.procedure.procedureId;
|
|
3895
|
+
if ((options == null ? void 0 : options.clinicBranchId) && availableProcedureIds) {
|
|
3896
|
+
if (!availableProcedureIds.has(procedureId)) {
|
|
3897
|
+
console.log(
|
|
3898
|
+
`[APPOINTMENT_SERVICE] Skipping recommendation for procedure ${procedureId} - not available at clinic ${options.clinicBranchId}`
|
|
3899
|
+
);
|
|
3900
|
+
continue;
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
const recommendationId = `${appointment.id}:${index}`;
|
|
3904
|
+
const nextStepsRecommendation = {
|
|
3905
|
+
id: recommendationId,
|
|
3906
|
+
recommendedProcedure,
|
|
3907
|
+
appointmentId: appointment.id,
|
|
3908
|
+
appointmentDate: appointment.appointmentStartTime,
|
|
3909
|
+
practitionerId: appointment.practitionerId,
|
|
3910
|
+
practitionerName: ((_b = appointment.practitionerInfo) == null ? void 0 : _b.name) || "Unknown Practitioner",
|
|
3911
|
+
clinicBranchId: appointment.clinicBranchId,
|
|
3912
|
+
clinicName: ((_c = appointment.clinicInfo) == null ? void 0 : _c.name) || "Unknown Clinic",
|
|
3913
|
+
appointmentStatus: appointment.status,
|
|
3914
|
+
isDismissed: false,
|
|
3915
|
+
// Clinic view doesn't track dismissals
|
|
3916
|
+
dismissedAt: null
|
|
3917
|
+
};
|
|
3918
|
+
recommendations.push(nextStepsRecommendation);
|
|
3919
|
+
}
|
|
3920
|
+
console.log(
|
|
3921
|
+
`[APPOINTMENT_SERVICE] Found ${recommendations.length} next steps recommendations for appointment ${appointmentId}`,
|
|
3922
|
+
(options == null ? void 0 : options.clinicBranchId) ? `(filtered to procedures available at clinic ${options.clinicBranchId})` : ""
|
|
3923
|
+
);
|
|
3924
|
+
return recommendations;
|
|
3925
|
+
} catch (error) {
|
|
3926
|
+
console.error(
|
|
3927
|
+
`[APPOINTMENT_SERVICE] Error getting next steps recommendations for appointment ${appointmentId}:`,
|
|
3928
|
+
error
|
|
3929
|
+
);
|
|
3930
|
+
throw error;
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3638
3933
|
};
|
|
3639
3934
|
|
|
3640
3935
|
// src/services/auth/auth.service.ts
|
|
@@ -4136,8 +4431,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
|
|
|
4136
4431
|
}
|
|
4137
4432
|
const patientsSnapshot = await (0, import_firestore12.getDocs)(q);
|
|
4138
4433
|
const patients = [];
|
|
4139
|
-
patientsSnapshot.forEach((
|
|
4140
|
-
patients.push(
|
|
4434
|
+
patientsSnapshot.forEach((doc45) => {
|
|
4435
|
+
patients.push(doc45.data());
|
|
4141
4436
|
});
|
|
4142
4437
|
console.log(
|
|
4143
4438
|
`[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
|
|
@@ -4380,6 +4675,7 @@ var patientProfileSchema = import_zod7.z.object({
|
|
|
4380
4675
|
clinics: import_zod7.z.array(patientClinicSchema),
|
|
4381
4676
|
doctorIds: import_zod7.z.array(import_zod7.z.string()),
|
|
4382
4677
|
clinicIds: import_zod7.z.array(import_zod7.z.string()),
|
|
4678
|
+
dismissedNextStepsRecommendations: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
4383
4679
|
createdAt: import_zod7.z.instanceof(import_firestore14.Timestamp),
|
|
4384
4680
|
updatedAt: import_zod7.z.instanceof(import_firestore14.Timestamp)
|
|
4385
4681
|
});
|
|
@@ -4478,8 +4774,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
|
|
|
4478
4774
|
}
|
|
4479
4775
|
const patientsSnapshot = await (0, import_firestore15.getDocs)(q);
|
|
4480
4776
|
const patients = [];
|
|
4481
|
-
patientsSnapshot.forEach((
|
|
4482
|
-
patients.push(
|
|
4777
|
+
patientsSnapshot.forEach((doc45) => {
|
|
4778
|
+
patients.push(doc45.data());
|
|
4483
4779
|
});
|
|
4484
4780
|
console.log(
|
|
4485
4781
|
`[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
|
|
@@ -4696,7 +4992,6 @@ var reviewSchema = import_zod8.z.object({
|
|
|
4696
4992
|
clinicReview: clinicReviewSchema.optional(),
|
|
4697
4993
|
practitionerReview: practitionerReviewSchema.optional(),
|
|
4698
4994
|
procedureReview: procedureReviewSchema.optional(),
|
|
4699
|
-
extendedProcedureReviews: import_zod8.z.array(procedureReviewSchema).optional(),
|
|
4700
4995
|
overallComment: import_zod8.z.string().min(1).max(2e3),
|
|
4701
4996
|
overallRating: import_zod8.z.number().min(1).max(5)
|
|
4702
4997
|
});
|
|
@@ -4705,14 +5000,13 @@ var createReviewSchema = import_zod8.z.object({
|
|
|
4705
5000
|
clinicReview: createClinicReviewSchema.optional(),
|
|
4706
5001
|
practitionerReview: createPractitionerReviewSchema.optional(),
|
|
4707
5002
|
procedureReview: createProcedureReviewSchema.optional(),
|
|
4708
|
-
extendedProcedureReviews: import_zod8.z.array(createProcedureReviewSchema).optional(),
|
|
4709
5003
|
overallComment: import_zod8.z.string().min(1).max(2e3)
|
|
4710
5004
|
}).refine(
|
|
4711
5005
|
(data) => {
|
|
4712
|
-
return data.clinicReview || data.practitionerReview || data.procedureReview
|
|
5006
|
+
return data.clinicReview || data.practitionerReview || data.procedureReview;
|
|
4713
5007
|
},
|
|
4714
5008
|
{
|
|
4715
|
-
message: "At least one review type (clinic, practitioner,
|
|
5009
|
+
message: "At least one review type (clinic, practitioner, or procedure) must be provided",
|
|
4716
5010
|
path: ["reviewType"]
|
|
4717
5011
|
}
|
|
4718
5012
|
);
|
|
@@ -5294,7 +5588,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
5294
5588
|
(0, import_firestore17.where)("clinicGroupId", "==", clinicGroupId)
|
|
5295
5589
|
);
|
|
5296
5590
|
const querySnapshot = await (0, import_firestore17.getDocs)(q);
|
|
5297
|
-
return querySnapshot.docs.map((
|
|
5591
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
5298
5592
|
}
|
|
5299
5593
|
async function updateClinicAdmin(db, adminId, data) {
|
|
5300
5594
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -5973,9 +6267,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
5973
6267
|
};
|
|
5974
6268
|
var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
|
|
5975
6269
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5976
|
-
const
|
|
5977
|
-
if (!
|
|
5978
|
-
const medicalInfo =
|
|
6270
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6271
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6272
|
+
const medicalInfo = doc45.data();
|
|
5979
6273
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
5980
6274
|
throw new Error("Invalid allergy index");
|
|
5981
6275
|
}
|
|
@@ -6002,9 +6296,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
6002
6296
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
6003
6297
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
6004
6298
|
const { conditionIndex, ...updateData } = validatedData;
|
|
6005
|
-
const
|
|
6006
|
-
if (!
|
|
6007
|
-
const medicalInfo =
|
|
6299
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6300
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6301
|
+
const medicalInfo = doc45.data();
|
|
6008
6302
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
6009
6303
|
throw new Error("Invalid blocking condition index");
|
|
6010
6304
|
}
|
|
@@ -6021,9 +6315,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
6021
6315
|
};
|
|
6022
6316
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
|
|
6023
6317
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
6024
|
-
const
|
|
6025
|
-
if (!
|
|
6026
|
-
const medicalInfo =
|
|
6318
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6319
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6320
|
+
const medicalInfo = doc45.data();
|
|
6027
6321
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
6028
6322
|
throw new Error("Invalid blocking condition index");
|
|
6029
6323
|
}
|
|
@@ -6050,9 +6344,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
6050
6344
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
6051
6345
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
6052
6346
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
6053
|
-
const
|
|
6054
|
-
if (!
|
|
6055
|
-
const medicalInfo =
|
|
6347
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6348
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6349
|
+
const medicalInfo = doc45.data();
|
|
6056
6350
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
6057
6351
|
throw new Error("Invalid contraindication index");
|
|
6058
6352
|
}
|
|
@@ -6069,9 +6363,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
6069
6363
|
};
|
|
6070
6364
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
|
|
6071
6365
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
6072
|
-
const
|
|
6073
|
-
if (!
|
|
6074
|
-
const medicalInfo =
|
|
6366
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6367
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6368
|
+
const medicalInfo = doc45.data();
|
|
6075
6369
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
6076
6370
|
throw new Error("Invalid contraindication index");
|
|
6077
6371
|
}
|
|
@@ -6098,9 +6392,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
6098
6392
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
6099
6393
|
const validatedData = updateMedicationSchema.parse(data);
|
|
6100
6394
|
const { medicationIndex, ...updateData } = validatedData;
|
|
6101
|
-
const
|
|
6102
|
-
if (!
|
|
6103
|
-
const medicalInfo =
|
|
6395
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6396
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6397
|
+
const medicalInfo = doc45.data();
|
|
6104
6398
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
6105
6399
|
throw new Error("Invalid medication index");
|
|
6106
6400
|
}
|
|
@@ -6117,9 +6411,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
6117
6411
|
};
|
|
6118
6412
|
var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
|
|
6119
6413
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
6120
|
-
const
|
|
6121
|
-
if (!
|
|
6122
|
-
const medicalInfo =
|
|
6414
|
+
const doc45 = await (0, import_firestore22.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
6415
|
+
if (!doc45.exists()) throw new Error("Medical info not found");
|
|
6416
|
+
const medicalInfo = doc45.data();
|
|
6123
6417
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
6124
6418
|
throw new Error("Invalid medication index");
|
|
6125
6419
|
}
|
|
@@ -6406,7 +6700,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
6406
6700
|
const finalQuery = (0, import_firestore23.query)(patientsCollectionRef, ...constraints);
|
|
6407
6701
|
const querySnapshot = await (0, import_firestore23.getDocs)(finalQuery);
|
|
6408
6702
|
const patients = querySnapshot.docs.map(
|
|
6409
|
-
(
|
|
6703
|
+
(doc45) => doc45.data()
|
|
6410
6704
|
);
|
|
6411
6705
|
console.log(
|
|
6412
6706
|
`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
|
|
@@ -6438,8 +6732,8 @@ var getAllPatientsUtil = async (db, options) => {
|
|
|
6438
6732
|
}
|
|
6439
6733
|
const patientsSnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6440
6734
|
const patients = [];
|
|
6441
|
-
patientsSnapshot.forEach((
|
|
6442
|
-
patients.push(
|
|
6735
|
+
patientsSnapshot.forEach((doc45) => {
|
|
6736
|
+
patients.push(doc45.data());
|
|
6443
6737
|
});
|
|
6444
6738
|
console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
|
|
6445
6739
|
return patients;
|
|
@@ -6561,7 +6855,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
|
|
|
6561
6855
|
if (querySnapshot.empty) {
|
|
6562
6856
|
return [];
|
|
6563
6857
|
}
|
|
6564
|
-
return querySnapshot.docs.map((
|
|
6858
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
6565
6859
|
};
|
|
6566
6860
|
var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
6567
6861
|
const tokensRef = (0, import_firestore24.collection)(
|
|
@@ -6579,7 +6873,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
|
6579
6873
|
if (querySnapshot.empty) {
|
|
6580
6874
|
return [];
|
|
6581
6875
|
}
|
|
6582
|
-
return querySnapshot.docs.map((
|
|
6876
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
6583
6877
|
};
|
|
6584
6878
|
|
|
6585
6879
|
// src/services/patient/utils/aesthetic-analysis.utils.ts
|
|
@@ -7948,7 +8242,7 @@ var PractitionerService = class extends BaseService {
|
|
|
7948
8242
|
(0, import_firestore29.where)("expiresAt", ">", import_firestore29.Timestamp.now())
|
|
7949
8243
|
);
|
|
7950
8244
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
7951
|
-
return querySnapshot.docs.map((
|
|
8245
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
7952
8246
|
}
|
|
7953
8247
|
/**
|
|
7954
8248
|
* Gets a token by its string value and validates it
|
|
@@ -8058,7 +8352,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8058
8352
|
(0, import_firestore29.where)("status", "==", "active" /* ACTIVE */)
|
|
8059
8353
|
);
|
|
8060
8354
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8061
|
-
return querySnapshot.docs.map((
|
|
8355
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
8062
8356
|
}
|
|
8063
8357
|
/**
|
|
8064
8358
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -8070,7 +8364,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8070
8364
|
(0, import_firestore29.where)("isActive", "==", true)
|
|
8071
8365
|
);
|
|
8072
8366
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8073
|
-
return querySnapshot.docs.map((
|
|
8367
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
8074
8368
|
}
|
|
8075
8369
|
/**
|
|
8076
8370
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -8082,7 +8376,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8082
8376
|
(0, import_firestore29.where)("status", "==", "draft" /* DRAFT */)
|
|
8083
8377
|
);
|
|
8084
8378
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8085
|
-
return querySnapshot.docs.map((
|
|
8379
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
8086
8380
|
}
|
|
8087
8381
|
/**
|
|
8088
8382
|
* Updates a practitioner
|
|
@@ -8299,7 +8593,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8299
8593
|
);
|
|
8300
8594
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8301
8595
|
const practitioners = querySnapshot.docs.map(
|
|
8302
|
-
(
|
|
8596
|
+
(doc45) => doc45.data()
|
|
8303
8597
|
);
|
|
8304
8598
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
8305
8599
|
return {
|
|
@@ -8384,7 +8678,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8384
8678
|
);
|
|
8385
8679
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8386
8680
|
const practitioners = querySnapshot.docs.map(
|
|
8387
|
-
(
|
|
8681
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
8388
8682
|
);
|
|
8389
8683
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
8390
8684
|
console.log(
|
|
@@ -8448,7 +8742,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8448
8742
|
);
|
|
8449
8743
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8450
8744
|
let practitioners = querySnapshot.docs.map(
|
|
8451
|
-
(
|
|
8745
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
8452
8746
|
);
|
|
8453
8747
|
if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
|
|
8454
8748
|
const location = filters.location;
|
|
@@ -8493,7 +8787,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8493
8787
|
);
|
|
8494
8788
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8495
8789
|
let practitioners = querySnapshot.docs.map(
|
|
8496
|
-
(
|
|
8790
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
8497
8791
|
);
|
|
8498
8792
|
practitioners = this.applyInMemoryFilters(practitioners, filters);
|
|
8499
8793
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -8523,7 +8817,7 @@ var PractitionerService = class extends BaseService {
|
|
|
8523
8817
|
);
|
|
8524
8818
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
8525
8819
|
let practitioners = querySnapshot.docs.map(
|
|
8526
|
-
(
|
|
8820
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
8527
8821
|
);
|
|
8528
8822
|
practitioners = this.applyInMemoryFilters(practitioners, filters);
|
|
8529
8823
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -9070,7 +9364,7 @@ var UserService = class extends BaseService {
|
|
|
9070
9364
|
const constraints = [(0, import_firestore30.where)("roles", "array-contains", role)];
|
|
9071
9365
|
const q = (0, import_firestore30.query)((0, import_firestore30.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
9072
9366
|
const querySnapshot = await (0, import_firestore30.getDocs)(q);
|
|
9073
|
-
const users = querySnapshot.docs.map((
|
|
9367
|
+
const users = querySnapshot.docs.map((doc45) => doc45.data());
|
|
9074
9368
|
return users.map((userData) => userSchema.parse(userData));
|
|
9075
9369
|
}
|
|
9076
9370
|
/**
|
|
@@ -9228,9 +9522,9 @@ var BillingTransactionsService = class extends BaseService {
|
|
|
9228
9522
|
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
9229
9523
|
const docs = querySnapshot.docs;
|
|
9230
9524
|
const hasMore = docs.length > queryLimit;
|
|
9231
|
-
const transactions = docs.slice(0, queryLimit).map((
|
|
9232
|
-
id:
|
|
9233
|
-
...
|
|
9525
|
+
const transactions = docs.slice(0, queryLimit).map((doc45) => ({
|
|
9526
|
+
id: doc45.id,
|
|
9527
|
+
...doc45.data()
|
|
9234
9528
|
}));
|
|
9235
9529
|
const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
|
|
9236
9530
|
return {
|
|
@@ -9306,9 +9600,9 @@ var BillingTransactionsService = class extends BaseService {
|
|
|
9306
9600
|
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
9307
9601
|
const docs = querySnapshot.docs;
|
|
9308
9602
|
const hasMore = docs.length > queryLimit;
|
|
9309
|
-
const transactions = docs.slice(0, queryLimit).map((
|
|
9310
|
-
id:
|
|
9311
|
-
...
|
|
9603
|
+
const transactions = docs.slice(0, queryLimit).map((doc45) => ({
|
|
9604
|
+
id: doc45.id,
|
|
9605
|
+
...doc45.data()
|
|
9312
9606
|
}));
|
|
9313
9607
|
const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
|
|
9314
9608
|
return {
|
|
@@ -9557,7 +9851,7 @@ async function getAllActiveGroups(db) {
|
|
|
9557
9851
|
(0, import_firestore32.where)("isActive", "==", true)
|
|
9558
9852
|
);
|
|
9559
9853
|
const querySnapshot = await (0, import_firestore32.getDocs)(q);
|
|
9560
|
-
return querySnapshot.docs.map((
|
|
9854
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
9561
9855
|
}
|
|
9562
9856
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
9563
9857
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -9993,7 +10287,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
9993
10287
|
(0, import_firestore33.where)("isActive", "==", true)
|
|
9994
10288
|
);
|
|
9995
10289
|
const querySnapshot = await (0, import_firestore33.getDocs)(q);
|
|
9996
|
-
return querySnapshot.docs.map((
|
|
10290
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
9997
10291
|
}
|
|
9998
10292
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
9999
10293
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -10187,7 +10481,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
10187
10481
|
}
|
|
10188
10482
|
const q = (0, import_firestore33.query)((0, import_firestore33.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10189
10483
|
const querySnapshot = await (0, import_firestore33.getDocs)(q);
|
|
10190
|
-
return querySnapshot.docs.map((
|
|
10484
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
10191
10485
|
}
|
|
10192
10486
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
10193
10487
|
return getClinicsByAdmin(
|
|
@@ -10232,11 +10526,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
10232
10526
|
}
|
|
10233
10527
|
const clinicsSnapshot = await (0, import_firestore33.getDocs)(clinicsQuery);
|
|
10234
10528
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
10235
|
-
const clinics = clinicsSnapshot.docs.map((
|
|
10236
|
-
const data =
|
|
10529
|
+
const clinics = clinicsSnapshot.docs.map((doc45) => {
|
|
10530
|
+
const data = doc45.data();
|
|
10237
10531
|
return {
|
|
10238
10532
|
...data,
|
|
10239
|
-
id:
|
|
10533
|
+
id: doc45.id
|
|
10240
10534
|
};
|
|
10241
10535
|
});
|
|
10242
10536
|
return {
|
|
@@ -10263,8 +10557,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
10263
10557
|
];
|
|
10264
10558
|
const q = (0, import_firestore33.query)((0, import_firestore33.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10265
10559
|
const querySnapshot = await (0, import_firestore33.getDocs)(q);
|
|
10266
|
-
for (const
|
|
10267
|
-
const clinic =
|
|
10560
|
+
for (const doc45 of querySnapshot.docs) {
|
|
10561
|
+
const clinic = doc45.data();
|
|
10268
10562
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
10269
10563
|
[center.latitude, center.longitude],
|
|
10270
10564
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -10381,8 +10675,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
10381
10675
|
}
|
|
10382
10676
|
const q = (0, import_firestore34.query)((0, import_firestore34.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10383
10677
|
const querySnapshot = await (0, import_firestore34.getDocs)(q);
|
|
10384
|
-
for (const
|
|
10385
|
-
const clinic =
|
|
10678
|
+
for (const doc45 of querySnapshot.docs) {
|
|
10679
|
+
const clinic = doc45.data();
|
|
10386
10680
|
const distance = (0, import_geofire_common5.distanceBetween)(
|
|
10387
10681
|
[center.latitude, center.longitude],
|
|
10388
10682
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -10503,7 +10797,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
10503
10797
|
constraints.push((0, import_firestore35.limit)(filters.pagination || 5));
|
|
10504
10798
|
const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10505
10799
|
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
10506
|
-
let clinics = querySnapshot.docs.map((
|
|
10800
|
+
let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
|
|
10507
10801
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
10508
10802
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
10509
10803
|
console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
|
|
@@ -10535,7 +10829,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
10535
10829
|
constraints.push((0, import_firestore35.limit)(filters.pagination || 5));
|
|
10536
10830
|
const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10537
10831
|
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
10538
|
-
let clinics = querySnapshot.docs.map((
|
|
10832
|
+
let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
|
|
10539
10833
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
10540
10834
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
10541
10835
|
console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
|
|
@@ -10565,7 +10859,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
10565
10859
|
constraints.push((0, import_firestore35.limit)(filters.pagination || 5));
|
|
10566
10860
|
const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10567
10861
|
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
10568
|
-
let clinics = querySnapshot.docs.map((
|
|
10862
|
+
let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
|
|
10569
10863
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
10570
10864
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
10571
10865
|
console.log(`[CLINIC_SERVICE] Strategy 3 success: ${clinics.length} clinics`);
|
|
@@ -10585,7 +10879,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
10585
10879
|
];
|
|
10586
10880
|
const q = (0, import_firestore35.query)((0, import_firestore35.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
10587
10881
|
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
10588
|
-
let clinics = querySnapshot.docs.map((
|
|
10882
|
+
let clinics = querySnapshot.docs.map((doc45) => ({ ...doc45.data(), id: doc45.id }));
|
|
10589
10883
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
10590
10884
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
10591
10885
|
console.log(`[CLINIC_SERVICE] Strategy 4 success: ${clinics.length} clinics`);
|
|
@@ -11157,11 +11451,11 @@ var ClinicService = class extends BaseService {
|
|
|
11157
11451
|
async getClinicsForMap() {
|
|
11158
11452
|
const clinicsRef = (0, import_firestore36.collection)(this.db, CLINICS_COLLECTION);
|
|
11159
11453
|
const snapshot = await (0, import_firestore36.getDocs)(clinicsRef);
|
|
11160
|
-
const clinicsForMap = snapshot.docs.map((
|
|
11454
|
+
const clinicsForMap = snapshot.docs.map((doc45) => {
|
|
11161
11455
|
var _a, _b, _c;
|
|
11162
|
-
const data =
|
|
11456
|
+
const data = doc45.data();
|
|
11163
11457
|
return {
|
|
11164
|
-
id:
|
|
11458
|
+
id: doc45.id,
|
|
11165
11459
|
name: data.name,
|
|
11166
11460
|
address: ((_a = data.location) == null ? void 0 : _a.address) || "",
|
|
11167
11461
|
latitude: (_b = data.location) == null ? void 0 : _b.latitude,
|
|
@@ -12289,7 +12583,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
12289
12583
|
const finalQuery = (0, import_firestore42.query)(collectionRef, ...constraints);
|
|
12290
12584
|
const querySnapshot = await (0, import_firestore42.getDocs)(finalQuery);
|
|
12291
12585
|
const events = querySnapshot.docs.map(
|
|
12292
|
-
(
|
|
12586
|
+
(doc45) => ({ id: doc45.id, ...doc45.data() })
|
|
12293
12587
|
);
|
|
12294
12588
|
return events;
|
|
12295
12589
|
} catch (error) {
|
|
@@ -12371,7 +12665,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
12371
12665
|
);
|
|
12372
12666
|
const q = (0, import_firestore43.query)(calendarsRef, (0, import_firestore43.orderBy)("createdAt", "desc"));
|
|
12373
12667
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
12374
|
-
return querySnapshot.docs.map((
|
|
12668
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
12375
12669
|
}
|
|
12376
12670
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
12377
12671
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -12388,7 +12682,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
12388
12682
|
);
|
|
12389
12683
|
const q = (0, import_firestore43.query)(calendarsRef, (0, import_firestore43.orderBy)("createdAt", "desc"));
|
|
12390
12684
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
12391
|
-
return querySnapshot.docs.map((
|
|
12685
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
12392
12686
|
}
|
|
12393
12687
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
12394
12688
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -12405,7 +12699,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
12405
12699
|
);
|
|
12406
12700
|
const q = (0, import_firestore43.query)(calendarsRef, (0, import_firestore43.orderBy)("createdAt", "desc"));
|
|
12407
12701
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
12408
|
-
return querySnapshot.docs.map((
|
|
12702
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
12409
12703
|
}
|
|
12410
12704
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
12411
12705
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -13760,9 +14054,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13760
14054
|
(0, import_firestore46.where)("eventTime.start", "<=", import_firestore45.Timestamp.fromDate(endDate))
|
|
13761
14055
|
);
|
|
13762
14056
|
const eventsSnapshot = await (0, import_firestore46.getDocs)(q);
|
|
13763
|
-
const events = eventsSnapshot.docs.map((
|
|
13764
|
-
id:
|
|
13765
|
-
...
|
|
14057
|
+
const events = eventsSnapshot.docs.map((doc45) => ({
|
|
14058
|
+
id: doc45.id,
|
|
14059
|
+
...doc45.data()
|
|
13766
14060
|
}));
|
|
13767
14061
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
13768
14062
|
doctorId
|
|
@@ -14396,7 +14690,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
14396
14690
|
])
|
|
14397
14691
|
);
|
|
14398
14692
|
const querySnapshot = await (0, import_firestore46.getDocs)(q);
|
|
14399
|
-
return querySnapshot.docs.map((
|
|
14693
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
14400
14694
|
}
|
|
14401
14695
|
/**
|
|
14402
14696
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -14927,7 +15221,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
14927
15221
|
...constraints
|
|
14928
15222
|
);
|
|
14929
15223
|
const querySnapshot = await (0, import_firestore49.getDocs)(q);
|
|
14930
|
-
return querySnapshot.docs.map((
|
|
15224
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
14931
15225
|
} catch (error) {
|
|
14932
15226
|
console.error(
|
|
14933
15227
|
"[PractitionerInviteService] Error getting doctor invites:",
|
|
@@ -14956,7 +15250,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
14956
15250
|
...constraints
|
|
14957
15251
|
);
|
|
14958
15252
|
const querySnapshot = await (0, import_firestore49.getDocs)(q);
|
|
14959
|
-
return querySnapshot.docs.map((
|
|
15253
|
+
return querySnapshot.docs.map((doc45) => doc45.data());
|
|
14960
15254
|
} catch (error) {
|
|
14961
15255
|
console.error(
|
|
14962
15256
|
"[PractitionerInviteService] Error getting clinic invites:",
|
|
@@ -15112,7 +15406,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
15112
15406
|
);
|
|
15113
15407
|
const querySnapshot = await (0, import_firestore49.getDocs)(q);
|
|
15114
15408
|
let invites = querySnapshot.docs.map(
|
|
15115
|
-
(
|
|
15409
|
+
(doc45) => doc45.data()
|
|
15116
15410
|
);
|
|
15117
15411
|
if (filters.fromDate) {
|
|
15118
15412
|
invites = invites.filter(
|
|
@@ -15370,8 +15664,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15370
15664
|
const q = (0, import_firestore50.query)(versionsCollectionRef, (0, import_firestore50.orderBy)("version", "desc"));
|
|
15371
15665
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15372
15666
|
const versions = [];
|
|
15373
|
-
querySnapshot.forEach((
|
|
15374
|
-
versions.push(
|
|
15667
|
+
querySnapshot.forEach((doc45) => {
|
|
15668
|
+
versions.push(doc45.data());
|
|
15375
15669
|
});
|
|
15376
15670
|
return versions;
|
|
15377
15671
|
}
|
|
@@ -15402,9 +15696,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15402
15696
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15403
15697
|
const templates = [];
|
|
15404
15698
|
let lastVisible = null;
|
|
15405
|
-
querySnapshot.forEach((
|
|
15406
|
-
templates.push(
|
|
15407
|
-
lastVisible =
|
|
15699
|
+
querySnapshot.forEach((doc45) => {
|
|
15700
|
+
templates.push(doc45.data());
|
|
15701
|
+
lastVisible = doc45;
|
|
15408
15702
|
});
|
|
15409
15703
|
return {
|
|
15410
15704
|
templates,
|
|
@@ -15446,9 +15740,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15446
15740
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15447
15741
|
const templates = [];
|
|
15448
15742
|
let lastVisible = null;
|
|
15449
|
-
querySnapshot.forEach((
|
|
15450
|
-
templates.push(
|
|
15451
|
-
lastVisible =
|
|
15743
|
+
querySnapshot.forEach((doc45) => {
|
|
15744
|
+
templates.push(doc45.data());
|
|
15745
|
+
lastVisible = doc45;
|
|
15452
15746
|
});
|
|
15453
15747
|
return {
|
|
15454
15748
|
templates,
|
|
@@ -15488,8 +15782,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15488
15782
|
);
|
|
15489
15783
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15490
15784
|
const templates = [];
|
|
15491
|
-
querySnapshot.forEach((
|
|
15492
|
-
templates.push(
|
|
15785
|
+
querySnapshot.forEach((doc45) => {
|
|
15786
|
+
templates.push(doc45.data());
|
|
15493
15787
|
});
|
|
15494
15788
|
return templates;
|
|
15495
15789
|
}
|
|
@@ -15514,9 +15808,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15514
15808
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15515
15809
|
const templates = [];
|
|
15516
15810
|
let lastVisible = null;
|
|
15517
|
-
querySnapshot.forEach((
|
|
15518
|
-
templates.push(
|
|
15519
|
-
lastVisible =
|
|
15811
|
+
querySnapshot.forEach((doc45) => {
|
|
15812
|
+
templates.push(doc45.data());
|
|
15813
|
+
lastVisible = doc45;
|
|
15520
15814
|
});
|
|
15521
15815
|
return {
|
|
15522
15816
|
templates,
|
|
@@ -15543,9 +15837,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15543
15837
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15544
15838
|
const templates = [];
|
|
15545
15839
|
let lastVisible = null;
|
|
15546
|
-
querySnapshot.forEach((
|
|
15547
|
-
templates.push(
|
|
15548
|
-
lastVisible =
|
|
15840
|
+
querySnapshot.forEach((doc45) => {
|
|
15841
|
+
templates.push(doc45.data());
|
|
15842
|
+
lastVisible = doc45;
|
|
15549
15843
|
});
|
|
15550
15844
|
return {
|
|
15551
15845
|
templates,
|
|
@@ -15571,8 +15865,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
15571
15865
|
}
|
|
15572
15866
|
const querySnapshot = await (0, import_firestore50.getDocs)(q);
|
|
15573
15867
|
const templates = [];
|
|
15574
|
-
querySnapshot.forEach((
|
|
15575
|
-
templates.push(
|
|
15868
|
+
querySnapshot.forEach((doc45) => {
|
|
15869
|
+
templates.push(doc45.data());
|
|
15576
15870
|
});
|
|
15577
15871
|
return templates;
|
|
15578
15872
|
}
|
|
@@ -15767,9 +16061,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
15767
16061
|
const querySnapshot = await (0, import_firestore52.getDocs)(q);
|
|
15768
16062
|
const documents = [];
|
|
15769
16063
|
let lastVisible = null;
|
|
15770
|
-
querySnapshot.forEach((
|
|
15771
|
-
documents.push(
|
|
15772
|
-
lastVisible =
|
|
16064
|
+
querySnapshot.forEach((doc45) => {
|
|
16065
|
+
documents.push(doc45.data());
|
|
16066
|
+
lastVisible = doc45;
|
|
15773
16067
|
});
|
|
15774
16068
|
return {
|
|
15775
16069
|
documents,
|
|
@@ -15978,9 +16272,9 @@ var NotificationService = class extends BaseService {
|
|
|
15978
16272
|
(0, import_firestore53.orderBy)("notificationTime", "desc")
|
|
15979
16273
|
);
|
|
15980
16274
|
const querySnapshot = await (0, import_firestore53.getDocs)(q);
|
|
15981
|
-
return querySnapshot.docs.map((
|
|
15982
|
-
id:
|
|
15983
|
-
...
|
|
16275
|
+
return querySnapshot.docs.map((doc45) => ({
|
|
16276
|
+
id: doc45.id,
|
|
16277
|
+
...doc45.data()
|
|
15984
16278
|
}));
|
|
15985
16279
|
}
|
|
15986
16280
|
/**
|
|
@@ -15994,9 +16288,9 @@ var NotificationService = class extends BaseService {
|
|
|
15994
16288
|
(0, import_firestore53.orderBy)("notificationTime", "desc")
|
|
15995
16289
|
);
|
|
15996
16290
|
const querySnapshot = await (0, import_firestore53.getDocs)(q);
|
|
15997
|
-
return querySnapshot.docs.map((
|
|
15998
|
-
id:
|
|
15999
|
-
...
|
|
16291
|
+
return querySnapshot.docs.map((doc45) => ({
|
|
16292
|
+
id: doc45.id,
|
|
16293
|
+
...doc45.data()
|
|
16000
16294
|
}));
|
|
16001
16295
|
}
|
|
16002
16296
|
/**
|
|
@@ -16068,9 +16362,9 @@ var NotificationService = class extends BaseService {
|
|
|
16068
16362
|
(0, import_firestore53.orderBy)("notificationTime", "desc")
|
|
16069
16363
|
);
|
|
16070
16364
|
const querySnapshot = await (0, import_firestore53.getDocs)(q);
|
|
16071
|
-
return querySnapshot.docs.map((
|
|
16072
|
-
id:
|
|
16073
|
-
...
|
|
16365
|
+
return querySnapshot.docs.map((doc45) => ({
|
|
16366
|
+
id: doc45.id,
|
|
16367
|
+
...doc45.data()
|
|
16074
16368
|
}));
|
|
16075
16369
|
}
|
|
16076
16370
|
/**
|
|
@@ -16083,9 +16377,9 @@ var NotificationService = class extends BaseService {
|
|
|
16083
16377
|
(0, import_firestore53.orderBy)("notificationTime", "desc")
|
|
16084
16378
|
);
|
|
16085
16379
|
const querySnapshot = await (0, import_firestore53.getDocs)(q);
|
|
16086
|
-
return querySnapshot.docs.map((
|
|
16087
|
-
id:
|
|
16088
|
-
...
|
|
16380
|
+
return querySnapshot.docs.map((doc45) => ({
|
|
16381
|
+
id: doc45.id,
|
|
16382
|
+
...doc45.data()
|
|
16089
16383
|
}));
|
|
16090
16384
|
}
|
|
16091
16385
|
};
|
|
@@ -16696,8 +16990,8 @@ var ProcedureService = class extends BaseService {
|
|
|
16696
16990
|
(0, import_firestore55.where)((0, import_firestore55.documentId)(), "in", chunk)
|
|
16697
16991
|
);
|
|
16698
16992
|
const practitionersSnapshot = await (0, import_firestore55.getDocs)(practitionersQuery);
|
|
16699
|
-
practitionersSnapshot.docs.forEach((
|
|
16700
|
-
practitionersMap.set(
|
|
16993
|
+
practitionersSnapshot.docs.forEach((doc45) => {
|
|
16994
|
+
practitionersMap.set(doc45.id, doc45.data());
|
|
16701
16995
|
});
|
|
16702
16996
|
}
|
|
16703
16997
|
if (practitionersMap.size !== practitionerIds.length) {
|
|
@@ -16792,8 +17086,8 @@ var ProcedureService = class extends BaseService {
|
|
|
16792
17086
|
const chunk = createdProcedureIds.slice(i, i + 30);
|
|
16793
17087
|
const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), (0, import_firestore55.where)((0, import_firestore55.documentId)(), "in", chunk));
|
|
16794
17088
|
const snapshot = await (0, import_firestore55.getDocs)(q);
|
|
16795
|
-
snapshot.forEach((
|
|
16796
|
-
fetchedProcedures.push(
|
|
17089
|
+
snapshot.forEach((doc45) => {
|
|
17090
|
+
fetchedProcedures.push(doc45.data());
|
|
16797
17091
|
});
|
|
16798
17092
|
}
|
|
16799
17093
|
return fetchedProcedures;
|
|
@@ -16823,7 +17117,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16823
17117
|
(0, import_firestore55.where)("isActive", "==", true)
|
|
16824
17118
|
);
|
|
16825
17119
|
const snapshot = await (0, import_firestore55.getDocs)(q);
|
|
16826
|
-
return snapshot.docs.map((
|
|
17120
|
+
return snapshot.docs.map((doc45) => doc45.data());
|
|
16827
17121
|
}
|
|
16828
17122
|
/**
|
|
16829
17123
|
* Gets all procedures for a practitioner
|
|
@@ -16837,7 +17131,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16837
17131
|
(0, import_firestore55.where)("isActive", "==", true)
|
|
16838
17132
|
);
|
|
16839
17133
|
const snapshot = await (0, import_firestore55.getDocs)(q);
|
|
16840
|
-
return snapshot.docs.map((
|
|
17134
|
+
return snapshot.docs.map((doc45) => doc45.data());
|
|
16841
17135
|
}
|
|
16842
17136
|
/**
|
|
16843
17137
|
* Gets all inactive procedures for a practitioner
|
|
@@ -16851,7 +17145,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16851
17145
|
(0, import_firestore55.where)("isActive", "==", false)
|
|
16852
17146
|
);
|
|
16853
17147
|
const snapshot = await (0, import_firestore55.getDocs)(q);
|
|
16854
|
-
return snapshot.docs.map((
|
|
17148
|
+
return snapshot.docs.map((doc45) => doc45.data());
|
|
16855
17149
|
}
|
|
16856
17150
|
/**
|
|
16857
17151
|
* Updates a procedure
|
|
@@ -17070,11 +17364,11 @@ var ProcedureService = class extends BaseService {
|
|
|
17070
17364
|
}
|
|
17071
17365
|
const proceduresSnapshot = await (0, import_firestore55.getDocs)(proceduresQuery);
|
|
17072
17366
|
const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
|
|
17073
|
-
const procedures = proceduresSnapshot.docs.map((
|
|
17074
|
-
const data =
|
|
17367
|
+
const procedures = proceduresSnapshot.docs.map((doc45) => {
|
|
17368
|
+
const data = doc45.data();
|
|
17075
17369
|
return {
|
|
17076
17370
|
...data,
|
|
17077
|
-
id:
|
|
17371
|
+
id: doc45.id
|
|
17078
17372
|
// Ensure ID is present
|
|
17079
17373
|
};
|
|
17080
17374
|
});
|
|
@@ -17193,7 +17487,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17193
17487
|
const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
17194
17488
|
const querySnapshot = await (0, import_firestore55.getDocs)(q);
|
|
17195
17489
|
const procedures = querySnapshot.docs.map(
|
|
17196
|
-
(
|
|
17490
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
17197
17491
|
);
|
|
17198
17492
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
17199
17493
|
console.log(`[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`);
|
|
@@ -17226,7 +17520,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17226
17520
|
const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
17227
17521
|
const querySnapshot = await (0, import_firestore55.getDocs)(q);
|
|
17228
17522
|
const procedures = querySnapshot.docs.map(
|
|
17229
|
-
(
|
|
17523
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
17230
17524
|
);
|
|
17231
17525
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
17232
17526
|
console.log(`[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`);
|
|
@@ -17257,7 +17551,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17257
17551
|
const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
17258
17552
|
const querySnapshot = await (0, import_firestore55.getDocs)(q);
|
|
17259
17553
|
let procedures = querySnapshot.docs.map(
|
|
17260
|
-
(
|
|
17554
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
17261
17555
|
);
|
|
17262
17556
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
17263
17557
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -17285,7 +17579,7 @@ var ProcedureService = class extends BaseService {
|
|
|
17285
17579
|
const q = (0, import_firestore55.query)((0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
17286
17580
|
const querySnapshot = await (0, import_firestore55.getDocs)(q);
|
|
17287
17581
|
let procedures = querySnapshot.docs.map(
|
|
17288
|
-
(
|
|
17582
|
+
(doc45) => ({ ...doc45.data(), id: doc45.id })
|
|
17289
17583
|
);
|
|
17290
17584
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
17291
17585
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -17592,11 +17886,11 @@ var ProcedureService = class extends BaseService {
|
|
|
17592
17886
|
async getProceduresForMap() {
|
|
17593
17887
|
const proceduresRef = (0, import_firestore55.collection)(this.db, PROCEDURES_COLLECTION);
|
|
17594
17888
|
const snapshot = await (0, import_firestore55.getDocs)(proceduresRef);
|
|
17595
|
-
const proceduresForMap = snapshot.docs.map((
|
|
17889
|
+
const proceduresForMap = snapshot.docs.map((doc45) => {
|
|
17596
17890
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17597
|
-
const data =
|
|
17891
|
+
const data = doc45.data();
|
|
17598
17892
|
return {
|
|
17599
|
-
id:
|
|
17893
|
+
id: doc45.id,
|
|
17600
17894
|
name: data.name,
|
|
17601
17895
|
clinicId: (_a = data.clinicInfo) == null ? void 0 : _a.id,
|
|
17602
17896
|
clinicName: (_b = data.clinicInfo) == null ? void 0 : _b.name,
|
|
@@ -17639,9 +17933,9 @@ var ProcedureService = class extends BaseService {
|
|
|
17639
17933
|
(0, import_firestore55.orderBy)("name", "asc")
|
|
17640
17934
|
);
|
|
17641
17935
|
const querySnapshot = await (0, import_firestore55.getDocs)(proceduresQuery);
|
|
17642
|
-
return querySnapshot.docs.map((
|
|
17643
|
-
id:
|
|
17644
|
-
...
|
|
17936
|
+
return querySnapshot.docs.map((doc45) => ({
|
|
17937
|
+
id: doc45.id,
|
|
17938
|
+
...doc45.data()
|
|
17645
17939
|
}));
|
|
17646
17940
|
}
|
|
17647
17941
|
};
|
|
@@ -17660,17 +17954,16 @@ var ReviewService = class extends BaseService {
|
|
|
17660
17954
|
* @returns The created review
|
|
17661
17955
|
*/
|
|
17662
17956
|
async createReview(data, appointmentId) {
|
|
17663
|
-
var _a, _b, _c, _d, _e, _f
|
|
17957
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17664
17958
|
try {
|
|
17665
17959
|
console.log("\u{1F50D} ReviewService.createReview - Input data:", {
|
|
17666
17960
|
appointmentId,
|
|
17667
17961
|
hasClinicReview: !!data.clinicReview,
|
|
17668
17962
|
hasPractitionerReview: !!data.practitionerReview,
|
|
17669
17963
|
hasProcedureReview: !!data.procedureReview,
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
|
|
17673
|
-
procedureId: (_d = data.procedureReview) == null ? void 0 : _d.procedureId
|
|
17964
|
+
practitionerId: (_a = data.practitionerReview) == null ? void 0 : _a.practitionerId,
|
|
17965
|
+
clinicId: (_b = data.clinicReview) == null ? void 0 : _b.clinicId,
|
|
17966
|
+
procedureId: (_c = data.procedureReview) == null ? void 0 : _c.procedureId
|
|
17674
17967
|
});
|
|
17675
17968
|
const validatedData = createReviewSchema.parse(data);
|
|
17676
17969
|
const ratings = [];
|
|
@@ -17710,20 +18003,6 @@ var ReviewService = class extends BaseService {
|
|
|
17710
18003
|
data.procedureReview.overallRating = procedureAverage;
|
|
17711
18004
|
ratings.push(procedureAverage);
|
|
17712
18005
|
}
|
|
17713
|
-
if (data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0) {
|
|
17714
|
-
data.extendedProcedureReviews.forEach((extendedReview) => {
|
|
17715
|
-
const extendedRatings = [
|
|
17716
|
-
extendedReview.effectivenessOfTreatment,
|
|
17717
|
-
extendedReview.outcomeExplanation,
|
|
17718
|
-
extendedReview.painManagement,
|
|
17719
|
-
extendedReview.followUpCare,
|
|
17720
|
-
extendedReview.valueForMoney
|
|
17721
|
-
];
|
|
17722
|
-
const extendedAverage = this.calculateAverage(extendedRatings);
|
|
17723
|
-
extendedReview.overallRating = extendedAverage;
|
|
17724
|
-
ratings.push(extendedAverage);
|
|
17725
|
-
});
|
|
17726
|
-
}
|
|
17727
18006
|
const overallRating = this.calculateAverage(ratings);
|
|
17728
18007
|
const reviewId = this.generateId();
|
|
17729
18008
|
if (data.clinicReview) {
|
|
@@ -17739,14 +18018,6 @@ var ReviewService = class extends BaseService {
|
|
|
17739
18018
|
data.procedureReview.fullReviewId = reviewId;
|
|
17740
18019
|
}
|
|
17741
18020
|
const now = /* @__PURE__ */ new Date();
|
|
17742
|
-
if (data.extendedProcedureReviews && data.extendedProcedureReviews.length > 0) {
|
|
17743
|
-
data.extendedProcedureReviews.forEach((extendedReview) => {
|
|
17744
|
-
extendedReview.id = this.generateId();
|
|
17745
|
-
extendedReview.fullReviewId = reviewId;
|
|
17746
|
-
extendedReview.createdAt = now;
|
|
17747
|
-
extendedReview.updatedAt = now;
|
|
17748
|
-
});
|
|
17749
|
-
}
|
|
17750
18021
|
const review = {
|
|
17751
18022
|
id: reviewId,
|
|
17752
18023
|
appointmentId,
|
|
@@ -17754,7 +18025,6 @@ var ReviewService = class extends BaseService {
|
|
|
17754
18025
|
clinicReview: data.clinicReview,
|
|
17755
18026
|
practitionerReview: data.practitionerReview,
|
|
17756
18027
|
procedureReview: data.procedureReview,
|
|
17757
|
-
extendedProcedureReviews: data.extendedProcedureReviews,
|
|
17758
18028
|
overallComment: data.overallComment,
|
|
17759
18029
|
overallRating,
|
|
17760
18030
|
createdAt: now,
|
|
@@ -17769,10 +18039,9 @@ var ReviewService = class extends BaseService {
|
|
|
17769
18039
|
});
|
|
17770
18040
|
console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
|
|
17771
18041
|
reviewId,
|
|
17772
|
-
practitionerId: (
|
|
17773
|
-
clinicId: (
|
|
17774
|
-
procedureId: (
|
|
17775
|
-
extendedProcedureReviewsCount: ((_h = review.extendedProcedureReviews) == null ? void 0 : _h.length) || 0
|
|
18042
|
+
practitionerId: (_d = review.practitionerReview) == null ? void 0 : _d.practitionerId,
|
|
18043
|
+
clinicId: (_e = review.clinicReview) == null ? void 0 : _e.clinicId,
|
|
18044
|
+
procedureId: (_f = review.procedureReview) == null ? void 0 : _f.procedureId
|
|
17776
18045
|
});
|
|
17777
18046
|
return review;
|
|
17778
18047
|
} catch (error) {
|
|
@@ -17788,7 +18057,7 @@ var ReviewService = class extends BaseService {
|
|
|
17788
18057
|
* @returns The review with entity names if found, null otherwise
|
|
17789
18058
|
*/
|
|
17790
18059
|
async getReview(reviewId) {
|
|
17791
|
-
var _a, _b, _c
|
|
18060
|
+
var _a, _b, _c;
|
|
17792
18061
|
console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
|
|
17793
18062
|
const docRef = (0, import_firestore56.doc)(this.db, REVIEWS_COLLECTION, reviewId);
|
|
17794
18063
|
const docSnap = await (0, import_firestore56.getDoc)(docRef);
|
|
@@ -17822,27 +18091,12 @@ var ReviewService = class extends BaseService {
|
|
|
17822
18091
|
procedureName: appointment.procedureInfo.name
|
|
17823
18092
|
};
|
|
17824
18093
|
}
|
|
17825
|
-
if (enhancedReview.extendedProcedureReviews && enhancedReview.extendedProcedureReviews.length > 0) {
|
|
17826
|
-
const extendedProcedures = ((_a = appointment.metadata) == null ? void 0 : _a.extendedProcedures) || [];
|
|
17827
|
-
enhancedReview.extendedProcedureReviews = enhancedReview.extendedProcedureReviews.map((extendedReview) => {
|
|
17828
|
-
const procedureInfo = extendedProcedures.find(
|
|
17829
|
-
(ep) => ep.procedureId === extendedReview.procedureId
|
|
17830
|
-
);
|
|
17831
|
-
if (procedureInfo) {
|
|
17832
|
-
return {
|
|
17833
|
-
...extendedReview,
|
|
17834
|
-
procedureName: procedureInfo.procedureName
|
|
17835
|
-
};
|
|
17836
|
-
}
|
|
17837
|
-
return extendedReview;
|
|
17838
|
-
});
|
|
17839
|
-
}
|
|
17840
18094
|
if (appointment.patientInfo) {
|
|
17841
18095
|
enhancedReview.patientName = appointment.patientInfo.fullName;
|
|
17842
18096
|
}
|
|
17843
18097
|
console.log("\u2705 ReviewService.getReview - Enhanced review:", {
|
|
17844
18098
|
reviewId,
|
|
17845
|
-
hasEntityNames: !!(((
|
|
18099
|
+
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)
|
|
17846
18100
|
});
|
|
17847
18101
|
return enhancedReview;
|
|
17848
18102
|
}
|
|
@@ -17861,7 +18115,7 @@ var ReviewService = class extends BaseService {
|
|
|
17861
18115
|
async getReviewsByPatient(patientId) {
|
|
17862
18116
|
const q = (0, import_firestore56.query)((0, import_firestore56.collection)(this.db, REVIEWS_COLLECTION), (0, import_firestore56.where)("patientId", "==", patientId));
|
|
17863
18117
|
const snapshot = await (0, import_firestore56.getDocs)(q);
|
|
17864
|
-
const reviews = snapshot.docs.map((
|
|
18118
|
+
const reviews = snapshot.docs.map((doc45) => doc45.data());
|
|
17865
18119
|
const enhancedReviews = await Promise.all(
|
|
17866
18120
|
reviews.map(async (review) => {
|
|
17867
18121
|
try {
|
|
@@ -17915,9 +18169,9 @@ var ReviewService = class extends BaseService {
|
|
|
17915
18169
|
(0, import_firestore56.where)("clinicReview.clinicId", "==", clinicId)
|
|
17916
18170
|
);
|
|
17917
18171
|
const snapshot = await (0, import_firestore56.getDocs)(q);
|
|
17918
|
-
const reviews = snapshot.docs.map((
|
|
17919
|
-
const data =
|
|
17920
|
-
return { ...data, id:
|
|
18172
|
+
const reviews = snapshot.docs.map((doc45) => {
|
|
18173
|
+
const data = doc45.data();
|
|
18174
|
+
return { ...data, id: doc45.id };
|
|
17921
18175
|
});
|
|
17922
18176
|
console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
|
|
17923
18177
|
clinicId,
|
|
@@ -17991,9 +18245,9 @@ var ReviewService = class extends BaseService {
|
|
|
17991
18245
|
(0, import_firestore56.where)("practitionerReview.practitionerId", "==", practitionerId)
|
|
17992
18246
|
);
|
|
17993
18247
|
const snapshot = await (0, import_firestore56.getDocs)(q);
|
|
17994
|
-
const reviews = snapshot.docs.map((
|
|
17995
|
-
const data =
|
|
17996
|
-
return { ...data, id:
|
|
18248
|
+
const reviews = snapshot.docs.map((doc45) => {
|
|
18249
|
+
const data = doc45.data();
|
|
18250
|
+
return { ...data, id: doc45.id };
|
|
17997
18251
|
});
|
|
17998
18252
|
console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
|
|
17999
18253
|
practitionerId,
|
|
@@ -18064,9 +18318,9 @@ var ReviewService = class extends BaseService {
|
|
|
18064
18318
|
(0, import_firestore56.where)("procedureReview.procedureId", "==", procedureId)
|
|
18065
18319
|
);
|
|
18066
18320
|
const snapshot = await (0, import_firestore56.getDocs)(q);
|
|
18067
|
-
const reviews = snapshot.docs.map((
|
|
18068
|
-
const data =
|
|
18069
|
-
return { ...data, id:
|
|
18321
|
+
const reviews = snapshot.docs.map((doc45) => {
|
|
18322
|
+
const data = doc45.data();
|
|
18323
|
+
return { ...data, id: doc45.id };
|
|
18070
18324
|
});
|
|
18071
18325
|
console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
|
|
18072
18326
|
procedureId,
|
|
@@ -18274,9 +18528,9 @@ var BrandService = class extends BaseService {
|
|
|
18274
18528
|
const q = (0, import_firestore58.query)(this.getBrandsRef(), ...constraints);
|
|
18275
18529
|
const snapshot = await (0, import_firestore58.getDocs)(q);
|
|
18276
18530
|
const brands = snapshot.docs.map(
|
|
18277
|
-
(
|
|
18278
|
-
id:
|
|
18279
|
-
...
|
|
18531
|
+
(doc45) => ({
|
|
18532
|
+
id: doc45.id,
|
|
18533
|
+
...doc45.data()
|
|
18280
18534
|
})
|
|
18281
18535
|
);
|
|
18282
18536
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -18310,9 +18564,9 @@ var BrandService = class extends BaseService {
|
|
|
18310
18564
|
);
|
|
18311
18565
|
const snapshot = await (0, import_firestore58.getDocs)(q);
|
|
18312
18566
|
return snapshot.docs.map(
|
|
18313
|
-
(
|
|
18314
|
-
id:
|
|
18315
|
-
...
|
|
18567
|
+
(doc45) => ({
|
|
18568
|
+
id: doc45.id,
|
|
18569
|
+
...doc45.data()
|
|
18316
18570
|
})
|
|
18317
18571
|
);
|
|
18318
18572
|
}
|
|
@@ -18477,9 +18731,9 @@ var CategoryService = class extends BaseService {
|
|
|
18477
18731
|
const q = (0, import_firestore59.query)(this.categoriesRef, (0, import_firestore59.where)("isActive", "==", true));
|
|
18478
18732
|
const snapshot = await (0, import_firestore59.getDocs)(q);
|
|
18479
18733
|
return snapshot.docs.map(
|
|
18480
|
-
(
|
|
18481
|
-
id:
|
|
18482
|
-
...
|
|
18734
|
+
(doc45) => ({
|
|
18735
|
+
id: doc45.id,
|
|
18736
|
+
...doc45.data()
|
|
18483
18737
|
})
|
|
18484
18738
|
);
|
|
18485
18739
|
}
|
|
@@ -18497,9 +18751,9 @@ var CategoryService = class extends BaseService {
|
|
|
18497
18751
|
);
|
|
18498
18752
|
const snapshot = await (0, import_firestore59.getDocs)(q);
|
|
18499
18753
|
return snapshot.docs.map(
|
|
18500
|
-
(
|
|
18501
|
-
id:
|
|
18502
|
-
...
|
|
18754
|
+
(doc45) => ({
|
|
18755
|
+
id: doc45.id,
|
|
18756
|
+
...doc45.data()
|
|
18503
18757
|
})
|
|
18504
18758
|
);
|
|
18505
18759
|
}
|
|
@@ -18519,9 +18773,9 @@ var CategoryService = class extends BaseService {
|
|
|
18519
18773
|
const q = (0, import_firestore59.query)(this.categoriesRef, ...constraints);
|
|
18520
18774
|
const snapshot = await (0, import_firestore59.getDocs)(q);
|
|
18521
18775
|
const categories = snapshot.docs.map(
|
|
18522
|
-
(
|
|
18523
|
-
id:
|
|
18524
|
-
...
|
|
18776
|
+
(doc45) => ({
|
|
18777
|
+
id: doc45.id,
|
|
18778
|
+
...doc45.data()
|
|
18525
18779
|
})
|
|
18526
18780
|
);
|
|
18527
18781
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -18545,9 +18799,9 @@ var CategoryService = class extends BaseService {
|
|
|
18545
18799
|
const q = (0, import_firestore59.query)(this.categoriesRef, ...constraints);
|
|
18546
18800
|
const snapshot = await (0, import_firestore59.getDocs)(q);
|
|
18547
18801
|
const categories = snapshot.docs.map(
|
|
18548
|
-
(
|
|
18549
|
-
id:
|
|
18550
|
-
...
|
|
18802
|
+
(doc45) => ({
|
|
18803
|
+
id: doc45.id,
|
|
18804
|
+
...doc45.data()
|
|
18551
18805
|
})
|
|
18552
18806
|
);
|
|
18553
18807
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -18739,9 +18993,9 @@ var SubcategoryService = class extends BaseService {
|
|
|
18739
18993
|
const q = (0, import_firestore60.query)(this.getSubcategoriesRef(categoryId), ...constraints);
|
|
18740
18994
|
const querySnapshot = await (0, import_firestore60.getDocs)(q);
|
|
18741
18995
|
const subcategories = querySnapshot.docs.map(
|
|
18742
|
-
(
|
|
18743
|
-
id:
|
|
18744
|
-
...
|
|
18996
|
+
(doc45) => ({
|
|
18997
|
+
id: doc45.id,
|
|
18998
|
+
...doc45.data()
|
|
18745
18999
|
})
|
|
18746
19000
|
);
|
|
18747
19001
|
const newLastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
|
|
@@ -18769,9 +19023,9 @@ var SubcategoryService = class extends BaseService {
|
|
|
18769
19023
|
);
|
|
18770
19024
|
const querySnapshot = await (0, import_firestore60.getDocs)(q);
|
|
18771
19025
|
const subcategories = querySnapshot.docs.map(
|
|
18772
|
-
(
|
|
18773
|
-
id:
|
|
18774
|
-
...
|
|
19026
|
+
(doc45) => ({
|
|
19027
|
+
id: doc45.id,
|
|
19028
|
+
...doc45.data()
|
|
18775
19029
|
})
|
|
18776
19030
|
);
|
|
18777
19031
|
const newLastVisible = querySnapshot.docs[querySnapshot.docs.length - 1];
|
|
@@ -18789,9 +19043,9 @@ var SubcategoryService = class extends BaseService {
|
|
|
18789
19043
|
);
|
|
18790
19044
|
const querySnapshot = await (0, import_firestore60.getDocs)(q);
|
|
18791
19045
|
return querySnapshot.docs.map(
|
|
18792
|
-
(
|
|
18793
|
-
id:
|
|
18794
|
-
...
|
|
19046
|
+
(doc45) => ({
|
|
19047
|
+
id: doc45.id,
|
|
19048
|
+
...doc45.data()
|
|
18795
19049
|
})
|
|
18796
19050
|
);
|
|
18797
19051
|
}
|
|
@@ -18806,9 +19060,9 @@ var SubcategoryService = class extends BaseService {
|
|
|
18806
19060
|
);
|
|
18807
19061
|
const querySnapshot = await (0, import_firestore60.getDocs)(q);
|
|
18808
19062
|
return querySnapshot.docs.map(
|
|
18809
|
-
(
|
|
18810
|
-
id:
|
|
18811
|
-
...
|
|
19063
|
+
(doc45) => ({
|
|
19064
|
+
id: doc45.id,
|
|
19065
|
+
...doc45.data()
|
|
18812
19066
|
})
|
|
18813
19067
|
);
|
|
18814
19068
|
}
|
|
@@ -19002,6 +19256,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19002
19256
|
if (technology.technicalDetails) {
|
|
19003
19257
|
newTechnology.technicalDetails = technology.technicalDetails;
|
|
19004
19258
|
}
|
|
19259
|
+
if (technology.photoTemplate) {
|
|
19260
|
+
newTechnology.photoTemplate = technology.photoTemplate;
|
|
19261
|
+
}
|
|
19005
19262
|
const docRef = await (0, import_firestore61.addDoc)(this.technologiesRef, newTechnology);
|
|
19006
19263
|
return { id: docRef.id, ...newTechnology };
|
|
19007
19264
|
}
|
|
@@ -19014,8 +19271,8 @@ var TechnologyService = class extends BaseService {
|
|
|
19014
19271
|
const q = (0, import_firestore61.query)(this.technologiesRef, (0, import_firestore61.where)("isActive", "==", active));
|
|
19015
19272
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19016
19273
|
const counts = {};
|
|
19017
|
-
snapshot.docs.forEach((
|
|
19018
|
-
const tech =
|
|
19274
|
+
snapshot.docs.forEach((doc45) => {
|
|
19275
|
+
const tech = doc45.data();
|
|
19019
19276
|
counts[tech.subcategoryId] = (counts[tech.subcategoryId] || 0) + 1;
|
|
19020
19277
|
});
|
|
19021
19278
|
return counts;
|
|
@@ -19029,8 +19286,8 @@ var TechnologyService = class extends BaseService {
|
|
|
19029
19286
|
const q = (0, import_firestore61.query)(this.technologiesRef, (0, import_firestore61.where)("isActive", "==", active));
|
|
19030
19287
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19031
19288
|
const counts = {};
|
|
19032
|
-
snapshot.docs.forEach((
|
|
19033
|
-
const tech =
|
|
19289
|
+
snapshot.docs.forEach((doc45) => {
|
|
19290
|
+
const tech = doc45.data();
|
|
19034
19291
|
counts[tech.categoryId] = (counts[tech.categoryId] || 0) + 1;
|
|
19035
19292
|
});
|
|
19036
19293
|
return counts;
|
|
@@ -19051,9 +19308,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19051
19308
|
const q = (0, import_firestore61.query)(this.technologiesRef, ...constraints);
|
|
19052
19309
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19053
19310
|
const technologies = snapshot.docs.map(
|
|
19054
|
-
(
|
|
19055
|
-
id:
|
|
19056
|
-
...
|
|
19311
|
+
(doc45) => ({
|
|
19312
|
+
id: doc45.id,
|
|
19313
|
+
...doc45.data()
|
|
19057
19314
|
})
|
|
19058
19315
|
);
|
|
19059
19316
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -19077,9 +19334,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19077
19334
|
const q = (0, import_firestore61.query)(this.technologiesRef, ...constraints);
|
|
19078
19335
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19079
19336
|
const technologies = snapshot.docs.map(
|
|
19080
|
-
(
|
|
19081
|
-
id:
|
|
19082
|
-
...
|
|
19337
|
+
(doc45) => ({
|
|
19338
|
+
id: doc45.id,
|
|
19339
|
+
...doc45.data()
|
|
19083
19340
|
})
|
|
19084
19341
|
);
|
|
19085
19342
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -19103,9 +19360,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19103
19360
|
const q = (0, import_firestore61.query)(this.technologiesRef, ...constraints);
|
|
19104
19361
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19105
19362
|
const technologies = snapshot.docs.map(
|
|
19106
|
-
(
|
|
19107
|
-
id:
|
|
19108
|
-
...
|
|
19363
|
+
(doc45) => ({
|
|
19364
|
+
id: doc45.id,
|
|
19365
|
+
...doc45.data()
|
|
19109
19366
|
})
|
|
19110
19367
|
);
|
|
19111
19368
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -19124,6 +19381,13 @@ var TechnologyService = class extends BaseService {
|
|
|
19124
19381
|
delete updateData[key];
|
|
19125
19382
|
}
|
|
19126
19383
|
});
|
|
19384
|
+
if ("photoTemplate" in technology) {
|
|
19385
|
+
if (technology.photoTemplate === null || technology.photoTemplate === "") {
|
|
19386
|
+
updateData.photoTemplate = null;
|
|
19387
|
+
} else if (technology.photoTemplate !== void 0) {
|
|
19388
|
+
updateData.photoTemplate = technology.photoTemplate;
|
|
19389
|
+
}
|
|
19390
|
+
}
|
|
19127
19391
|
updateData.updatedAt = /* @__PURE__ */ new Date();
|
|
19128
19392
|
const docRef = (0, import_firestore61.doc)(this.technologiesRef, id);
|
|
19129
19393
|
const beforeTech = await this.getById(id);
|
|
@@ -19529,9 +19793,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19529
19793
|
);
|
|
19530
19794
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19531
19795
|
return snapshot.docs.map(
|
|
19532
|
-
(
|
|
19533
|
-
id:
|
|
19534
|
-
...
|
|
19796
|
+
(doc45) => ({
|
|
19797
|
+
id: doc45.id,
|
|
19798
|
+
...doc45.data()
|
|
19535
19799
|
})
|
|
19536
19800
|
);
|
|
19537
19801
|
}
|
|
@@ -19550,9 +19814,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19550
19814
|
);
|
|
19551
19815
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19552
19816
|
return snapshot.docs.map(
|
|
19553
|
-
(
|
|
19554
|
-
id:
|
|
19555
|
-
...
|
|
19817
|
+
(doc45) => ({
|
|
19818
|
+
id: doc45.id,
|
|
19819
|
+
...doc45.data()
|
|
19556
19820
|
})
|
|
19557
19821
|
);
|
|
19558
19822
|
}
|
|
@@ -19567,9 +19831,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19567
19831
|
);
|
|
19568
19832
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19569
19833
|
return snapshot.docs.map(
|
|
19570
|
-
(
|
|
19571
|
-
id:
|
|
19572
|
-
...
|
|
19834
|
+
(doc45) => ({
|
|
19835
|
+
id: doc45.id,
|
|
19836
|
+
...doc45.data()
|
|
19573
19837
|
})
|
|
19574
19838
|
);
|
|
19575
19839
|
}
|
|
@@ -19619,9 +19883,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19619
19883
|
);
|
|
19620
19884
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19621
19885
|
return snapshot.docs.map(
|
|
19622
|
-
(
|
|
19623
|
-
id:
|
|
19624
|
-
...
|
|
19886
|
+
(doc45) => ({
|
|
19887
|
+
id: doc45.id,
|
|
19888
|
+
...doc45.data()
|
|
19625
19889
|
})
|
|
19626
19890
|
);
|
|
19627
19891
|
}
|
|
@@ -19636,9 +19900,9 @@ var TechnologyService = class extends BaseService {
|
|
|
19636
19900
|
);
|
|
19637
19901
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19638
19902
|
const allProducts = snapshot.docs.map(
|
|
19639
|
-
(
|
|
19640
|
-
id:
|
|
19641
|
-
...
|
|
19903
|
+
(doc45) => ({
|
|
19904
|
+
id: doc45.id,
|
|
19905
|
+
...doc45.data()
|
|
19642
19906
|
})
|
|
19643
19907
|
);
|
|
19644
19908
|
return allProducts.filter(
|
|
@@ -19755,8 +20019,8 @@ var TechnologyService = class extends BaseService {
|
|
|
19755
20019
|
const productsRef = (0, import_firestore61.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
19756
20020
|
const q = (0, import_firestore61.query)(productsRef, (0, import_firestore61.where)("isActive", "==", true));
|
|
19757
20021
|
const snapshot = await (0, import_firestore61.getDocs)(q);
|
|
19758
|
-
return snapshot.docs.map((
|
|
19759
|
-
const product =
|
|
20022
|
+
return snapshot.docs.map((doc45) => {
|
|
20023
|
+
const product = doc45.data();
|
|
19760
20024
|
return product.name || "";
|
|
19761
20025
|
}).filter((name) => name);
|
|
19762
20026
|
} catch (error) {
|
|
@@ -19852,9 +20116,9 @@ var ProductService = class extends BaseService {
|
|
|
19852
20116
|
const q = (0, import_firestore62.query)((0, import_firestore62.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
19853
20117
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
19854
20118
|
const products = snapshot.docs.map(
|
|
19855
|
-
(
|
|
19856
|
-
id:
|
|
19857
|
-
...
|
|
20119
|
+
(doc45) => ({
|
|
20120
|
+
id: doc45.id,
|
|
20121
|
+
...doc45.data()
|
|
19858
20122
|
})
|
|
19859
20123
|
);
|
|
19860
20124
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -19891,8 +20155,8 @@ var ProductService = class extends BaseService {
|
|
|
19891
20155
|
};
|
|
19892
20156
|
const q = (0, import_firestore62.query)((0, import_firestore62.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore62.where)("isActive", "==", true));
|
|
19893
20157
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
19894
|
-
snapshot.docs.forEach((
|
|
19895
|
-
const product =
|
|
20158
|
+
snapshot.docs.forEach((doc45) => {
|
|
20159
|
+
const product = doc45.data();
|
|
19896
20160
|
if (product.categoryId) {
|
|
19897
20161
|
counts.byCategory[product.categoryId] = (counts.byCategory[product.categoryId] || 0) + 1;
|
|
19898
20162
|
}
|
|
@@ -19916,9 +20180,9 @@ var ProductService = class extends BaseService {
|
|
|
19916
20180
|
);
|
|
19917
20181
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
19918
20182
|
return snapshot.docs.map(
|
|
19919
|
-
(
|
|
19920
|
-
id:
|
|
19921
|
-
...
|
|
20183
|
+
(doc45) => ({
|
|
20184
|
+
id: doc45.id,
|
|
20185
|
+
...doc45.data()
|
|
19922
20186
|
})
|
|
19923
20187
|
);
|
|
19924
20188
|
}
|
|
@@ -19938,9 +20202,9 @@ var ProductService = class extends BaseService {
|
|
|
19938
20202
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
19939
20203
|
products.push(
|
|
19940
20204
|
...snapshot.docs.map(
|
|
19941
|
-
(
|
|
19942
|
-
id:
|
|
19943
|
-
...
|
|
20205
|
+
(doc45) => ({
|
|
20206
|
+
id: doc45.id,
|
|
20207
|
+
...doc45.data()
|
|
19944
20208
|
})
|
|
19945
20209
|
)
|
|
19946
20210
|
);
|
|
@@ -20014,9 +20278,9 @@ var ProductService = class extends BaseService {
|
|
|
20014
20278
|
const q = (0, import_firestore62.query)(this.getTopLevelProductsRef(), ...constraints);
|
|
20015
20279
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
20016
20280
|
const products = snapshot.docs.map(
|
|
20017
|
-
(
|
|
20018
|
-
id:
|
|
20019
|
-
...
|
|
20281
|
+
(doc45) => ({
|
|
20282
|
+
id: doc45.id,
|
|
20283
|
+
...doc45.data()
|
|
20020
20284
|
})
|
|
20021
20285
|
);
|
|
20022
20286
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -20086,9 +20350,9 @@ var ProductService = class extends BaseService {
|
|
|
20086
20350
|
);
|
|
20087
20351
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
20088
20352
|
return snapshot.docs.map(
|
|
20089
|
-
(
|
|
20090
|
-
id:
|
|
20091
|
-
...
|
|
20353
|
+
(doc45) => ({
|
|
20354
|
+
id: doc45.id,
|
|
20355
|
+
...doc45.data()
|
|
20092
20356
|
})
|
|
20093
20357
|
);
|
|
20094
20358
|
}
|
|
@@ -20103,9 +20367,9 @@ var ProductService = class extends BaseService {
|
|
|
20103
20367
|
);
|
|
20104
20368
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
20105
20369
|
const allProducts = snapshot.docs.map(
|
|
20106
|
-
(
|
|
20107
|
-
id:
|
|
20108
|
-
...
|
|
20370
|
+
(doc45) => ({
|
|
20371
|
+
id: doc45.id,
|
|
20372
|
+
...doc45.data()
|
|
20109
20373
|
})
|
|
20110
20374
|
);
|
|
20111
20375
|
return allProducts.filter(
|
|
@@ -20127,9 +20391,9 @@ var ProductService = class extends BaseService {
|
|
|
20127
20391
|
);
|
|
20128
20392
|
const snapshot = await (0, import_firestore62.getDocs)(q);
|
|
20129
20393
|
return snapshot.docs.map(
|
|
20130
|
-
(
|
|
20131
|
-
id:
|
|
20132
|
-
...
|
|
20394
|
+
(doc45) => ({
|
|
20395
|
+
id: doc45.id,
|
|
20396
|
+
...doc45.data()
|
|
20133
20397
|
})
|
|
20134
20398
|
);
|
|
20135
20399
|
}
|