@blackcode_sa/metaestetics-api 1.7.26 → 1.7.28
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 +13 -1
- package/dist/admin/index.d.ts +13 -1
- package/dist/admin/index.js +137 -6
- package/dist/admin/index.mjs +137 -6
- package/dist/backoffice/index.d.mts +1 -0
- package/dist/backoffice/index.d.ts +1 -0
- package/dist/index.d.mts +388 -146
- package/dist/index.d.ts +388 -146
- package/dist/index.js +809 -350
- package/dist/index.mjs +716 -260
- package/package.json +1 -1
- package/src/admin/aggregation/procedure/procedure.aggregation.service.ts +202 -8
- package/src/index.ts +3 -0
- package/src/recommender/admin/index.ts +1 -0
- package/src/recommender/admin/services/recommender.service.admin.ts +5 -0
- package/src/recommender/front/index.ts +1 -0
- package/src/recommender/front/services/onboarding.service.ts +5 -0
- package/src/recommender/front/services/recommender.service.ts +3 -0
- package/src/recommender/index.ts +1 -0
- package/src/services/calendar/calendar.v3.service.ts +313 -0
- package/src/services/practitioner/practitioner.service.ts +178 -1
- package/src/services/procedure/procedure.service.ts +141 -0
- package/src/types/calendar/index.ts +29 -0
- package/src/types/practitioner/index.ts +3 -0
- package/src/validations/calendar.schema.ts +41 -0
- package/src/validations/practitioner.schema.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __export(index_exports, {
|
|
|
46
46
|
CalendarEventStatus: () => CalendarEventStatus,
|
|
47
47
|
CalendarEventType: () => CalendarEventType,
|
|
48
48
|
CalendarServiceV2: () => CalendarServiceV2,
|
|
49
|
+
CalendarServiceV3: () => CalendarServiceV3,
|
|
49
50
|
CalendarSyncStatus: () => CalendarSyncStatus,
|
|
50
51
|
CategoryService: () => CategoryService,
|
|
51
52
|
CertificationLevel: () => CertificationLevel,
|
|
@@ -152,6 +153,7 @@ __export(index_exports, {
|
|
|
152
153
|
contraindicationSchema: () => contraindicationSchema,
|
|
153
154
|
createAdminTokenSchema: () => createAdminTokenSchema,
|
|
154
155
|
createAppointmentSchema: () => createAppointmentSchema,
|
|
156
|
+
createBlockingEventSchema: () => createBlockingEventSchema,
|
|
155
157
|
createCalendarEventSchema: () => createCalendarEventSchema,
|
|
156
158
|
createClinicAdminSchema: () => createClinicAdminSchema,
|
|
157
159
|
createClinicGroupSchema: () => createClinicGroupSchema,
|
|
@@ -222,6 +224,7 @@ __export(index_exports, {
|
|
|
222
224
|
updateAllergySchema: () => updateAllergySchema,
|
|
223
225
|
updateAppointmentSchema: () => updateAppointmentSchema,
|
|
224
226
|
updateBlockingConditionSchema: () => updateBlockingConditionSchema,
|
|
227
|
+
updateBlockingEventSchema: () => updateBlockingEventSchema,
|
|
225
228
|
updateCalendarEventSchema: () => updateCalendarEventSchema,
|
|
226
229
|
updateClinicAdminSchema: () => updateClinicAdminSchema,
|
|
227
230
|
updateClinicGroupSchema: () => updateClinicGroupSchema,
|
|
@@ -1483,7 +1486,7 @@ var MediaService = class extends BaseService {
|
|
|
1483
1486
|
try {
|
|
1484
1487
|
const querySnapshot = await (0, import_firestore3.getDocs)(finalQuery);
|
|
1485
1488
|
const mediaList = querySnapshot.docs.map(
|
|
1486
|
-
(
|
|
1489
|
+
(doc36) => doc36.data()
|
|
1487
1490
|
);
|
|
1488
1491
|
console.log(`[MediaService] Found ${mediaList.length} media items.`);
|
|
1489
1492
|
return mediaList;
|
|
@@ -2120,8 +2123,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
|
|
|
2120
2123
|
}
|
|
2121
2124
|
const patientsSnapshot = await (0, import_firestore8.getDocs)(q);
|
|
2122
2125
|
const patients = [];
|
|
2123
|
-
patientsSnapshot.forEach((
|
|
2124
|
-
patients.push(
|
|
2126
|
+
patientsSnapshot.forEach((doc36) => {
|
|
2127
|
+
patients.push(doc36.data());
|
|
2125
2128
|
});
|
|
2126
2129
|
console.log(
|
|
2127
2130
|
`[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
|
|
@@ -2351,9 +2354,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
2351
2354
|
});
|
|
2352
2355
|
};
|
|
2353
2356
|
var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
|
|
2354
|
-
const
|
|
2355
|
-
if (!
|
|
2356
|
-
const medicalInfo =
|
|
2357
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2358
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2359
|
+
const medicalInfo = doc36.data();
|
|
2357
2360
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
2358
2361
|
throw new Error("Invalid allergy index");
|
|
2359
2362
|
}
|
|
@@ -2378,9 +2381,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
2378
2381
|
var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
2379
2382
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
2380
2383
|
const { conditionIndex, ...updateData } = validatedData;
|
|
2381
|
-
const
|
|
2382
|
-
if (!
|
|
2383
|
-
const medicalInfo =
|
|
2384
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2385
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2386
|
+
const medicalInfo = doc36.data();
|
|
2384
2387
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
2385
2388
|
throw new Error("Invalid blocking condition index");
|
|
2386
2389
|
}
|
|
@@ -2396,9 +2399,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
2396
2399
|
});
|
|
2397
2400
|
};
|
|
2398
2401
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
|
|
2399
|
-
const
|
|
2400
|
-
if (!
|
|
2401
|
-
const medicalInfo =
|
|
2402
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2403
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2404
|
+
const medicalInfo = doc36.data();
|
|
2402
2405
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
2403
2406
|
throw new Error("Invalid blocking condition index");
|
|
2404
2407
|
}
|
|
@@ -2423,9 +2426,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
2423
2426
|
var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
2424
2427
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
2425
2428
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
2426
|
-
const
|
|
2427
|
-
if (!
|
|
2428
|
-
const medicalInfo =
|
|
2429
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2430
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2431
|
+
const medicalInfo = doc36.data();
|
|
2429
2432
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
2430
2433
|
throw new Error("Invalid contraindication index");
|
|
2431
2434
|
}
|
|
@@ -2441,9 +2444,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
2441
2444
|
});
|
|
2442
2445
|
};
|
|
2443
2446
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
|
|
2444
|
-
const
|
|
2445
|
-
if (!
|
|
2446
|
-
const medicalInfo =
|
|
2447
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2448
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2449
|
+
const medicalInfo = doc36.data();
|
|
2447
2450
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
2448
2451
|
throw new Error("Invalid contraindication index");
|
|
2449
2452
|
}
|
|
@@ -2468,9 +2471,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
2468
2471
|
var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
2469
2472
|
const validatedData = updateMedicationSchema.parse(data);
|
|
2470
2473
|
const { medicationIndex, ...updateData } = validatedData;
|
|
2471
|
-
const
|
|
2472
|
-
if (!
|
|
2473
|
-
const medicalInfo =
|
|
2474
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2475
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2476
|
+
const medicalInfo = doc36.data();
|
|
2474
2477
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
2475
2478
|
throw new Error("Invalid medication index");
|
|
2476
2479
|
}
|
|
@@ -2486,9 +2489,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
2486
2489
|
});
|
|
2487
2490
|
};
|
|
2488
2491
|
var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
|
|
2489
|
-
const
|
|
2490
|
-
if (!
|
|
2491
|
-
const medicalInfo =
|
|
2492
|
+
const doc36 = await (0, import_firestore9.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
2493
|
+
if (!doc36.exists()) throw new Error("Medical info not found");
|
|
2494
|
+
const medicalInfo = doc36.data();
|
|
2492
2495
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
2493
2496
|
throw new Error("Invalid medication index");
|
|
2494
2497
|
}
|
|
@@ -2767,7 +2770,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
2767
2770
|
const finalQuery = (0, import_firestore10.query)(patientsCollectionRef, ...constraints);
|
|
2768
2771
|
const querySnapshot = await (0, import_firestore10.getDocs)(finalQuery);
|
|
2769
2772
|
const patients = querySnapshot.docs.map(
|
|
2770
|
-
(
|
|
2773
|
+
(doc36) => doc36.data()
|
|
2771
2774
|
);
|
|
2772
2775
|
console.log(
|
|
2773
2776
|
`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
|
|
@@ -2799,8 +2802,8 @@ var getAllPatientsUtil = async (db, options) => {
|
|
|
2799
2802
|
}
|
|
2800
2803
|
const patientsSnapshot = await (0, import_firestore10.getDocs)(q);
|
|
2801
2804
|
const patients = [];
|
|
2802
|
-
patientsSnapshot.forEach((
|
|
2803
|
-
patients.push(
|
|
2805
|
+
patientsSnapshot.forEach((doc36) => {
|
|
2806
|
+
patients.push(doc36.data());
|
|
2804
2807
|
});
|
|
2805
2808
|
console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
|
|
2806
2809
|
return patients;
|
|
@@ -3012,8 +3015,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
|
|
|
3012
3015
|
}
|
|
3013
3016
|
const patientsSnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3014
3017
|
const patients = [];
|
|
3015
|
-
patientsSnapshot.forEach((
|
|
3016
|
-
patients.push(
|
|
3018
|
+
patientsSnapshot.forEach((doc36) => {
|
|
3019
|
+
patients.push(doc36.data());
|
|
3017
3020
|
});
|
|
3018
3021
|
console.log(
|
|
3019
3022
|
`[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
|
|
@@ -4281,7 +4284,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
4281
4284
|
(0, import_firestore16.where)("clinicGroupId", "==", clinicGroupId)
|
|
4282
4285
|
);
|
|
4283
4286
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
4284
|
-
return querySnapshot.docs.map((
|
|
4287
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
4285
4288
|
}
|
|
4286
4289
|
async function updateClinicAdmin(db, adminId, data) {
|
|
4287
4290
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -4640,6 +4643,7 @@ var practitionerSchema = import_zod14.z.object({
|
|
|
4640
4643
|
clinicWorkingHours: import_zod14.z.array(practitionerClinicWorkingHoursSchema),
|
|
4641
4644
|
clinicsInfo: import_zod14.z.array(clinicInfoSchema),
|
|
4642
4645
|
procedures: import_zod14.z.array(import_zod14.z.string()),
|
|
4646
|
+
freeConsultations: import_zod14.z.record(import_zod14.z.string(), import_zod14.z.string()).optional().nullable(),
|
|
4643
4647
|
proceduresInfo: import_zod14.z.array(procedureSummaryInfoSchema),
|
|
4644
4648
|
reviewInfo: practitionerReviewInfoSchema,
|
|
4645
4649
|
isActive: import_zod14.z.boolean(),
|
|
@@ -4655,6 +4659,7 @@ var createPractitionerSchema = import_zod14.z.object({
|
|
|
4655
4659
|
clinics: import_zod14.z.array(import_zod14.z.string()).optional(),
|
|
4656
4660
|
clinicWorkingHours: import_zod14.z.array(practitionerClinicWorkingHoursSchema).optional(),
|
|
4657
4661
|
clinicsInfo: import_zod14.z.array(clinicInfoSchema).optional(),
|
|
4662
|
+
freeConsultations: import_zod14.z.record(import_zod14.z.string(), import_zod14.z.string()).optional().nullable(),
|
|
4658
4663
|
proceduresInfo: import_zod14.z.array(procedureSummaryInfoSchema).optional(),
|
|
4659
4664
|
isActive: import_zod14.z.boolean(),
|
|
4660
4665
|
isVerified: import_zod14.z.boolean(),
|
|
@@ -4666,6 +4671,7 @@ var createDraftPractitionerSchema = import_zod14.z.object({
|
|
|
4666
4671
|
clinics: import_zod14.z.array(import_zod14.z.string()).optional(),
|
|
4667
4672
|
clinicWorkingHours: import_zod14.z.array(practitionerClinicWorkingHoursSchema).optional(),
|
|
4668
4673
|
clinicsInfo: import_zod14.z.array(clinicInfoSchema).optional(),
|
|
4674
|
+
freeConsultations: import_zod14.z.record(import_zod14.z.string(), import_zod14.z.string()).optional().nullable(),
|
|
4669
4675
|
proceduresInfo: import_zod14.z.array(procedureSummaryInfoSchema).optional(),
|
|
4670
4676
|
isActive: import_zod14.z.boolean().optional().default(false),
|
|
4671
4677
|
isVerified: import_zod14.z.boolean().optional().default(false)
|
|
@@ -4710,9 +4716,10 @@ var practitionerSignupSchema = import_zod14.z.object({
|
|
|
4710
4716
|
var import_zod15 = require("zod");
|
|
4711
4717
|
var import_geofire_common2 = require("geofire-common");
|
|
4712
4718
|
var PractitionerService = class extends BaseService {
|
|
4713
|
-
constructor(db, auth, app, clinicService) {
|
|
4719
|
+
constructor(db, auth, app, clinicService, procedureService) {
|
|
4714
4720
|
super(db, auth, app);
|
|
4715
4721
|
this.clinicService = clinicService;
|
|
4722
|
+
this.procedureService = procedureService;
|
|
4716
4723
|
this.mediaService = new MediaService(db, auth, app);
|
|
4717
4724
|
}
|
|
4718
4725
|
getClinicService() {
|
|
@@ -4721,9 +4728,18 @@ var PractitionerService = class extends BaseService {
|
|
|
4721
4728
|
}
|
|
4722
4729
|
return this.clinicService;
|
|
4723
4730
|
}
|
|
4731
|
+
getProcedureService() {
|
|
4732
|
+
if (!this.procedureService) {
|
|
4733
|
+
throw new Error("Procedure service not initialized!");
|
|
4734
|
+
}
|
|
4735
|
+
return this.procedureService;
|
|
4736
|
+
}
|
|
4724
4737
|
setClinicService(clinicService) {
|
|
4725
4738
|
this.clinicService = clinicService;
|
|
4726
4739
|
}
|
|
4740
|
+
setProcedureService(procedureService) {
|
|
4741
|
+
this.procedureService = procedureService;
|
|
4742
|
+
}
|
|
4727
4743
|
/**
|
|
4728
4744
|
* Handles profile photo upload for practitioners
|
|
4729
4745
|
* @param profilePhoto - MediaResource (File, Blob, or URL string)
|
|
@@ -5018,7 +5034,7 @@ var PractitionerService = class extends BaseService {
|
|
|
5018
5034
|
(0, import_firestore18.where)("expiresAt", ">", import_firestore18.Timestamp.now())
|
|
5019
5035
|
);
|
|
5020
5036
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5021
|
-
return querySnapshot.docs.map((
|
|
5037
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
5022
5038
|
}
|
|
5023
5039
|
/**
|
|
5024
5040
|
* Gets a token by its string value and validates it
|
|
@@ -5128,7 +5144,7 @@ var PractitionerService = class extends BaseService {
|
|
|
5128
5144
|
(0, import_firestore18.where)("status", "==", "active" /* ACTIVE */)
|
|
5129
5145
|
);
|
|
5130
5146
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5131
|
-
return querySnapshot.docs.map((
|
|
5147
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
5132
5148
|
}
|
|
5133
5149
|
/**
|
|
5134
5150
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -5140,7 +5156,7 @@ var PractitionerService = class extends BaseService {
|
|
|
5140
5156
|
(0, import_firestore18.where)("isActive", "==", true)
|
|
5141
5157
|
);
|
|
5142
5158
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5143
|
-
return querySnapshot.docs.map((
|
|
5159
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
5144
5160
|
}
|
|
5145
5161
|
/**
|
|
5146
5162
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -5152,7 +5168,7 @@ var PractitionerService = class extends BaseService {
|
|
|
5152
5168
|
(0, import_firestore18.where)("status", "==", "draft" /* DRAFT */)
|
|
5153
5169
|
);
|
|
5154
5170
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5155
|
-
return querySnapshot.docs.map((
|
|
5171
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
5156
5172
|
}
|
|
5157
5173
|
/**
|
|
5158
5174
|
* Updates a practitioner
|
|
@@ -5366,7 +5382,7 @@ var PractitionerService = class extends BaseService {
|
|
|
5366
5382
|
);
|
|
5367
5383
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5368
5384
|
const practitioners = querySnapshot.docs.map(
|
|
5369
|
-
(
|
|
5385
|
+
(doc36) => doc36.data()
|
|
5370
5386
|
);
|
|
5371
5387
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
5372
5388
|
return {
|
|
@@ -5437,8 +5453,8 @@ var PractitionerService = class extends BaseService {
|
|
|
5437
5453
|
console.log(
|
|
5438
5454
|
`[PRACTITIONER_SERVICE] Found ${querySnapshot.docs.length} practitioners with base query`
|
|
5439
5455
|
);
|
|
5440
|
-
let practitioners = querySnapshot.docs.map((
|
|
5441
|
-
return { ...
|
|
5456
|
+
let practitioners = querySnapshot.docs.map((doc36) => {
|
|
5457
|
+
return { ...doc36.data(), id: doc36.id };
|
|
5442
5458
|
});
|
|
5443
5459
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
5444
5460
|
if (filters.nameSearch && filters.nameSearch.trim() !== "") {
|
|
@@ -5518,6 +5534,119 @@ var PractitionerService = class extends BaseService {
|
|
|
5518
5534
|
throw error;
|
|
5519
5535
|
}
|
|
5520
5536
|
}
|
|
5537
|
+
/**
|
|
5538
|
+
* Enables free consultation for a practitioner in a specific clinic
|
|
5539
|
+
* Creates a free consultation procedure with hardcoded parameters
|
|
5540
|
+
* @param practitionerId - ID of the practitioner
|
|
5541
|
+
* @param clinicId - ID of the clinic
|
|
5542
|
+
* @returns The created consultation procedure
|
|
5543
|
+
*/
|
|
5544
|
+
async EnableFreeConsultation(practitionerId, clinicId) {
|
|
5545
|
+
try {
|
|
5546
|
+
const practitioner = await this.getPractitioner(practitionerId);
|
|
5547
|
+
if (!practitioner) {
|
|
5548
|
+
throw new Error(`Practitioner ${practitionerId} not found`);
|
|
5549
|
+
}
|
|
5550
|
+
if (!practitioner.isActive || practitioner.status !== "active" /* ACTIVE */) {
|
|
5551
|
+
throw new Error(`Practitioner ${practitionerId} is not active`);
|
|
5552
|
+
}
|
|
5553
|
+
const clinic = await this.getClinicService().getClinic(clinicId);
|
|
5554
|
+
if (!clinic) {
|
|
5555
|
+
throw new Error(`Clinic ${clinicId} not found`);
|
|
5556
|
+
}
|
|
5557
|
+
if (!practitioner.clinics.includes(clinicId)) {
|
|
5558
|
+
throw new Error(
|
|
5559
|
+
`Practitioner ${practitionerId} is not associated with clinic ${clinicId}`
|
|
5560
|
+
);
|
|
5561
|
+
}
|
|
5562
|
+
const existingProcedures = await this.getProcedureService().getProceduresByPractitioner(
|
|
5563
|
+
practitionerId
|
|
5564
|
+
);
|
|
5565
|
+
const existingConsultation = existingProcedures.find(
|
|
5566
|
+
(procedure) => procedure.name === "Free Consultation" && procedure.clinicBranchId === clinicId && procedure.isActive
|
|
5567
|
+
);
|
|
5568
|
+
if (existingConsultation) {
|
|
5569
|
+
console.log(
|
|
5570
|
+
`Free consultation already exists for practitioner ${practitionerId} in clinic ${clinicId}`
|
|
5571
|
+
);
|
|
5572
|
+
return;
|
|
5573
|
+
}
|
|
5574
|
+
const consultationData = {
|
|
5575
|
+
name: "Free Consultation",
|
|
5576
|
+
description: "Free initial consultation to discuss treatment options and assess patient needs.",
|
|
5577
|
+
family: "aesthetics" /* AESTHETICS */,
|
|
5578
|
+
categoryId: "consultation",
|
|
5579
|
+
subcategoryId: "free-consultation",
|
|
5580
|
+
technologyId: "free-consultation-tech",
|
|
5581
|
+
price: 0,
|
|
5582
|
+
currency: "EUR" /* EUR */,
|
|
5583
|
+
pricingMeasure: "per_session" /* PER_SESSION */,
|
|
5584
|
+
duration: 30,
|
|
5585
|
+
// 30 minutes consultation
|
|
5586
|
+
practitionerId,
|
|
5587
|
+
clinicBranchId: clinicId,
|
|
5588
|
+
photos: []
|
|
5589
|
+
// No photos for consultation
|
|
5590
|
+
};
|
|
5591
|
+
await this.getProcedureService().createConsultationProcedure(
|
|
5592
|
+
consultationData
|
|
5593
|
+
);
|
|
5594
|
+
console.log(
|
|
5595
|
+
`Free consultation enabled for practitioner ${practitionerId} in clinic ${clinicId}`
|
|
5596
|
+
);
|
|
5597
|
+
} catch (error) {
|
|
5598
|
+
console.error(
|
|
5599
|
+
`Error enabling free consultation for practitioner ${practitionerId} in clinic ${clinicId}:`,
|
|
5600
|
+
error
|
|
5601
|
+
);
|
|
5602
|
+
throw error;
|
|
5603
|
+
}
|
|
5604
|
+
}
|
|
5605
|
+
/**
|
|
5606
|
+
* Disables free consultation for a practitioner in a specific clinic
|
|
5607
|
+
* Finds and deactivates the existing free consultation procedure
|
|
5608
|
+
* @param practitionerId - ID of the practitioner
|
|
5609
|
+
* @param clinicId - ID of the clinic
|
|
5610
|
+
*/
|
|
5611
|
+
async DisableFreeConsultation(practitionerId, clinicId) {
|
|
5612
|
+
try {
|
|
5613
|
+
const practitioner = await this.getPractitioner(practitionerId);
|
|
5614
|
+
if (!practitioner) {
|
|
5615
|
+
throw new Error(`Practitioner ${practitionerId} not found`);
|
|
5616
|
+
}
|
|
5617
|
+
const clinic = await this.getClinicService().getClinic(clinicId);
|
|
5618
|
+
if (!clinic) {
|
|
5619
|
+
throw new Error(`Clinic ${clinicId} not found`);
|
|
5620
|
+
}
|
|
5621
|
+
if (!practitioner.clinics.includes(clinicId)) {
|
|
5622
|
+
throw new Error(
|
|
5623
|
+
`Practitioner ${practitionerId} is not associated with clinic ${clinicId}`
|
|
5624
|
+
);
|
|
5625
|
+
}
|
|
5626
|
+
const existingProcedures = await this.getProcedureService().getProceduresByPractitioner(
|
|
5627
|
+
practitionerId
|
|
5628
|
+
);
|
|
5629
|
+
const freeConsultation = existingProcedures.find(
|
|
5630
|
+
(procedure) => procedure.name === "Free Consultation" && procedure.clinicBranchId === clinicId && procedure.isActive
|
|
5631
|
+
);
|
|
5632
|
+
if (!freeConsultation) {
|
|
5633
|
+
console.log(
|
|
5634
|
+
`No active free consultation found for practitioner ${practitionerId} in clinic ${clinicId}`
|
|
5635
|
+
);
|
|
5636
|
+
return;
|
|
5637
|
+
}
|
|
5638
|
+
await this.getProcedureService().deactivateProcedure(freeConsultation.id);
|
|
5639
|
+
console.log(
|
|
5640
|
+
`Free consultation disabled for practitioner ${practitionerId} in clinic ${clinicId}`
|
|
5641
|
+
);
|
|
5642
|
+
} catch (error) {
|
|
5643
|
+
console.error(
|
|
5644
|
+
`Error disabling free consultation for practitioner ${practitionerId} in clinic ${clinicId}:`,
|
|
5645
|
+
error
|
|
5646
|
+
);
|
|
5647
|
+
throw error;
|
|
5648
|
+
}
|
|
5649
|
+
}
|
|
5521
5650
|
};
|
|
5522
5651
|
|
|
5523
5652
|
// src/services/user.service.ts
|
|
@@ -5695,7 +5824,7 @@ var UserService = class extends BaseService {
|
|
|
5695
5824
|
];
|
|
5696
5825
|
const q = (0, import_firestore19.query)((0, import_firestore19.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
5697
5826
|
const querySnapshot = await (0, import_firestore19.getDocs)(q);
|
|
5698
|
-
const users = querySnapshot.docs.map((
|
|
5827
|
+
const users = querySnapshot.docs.map((doc36) => doc36.data());
|
|
5699
5828
|
return Promise.all(users.map((userData) => userSchema.parse(userData)));
|
|
5700
5829
|
}
|
|
5701
5830
|
/**
|
|
@@ -6059,7 +6188,7 @@ async function getAllActiveGroups(db) {
|
|
|
6059
6188
|
(0, import_firestore20.where)("isActive", "==", true)
|
|
6060
6189
|
);
|
|
6061
6190
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6062
|
-
return querySnapshot.docs.map((
|
|
6191
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
6063
6192
|
}
|
|
6064
6193
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
6065
6194
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -6499,7 +6628,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
6499
6628
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6500
6629
|
);
|
|
6501
6630
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6502
|
-
return querySnapshot.docs.map((
|
|
6631
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
6503
6632
|
}
|
|
6504
6633
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
6505
6634
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -6693,7 +6822,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
6693
6822
|
}
|
|
6694
6823
|
const q = (0, import_firestore21.query)((0, import_firestore21.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
6695
6824
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6696
|
-
return querySnapshot.docs.map((
|
|
6825
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
6697
6826
|
}
|
|
6698
6827
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
6699
6828
|
return getClinicsByAdmin(
|
|
@@ -6738,11 +6867,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
6738
6867
|
}
|
|
6739
6868
|
const clinicsSnapshot = await (0, import_firestore21.getDocs)(clinicsQuery);
|
|
6740
6869
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
6741
|
-
const clinics = clinicsSnapshot.docs.map((
|
|
6742
|
-
const data =
|
|
6870
|
+
const clinics = clinicsSnapshot.docs.map((doc36) => {
|
|
6871
|
+
const data = doc36.data();
|
|
6743
6872
|
return {
|
|
6744
6873
|
...data,
|
|
6745
|
-
id:
|
|
6874
|
+
id: doc36.id
|
|
6746
6875
|
};
|
|
6747
6876
|
});
|
|
6748
6877
|
return {
|
|
@@ -6769,8 +6898,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
6769
6898
|
];
|
|
6770
6899
|
const q = (0, import_firestore21.query)((0, import_firestore21.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
6771
6900
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6772
|
-
for (const
|
|
6773
|
-
const clinic =
|
|
6901
|
+
for (const doc36 of querySnapshot.docs) {
|
|
6902
|
+
const clinic = doc36.data();
|
|
6774
6903
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
6775
6904
|
[center.latitude, center.longitude],
|
|
6776
6905
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -6887,8 +7016,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
6887
7016
|
}
|
|
6888
7017
|
const q = (0, import_firestore22.query)((0, import_firestore22.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
6889
7018
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6890
|
-
for (const
|
|
6891
|
-
const clinic =
|
|
7019
|
+
for (const doc36 of querySnapshot.docs) {
|
|
7020
|
+
const clinic = doc36.data();
|
|
6892
7021
|
const distance = (0, import_geofire_common5.distanceBetween)(
|
|
6893
7022
|
[center.latitude, center.longitude],
|
|
6894
7023
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -6976,8 +7105,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
6976
7105
|
console.log(
|
|
6977
7106
|
`[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics in geo bound`
|
|
6978
7107
|
);
|
|
6979
|
-
for (const
|
|
6980
|
-
const clinic = { ...
|
|
7108
|
+
for (const doc36 of querySnapshot.docs) {
|
|
7109
|
+
const clinic = { ...doc36.data(), id: doc36.id };
|
|
6981
7110
|
const distance = (0, import_geofire_common6.distanceBetween)(
|
|
6982
7111
|
[center.latitude, center.longitude],
|
|
6983
7112
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -7033,8 +7162,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
7033
7162
|
console.log(
|
|
7034
7163
|
`[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics with regular query`
|
|
7035
7164
|
);
|
|
7036
|
-
const clinics = querySnapshot.docs.map((
|
|
7037
|
-
return { ...
|
|
7165
|
+
const clinics = querySnapshot.docs.map((doc36) => {
|
|
7166
|
+
return { ...doc36.data(), id: doc36.id };
|
|
7038
7167
|
});
|
|
7039
7168
|
let filteredClinics = clinics;
|
|
7040
7169
|
if (filters.center) {
|
|
@@ -8468,9 +8597,9 @@ var NotificationService = class extends BaseService {
|
|
|
8468
8597
|
(0, import_firestore26.orderBy)("notificationTime", "desc")
|
|
8469
8598
|
);
|
|
8470
8599
|
const querySnapshot = await (0, import_firestore26.getDocs)(q);
|
|
8471
|
-
return querySnapshot.docs.map((
|
|
8472
|
-
id:
|
|
8473
|
-
...
|
|
8600
|
+
return querySnapshot.docs.map((doc36) => ({
|
|
8601
|
+
id: doc36.id,
|
|
8602
|
+
...doc36.data()
|
|
8474
8603
|
}));
|
|
8475
8604
|
}
|
|
8476
8605
|
/**
|
|
@@ -8484,9 +8613,9 @@ var NotificationService = class extends BaseService {
|
|
|
8484
8613
|
(0, import_firestore26.orderBy)("notificationTime", "desc")
|
|
8485
8614
|
);
|
|
8486
8615
|
const querySnapshot = await (0, import_firestore26.getDocs)(q);
|
|
8487
|
-
return querySnapshot.docs.map((
|
|
8488
|
-
id:
|
|
8489
|
-
...
|
|
8616
|
+
return querySnapshot.docs.map((doc36) => ({
|
|
8617
|
+
id: doc36.id,
|
|
8618
|
+
...doc36.data()
|
|
8490
8619
|
}));
|
|
8491
8620
|
}
|
|
8492
8621
|
/**
|
|
@@ -8558,9 +8687,9 @@ var NotificationService = class extends BaseService {
|
|
|
8558
8687
|
(0, import_firestore26.orderBy)("notificationTime", "desc")
|
|
8559
8688
|
);
|
|
8560
8689
|
const querySnapshot = await (0, import_firestore26.getDocs)(q);
|
|
8561
|
-
return querySnapshot.docs.map((
|
|
8562
|
-
id:
|
|
8563
|
-
...
|
|
8690
|
+
return querySnapshot.docs.map((doc36) => ({
|
|
8691
|
+
id: doc36.id,
|
|
8692
|
+
...doc36.data()
|
|
8564
8693
|
}));
|
|
8565
8694
|
}
|
|
8566
8695
|
/**
|
|
@@ -8573,9 +8702,9 @@ var NotificationService = class extends BaseService {
|
|
|
8573
8702
|
(0, import_firestore26.orderBy)("notificationTime", "desc")
|
|
8574
8703
|
);
|
|
8575
8704
|
const querySnapshot = await (0, import_firestore26.getDocs)(q);
|
|
8576
|
-
return querySnapshot.docs.map((
|
|
8577
|
-
id:
|
|
8578
|
-
...
|
|
8705
|
+
return querySnapshot.docs.map((doc36) => ({
|
|
8706
|
+
id: doc36.id,
|
|
8707
|
+
...doc36.data()
|
|
8579
8708
|
}));
|
|
8580
8709
|
}
|
|
8581
8710
|
};
|
|
@@ -8856,7 +8985,7 @@ var ProcedureService = class extends BaseService {
|
|
|
8856
8985
|
(0, import_firestore27.where)("isActive", "==", true)
|
|
8857
8986
|
);
|
|
8858
8987
|
const snapshot = await (0, import_firestore27.getDocs)(q);
|
|
8859
|
-
return snapshot.docs.map((
|
|
8988
|
+
return snapshot.docs.map((doc36) => doc36.data());
|
|
8860
8989
|
}
|
|
8861
8990
|
/**
|
|
8862
8991
|
* Gets all procedures for a practitioner
|
|
@@ -8870,7 +8999,7 @@ var ProcedureService = class extends BaseService {
|
|
|
8870
8999
|
(0, import_firestore27.where)("isActive", "==", true)
|
|
8871
9000
|
);
|
|
8872
9001
|
const snapshot = await (0, import_firestore27.getDocs)(q);
|
|
8873
|
-
return snapshot.docs.map((
|
|
9002
|
+
return snapshot.docs.map((doc36) => doc36.data());
|
|
8874
9003
|
}
|
|
8875
9004
|
/**
|
|
8876
9005
|
* Updates a procedure
|
|
@@ -9082,11 +9211,11 @@ var ProcedureService = class extends BaseService {
|
|
|
9082
9211
|
}
|
|
9083
9212
|
const proceduresSnapshot = await (0, import_firestore27.getDocs)(proceduresQuery);
|
|
9084
9213
|
const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
|
|
9085
|
-
const procedures = proceduresSnapshot.docs.map((
|
|
9086
|
-
const data =
|
|
9214
|
+
const procedures = proceduresSnapshot.docs.map((doc36) => {
|
|
9215
|
+
const data = doc36.data();
|
|
9087
9216
|
return {
|
|
9088
9217
|
...data,
|
|
9089
|
-
id:
|
|
9218
|
+
id: doc36.id
|
|
9090
9219
|
// Ensure ID is present
|
|
9091
9220
|
};
|
|
9092
9221
|
});
|
|
@@ -9168,8 +9297,8 @@ var ProcedureService = class extends BaseService {
|
|
|
9168
9297
|
console.log(
|
|
9169
9298
|
`[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures in geo bound`
|
|
9170
9299
|
);
|
|
9171
|
-
for (const
|
|
9172
|
-
const procedure = { ...
|
|
9300
|
+
for (const doc36 of querySnapshot.docs) {
|
|
9301
|
+
const procedure = { ...doc36.data(), id: doc36.id };
|
|
9173
9302
|
const distance = (0, import_geofire_common8.distanceBetween)(
|
|
9174
9303
|
[center.latitude, center.longitude],
|
|
9175
9304
|
[
|
|
@@ -9220,8 +9349,8 @@ var ProcedureService = class extends BaseService {
|
|
|
9220
9349
|
console.log(
|
|
9221
9350
|
`[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures with regular query`
|
|
9222
9351
|
);
|
|
9223
|
-
const procedures = querySnapshot.docs.map((
|
|
9224
|
-
return { ...
|
|
9352
|
+
const procedures = querySnapshot.docs.map((doc36) => {
|
|
9353
|
+
return { ...doc36.data(), id: doc36.id };
|
|
9225
9354
|
});
|
|
9226
9355
|
if (filters.location) {
|
|
9227
9356
|
const center = filters.location;
|
|
@@ -9325,6 +9454,114 @@ var ProcedureService = class extends BaseService {
|
|
|
9325
9454
|
}
|
|
9326
9455
|
return filteredProcedures;
|
|
9327
9456
|
}
|
|
9457
|
+
/**
|
|
9458
|
+
* Creates a consultation procedure without requiring a product
|
|
9459
|
+
* This is a special method for consultation procedures that don't use products
|
|
9460
|
+
* @param data - The data for creating a consultation procedure (without productId)
|
|
9461
|
+
* @returns The created procedure
|
|
9462
|
+
*/
|
|
9463
|
+
async createConsultationProcedure(data) {
|
|
9464
|
+
var _a;
|
|
9465
|
+
const procedureId = this.generateId();
|
|
9466
|
+
const [category, subcategory, technology] = await Promise.all([
|
|
9467
|
+
this.categoryService.getById(data.categoryId),
|
|
9468
|
+
this.subcategoryService.getById(data.categoryId, data.subcategoryId),
|
|
9469
|
+
this.technologyService.getById(data.technologyId)
|
|
9470
|
+
]);
|
|
9471
|
+
if (!category || !subcategory || !technology) {
|
|
9472
|
+
throw new Error("One or more required base entities not found");
|
|
9473
|
+
}
|
|
9474
|
+
const clinicRef = (0, import_firestore27.doc)(this.db, CLINICS_COLLECTION, data.clinicBranchId);
|
|
9475
|
+
const clinicSnapshot = await (0, import_firestore27.getDoc)(clinicRef);
|
|
9476
|
+
if (!clinicSnapshot.exists()) {
|
|
9477
|
+
throw new Error(`Clinic with ID ${data.clinicBranchId} not found`);
|
|
9478
|
+
}
|
|
9479
|
+
const clinic = clinicSnapshot.data();
|
|
9480
|
+
const practitionerRef = (0, import_firestore27.doc)(
|
|
9481
|
+
this.db,
|
|
9482
|
+
PRACTITIONERS_COLLECTION,
|
|
9483
|
+
data.practitionerId
|
|
9484
|
+
);
|
|
9485
|
+
const practitionerSnapshot = await (0, import_firestore27.getDoc)(practitionerRef);
|
|
9486
|
+
if (!practitionerSnapshot.exists()) {
|
|
9487
|
+
throw new Error(`Practitioner with ID ${data.practitionerId} not found`);
|
|
9488
|
+
}
|
|
9489
|
+
const practitioner = practitionerSnapshot.data();
|
|
9490
|
+
let processedPhotos = [];
|
|
9491
|
+
if (data.photos && data.photos.length > 0) {
|
|
9492
|
+
processedPhotos = await this.processMediaArray(
|
|
9493
|
+
data.photos,
|
|
9494
|
+
procedureId,
|
|
9495
|
+
"procedure-photos"
|
|
9496
|
+
);
|
|
9497
|
+
}
|
|
9498
|
+
const clinicInfo = {
|
|
9499
|
+
id: clinicSnapshot.id,
|
|
9500
|
+
name: clinic.name,
|
|
9501
|
+
description: clinic.description || "",
|
|
9502
|
+
featuredPhoto: clinic.featuredPhotos && clinic.featuredPhotos.length > 0 ? typeof clinic.featuredPhotos[0] === "string" ? clinic.featuredPhotos[0] : "" : typeof clinic.coverPhoto === "string" ? clinic.coverPhoto : "",
|
|
9503
|
+
location: clinic.location,
|
|
9504
|
+
contactInfo: clinic.contactInfo
|
|
9505
|
+
};
|
|
9506
|
+
const doctorInfo = {
|
|
9507
|
+
id: practitionerSnapshot.id,
|
|
9508
|
+
name: `${practitioner.basicInfo.firstName} ${practitioner.basicInfo.lastName}`,
|
|
9509
|
+
description: practitioner.basicInfo.bio || "",
|
|
9510
|
+
photo: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : "",
|
|
9511
|
+
rating: ((_a = practitioner.reviewInfo) == null ? void 0 : _a.averageRating) || 0,
|
|
9512
|
+
services: practitioner.procedures || []
|
|
9513
|
+
};
|
|
9514
|
+
const consultationProduct = {
|
|
9515
|
+
id: "consultation-no-product",
|
|
9516
|
+
name: "No Product Required",
|
|
9517
|
+
description: "Consultation procedures do not require specific products",
|
|
9518
|
+
brandId: "consultation-brand",
|
|
9519
|
+
brandName: "Consultation",
|
|
9520
|
+
technologyId: data.technologyId,
|
|
9521
|
+
technologyName: technology.name,
|
|
9522
|
+
isActive: true,
|
|
9523
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
9524
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
9525
|
+
};
|
|
9526
|
+
const newProcedure = {
|
|
9527
|
+
id: procedureId,
|
|
9528
|
+
...data,
|
|
9529
|
+
photos: processedPhotos,
|
|
9530
|
+
category,
|
|
9531
|
+
subcategory,
|
|
9532
|
+
technology,
|
|
9533
|
+
product: consultationProduct,
|
|
9534
|
+
// Use placeholder product
|
|
9535
|
+
blockingConditions: technology.blockingConditions,
|
|
9536
|
+
contraindications: technology.contraindications || [],
|
|
9537
|
+
treatmentBenefits: technology.benefits,
|
|
9538
|
+
preRequirements: technology.requirements.pre,
|
|
9539
|
+
postRequirements: technology.requirements.post,
|
|
9540
|
+
certificationRequirement: technology.certificationRequirement,
|
|
9541
|
+
documentationTemplates: (technology == null ? void 0 : technology.documentationTemplates) || [],
|
|
9542
|
+
clinicInfo,
|
|
9543
|
+
doctorInfo,
|
|
9544
|
+
reviewInfo: {
|
|
9545
|
+
totalReviews: 0,
|
|
9546
|
+
averageRating: 0,
|
|
9547
|
+
effectivenessOfTreatment: 0,
|
|
9548
|
+
outcomeExplanation: 0,
|
|
9549
|
+
painManagement: 0,
|
|
9550
|
+
followUpCare: 0,
|
|
9551
|
+
valueForMoney: 0,
|
|
9552
|
+
recommendationPercentage: 0
|
|
9553
|
+
},
|
|
9554
|
+
isActive: true
|
|
9555
|
+
};
|
|
9556
|
+
const procedureRef = (0, import_firestore27.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
9557
|
+
await (0, import_firestore27.setDoc)(procedureRef, {
|
|
9558
|
+
...newProcedure,
|
|
9559
|
+
createdAt: (0, import_firestore27.serverTimestamp)(),
|
|
9560
|
+
updatedAt: (0, import_firestore27.serverTimestamp)()
|
|
9561
|
+
});
|
|
9562
|
+
const savedDoc = await (0, import_firestore27.getDoc)(procedureRef);
|
|
9563
|
+
return savedDoc.data();
|
|
9564
|
+
}
|
|
9328
9565
|
};
|
|
9329
9566
|
|
|
9330
9567
|
// src/services/clinic/practitioner-invite.service.ts
|
|
@@ -9432,7 +9669,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
9432
9669
|
...constraints
|
|
9433
9670
|
);
|
|
9434
9671
|
const querySnapshot = await (0, import_firestore28.getDocs)(q);
|
|
9435
|
-
return querySnapshot.docs.map((
|
|
9672
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
9436
9673
|
} catch (error) {
|
|
9437
9674
|
console.error(
|
|
9438
9675
|
"[PractitionerInviteService] Error getting doctor invites:",
|
|
@@ -9461,7 +9698,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
9461
9698
|
...constraints
|
|
9462
9699
|
);
|
|
9463
9700
|
const querySnapshot = await (0, import_firestore28.getDocs)(q);
|
|
9464
|
-
return querySnapshot.docs.map((
|
|
9701
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
9465
9702
|
} catch (error) {
|
|
9466
9703
|
console.error(
|
|
9467
9704
|
"[PractitionerInviteService] Error getting clinic invites:",
|
|
@@ -9617,7 +9854,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
9617
9854
|
);
|
|
9618
9855
|
const querySnapshot = await (0, import_firestore28.getDocs)(q);
|
|
9619
9856
|
let invites = querySnapshot.docs.map(
|
|
9620
|
-
(
|
|
9857
|
+
(doc36) => doc36.data()
|
|
9621
9858
|
);
|
|
9622
9859
|
if (filters.fromDate) {
|
|
9623
9860
|
invites = invites.filter(
|
|
@@ -9874,8 +10111,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
9874
10111
|
const q = (0, import_firestore29.query)(versionsCollectionRef, (0, import_firestore29.orderBy)("version", "desc"));
|
|
9875
10112
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
9876
10113
|
const versions = [];
|
|
9877
|
-
querySnapshot.forEach((
|
|
9878
|
-
versions.push(
|
|
10114
|
+
querySnapshot.forEach((doc36) => {
|
|
10115
|
+
versions.push(doc36.data());
|
|
9879
10116
|
});
|
|
9880
10117
|
return versions;
|
|
9881
10118
|
}
|
|
@@ -9906,9 +10143,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
9906
10143
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
9907
10144
|
const templates = [];
|
|
9908
10145
|
let lastVisible = null;
|
|
9909
|
-
querySnapshot.forEach((
|
|
9910
|
-
templates.push(
|
|
9911
|
-
lastVisible =
|
|
10146
|
+
querySnapshot.forEach((doc36) => {
|
|
10147
|
+
templates.push(doc36.data());
|
|
10148
|
+
lastVisible = doc36;
|
|
9912
10149
|
});
|
|
9913
10150
|
return {
|
|
9914
10151
|
templates,
|
|
@@ -9936,9 +10173,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
9936
10173
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
9937
10174
|
const templates = [];
|
|
9938
10175
|
let lastVisible = null;
|
|
9939
|
-
querySnapshot.forEach((
|
|
9940
|
-
templates.push(
|
|
9941
|
-
lastVisible =
|
|
10176
|
+
querySnapshot.forEach((doc36) => {
|
|
10177
|
+
templates.push(doc36.data());
|
|
10178
|
+
lastVisible = doc36;
|
|
9942
10179
|
});
|
|
9943
10180
|
return {
|
|
9944
10181
|
templates,
|
|
@@ -9965,9 +10202,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
9965
10202
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
9966
10203
|
const templates = [];
|
|
9967
10204
|
let lastVisible = null;
|
|
9968
|
-
querySnapshot.forEach((
|
|
9969
|
-
templates.push(
|
|
9970
|
-
lastVisible =
|
|
10205
|
+
querySnapshot.forEach((doc36) => {
|
|
10206
|
+
templates.push(doc36.data());
|
|
10207
|
+
lastVisible = doc36;
|
|
9971
10208
|
});
|
|
9972
10209
|
return {
|
|
9973
10210
|
templates,
|
|
@@ -9993,8 +10230,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
9993
10230
|
}
|
|
9994
10231
|
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
9995
10232
|
const templates = [];
|
|
9996
|
-
querySnapshot.forEach((
|
|
9997
|
-
templates.push(
|
|
10233
|
+
querySnapshot.forEach((doc36) => {
|
|
10234
|
+
templates.push(doc36.data());
|
|
9998
10235
|
});
|
|
9999
10236
|
return templates;
|
|
10000
10237
|
}
|
|
@@ -10189,9 +10426,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
10189
10426
|
const querySnapshot = await (0, import_firestore30.getDocs)(q);
|
|
10190
10427
|
const documents = [];
|
|
10191
10428
|
let lastVisible = null;
|
|
10192
|
-
querySnapshot.forEach((
|
|
10193
|
-
documents.push(
|
|
10194
|
-
lastVisible =
|
|
10429
|
+
querySnapshot.forEach((doc36) => {
|
|
10430
|
+
documents.push(doc36.data());
|
|
10431
|
+
lastVisible = doc36;
|
|
10195
10432
|
});
|
|
10196
10433
|
return {
|
|
10197
10434
|
documents,
|
|
@@ -10537,6 +10774,28 @@ var calendarEventSchema = import_zod23.z.object({
|
|
|
10537
10774
|
createdAt: import_zod23.z.instanceof(Date).or(import_zod23.z.instanceof(import_firestore32.Timestamp)),
|
|
10538
10775
|
updatedAt: import_zod23.z.instanceof(Date).or(import_zod23.z.instanceof(import_firestore32.Timestamp))
|
|
10539
10776
|
});
|
|
10777
|
+
var createBlockingEventSchema = import_zod23.z.object({
|
|
10778
|
+
entityType: import_zod23.z.enum(["practitioner", "clinic"]),
|
|
10779
|
+
entityId: import_zod23.z.string().min(1, "Entity ID is required"),
|
|
10780
|
+
eventName: import_zod23.z.string().min(1, "Event name is required").max(200, "Event name too long"),
|
|
10781
|
+
eventTime: calendarEventTimeSchema,
|
|
10782
|
+
eventType: import_zod23.z.enum([
|
|
10783
|
+
"blocking" /* BLOCKING */,
|
|
10784
|
+
"break" /* BREAK */,
|
|
10785
|
+
"free_day" /* FREE_DAY */,
|
|
10786
|
+
"other" /* OTHER */
|
|
10787
|
+
]),
|
|
10788
|
+
description: import_zod23.z.string().max(1e3, "Description too long").optional()
|
|
10789
|
+
});
|
|
10790
|
+
var updateBlockingEventSchema = import_zod23.z.object({
|
|
10791
|
+
entityType: import_zod23.z.enum(["practitioner", "clinic"]),
|
|
10792
|
+
entityId: import_zod23.z.string().min(1, "Entity ID is required"),
|
|
10793
|
+
eventId: import_zod23.z.string().min(1, "Event ID is required"),
|
|
10794
|
+
eventName: import_zod23.z.string().min(1, "Event name is required").max(200, "Event name too long").optional(),
|
|
10795
|
+
eventTime: calendarEventTimeSchema.optional(),
|
|
10796
|
+
description: import_zod23.z.string().max(1e3, "Description too long").optional(),
|
|
10797
|
+
status: import_zod23.z.nativeEnum(CalendarEventStatus).optional()
|
|
10798
|
+
});
|
|
10540
10799
|
|
|
10541
10800
|
// src/services/calendar/utils/clinic.utils.ts
|
|
10542
10801
|
var import_firestore34 = require("firebase/firestore");
|
|
@@ -10837,7 +11096,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
10837
11096
|
const finalQuery = (0, import_firestore37.query)(collectionRef, ...constraints);
|
|
10838
11097
|
const querySnapshot = await (0, import_firestore37.getDocs)(finalQuery);
|
|
10839
11098
|
const events = querySnapshot.docs.map(
|
|
10840
|
-
(
|
|
11099
|
+
(doc36) => ({ id: doc36.id, ...doc36.data() })
|
|
10841
11100
|
);
|
|
10842
11101
|
return events;
|
|
10843
11102
|
} catch (error) {
|
|
@@ -10919,7 +11178,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
10919
11178
|
);
|
|
10920
11179
|
const q = (0, import_firestore38.query)(calendarsRef, (0, import_firestore38.orderBy)("createdAt", "desc"));
|
|
10921
11180
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
10922
|
-
return querySnapshot.docs.map((
|
|
11181
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
10923
11182
|
}
|
|
10924
11183
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
10925
11184
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -10936,7 +11195,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
10936
11195
|
);
|
|
10937
11196
|
const q = (0, import_firestore38.query)(calendarsRef, (0, import_firestore38.orderBy)("createdAt", "desc"));
|
|
10938
11197
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
10939
|
-
return querySnapshot.docs.map((
|
|
11198
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
10940
11199
|
}
|
|
10941
11200
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
10942
11201
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -10953,7 +11212,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
10953
11212
|
);
|
|
10954
11213
|
const q = (0, import_firestore38.query)(calendarsRef, (0, import_firestore38.orderBy)("createdAt", "desc"));
|
|
10955
11214
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
10956
|
-
return querySnapshot.docs.map((
|
|
11215
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
10957
11216
|
}
|
|
10958
11217
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
10959
11218
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -12308,9 +12567,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12308
12567
|
(0, import_firestore41.where)("eventTime.start", "<=", import_firestore40.Timestamp.fromDate(endDate))
|
|
12309
12568
|
);
|
|
12310
12569
|
const eventsSnapshot = await (0, import_firestore41.getDocs)(q);
|
|
12311
|
-
const events = eventsSnapshot.docs.map((
|
|
12312
|
-
id:
|
|
12313
|
-
...
|
|
12570
|
+
const events = eventsSnapshot.docs.map((doc36) => ({
|
|
12571
|
+
id: doc36.id,
|
|
12572
|
+
...doc36.data()
|
|
12314
12573
|
}));
|
|
12315
12574
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
12316
12575
|
doctorId
|
|
@@ -12944,7 +13203,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12944
13203
|
])
|
|
12945
13204
|
);
|
|
12946
13205
|
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
12947
|
-
return querySnapshot.docs.map((
|
|
13206
|
+
return querySnapshot.docs.map((doc36) => doc36.data());
|
|
12948
13207
|
}
|
|
12949
13208
|
/**
|
|
12950
13209
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -13068,8 +13327,205 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13068
13327
|
// #endregion
|
|
13069
13328
|
};
|
|
13070
13329
|
|
|
13071
|
-
// src/services/
|
|
13330
|
+
// src/services/calendar/calendar.v3.service.ts
|
|
13072
13331
|
var import_firestore42 = require("firebase/firestore");
|
|
13332
|
+
var import_firestore43 = require("firebase/firestore");
|
|
13333
|
+
var CalendarServiceV3 = class extends BaseService {
|
|
13334
|
+
/**
|
|
13335
|
+
* Creates a new CalendarServiceV3 instance
|
|
13336
|
+
* @param db - Firestore instance
|
|
13337
|
+
* @param auth - Firebase Auth instance
|
|
13338
|
+
* @param app - Firebase App instance
|
|
13339
|
+
*/
|
|
13340
|
+
constructor(db, auth, app) {
|
|
13341
|
+
super(db, auth, app);
|
|
13342
|
+
}
|
|
13343
|
+
// #region Blocking Event CRUD Operations
|
|
13344
|
+
/**
|
|
13345
|
+
* Creates a blocking event for a practitioner or clinic
|
|
13346
|
+
* @param params - Blocking event creation parameters
|
|
13347
|
+
* @returns Created calendar event
|
|
13348
|
+
*/
|
|
13349
|
+
async createBlockingEvent(params) {
|
|
13350
|
+
this.validateBlockingEventParams(params);
|
|
13351
|
+
const eventId = this.generateId();
|
|
13352
|
+
const collectionPath = this.getEntityCalendarPath(
|
|
13353
|
+
params.entityType,
|
|
13354
|
+
params.entityId
|
|
13355
|
+
);
|
|
13356
|
+
const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, eventId);
|
|
13357
|
+
const eventData = {
|
|
13358
|
+
id: eventId,
|
|
13359
|
+
eventName: params.eventName,
|
|
13360
|
+
eventTime: params.eventTime,
|
|
13361
|
+
eventType: params.eventType,
|
|
13362
|
+
description: params.description || "",
|
|
13363
|
+
status: "confirmed" /* CONFIRMED */,
|
|
13364
|
+
// Blocking events are always confirmed
|
|
13365
|
+
syncStatus: "internal" /* INTERNAL */,
|
|
13366
|
+
createdAt: (0, import_firestore42.serverTimestamp)(),
|
|
13367
|
+
updatedAt: (0, import_firestore42.serverTimestamp)()
|
|
13368
|
+
};
|
|
13369
|
+
if (params.entityType === "practitioner") {
|
|
13370
|
+
eventData.practitionerProfileId = params.entityId;
|
|
13371
|
+
} else {
|
|
13372
|
+
eventData.clinicBranchId = params.entityId;
|
|
13373
|
+
}
|
|
13374
|
+
await (0, import_firestore43.setDoc)(eventRef, eventData);
|
|
13375
|
+
return {
|
|
13376
|
+
...eventData,
|
|
13377
|
+
createdAt: import_firestore42.Timestamp.now(),
|
|
13378
|
+
updatedAt: import_firestore42.Timestamp.now()
|
|
13379
|
+
};
|
|
13380
|
+
}
|
|
13381
|
+
/**
|
|
13382
|
+
* Updates a blocking event
|
|
13383
|
+
* @param params - Blocking event update parameters
|
|
13384
|
+
* @returns Updated calendar event
|
|
13385
|
+
*/
|
|
13386
|
+
async updateBlockingEvent(params) {
|
|
13387
|
+
const collectionPath = this.getEntityCalendarPath(
|
|
13388
|
+
params.entityType,
|
|
13389
|
+
params.entityId
|
|
13390
|
+
);
|
|
13391
|
+
const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, params.eventId);
|
|
13392
|
+
const eventDoc = await (0, import_firestore43.getDoc)(eventRef);
|
|
13393
|
+
if (!eventDoc.exists()) {
|
|
13394
|
+
throw new Error(`Blocking event with ID ${params.eventId} not found`);
|
|
13395
|
+
}
|
|
13396
|
+
const updateData = {
|
|
13397
|
+
updatedAt: (0, import_firestore42.serverTimestamp)()
|
|
13398
|
+
};
|
|
13399
|
+
if (params.eventName !== void 0) {
|
|
13400
|
+
updateData.eventName = params.eventName;
|
|
13401
|
+
}
|
|
13402
|
+
if (params.eventTime !== void 0) {
|
|
13403
|
+
updateData.eventTime = params.eventTime;
|
|
13404
|
+
}
|
|
13405
|
+
if (params.description !== void 0) {
|
|
13406
|
+
updateData.description = params.description;
|
|
13407
|
+
}
|
|
13408
|
+
if (params.status !== void 0) {
|
|
13409
|
+
updateData.status = params.status;
|
|
13410
|
+
}
|
|
13411
|
+
await (0, import_firestore43.updateDoc)(eventRef, updateData);
|
|
13412
|
+
const updatedEventDoc = await (0, import_firestore43.getDoc)(eventRef);
|
|
13413
|
+
return updatedEventDoc.data();
|
|
13414
|
+
}
|
|
13415
|
+
/**
|
|
13416
|
+
* Deletes a blocking event
|
|
13417
|
+
* @param entityType - Type of entity (practitioner or clinic)
|
|
13418
|
+
* @param entityId - ID of the entity
|
|
13419
|
+
* @param eventId - ID of the event to delete
|
|
13420
|
+
*/
|
|
13421
|
+
async deleteBlockingEvent(entityType, entityId, eventId) {
|
|
13422
|
+
const collectionPath = this.getEntityCalendarPath(entityType, entityId);
|
|
13423
|
+
const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, eventId);
|
|
13424
|
+
const eventDoc = await (0, import_firestore43.getDoc)(eventRef);
|
|
13425
|
+
if (!eventDoc.exists()) {
|
|
13426
|
+
throw new Error(`Blocking event with ID ${eventId} not found`);
|
|
13427
|
+
}
|
|
13428
|
+
await (0, import_firestore43.deleteDoc)(eventRef);
|
|
13429
|
+
}
|
|
13430
|
+
/**
|
|
13431
|
+
* Gets a specific blocking event
|
|
13432
|
+
* @param entityType - Type of entity (practitioner or clinic)
|
|
13433
|
+
* @param entityId - ID of the entity
|
|
13434
|
+
* @param eventId - ID of the event to retrieve
|
|
13435
|
+
* @returns Calendar event or null if not found
|
|
13436
|
+
*/
|
|
13437
|
+
async getBlockingEvent(entityType, entityId, eventId) {
|
|
13438
|
+
const collectionPath = this.getEntityCalendarPath(entityType, entityId);
|
|
13439
|
+
const eventRef = (0, import_firestore43.doc)(this.db, collectionPath, eventId);
|
|
13440
|
+
const eventDoc = await (0, import_firestore43.getDoc)(eventRef);
|
|
13441
|
+
if (!eventDoc.exists()) {
|
|
13442
|
+
return null;
|
|
13443
|
+
}
|
|
13444
|
+
return eventDoc.data();
|
|
13445
|
+
}
|
|
13446
|
+
/**
|
|
13447
|
+
* Gets blocking events for a specific entity
|
|
13448
|
+
* @param entityType - Type of entity (practitioner or clinic)
|
|
13449
|
+
* @param entityId - ID of the entity
|
|
13450
|
+
* @param dateRange - Optional date range filter
|
|
13451
|
+
* @param eventType - Optional event type filter
|
|
13452
|
+
* @returns Array of calendar events
|
|
13453
|
+
*/
|
|
13454
|
+
async getEntityBlockingEvents(entityType, entityId, dateRange, eventType) {
|
|
13455
|
+
const searchParams = {
|
|
13456
|
+
searchLocation: entityType === "practitioner" ? "practitioner" /* PRACTITIONER */ : "clinic" /* CLINIC */,
|
|
13457
|
+
entityId,
|
|
13458
|
+
dateRange,
|
|
13459
|
+
eventType
|
|
13460
|
+
};
|
|
13461
|
+
if (!eventType) {
|
|
13462
|
+
const allEvents = await searchCalendarEventsUtil(this.db, searchParams);
|
|
13463
|
+
return allEvents.filter(
|
|
13464
|
+
(event) => event.eventType === "blocking" /* BLOCKING */ || event.eventType === "break" /* BREAK */ || event.eventType === "free_day" /* FREE_DAY */ || event.eventType === "other" /* OTHER */
|
|
13465
|
+
);
|
|
13466
|
+
}
|
|
13467
|
+
return searchCalendarEventsUtil(this.db, searchParams);
|
|
13468
|
+
}
|
|
13469
|
+
// #endregion
|
|
13470
|
+
// #region Calendar Event Search
|
|
13471
|
+
/**
|
|
13472
|
+
* Searches for calendar events based on specified criteria.
|
|
13473
|
+
* This method supports searching for ALL event types (appointments, blocking events, etc.)
|
|
13474
|
+
*
|
|
13475
|
+
* @param params - The search parameters
|
|
13476
|
+
* @returns A promise that resolves to an array of matching calendar events
|
|
13477
|
+
*/
|
|
13478
|
+
async searchCalendarEvents(params) {
|
|
13479
|
+
return searchCalendarEventsUtil(this.db, params);
|
|
13480
|
+
}
|
|
13481
|
+
// #endregion
|
|
13482
|
+
// #region Private Helper Methods
|
|
13483
|
+
/**
|
|
13484
|
+
* Gets the calendar collection path for a specific entity
|
|
13485
|
+
* @param entityType - Type of entity (practitioner or clinic)
|
|
13486
|
+
* @param entityId - ID of the entity
|
|
13487
|
+
* @returns Collection path string
|
|
13488
|
+
*/
|
|
13489
|
+
getEntityCalendarPath(entityType, entityId) {
|
|
13490
|
+
if (entityType === "practitioner") {
|
|
13491
|
+
return `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
13492
|
+
} else {
|
|
13493
|
+
return `${CLINICS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
13494
|
+
}
|
|
13495
|
+
}
|
|
13496
|
+
/**
|
|
13497
|
+
* Validates blocking event creation parameters
|
|
13498
|
+
* @param params - Parameters to validate
|
|
13499
|
+
* @throws Error if validation fails
|
|
13500
|
+
*/
|
|
13501
|
+
validateBlockingEventParams(params) {
|
|
13502
|
+
if (!params.entityType || !params.entityId) {
|
|
13503
|
+
throw new Error("Entity type and ID are required");
|
|
13504
|
+
}
|
|
13505
|
+
if (!params.eventName || params.eventName.trim() === "") {
|
|
13506
|
+
throw new Error("Event name is required");
|
|
13507
|
+
}
|
|
13508
|
+
if (!params.eventTime || !params.eventTime.start || !params.eventTime.end) {
|
|
13509
|
+
throw new Error("Event time with start and end is required");
|
|
13510
|
+
}
|
|
13511
|
+
if (params.eventTime.end.toMillis() <= params.eventTime.start.toMillis()) {
|
|
13512
|
+
throw new Error("Event end time must be after start time");
|
|
13513
|
+
}
|
|
13514
|
+
const validTypes = [
|
|
13515
|
+
"blocking" /* BLOCKING */,
|
|
13516
|
+
"break" /* BREAK */,
|
|
13517
|
+
"free_day" /* FREE_DAY */,
|
|
13518
|
+
"other" /* OTHER */
|
|
13519
|
+
];
|
|
13520
|
+
if (!validTypes.includes(params.eventType)) {
|
|
13521
|
+
throw new Error("Invalid event type for blocking events");
|
|
13522
|
+
}
|
|
13523
|
+
}
|
|
13524
|
+
// #endregion
|
|
13525
|
+
};
|
|
13526
|
+
|
|
13527
|
+
// src/services/reviews/reviews.service.ts
|
|
13528
|
+
var import_firestore44 = require("firebase/firestore");
|
|
13073
13529
|
|
|
13074
13530
|
// src/types/reviews/index.ts
|
|
13075
13531
|
var REVIEWS_COLLECTION = "reviews";
|
|
@@ -13154,11 +13610,11 @@ var ReviewService = class extends BaseService {
|
|
|
13154
13610
|
updatedAt: now
|
|
13155
13611
|
};
|
|
13156
13612
|
reviewSchema.parse(review);
|
|
13157
|
-
const docRef = (0,
|
|
13158
|
-
await (0,
|
|
13613
|
+
const docRef = (0, import_firestore44.doc)(this.db, REVIEWS_COLLECTION, reviewId);
|
|
13614
|
+
await (0, import_firestore44.setDoc)(docRef, {
|
|
13159
13615
|
...review,
|
|
13160
|
-
createdAt: (0,
|
|
13161
|
-
updatedAt: (0,
|
|
13616
|
+
createdAt: (0, import_firestore44.serverTimestamp)(),
|
|
13617
|
+
updatedAt: (0, import_firestore44.serverTimestamp)()
|
|
13162
13618
|
});
|
|
13163
13619
|
return review;
|
|
13164
13620
|
} catch (error) {
|
|
@@ -13174,8 +13630,8 @@ var ReviewService = class extends BaseService {
|
|
|
13174
13630
|
* @returns The review if found, null otherwise
|
|
13175
13631
|
*/
|
|
13176
13632
|
async getReview(reviewId) {
|
|
13177
|
-
const docRef = (0,
|
|
13178
|
-
const docSnap = await (0,
|
|
13633
|
+
const docRef = (0, import_firestore44.doc)(this.db, REVIEWS_COLLECTION, reviewId);
|
|
13634
|
+
const docSnap = await (0, import_firestore44.getDoc)(docRef);
|
|
13179
13635
|
if (!docSnap.exists()) {
|
|
13180
13636
|
return null;
|
|
13181
13637
|
}
|
|
@@ -13187,12 +13643,12 @@ var ReviewService = class extends BaseService {
|
|
|
13187
13643
|
* @returns Array of reviews for the patient
|
|
13188
13644
|
*/
|
|
13189
13645
|
async getReviewsByPatient(patientId) {
|
|
13190
|
-
const q = (0,
|
|
13191
|
-
(0,
|
|
13192
|
-
(0,
|
|
13646
|
+
const q = (0, import_firestore44.query)(
|
|
13647
|
+
(0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
|
|
13648
|
+
(0, import_firestore44.where)("patientId", "==", patientId)
|
|
13193
13649
|
);
|
|
13194
|
-
const snapshot = await (0,
|
|
13195
|
-
return snapshot.docs.map((
|
|
13650
|
+
const snapshot = await (0, import_firestore44.getDocs)(q);
|
|
13651
|
+
return snapshot.docs.map((doc36) => doc36.data());
|
|
13196
13652
|
}
|
|
13197
13653
|
/**
|
|
13198
13654
|
* Gets all reviews for a specific clinic
|
|
@@ -13200,12 +13656,12 @@ var ReviewService = class extends BaseService {
|
|
|
13200
13656
|
* @returns Array of reviews containing clinic reviews
|
|
13201
13657
|
*/
|
|
13202
13658
|
async getReviewsByClinic(clinicId) {
|
|
13203
|
-
const q = (0,
|
|
13204
|
-
(0,
|
|
13205
|
-
(0,
|
|
13659
|
+
const q = (0, import_firestore44.query)(
|
|
13660
|
+
(0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
|
|
13661
|
+
(0, import_firestore44.where)("clinicReview.clinicId", "==", clinicId)
|
|
13206
13662
|
);
|
|
13207
|
-
const snapshot = await (0,
|
|
13208
|
-
return snapshot.docs.map((
|
|
13663
|
+
const snapshot = await (0, import_firestore44.getDocs)(q);
|
|
13664
|
+
return snapshot.docs.map((doc36) => doc36.data());
|
|
13209
13665
|
}
|
|
13210
13666
|
/**
|
|
13211
13667
|
* Gets all reviews for a specific practitioner
|
|
@@ -13213,12 +13669,12 @@ var ReviewService = class extends BaseService {
|
|
|
13213
13669
|
* @returns Array of reviews containing practitioner reviews
|
|
13214
13670
|
*/
|
|
13215
13671
|
async getReviewsByPractitioner(practitionerId) {
|
|
13216
|
-
const q = (0,
|
|
13217
|
-
(0,
|
|
13218
|
-
(0,
|
|
13672
|
+
const q = (0, import_firestore44.query)(
|
|
13673
|
+
(0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
|
|
13674
|
+
(0, import_firestore44.where)("practitionerReview.practitionerId", "==", practitionerId)
|
|
13219
13675
|
);
|
|
13220
|
-
const snapshot = await (0,
|
|
13221
|
-
return snapshot.docs.map((
|
|
13676
|
+
const snapshot = await (0, import_firestore44.getDocs)(q);
|
|
13677
|
+
return snapshot.docs.map((doc36) => doc36.data());
|
|
13222
13678
|
}
|
|
13223
13679
|
/**
|
|
13224
13680
|
* Gets all reviews for a specific procedure
|
|
@@ -13226,12 +13682,12 @@ var ReviewService = class extends BaseService {
|
|
|
13226
13682
|
* @returns Array of reviews containing procedure reviews
|
|
13227
13683
|
*/
|
|
13228
13684
|
async getReviewsByProcedure(procedureId) {
|
|
13229
|
-
const q = (0,
|
|
13230
|
-
(0,
|
|
13231
|
-
(0,
|
|
13685
|
+
const q = (0, import_firestore44.query)(
|
|
13686
|
+
(0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
|
|
13687
|
+
(0, import_firestore44.where)("procedureReview.procedureId", "==", procedureId)
|
|
13232
13688
|
);
|
|
13233
|
-
const snapshot = await (0,
|
|
13234
|
-
return snapshot.docs.map((
|
|
13689
|
+
const snapshot = await (0, import_firestore44.getDocs)(q);
|
|
13690
|
+
return snapshot.docs.map((doc36) => doc36.data());
|
|
13235
13691
|
}
|
|
13236
13692
|
/**
|
|
13237
13693
|
* Gets all reviews for a specific appointment
|
|
@@ -13239,11 +13695,11 @@ var ReviewService = class extends BaseService {
|
|
|
13239
13695
|
* @returns The review for the appointment if found, null otherwise
|
|
13240
13696
|
*/
|
|
13241
13697
|
async getReviewByAppointment(appointmentId) {
|
|
13242
|
-
const q = (0,
|
|
13243
|
-
(0,
|
|
13244
|
-
(0,
|
|
13698
|
+
const q = (0, import_firestore44.query)(
|
|
13699
|
+
(0, import_firestore44.collection)(this.db, REVIEWS_COLLECTION),
|
|
13700
|
+
(0, import_firestore44.where)("appointmentId", "==", appointmentId)
|
|
13245
13701
|
);
|
|
13246
|
-
const snapshot = await (0,
|
|
13702
|
+
const snapshot = await (0, import_firestore44.getDocs)(q);
|
|
13247
13703
|
if (snapshot.empty) {
|
|
13248
13704
|
return null;
|
|
13249
13705
|
}
|
|
@@ -13258,7 +13714,7 @@ var ReviewService = class extends BaseService {
|
|
|
13258
13714
|
if (!review) {
|
|
13259
13715
|
throw new Error(`Review with ID ${reviewId} not found`);
|
|
13260
13716
|
}
|
|
13261
|
-
await (0,
|
|
13717
|
+
await (0, import_firestore44.deleteDoc)((0, import_firestore44.doc)(this.db, REVIEWS_COLLECTION, reviewId));
|
|
13262
13718
|
}
|
|
13263
13719
|
/**
|
|
13264
13720
|
* Calculates the average of an array of numbers
|
|
@@ -13276,11 +13732,11 @@ var ReviewService = class extends BaseService {
|
|
|
13276
13732
|
};
|
|
13277
13733
|
|
|
13278
13734
|
// src/services/appointment/appointment.service.ts
|
|
13279
|
-
var
|
|
13735
|
+
var import_firestore46 = require("firebase/firestore");
|
|
13280
13736
|
var import_functions2 = require("firebase/functions");
|
|
13281
13737
|
|
|
13282
13738
|
// src/services/appointment/utils/appointment.utils.ts
|
|
13283
|
-
var
|
|
13739
|
+
var import_firestore45 = require("firebase/firestore");
|
|
13284
13740
|
|
|
13285
13741
|
// src/backoffice/types/technology.types.ts
|
|
13286
13742
|
var TECHNOLOGIES_COLLECTION = "technologies";
|
|
@@ -13288,8 +13744,8 @@ var TECHNOLOGIES_COLLECTION = "technologies";
|
|
|
13288
13744
|
// src/services/appointment/utils/appointment.utils.ts
|
|
13289
13745
|
async function updateAppointmentUtil2(db, appointmentId, data) {
|
|
13290
13746
|
try {
|
|
13291
|
-
const appointmentRef = (0,
|
|
13292
|
-
const appointmentDoc = await (0,
|
|
13747
|
+
const appointmentRef = (0, import_firestore45.doc)(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
13748
|
+
const appointmentDoc = await (0, import_firestore45.getDoc)(appointmentRef);
|
|
13293
13749
|
if (!appointmentDoc.exists()) {
|
|
13294
13750
|
throw new Error(`Appointment with ID ${appointmentId} not found`);
|
|
13295
13751
|
}
|
|
@@ -13338,7 +13794,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
|
|
|
13338
13794
|
...data,
|
|
13339
13795
|
completedPreRequirements,
|
|
13340
13796
|
completedPostRequirements,
|
|
13341
|
-
updatedAt: (0,
|
|
13797
|
+
updatedAt: (0, import_firestore45.serverTimestamp)()
|
|
13342
13798
|
};
|
|
13343
13799
|
Object.keys(updateData).forEach((key) => {
|
|
13344
13800
|
if (updateData[key] === void 0) {
|
|
@@ -13347,7 +13803,7 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
|
|
|
13347
13803
|
});
|
|
13348
13804
|
if (data.status && data.status !== currentAppointment.status) {
|
|
13349
13805
|
if (data.status === "confirmed" /* CONFIRMED */ && !updateData.confirmationTime) {
|
|
13350
|
-
updateData.confirmationTime =
|
|
13806
|
+
updateData.confirmationTime = import_firestore45.Timestamp.now();
|
|
13351
13807
|
}
|
|
13352
13808
|
if (currentAppointment.calendarEventId) {
|
|
13353
13809
|
await updateCalendarEventStatus(
|
|
@@ -13357,8 +13813,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
|
|
|
13357
13813
|
);
|
|
13358
13814
|
}
|
|
13359
13815
|
}
|
|
13360
|
-
await (0,
|
|
13361
|
-
const updatedAppointmentDoc = await (0,
|
|
13816
|
+
await (0, import_firestore45.updateDoc)(appointmentRef, updateData);
|
|
13817
|
+
const updatedAppointmentDoc = await (0, import_firestore45.getDoc)(appointmentRef);
|
|
13362
13818
|
if (!updatedAppointmentDoc.exists()) {
|
|
13363
13819
|
throw new Error(
|
|
13364
13820
|
`Failed to retrieve updated appointment ${appointmentId}`
|
|
@@ -13372,8 +13828,8 @@ async function updateAppointmentUtil2(db, appointmentId, data) {
|
|
|
13372
13828
|
}
|
|
13373
13829
|
async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus) {
|
|
13374
13830
|
try {
|
|
13375
|
-
const calendarEventRef = (0,
|
|
13376
|
-
const calendarEventDoc = await (0,
|
|
13831
|
+
const calendarEventRef = (0, import_firestore45.doc)(db, CALENDAR_COLLECTION, calendarEventId);
|
|
13832
|
+
const calendarEventDoc = await (0, import_firestore45.getDoc)(calendarEventRef);
|
|
13377
13833
|
if (!calendarEventDoc.exists()) {
|
|
13378
13834
|
console.warn(`Calendar event with ID ${calendarEventId} not found`);
|
|
13379
13835
|
return;
|
|
@@ -13396,9 +13852,9 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
|
|
|
13396
13852
|
default:
|
|
13397
13853
|
return;
|
|
13398
13854
|
}
|
|
13399
|
-
await (0,
|
|
13855
|
+
await (0, import_firestore45.updateDoc)(calendarEventRef, {
|
|
13400
13856
|
status: calendarStatus,
|
|
13401
|
-
updatedAt: (0,
|
|
13857
|
+
updatedAt: (0, import_firestore45.serverTimestamp)()
|
|
13402
13858
|
});
|
|
13403
13859
|
} catch (error) {
|
|
13404
13860
|
console.error(`Error updating calendar event ${calendarEventId}:`, error);
|
|
@@ -13406,8 +13862,8 @@ async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus)
|
|
|
13406
13862
|
}
|
|
13407
13863
|
async function getAppointmentByIdUtil(db, appointmentId) {
|
|
13408
13864
|
try {
|
|
13409
|
-
const appointmentDoc = await (0,
|
|
13410
|
-
(0,
|
|
13865
|
+
const appointmentDoc = await (0, import_firestore45.getDoc)(
|
|
13866
|
+
(0, import_firestore45.doc)(db, APPOINTMENTS_COLLECTION, appointmentId)
|
|
13411
13867
|
);
|
|
13412
13868
|
if (!appointmentDoc.exists()) {
|
|
13413
13869
|
return null;
|
|
@@ -13422,46 +13878,46 @@ async function searchAppointmentsUtil(db, params) {
|
|
|
13422
13878
|
try {
|
|
13423
13879
|
const constraints = [];
|
|
13424
13880
|
if (params.patientId) {
|
|
13425
|
-
constraints.push((0,
|
|
13881
|
+
constraints.push((0, import_firestore45.where)("patientId", "==", params.patientId));
|
|
13426
13882
|
}
|
|
13427
13883
|
if (params.practitionerId) {
|
|
13428
|
-
constraints.push((0,
|
|
13884
|
+
constraints.push((0, import_firestore45.where)("practitionerId", "==", params.practitionerId));
|
|
13429
13885
|
}
|
|
13430
13886
|
if (params.clinicBranchId) {
|
|
13431
|
-
constraints.push((0,
|
|
13887
|
+
constraints.push((0, import_firestore45.where)("clinicBranchId", "==", params.clinicBranchId));
|
|
13432
13888
|
}
|
|
13433
13889
|
if (params.startDate) {
|
|
13434
13890
|
constraints.push(
|
|
13435
|
-
(0,
|
|
13891
|
+
(0, import_firestore45.where)(
|
|
13436
13892
|
"appointmentStartTime",
|
|
13437
13893
|
">=",
|
|
13438
|
-
|
|
13894
|
+
import_firestore45.Timestamp.fromDate(params.startDate)
|
|
13439
13895
|
)
|
|
13440
13896
|
);
|
|
13441
13897
|
}
|
|
13442
13898
|
if (params.endDate) {
|
|
13443
13899
|
constraints.push(
|
|
13444
|
-
(0,
|
|
13900
|
+
(0, import_firestore45.where)("appointmentStartTime", "<=", import_firestore45.Timestamp.fromDate(params.endDate))
|
|
13445
13901
|
);
|
|
13446
13902
|
}
|
|
13447
13903
|
if (params.status) {
|
|
13448
13904
|
if (Array.isArray(params.status)) {
|
|
13449
|
-
constraints.push((0,
|
|
13905
|
+
constraints.push((0, import_firestore45.where)("status", "in", params.status));
|
|
13450
13906
|
} else {
|
|
13451
|
-
constraints.push((0,
|
|
13907
|
+
constraints.push((0, import_firestore45.where)("status", "==", params.status));
|
|
13452
13908
|
}
|
|
13453
13909
|
}
|
|
13454
|
-
constraints.push((0,
|
|
13910
|
+
constraints.push((0, import_firestore45.orderBy)("appointmentStartTime", "asc"));
|
|
13455
13911
|
if (params.limit) {
|
|
13456
|
-
constraints.push((0,
|
|
13912
|
+
constraints.push((0, import_firestore45.limit)(params.limit));
|
|
13457
13913
|
}
|
|
13458
13914
|
if (params.startAfter) {
|
|
13459
|
-
constraints.push((0,
|
|
13915
|
+
constraints.push((0, import_firestore45.startAfter)(params.startAfter));
|
|
13460
13916
|
}
|
|
13461
|
-
const q = (0,
|
|
13462
|
-
const querySnapshot = await (0,
|
|
13917
|
+
const q = (0, import_firestore45.query)((0, import_firestore45.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
13918
|
+
const querySnapshot = await (0, import_firestore45.getDocs)(q);
|
|
13463
13919
|
const appointments = querySnapshot.docs.map(
|
|
13464
|
-
(
|
|
13920
|
+
(doc36) => doc36.data()
|
|
13465
13921
|
);
|
|
13466
13922
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
13467
13923
|
return { appointments, lastDoc };
|
|
@@ -13830,7 +14286,7 @@ var AppointmentService = class extends BaseService {
|
|
|
13830
14286
|
);
|
|
13831
14287
|
const updateData = {
|
|
13832
14288
|
status: newStatus,
|
|
13833
|
-
updatedAt: (0,
|
|
14289
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
13834
14290
|
};
|
|
13835
14291
|
if (newStatus === "canceled_clinic" /* CANCELED_CLINIC */ || newStatus === "canceled_patient" /* CANCELED_PATIENT */ || newStatus === "canceled_patient_rescheduled" /* CANCELED_PATIENT_RESCHEDULED */) {
|
|
13836
14292
|
if (!(details == null ? void 0 : details.cancellationReason)) {
|
|
@@ -13841,13 +14297,13 @@ var AppointmentService = class extends BaseService {
|
|
|
13841
14297
|
}
|
|
13842
14298
|
updateData.cancellationReason = details.cancellationReason;
|
|
13843
14299
|
updateData.canceledBy = details.canceledBy;
|
|
13844
|
-
updateData.cancellationTime =
|
|
14300
|
+
updateData.cancellationTime = import_firestore46.Timestamp.now();
|
|
13845
14301
|
}
|
|
13846
14302
|
if (newStatus === "confirmed" /* CONFIRMED */) {
|
|
13847
|
-
updateData.confirmationTime =
|
|
14303
|
+
updateData.confirmationTime = import_firestore46.Timestamp.now();
|
|
13848
14304
|
}
|
|
13849
14305
|
if (newStatus === "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */) {
|
|
13850
|
-
updateData.rescheduleTime =
|
|
14306
|
+
updateData.rescheduleTime = import_firestore46.Timestamp.now();
|
|
13851
14307
|
}
|
|
13852
14308
|
return this.updateAppointment(appointmentId, updateData);
|
|
13853
14309
|
}
|
|
@@ -13925,9 +14381,9 @@ var AppointmentService = class extends BaseService {
|
|
|
13925
14381
|
status: "rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */,
|
|
13926
14382
|
appointmentStartTime: startTimestamp,
|
|
13927
14383
|
appointmentEndTime: endTimestamp,
|
|
13928
|
-
rescheduleTime:
|
|
14384
|
+
rescheduleTime: import_firestore46.Timestamp.now(),
|
|
13929
14385
|
confirmationTime: null,
|
|
13930
|
-
updatedAt: (0,
|
|
14386
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
13931
14387
|
};
|
|
13932
14388
|
return this.updateAppointment(validatedParams.appointmentId, updateData);
|
|
13933
14389
|
}
|
|
@@ -13945,19 +14401,19 @@ var AppointmentService = class extends BaseService {
|
|
|
13945
14401
|
return value;
|
|
13946
14402
|
}
|
|
13947
14403
|
if (typeof value === "number") {
|
|
13948
|
-
return
|
|
14404
|
+
return import_firestore46.Timestamp.fromMillis(value);
|
|
13949
14405
|
}
|
|
13950
14406
|
if (typeof value === "string") {
|
|
13951
|
-
return
|
|
14407
|
+
return import_firestore46.Timestamp.fromDate(new Date(value));
|
|
13952
14408
|
}
|
|
13953
14409
|
if (value instanceof Date) {
|
|
13954
|
-
return
|
|
14410
|
+
return import_firestore46.Timestamp.fromDate(value);
|
|
13955
14411
|
}
|
|
13956
14412
|
if (value && typeof value._seconds === "number") {
|
|
13957
|
-
return new
|
|
14413
|
+
return new import_firestore46.Timestamp(value._seconds, value._nanoseconds || 0);
|
|
13958
14414
|
}
|
|
13959
14415
|
if (value && typeof value.seconds === "number") {
|
|
13960
|
-
return new
|
|
14416
|
+
return new import_firestore46.Timestamp(value.seconds, value.nanoseconds || 0);
|
|
13961
14417
|
}
|
|
13962
14418
|
throw new Error(
|
|
13963
14419
|
`Invalid timestamp format: ${typeof value}, value: ${JSON.stringify(
|
|
@@ -14056,9 +14512,9 @@ var AppointmentService = class extends BaseService {
|
|
|
14056
14512
|
}
|
|
14057
14513
|
const updateData = {
|
|
14058
14514
|
status: "in_progress" /* IN_PROGRESS */,
|
|
14059
|
-
procedureActualStartTime:
|
|
14515
|
+
procedureActualStartTime: import_firestore46.Timestamp.now(),
|
|
14060
14516
|
// Set actual start time
|
|
14061
|
-
updatedAt: (0,
|
|
14517
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
14062
14518
|
};
|
|
14063
14519
|
return this.updateAppointment(appointmentId, updateData);
|
|
14064
14520
|
}
|
|
@@ -14076,7 +14532,7 @@ var AppointmentService = class extends BaseService {
|
|
|
14076
14532
|
if (!appointment)
|
|
14077
14533
|
throw new Error(`Appointment ${appointmentId} not found.`);
|
|
14078
14534
|
let calculatedDurationMinutes = actualDurationMinutesInput;
|
|
14079
|
-
const procedureCompletionTime =
|
|
14535
|
+
const procedureCompletionTime = import_firestore46.Timestamp.now();
|
|
14080
14536
|
if (calculatedDurationMinutes === void 0 && appointment.procedureActualStartTime) {
|
|
14081
14537
|
const startTimeMillis = appointment.procedureActualStartTime.toMillis();
|
|
14082
14538
|
const endTimeMillis = procedureCompletionTime.toMillis();
|
|
@@ -14099,7 +14555,7 @@ var AppointmentService = class extends BaseService {
|
|
|
14099
14555
|
},
|
|
14100
14556
|
// Optionally update appointmentEndTime to the actual completion time
|
|
14101
14557
|
// appointmentEndTime: procedureCompletionTime,
|
|
14102
|
-
updatedAt: (0,
|
|
14558
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
14103
14559
|
};
|
|
14104
14560
|
return this.updateAppointment(appointmentId, updateData);
|
|
14105
14561
|
}
|
|
@@ -14113,7 +14569,7 @@ var AppointmentService = class extends BaseService {
|
|
|
14113
14569
|
const appointment = await this.getAppointmentById(appointmentId);
|
|
14114
14570
|
if (!appointment)
|
|
14115
14571
|
throw new Error(`Appointment ${appointmentId} not found.`);
|
|
14116
|
-
if (
|
|
14572
|
+
if (import_firestore46.Timestamp.now().toMillis() < appointment.appointmentStartTime.toMillis()) {
|
|
14117
14573
|
throw new Error("Cannot mark no-show before appointment start time.");
|
|
14118
14574
|
}
|
|
14119
14575
|
return this.updateAppointmentStatus(
|
|
@@ -14137,12 +14593,12 @@ var AppointmentService = class extends BaseService {
|
|
|
14137
14593
|
const newMediaItem = {
|
|
14138
14594
|
...mediaItemData,
|
|
14139
14595
|
id: this.generateId(),
|
|
14140
|
-
uploadedAt:
|
|
14596
|
+
uploadedAt: import_firestore46.Timestamp.now(),
|
|
14141
14597
|
uploadedBy: currentUser.uid
|
|
14142
14598
|
};
|
|
14143
14599
|
const updateData = {
|
|
14144
|
-
media: (0,
|
|
14145
|
-
updatedAt: (0,
|
|
14600
|
+
media: (0, import_firestore46.arrayUnion)(newMediaItem),
|
|
14601
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
14146
14602
|
};
|
|
14147
14603
|
return this.updateAppointment(appointmentId, updateData);
|
|
14148
14604
|
}
|
|
@@ -14162,8 +14618,8 @@ var AppointmentService = class extends BaseService {
|
|
|
14162
14618
|
throw new Error(`Media item ${mediaItemId} not found in appointment.`);
|
|
14163
14619
|
}
|
|
14164
14620
|
const updateData = {
|
|
14165
|
-
media: (0,
|
|
14166
|
-
updatedAt: (0,
|
|
14621
|
+
media: (0, import_firestore46.arrayRemove)(mediaToRemove),
|
|
14622
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
14167
14623
|
};
|
|
14168
14624
|
return this.updateAppointment(appointmentId, updateData);
|
|
14169
14625
|
}
|
|
@@ -14177,11 +14633,11 @@ var AppointmentService = class extends BaseService {
|
|
|
14177
14633
|
const newReviewInfo = {
|
|
14178
14634
|
...reviewData,
|
|
14179
14635
|
reviewId: this.generateId(),
|
|
14180
|
-
reviewedAt:
|
|
14636
|
+
reviewedAt: import_firestore46.Timestamp.now()
|
|
14181
14637
|
};
|
|
14182
14638
|
const updateData = {
|
|
14183
14639
|
reviewInfo: newReviewInfo,
|
|
14184
|
-
updatedAt: (0,
|
|
14640
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
14185
14641
|
};
|
|
14186
14642
|
return this.updateAppointment(appointmentId, updateData);
|
|
14187
14643
|
}
|
|
@@ -14195,7 +14651,7 @@ var AppointmentService = class extends BaseService {
|
|
|
14195
14651
|
const updateData = {
|
|
14196
14652
|
paymentStatus,
|
|
14197
14653
|
paymentTransactionId: paymentTransactionId || null,
|
|
14198
|
-
updatedAt: (0,
|
|
14654
|
+
updatedAt: (0, import_firestore46.serverTimestamp)()
|
|
14199
14655
|
};
|
|
14200
14656
|
return this.updateAppointment(appointmentId, updateData);
|
|
14201
14657
|
}
|
|
@@ -14237,38 +14693,38 @@ var AppointmentService = class extends BaseService {
|
|
|
14237
14693
|
"rescheduled_by_clinic" /* RESCHEDULED_BY_CLINIC */
|
|
14238
14694
|
];
|
|
14239
14695
|
const constraints = [];
|
|
14240
|
-
constraints.push((0,
|
|
14241
|
-
constraints.push((0,
|
|
14696
|
+
constraints.push((0, import_firestore46.where)("patientId", "==", patientId));
|
|
14697
|
+
constraints.push((0, import_firestore46.where)("status", "in", upcomingStatuses));
|
|
14242
14698
|
constraints.push(
|
|
14243
|
-
(0,
|
|
14699
|
+
(0, import_firestore46.where)(
|
|
14244
14700
|
"appointmentStartTime",
|
|
14245
14701
|
">=",
|
|
14246
|
-
|
|
14702
|
+
import_firestore46.Timestamp.fromDate(effectiveStartDate)
|
|
14247
14703
|
)
|
|
14248
14704
|
);
|
|
14249
14705
|
if (options == null ? void 0 : options.endDate) {
|
|
14250
14706
|
constraints.push(
|
|
14251
|
-
(0,
|
|
14707
|
+
(0, import_firestore46.where)(
|
|
14252
14708
|
"appointmentStartTime",
|
|
14253
14709
|
"<=",
|
|
14254
|
-
|
|
14710
|
+
import_firestore46.Timestamp.fromDate(options.endDate)
|
|
14255
14711
|
)
|
|
14256
14712
|
);
|
|
14257
14713
|
}
|
|
14258
|
-
constraints.push((0,
|
|
14714
|
+
constraints.push((0, import_firestore46.orderBy)("appointmentStartTime", "asc"));
|
|
14259
14715
|
if (options == null ? void 0 : options.limit) {
|
|
14260
|
-
constraints.push((0,
|
|
14716
|
+
constraints.push((0, import_firestore46.limit)(options.limit));
|
|
14261
14717
|
}
|
|
14262
14718
|
if (options == null ? void 0 : options.startAfter) {
|
|
14263
|
-
constraints.push((0,
|
|
14719
|
+
constraints.push((0, import_firestore46.startAfter)(options.startAfter));
|
|
14264
14720
|
}
|
|
14265
|
-
const q = (0,
|
|
14266
|
-
(0,
|
|
14721
|
+
const q = (0, import_firestore46.query)(
|
|
14722
|
+
(0, import_firestore46.collection)(this.db, APPOINTMENTS_COLLECTION),
|
|
14267
14723
|
...constraints
|
|
14268
14724
|
);
|
|
14269
|
-
const querySnapshot = await (0,
|
|
14725
|
+
const querySnapshot = await (0, import_firestore46.getDocs)(q);
|
|
14270
14726
|
const appointments = querySnapshot.docs.map(
|
|
14271
|
-
(
|
|
14727
|
+
(doc36) => doc36.data()
|
|
14272
14728
|
);
|
|
14273
14729
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14274
14730
|
console.log(
|
|
@@ -14310,38 +14766,38 @@ var AppointmentService = class extends BaseService {
|
|
|
14310
14766
|
pastStatuses.push("no_show" /* NO_SHOW */);
|
|
14311
14767
|
}
|
|
14312
14768
|
const constraints = [];
|
|
14313
|
-
constraints.push((0,
|
|
14314
|
-
constraints.push((0,
|
|
14769
|
+
constraints.push((0, import_firestore46.where)("patientId", "==", patientId));
|
|
14770
|
+
constraints.push((0, import_firestore46.where)("status", "in", pastStatuses));
|
|
14315
14771
|
if (options == null ? void 0 : options.startDate) {
|
|
14316
14772
|
constraints.push(
|
|
14317
|
-
(0,
|
|
14773
|
+
(0, import_firestore46.where)(
|
|
14318
14774
|
"appointmentStartTime",
|
|
14319
14775
|
">=",
|
|
14320
|
-
|
|
14776
|
+
import_firestore46.Timestamp.fromDate(options.startDate)
|
|
14321
14777
|
)
|
|
14322
14778
|
);
|
|
14323
14779
|
}
|
|
14324
14780
|
constraints.push(
|
|
14325
|
-
(0,
|
|
14781
|
+
(0, import_firestore46.where)(
|
|
14326
14782
|
"appointmentStartTime",
|
|
14327
14783
|
"<=",
|
|
14328
|
-
|
|
14784
|
+
import_firestore46.Timestamp.fromDate(effectiveEndDate)
|
|
14329
14785
|
)
|
|
14330
14786
|
);
|
|
14331
|
-
constraints.push((0,
|
|
14787
|
+
constraints.push((0, import_firestore46.orderBy)("appointmentStartTime", "desc"));
|
|
14332
14788
|
if (options == null ? void 0 : options.limit) {
|
|
14333
|
-
constraints.push((0,
|
|
14789
|
+
constraints.push((0, import_firestore46.limit)(options.limit));
|
|
14334
14790
|
}
|
|
14335
14791
|
if (options == null ? void 0 : options.startAfter) {
|
|
14336
|
-
constraints.push((0,
|
|
14792
|
+
constraints.push((0, import_firestore46.startAfter)(options.startAfter));
|
|
14337
14793
|
}
|
|
14338
|
-
const q = (0,
|
|
14339
|
-
(0,
|
|
14794
|
+
const q = (0, import_firestore46.query)(
|
|
14795
|
+
(0, import_firestore46.collection)(this.db, APPOINTMENTS_COLLECTION),
|
|
14340
14796
|
...constraints
|
|
14341
14797
|
);
|
|
14342
|
-
const querySnapshot = await (0,
|
|
14798
|
+
const querySnapshot = await (0, import_firestore46.getDocs)(q);
|
|
14343
14799
|
const appointments = querySnapshot.docs.map(
|
|
14344
|
-
(
|
|
14800
|
+
(doc36) => doc36.data()
|
|
14345
14801
|
);
|
|
14346
14802
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14347
14803
|
console.log(
|
|
@@ -14359,7 +14815,7 @@ var AppointmentService = class extends BaseService {
|
|
|
14359
14815
|
};
|
|
14360
14816
|
|
|
14361
14817
|
// src/services/patient/patientRequirements.service.ts
|
|
14362
|
-
var
|
|
14818
|
+
var import_firestore47 = require("firebase/firestore");
|
|
14363
14819
|
|
|
14364
14820
|
// src/types/patient/patient-requirements.ts
|
|
14365
14821
|
var PatientInstructionStatus = /* @__PURE__ */ ((PatientInstructionStatus2) => {
|
|
@@ -14389,13 +14845,13 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14389
14845
|
super(db, auth, app);
|
|
14390
14846
|
}
|
|
14391
14847
|
getPatientRequirementsCollectionRef(patientId) {
|
|
14392
|
-
return (0,
|
|
14848
|
+
return (0, import_firestore47.collection)(
|
|
14393
14849
|
this.db,
|
|
14394
14850
|
`patients/${patientId}/${PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME}`
|
|
14395
14851
|
);
|
|
14396
14852
|
}
|
|
14397
14853
|
getPatientRequirementDocRef(patientId, instanceId) {
|
|
14398
|
-
return (0,
|
|
14854
|
+
return (0, import_firestore47.doc)(
|
|
14399
14855
|
this.getPatientRequirementsCollectionRef(patientId),
|
|
14400
14856
|
instanceId
|
|
14401
14857
|
);
|
|
@@ -14408,7 +14864,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14408
14864
|
*/
|
|
14409
14865
|
async getPatientRequirementInstance(patientId, instanceId) {
|
|
14410
14866
|
const docRef = this.getPatientRequirementDocRef(patientId, instanceId);
|
|
14411
|
-
const docSnap = await (0,
|
|
14867
|
+
const docSnap = await (0, import_firestore47.getDoc)(docRef);
|
|
14412
14868
|
if (!docSnap.exists()) {
|
|
14413
14869
|
return null;
|
|
14414
14870
|
}
|
|
@@ -14427,22 +14883,22 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14427
14883
|
*/
|
|
14428
14884
|
async getAllPatientRequirementInstances(patientId, filters, pageLimit = 20, lastVisible) {
|
|
14429
14885
|
const collRef = this.getPatientRequirementsCollectionRef(patientId);
|
|
14430
|
-
let q = (0,
|
|
14886
|
+
let q = (0, import_firestore47.query)(collRef, (0, import_firestore47.orderBy)("createdAt", "desc"));
|
|
14431
14887
|
const queryConstraints = [];
|
|
14432
14888
|
if ((filters == null ? void 0 : filters.appointmentId) && filters.appointmentId !== "all") {
|
|
14433
14889
|
queryConstraints.push(
|
|
14434
|
-
(0,
|
|
14890
|
+
(0, import_firestore47.where)("appointmentId", "==", filters.appointmentId)
|
|
14435
14891
|
);
|
|
14436
14892
|
}
|
|
14437
14893
|
if ((filters == null ? void 0 : filters.statuses) && filters.statuses.length > 0) {
|
|
14438
|
-
queryConstraints.push((0,
|
|
14894
|
+
queryConstraints.push((0, import_firestore47.where)("overallStatus", "in", filters.statuses));
|
|
14439
14895
|
}
|
|
14440
14896
|
if (lastVisible) {
|
|
14441
|
-
queryConstraints.push((0,
|
|
14897
|
+
queryConstraints.push((0, import_firestore47.startAfter)(lastVisible));
|
|
14442
14898
|
}
|
|
14443
|
-
queryConstraints.push((0,
|
|
14444
|
-
q = (0,
|
|
14445
|
-
const snapshot = await (0,
|
|
14899
|
+
queryConstraints.push((0, import_firestore47.limit)(pageLimit));
|
|
14900
|
+
q = (0, import_firestore47.query)(collRef, ...queryConstraints);
|
|
14901
|
+
const snapshot = await (0, import_firestore47.getDocs)(q);
|
|
14446
14902
|
let requirements = snapshot.docs.map((docSnap) => {
|
|
14447
14903
|
const data = docSnap.data();
|
|
14448
14904
|
return { id: docSnap.id, ...data };
|
|
@@ -14485,7 +14941,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14485
14941
|
*/
|
|
14486
14942
|
async completeInstruction(patientId, instanceId, instructionId) {
|
|
14487
14943
|
const instanceRef = this.getPatientRequirementDocRef(patientId, instanceId);
|
|
14488
|
-
const instanceSnap = await (0,
|
|
14944
|
+
const instanceSnap = await (0, import_firestore47.getDoc)(instanceRef);
|
|
14489
14945
|
if (!instanceSnap.exists()) {
|
|
14490
14946
|
throw new Error(
|
|
14491
14947
|
`PatientRequirementInstance ${instanceId} not found for patient ${patientId}.`
|
|
@@ -14513,7 +14969,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14513
14969
|
`Instruction ${instructionId} is in status ${instructionToUpdate.status} and cannot be marked as completed.`
|
|
14514
14970
|
);
|
|
14515
14971
|
}
|
|
14516
|
-
const now =
|
|
14972
|
+
const now = import_firestore47.Timestamp.now();
|
|
14517
14973
|
const updatedInstructions = [...instance.instructions];
|
|
14518
14974
|
updatedInstructions[instructionIndex] = {
|
|
14519
14975
|
...instructionToUpdate,
|
|
@@ -14540,7 +14996,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14540
14996
|
if (newOverallStatus !== instance.overallStatus) {
|
|
14541
14997
|
updatePayload.overallStatus = newOverallStatus;
|
|
14542
14998
|
}
|
|
14543
|
-
await (0,
|
|
14999
|
+
await (0, import_firestore47.updateDoc)(instanceRef, updatePayload);
|
|
14544
15000
|
return {
|
|
14545
15001
|
...instance,
|
|
14546
15002
|
instructions: updatedInstructions,
|
|
@@ -14553,7 +15009,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14553
15009
|
};
|
|
14554
15010
|
|
|
14555
15011
|
// src/backoffice/services/brand.service.ts
|
|
14556
|
-
var
|
|
15012
|
+
var import_firestore48 = require("firebase/firestore");
|
|
14557
15013
|
|
|
14558
15014
|
// src/backoffice/types/brand.types.ts
|
|
14559
15015
|
var BRANDS_COLLECTION = "brands";
|
|
@@ -14564,7 +15020,7 @@ var BrandService = class extends BaseService {
|
|
|
14564
15020
|
* Gets reference to brands collection
|
|
14565
15021
|
*/
|
|
14566
15022
|
getBrandsRef() {
|
|
14567
|
-
return (0,
|
|
15023
|
+
return (0, import_firestore48.collection)(this.db, BRANDS_COLLECTION);
|
|
14568
15024
|
}
|
|
14569
15025
|
/**
|
|
14570
15026
|
* Creates a new brand
|
|
@@ -14577,19 +15033,19 @@ var BrandService = class extends BaseService {
|
|
|
14577
15033
|
updatedAt: now,
|
|
14578
15034
|
isActive: true
|
|
14579
15035
|
};
|
|
14580
|
-
const docRef = await (0,
|
|
15036
|
+
const docRef = await (0, import_firestore48.addDoc)(this.getBrandsRef(), newBrand);
|
|
14581
15037
|
return { id: docRef.id, ...newBrand };
|
|
14582
15038
|
}
|
|
14583
15039
|
/**
|
|
14584
15040
|
* Gets all active brands
|
|
14585
15041
|
*/
|
|
14586
15042
|
async getAll() {
|
|
14587
|
-
const q = (0,
|
|
14588
|
-
const snapshot = await (0,
|
|
15043
|
+
const q = (0, import_firestore48.query)(this.getBrandsRef(), (0, import_firestore48.where)("isActive", "==", true));
|
|
15044
|
+
const snapshot = await (0, import_firestore48.getDocs)(q);
|
|
14589
15045
|
return snapshot.docs.map(
|
|
14590
|
-
(
|
|
14591
|
-
id:
|
|
14592
|
-
...
|
|
15046
|
+
(doc36) => ({
|
|
15047
|
+
id: doc36.id,
|
|
15048
|
+
...doc36.data()
|
|
14593
15049
|
})
|
|
14594
15050
|
);
|
|
14595
15051
|
}
|
|
@@ -14601,8 +15057,8 @@ var BrandService = class extends BaseService {
|
|
|
14601
15057
|
...brand,
|
|
14602
15058
|
updatedAt: /* @__PURE__ */ new Date()
|
|
14603
15059
|
};
|
|
14604
|
-
const docRef = (0,
|
|
14605
|
-
await (0,
|
|
15060
|
+
const docRef = (0, import_firestore48.doc)(this.getBrandsRef(), brandId);
|
|
15061
|
+
await (0, import_firestore48.updateDoc)(docRef, updateData);
|
|
14606
15062
|
return this.getById(brandId);
|
|
14607
15063
|
}
|
|
14608
15064
|
/**
|
|
@@ -14617,8 +15073,8 @@ var BrandService = class extends BaseService {
|
|
|
14617
15073
|
* Gets a brand by ID
|
|
14618
15074
|
*/
|
|
14619
15075
|
async getById(brandId) {
|
|
14620
|
-
const docRef = (0,
|
|
14621
|
-
const docSnap = await (0,
|
|
15076
|
+
const docRef = (0, import_firestore48.doc)(this.getBrandsRef(), brandId);
|
|
15077
|
+
const docSnap = await (0, import_firestore48.getDoc)(docRef);
|
|
14622
15078
|
if (!docSnap.exists()) return null;
|
|
14623
15079
|
return {
|
|
14624
15080
|
id: docSnap.id,
|
|
@@ -14628,7 +15084,7 @@ var BrandService = class extends BaseService {
|
|
|
14628
15084
|
};
|
|
14629
15085
|
|
|
14630
15086
|
// src/backoffice/services/category.service.ts
|
|
14631
|
-
var
|
|
15087
|
+
var import_firestore49 = require("firebase/firestore");
|
|
14632
15088
|
|
|
14633
15089
|
// src/backoffice/types/category.types.ts
|
|
14634
15090
|
var CATEGORIES_COLLECTION = "backoffice_categories";
|
|
@@ -14639,7 +15095,7 @@ var CategoryService = class extends BaseService {
|
|
|
14639
15095
|
* Referenca na Firestore kolekciju kategorija
|
|
14640
15096
|
*/
|
|
14641
15097
|
get categoriesRef() {
|
|
14642
|
-
return (0,
|
|
15098
|
+
return (0, import_firestore49.collection)(this.db, CATEGORIES_COLLECTION);
|
|
14643
15099
|
}
|
|
14644
15100
|
/**
|
|
14645
15101
|
* Kreira novu kategoriju u sistemu
|
|
@@ -14654,7 +15110,7 @@ var CategoryService = class extends BaseService {
|
|
|
14654
15110
|
updatedAt: now,
|
|
14655
15111
|
isActive: true
|
|
14656
15112
|
};
|
|
14657
|
-
const docRef = await (0,
|
|
15113
|
+
const docRef = await (0, import_firestore49.addDoc)(this.categoriesRef, newCategory);
|
|
14658
15114
|
return { id: docRef.id, ...newCategory };
|
|
14659
15115
|
}
|
|
14660
15116
|
/**
|
|
@@ -14662,12 +15118,12 @@ var CategoryService = class extends BaseService {
|
|
|
14662
15118
|
* @returns Lista aktivnih kategorija
|
|
14663
15119
|
*/
|
|
14664
15120
|
async getAll() {
|
|
14665
|
-
const q = (0,
|
|
14666
|
-
const snapshot = await (0,
|
|
15121
|
+
const q = (0, import_firestore49.query)(this.categoriesRef, (0, import_firestore49.where)("isActive", "==", true));
|
|
15122
|
+
const snapshot = await (0, import_firestore49.getDocs)(q);
|
|
14667
15123
|
return snapshot.docs.map(
|
|
14668
|
-
(
|
|
14669
|
-
id:
|
|
14670
|
-
...
|
|
15124
|
+
(doc36) => ({
|
|
15125
|
+
id: doc36.id,
|
|
15126
|
+
...doc36.data()
|
|
14671
15127
|
})
|
|
14672
15128
|
);
|
|
14673
15129
|
}
|
|
@@ -14677,16 +15133,16 @@ var CategoryService = class extends BaseService {
|
|
|
14677
15133
|
* @returns Lista kategorija koje pripadaju traženoj familiji
|
|
14678
15134
|
*/
|
|
14679
15135
|
async getAllByFamily(family) {
|
|
14680
|
-
const q = (0,
|
|
15136
|
+
const q = (0, import_firestore49.query)(
|
|
14681
15137
|
this.categoriesRef,
|
|
14682
|
-
(0,
|
|
14683
|
-
(0,
|
|
15138
|
+
(0, import_firestore49.where)("family", "==", family),
|
|
15139
|
+
(0, import_firestore49.where)("isActive", "==", true)
|
|
14684
15140
|
);
|
|
14685
|
-
const snapshot = await (0,
|
|
15141
|
+
const snapshot = await (0, import_firestore49.getDocs)(q);
|
|
14686
15142
|
return snapshot.docs.map(
|
|
14687
|
-
(
|
|
14688
|
-
id:
|
|
14689
|
-
...
|
|
15143
|
+
(doc36) => ({
|
|
15144
|
+
id: doc36.id,
|
|
15145
|
+
...doc36.data()
|
|
14690
15146
|
})
|
|
14691
15147
|
);
|
|
14692
15148
|
}
|
|
@@ -14701,8 +15157,8 @@ var CategoryService = class extends BaseService {
|
|
|
14701
15157
|
...category,
|
|
14702
15158
|
updatedAt: /* @__PURE__ */ new Date()
|
|
14703
15159
|
};
|
|
14704
|
-
const docRef = (0,
|
|
14705
|
-
await (0,
|
|
15160
|
+
const docRef = (0, import_firestore49.doc)(this.categoriesRef, id);
|
|
15161
|
+
await (0, import_firestore49.updateDoc)(docRef, updateData);
|
|
14706
15162
|
return this.getById(id);
|
|
14707
15163
|
}
|
|
14708
15164
|
/**
|
|
@@ -14718,8 +15174,8 @@ var CategoryService = class extends BaseService {
|
|
|
14718
15174
|
* @returns Kategorija ili null ako ne postoji
|
|
14719
15175
|
*/
|
|
14720
15176
|
async getById(id) {
|
|
14721
|
-
const docRef = (0,
|
|
14722
|
-
const docSnap = await (0,
|
|
15177
|
+
const docRef = (0, import_firestore49.doc)(this.categoriesRef, id);
|
|
15178
|
+
const docSnap = await (0, import_firestore49.getDoc)(docRef);
|
|
14723
15179
|
if (!docSnap.exists()) return null;
|
|
14724
15180
|
return {
|
|
14725
15181
|
id: docSnap.id,
|
|
@@ -14729,7 +15185,7 @@ var CategoryService = class extends BaseService {
|
|
|
14729
15185
|
};
|
|
14730
15186
|
|
|
14731
15187
|
// src/backoffice/services/subcategory.service.ts
|
|
14732
|
-
var
|
|
15188
|
+
var import_firestore50 = require("firebase/firestore");
|
|
14733
15189
|
|
|
14734
15190
|
// src/backoffice/types/subcategory.types.ts
|
|
14735
15191
|
var SUBCATEGORIES_COLLECTION = "subcategories";
|
|
@@ -14741,7 +15197,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
14741
15197
|
* @param categoryId - ID roditeljske kategorije
|
|
14742
15198
|
*/
|
|
14743
15199
|
getSubcategoriesRef(categoryId) {
|
|
14744
|
-
return (0,
|
|
15200
|
+
return (0, import_firestore50.collection)(
|
|
14745
15201
|
this.db,
|
|
14746
15202
|
CATEGORIES_COLLECTION,
|
|
14747
15203
|
categoryId,
|
|
@@ -14763,7 +15219,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
14763
15219
|
updatedAt: now,
|
|
14764
15220
|
isActive: true
|
|
14765
15221
|
};
|
|
14766
|
-
const docRef = await (0,
|
|
15222
|
+
const docRef = await (0, import_firestore50.addDoc)(
|
|
14767
15223
|
this.getSubcategoriesRef(categoryId),
|
|
14768
15224
|
newSubcategory
|
|
14769
15225
|
);
|
|
@@ -14775,15 +15231,15 @@ var SubcategoryService = class extends BaseService {
|
|
|
14775
15231
|
* @returns Lista aktivnih podkategorija
|
|
14776
15232
|
*/
|
|
14777
15233
|
async getAllByCategoryId(categoryId) {
|
|
14778
|
-
const q = (0,
|
|
15234
|
+
const q = (0, import_firestore50.query)(
|
|
14779
15235
|
this.getSubcategoriesRef(categoryId),
|
|
14780
|
-
(0,
|
|
15236
|
+
(0, import_firestore50.where)("isActive", "==", true)
|
|
14781
15237
|
);
|
|
14782
|
-
const snapshot = await (0,
|
|
15238
|
+
const snapshot = await (0, import_firestore50.getDocs)(q);
|
|
14783
15239
|
return snapshot.docs.map(
|
|
14784
|
-
(
|
|
14785
|
-
id:
|
|
14786
|
-
...
|
|
15240
|
+
(doc36) => ({
|
|
15241
|
+
id: doc36.id,
|
|
15242
|
+
...doc36.data()
|
|
14787
15243
|
})
|
|
14788
15244
|
);
|
|
14789
15245
|
}
|
|
@@ -14799,8 +15255,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
14799
15255
|
...subcategory,
|
|
14800
15256
|
updatedAt: /* @__PURE__ */ new Date()
|
|
14801
15257
|
};
|
|
14802
|
-
const docRef = (0,
|
|
14803
|
-
await (0,
|
|
15258
|
+
const docRef = (0, import_firestore50.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
15259
|
+
await (0, import_firestore50.updateDoc)(docRef, updateData);
|
|
14804
15260
|
return this.getById(categoryId, subcategoryId);
|
|
14805
15261
|
}
|
|
14806
15262
|
/**
|
|
@@ -14818,8 +15274,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
14818
15274
|
* @returns Podkategorija ili null ako ne postoji
|
|
14819
15275
|
*/
|
|
14820
15276
|
async getById(categoryId, subcategoryId) {
|
|
14821
|
-
const docRef = (0,
|
|
14822
|
-
const docSnap = await (0,
|
|
15277
|
+
const docRef = (0, import_firestore50.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
15278
|
+
const docSnap = await (0, import_firestore50.getDoc)(docRef);
|
|
14823
15279
|
if (!docSnap.exists()) return null;
|
|
14824
15280
|
return {
|
|
14825
15281
|
id: docSnap.id,
|
|
@@ -14829,7 +15285,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
14829
15285
|
};
|
|
14830
15286
|
|
|
14831
15287
|
// src/backoffice/services/technology.service.ts
|
|
14832
|
-
var
|
|
15288
|
+
var import_firestore51 = require("firebase/firestore");
|
|
14833
15289
|
var DEFAULT_CERTIFICATION_REQUIREMENT = {
|
|
14834
15290
|
minimumLevel: "aesthetician" /* AESTHETICIAN */,
|
|
14835
15291
|
requiredSpecialties: []
|
|
@@ -14839,7 +15295,7 @@ var TechnologyService = class extends BaseService {
|
|
|
14839
15295
|
* Vraća referencu na Firestore kolekciju tehnologija
|
|
14840
15296
|
*/
|
|
14841
15297
|
getTechnologiesRef() {
|
|
14842
|
-
return (0,
|
|
15298
|
+
return (0, import_firestore51.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
14843
15299
|
}
|
|
14844
15300
|
/**
|
|
14845
15301
|
* Kreira novu tehnologiju
|
|
@@ -14862,7 +15318,7 @@ var TechnologyService = class extends BaseService {
|
|
|
14862
15318
|
benefits: technology.benefits || [],
|
|
14863
15319
|
certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
|
|
14864
15320
|
};
|
|
14865
|
-
const docRef = await (0,
|
|
15321
|
+
const docRef = await (0, import_firestore51.addDoc)(this.getTechnologiesRef(), newTechnology);
|
|
14866
15322
|
return { id: docRef.id, ...newTechnology };
|
|
14867
15323
|
}
|
|
14868
15324
|
/**
|
|
@@ -14870,12 +15326,12 @@ var TechnologyService = class extends BaseService {
|
|
|
14870
15326
|
* @returns Lista aktivnih tehnologija
|
|
14871
15327
|
*/
|
|
14872
15328
|
async getAll() {
|
|
14873
|
-
const q = (0,
|
|
14874
|
-
const snapshot = await (0,
|
|
15329
|
+
const q = (0, import_firestore51.query)(this.getTechnologiesRef(), (0, import_firestore51.where)("isActive", "==", true));
|
|
15330
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
14875
15331
|
return snapshot.docs.map(
|
|
14876
|
-
(
|
|
14877
|
-
id:
|
|
14878
|
-
...
|
|
15332
|
+
(doc36) => ({
|
|
15333
|
+
id: doc36.id,
|
|
15334
|
+
...doc36.data()
|
|
14879
15335
|
})
|
|
14880
15336
|
);
|
|
14881
15337
|
}
|
|
@@ -14885,16 +15341,16 @@ var TechnologyService = class extends BaseService {
|
|
|
14885
15341
|
* @returns Lista aktivnih tehnologija
|
|
14886
15342
|
*/
|
|
14887
15343
|
async getAllByFamily(family) {
|
|
14888
|
-
const q = (0,
|
|
15344
|
+
const q = (0, import_firestore51.query)(
|
|
14889
15345
|
this.getTechnologiesRef(),
|
|
14890
|
-
(0,
|
|
14891
|
-
(0,
|
|
15346
|
+
(0, import_firestore51.where)("isActive", "==", true),
|
|
15347
|
+
(0, import_firestore51.where)("family", "==", family)
|
|
14892
15348
|
);
|
|
14893
|
-
const snapshot = await (0,
|
|
15349
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
14894
15350
|
return snapshot.docs.map(
|
|
14895
|
-
(
|
|
14896
|
-
id:
|
|
14897
|
-
...
|
|
15351
|
+
(doc36) => ({
|
|
15352
|
+
id: doc36.id,
|
|
15353
|
+
...doc36.data()
|
|
14898
15354
|
})
|
|
14899
15355
|
);
|
|
14900
15356
|
}
|
|
@@ -14904,16 +15360,16 @@ var TechnologyService = class extends BaseService {
|
|
|
14904
15360
|
* @returns Lista aktivnih tehnologija
|
|
14905
15361
|
*/
|
|
14906
15362
|
async getAllByCategoryId(categoryId) {
|
|
14907
|
-
const q = (0,
|
|
15363
|
+
const q = (0, import_firestore51.query)(
|
|
14908
15364
|
this.getTechnologiesRef(),
|
|
14909
|
-
(0,
|
|
14910
|
-
(0,
|
|
15365
|
+
(0, import_firestore51.where)("isActive", "==", true),
|
|
15366
|
+
(0, import_firestore51.where)("categoryId", "==", categoryId)
|
|
14911
15367
|
);
|
|
14912
|
-
const snapshot = await (0,
|
|
15368
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
14913
15369
|
return snapshot.docs.map(
|
|
14914
|
-
(
|
|
14915
|
-
id:
|
|
14916
|
-
...
|
|
15370
|
+
(doc36) => ({
|
|
15371
|
+
id: doc36.id,
|
|
15372
|
+
...doc36.data()
|
|
14917
15373
|
})
|
|
14918
15374
|
);
|
|
14919
15375
|
}
|
|
@@ -14923,16 +15379,16 @@ var TechnologyService = class extends BaseService {
|
|
|
14923
15379
|
* @returns Lista aktivnih tehnologija
|
|
14924
15380
|
*/
|
|
14925
15381
|
async getAllBySubcategoryId(subcategoryId) {
|
|
14926
|
-
const q = (0,
|
|
15382
|
+
const q = (0, import_firestore51.query)(
|
|
14927
15383
|
this.getTechnologiesRef(),
|
|
14928
|
-
(0,
|
|
14929
|
-
(0,
|
|
15384
|
+
(0, import_firestore51.where)("isActive", "==", true),
|
|
15385
|
+
(0, import_firestore51.where)("subcategoryId", "==", subcategoryId)
|
|
14930
15386
|
);
|
|
14931
|
-
const snapshot = await (0,
|
|
15387
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
14932
15388
|
return snapshot.docs.map(
|
|
14933
|
-
(
|
|
14934
|
-
id:
|
|
14935
|
-
...
|
|
15389
|
+
(doc36) => ({
|
|
15390
|
+
id: doc36.id,
|
|
15391
|
+
...doc36.data()
|
|
14936
15392
|
})
|
|
14937
15393
|
);
|
|
14938
15394
|
}
|
|
@@ -14947,8 +15403,8 @@ var TechnologyService = class extends BaseService {
|
|
|
14947
15403
|
...technology,
|
|
14948
15404
|
updatedAt: /* @__PURE__ */ new Date()
|
|
14949
15405
|
};
|
|
14950
|
-
const docRef = (0,
|
|
14951
|
-
await (0,
|
|
15406
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15407
|
+
await (0, import_firestore51.updateDoc)(docRef, updateData);
|
|
14952
15408
|
return this.getById(technologyId);
|
|
14953
15409
|
}
|
|
14954
15410
|
/**
|
|
@@ -14966,8 +15422,8 @@ var TechnologyService = class extends BaseService {
|
|
|
14966
15422
|
* @returns Tehnologija ili null ako ne postoji
|
|
14967
15423
|
*/
|
|
14968
15424
|
async getById(technologyId) {
|
|
14969
|
-
const docRef = (0,
|
|
14970
|
-
const docSnap = await (0,
|
|
15425
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15426
|
+
const docSnap = await (0, import_firestore51.getDoc)(docRef);
|
|
14971
15427
|
if (!docSnap.exists()) return null;
|
|
14972
15428
|
return {
|
|
14973
15429
|
id: docSnap.id,
|
|
@@ -14981,10 +15437,10 @@ var TechnologyService = class extends BaseService {
|
|
|
14981
15437
|
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
14982
15438
|
*/
|
|
14983
15439
|
async addRequirement(technologyId, requirement) {
|
|
14984
|
-
const docRef = (0,
|
|
15440
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
14985
15441
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
14986
|
-
await (0,
|
|
14987
|
-
[requirementType]: (0,
|
|
15442
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15443
|
+
[requirementType]: (0, import_firestore51.arrayUnion)(requirement),
|
|
14988
15444
|
updatedAt: /* @__PURE__ */ new Date()
|
|
14989
15445
|
});
|
|
14990
15446
|
return this.getById(technologyId);
|
|
@@ -14996,10 +15452,10 @@ var TechnologyService = class extends BaseService {
|
|
|
14996
15452
|
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
14997
15453
|
*/
|
|
14998
15454
|
async removeRequirement(technologyId, requirement) {
|
|
14999
|
-
const docRef = (0,
|
|
15455
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15000
15456
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
15001
|
-
await (0,
|
|
15002
|
-
[requirementType]: (0,
|
|
15457
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15458
|
+
[requirementType]: (0, import_firestore51.arrayRemove)(requirement),
|
|
15003
15459
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15004
15460
|
});
|
|
15005
15461
|
return this.getById(technologyId);
|
|
@@ -15036,9 +15492,9 @@ var TechnologyService = class extends BaseService {
|
|
|
15036
15492
|
* @returns Ažurirana tehnologija
|
|
15037
15493
|
*/
|
|
15038
15494
|
async addBlockingCondition(technologyId, condition) {
|
|
15039
|
-
const docRef = (0,
|
|
15040
|
-
await (0,
|
|
15041
|
-
blockingConditions: (0,
|
|
15495
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15496
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15497
|
+
blockingConditions: (0, import_firestore51.arrayUnion)(condition),
|
|
15042
15498
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15043
15499
|
});
|
|
15044
15500
|
return this.getById(technologyId);
|
|
@@ -15050,9 +15506,9 @@ var TechnologyService = class extends BaseService {
|
|
|
15050
15506
|
* @returns Ažurirana tehnologija
|
|
15051
15507
|
*/
|
|
15052
15508
|
async removeBlockingCondition(technologyId, condition) {
|
|
15053
|
-
const docRef = (0,
|
|
15054
|
-
await (0,
|
|
15055
|
-
blockingConditions: (0,
|
|
15509
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15510
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15511
|
+
blockingConditions: (0, import_firestore51.arrayRemove)(condition),
|
|
15056
15512
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15057
15513
|
});
|
|
15058
15514
|
return this.getById(technologyId);
|
|
@@ -15064,9 +15520,9 @@ var TechnologyService = class extends BaseService {
|
|
|
15064
15520
|
* @returns Ažurirana tehnologija
|
|
15065
15521
|
*/
|
|
15066
15522
|
async addContraindication(technologyId, contraindication) {
|
|
15067
|
-
const docRef = (0,
|
|
15068
|
-
await (0,
|
|
15069
|
-
contraindications: (0,
|
|
15523
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15524
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15525
|
+
contraindications: (0, import_firestore51.arrayUnion)(contraindication),
|
|
15070
15526
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15071
15527
|
});
|
|
15072
15528
|
return this.getById(technologyId);
|
|
@@ -15078,9 +15534,9 @@ var TechnologyService = class extends BaseService {
|
|
|
15078
15534
|
* @returns Ažurirana tehnologija
|
|
15079
15535
|
*/
|
|
15080
15536
|
async removeContraindication(technologyId, contraindication) {
|
|
15081
|
-
const docRef = (0,
|
|
15082
|
-
await (0,
|
|
15083
|
-
contraindications: (0,
|
|
15537
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15538
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15539
|
+
contraindications: (0, import_firestore51.arrayRemove)(contraindication),
|
|
15084
15540
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15085
15541
|
});
|
|
15086
15542
|
return this.getById(technologyId);
|
|
@@ -15092,9 +15548,9 @@ var TechnologyService = class extends BaseService {
|
|
|
15092
15548
|
* @returns Ažurirana tehnologija
|
|
15093
15549
|
*/
|
|
15094
15550
|
async addBenefit(technologyId, benefit) {
|
|
15095
|
-
const docRef = (0,
|
|
15096
|
-
await (0,
|
|
15097
|
-
benefits: (0,
|
|
15551
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15552
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15553
|
+
benefits: (0, import_firestore51.arrayUnion)(benefit),
|
|
15098
15554
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15099
15555
|
});
|
|
15100
15556
|
return this.getById(technologyId);
|
|
@@ -15106,9 +15562,9 @@ var TechnologyService = class extends BaseService {
|
|
|
15106
15562
|
* @returns Ažurirana tehnologija
|
|
15107
15563
|
*/
|
|
15108
15564
|
async removeBenefit(technologyId, benefit) {
|
|
15109
|
-
const docRef = (0,
|
|
15110
|
-
await (0,
|
|
15111
|
-
benefits: (0,
|
|
15565
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15566
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15567
|
+
benefits: (0, import_firestore51.arrayRemove)(benefit),
|
|
15112
15568
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15113
15569
|
});
|
|
15114
15570
|
return this.getById(technologyId);
|
|
@@ -15147,8 +15603,8 @@ var TechnologyService = class extends BaseService {
|
|
|
15147
15603
|
* @returns Ažurirana tehnologija
|
|
15148
15604
|
*/
|
|
15149
15605
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
15150
|
-
const docRef = (0,
|
|
15151
|
-
await (0,
|
|
15606
|
+
const docRef = (0, import_firestore51.doc)(this.getTechnologiesRef(), technologyId);
|
|
15607
|
+
await (0, import_firestore51.updateDoc)(docRef, {
|
|
15152
15608
|
certificationRequirement,
|
|
15153
15609
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15154
15610
|
});
|
|
@@ -15248,7 +15704,7 @@ var TechnologyService = class extends BaseService {
|
|
|
15248
15704
|
};
|
|
15249
15705
|
|
|
15250
15706
|
// src/backoffice/services/product.service.ts
|
|
15251
|
-
var
|
|
15707
|
+
var import_firestore52 = require("firebase/firestore");
|
|
15252
15708
|
|
|
15253
15709
|
// src/backoffice/types/product.types.ts
|
|
15254
15710
|
var PRODUCTS_COLLECTION = "products";
|
|
@@ -15261,7 +15717,7 @@ var ProductService = class extends BaseService {
|
|
|
15261
15717
|
* @returns Firestore collection reference
|
|
15262
15718
|
*/
|
|
15263
15719
|
getProductsRef(technologyId) {
|
|
15264
|
-
return (0,
|
|
15720
|
+
return (0, import_firestore52.collection)(
|
|
15265
15721
|
this.db,
|
|
15266
15722
|
TECHNOLOGIES_COLLECTION,
|
|
15267
15723
|
technologyId,
|
|
@@ -15281,7 +15737,7 @@ var ProductService = class extends BaseService {
|
|
|
15281
15737
|
updatedAt: now,
|
|
15282
15738
|
isActive: true
|
|
15283
15739
|
};
|
|
15284
|
-
const productRef = await (0,
|
|
15740
|
+
const productRef = await (0, import_firestore52.addDoc)(
|
|
15285
15741
|
this.getProductsRef(technologyId),
|
|
15286
15742
|
newProduct
|
|
15287
15743
|
);
|
|
@@ -15291,15 +15747,15 @@ var ProductService = class extends BaseService {
|
|
|
15291
15747
|
* Gets all products for a technology
|
|
15292
15748
|
*/
|
|
15293
15749
|
async getAllByTechnology(technologyId) {
|
|
15294
|
-
const q = (0,
|
|
15750
|
+
const q = (0, import_firestore52.query)(
|
|
15295
15751
|
this.getProductsRef(technologyId),
|
|
15296
|
-
(0,
|
|
15752
|
+
(0, import_firestore52.where)("isActive", "==", true)
|
|
15297
15753
|
);
|
|
15298
|
-
const snapshot = await (0,
|
|
15754
|
+
const snapshot = await (0, import_firestore52.getDocs)(q);
|
|
15299
15755
|
return snapshot.docs.map(
|
|
15300
|
-
(
|
|
15301
|
-
id:
|
|
15302
|
-
...
|
|
15756
|
+
(doc36) => ({
|
|
15757
|
+
id: doc36.id,
|
|
15758
|
+
...doc36.data()
|
|
15303
15759
|
})
|
|
15304
15760
|
);
|
|
15305
15761
|
}
|
|
@@ -15307,21 +15763,21 @@ var ProductService = class extends BaseService {
|
|
|
15307
15763
|
* Gets all products for a brand by filtering through all technologies
|
|
15308
15764
|
*/
|
|
15309
15765
|
async getAllByBrand(brandId) {
|
|
15310
|
-
const allTechnologiesRef = (0,
|
|
15311
|
-
const technologiesSnapshot = await (0,
|
|
15766
|
+
const allTechnologiesRef = (0, import_firestore52.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
15767
|
+
const technologiesSnapshot = await (0, import_firestore52.getDocs)(allTechnologiesRef);
|
|
15312
15768
|
const products = [];
|
|
15313
15769
|
for (const techDoc of technologiesSnapshot.docs) {
|
|
15314
|
-
const q = (0,
|
|
15770
|
+
const q = (0, import_firestore52.query)(
|
|
15315
15771
|
this.getProductsRef(techDoc.id),
|
|
15316
|
-
(0,
|
|
15317
|
-
(0,
|
|
15772
|
+
(0, import_firestore52.where)("brandId", "==", brandId),
|
|
15773
|
+
(0, import_firestore52.where)("isActive", "==", true)
|
|
15318
15774
|
);
|
|
15319
|
-
const snapshot = await (0,
|
|
15775
|
+
const snapshot = await (0, import_firestore52.getDocs)(q);
|
|
15320
15776
|
products.push(
|
|
15321
15777
|
...snapshot.docs.map(
|
|
15322
|
-
(
|
|
15323
|
-
id:
|
|
15324
|
-
...
|
|
15778
|
+
(doc36) => ({
|
|
15779
|
+
id: doc36.id,
|
|
15780
|
+
...doc36.data()
|
|
15325
15781
|
})
|
|
15326
15782
|
)
|
|
15327
15783
|
);
|
|
@@ -15336,8 +15792,8 @@ var ProductService = class extends BaseService {
|
|
|
15336
15792
|
...product,
|
|
15337
15793
|
updatedAt: /* @__PURE__ */ new Date()
|
|
15338
15794
|
};
|
|
15339
|
-
const docRef = (0,
|
|
15340
|
-
await (0,
|
|
15795
|
+
const docRef = (0, import_firestore52.doc)(this.getProductsRef(technologyId), productId);
|
|
15796
|
+
await (0, import_firestore52.updateDoc)(docRef, updateData);
|
|
15341
15797
|
return this.getById(technologyId, productId);
|
|
15342
15798
|
}
|
|
15343
15799
|
/**
|
|
@@ -15352,8 +15808,8 @@ var ProductService = class extends BaseService {
|
|
|
15352
15808
|
* Gets a product by ID
|
|
15353
15809
|
*/
|
|
15354
15810
|
async getById(technologyId, productId) {
|
|
15355
|
-
const docRef = (0,
|
|
15356
|
-
const docSnap = await (0,
|
|
15811
|
+
const docRef = (0, import_firestore52.doc)(this.getProductsRef(technologyId), productId);
|
|
15812
|
+
const docSnap = await (0, import_firestore52.getDoc)(docRef);
|
|
15357
15813
|
if (!docSnap.exists()) return null;
|
|
15358
15814
|
return {
|
|
15359
15815
|
id: docSnap.id,
|
|
@@ -15476,6 +15932,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
15476
15932
|
CalendarEventStatus,
|
|
15477
15933
|
CalendarEventType,
|
|
15478
15934
|
CalendarServiceV2,
|
|
15935
|
+
CalendarServiceV3,
|
|
15479
15936
|
CalendarSyncStatus,
|
|
15480
15937
|
CategoryService,
|
|
15481
15938
|
CertificationLevel,
|
|
@@ -15582,6 +16039,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
15582
16039
|
contraindicationSchema,
|
|
15583
16040
|
createAdminTokenSchema,
|
|
15584
16041
|
createAppointmentSchema,
|
|
16042
|
+
createBlockingEventSchema,
|
|
15585
16043
|
createCalendarEventSchema,
|
|
15586
16044
|
createClinicAdminSchema,
|
|
15587
16045
|
createClinicGroupSchema,
|
|
@@ -15652,6 +16110,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
15652
16110
|
updateAllergySchema,
|
|
15653
16111
|
updateAppointmentSchema,
|
|
15654
16112
|
updateBlockingConditionSchema,
|
|
16113
|
+
updateBlockingEventSchema,
|
|
15655
16114
|
updateCalendarEventSchema,
|
|
15656
16115
|
updateClinicAdminSchema,
|
|
15657
16116
|
updateClinicGroupSchema,
|