@blackcode_sa/metaestetics-api 1.6.17 → 1.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/index.js +52 -8
- package/dist/admin/index.mjs +52 -8
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +22 -18
- package/dist/index.mjs +11 -7
- package/package.json +1 -1
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +61 -9
- package/src/admin/users/user-profile.admin.ts +404 -0
- package/src/config/firebase.ts +17 -1
- package/src/services/auth.v2.service.ts +959 -0
- package/src/services/user.v2.service.ts +466 -0
package/dist/admin/index.js
CHANGED
|
@@ -3345,18 +3345,46 @@ var AppointmentAggregationService = class {
|
|
|
3345
3345
|
try {
|
|
3346
3346
|
const batch = this.db.batch();
|
|
3347
3347
|
let instancesCreatedCount = 0;
|
|
3348
|
+
Logger.info(
|
|
3349
|
+
`[AggService] Found ${appointment.preProcedureRequirements.length} pre-requirements to process: ${JSON.stringify(
|
|
3350
|
+
appointment.preProcedureRequirements.map((r) => {
|
|
3351
|
+
var _a2, _b;
|
|
3352
|
+
return {
|
|
3353
|
+
id: r.id,
|
|
3354
|
+
name: r.name,
|
|
3355
|
+
type: r.type,
|
|
3356
|
+
isActive: r.isActive,
|
|
3357
|
+
hasTimeframe: !!r.timeframe,
|
|
3358
|
+
notifyAtLength: ((_b = (_a2 = r.timeframe) == null ? void 0 : _a2.notifyAt) == null ? void 0 : _b.length) || 0
|
|
3359
|
+
};
|
|
3360
|
+
})
|
|
3361
|
+
)}`
|
|
3362
|
+
);
|
|
3348
3363
|
for (const template of appointment.preProcedureRequirements) {
|
|
3349
|
-
if (!template)
|
|
3364
|
+
if (!template) {
|
|
3365
|
+
Logger.warn(
|
|
3366
|
+
`[AggService] Found null/undefined template in preProcedureRequirements array`
|
|
3367
|
+
);
|
|
3368
|
+
continue;
|
|
3369
|
+
}
|
|
3350
3370
|
if (template.type !== "pre" /* PRE */ || !template.isActive) {
|
|
3351
3371
|
Logger.debug(
|
|
3352
3372
|
`[AggService] Skipping template ${template.id} (${template.name}): not an active PRE requirement.`
|
|
3353
3373
|
);
|
|
3354
3374
|
continue;
|
|
3355
3375
|
}
|
|
3376
|
+
if (!template.timeframe || !template.timeframe.notifyAt || template.timeframe.notifyAt.length === 0) {
|
|
3377
|
+
Logger.warn(
|
|
3378
|
+
`[AggService] Template ${template.id} (${template.name}) has no timeframe.notifyAt values. Creating with empty instructions.`
|
|
3379
|
+
);
|
|
3380
|
+
}
|
|
3356
3381
|
Logger.debug(
|
|
3357
3382
|
`[AggService] Processing template ${template.id} (${template.name}) for appt ${appointment.id}`
|
|
3358
3383
|
);
|
|
3359
3384
|
const newInstanceRef = this.db.collection(PATIENTS_COLLECTION).doc(appointment.patientId).collection(PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME).doc();
|
|
3385
|
+
Logger.debug(
|
|
3386
|
+
`[AggService] Created doc reference: ${newInstanceRef.path}`
|
|
3387
|
+
);
|
|
3360
3388
|
const instructions = (((_a = template.timeframe) == null ? void 0 : _a.notifyAt) || []).map((notifyAtValue) => {
|
|
3361
3389
|
let dueTime = appointment.appointmentStartTime;
|
|
3362
3390
|
if (template.timeframe && typeof notifyAtValue === "number") {
|
|
@@ -3383,10 +3411,8 @@ var AppointmentAggregationService = class {
|
|
|
3383
3411
|
status: "pendingNotification" /* PENDING_NOTIFICATION */,
|
|
3384
3412
|
originalNotifyAtValue: notifyAtValue,
|
|
3385
3413
|
originalTimeframeUnit: template.timeframe.unit,
|
|
3386
|
-
updatedAt: admin10.firestore.Timestamp.now()
|
|
3414
|
+
updatedAt: admin10.firestore.Timestamp.now()
|
|
3387
3415
|
// Use current server timestamp
|
|
3388
|
-
notificationId: void 0,
|
|
3389
|
-
actionTakenAt: void 0
|
|
3390
3416
|
};
|
|
3391
3417
|
return instructionObject;
|
|
3392
3418
|
});
|
|
@@ -3405,6 +3431,15 @@ var AppointmentAggregationService = class {
|
|
|
3405
3431
|
createdAt: admin10.firestore.FieldValue.serverTimestamp(),
|
|
3406
3432
|
updatedAt: admin10.firestore.FieldValue.serverTimestamp()
|
|
3407
3433
|
};
|
|
3434
|
+
Logger.debug(
|
|
3435
|
+
`[AggService] Setting data for requirement: ${JSON.stringify({
|
|
3436
|
+
id: newInstanceRef.id,
|
|
3437
|
+
patientId: newInstanceData.patientId,
|
|
3438
|
+
appointmentId: newInstanceData.appointmentId,
|
|
3439
|
+
requirementName: newInstanceData.requirementName,
|
|
3440
|
+
instructionsCount: newInstanceData.instructions.length
|
|
3441
|
+
})}`
|
|
3442
|
+
);
|
|
3408
3443
|
batch.set(newInstanceRef, newInstanceData);
|
|
3409
3444
|
instancesCreatedCount++;
|
|
3410
3445
|
Logger.debug(
|
|
@@ -3412,10 +3447,18 @@ var AppointmentAggregationService = class {
|
|
|
3412
3447
|
);
|
|
3413
3448
|
}
|
|
3414
3449
|
if (instancesCreatedCount > 0) {
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3450
|
+
try {
|
|
3451
|
+
await batch.commit();
|
|
3452
|
+
Logger.info(
|
|
3453
|
+
`[AggService] Successfully created ${instancesCreatedCount} PRE_APPOINTMENT requirement instances for appointment ${appointment.id}.`
|
|
3454
|
+
);
|
|
3455
|
+
} catch (commitError) {
|
|
3456
|
+
Logger.error(
|
|
3457
|
+
`[AggService] Error committing batch for PRE_APPOINTMENT requirement instances for appointment ${appointment.id}:`,
|
|
3458
|
+
commitError
|
|
3459
|
+
);
|
|
3460
|
+
throw commitError;
|
|
3461
|
+
}
|
|
3419
3462
|
} else {
|
|
3420
3463
|
Logger.info(
|
|
3421
3464
|
`[AggService] No new PRE_APPOINTMENT requirement instances were prepared for batch commit for appointment ${appointment.id}.`
|
|
@@ -3426,6 +3469,7 @@ var AppointmentAggregationService = class {
|
|
|
3426
3469
|
`[AggService] Error creating PRE_APPOINTMENT requirement instances for appointment ${appointment.id}:`,
|
|
3427
3470
|
error
|
|
3428
3471
|
);
|
|
3472
|
+
throw error;
|
|
3429
3473
|
}
|
|
3430
3474
|
}
|
|
3431
3475
|
/**
|
package/dist/admin/index.mjs
CHANGED
|
@@ -3290,18 +3290,46 @@ var AppointmentAggregationService = class {
|
|
|
3290
3290
|
try {
|
|
3291
3291
|
const batch = this.db.batch();
|
|
3292
3292
|
let instancesCreatedCount = 0;
|
|
3293
|
+
Logger.info(
|
|
3294
|
+
`[AggService] Found ${appointment.preProcedureRequirements.length} pre-requirements to process: ${JSON.stringify(
|
|
3295
|
+
appointment.preProcedureRequirements.map((r) => {
|
|
3296
|
+
var _a2, _b;
|
|
3297
|
+
return {
|
|
3298
|
+
id: r.id,
|
|
3299
|
+
name: r.name,
|
|
3300
|
+
type: r.type,
|
|
3301
|
+
isActive: r.isActive,
|
|
3302
|
+
hasTimeframe: !!r.timeframe,
|
|
3303
|
+
notifyAtLength: ((_b = (_a2 = r.timeframe) == null ? void 0 : _a2.notifyAt) == null ? void 0 : _b.length) || 0
|
|
3304
|
+
};
|
|
3305
|
+
})
|
|
3306
|
+
)}`
|
|
3307
|
+
);
|
|
3293
3308
|
for (const template of appointment.preProcedureRequirements) {
|
|
3294
|
-
if (!template)
|
|
3309
|
+
if (!template) {
|
|
3310
|
+
Logger.warn(
|
|
3311
|
+
`[AggService] Found null/undefined template in preProcedureRequirements array`
|
|
3312
|
+
);
|
|
3313
|
+
continue;
|
|
3314
|
+
}
|
|
3295
3315
|
if (template.type !== "pre" /* PRE */ || !template.isActive) {
|
|
3296
3316
|
Logger.debug(
|
|
3297
3317
|
`[AggService] Skipping template ${template.id} (${template.name}): not an active PRE requirement.`
|
|
3298
3318
|
);
|
|
3299
3319
|
continue;
|
|
3300
3320
|
}
|
|
3321
|
+
if (!template.timeframe || !template.timeframe.notifyAt || template.timeframe.notifyAt.length === 0) {
|
|
3322
|
+
Logger.warn(
|
|
3323
|
+
`[AggService] Template ${template.id} (${template.name}) has no timeframe.notifyAt values. Creating with empty instructions.`
|
|
3324
|
+
);
|
|
3325
|
+
}
|
|
3301
3326
|
Logger.debug(
|
|
3302
3327
|
`[AggService] Processing template ${template.id} (${template.name}) for appt ${appointment.id}`
|
|
3303
3328
|
);
|
|
3304
3329
|
const newInstanceRef = this.db.collection(PATIENTS_COLLECTION).doc(appointment.patientId).collection(PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME).doc();
|
|
3330
|
+
Logger.debug(
|
|
3331
|
+
`[AggService] Created doc reference: ${newInstanceRef.path}`
|
|
3332
|
+
);
|
|
3305
3333
|
const instructions = (((_a = template.timeframe) == null ? void 0 : _a.notifyAt) || []).map((notifyAtValue) => {
|
|
3306
3334
|
let dueTime = appointment.appointmentStartTime;
|
|
3307
3335
|
if (template.timeframe && typeof notifyAtValue === "number") {
|
|
@@ -3328,10 +3356,8 @@ var AppointmentAggregationService = class {
|
|
|
3328
3356
|
status: "pendingNotification" /* PENDING_NOTIFICATION */,
|
|
3329
3357
|
originalNotifyAtValue: notifyAtValue,
|
|
3330
3358
|
originalTimeframeUnit: template.timeframe.unit,
|
|
3331
|
-
updatedAt: admin10.firestore.Timestamp.now()
|
|
3359
|
+
updatedAt: admin10.firestore.Timestamp.now()
|
|
3332
3360
|
// Use current server timestamp
|
|
3333
|
-
notificationId: void 0,
|
|
3334
|
-
actionTakenAt: void 0
|
|
3335
3361
|
};
|
|
3336
3362
|
return instructionObject;
|
|
3337
3363
|
});
|
|
@@ -3350,6 +3376,15 @@ var AppointmentAggregationService = class {
|
|
|
3350
3376
|
createdAt: admin10.firestore.FieldValue.serverTimestamp(),
|
|
3351
3377
|
updatedAt: admin10.firestore.FieldValue.serverTimestamp()
|
|
3352
3378
|
};
|
|
3379
|
+
Logger.debug(
|
|
3380
|
+
`[AggService] Setting data for requirement: ${JSON.stringify({
|
|
3381
|
+
id: newInstanceRef.id,
|
|
3382
|
+
patientId: newInstanceData.patientId,
|
|
3383
|
+
appointmentId: newInstanceData.appointmentId,
|
|
3384
|
+
requirementName: newInstanceData.requirementName,
|
|
3385
|
+
instructionsCount: newInstanceData.instructions.length
|
|
3386
|
+
})}`
|
|
3387
|
+
);
|
|
3353
3388
|
batch.set(newInstanceRef, newInstanceData);
|
|
3354
3389
|
instancesCreatedCount++;
|
|
3355
3390
|
Logger.debug(
|
|
@@ -3357,10 +3392,18 @@ var AppointmentAggregationService = class {
|
|
|
3357
3392
|
);
|
|
3358
3393
|
}
|
|
3359
3394
|
if (instancesCreatedCount > 0) {
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3395
|
+
try {
|
|
3396
|
+
await batch.commit();
|
|
3397
|
+
Logger.info(
|
|
3398
|
+
`[AggService] Successfully created ${instancesCreatedCount} PRE_APPOINTMENT requirement instances for appointment ${appointment.id}.`
|
|
3399
|
+
);
|
|
3400
|
+
} catch (commitError) {
|
|
3401
|
+
Logger.error(
|
|
3402
|
+
`[AggService] Error committing batch for PRE_APPOINTMENT requirement instances for appointment ${appointment.id}:`,
|
|
3403
|
+
commitError
|
|
3404
|
+
);
|
|
3405
|
+
throw commitError;
|
|
3406
|
+
}
|
|
3364
3407
|
} else {
|
|
3365
3408
|
Logger.info(
|
|
3366
3409
|
`[AggService] No new PRE_APPOINTMENT requirement instances were prepared for batch commit for appointment ${appointment.id}.`
|
|
@@ -3371,6 +3414,7 @@ var AppointmentAggregationService = class {
|
|
|
3371
3414
|
`[AggService] Error creating PRE_APPOINTMENT requirement instances for appointment ${appointment.id}:`,
|
|
3372
3415
|
error
|
|
3373
3416
|
);
|
|
3417
|
+
throw error;
|
|
3374
3418
|
}
|
|
3375
3419
|
}
|
|
3376
3420
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import { FirebaseApp } from 'firebase/app';
|
|
|
5
5
|
import { Auth, User as User$1 } from 'firebase/auth';
|
|
6
6
|
import { Analytics } from 'firebase/analytics';
|
|
7
7
|
import { FirebaseStorage } from 'firebase/storage';
|
|
8
|
+
import { Functions } from 'firebase/functions';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Review system type definitions
|
|
@@ -5042,6 +5043,8 @@ interface FirebaseInstance {
|
|
|
5042
5043
|
db: Firestore;
|
|
5043
5044
|
auth: Auth;
|
|
5044
5045
|
analytics: Analytics | null;
|
|
5046
|
+
storage: FirebaseStorage;
|
|
5047
|
+
functions: Functions;
|
|
5045
5048
|
}
|
|
5046
5049
|
declare const initializeFirebase: (config: {
|
|
5047
5050
|
apiKey: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { FirebaseApp } from 'firebase/app';
|
|
|
5
5
|
import { Auth, User as User$1 } from 'firebase/auth';
|
|
6
6
|
import { Analytics } from 'firebase/analytics';
|
|
7
7
|
import { FirebaseStorage } from 'firebase/storage';
|
|
8
|
+
import { Functions } from 'firebase/functions';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Review system type definitions
|
|
@@ -5042,6 +5043,8 @@ interface FirebaseInstance {
|
|
|
5042
5043
|
db: Firestore;
|
|
5043
5044
|
auth: Auth;
|
|
5044
5045
|
analytics: Analytics | null;
|
|
5046
|
+
storage: FirebaseStorage;
|
|
5047
|
+
functions: Functions;
|
|
5045
5048
|
}
|
|
5046
5049
|
declare const initializeFirebase: (config: {
|
|
5047
5050
|
apiKey: string;
|
package/dist/index.js
CHANGED
|
@@ -705,17 +705,21 @@ var import_firestore = require("firebase/firestore");
|
|
|
705
705
|
var import_auth = require("firebase/auth");
|
|
706
706
|
var import_analytics = require("firebase/analytics");
|
|
707
707
|
var import_react_native = require("react-native");
|
|
708
|
+
var import_storage = require("firebase/storage");
|
|
709
|
+
var import_functions = require("firebase/functions");
|
|
708
710
|
var firebaseInstance = null;
|
|
709
711
|
var initializeFirebase = (config) => {
|
|
710
712
|
if (!firebaseInstance) {
|
|
711
713
|
const app = (0, import_app.initializeApp)(config);
|
|
712
714
|
const db = (0, import_firestore.getFirestore)(app);
|
|
713
715
|
const auth = (0, import_auth.getAuth)(app);
|
|
716
|
+
const storage = (0, import_storage.getStorage)(app);
|
|
717
|
+
const functions = (0, import_functions.getFunctions)(app);
|
|
714
718
|
let analytics = null;
|
|
715
719
|
if (typeof window !== "undefined" && import_react_native.Platform.OS === "web") {
|
|
716
720
|
analytics = (0, import_analytics.getAnalytics)(app);
|
|
717
721
|
}
|
|
718
|
-
firebaseInstance = { app, db, auth, analytics };
|
|
722
|
+
firebaseInstance = { app, db, auth, analytics, storage, functions };
|
|
719
723
|
}
|
|
720
724
|
return firebaseInstance;
|
|
721
725
|
};
|
|
@@ -1061,13 +1065,13 @@ var FirebaseErrorCode = /* @__PURE__ */ ((FirebaseErrorCode2) => {
|
|
|
1061
1065
|
})(FirebaseErrorCode || {});
|
|
1062
1066
|
|
|
1063
1067
|
// src/services/base.service.ts
|
|
1064
|
-
var
|
|
1068
|
+
var import_storage2 = require("firebase/storage");
|
|
1065
1069
|
var BaseService = class {
|
|
1066
1070
|
constructor(db, auth, app) {
|
|
1067
1071
|
this.db = db;
|
|
1068
1072
|
this.auth = auth;
|
|
1069
1073
|
this.app = app;
|
|
1070
|
-
this.storage = (0,
|
|
1074
|
+
this.storage = (0, import_storage2.getStorage)(app);
|
|
1071
1075
|
}
|
|
1072
1076
|
/**
|
|
1073
1077
|
* Generiše jedinstveni ID za dokumente
|
|
@@ -1188,7 +1192,7 @@ var import_firestore11 = require("firebase/firestore");
|
|
|
1188
1192
|
|
|
1189
1193
|
// src/services/patient/utils/profile.utils.ts
|
|
1190
1194
|
var import_firestore6 = require("firebase/firestore");
|
|
1191
|
-
var
|
|
1195
|
+
var import_storage3 = require("firebase/storage");
|
|
1192
1196
|
var import_zod8 = require("zod");
|
|
1193
1197
|
|
|
1194
1198
|
// src/types/patient/medical-info.types.ts
|
|
@@ -2116,9 +2120,9 @@ var updatePatientProfileByUserRefUtil = async (db, userRef, data) => {
|
|
|
2116
2120
|
}
|
|
2117
2121
|
};
|
|
2118
2122
|
var uploadProfilePhotoUtil = async (storage, patientId, file) => {
|
|
2119
|
-
const photoRef = (0,
|
|
2120
|
-
await (0,
|
|
2121
|
-
return (0,
|
|
2123
|
+
const photoRef = (0, import_storage3.ref)(storage, `patient-photos/${patientId}/profile-photo`);
|
|
2124
|
+
await (0, import_storage3.uploadBytes)(photoRef, file);
|
|
2125
|
+
return (0, import_storage3.getDownloadURL)(photoRef);
|
|
2122
2126
|
};
|
|
2123
2127
|
var updateProfilePhotoUtil = async (storage, db, patientId, file) => {
|
|
2124
2128
|
const patientDoc = await (0, import_firestore6.getDoc)(getPatientDocRef(db, patientId));
|
|
@@ -2126,8 +2130,8 @@ var updateProfilePhotoUtil = async (storage, db, patientId, file) => {
|
|
|
2126
2130
|
const patientData = patientDoc.data();
|
|
2127
2131
|
if (patientData.profilePhoto) {
|
|
2128
2132
|
try {
|
|
2129
|
-
const oldPhotoRef = (0,
|
|
2130
|
-
await (0,
|
|
2133
|
+
const oldPhotoRef = (0, import_storage3.ref)(storage, patientData.profilePhoto);
|
|
2134
|
+
await (0, import_storage3.deleteObject)(oldPhotoRef);
|
|
2131
2135
|
} catch (error) {
|
|
2132
2136
|
console.warn("Failed to delete old profile photo:", error);
|
|
2133
2137
|
}
|
|
@@ -2145,8 +2149,8 @@ var deleteProfilePhotoUtil = async (storage, db, patientId) => {
|
|
|
2145
2149
|
const patientData = patientDoc.data();
|
|
2146
2150
|
if (patientData.profilePhoto) {
|
|
2147
2151
|
try {
|
|
2148
|
-
const photoRef = (0,
|
|
2149
|
-
await (0,
|
|
2152
|
+
const photoRef = (0, import_storage3.ref)(storage, patientData.profilePhoto);
|
|
2153
|
+
await (0, import_storage3.deleteObject)(photoRef);
|
|
2150
2154
|
} catch (error) {
|
|
2151
2155
|
console.warn("Failed to delete profile photo:", error);
|
|
2152
2156
|
}
|
|
@@ -5130,7 +5134,7 @@ var import_geofire_common3 = require("geofire-common");
|
|
|
5130
5134
|
var import_zod16 = require("zod");
|
|
5131
5135
|
|
|
5132
5136
|
// src/services/clinic/utils/photos.utils.ts
|
|
5133
|
-
var
|
|
5137
|
+
var import_storage4 = require("firebase/storage");
|
|
5134
5138
|
async function uploadPhoto(photo, entityType, entityId, photoType, app, fileName) {
|
|
5135
5139
|
if (!photo || typeof photo !== "string" || !photo.startsWith("data:")) {
|
|
5136
5140
|
return photo;
|
|
@@ -5139,9 +5143,9 @@ async function uploadPhoto(photo, entityType, entityId, photoType, app, fileName
|
|
|
5139
5143
|
console.log(
|
|
5140
5144
|
`[PHOTO_UTILS] Uploading ${photoType} for ${entityType}/${entityId}`
|
|
5141
5145
|
);
|
|
5142
|
-
const storage = (0,
|
|
5146
|
+
const storage = (0, import_storage4.getStorage)(app);
|
|
5143
5147
|
const storageFileName = fileName || `${photoType}-${Date.now()}`;
|
|
5144
|
-
const storageRef = (0,
|
|
5148
|
+
const storageRef = (0, import_storage4.ref)(
|
|
5145
5149
|
storage,
|
|
5146
5150
|
`${entityType}/${entityId}/${storageFileName}`
|
|
5147
5151
|
);
|
|
@@ -5153,8 +5157,8 @@ async function uploadPhoto(photo, entityType, entityId, photoType, app, fileName
|
|
|
5153
5157
|
byteArrays.push(byteCharacters.charCodeAt(i));
|
|
5154
5158
|
}
|
|
5155
5159
|
const blob = new Blob([new Uint8Array(byteArrays)], { type: contentType });
|
|
5156
|
-
await (0,
|
|
5157
|
-
const downloadUrl = await (0,
|
|
5160
|
+
await (0, import_storage4.uploadBytes)(storageRef, blob, { contentType });
|
|
5161
|
+
const downloadUrl = await (0, import_storage4.getDownloadURL)(storageRef);
|
|
5158
5162
|
console.log(`[PHOTO_UTILS] ${photoType} uploaded successfully`, {
|
|
5159
5163
|
downloadUrl
|
|
5160
5164
|
});
|
|
@@ -12163,7 +12167,7 @@ var ReviewService = class extends BaseService {
|
|
|
12163
12167
|
|
|
12164
12168
|
// src/services/appointment/appointment.service.ts
|
|
12165
12169
|
var import_firestore40 = require("firebase/firestore");
|
|
12166
|
-
var
|
|
12170
|
+
var import_functions2 = require("firebase/functions");
|
|
12167
12171
|
|
|
12168
12172
|
// src/services/appointment/utils/appointment.utils.ts
|
|
12169
12173
|
var import_firestore39 = require("firebase/firestore");
|
|
@@ -12377,7 +12381,7 @@ var AppointmentService = class extends BaseService {
|
|
|
12377
12381
|
this.practitionerService = practitionerService;
|
|
12378
12382
|
this.clinicService = clinicService;
|
|
12379
12383
|
this.filledDocumentService = filledDocumentService;
|
|
12380
|
-
this.functions = (0,
|
|
12384
|
+
this.functions = (0, import_functions2.getFunctions)(app, "europe-west6");
|
|
12381
12385
|
}
|
|
12382
12386
|
/**
|
|
12383
12387
|
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
package/dist/index.mjs
CHANGED
|
@@ -471,17 +471,21 @@ import { getFirestore } from "firebase/firestore";
|
|
|
471
471
|
import { getAuth } from "firebase/auth";
|
|
472
472
|
import { getAnalytics } from "firebase/analytics";
|
|
473
473
|
import { Platform } from "react-native";
|
|
474
|
+
import { getStorage } from "firebase/storage";
|
|
475
|
+
import { getFunctions } from "firebase/functions";
|
|
474
476
|
var firebaseInstance = null;
|
|
475
477
|
var initializeFirebase = (config) => {
|
|
476
478
|
if (!firebaseInstance) {
|
|
477
479
|
const app = initializeApp(config);
|
|
478
480
|
const db = getFirestore(app);
|
|
479
481
|
const auth = getAuth(app);
|
|
482
|
+
const storage = getStorage(app);
|
|
483
|
+
const functions = getFunctions(app);
|
|
480
484
|
let analytics = null;
|
|
481
485
|
if (typeof window !== "undefined" && Platform.OS === "web") {
|
|
482
486
|
analytics = getAnalytics(app);
|
|
483
487
|
}
|
|
484
|
-
firebaseInstance = { app, db, auth, analytics };
|
|
488
|
+
firebaseInstance = { app, db, auth, analytics, storage, functions };
|
|
485
489
|
}
|
|
486
490
|
return firebaseInstance;
|
|
487
491
|
};
|
|
@@ -846,13 +850,13 @@ var FirebaseErrorCode = /* @__PURE__ */ ((FirebaseErrorCode2) => {
|
|
|
846
850
|
})(FirebaseErrorCode || {});
|
|
847
851
|
|
|
848
852
|
// src/services/base.service.ts
|
|
849
|
-
import { getStorage } from "firebase/storage";
|
|
853
|
+
import { getStorage as getStorage2 } from "firebase/storage";
|
|
850
854
|
var BaseService = class {
|
|
851
855
|
constructor(db, auth, app) {
|
|
852
856
|
this.db = db;
|
|
853
857
|
this.auth = auth;
|
|
854
858
|
this.app = app;
|
|
855
|
-
this.storage =
|
|
859
|
+
this.storage = getStorage2(app);
|
|
856
860
|
}
|
|
857
861
|
/**
|
|
858
862
|
* Generiše jedinstveni ID za dokumente
|
|
@@ -5036,7 +5040,7 @@ import { z as z16 } from "zod";
|
|
|
5036
5040
|
|
|
5037
5041
|
// src/services/clinic/utils/photos.utils.ts
|
|
5038
5042
|
import {
|
|
5039
|
-
getStorage as
|
|
5043
|
+
getStorage as getStorage3,
|
|
5040
5044
|
ref as ref2,
|
|
5041
5045
|
uploadBytes as uploadBytes2,
|
|
5042
5046
|
getDownloadURL as getDownloadURL2,
|
|
@@ -5050,7 +5054,7 @@ async function uploadPhoto(photo, entityType, entityId, photoType, app, fileName
|
|
|
5050
5054
|
console.log(
|
|
5051
5055
|
`[PHOTO_UTILS] Uploading ${photoType} for ${entityType}/${entityId}`
|
|
5052
5056
|
);
|
|
5053
|
-
const storage =
|
|
5057
|
+
const storage = getStorage3(app);
|
|
5054
5058
|
const storageFileName = fileName || `${photoType}-${Date.now()}`;
|
|
5055
5059
|
const storageRef = ref2(
|
|
5056
5060
|
storage,
|
|
@@ -12258,7 +12262,7 @@ import {
|
|
|
12258
12262
|
startAfter as startAfter11,
|
|
12259
12263
|
getDocs as getDocs26
|
|
12260
12264
|
} from "firebase/firestore";
|
|
12261
|
-
import { getFunctions } from "firebase/functions";
|
|
12265
|
+
import { getFunctions as getFunctions2 } from "firebase/functions";
|
|
12262
12266
|
|
|
12263
12267
|
// src/services/appointment/utils/appointment.utils.ts
|
|
12264
12268
|
import {
|
|
@@ -12486,7 +12490,7 @@ var AppointmentService = class extends BaseService {
|
|
|
12486
12490
|
this.practitionerService = practitionerService;
|
|
12487
12491
|
this.clinicService = clinicService;
|
|
12488
12492
|
this.filledDocumentService = filledDocumentService;
|
|
12489
|
-
this.functions =
|
|
12493
|
+
this.functions = getFunctions2(app, "europe-west6");
|
|
12490
12494
|
}
|
|
12491
12495
|
/**
|
|
12492
12496
|
* Gets available booking slots for a specific clinic, practitioner, and procedure using HTTP request.
|
package/package.json
CHANGED
|
@@ -508,8 +508,29 @@ export class AppointmentAggregationService {
|
|
|
508
508
|
const batch = this.db.batch();
|
|
509
509
|
let instancesCreatedCount = 0;
|
|
510
510
|
|
|
511
|
+
// Log more details about the pre-requirements
|
|
512
|
+
Logger.info(
|
|
513
|
+
`[AggService] Found ${
|
|
514
|
+
appointment.preProcedureRequirements.length
|
|
515
|
+
} pre-requirements to process: ${JSON.stringify(
|
|
516
|
+
appointment.preProcedureRequirements.map((r) => ({
|
|
517
|
+
id: r.id,
|
|
518
|
+
name: r.name,
|
|
519
|
+
type: r.type,
|
|
520
|
+
isActive: r.isActive,
|
|
521
|
+
hasTimeframe: !!r.timeframe,
|
|
522
|
+
notifyAtLength: r.timeframe?.notifyAt?.length || 0,
|
|
523
|
+
}))
|
|
524
|
+
)}`
|
|
525
|
+
);
|
|
526
|
+
|
|
511
527
|
for (const template of appointment.preProcedureRequirements) {
|
|
512
|
-
if (!template)
|
|
528
|
+
if (!template) {
|
|
529
|
+
Logger.warn(
|
|
530
|
+
`[AggService] Found null/undefined template in preProcedureRequirements array`
|
|
531
|
+
);
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
513
534
|
|
|
514
535
|
// Ensure it's an active, PRE-type requirement
|
|
515
536
|
if (template.type !== RequirementType.PRE || !template.isActive) {
|
|
@@ -519,6 +540,16 @@ export class AppointmentAggregationService {
|
|
|
519
540
|
continue;
|
|
520
541
|
}
|
|
521
542
|
|
|
543
|
+
if (
|
|
544
|
+
!template.timeframe ||
|
|
545
|
+
!template.timeframe.notifyAt ||
|
|
546
|
+
template.timeframe.notifyAt.length === 0
|
|
547
|
+
) {
|
|
548
|
+
Logger.warn(
|
|
549
|
+
`[AggService] Template ${template.id} (${template.name}) has no timeframe.notifyAt values. Creating with empty instructions.`
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
|
|
522
553
|
Logger.debug(
|
|
523
554
|
`[AggService] Processing template ${template.id} (${template.name}) for appt ${appointment.id}`
|
|
524
555
|
);
|
|
@@ -529,6 +560,11 @@ export class AppointmentAggregationService {
|
|
|
529
560
|
.collection(PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME)
|
|
530
561
|
.doc(); // Auto-generate ID for the new instance
|
|
531
562
|
|
|
563
|
+
// Log the path for debugging
|
|
564
|
+
Logger.debug(
|
|
565
|
+
`[AggService] Created doc reference: ${newInstanceRef.path}`
|
|
566
|
+
);
|
|
567
|
+
|
|
532
568
|
const instructions: PatientRequirementInstruction[] = (
|
|
533
569
|
template.timeframe?.notifyAt || []
|
|
534
570
|
).map((notifyAtValue) => {
|
|
@@ -566,8 +602,6 @@ export class AppointmentAggregationService {
|
|
|
566
602
|
originalNotifyAtValue: notifyAtValue,
|
|
567
603
|
originalTimeframeUnit: template.timeframe.unit,
|
|
568
604
|
updatedAt: admin.firestore.Timestamp.now() as any, // Use current server timestamp
|
|
569
|
-
notificationId: undefined,
|
|
570
|
-
actionTakenAt: undefined,
|
|
571
605
|
};
|
|
572
606
|
return instructionObject;
|
|
573
607
|
});
|
|
@@ -587,6 +621,17 @@ export class AppointmentAggregationService {
|
|
|
587
621
|
updatedAt: admin.firestore.FieldValue.serverTimestamp() as any,
|
|
588
622
|
};
|
|
589
623
|
|
|
624
|
+
// Log the data being set
|
|
625
|
+
Logger.debug(
|
|
626
|
+
`[AggService] Setting data for requirement: ${JSON.stringify({
|
|
627
|
+
id: newInstanceRef.id,
|
|
628
|
+
patientId: newInstanceData.patientId,
|
|
629
|
+
appointmentId: newInstanceData.appointmentId,
|
|
630
|
+
requirementName: newInstanceData.requirementName,
|
|
631
|
+
instructionsCount: newInstanceData.instructions.length,
|
|
632
|
+
})}`
|
|
633
|
+
);
|
|
634
|
+
|
|
590
635
|
batch.set(newInstanceRef, newInstanceData);
|
|
591
636
|
instancesCreatedCount++;
|
|
592
637
|
Logger.debug(
|
|
@@ -595,10 +640,18 @@ export class AppointmentAggregationService {
|
|
|
595
640
|
}
|
|
596
641
|
|
|
597
642
|
if (instancesCreatedCount > 0) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
643
|
+
try {
|
|
644
|
+
await batch.commit();
|
|
645
|
+
Logger.info(
|
|
646
|
+
`[AggService] Successfully created ${instancesCreatedCount} PRE_APPOINTMENT requirement instances for appointment ${appointment.id}.`
|
|
647
|
+
);
|
|
648
|
+
} catch (commitError) {
|
|
649
|
+
Logger.error(
|
|
650
|
+
`[AggService] Error committing batch for PRE_APPOINTMENT requirement instances for appointment ${appointment.id}:`,
|
|
651
|
+
commitError
|
|
652
|
+
);
|
|
653
|
+
throw commitError; // Re-throw to ensure the caller knows there was a problem
|
|
654
|
+
}
|
|
602
655
|
} else {
|
|
603
656
|
Logger.info(
|
|
604
657
|
`[AggService] No new PRE_APPOINTMENT requirement instances were prepared for batch commit for appointment ${appointment.id}.`
|
|
@@ -609,8 +662,7 @@ export class AppointmentAggregationService {
|
|
|
609
662
|
`[AggService] Error creating PRE_APPOINTMENT requirement instances for appointment ${appointment.id}:`,
|
|
610
663
|
error
|
|
611
664
|
);
|
|
612
|
-
|
|
613
|
-
// For now, just logging.
|
|
665
|
+
throw error; // Re-throw to ensure the caller knows there was a problem
|
|
614
666
|
}
|
|
615
667
|
}
|
|
616
668
|
|