@blackcode_sa/metaestetics-api 1.8.4 → 1.8.6
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/index.d.mts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +967 -124
- package/dist/index.mjs +999 -124
- package/package.json +1 -1
- package/src/backoffice/expo-safe/README.md +26 -0
- package/src/backoffice/expo-safe/index.ts +37 -0
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -37,6 +37,8 @@ __export(index_exports, {
|
|
|
37
37
|
AppointmentStatus: () => AppointmentStatus,
|
|
38
38
|
AuthService: () => AuthService,
|
|
39
39
|
BaseService: () => BaseService,
|
|
40
|
+
BlockingCondition: () => BlockingCondition,
|
|
41
|
+
BrandService: () => BrandService,
|
|
40
42
|
CALENDAR_COLLECTION: () => CALENDAR_COLLECTION,
|
|
41
43
|
CLINICS_COLLECTION: () => CLINICS_COLLECTION,
|
|
42
44
|
CLINIC_ADMINS_COLLECTION: () => CLINIC_ADMINS_COLLECTION,
|
|
@@ -46,12 +48,17 @@ __export(index_exports, {
|
|
|
46
48
|
CalendarServiceV2: () => CalendarServiceV2,
|
|
47
49
|
CalendarServiceV3: () => CalendarServiceV3,
|
|
48
50
|
CalendarSyncStatus: () => CalendarSyncStatus,
|
|
51
|
+
CategoryService: () => CategoryService,
|
|
52
|
+
CertificationLevel: () => CertificationLevel,
|
|
53
|
+
CertificationSpecialty: () => CertificationSpecialty,
|
|
49
54
|
ClinicAdminService: () => ClinicAdminService,
|
|
50
55
|
ClinicGroupService: () => ClinicGroupService,
|
|
51
56
|
ClinicPhotoTag: () => ClinicPhotoTag,
|
|
52
57
|
ClinicService: () => ClinicService,
|
|
53
58
|
ClinicTag: () => ClinicTag,
|
|
59
|
+
Contraindication: () => Contraindication,
|
|
54
60
|
CosmeticAllergySubtype: () => CosmeticAllergySubtype,
|
|
61
|
+
Currency: () => Currency,
|
|
55
62
|
DEFAULT_MEDICAL_INFO: () => DEFAULT_MEDICAL_INFO,
|
|
56
63
|
DOCTOR_FORMS_SUBCOLLECTION: () => DOCTOR_FORMS_SUBCOLLECTION,
|
|
57
64
|
DOCUMENTATION_TEMPLATES_COLLECTION: () => DOCUMENTATION_TEMPLATES_COLLECTION,
|
|
@@ -100,15 +107,23 @@ __export(index_exports, {
|
|
|
100
107
|
PractitionerService: () => PractitionerService,
|
|
101
108
|
PractitionerStatus: () => PractitionerStatus,
|
|
102
109
|
PractitionerTokenStatus: () => PractitionerTokenStatus,
|
|
110
|
+
PricingMeasure: () => PricingMeasure,
|
|
111
|
+
ProcedureFamily: () => ProcedureFamily,
|
|
103
112
|
ProcedureService: () => ProcedureService,
|
|
113
|
+
ProductService: () => ProductService,
|
|
104
114
|
REGISTER_TOKENS_COLLECTION: () => REGISTER_TOKENS_COLLECTION,
|
|
105
115
|
REVIEWS_COLLECTION: () => REVIEWS_COLLECTION,
|
|
116
|
+
RequirementType: () => RequirementType,
|
|
106
117
|
ReviewService: () => ReviewService,
|
|
107
118
|
SYNCED_CALENDARS_COLLECTION: () => SYNCED_CALENDARS_COLLECTION,
|
|
108
119
|
SearchLocationEnum: () => SearchLocationEnum,
|
|
120
|
+
SubcategoryService: () => SubcategoryService,
|
|
109
121
|
SubscriptionModel: () => SubscriptionModel,
|
|
110
122
|
SyncedCalendarProvider: () => SyncedCalendarProvider,
|
|
123
|
+
TechnologyService: () => TechnologyService,
|
|
124
|
+
TimeUnit: () => TimeUnit,
|
|
111
125
|
TimestampUtils: () => TimestampUtils,
|
|
126
|
+
TreatmentBenefit: () => TreatmentBenefit,
|
|
112
127
|
USERS_COLLECTION: () => USERS_COLLECTION,
|
|
113
128
|
USER_FORMS_SUBCOLLECTION: () => USER_FORMS_SUBCOLLECTION,
|
|
114
129
|
UserRole: () => UserRole,
|
|
@@ -1054,6 +1069,9 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
|
|
1054
1069
|
// src/types/procedure/index.ts
|
|
1055
1070
|
var PROCEDURES_COLLECTION = "procedures";
|
|
1056
1071
|
|
|
1072
|
+
// src/backoffice/types/technology.types.ts
|
|
1073
|
+
var TECHNOLOGIES_COLLECTION = "technologies";
|
|
1074
|
+
|
|
1057
1075
|
// src/services/appointment/utils/appointment.utils.ts
|
|
1058
1076
|
async function updateAppointmentUtil(db, appointmentId, data) {
|
|
1059
1077
|
try {
|
|
@@ -1230,7 +1248,7 @@ async function searchAppointmentsUtil(db, params) {
|
|
|
1230
1248
|
const q = (0, import_firestore.query)((0, import_firestore.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
1231
1249
|
const querySnapshot = await (0, import_firestore.getDocs)(q);
|
|
1232
1250
|
const appointments = querySnapshot.docs.map(
|
|
1233
|
-
(
|
|
1251
|
+
(doc37) => doc37.data()
|
|
1234
1252
|
);
|
|
1235
1253
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
1236
1254
|
return { appointments, lastDoc };
|
|
@@ -2037,7 +2055,7 @@ var AppointmentService = class extends BaseService {
|
|
|
2037
2055
|
);
|
|
2038
2056
|
const querySnapshot = await (0, import_firestore2.getDocs)(q);
|
|
2039
2057
|
const appointments = querySnapshot.docs.map(
|
|
2040
|
-
(
|
|
2058
|
+
(doc37) => doc37.data()
|
|
2041
2059
|
);
|
|
2042
2060
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
2043
2061
|
console.log(
|
|
@@ -2110,7 +2128,7 @@ var AppointmentService = class extends BaseService {
|
|
|
2110
2128
|
);
|
|
2111
2129
|
const querySnapshot = await (0, import_firestore2.getDocs)(q);
|
|
2112
2130
|
const appointments = querySnapshot.docs.map(
|
|
2113
|
-
(
|
|
2131
|
+
(doc37) => doc37.data()
|
|
2114
2132
|
);
|
|
2115
2133
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
2116
2134
|
console.log(
|
|
@@ -2404,16 +2422,16 @@ var CertificationLevel = /* @__PURE__ */ ((CertificationLevel2) => {
|
|
|
2404
2422
|
CertificationLevel2["PLASTIC_SURGEON"] = "plastic_surgeon";
|
|
2405
2423
|
return CertificationLevel2;
|
|
2406
2424
|
})(CertificationLevel || {});
|
|
2407
|
-
var CertificationSpecialty = /* @__PURE__ */ ((
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
return
|
|
2425
|
+
var CertificationSpecialty = /* @__PURE__ */ ((CertificationSpecialty3) => {
|
|
2426
|
+
CertificationSpecialty3["LASER"] = "laser";
|
|
2427
|
+
CertificationSpecialty3["INJECTABLES"] = "injectables";
|
|
2428
|
+
CertificationSpecialty3["CHEMICAL_PEELS"] = "chemical_peels";
|
|
2429
|
+
CertificationSpecialty3["MICRODERMABRASION"] = "microdermabrasion";
|
|
2430
|
+
CertificationSpecialty3["BODY_CONTOURING"] = "body_contouring";
|
|
2431
|
+
CertificationSpecialty3["SKIN_CARE"] = "skin_care";
|
|
2432
|
+
CertificationSpecialty3["WOUND_CARE"] = "wound_care";
|
|
2433
|
+
CertificationSpecialty3["ANESTHESIA"] = "anesthesia";
|
|
2434
|
+
return CertificationSpecialty3;
|
|
2417
2435
|
})(CertificationSpecialty || {});
|
|
2418
2436
|
|
|
2419
2437
|
// src/services/auth/utils/practitioner.utils.ts
|
|
@@ -3363,7 +3381,7 @@ var MediaService = class extends BaseService {
|
|
|
3363
3381
|
try {
|
|
3364
3382
|
const querySnapshot = await (0, import_firestore5.getDocs)(finalQuery);
|
|
3365
3383
|
const mediaList = querySnapshot.docs.map(
|
|
3366
|
-
(
|
|
3384
|
+
(doc37) => doc37.data()
|
|
3367
3385
|
);
|
|
3368
3386
|
console.log(`[MediaService] Found ${mediaList.length} media items.`);
|
|
3369
3387
|
return mediaList;
|
|
@@ -3417,8 +3435,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
|
|
|
3417
3435
|
}
|
|
3418
3436
|
const patientsSnapshot = await (0, import_firestore6.getDocs)(q);
|
|
3419
3437
|
const patients = [];
|
|
3420
|
-
patientsSnapshot.forEach((
|
|
3421
|
-
patients.push(
|
|
3438
|
+
patientsSnapshot.forEach((doc37) => {
|
|
3439
|
+
patients.push(doc37.data());
|
|
3422
3440
|
});
|
|
3423
3441
|
console.log(
|
|
3424
3442
|
`[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
|
|
@@ -3771,8 +3789,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
|
|
|
3771
3789
|
}
|
|
3772
3790
|
const patientsSnapshot = await (0, import_firestore9.getDocs)(q);
|
|
3773
3791
|
const patients = [];
|
|
3774
|
-
patientsSnapshot.forEach((
|
|
3775
|
-
patients.push(
|
|
3792
|
+
patientsSnapshot.forEach((doc37) => {
|
|
3793
|
+
patients.push(doc37.data());
|
|
3776
3794
|
});
|
|
3777
3795
|
console.log(
|
|
3778
3796
|
`[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
|
|
@@ -4340,7 +4358,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
4340
4358
|
(0, import_firestore11.where)("clinicGroupId", "==", clinicGroupId)
|
|
4341
4359
|
);
|
|
4342
4360
|
const querySnapshot = await (0, import_firestore11.getDocs)(q);
|
|
4343
|
-
return querySnapshot.docs.map((
|
|
4361
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
4344
4362
|
}
|
|
4345
4363
|
async function updateClinicAdmin(db, adminId, data) {
|
|
4346
4364
|
const admin2 = await getClinicAdmin(db, adminId);
|
|
@@ -5003,9 +5021,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
5003
5021
|
};
|
|
5004
5022
|
var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
|
|
5005
5023
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5006
|
-
const
|
|
5007
|
-
if (!
|
|
5008
|
-
const medicalInfo =
|
|
5024
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5025
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5026
|
+
const medicalInfo = doc37.data();
|
|
5009
5027
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
5010
5028
|
throw new Error("Invalid allergy index");
|
|
5011
5029
|
}
|
|
@@ -5032,9 +5050,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
5032
5050
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5033
5051
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
5034
5052
|
const { conditionIndex, ...updateData } = validatedData;
|
|
5035
|
-
const
|
|
5036
|
-
if (!
|
|
5037
|
-
const medicalInfo =
|
|
5053
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5054
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5055
|
+
const medicalInfo = doc37.data();
|
|
5038
5056
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
5039
5057
|
throw new Error("Invalid blocking condition index");
|
|
5040
5058
|
}
|
|
@@ -5051,9 +5069,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
5051
5069
|
};
|
|
5052
5070
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
|
|
5053
5071
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5054
|
-
const
|
|
5055
|
-
if (!
|
|
5056
|
-
const medicalInfo =
|
|
5072
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5073
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5074
|
+
const medicalInfo = doc37.data();
|
|
5057
5075
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
5058
5076
|
throw new Error("Invalid blocking condition index");
|
|
5059
5077
|
}
|
|
@@ -5080,9 +5098,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
5080
5098
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5081
5099
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
5082
5100
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
5083
|
-
const
|
|
5084
|
-
if (!
|
|
5085
|
-
const medicalInfo =
|
|
5101
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5102
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5103
|
+
const medicalInfo = doc37.data();
|
|
5086
5104
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
5087
5105
|
throw new Error("Invalid contraindication index");
|
|
5088
5106
|
}
|
|
@@ -5099,9 +5117,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
5099
5117
|
};
|
|
5100
5118
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
|
|
5101
5119
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5102
|
-
const
|
|
5103
|
-
if (!
|
|
5104
|
-
const medicalInfo =
|
|
5120
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5121
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5122
|
+
const medicalInfo = doc37.data();
|
|
5105
5123
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
5106
5124
|
throw new Error("Invalid contraindication index");
|
|
5107
5125
|
}
|
|
@@ -5128,9 +5146,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
5128
5146
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5129
5147
|
const validatedData = updateMedicationSchema.parse(data);
|
|
5130
5148
|
const { medicationIndex, ...updateData } = validatedData;
|
|
5131
|
-
const
|
|
5132
|
-
if (!
|
|
5133
|
-
const medicalInfo =
|
|
5149
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5150
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5151
|
+
const medicalInfo = doc37.data();
|
|
5134
5152
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
5135
5153
|
throw new Error("Invalid medication index");
|
|
5136
5154
|
}
|
|
@@ -5147,9 +5165,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
5147
5165
|
};
|
|
5148
5166
|
var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
|
|
5149
5167
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
5150
|
-
const
|
|
5151
|
-
if (!
|
|
5152
|
-
const medicalInfo =
|
|
5168
|
+
const doc37 = await (0, import_firestore16.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
5169
|
+
if (!doc37.exists()) throw new Error("Medical info not found");
|
|
5170
|
+
const medicalInfo = doc37.data();
|
|
5153
5171
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
5154
5172
|
throw new Error("Invalid medication index");
|
|
5155
5173
|
}
|
|
@@ -5436,7 +5454,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
5436
5454
|
const finalQuery = (0, import_firestore17.query)(patientsCollectionRef, ...constraints);
|
|
5437
5455
|
const querySnapshot = await (0, import_firestore17.getDocs)(finalQuery);
|
|
5438
5456
|
const patients = querySnapshot.docs.map(
|
|
5439
|
-
(
|
|
5457
|
+
(doc37) => doc37.data()
|
|
5440
5458
|
);
|
|
5441
5459
|
console.log(
|
|
5442
5460
|
`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
|
|
@@ -5468,8 +5486,8 @@ var getAllPatientsUtil = async (db, options) => {
|
|
|
5468
5486
|
}
|
|
5469
5487
|
const patientsSnapshot = await (0, import_firestore17.getDocs)(q);
|
|
5470
5488
|
const patients = [];
|
|
5471
|
-
patientsSnapshot.forEach((
|
|
5472
|
-
patients.push(
|
|
5489
|
+
patientsSnapshot.forEach((doc37) => {
|
|
5490
|
+
patients.push(doc37.data());
|
|
5473
5491
|
});
|
|
5474
5492
|
console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
|
|
5475
5493
|
return patients;
|
|
@@ -5591,7 +5609,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
|
|
|
5591
5609
|
if (querySnapshot.empty) {
|
|
5592
5610
|
return [];
|
|
5593
5611
|
}
|
|
5594
|
-
return querySnapshot.docs.map((
|
|
5612
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
5595
5613
|
};
|
|
5596
5614
|
var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
5597
5615
|
const tokensRef = (0, import_firestore18.collection)(
|
|
@@ -5609,7 +5627,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
|
5609
5627
|
if (querySnapshot.empty) {
|
|
5610
5628
|
return [];
|
|
5611
5629
|
}
|
|
5612
|
-
return querySnapshot.docs.map((
|
|
5630
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
5613
5631
|
};
|
|
5614
5632
|
|
|
5615
5633
|
// src/services/patient/patient.service.ts
|
|
@@ -6715,7 +6733,7 @@ var PractitionerService = class extends BaseService {
|
|
|
6715
6733
|
(0, import_firestore21.where)("expiresAt", ">", import_firestore21.Timestamp.now())
|
|
6716
6734
|
);
|
|
6717
6735
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6718
|
-
return querySnapshot.docs.map((
|
|
6736
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
6719
6737
|
}
|
|
6720
6738
|
/**
|
|
6721
6739
|
* Gets a token by its string value and validates it
|
|
@@ -6825,7 +6843,7 @@ var PractitionerService = class extends BaseService {
|
|
|
6825
6843
|
(0, import_firestore21.where)("status", "==", "active" /* ACTIVE */)
|
|
6826
6844
|
);
|
|
6827
6845
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6828
|
-
return querySnapshot.docs.map((
|
|
6846
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
6829
6847
|
}
|
|
6830
6848
|
/**
|
|
6831
6849
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -6837,7 +6855,7 @@ var PractitionerService = class extends BaseService {
|
|
|
6837
6855
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6838
6856
|
);
|
|
6839
6857
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6840
|
-
return querySnapshot.docs.map((
|
|
6858
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
6841
6859
|
}
|
|
6842
6860
|
/**
|
|
6843
6861
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -6849,7 +6867,7 @@ var PractitionerService = class extends BaseService {
|
|
|
6849
6867
|
(0, import_firestore21.where)("status", "==", "draft" /* DRAFT */)
|
|
6850
6868
|
);
|
|
6851
6869
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6852
|
-
return querySnapshot.docs.map((
|
|
6870
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
6853
6871
|
}
|
|
6854
6872
|
/**
|
|
6855
6873
|
* Updates a practitioner
|
|
@@ -7063,7 +7081,7 @@ var PractitionerService = class extends BaseService {
|
|
|
7063
7081
|
);
|
|
7064
7082
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
7065
7083
|
const practitioners = querySnapshot.docs.map(
|
|
7066
|
-
(
|
|
7084
|
+
(doc37) => doc37.data()
|
|
7067
7085
|
);
|
|
7068
7086
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
7069
7087
|
return {
|
|
@@ -7134,8 +7152,8 @@ var PractitionerService = class extends BaseService {
|
|
|
7134
7152
|
console.log(
|
|
7135
7153
|
`[PRACTITIONER_SERVICE] Found ${querySnapshot.docs.length} practitioners with base query`
|
|
7136
7154
|
);
|
|
7137
|
-
let practitioners = querySnapshot.docs.map((
|
|
7138
|
-
return { ...
|
|
7155
|
+
let practitioners = querySnapshot.docs.map((doc37) => {
|
|
7156
|
+
return { ...doc37.data(), id: doc37.id };
|
|
7139
7157
|
});
|
|
7140
7158
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
7141
7159
|
if (filters.nameSearch && filters.nameSearch.trim() !== "") {
|
|
@@ -7619,7 +7637,7 @@ var UserService = class extends BaseService {
|
|
|
7619
7637
|
];
|
|
7620
7638
|
const q = (0, import_firestore22.query)((0, import_firestore22.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
7621
7639
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
7622
|
-
const users = querySnapshot.docs.map((
|
|
7640
|
+
const users = querySnapshot.docs.map((doc37) => doc37.data());
|
|
7623
7641
|
return users.map((userData) => userSchema.parse(userData));
|
|
7624
7642
|
}
|
|
7625
7643
|
/**
|
|
@@ -7983,7 +8001,7 @@ async function getAllActiveGroups(db) {
|
|
|
7983
8001
|
(0, import_firestore23.where)("isActive", "==", true)
|
|
7984
8002
|
);
|
|
7985
8003
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7986
|
-
return querySnapshot.docs.map((
|
|
8004
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
7987
8005
|
}
|
|
7988
8006
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
7989
8007
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -8423,7 +8441,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
8423
8441
|
(0, import_firestore24.where)("isActive", "==", true)
|
|
8424
8442
|
);
|
|
8425
8443
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
8426
|
-
return querySnapshot.docs.map((
|
|
8444
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
8427
8445
|
}
|
|
8428
8446
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
8429
8447
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -8617,7 +8635,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
8617
8635
|
}
|
|
8618
8636
|
const q = (0, import_firestore24.query)((0, import_firestore24.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
8619
8637
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
8620
|
-
return querySnapshot.docs.map((
|
|
8638
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
8621
8639
|
}
|
|
8622
8640
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
8623
8641
|
return getClinicsByAdmin(
|
|
@@ -8662,11 +8680,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
8662
8680
|
}
|
|
8663
8681
|
const clinicsSnapshot = await (0, import_firestore24.getDocs)(clinicsQuery);
|
|
8664
8682
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
8665
|
-
const clinics = clinicsSnapshot.docs.map((
|
|
8666
|
-
const data =
|
|
8683
|
+
const clinics = clinicsSnapshot.docs.map((doc37) => {
|
|
8684
|
+
const data = doc37.data();
|
|
8667
8685
|
return {
|
|
8668
8686
|
...data,
|
|
8669
|
-
id:
|
|
8687
|
+
id: doc37.id
|
|
8670
8688
|
};
|
|
8671
8689
|
});
|
|
8672
8690
|
return {
|
|
@@ -8693,8 +8711,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
8693
8711
|
];
|
|
8694
8712
|
const q = (0, import_firestore24.query)((0, import_firestore24.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
8695
8713
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
8696
|
-
for (const
|
|
8697
|
-
const clinic =
|
|
8714
|
+
for (const doc37 of querySnapshot.docs) {
|
|
8715
|
+
const clinic = doc37.data();
|
|
8698
8716
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
8699
8717
|
[center.latitude, center.longitude],
|
|
8700
8718
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -8811,8 +8829,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
8811
8829
|
}
|
|
8812
8830
|
const q = (0, import_firestore25.query)((0, import_firestore25.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
8813
8831
|
const querySnapshot = await (0, import_firestore25.getDocs)(q);
|
|
8814
|
-
for (const
|
|
8815
|
-
const clinic =
|
|
8832
|
+
for (const doc37 of querySnapshot.docs) {
|
|
8833
|
+
const clinic = doc37.data();
|
|
8816
8834
|
const distance = (0, import_geofire_common5.distanceBetween)(
|
|
8817
8835
|
[center.latitude, center.longitude],
|
|
8818
8836
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -8900,8 +8918,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
8900
8918
|
console.log(
|
|
8901
8919
|
`[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics in geo bound`
|
|
8902
8920
|
);
|
|
8903
|
-
for (const
|
|
8904
|
-
const clinic = { ...
|
|
8921
|
+
for (const doc37 of querySnapshot.docs) {
|
|
8922
|
+
const clinic = { ...doc37.data(), id: doc37.id };
|
|
8905
8923
|
const distance = (0, import_geofire_common6.distanceBetween)(
|
|
8906
8924
|
[center.latitude, center.longitude],
|
|
8907
8925
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -8957,8 +8975,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
8957
8975
|
console.log(
|
|
8958
8976
|
`[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics with regular query`
|
|
8959
8977
|
);
|
|
8960
|
-
const clinics = querySnapshot.docs.map((
|
|
8961
|
-
return { ...
|
|
8978
|
+
const clinics = querySnapshot.docs.map((doc37) => {
|
|
8979
|
+
return { ...doc37.data(), id: doc37.id };
|
|
8962
8980
|
});
|
|
8963
8981
|
let filteredClinics = clinics;
|
|
8964
8982
|
if (filters.center) {
|
|
@@ -10579,7 +10597,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
10579
10597
|
const finalQuery = (0, import_firestore33.query)(collectionRef, ...constraints);
|
|
10580
10598
|
const querySnapshot = await (0, import_firestore33.getDocs)(finalQuery);
|
|
10581
10599
|
const events = querySnapshot.docs.map(
|
|
10582
|
-
(
|
|
10600
|
+
(doc37) => ({ id: doc37.id, ...doc37.data() })
|
|
10583
10601
|
);
|
|
10584
10602
|
return events;
|
|
10585
10603
|
} catch (error) {
|
|
@@ -10661,7 +10679,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
10661
10679
|
);
|
|
10662
10680
|
const q = (0, import_firestore34.query)(calendarsRef, (0, import_firestore34.orderBy)("createdAt", "desc"));
|
|
10663
10681
|
const querySnapshot = await (0, import_firestore34.getDocs)(q);
|
|
10664
|
-
return querySnapshot.docs.map((
|
|
10682
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
10665
10683
|
}
|
|
10666
10684
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
10667
10685
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -10678,7 +10696,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
10678
10696
|
);
|
|
10679
10697
|
const q = (0, import_firestore34.query)(calendarsRef, (0, import_firestore34.orderBy)("createdAt", "desc"));
|
|
10680
10698
|
const querySnapshot = await (0, import_firestore34.getDocs)(q);
|
|
10681
|
-
return querySnapshot.docs.map((
|
|
10699
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
10682
10700
|
}
|
|
10683
10701
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
10684
10702
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -10695,7 +10713,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
10695
10713
|
);
|
|
10696
10714
|
const q = (0, import_firestore34.query)(calendarsRef, (0, import_firestore34.orderBy)("createdAt", "desc"));
|
|
10697
10715
|
const querySnapshot = await (0, import_firestore34.getDocs)(q);
|
|
10698
|
-
return querySnapshot.docs.map((
|
|
10716
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
10699
10717
|
}
|
|
10700
10718
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
10701
10719
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -12050,9 +12068,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12050
12068
|
(0, import_firestore37.where)("eventTime.start", "<=", import_firestore36.Timestamp.fromDate(endDate))
|
|
12051
12069
|
);
|
|
12052
12070
|
const eventsSnapshot = await (0, import_firestore37.getDocs)(q);
|
|
12053
|
-
const events = eventsSnapshot.docs.map((
|
|
12054
|
-
id:
|
|
12055
|
-
...
|
|
12071
|
+
const events = eventsSnapshot.docs.map((doc37) => ({
|
|
12072
|
+
id: doc37.id,
|
|
12073
|
+
...doc37.data()
|
|
12056
12074
|
}));
|
|
12057
12075
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
12058
12076
|
doctorId
|
|
@@ -12686,7 +12704,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12686
12704
|
])
|
|
12687
12705
|
);
|
|
12688
12706
|
const querySnapshot = await (0, import_firestore37.getDocs)(q);
|
|
12689
|
-
return querySnapshot.docs.map((
|
|
12707
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
12690
12708
|
}
|
|
12691
12709
|
/**
|
|
12692
12710
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -13217,7 +13235,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13217
13235
|
...constraints
|
|
13218
13236
|
);
|
|
13219
13237
|
const querySnapshot = await (0, import_firestore40.getDocs)(q);
|
|
13220
|
-
return querySnapshot.docs.map((
|
|
13238
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
13221
13239
|
} catch (error) {
|
|
13222
13240
|
console.error(
|
|
13223
13241
|
"[PractitionerInviteService] Error getting doctor invites:",
|
|
@@ -13246,7 +13264,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13246
13264
|
...constraints
|
|
13247
13265
|
);
|
|
13248
13266
|
const querySnapshot = await (0, import_firestore40.getDocs)(q);
|
|
13249
|
-
return querySnapshot.docs.map((
|
|
13267
|
+
return querySnapshot.docs.map((doc37) => doc37.data());
|
|
13250
13268
|
} catch (error) {
|
|
13251
13269
|
console.error(
|
|
13252
13270
|
"[PractitionerInviteService] Error getting clinic invites:",
|
|
@@ -13402,7 +13420,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13402
13420
|
);
|
|
13403
13421
|
const querySnapshot = await (0, import_firestore40.getDocs)(q);
|
|
13404
13422
|
let invites = querySnapshot.docs.map(
|
|
13405
|
-
(
|
|
13423
|
+
(doc37) => doc37.data()
|
|
13406
13424
|
);
|
|
13407
13425
|
if (filters.fromDate) {
|
|
13408
13426
|
invites = invites.filter(
|
|
@@ -13659,8 +13677,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13659
13677
|
const q = (0, import_firestore41.query)(versionsCollectionRef, (0, import_firestore41.orderBy)("version", "desc"));
|
|
13660
13678
|
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13661
13679
|
const versions = [];
|
|
13662
|
-
querySnapshot.forEach((
|
|
13663
|
-
versions.push(
|
|
13680
|
+
querySnapshot.forEach((doc37) => {
|
|
13681
|
+
versions.push(doc37.data());
|
|
13664
13682
|
});
|
|
13665
13683
|
return versions;
|
|
13666
13684
|
}
|
|
@@ -13691,9 +13709,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13691
13709
|
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13692
13710
|
const templates = [];
|
|
13693
13711
|
let lastVisible = null;
|
|
13694
|
-
querySnapshot.forEach((
|
|
13695
|
-
templates.push(
|
|
13696
|
-
lastVisible =
|
|
13712
|
+
querySnapshot.forEach((doc37) => {
|
|
13713
|
+
templates.push(doc37.data());
|
|
13714
|
+
lastVisible = doc37;
|
|
13697
13715
|
});
|
|
13698
13716
|
return {
|
|
13699
13717
|
templates,
|
|
@@ -13721,9 +13739,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13721
13739
|
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13722
13740
|
const templates = [];
|
|
13723
13741
|
let lastVisible = null;
|
|
13724
|
-
querySnapshot.forEach((
|
|
13725
|
-
templates.push(
|
|
13726
|
-
lastVisible =
|
|
13742
|
+
querySnapshot.forEach((doc37) => {
|
|
13743
|
+
templates.push(doc37.data());
|
|
13744
|
+
lastVisible = doc37;
|
|
13727
13745
|
});
|
|
13728
13746
|
return {
|
|
13729
13747
|
templates,
|
|
@@ -13750,9 +13768,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13750
13768
|
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13751
13769
|
const templates = [];
|
|
13752
13770
|
let lastVisible = null;
|
|
13753
|
-
querySnapshot.forEach((
|
|
13754
|
-
templates.push(
|
|
13755
|
-
lastVisible =
|
|
13771
|
+
querySnapshot.forEach((doc37) => {
|
|
13772
|
+
templates.push(doc37.data());
|
|
13773
|
+
lastVisible = doc37;
|
|
13756
13774
|
});
|
|
13757
13775
|
return {
|
|
13758
13776
|
templates,
|
|
@@ -13778,8 +13796,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13778
13796
|
}
|
|
13779
13797
|
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13780
13798
|
const templates = [];
|
|
13781
|
-
querySnapshot.forEach((
|
|
13782
|
-
templates.push(
|
|
13799
|
+
querySnapshot.forEach((doc37) => {
|
|
13800
|
+
templates.push(doc37.data());
|
|
13783
13801
|
});
|
|
13784
13802
|
return templates;
|
|
13785
13803
|
}
|
|
@@ -13974,9 +13992,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
13974
13992
|
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
13975
13993
|
const documents = [];
|
|
13976
13994
|
let lastVisible = null;
|
|
13977
|
-
querySnapshot.forEach((
|
|
13978
|
-
documents.push(
|
|
13979
|
-
lastVisible =
|
|
13995
|
+
querySnapshot.forEach((doc37) => {
|
|
13996
|
+
documents.push(doc37.data());
|
|
13997
|
+
lastVisible = doc37;
|
|
13980
13998
|
});
|
|
13981
13999
|
return {
|
|
13982
14000
|
documents,
|
|
@@ -14185,9 +14203,9 @@ var NotificationService = class extends BaseService {
|
|
|
14185
14203
|
(0, import_firestore43.orderBy)("notificationTime", "desc")
|
|
14186
14204
|
);
|
|
14187
14205
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
14188
|
-
return querySnapshot.docs.map((
|
|
14189
|
-
id:
|
|
14190
|
-
...
|
|
14206
|
+
return querySnapshot.docs.map((doc37) => ({
|
|
14207
|
+
id: doc37.id,
|
|
14208
|
+
...doc37.data()
|
|
14191
14209
|
}));
|
|
14192
14210
|
}
|
|
14193
14211
|
/**
|
|
@@ -14201,9 +14219,9 @@ var NotificationService = class extends BaseService {
|
|
|
14201
14219
|
(0, import_firestore43.orderBy)("notificationTime", "desc")
|
|
14202
14220
|
);
|
|
14203
14221
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
14204
|
-
return querySnapshot.docs.map((
|
|
14205
|
-
id:
|
|
14206
|
-
...
|
|
14222
|
+
return querySnapshot.docs.map((doc37) => ({
|
|
14223
|
+
id: doc37.id,
|
|
14224
|
+
...doc37.data()
|
|
14207
14225
|
}));
|
|
14208
14226
|
}
|
|
14209
14227
|
/**
|
|
@@ -14275,9 +14293,9 @@ var NotificationService = class extends BaseService {
|
|
|
14275
14293
|
(0, import_firestore43.orderBy)("notificationTime", "desc")
|
|
14276
14294
|
);
|
|
14277
14295
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
14278
|
-
return querySnapshot.docs.map((
|
|
14279
|
-
id:
|
|
14280
|
-
...
|
|
14296
|
+
return querySnapshot.docs.map((doc37) => ({
|
|
14297
|
+
id: doc37.id,
|
|
14298
|
+
...doc37.data()
|
|
14281
14299
|
}));
|
|
14282
14300
|
}
|
|
14283
14301
|
/**
|
|
@@ -14290,9 +14308,9 @@ var NotificationService = class extends BaseService {
|
|
|
14290
14308
|
(0, import_firestore43.orderBy)("notificationTime", "desc")
|
|
14291
14309
|
);
|
|
14292
14310
|
const querySnapshot = await (0, import_firestore43.getDocs)(q);
|
|
14293
|
-
return querySnapshot.docs.map((
|
|
14294
|
-
id:
|
|
14295
|
-
...
|
|
14311
|
+
return querySnapshot.docs.map((doc37) => ({
|
|
14312
|
+
id: doc37.id,
|
|
14313
|
+
...doc37.data()
|
|
14296
14314
|
}));
|
|
14297
14315
|
}
|
|
14298
14316
|
};
|
|
@@ -14769,8 +14787,8 @@ var ProcedureService = class extends BaseService {
|
|
|
14769
14787
|
(0, import_firestore45.where)((0, import_firestore45.documentId)(), "in", chunk)
|
|
14770
14788
|
);
|
|
14771
14789
|
const practitionersSnapshot = await (0, import_firestore45.getDocs)(practitionersQuery);
|
|
14772
|
-
practitionersSnapshot.docs.forEach((
|
|
14773
|
-
practitionersMap.set(
|
|
14790
|
+
practitionersSnapshot.docs.forEach((doc37) => {
|
|
14791
|
+
practitionersMap.set(doc37.id, doc37.data());
|
|
14774
14792
|
});
|
|
14775
14793
|
}
|
|
14776
14794
|
if (practitionersMap.size !== practitionerIds.length) {
|
|
@@ -14852,8 +14870,8 @@ var ProcedureService = class extends BaseService {
|
|
|
14852
14870
|
(0, import_firestore45.where)((0, import_firestore45.documentId)(), "in", chunk)
|
|
14853
14871
|
);
|
|
14854
14872
|
const snapshot = await (0, import_firestore45.getDocs)(q);
|
|
14855
|
-
snapshot.forEach((
|
|
14856
|
-
fetchedProcedures.push(
|
|
14873
|
+
snapshot.forEach((doc37) => {
|
|
14874
|
+
fetchedProcedures.push(doc37.data());
|
|
14857
14875
|
});
|
|
14858
14876
|
}
|
|
14859
14877
|
return fetchedProcedures;
|
|
@@ -14883,7 +14901,7 @@ var ProcedureService = class extends BaseService {
|
|
|
14883
14901
|
(0, import_firestore45.where)("isActive", "==", true)
|
|
14884
14902
|
);
|
|
14885
14903
|
const snapshot = await (0, import_firestore45.getDocs)(q);
|
|
14886
|
-
return snapshot.docs.map((
|
|
14904
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
14887
14905
|
}
|
|
14888
14906
|
/**
|
|
14889
14907
|
* Gets all procedures for a practitioner
|
|
@@ -14897,7 +14915,7 @@ var ProcedureService = class extends BaseService {
|
|
|
14897
14915
|
(0, import_firestore45.where)("isActive", "==", true)
|
|
14898
14916
|
);
|
|
14899
14917
|
const snapshot = await (0, import_firestore45.getDocs)(q);
|
|
14900
|
-
return snapshot.docs.map((
|
|
14918
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
14901
14919
|
}
|
|
14902
14920
|
/**
|
|
14903
14921
|
* Gets all inactive procedures for a practitioner
|
|
@@ -14911,7 +14929,7 @@ var ProcedureService = class extends BaseService {
|
|
|
14911
14929
|
(0, import_firestore45.where)("isActive", "==", false)
|
|
14912
14930
|
);
|
|
14913
14931
|
const snapshot = await (0, import_firestore45.getDocs)(q);
|
|
14914
|
-
return snapshot.docs.map((
|
|
14932
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
14915
14933
|
}
|
|
14916
14934
|
/**
|
|
14917
14935
|
* Updates a procedure
|
|
@@ -15123,11 +15141,11 @@ var ProcedureService = class extends BaseService {
|
|
|
15123
15141
|
}
|
|
15124
15142
|
const proceduresSnapshot = await (0, import_firestore45.getDocs)(proceduresQuery);
|
|
15125
15143
|
const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
|
|
15126
|
-
const procedures = proceduresSnapshot.docs.map((
|
|
15127
|
-
const data =
|
|
15144
|
+
const procedures = proceduresSnapshot.docs.map((doc37) => {
|
|
15145
|
+
const data = doc37.data();
|
|
15128
15146
|
return {
|
|
15129
15147
|
...data,
|
|
15130
|
-
id:
|
|
15148
|
+
id: doc37.id
|
|
15131
15149
|
// Ensure ID is present
|
|
15132
15150
|
};
|
|
15133
15151
|
});
|
|
@@ -15209,8 +15227,8 @@ var ProcedureService = class extends BaseService {
|
|
|
15209
15227
|
console.log(
|
|
15210
15228
|
`[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures in geo bound`
|
|
15211
15229
|
);
|
|
15212
|
-
for (const
|
|
15213
|
-
const procedure = { ...
|
|
15230
|
+
for (const doc37 of querySnapshot.docs) {
|
|
15231
|
+
const procedure = { ...doc37.data(), id: doc37.id };
|
|
15214
15232
|
const distance = (0, import_geofire_common8.distanceBetween)(
|
|
15215
15233
|
[center.latitude, center.longitude],
|
|
15216
15234
|
[
|
|
@@ -15261,8 +15279,8 @@ var ProcedureService = class extends BaseService {
|
|
|
15261
15279
|
console.log(
|
|
15262
15280
|
`[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures with regular query`
|
|
15263
15281
|
);
|
|
15264
|
-
const procedures = querySnapshot.docs.map((
|
|
15265
|
-
return { ...
|
|
15282
|
+
const procedures = querySnapshot.docs.map((doc37) => {
|
|
15283
|
+
return { ...doc37.data(), id: doc37.id };
|
|
15266
15284
|
});
|
|
15267
15285
|
if (filters.location) {
|
|
15268
15286
|
const center = filters.location;
|
|
@@ -15595,7 +15613,7 @@ var ReviewService = class extends BaseService {
|
|
|
15595
15613
|
(0, import_firestore46.where)("patientId", "==", patientId)
|
|
15596
15614
|
);
|
|
15597
15615
|
const snapshot = await (0, import_firestore46.getDocs)(q);
|
|
15598
|
-
return snapshot.docs.map((
|
|
15616
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
15599
15617
|
}
|
|
15600
15618
|
/**
|
|
15601
15619
|
* Gets all reviews for a specific clinic
|
|
@@ -15608,7 +15626,7 @@ var ReviewService = class extends BaseService {
|
|
|
15608
15626
|
(0, import_firestore46.where)("clinicReview.clinicId", "==", clinicId)
|
|
15609
15627
|
);
|
|
15610
15628
|
const snapshot = await (0, import_firestore46.getDocs)(q);
|
|
15611
|
-
return snapshot.docs.map((
|
|
15629
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
15612
15630
|
}
|
|
15613
15631
|
/**
|
|
15614
15632
|
* Gets all reviews for a specific practitioner
|
|
@@ -15621,7 +15639,7 @@ var ReviewService = class extends BaseService {
|
|
|
15621
15639
|
(0, import_firestore46.where)("practitionerReview.practitionerId", "==", practitionerId)
|
|
15622
15640
|
);
|
|
15623
15641
|
const snapshot = await (0, import_firestore46.getDocs)(q);
|
|
15624
|
-
return snapshot.docs.map((
|
|
15642
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
15625
15643
|
}
|
|
15626
15644
|
/**
|
|
15627
15645
|
* Gets all reviews for a specific procedure
|
|
@@ -15634,7 +15652,7 @@ var ReviewService = class extends BaseService {
|
|
|
15634
15652
|
(0, import_firestore46.where)("procedureReview.procedureId", "==", procedureId)
|
|
15635
15653
|
);
|
|
15636
15654
|
const snapshot = await (0, import_firestore46.getDocs)(q);
|
|
15637
|
-
return snapshot.docs.map((
|
|
15655
|
+
return snapshot.docs.map((doc37) => doc37.data());
|
|
15638
15656
|
}
|
|
15639
15657
|
/**
|
|
15640
15658
|
* Gets all reviews for a specific appointment
|
|
@@ -16300,6 +16318,816 @@ var getFirebaseFunctions = async () => {
|
|
|
16300
16318
|
const instance = await getFirebaseInstance();
|
|
16301
16319
|
return instance.functions;
|
|
16302
16320
|
};
|
|
16321
|
+
|
|
16322
|
+
// src/backoffice/services/brand.service.ts
|
|
16323
|
+
var import_firestore51 = require("firebase/firestore");
|
|
16324
|
+
|
|
16325
|
+
// src/backoffice/types/brand.types.ts
|
|
16326
|
+
var BRANDS_COLLECTION = "brands";
|
|
16327
|
+
|
|
16328
|
+
// src/backoffice/services/brand.service.ts
|
|
16329
|
+
var BrandService = class extends BaseService {
|
|
16330
|
+
/**
|
|
16331
|
+
* Gets reference to brands collection
|
|
16332
|
+
*/
|
|
16333
|
+
getBrandsRef() {
|
|
16334
|
+
return (0, import_firestore51.collection)(this.db, BRANDS_COLLECTION);
|
|
16335
|
+
}
|
|
16336
|
+
/**
|
|
16337
|
+
* Creates a new brand
|
|
16338
|
+
*/
|
|
16339
|
+
async create(brand) {
|
|
16340
|
+
const now = /* @__PURE__ */ new Date();
|
|
16341
|
+
const newBrand = {
|
|
16342
|
+
...brand,
|
|
16343
|
+
createdAt: now,
|
|
16344
|
+
updatedAt: now,
|
|
16345
|
+
isActive: true
|
|
16346
|
+
};
|
|
16347
|
+
const docRef = await (0, import_firestore51.addDoc)(this.getBrandsRef(), newBrand);
|
|
16348
|
+
return { id: docRef.id, ...newBrand };
|
|
16349
|
+
}
|
|
16350
|
+
/**
|
|
16351
|
+
* Gets all active brands
|
|
16352
|
+
*/
|
|
16353
|
+
async getAll() {
|
|
16354
|
+
const q = (0, import_firestore51.query)(this.getBrandsRef(), (0, import_firestore51.where)("isActive", "==", true));
|
|
16355
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
16356
|
+
return snapshot.docs.map(
|
|
16357
|
+
(doc37) => ({
|
|
16358
|
+
id: doc37.id,
|
|
16359
|
+
...doc37.data()
|
|
16360
|
+
})
|
|
16361
|
+
);
|
|
16362
|
+
}
|
|
16363
|
+
/**
|
|
16364
|
+
* Updates a brand
|
|
16365
|
+
*/
|
|
16366
|
+
async update(brandId, brand) {
|
|
16367
|
+
const updateData = {
|
|
16368
|
+
...brand,
|
|
16369
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16370
|
+
};
|
|
16371
|
+
const docRef = (0, import_firestore51.doc)(this.getBrandsRef(), brandId);
|
|
16372
|
+
await (0, import_firestore51.updateDoc)(docRef, updateData);
|
|
16373
|
+
return this.getById(brandId);
|
|
16374
|
+
}
|
|
16375
|
+
/**
|
|
16376
|
+
* Soft deletes a brand
|
|
16377
|
+
*/
|
|
16378
|
+
async delete(brandId) {
|
|
16379
|
+
await this.update(brandId, {
|
|
16380
|
+
isActive: false
|
|
16381
|
+
});
|
|
16382
|
+
}
|
|
16383
|
+
/**
|
|
16384
|
+
* Gets a brand by ID
|
|
16385
|
+
*/
|
|
16386
|
+
async getById(brandId) {
|
|
16387
|
+
const docRef = (0, import_firestore51.doc)(this.getBrandsRef(), brandId);
|
|
16388
|
+
const docSnap = await (0, import_firestore51.getDoc)(docRef);
|
|
16389
|
+
if (!docSnap.exists()) return null;
|
|
16390
|
+
return {
|
|
16391
|
+
id: docSnap.id,
|
|
16392
|
+
...docSnap.data()
|
|
16393
|
+
};
|
|
16394
|
+
}
|
|
16395
|
+
};
|
|
16396
|
+
|
|
16397
|
+
// src/backoffice/services/category.service.ts
|
|
16398
|
+
var import_firestore52 = require("firebase/firestore");
|
|
16399
|
+
|
|
16400
|
+
// src/backoffice/types/category.types.ts
|
|
16401
|
+
var CATEGORIES_COLLECTION = "backoffice_categories";
|
|
16402
|
+
|
|
16403
|
+
// src/backoffice/services/category.service.ts
|
|
16404
|
+
var CategoryService = class extends BaseService {
|
|
16405
|
+
/**
|
|
16406
|
+
* Referenca na Firestore kolekciju kategorija
|
|
16407
|
+
*/
|
|
16408
|
+
get categoriesRef() {
|
|
16409
|
+
return (0, import_firestore52.collection)(this.db, CATEGORIES_COLLECTION);
|
|
16410
|
+
}
|
|
16411
|
+
/**
|
|
16412
|
+
* Kreira novu kategoriju u sistemu
|
|
16413
|
+
* @param category - Podaci za novu kategoriju
|
|
16414
|
+
* @returns Kreirana kategorija sa generisanim ID-em
|
|
16415
|
+
*/
|
|
16416
|
+
async create(category) {
|
|
16417
|
+
const now = /* @__PURE__ */ new Date();
|
|
16418
|
+
const newCategory = {
|
|
16419
|
+
...category,
|
|
16420
|
+
createdAt: now,
|
|
16421
|
+
updatedAt: now,
|
|
16422
|
+
isActive: true
|
|
16423
|
+
};
|
|
16424
|
+
const docRef = await (0, import_firestore52.addDoc)(this.categoriesRef, newCategory);
|
|
16425
|
+
return { id: docRef.id, ...newCategory };
|
|
16426
|
+
}
|
|
16427
|
+
/**
|
|
16428
|
+
* Vraća sve aktivne kategorije
|
|
16429
|
+
* @returns Lista aktivnih kategorija
|
|
16430
|
+
*/
|
|
16431
|
+
async getAll() {
|
|
16432
|
+
const q = (0, import_firestore52.query)(this.categoriesRef, (0, import_firestore52.where)("isActive", "==", true));
|
|
16433
|
+
const snapshot = await (0, import_firestore52.getDocs)(q);
|
|
16434
|
+
return snapshot.docs.map(
|
|
16435
|
+
(doc37) => ({
|
|
16436
|
+
id: doc37.id,
|
|
16437
|
+
...doc37.data()
|
|
16438
|
+
})
|
|
16439
|
+
);
|
|
16440
|
+
}
|
|
16441
|
+
/**
|
|
16442
|
+
* Vraća sve aktivne kategorije za određenu familiju procedura
|
|
16443
|
+
* @param family - Familija procedura (aesthetics/surgery)
|
|
16444
|
+
* @returns Lista kategorija koje pripadaju traženoj familiji
|
|
16445
|
+
*/
|
|
16446
|
+
async getAllByFamily(family) {
|
|
16447
|
+
const q = (0, import_firestore52.query)(
|
|
16448
|
+
this.categoriesRef,
|
|
16449
|
+
(0, import_firestore52.where)("family", "==", family),
|
|
16450
|
+
(0, import_firestore52.where)("isActive", "==", true)
|
|
16451
|
+
);
|
|
16452
|
+
const snapshot = await (0, import_firestore52.getDocs)(q);
|
|
16453
|
+
return snapshot.docs.map(
|
|
16454
|
+
(doc37) => ({
|
|
16455
|
+
id: doc37.id,
|
|
16456
|
+
...doc37.data()
|
|
16457
|
+
})
|
|
16458
|
+
);
|
|
16459
|
+
}
|
|
16460
|
+
/**
|
|
16461
|
+
* Ažurira postojeću kategoriju
|
|
16462
|
+
* @param id - ID kategorije koja se ažurira
|
|
16463
|
+
* @param category - Novi podaci za kategoriju
|
|
16464
|
+
* @returns Ažurirana kategorija
|
|
16465
|
+
*/
|
|
16466
|
+
async update(id, category) {
|
|
16467
|
+
const updateData = {
|
|
16468
|
+
...category,
|
|
16469
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16470
|
+
};
|
|
16471
|
+
const docRef = (0, import_firestore52.doc)(this.categoriesRef, id);
|
|
16472
|
+
await (0, import_firestore52.updateDoc)(docRef, updateData);
|
|
16473
|
+
return this.getById(id);
|
|
16474
|
+
}
|
|
16475
|
+
/**
|
|
16476
|
+
* Soft delete kategorije (postavlja isActive na false)
|
|
16477
|
+
* @param id - ID kategorije koja se briše
|
|
16478
|
+
*/
|
|
16479
|
+
async delete(id) {
|
|
16480
|
+
await this.update(id, { isActive: false });
|
|
16481
|
+
}
|
|
16482
|
+
/**
|
|
16483
|
+
* Vraća kategoriju po ID-u
|
|
16484
|
+
* @param id - ID tražene kategorije
|
|
16485
|
+
* @returns Kategorija ili null ako ne postoji
|
|
16486
|
+
*/
|
|
16487
|
+
async getById(id) {
|
|
16488
|
+
const docRef = (0, import_firestore52.doc)(this.categoriesRef, id);
|
|
16489
|
+
const docSnap = await (0, import_firestore52.getDoc)(docRef);
|
|
16490
|
+
if (!docSnap.exists()) return null;
|
|
16491
|
+
return {
|
|
16492
|
+
id: docSnap.id,
|
|
16493
|
+
...docSnap.data()
|
|
16494
|
+
};
|
|
16495
|
+
}
|
|
16496
|
+
};
|
|
16497
|
+
|
|
16498
|
+
// src/backoffice/services/subcategory.service.ts
|
|
16499
|
+
var import_firestore53 = require("firebase/firestore");
|
|
16500
|
+
|
|
16501
|
+
// src/backoffice/types/subcategory.types.ts
|
|
16502
|
+
var SUBCATEGORIES_COLLECTION = "subcategories";
|
|
16503
|
+
|
|
16504
|
+
// src/backoffice/services/subcategory.service.ts
|
|
16505
|
+
var SubcategoryService = class extends BaseService {
|
|
16506
|
+
/**
|
|
16507
|
+
* Vraća referencu na Firestore kolekciju podkategorija za određenu kategoriju
|
|
16508
|
+
* @param categoryId - ID roditeljske kategorije
|
|
16509
|
+
*/
|
|
16510
|
+
getSubcategoriesRef(categoryId) {
|
|
16511
|
+
return (0, import_firestore53.collection)(
|
|
16512
|
+
this.db,
|
|
16513
|
+
CATEGORIES_COLLECTION,
|
|
16514
|
+
categoryId,
|
|
16515
|
+
SUBCATEGORIES_COLLECTION
|
|
16516
|
+
);
|
|
16517
|
+
}
|
|
16518
|
+
/**
|
|
16519
|
+
* Kreira novu podkategoriju u okviru kategorije
|
|
16520
|
+
* @param categoryId - ID kategorije kojoj će pripadati nova podkategorija
|
|
16521
|
+
* @param subcategory - Podaci za novu podkategoriju
|
|
16522
|
+
* @returns Kreirana podkategorija sa generisanim ID-em
|
|
16523
|
+
*/
|
|
16524
|
+
async create(categoryId, subcategory) {
|
|
16525
|
+
const now = /* @__PURE__ */ new Date();
|
|
16526
|
+
const newSubcategory = {
|
|
16527
|
+
...subcategory,
|
|
16528
|
+
categoryId,
|
|
16529
|
+
createdAt: now,
|
|
16530
|
+
updatedAt: now,
|
|
16531
|
+
isActive: true
|
|
16532
|
+
};
|
|
16533
|
+
const docRef = await (0, import_firestore53.addDoc)(
|
|
16534
|
+
this.getSubcategoriesRef(categoryId),
|
|
16535
|
+
newSubcategory
|
|
16536
|
+
);
|
|
16537
|
+
return { id: docRef.id, ...newSubcategory };
|
|
16538
|
+
}
|
|
16539
|
+
/**
|
|
16540
|
+
* Vraća sve aktivne podkategorije za određenu kategoriju
|
|
16541
|
+
* @param categoryId - ID kategorije čije podkategorije tražimo
|
|
16542
|
+
* @returns Lista aktivnih podkategorija
|
|
16543
|
+
*/
|
|
16544
|
+
async getAllByCategoryId(categoryId) {
|
|
16545
|
+
const q = (0, import_firestore53.query)(
|
|
16546
|
+
this.getSubcategoriesRef(categoryId),
|
|
16547
|
+
(0, import_firestore53.where)("isActive", "==", true)
|
|
16548
|
+
);
|
|
16549
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
16550
|
+
return snapshot.docs.map(
|
|
16551
|
+
(doc37) => ({
|
|
16552
|
+
id: doc37.id,
|
|
16553
|
+
...doc37.data()
|
|
16554
|
+
})
|
|
16555
|
+
);
|
|
16556
|
+
}
|
|
16557
|
+
/**
|
|
16558
|
+
* Ažurira postojeću podkategoriju
|
|
16559
|
+
* @param categoryId - ID kategorije kojoj pripada podkategorija
|
|
16560
|
+
* @param subcategoryId - ID podkategorije koja se ažurira
|
|
16561
|
+
* @param subcategory - Novi podaci za podkategoriju
|
|
16562
|
+
* @returns Ažurirana podkategorija
|
|
16563
|
+
*/
|
|
16564
|
+
async update(categoryId, subcategoryId, subcategory) {
|
|
16565
|
+
const updateData = {
|
|
16566
|
+
...subcategory,
|
|
16567
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16568
|
+
};
|
|
16569
|
+
const docRef = (0, import_firestore53.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
16570
|
+
await (0, import_firestore53.updateDoc)(docRef, updateData);
|
|
16571
|
+
return this.getById(categoryId, subcategoryId);
|
|
16572
|
+
}
|
|
16573
|
+
/**
|
|
16574
|
+
* Soft delete podkategorije (postavlja isActive na false)
|
|
16575
|
+
* @param categoryId - ID kategorije kojoj pripada podkategorija
|
|
16576
|
+
* @param subcategoryId - ID podkategorije koja se briše
|
|
16577
|
+
*/
|
|
16578
|
+
async delete(categoryId, subcategoryId) {
|
|
16579
|
+
await this.update(categoryId, subcategoryId, { isActive: false });
|
|
16580
|
+
}
|
|
16581
|
+
/**
|
|
16582
|
+
* Vraća podkategoriju po ID-u
|
|
16583
|
+
* @param categoryId - ID kategorije kojoj pripada podkategorija
|
|
16584
|
+
* @param subcategoryId - ID tražene podkategorije
|
|
16585
|
+
* @returns Podkategorija ili null ako ne postoji
|
|
16586
|
+
*/
|
|
16587
|
+
async getById(categoryId, subcategoryId) {
|
|
16588
|
+
const docRef = (0, import_firestore53.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
16589
|
+
const docSnap = await (0, import_firestore53.getDoc)(docRef);
|
|
16590
|
+
if (!docSnap.exists()) return null;
|
|
16591
|
+
return {
|
|
16592
|
+
id: docSnap.id,
|
|
16593
|
+
...docSnap.data()
|
|
16594
|
+
};
|
|
16595
|
+
}
|
|
16596
|
+
};
|
|
16597
|
+
|
|
16598
|
+
// src/backoffice/services/technology.service.ts
|
|
16599
|
+
var import_firestore54 = require("firebase/firestore");
|
|
16600
|
+
var DEFAULT_CERTIFICATION_REQUIREMENT = {
|
|
16601
|
+
minimumLevel: "aesthetician" /* AESTHETICIAN */,
|
|
16602
|
+
requiredSpecialties: []
|
|
16603
|
+
};
|
|
16604
|
+
var TechnologyService = class extends BaseService {
|
|
16605
|
+
/**
|
|
16606
|
+
* Vraća referencu na Firestore kolekciju tehnologija
|
|
16607
|
+
*/
|
|
16608
|
+
getTechnologiesRef() {
|
|
16609
|
+
return (0, import_firestore54.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
16610
|
+
}
|
|
16611
|
+
/**
|
|
16612
|
+
* Kreira novu tehnologiju
|
|
16613
|
+
* @param technology - Podaci za novu tehnologiju
|
|
16614
|
+
* @returns Kreirana tehnologija sa generisanim ID-em
|
|
16615
|
+
*/
|
|
16616
|
+
async create(technology) {
|
|
16617
|
+
const now = /* @__PURE__ */ new Date();
|
|
16618
|
+
const newTechnology = {
|
|
16619
|
+
...technology,
|
|
16620
|
+
createdAt: now,
|
|
16621
|
+
updatedAt: now,
|
|
16622
|
+
isActive: true,
|
|
16623
|
+
requirements: technology.requirements || {
|
|
16624
|
+
pre: [],
|
|
16625
|
+
post: []
|
|
16626
|
+
},
|
|
16627
|
+
blockingConditions: technology.blockingConditions || [],
|
|
16628
|
+
contraindications: technology.contraindications || [],
|
|
16629
|
+
benefits: technology.benefits || [],
|
|
16630
|
+
certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
|
|
16631
|
+
};
|
|
16632
|
+
const docRef = await (0, import_firestore54.addDoc)(this.getTechnologiesRef(), newTechnology);
|
|
16633
|
+
return { id: docRef.id, ...newTechnology };
|
|
16634
|
+
}
|
|
16635
|
+
/**
|
|
16636
|
+
* Vraća sve aktivne tehnologije
|
|
16637
|
+
* @returns Lista aktivnih tehnologija
|
|
16638
|
+
*/
|
|
16639
|
+
async getAll() {
|
|
16640
|
+
const q = (0, import_firestore54.query)(this.getTechnologiesRef(), (0, import_firestore54.where)("isActive", "==", true));
|
|
16641
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
16642
|
+
return snapshot.docs.map(
|
|
16643
|
+
(doc37) => ({
|
|
16644
|
+
id: doc37.id,
|
|
16645
|
+
...doc37.data()
|
|
16646
|
+
})
|
|
16647
|
+
);
|
|
16648
|
+
}
|
|
16649
|
+
/**
|
|
16650
|
+
* Vraća sve aktivne tehnologije za određenu familiju
|
|
16651
|
+
* @param family - Familija procedura
|
|
16652
|
+
* @returns Lista aktivnih tehnologija
|
|
16653
|
+
*/
|
|
16654
|
+
async getAllByFamily(family) {
|
|
16655
|
+
const q = (0, import_firestore54.query)(
|
|
16656
|
+
this.getTechnologiesRef(),
|
|
16657
|
+
(0, import_firestore54.where)("isActive", "==", true),
|
|
16658
|
+
(0, import_firestore54.where)("family", "==", family)
|
|
16659
|
+
);
|
|
16660
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
16661
|
+
return snapshot.docs.map(
|
|
16662
|
+
(doc37) => ({
|
|
16663
|
+
id: doc37.id,
|
|
16664
|
+
...doc37.data()
|
|
16665
|
+
})
|
|
16666
|
+
);
|
|
16667
|
+
}
|
|
16668
|
+
/**
|
|
16669
|
+
* Vraća sve aktivne tehnologije za određenu kategoriju
|
|
16670
|
+
* @param categoryId - ID kategorije
|
|
16671
|
+
* @returns Lista aktivnih tehnologija
|
|
16672
|
+
*/
|
|
16673
|
+
async getAllByCategoryId(categoryId) {
|
|
16674
|
+
const q = (0, import_firestore54.query)(
|
|
16675
|
+
this.getTechnologiesRef(),
|
|
16676
|
+
(0, import_firestore54.where)("isActive", "==", true),
|
|
16677
|
+
(0, import_firestore54.where)("categoryId", "==", categoryId)
|
|
16678
|
+
);
|
|
16679
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
16680
|
+
return snapshot.docs.map(
|
|
16681
|
+
(doc37) => ({
|
|
16682
|
+
id: doc37.id,
|
|
16683
|
+
...doc37.data()
|
|
16684
|
+
})
|
|
16685
|
+
);
|
|
16686
|
+
}
|
|
16687
|
+
/**
|
|
16688
|
+
* Vraća sve aktivne tehnologije za određenu podkategoriju
|
|
16689
|
+
* @param subcategoryId - ID podkategorije
|
|
16690
|
+
* @returns Lista aktivnih tehnologija
|
|
16691
|
+
*/
|
|
16692
|
+
async getAllBySubcategoryId(subcategoryId) {
|
|
16693
|
+
const q = (0, import_firestore54.query)(
|
|
16694
|
+
this.getTechnologiesRef(),
|
|
16695
|
+
(0, import_firestore54.where)("isActive", "==", true),
|
|
16696
|
+
(0, import_firestore54.where)("subcategoryId", "==", subcategoryId)
|
|
16697
|
+
);
|
|
16698
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
16699
|
+
return snapshot.docs.map(
|
|
16700
|
+
(doc37) => ({
|
|
16701
|
+
id: doc37.id,
|
|
16702
|
+
...doc37.data()
|
|
16703
|
+
})
|
|
16704
|
+
);
|
|
16705
|
+
}
|
|
16706
|
+
/**
|
|
16707
|
+
* Ažurira postojeću tehnologiju
|
|
16708
|
+
* @param technologyId - ID tehnologije
|
|
16709
|
+
* @param technology - Novi podaci za tehnologiju
|
|
16710
|
+
* @returns Ažurirana tehnologija
|
|
16711
|
+
*/
|
|
16712
|
+
async update(technologyId, technology) {
|
|
16713
|
+
const updateData = {
|
|
16714
|
+
...technology,
|
|
16715
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16716
|
+
};
|
|
16717
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16718
|
+
await (0, import_firestore54.updateDoc)(docRef, updateData);
|
|
16719
|
+
return this.getById(technologyId);
|
|
16720
|
+
}
|
|
16721
|
+
/**
|
|
16722
|
+
* Soft delete tehnologije (postavlja isActive na false)
|
|
16723
|
+
* @param technologyId - ID tehnologije koja se briše
|
|
16724
|
+
*/
|
|
16725
|
+
async delete(technologyId) {
|
|
16726
|
+
await this.update(technologyId, {
|
|
16727
|
+
isActive: false
|
|
16728
|
+
});
|
|
16729
|
+
}
|
|
16730
|
+
/**
|
|
16731
|
+
* Vraća tehnologiju po ID-u
|
|
16732
|
+
* @param technologyId - ID tražene tehnologije
|
|
16733
|
+
* @returns Tehnologija ili null ako ne postoji
|
|
16734
|
+
*/
|
|
16735
|
+
async getById(technologyId) {
|
|
16736
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16737
|
+
const docSnap = await (0, import_firestore54.getDoc)(docRef);
|
|
16738
|
+
if (!docSnap.exists()) return null;
|
|
16739
|
+
return {
|
|
16740
|
+
id: docSnap.id,
|
|
16741
|
+
...docSnap.data()
|
|
16742
|
+
};
|
|
16743
|
+
}
|
|
16744
|
+
/**
|
|
16745
|
+
* Dodaje novi zahtev tehnologiji
|
|
16746
|
+
* @param technologyId - ID tehnologije
|
|
16747
|
+
* @param requirement - Zahtev koji se dodaje
|
|
16748
|
+
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
16749
|
+
*/
|
|
16750
|
+
async addRequirement(technologyId, requirement) {
|
|
16751
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16752
|
+
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
16753
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16754
|
+
[requirementType]: (0, import_firestore54.arrayUnion)(requirement),
|
|
16755
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16756
|
+
});
|
|
16757
|
+
return this.getById(technologyId);
|
|
16758
|
+
}
|
|
16759
|
+
/**
|
|
16760
|
+
* Uklanja zahtev iz tehnologije
|
|
16761
|
+
* @param technologyId - ID tehnologije
|
|
16762
|
+
* @param requirement - Zahtev koji se uklanja
|
|
16763
|
+
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
16764
|
+
*/
|
|
16765
|
+
async removeRequirement(technologyId, requirement) {
|
|
16766
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16767
|
+
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
16768
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16769
|
+
[requirementType]: (0, import_firestore54.arrayRemove)(requirement),
|
|
16770
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16771
|
+
});
|
|
16772
|
+
return this.getById(technologyId);
|
|
16773
|
+
}
|
|
16774
|
+
/**
|
|
16775
|
+
* Vraća sve zahteve za tehnologiju
|
|
16776
|
+
* @param technologyId - ID tehnologije
|
|
16777
|
+
* @param type - Opcioni filter za tip zahteva (pre/post)
|
|
16778
|
+
* @returns Lista zahteva
|
|
16779
|
+
*/
|
|
16780
|
+
async getRequirements(technologyId, type) {
|
|
16781
|
+
const technology = await this.getById(technologyId);
|
|
16782
|
+
if (!technology || !technology.requirements) return [];
|
|
16783
|
+
if (type) {
|
|
16784
|
+
return technology.requirements[type];
|
|
16785
|
+
}
|
|
16786
|
+
return [...technology.requirements.pre, ...technology.requirements.post];
|
|
16787
|
+
}
|
|
16788
|
+
/**
|
|
16789
|
+
* Ažurira postojeći zahtev
|
|
16790
|
+
* @param technologyId - ID tehnologije
|
|
16791
|
+
* @param oldRequirement - Stari zahtev koji se menja
|
|
16792
|
+
* @param newRequirement - Novi zahtev koji zamenjuje stari
|
|
16793
|
+
* @returns Ažurirana tehnologija
|
|
16794
|
+
*/
|
|
16795
|
+
async updateRequirement(technologyId, oldRequirement, newRequirement) {
|
|
16796
|
+
await this.removeRequirement(technologyId, oldRequirement);
|
|
16797
|
+
return this.addRequirement(technologyId, newRequirement);
|
|
16798
|
+
}
|
|
16799
|
+
/**
|
|
16800
|
+
* Dodaje blokirajući uslov tehnologiji
|
|
16801
|
+
* @param technologyId - ID tehnologije
|
|
16802
|
+
* @param condition - Blokirajući uslov koji se dodaje
|
|
16803
|
+
* @returns Ažurirana tehnologija
|
|
16804
|
+
*/
|
|
16805
|
+
async addBlockingCondition(technologyId, condition) {
|
|
16806
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16807
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16808
|
+
blockingConditions: (0, import_firestore54.arrayUnion)(condition),
|
|
16809
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16810
|
+
});
|
|
16811
|
+
return this.getById(technologyId);
|
|
16812
|
+
}
|
|
16813
|
+
/**
|
|
16814
|
+
* Uklanja blokirajući uslov iz tehnologije
|
|
16815
|
+
* @param technologyId - ID tehnologije
|
|
16816
|
+
* @param condition - Blokirajući uslov koji se uklanja
|
|
16817
|
+
* @returns Ažurirana tehnologija
|
|
16818
|
+
*/
|
|
16819
|
+
async removeBlockingCondition(technologyId, condition) {
|
|
16820
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16821
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16822
|
+
blockingConditions: (0, import_firestore54.arrayRemove)(condition),
|
|
16823
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16824
|
+
});
|
|
16825
|
+
return this.getById(technologyId);
|
|
16826
|
+
}
|
|
16827
|
+
/**
|
|
16828
|
+
* Dodaje kontraindikaciju tehnologiji
|
|
16829
|
+
* @param technologyId - ID tehnologije
|
|
16830
|
+
* @param contraindication - Kontraindikacija koja se dodaje
|
|
16831
|
+
* @returns Ažurirana tehnologija
|
|
16832
|
+
*/
|
|
16833
|
+
async addContraindication(technologyId, contraindication) {
|
|
16834
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16835
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16836
|
+
contraindications: (0, import_firestore54.arrayUnion)(contraindication),
|
|
16837
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16838
|
+
});
|
|
16839
|
+
return this.getById(technologyId);
|
|
16840
|
+
}
|
|
16841
|
+
/**
|
|
16842
|
+
* Uklanja kontraindikaciju iz tehnologije
|
|
16843
|
+
* @param technologyId - ID tehnologije
|
|
16844
|
+
* @param contraindication - Kontraindikacija koja se uklanja
|
|
16845
|
+
* @returns Ažurirana tehnologija
|
|
16846
|
+
*/
|
|
16847
|
+
async removeContraindication(technologyId, contraindication) {
|
|
16848
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16849
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16850
|
+
contraindications: (0, import_firestore54.arrayRemove)(contraindication),
|
|
16851
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16852
|
+
});
|
|
16853
|
+
return this.getById(technologyId);
|
|
16854
|
+
}
|
|
16855
|
+
/**
|
|
16856
|
+
* Dodaje benefit tehnologiji
|
|
16857
|
+
* @param technologyId - ID tehnologije
|
|
16858
|
+
* @param benefit - Benefit koji se dodaje
|
|
16859
|
+
* @returns Ažurirana tehnologija
|
|
16860
|
+
*/
|
|
16861
|
+
async addBenefit(technologyId, benefit) {
|
|
16862
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16863
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16864
|
+
benefits: (0, import_firestore54.arrayUnion)(benefit),
|
|
16865
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16866
|
+
});
|
|
16867
|
+
return this.getById(technologyId);
|
|
16868
|
+
}
|
|
16869
|
+
/**
|
|
16870
|
+
* Uklanja benefit iz tehnologije
|
|
16871
|
+
* @param technologyId - ID tehnologije
|
|
16872
|
+
* @param benefit - Benefit koji se uklanja
|
|
16873
|
+
* @returns Ažurirana tehnologija
|
|
16874
|
+
*/
|
|
16875
|
+
async removeBenefit(technologyId, benefit) {
|
|
16876
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16877
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16878
|
+
benefits: (0, import_firestore54.arrayRemove)(benefit),
|
|
16879
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16880
|
+
});
|
|
16881
|
+
return this.getById(technologyId);
|
|
16882
|
+
}
|
|
16883
|
+
/**
|
|
16884
|
+
* Vraća sve blokirajuće uslove za tehnologiju
|
|
16885
|
+
* @param technologyId - ID tehnologije
|
|
16886
|
+
* @returns Lista blokirajućih uslova
|
|
16887
|
+
*/
|
|
16888
|
+
async getBlockingConditions(technologyId) {
|
|
16889
|
+
const technology = await this.getById(technologyId);
|
|
16890
|
+
return (technology == null ? void 0 : technology.blockingConditions) || [];
|
|
16891
|
+
}
|
|
16892
|
+
/**
|
|
16893
|
+
* Vraća sve kontraindikacije za tehnologiju
|
|
16894
|
+
* @param technologyId - ID tehnologije
|
|
16895
|
+
* @returns Lista kontraindikacija
|
|
16896
|
+
*/
|
|
16897
|
+
async getContraindications(technologyId) {
|
|
16898
|
+
const technology = await this.getById(technologyId);
|
|
16899
|
+
return (technology == null ? void 0 : technology.contraindications) || [];
|
|
16900
|
+
}
|
|
16901
|
+
/**
|
|
16902
|
+
* Vraća sve benefite za tehnologiju
|
|
16903
|
+
* @param technologyId - ID tehnologije
|
|
16904
|
+
* @returns Lista benefita
|
|
16905
|
+
*/
|
|
16906
|
+
async getBenefits(technologyId) {
|
|
16907
|
+
const technology = await this.getById(technologyId);
|
|
16908
|
+
return (technology == null ? void 0 : technology.benefits) || [];
|
|
16909
|
+
}
|
|
16910
|
+
/**
|
|
16911
|
+
* Ažurira zahteve sertifikacije za tehnologiju
|
|
16912
|
+
* @param technologyId - ID tehnologije
|
|
16913
|
+
* @param certificationRequirement - Novi zahtevi sertifikacije
|
|
16914
|
+
* @returns Ažurirana tehnologija
|
|
16915
|
+
*/
|
|
16916
|
+
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
16917
|
+
const docRef = (0, import_firestore54.doc)(this.getTechnologiesRef(), technologyId);
|
|
16918
|
+
await (0, import_firestore54.updateDoc)(docRef, {
|
|
16919
|
+
certificationRequirement,
|
|
16920
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
16921
|
+
});
|
|
16922
|
+
return this.getById(technologyId);
|
|
16923
|
+
}
|
|
16924
|
+
/**
|
|
16925
|
+
* Vraća zahteve sertifikacije za tehnologiju
|
|
16926
|
+
* @param technologyId - ID tehnologije
|
|
16927
|
+
* @returns Zahtevi sertifikacije ili null ako tehnologija ne postoji
|
|
16928
|
+
*/
|
|
16929
|
+
async getCertificationRequirement(technologyId) {
|
|
16930
|
+
const technology = await this.getById(technologyId);
|
|
16931
|
+
return (technology == null ? void 0 : technology.certificationRequirement) || null;
|
|
16932
|
+
}
|
|
16933
|
+
/**
|
|
16934
|
+
* Proverava da li doktor ima odgovarajuću sertifikaciju za izvođenje tehnologije
|
|
16935
|
+
*
|
|
16936
|
+
* @param requiredCertification - Zahtevana sertifikacija za tehnologiju
|
|
16937
|
+
* @param practitionerCertification - Sertifikacija zdravstvenog radnika
|
|
16938
|
+
* @returns true ako zdravstveni radnik ima odgovarajuću sertifikaciju, false ako nema
|
|
16939
|
+
*
|
|
16940
|
+
* @example
|
|
16941
|
+
* const isValid = technologyService.validateCertification(
|
|
16942
|
+
* {
|
|
16943
|
+
* minimumLevel: CertificationLevel.DOCTOR,
|
|
16944
|
+
* requiredSpecialties: [CertificationSpecialty.INJECTABLES]
|
|
16945
|
+
* },
|
|
16946
|
+
* {
|
|
16947
|
+
* level: CertificationLevel.SPECIALIST,
|
|
16948
|
+
* specialties: [CertificationSpecialty.INJECTABLES, CertificationSpecialty.LASER]
|
|
16949
|
+
* }
|
|
16950
|
+
* );
|
|
16951
|
+
*/
|
|
16952
|
+
validateCertification(requiredCertification, practitionerCertification) {
|
|
16953
|
+
const doctorLevel = Object.values(CertificationLevel).indexOf(
|
|
16954
|
+
practitionerCertification.level
|
|
16955
|
+
);
|
|
16956
|
+
const requiredLevel = Object.values(CertificationLevel).indexOf(
|
|
16957
|
+
requiredCertification.minimumLevel
|
|
16958
|
+
);
|
|
16959
|
+
if (doctorLevel < requiredLevel) return false;
|
|
16960
|
+
const requiredSpecialties = requiredCertification.requiredSpecialties || [];
|
|
16961
|
+
if (requiredSpecialties.length > 0) {
|
|
16962
|
+
const doctorSpecialties = practitionerCertification.specialties;
|
|
16963
|
+
const hasAllRequiredSpecialties = requiredSpecialties.every(
|
|
16964
|
+
(requiredSpecialty) => doctorSpecialties.includes(requiredSpecialty)
|
|
16965
|
+
);
|
|
16966
|
+
if (!hasAllRequiredSpecialties) return false;
|
|
16967
|
+
}
|
|
16968
|
+
return true;
|
|
16969
|
+
}
|
|
16970
|
+
/**
|
|
16971
|
+
* Vraća sve tehnologije koje je zdravstveni radnik sertifikovan da izvodi
|
|
16972
|
+
* zajedno sa listama dozvoljenih familija, kategorija i podkategorija
|
|
16973
|
+
*
|
|
16974
|
+
* @param practitioner - Profil zdravstvenog radnika
|
|
16975
|
+
* @returns Objekat koji sadrži:
|
|
16976
|
+
* - technologies: Lista tehnologija koje zdravstveni radnik može da izvodi
|
|
16977
|
+
* - families: Lista familija procedura koje zdravstveni radnik može da izvodi
|
|
16978
|
+
* - categories: Lista ID-eva kategorija koje zdravstveni radnik može da izvodi
|
|
16979
|
+
* - subcategories: Lista ID-eva podkategorija koje zdravstveni radnik može da izvodi
|
|
16980
|
+
*
|
|
16981
|
+
* @example
|
|
16982
|
+
* const practitioner = {
|
|
16983
|
+
* certification: {
|
|
16984
|
+
* level: CertificationLevel.DOCTOR,
|
|
16985
|
+
* specialties: [CertificationSpecialty.INJECTABLES]
|
|
16986
|
+
* }
|
|
16987
|
+
* };
|
|
16988
|
+
* const allowedTechnologies = await technologyService.getAllowedTechnologies(practitioner);
|
|
16989
|
+
* console.log(allowedTechnologies.families); // [ProcedureFamily.AESTHETICS]
|
|
16990
|
+
* console.log(allowedTechnologies.categories); // ["category1", "category2"]
|
|
16991
|
+
* console.log(allowedTechnologies.subcategories); // ["subcategory1", "subcategory2"]
|
|
16992
|
+
*/
|
|
16993
|
+
async getAllowedTechnologies(practitioner) {
|
|
16994
|
+
const allTechnologies = await this.getAll();
|
|
16995
|
+
const allowedTechnologies = allTechnologies.filter(
|
|
16996
|
+
(technology) => this.validateCertification(
|
|
16997
|
+
technology.certificationRequirement,
|
|
16998
|
+
practitioner.certification
|
|
16999
|
+
)
|
|
17000
|
+
);
|
|
17001
|
+
const families = [...new Set(allowedTechnologies.map((t) => t.family))];
|
|
17002
|
+
const categories = [
|
|
17003
|
+
...new Set(allowedTechnologies.map((t) => t.categoryId))
|
|
17004
|
+
];
|
|
17005
|
+
const subcategories = [
|
|
17006
|
+
...new Set(allowedTechnologies.map((t) => t.subcategoryId))
|
|
17007
|
+
];
|
|
17008
|
+
return {
|
|
17009
|
+
technologies: allowedTechnologies,
|
|
17010
|
+
families,
|
|
17011
|
+
categories,
|
|
17012
|
+
subcategories
|
|
17013
|
+
};
|
|
17014
|
+
}
|
|
17015
|
+
};
|
|
17016
|
+
|
|
17017
|
+
// src/backoffice/services/product.service.ts
|
|
17018
|
+
var import_firestore55 = require("firebase/firestore");
|
|
17019
|
+
|
|
17020
|
+
// src/backoffice/types/product.types.ts
|
|
17021
|
+
var PRODUCTS_COLLECTION = "products";
|
|
17022
|
+
|
|
17023
|
+
// src/backoffice/services/product.service.ts
|
|
17024
|
+
var ProductService = class extends BaseService {
|
|
17025
|
+
/**
|
|
17026
|
+
* Gets reference to products collection under a technology
|
|
17027
|
+
* @param technologyId - ID of the technology
|
|
17028
|
+
* @returns Firestore collection reference
|
|
17029
|
+
*/
|
|
17030
|
+
getProductsRef(technologyId) {
|
|
17031
|
+
return (0, import_firestore55.collection)(
|
|
17032
|
+
this.db,
|
|
17033
|
+
TECHNOLOGIES_COLLECTION,
|
|
17034
|
+
technologyId,
|
|
17035
|
+
PRODUCTS_COLLECTION
|
|
17036
|
+
);
|
|
17037
|
+
}
|
|
17038
|
+
/**
|
|
17039
|
+
* Creates a new product under technology
|
|
17040
|
+
*/
|
|
17041
|
+
async create(technologyId, brandId, product) {
|
|
17042
|
+
const now = /* @__PURE__ */ new Date();
|
|
17043
|
+
const newProduct = {
|
|
17044
|
+
...product,
|
|
17045
|
+
brandId,
|
|
17046
|
+
technologyId,
|
|
17047
|
+
createdAt: now,
|
|
17048
|
+
updatedAt: now,
|
|
17049
|
+
isActive: true
|
|
17050
|
+
};
|
|
17051
|
+
const productRef = await (0, import_firestore55.addDoc)(
|
|
17052
|
+
this.getProductsRef(technologyId),
|
|
17053
|
+
newProduct
|
|
17054
|
+
);
|
|
17055
|
+
return { id: productRef.id, ...newProduct };
|
|
17056
|
+
}
|
|
17057
|
+
/**
|
|
17058
|
+
* Gets all products for a technology
|
|
17059
|
+
*/
|
|
17060
|
+
async getAllByTechnology(technologyId) {
|
|
17061
|
+
const q = (0, import_firestore55.query)(
|
|
17062
|
+
this.getProductsRef(technologyId),
|
|
17063
|
+
(0, import_firestore55.where)("isActive", "==", true)
|
|
17064
|
+
);
|
|
17065
|
+
const snapshot = await (0, import_firestore55.getDocs)(q);
|
|
17066
|
+
return snapshot.docs.map(
|
|
17067
|
+
(doc37) => ({
|
|
17068
|
+
id: doc37.id,
|
|
17069
|
+
...doc37.data()
|
|
17070
|
+
})
|
|
17071
|
+
);
|
|
17072
|
+
}
|
|
17073
|
+
/**
|
|
17074
|
+
* Gets all products for a brand by filtering through all technologies
|
|
17075
|
+
*/
|
|
17076
|
+
async getAllByBrand(brandId) {
|
|
17077
|
+
const allTechnologiesRef = (0, import_firestore55.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
17078
|
+
const technologiesSnapshot = await (0, import_firestore55.getDocs)(allTechnologiesRef);
|
|
17079
|
+
const products = [];
|
|
17080
|
+
for (const techDoc of technologiesSnapshot.docs) {
|
|
17081
|
+
const q = (0, import_firestore55.query)(
|
|
17082
|
+
this.getProductsRef(techDoc.id),
|
|
17083
|
+
(0, import_firestore55.where)("brandId", "==", brandId),
|
|
17084
|
+
(0, import_firestore55.where)("isActive", "==", true)
|
|
17085
|
+
);
|
|
17086
|
+
const snapshot = await (0, import_firestore55.getDocs)(q);
|
|
17087
|
+
products.push(
|
|
17088
|
+
...snapshot.docs.map(
|
|
17089
|
+
(doc37) => ({
|
|
17090
|
+
id: doc37.id,
|
|
17091
|
+
...doc37.data()
|
|
17092
|
+
})
|
|
17093
|
+
)
|
|
17094
|
+
);
|
|
17095
|
+
}
|
|
17096
|
+
return products;
|
|
17097
|
+
}
|
|
17098
|
+
/**
|
|
17099
|
+
* Updates a product
|
|
17100
|
+
*/
|
|
17101
|
+
async update(technologyId, productId, product) {
|
|
17102
|
+
const updateData = {
|
|
17103
|
+
...product,
|
|
17104
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
17105
|
+
};
|
|
17106
|
+
const docRef = (0, import_firestore55.doc)(this.getProductsRef(technologyId), productId);
|
|
17107
|
+
await (0, import_firestore55.updateDoc)(docRef, updateData);
|
|
17108
|
+
return this.getById(technologyId, productId);
|
|
17109
|
+
}
|
|
17110
|
+
/**
|
|
17111
|
+
* Soft deletes a product
|
|
17112
|
+
*/
|
|
17113
|
+
async delete(technologyId, productId) {
|
|
17114
|
+
await this.update(technologyId, productId, {
|
|
17115
|
+
isActive: false
|
|
17116
|
+
});
|
|
17117
|
+
}
|
|
17118
|
+
/**
|
|
17119
|
+
* Gets a product by ID
|
|
17120
|
+
*/
|
|
17121
|
+
async getById(technologyId, productId) {
|
|
17122
|
+
const docRef = (0, import_firestore55.doc)(this.getProductsRef(technologyId), productId);
|
|
17123
|
+
const docSnap = await (0, import_firestore55.getDoc)(docRef);
|
|
17124
|
+
if (!docSnap.exists()) return null;
|
|
17125
|
+
return {
|
|
17126
|
+
id: docSnap.id,
|
|
17127
|
+
...docSnap.data()
|
|
17128
|
+
};
|
|
17129
|
+
}
|
|
17130
|
+
};
|
|
16303
17131
|
// Annotate the CommonJS export names for ESM import in node:
|
|
16304
17132
|
0 && (module.exports = {
|
|
16305
17133
|
APPOINTMENTS_COLLECTION,
|
|
@@ -16309,6 +17137,8 @@ var getFirebaseFunctions = async () => {
|
|
|
16309
17137
|
AppointmentStatus,
|
|
16310
17138
|
AuthService,
|
|
16311
17139
|
BaseService,
|
|
17140
|
+
BlockingCondition,
|
|
17141
|
+
BrandService,
|
|
16312
17142
|
CALENDAR_COLLECTION,
|
|
16313
17143
|
CLINICS_COLLECTION,
|
|
16314
17144
|
CLINIC_ADMINS_COLLECTION,
|
|
@@ -16318,12 +17148,17 @@ var getFirebaseFunctions = async () => {
|
|
|
16318
17148
|
CalendarServiceV2,
|
|
16319
17149
|
CalendarServiceV3,
|
|
16320
17150
|
CalendarSyncStatus,
|
|
17151
|
+
CategoryService,
|
|
17152
|
+
CertificationLevel,
|
|
17153
|
+
CertificationSpecialty,
|
|
16321
17154
|
ClinicAdminService,
|
|
16322
17155
|
ClinicGroupService,
|
|
16323
17156
|
ClinicPhotoTag,
|
|
16324
17157
|
ClinicService,
|
|
16325
17158
|
ClinicTag,
|
|
17159
|
+
Contraindication,
|
|
16326
17160
|
CosmeticAllergySubtype,
|
|
17161
|
+
Currency,
|
|
16327
17162
|
DEFAULT_MEDICAL_INFO,
|
|
16328
17163
|
DOCTOR_FORMS_SUBCOLLECTION,
|
|
16329
17164
|
DOCUMENTATION_TEMPLATES_COLLECTION,
|
|
@@ -16372,15 +17207,23 @@ var getFirebaseFunctions = async () => {
|
|
|
16372
17207
|
PractitionerService,
|
|
16373
17208
|
PractitionerStatus,
|
|
16374
17209
|
PractitionerTokenStatus,
|
|
17210
|
+
PricingMeasure,
|
|
17211
|
+
ProcedureFamily,
|
|
16375
17212
|
ProcedureService,
|
|
17213
|
+
ProductService,
|
|
16376
17214
|
REGISTER_TOKENS_COLLECTION,
|
|
16377
17215
|
REVIEWS_COLLECTION,
|
|
17216
|
+
RequirementType,
|
|
16378
17217
|
ReviewService,
|
|
16379
17218
|
SYNCED_CALENDARS_COLLECTION,
|
|
16380
17219
|
SearchLocationEnum,
|
|
17220
|
+
SubcategoryService,
|
|
16381
17221
|
SubscriptionModel,
|
|
16382
17222
|
SyncedCalendarProvider,
|
|
17223
|
+
TechnologyService,
|
|
17224
|
+
TimeUnit,
|
|
16383
17225
|
TimestampUtils,
|
|
17226
|
+
TreatmentBenefit,
|
|
16384
17227
|
USERS_COLLECTION,
|
|
16385
17228
|
USER_FORMS_SUBCOLLECTION,
|
|
16386
17229
|
UserRole,
|