@blackcode_sa/metaestetics-api 1.5.16 → 1.5.18
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/backoffice/index.d.mts +2 -2
- package/dist/backoffice/index.d.ts +2 -2
- package/dist/index.d.mts +233 -40
- package/dist/index.d.ts +233 -40
- package/dist/index.js +748 -427
- package/dist/index.mjs +1073 -739
- package/package.json +1 -1
- package/src/index.ts +5 -0
- package/src/services/calendar/calendar-refactored.service.ts +147 -0
- package/src/services/calendar/utils/calendar-event.utils.ts +136 -0
- package/src/services/calendar/utils/index.ts +5 -5
- package/src/services/patient/patient.service.ts +100 -127
- package/src/services/patient/utils/medical-stuff.utils.ts +69 -18
- package/src/services/patient/utils/profile.utils.ts +206 -94
- package/src/types/calendar/index.ts +41 -0
- package/src/types/patient/index.ts +31 -1
- package/src/types/practitioner/index.ts +13 -14
- package/src/validations/patient.schema.ts +43 -0
package/dist/index.js
CHANGED
|
@@ -82,6 +82,7 @@ __export(index_exports, {
|
|
|
82
82
|
ProductService: () => ProductService,
|
|
83
83
|
REGISTER_TOKENS_COLLECTION: () => REGISTER_TOKENS_COLLECTION,
|
|
84
84
|
SYNCED_CALENDARS_COLLECTION: () => SYNCED_CALENDARS_COLLECTION,
|
|
85
|
+
SearchLocationEnum: () => SearchLocationEnum,
|
|
85
86
|
SubcategoryService: () => SubcategoryService,
|
|
86
87
|
SubscriptionModel: () => SubscriptionModel,
|
|
87
88
|
SyncedCalendarProvider: () => SyncedCalendarProvider,
|
|
@@ -171,7 +172,9 @@ __export(index_exports, {
|
|
|
171
172
|
preRequirementNotificationSchema: () => preRequirementNotificationSchema,
|
|
172
173
|
procedureCategorizationSchema: () => procedureCategorizationSchema,
|
|
173
174
|
procedureInfoSchema: () => procedureInfoSchema,
|
|
175
|
+
requesterInfoSchema: () => requesterInfoSchema,
|
|
174
176
|
reviewInfoSchema: () => reviewInfoSchema,
|
|
177
|
+
searchPatientsSchema: () => searchPatientsSchema,
|
|
175
178
|
serviceInfoSchema: () => serviceInfoSchema,
|
|
176
179
|
syncedCalendarEventSchema: () => syncedCalendarEventSchema,
|
|
177
180
|
timeSlotSchema: () => timeSlotSchema2,
|
|
@@ -290,29 +293,35 @@ var FilledDocumentStatus = /* @__PURE__ */ ((FilledDocumentStatus2) => {
|
|
|
290
293
|
})(FilledDocumentStatus || {});
|
|
291
294
|
|
|
292
295
|
// src/types/calendar/index.ts
|
|
293
|
-
var CalendarEventStatus = /* @__PURE__ */ ((
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return
|
|
296
|
+
var CalendarEventStatus = /* @__PURE__ */ ((CalendarEventStatus4) => {
|
|
297
|
+
CalendarEventStatus4["PENDING"] = "pending";
|
|
298
|
+
CalendarEventStatus4["CONFIRMED"] = "confirmed";
|
|
299
|
+
CalendarEventStatus4["REJECTED"] = "rejected";
|
|
300
|
+
CalendarEventStatus4["CANCELED"] = "canceled";
|
|
301
|
+
CalendarEventStatus4["RESCHEDULED"] = "rescheduled";
|
|
302
|
+
CalendarEventStatus4["COMPLETED"] = "completed";
|
|
303
|
+
return CalendarEventStatus4;
|
|
301
304
|
})(CalendarEventStatus || {});
|
|
302
|
-
var CalendarSyncStatus = /* @__PURE__ */ ((
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return
|
|
305
|
+
var CalendarSyncStatus = /* @__PURE__ */ ((CalendarSyncStatus4) => {
|
|
306
|
+
CalendarSyncStatus4["INTERNAL"] = "internal";
|
|
307
|
+
CalendarSyncStatus4["EXTERNAL"] = "external";
|
|
308
|
+
return CalendarSyncStatus4;
|
|
306
309
|
})(CalendarSyncStatus || {});
|
|
307
|
-
var CalendarEventType = /* @__PURE__ */ ((
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return
|
|
310
|
+
var CalendarEventType = /* @__PURE__ */ ((CalendarEventType3) => {
|
|
311
|
+
CalendarEventType3["APPOINTMENT"] = "appointment";
|
|
312
|
+
CalendarEventType3["BLOCKING"] = "blocking";
|
|
313
|
+
CalendarEventType3["BREAK"] = "break";
|
|
314
|
+
CalendarEventType3["FREE_DAY"] = "free_day";
|
|
315
|
+
CalendarEventType3["OTHER"] = "other";
|
|
316
|
+
return CalendarEventType3;
|
|
314
317
|
})(CalendarEventType || {});
|
|
315
318
|
var CALENDAR_COLLECTION = "calendar";
|
|
319
|
+
var SearchLocationEnum = /* @__PURE__ */ ((SearchLocationEnum2) => {
|
|
320
|
+
SearchLocationEnum2["PRACTITIONER"] = "practitioner";
|
|
321
|
+
SearchLocationEnum2["PATIENT"] = "patient";
|
|
322
|
+
SearchLocationEnum2["CLINIC"] = "clinic";
|
|
323
|
+
return SearchLocationEnum2;
|
|
324
|
+
})(SearchLocationEnum || {});
|
|
316
325
|
|
|
317
326
|
// src/types/index.ts
|
|
318
327
|
var UserRole = /* @__PURE__ */ ((UserRole2) => {
|
|
@@ -1148,6 +1157,8 @@ var patientProfileSchema = import_zod5.z.object({
|
|
|
1148
1157
|
isVerified: import_zod5.z.boolean(),
|
|
1149
1158
|
doctors: import_zod5.z.array(patientDoctorSchema),
|
|
1150
1159
|
clinics: import_zod5.z.array(patientClinicSchema),
|
|
1160
|
+
doctorIds: import_zod5.z.array(import_zod5.z.string()),
|
|
1161
|
+
clinicIds: import_zod5.z.array(import_zod5.z.string()),
|
|
1151
1162
|
createdAt: import_zod5.z.instanceof(import_firestore2.Timestamp),
|
|
1152
1163
|
updatedAt: import_zod5.z.instanceof(import_firestore2.Timestamp)
|
|
1153
1164
|
});
|
|
@@ -1160,7 +1171,9 @@ var createPatientProfileSchema = import_zod5.z.object({
|
|
|
1160
1171
|
isActive: import_zod5.z.boolean(),
|
|
1161
1172
|
isVerified: import_zod5.z.boolean(),
|
|
1162
1173
|
doctors: import_zod5.z.array(patientDoctorSchema).optional(),
|
|
1163
|
-
clinics: import_zod5.z.array(patientClinicSchema).optional()
|
|
1174
|
+
clinics: import_zod5.z.array(patientClinicSchema).optional(),
|
|
1175
|
+
doctorIds: import_zod5.z.array(import_zod5.z.string()).optional(),
|
|
1176
|
+
clinicIds: import_zod5.z.array(import_zod5.z.string()).optional()
|
|
1164
1177
|
});
|
|
1165
1178
|
var createPatientSensitiveInfoSchema = import_zod5.z.object({
|
|
1166
1179
|
patientId: import_zod5.z.string(),
|
|
@@ -1176,6 +1189,33 @@ var createPatientSensitiveInfoSchema = import_zod5.z.object({
|
|
|
1176
1189
|
addressData: addressDataSchema.optional(),
|
|
1177
1190
|
emergencyContacts: import_zod5.z.array(emergencyContactSchema).optional()
|
|
1178
1191
|
});
|
|
1192
|
+
var searchPatientsSchema = import_zod5.z.object({
|
|
1193
|
+
clinicId: import_zod5.z.string().optional(),
|
|
1194
|
+
practitionerId: import_zod5.z.string().optional()
|
|
1195
|
+
}).refine((data) => data.clinicId || data.practitionerId, {
|
|
1196
|
+
message: "At least one of clinicId or practitionerId must be provided",
|
|
1197
|
+
path: []
|
|
1198
|
+
// Optional: specify a path like ['clinicId'] or ['practitionerId']
|
|
1199
|
+
});
|
|
1200
|
+
var requesterInfoSchema = import_zod5.z.object({
|
|
1201
|
+
id: import_zod5.z.string(),
|
|
1202
|
+
role: import_zod5.z.enum(["clinic_admin", "practitioner"]),
|
|
1203
|
+
associatedClinicId: import_zod5.z.string().optional(),
|
|
1204
|
+
associatedPractitionerId: import_zod5.z.string().optional()
|
|
1205
|
+
}).refine(
|
|
1206
|
+
(data) => {
|
|
1207
|
+
if (data.role === "clinic_admin") {
|
|
1208
|
+
return !!data.associatedClinicId;
|
|
1209
|
+
} else if (data.role === "practitioner") {
|
|
1210
|
+
return !!data.associatedPractitionerId;
|
|
1211
|
+
}
|
|
1212
|
+
return false;
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
message: "Associated ID (clinic or practitioner) is required based on role",
|
|
1216
|
+
path: ["associatedClinicId", "associatedPractitionerId"]
|
|
1217
|
+
}
|
|
1218
|
+
);
|
|
1179
1219
|
|
|
1180
1220
|
// src/services/patient/utils/docs.utils.ts
|
|
1181
1221
|
var import_firestore4 = require("firebase/firestore");
|
|
@@ -1440,9 +1480,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1440
1480
|
var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
1441
1481
|
const validatedData = updateAllergySchema.parse(data);
|
|
1442
1482
|
const { allergyIndex, ...updateData } = validatedData;
|
|
1443
|
-
const
|
|
1444
|
-
if (!
|
|
1445
|
-
const medicalInfo =
|
|
1483
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1484
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1485
|
+
const medicalInfo = doc28.data();
|
|
1446
1486
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1447
1487
|
throw new Error("Invalid allergy index");
|
|
1448
1488
|
}
|
|
@@ -1458,9 +1498,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1458
1498
|
});
|
|
1459
1499
|
};
|
|
1460
1500
|
var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
|
|
1461
|
-
const
|
|
1462
|
-
if (!
|
|
1463
|
-
const medicalInfo =
|
|
1501
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1502
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1503
|
+
const medicalInfo = doc28.data();
|
|
1464
1504
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1465
1505
|
throw new Error("Invalid allergy index");
|
|
1466
1506
|
}
|
|
@@ -1485,9 +1525,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1485
1525
|
var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
1486
1526
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
1487
1527
|
const { conditionIndex, ...updateData } = validatedData;
|
|
1488
|
-
const
|
|
1489
|
-
if (!
|
|
1490
|
-
const medicalInfo =
|
|
1528
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1529
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1530
|
+
const medicalInfo = doc28.data();
|
|
1491
1531
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1492
1532
|
throw new Error("Invalid blocking condition index");
|
|
1493
1533
|
}
|
|
@@ -1503,9 +1543,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1503
1543
|
});
|
|
1504
1544
|
};
|
|
1505
1545
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
|
|
1506
|
-
const
|
|
1507
|
-
if (!
|
|
1508
|
-
const medicalInfo =
|
|
1546
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1547
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1548
|
+
const medicalInfo = doc28.data();
|
|
1509
1549
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1510
1550
|
throw new Error("Invalid blocking condition index");
|
|
1511
1551
|
}
|
|
@@ -1530,9 +1570,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1530
1570
|
var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
1531
1571
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
1532
1572
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
1533
|
-
const
|
|
1534
|
-
if (!
|
|
1535
|
-
const medicalInfo =
|
|
1573
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1574
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1575
|
+
const medicalInfo = doc28.data();
|
|
1536
1576
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1537
1577
|
throw new Error("Invalid contraindication index");
|
|
1538
1578
|
}
|
|
@@ -1548,9 +1588,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1548
1588
|
});
|
|
1549
1589
|
};
|
|
1550
1590
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
|
|
1551
|
-
const
|
|
1552
|
-
if (!
|
|
1553
|
-
const medicalInfo =
|
|
1591
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1592
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1593
|
+
const medicalInfo = doc28.data();
|
|
1554
1594
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1555
1595
|
throw new Error("Invalid contraindication index");
|
|
1556
1596
|
}
|
|
@@ -1575,9 +1615,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1575
1615
|
var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
1576
1616
|
const validatedData = updateMedicationSchema.parse(data);
|
|
1577
1617
|
const { medicationIndex, ...updateData } = validatedData;
|
|
1578
|
-
const
|
|
1579
|
-
if (!
|
|
1580
|
-
const medicalInfo =
|
|
1618
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1619
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1620
|
+
const medicalInfo = doc28.data();
|
|
1581
1621
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1582
1622
|
throw new Error("Invalid medication index");
|
|
1583
1623
|
}
|
|
@@ -1593,9 +1633,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1593
1633
|
});
|
|
1594
1634
|
};
|
|
1595
1635
|
var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
|
|
1596
|
-
const
|
|
1597
|
-
if (!
|
|
1598
|
-
const medicalInfo =
|
|
1636
|
+
const doc28 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1637
|
+
if (!doc28.exists()) throw new Error("Medical info not found");
|
|
1638
|
+
const medicalInfo = doc28.data();
|
|
1599
1639
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1600
1640
|
throw new Error("Invalid medication index");
|
|
1601
1641
|
}
|
|
@@ -1611,6 +1651,7 @@ var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
|
|
|
1611
1651
|
|
|
1612
1652
|
// src/services/patient/utils/profile.utils.ts
|
|
1613
1653
|
var createPatientProfileUtil = async (db, data, generateId2) => {
|
|
1654
|
+
var _a, _b;
|
|
1614
1655
|
try {
|
|
1615
1656
|
console.log("[createPatientProfileUtil] Starting patient profile creation");
|
|
1616
1657
|
const validatedData = createPatientProfileSchema.parse(data);
|
|
@@ -1630,6 +1671,8 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
|
|
|
1630
1671
|
isVerified: validatedData.isVerified,
|
|
1631
1672
|
doctors: validatedData.doctors || [],
|
|
1632
1673
|
clinics: validatedData.clinics || [],
|
|
1674
|
+
doctorIds: ((_a = validatedData.doctors) == null ? void 0 : _a.map((d) => d.userRef)) || [],
|
|
1675
|
+
clinicIds: ((_b = validatedData.clinics) == null ? void 0 : _b.map((c) => c.clinicId)) || [],
|
|
1633
1676
|
createdAt: (0, import_firestore6.serverTimestamp)(),
|
|
1634
1677
|
updatedAt: (0, import_firestore6.serverTimestamp)()
|
|
1635
1678
|
};
|
|
@@ -1652,58 +1695,36 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
|
|
|
1652
1695
|
);
|
|
1653
1696
|
sensitiveInfoSuccess = true;
|
|
1654
1697
|
} catch (sensitiveError) {
|
|
1655
|
-
console.error(
|
|
1656
|
-
`[createPatientProfileUtil] Error creating sensitive info:`,
|
|
1657
|
-
sensitiveError
|
|
1658
|
-
);
|
|
1698
|
+
console.error(`[createPatientProfileUtil] Error creating sensitive info:`, sensitiveError);
|
|
1659
1699
|
}
|
|
1660
1700
|
console.log(`[createPatientProfileUtil] Creating medical info document`);
|
|
1661
1701
|
let medicalInfoSuccess = false;
|
|
1662
1702
|
try {
|
|
1663
1703
|
await ensureMedicalInfoExists(db, patientId, validatedData.userRef);
|
|
1664
|
-
console.log(
|
|
1665
|
-
`[createPatientProfileUtil] Medical info document created successfully`
|
|
1666
|
-
);
|
|
1704
|
+
console.log(`[createPatientProfileUtil] Medical info document created successfully`);
|
|
1667
1705
|
medicalInfoSuccess = true;
|
|
1668
1706
|
} catch (medicalError) {
|
|
1669
|
-
console.error(
|
|
1670
|
-
`[createPatientProfileUtil] Error creating medical info:`,
|
|
1671
|
-
medicalError
|
|
1672
|
-
);
|
|
1707
|
+
console.error(`[createPatientProfileUtil] Error creating medical info:`, medicalError);
|
|
1673
1708
|
}
|
|
1674
1709
|
if (!sensitiveInfoSuccess || !medicalInfoSuccess) {
|
|
1675
|
-
console.log(
|
|
1676
|
-
`[createPatientProfileUtil] Using fallback method to create documents`
|
|
1677
|
-
);
|
|
1710
|
+
console.log(`[createPatientProfileUtil] Using fallback method to create documents`);
|
|
1678
1711
|
try {
|
|
1679
1712
|
await testCreateSubDocuments(db, patientId, validatedData.userRef);
|
|
1680
|
-
console.log(
|
|
1681
|
-
`[createPatientProfileUtil] Fallback method completed successfully`
|
|
1682
|
-
);
|
|
1713
|
+
console.log(`[createPatientProfileUtil] Fallback method completed successfully`);
|
|
1683
1714
|
} catch (fallbackError) {
|
|
1684
|
-
console.error(
|
|
1685
|
-
`[createPatientProfileUtil] Fallback method failed:`,
|
|
1686
|
-
fallbackError
|
|
1687
|
-
);
|
|
1715
|
+
console.error(`[createPatientProfileUtil] Fallback method failed:`, fallbackError);
|
|
1688
1716
|
}
|
|
1689
1717
|
}
|
|
1690
1718
|
console.log(`[createPatientProfileUtil] Verifying patient document exists`);
|
|
1691
1719
|
const patientDoc = await (0, import_firestore6.getDoc)(getPatientDocRef(db, patientId));
|
|
1692
1720
|
if (!patientDoc.exists()) {
|
|
1693
|
-
console.error(
|
|
1694
|
-
`[createPatientProfileUtil] Patient document not found after creation`
|
|
1695
|
-
);
|
|
1721
|
+
console.error(`[createPatientProfileUtil] Patient document not found after creation`);
|
|
1696
1722
|
throw new Error("Failed to create patient profile");
|
|
1697
1723
|
}
|
|
1698
|
-
console.log(
|
|
1699
|
-
`[createPatientProfileUtil] Patient profile creation completed successfully`
|
|
1700
|
-
);
|
|
1724
|
+
console.log(`[createPatientProfileUtil] Patient profile creation completed successfully`);
|
|
1701
1725
|
return patientDoc.data();
|
|
1702
1726
|
} catch (error) {
|
|
1703
|
-
console.error(
|
|
1704
|
-
`[createPatientProfileUtil] Error in patient profile creation:`,
|
|
1705
|
-
error
|
|
1706
|
-
);
|
|
1727
|
+
console.error(`[createPatientProfileUtil] Error in patient profile creation:`, error);
|
|
1707
1728
|
if (error instanceof import_zod7.z.ZodError) {
|
|
1708
1729
|
throw new Error("Invalid patient data: " + error.message);
|
|
1709
1730
|
}
|
|
@@ -1769,9 +1790,7 @@ var updatePatientProfileByUserRefUtil = async (db, userRef, data) => {
|
|
|
1769
1790
|
return updatePatientProfileUtil(db, patientData.id, data);
|
|
1770
1791
|
} catch (error) {
|
|
1771
1792
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1772
|
-
throw new Error(
|
|
1773
|
-
`Failed to update patient profile by user ref: ${errorMessage}`
|
|
1774
|
-
);
|
|
1793
|
+
throw new Error(`Failed to update patient profile by user ref: ${errorMessage}`);
|
|
1775
1794
|
}
|
|
1776
1795
|
};
|
|
1777
1796
|
var uploadProfilePhotoUtil = async (storage, patientId, file) => {
|
|
@@ -1822,9 +1841,7 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
1822
1841
|
try {
|
|
1823
1842
|
console.log(`[testCreateSubDocuments] Testing sensitive info creation`);
|
|
1824
1843
|
const sensitiveInfoRef = getSensitiveInfoDocRef(db, patientId);
|
|
1825
|
-
console.log(
|
|
1826
|
-
`[testCreateSubDocuments] Sensitive info path: ${sensitiveInfoRef.path}`
|
|
1827
|
-
);
|
|
1844
|
+
console.log(`[testCreateSubDocuments] Sensitive info path: ${sensitiveInfoRef.path}`);
|
|
1828
1845
|
const defaultSensitiveInfo = {
|
|
1829
1846
|
patientId,
|
|
1830
1847
|
userRef,
|
|
@@ -1839,14 +1856,10 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
1839
1856
|
updatedAt: import_firestore6.Timestamp.now()
|
|
1840
1857
|
};
|
|
1841
1858
|
await (0, import_firestore6.setDoc)(sensitiveInfoRef, defaultSensitiveInfo);
|
|
1842
|
-
console.log(
|
|
1843
|
-
`[testCreateSubDocuments] Sensitive info document created directly`
|
|
1844
|
-
);
|
|
1859
|
+
console.log(`[testCreateSubDocuments] Sensitive info document created directly`);
|
|
1845
1860
|
console.log(`[testCreateSubDocuments] Testing medical info creation`);
|
|
1846
1861
|
const medicalInfoRef = getMedicalInfoDocRef(db, patientId);
|
|
1847
|
-
console.log(
|
|
1848
|
-
`[testCreateSubDocuments] Medical info path: ${medicalInfoRef.path}`
|
|
1849
|
-
);
|
|
1862
|
+
console.log(`[testCreateSubDocuments] Medical info path: ${medicalInfoRef.path}`);
|
|
1850
1863
|
const defaultMedicalInfo = {
|
|
1851
1864
|
...DEFAULT_MEDICAL_INFO,
|
|
1852
1865
|
patientId,
|
|
@@ -1854,15 +1867,88 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
1854
1867
|
updatedBy: userRef
|
|
1855
1868
|
};
|
|
1856
1869
|
await (0, import_firestore6.setDoc)(medicalInfoRef, defaultMedicalInfo);
|
|
1857
|
-
console.log(
|
|
1858
|
-
`[testCreateSubDocuments] Medical info document created directly`
|
|
1859
|
-
);
|
|
1870
|
+
console.log(`[testCreateSubDocuments] Medical info document created directly`);
|
|
1860
1871
|
console.log(`[testCreateSubDocuments] Test completed successfully`);
|
|
1861
1872
|
} catch (error) {
|
|
1862
1873
|
console.error(`[testCreateSubDocuments] Error:`, error);
|
|
1863
1874
|
throw error;
|
|
1864
1875
|
}
|
|
1865
1876
|
};
|
|
1877
|
+
var searchPatientsUtil = async (db, params, requester) => {
|
|
1878
|
+
searchPatientsSchema.parse(params);
|
|
1879
|
+
requesterInfoSchema.parse(requester);
|
|
1880
|
+
const constraints = [];
|
|
1881
|
+
const patientsCollectionRef = (0, import_firestore6.collection)(db, PATIENTS_COLLECTION);
|
|
1882
|
+
if (requester.role === "clinic_admin") {
|
|
1883
|
+
if (!requester.associatedClinicId) {
|
|
1884
|
+
throw new Error("Associated clinic ID is required for clinic admin search.");
|
|
1885
|
+
}
|
|
1886
|
+
if (params.clinicId && params.clinicId !== requester.associatedClinicId) {
|
|
1887
|
+
console.warn(
|
|
1888
|
+
`Clinic admin (${requester.id}) attempted to search outside their associated clinic (${requester.associatedClinicId})`
|
|
1889
|
+
);
|
|
1890
|
+
return [];
|
|
1891
|
+
}
|
|
1892
|
+
constraints.push((0, import_firestore6.where)("clinicIds", "array-contains", requester.associatedClinicId));
|
|
1893
|
+
if (params.practitionerId) {
|
|
1894
|
+
constraints.push((0, import_firestore6.where)("doctorIds", "array-contains", params.practitionerId));
|
|
1895
|
+
}
|
|
1896
|
+
} else if (requester.role === "practitioner") {
|
|
1897
|
+
if (!requester.associatedPractitionerId) {
|
|
1898
|
+
throw new Error("Associated practitioner ID is required for practitioner search.");
|
|
1899
|
+
}
|
|
1900
|
+
if (params.practitionerId && params.practitionerId !== requester.associatedPractitionerId) {
|
|
1901
|
+
console.warn(
|
|
1902
|
+
`Practitioner (${requester.id}) attempted to search for patients of another practitioner (${params.practitionerId})`
|
|
1903
|
+
);
|
|
1904
|
+
return [];
|
|
1905
|
+
}
|
|
1906
|
+
constraints.push((0, import_firestore6.where)("doctorIds", "array-contains", requester.associatedPractitionerId));
|
|
1907
|
+
if (params.clinicId) {
|
|
1908
|
+
constraints.push((0, import_firestore6.where)("clinicIds", "array-contains", params.clinicId));
|
|
1909
|
+
}
|
|
1910
|
+
} else {
|
|
1911
|
+
throw new Error("Invalid requester role.");
|
|
1912
|
+
}
|
|
1913
|
+
try {
|
|
1914
|
+
const finalQuery = (0, import_firestore6.query)(patientsCollectionRef, ...constraints);
|
|
1915
|
+
const querySnapshot = await (0, import_firestore6.getDocs)(finalQuery);
|
|
1916
|
+
const patients = querySnapshot.docs.map((doc28) => doc28.data());
|
|
1917
|
+
console.log(`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`);
|
|
1918
|
+
return patients;
|
|
1919
|
+
} catch (error) {
|
|
1920
|
+
console.error("[searchPatientsUtil] Error searching patients:", error);
|
|
1921
|
+
return [];
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
var getAllPatientsUtil = async (db, options) => {
|
|
1925
|
+
try {
|
|
1926
|
+
console.log(`[getAllPatientsUtil] Fetching patients with options:`, options);
|
|
1927
|
+
const patientsCollection = (0, import_firestore6.collection)(db, PATIENTS_COLLECTION);
|
|
1928
|
+
let q = (0, import_firestore6.query)(patientsCollection);
|
|
1929
|
+
if (options == null ? void 0 : options.limit) {
|
|
1930
|
+
q = (0, import_firestore6.query)(q, (0, import_firestore6.limit)(options.limit));
|
|
1931
|
+
}
|
|
1932
|
+
if (options == null ? void 0 : options.startAfter) {
|
|
1933
|
+
const startAfterDoc = await (0, import_firestore6.getDoc)((0, import_firestore6.doc)(db, PATIENTS_COLLECTION, options.startAfter));
|
|
1934
|
+
if (startAfterDoc.exists()) {
|
|
1935
|
+
q = (0, import_firestore6.query)(q, (0, import_firestore6.startAfter)(startAfterDoc));
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
const patientsSnapshot = await (0, import_firestore6.getDocs)(q);
|
|
1939
|
+
const patients = [];
|
|
1940
|
+
patientsSnapshot.forEach((doc28) => {
|
|
1941
|
+
patients.push(doc28.data());
|
|
1942
|
+
});
|
|
1943
|
+
console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
|
|
1944
|
+
return patients;
|
|
1945
|
+
} catch (error) {
|
|
1946
|
+
console.error(`[getAllPatientsUtil] Error fetching patients:`, error);
|
|
1947
|
+
throw new Error(
|
|
1948
|
+
`Failed to retrieve patients: ${error instanceof Error ? error.message : String(error)}`
|
|
1949
|
+
);
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1866
1952
|
|
|
1867
1953
|
// src/services/patient/utils/location.utils.ts
|
|
1868
1954
|
var import_firestore7 = require("firebase/firestore");
|
|
@@ -1944,50 +2030,96 @@ var updateLocationInfoUtil = async (db, patientId, data, requesterId) => {
|
|
|
1944
2030
|
// src/services/patient/utils/medical-stuff.utils.ts
|
|
1945
2031
|
var import_firestore8 = require("firebase/firestore");
|
|
1946
2032
|
var addDoctorUtil = async (db, patientId, doctorRef, assignedBy) => {
|
|
2033
|
+
var _a;
|
|
1947
2034
|
const newDoctor = {
|
|
1948
2035
|
userRef: doctorRef,
|
|
1949
2036
|
assignedAt: import_firestore8.Timestamp.now(),
|
|
1950
2037
|
assignedBy,
|
|
1951
2038
|
isActive: true
|
|
1952
2039
|
};
|
|
1953
|
-
await (0, import_firestore8.updateDoc)(getPatientDocRef(db, patientId), {
|
|
1954
|
-
doctors: (0, import_firestore8.arrayUnion)(newDoctor),
|
|
1955
|
-
updatedAt: (0, import_firestore8.serverTimestamp)()
|
|
1956
|
-
});
|
|
1957
|
-
};
|
|
1958
|
-
var removeDoctorUtil = async (db, patientId, doctorRef) => {
|
|
1959
2040
|
const patientDoc = await (0, import_firestore8.getDoc)(getPatientDocRef(db, patientId));
|
|
1960
2041
|
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
1961
2042
|
const patientData = patientDoc.data();
|
|
1962
|
-
const
|
|
1963
|
-
(
|
|
2043
|
+
const existingDoctorIndex = (_a = patientData.doctors) == null ? void 0 : _a.findIndex(
|
|
2044
|
+
(d) => d.userRef === doctorRef
|
|
1964
2045
|
);
|
|
1965
|
-
|
|
2046
|
+
const updates = {
|
|
2047
|
+
updatedAt: (0, import_firestore8.serverTimestamp)(),
|
|
2048
|
+
doctorIds: (0, import_firestore8.arrayUnion)(doctorRef)
|
|
2049
|
+
};
|
|
2050
|
+
if (existingDoctorIndex !== void 0 && existingDoctorIndex > -1) {
|
|
2051
|
+
const updatedDoctors = [...patientData.doctors];
|
|
2052
|
+
updatedDoctors[existingDoctorIndex] = {
|
|
2053
|
+
...updatedDoctors[existingDoctorIndex],
|
|
2054
|
+
isActive: true,
|
|
2055
|
+
assignedAt: import_firestore8.Timestamp.now(),
|
|
2056
|
+
assignedBy
|
|
2057
|
+
};
|
|
2058
|
+
updates.doctors = updatedDoctors;
|
|
2059
|
+
} else {
|
|
2060
|
+
updates.doctors = (0, import_firestore8.arrayUnion)(newDoctor);
|
|
2061
|
+
}
|
|
2062
|
+
await (0, import_firestore8.updateDoc)(getPatientDocRef(db, patientId), updates);
|
|
2063
|
+
};
|
|
2064
|
+
var removeDoctorUtil = async (db, patientId, doctorRef) => {
|
|
2065
|
+
var _a;
|
|
2066
|
+
const patientDocRef = getPatientDocRef(db, patientId);
|
|
2067
|
+
const patientDoc = await (0, import_firestore8.getDoc)(patientDocRef);
|
|
2068
|
+
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
2069
|
+
const patientData = patientDoc.data();
|
|
2070
|
+
const updatedDoctors = ((_a = patientData.doctors) == null ? void 0 : _a.filter((doctor) => doctor.userRef !== doctorRef)) || [];
|
|
2071
|
+
await (0, import_firestore8.updateDoc)(patientDocRef, {
|
|
1966
2072
|
doctors: updatedDoctors,
|
|
2073
|
+
// Set the filtered array
|
|
2074
|
+
doctorIds: (0, import_firestore8.arrayRemove)(doctorRef),
|
|
2075
|
+
// Remove ID from the denormalized list
|
|
1967
2076
|
updatedAt: (0, import_firestore8.serverTimestamp)()
|
|
1968
2077
|
});
|
|
1969
2078
|
};
|
|
1970
2079
|
var addClinicUtil = async (db, patientId, clinicId, assignedBy) => {
|
|
2080
|
+
var _a;
|
|
1971
2081
|
const newClinic = {
|
|
1972
2082
|
clinicId,
|
|
1973
2083
|
assignedAt: import_firestore8.Timestamp.now(),
|
|
1974
2084
|
assignedBy,
|
|
1975
2085
|
isActive: true
|
|
1976
2086
|
};
|
|
1977
|
-
await (0, import_firestore8.updateDoc)(getPatientDocRef(db, patientId), {
|
|
1978
|
-
clinics: (0, import_firestore8.arrayUnion)(newClinic),
|
|
1979
|
-
updatedAt: (0, import_firestore8.serverTimestamp)()
|
|
1980
|
-
});
|
|
1981
|
-
};
|
|
1982
|
-
var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
1983
2087
|
const patientDoc = await (0, import_firestore8.getDoc)(getPatientDocRef(db, patientId));
|
|
1984
2088
|
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
1985
2089
|
const patientData = patientDoc.data();
|
|
1986
|
-
const
|
|
1987
|
-
(
|
|
2090
|
+
const existingClinicIndex = (_a = patientData.clinics) == null ? void 0 : _a.findIndex(
|
|
2091
|
+
(c) => c.clinicId === clinicId
|
|
1988
2092
|
);
|
|
1989
|
-
|
|
2093
|
+
const updates = {
|
|
2094
|
+
updatedAt: (0, import_firestore8.serverTimestamp)(),
|
|
2095
|
+
clinicIds: (0, import_firestore8.arrayUnion)(clinicId)
|
|
2096
|
+
};
|
|
2097
|
+
if (existingClinicIndex !== void 0 && existingClinicIndex > -1) {
|
|
2098
|
+
const updatedClinics = [...patientData.clinics];
|
|
2099
|
+
updatedClinics[existingClinicIndex] = {
|
|
2100
|
+
...updatedClinics[existingClinicIndex],
|
|
2101
|
+
isActive: true,
|
|
2102
|
+
assignedAt: import_firestore8.Timestamp.now(),
|
|
2103
|
+
assignedBy
|
|
2104
|
+
};
|
|
2105
|
+
updates.clinics = updatedClinics;
|
|
2106
|
+
} else {
|
|
2107
|
+
updates.clinics = (0, import_firestore8.arrayUnion)(newClinic);
|
|
2108
|
+
}
|
|
2109
|
+
await (0, import_firestore8.updateDoc)(getPatientDocRef(db, patientId), updates);
|
|
2110
|
+
};
|
|
2111
|
+
var removeClinicUtil = async (db, patientId, clinicId) => {
|
|
2112
|
+
var _a;
|
|
2113
|
+
const patientDocRef = getPatientDocRef(db, patientId);
|
|
2114
|
+
const patientDoc = await (0, import_firestore8.getDoc)(patientDocRef);
|
|
2115
|
+
if (!patientDoc.exists()) throw new Error("Patient profile not found");
|
|
2116
|
+
const patientData = patientDoc.data();
|
|
2117
|
+
const updatedClinics = ((_a = patientData.clinics) == null ? void 0 : _a.filter((clinic) => clinic.clinicId !== clinicId)) || [];
|
|
2118
|
+
await (0, import_firestore8.updateDoc)(patientDocRef, {
|
|
1990
2119
|
clinics: updatedClinics,
|
|
2120
|
+
// Set the filtered array
|
|
2121
|
+
clinicIds: (0, import_firestore8.arrayRemove)(clinicId),
|
|
2122
|
+
// Remove ID from the denormalized list
|
|
1991
2123
|
updatedAt: (0, import_firestore8.serverTimestamp)()
|
|
1992
2124
|
});
|
|
1993
2125
|
};
|
|
@@ -2048,22 +2180,11 @@ var PatientService = class extends BaseService {
|
|
|
2048
2180
|
// Metode za rad sa medicinskim informacijama
|
|
2049
2181
|
async createMedicalInfo(patientId, data) {
|
|
2050
2182
|
const currentUser = await this.getCurrentUser();
|
|
2051
|
-
await createMedicalInfoUtil(
|
|
2052
|
-
this.db,
|
|
2053
|
-
patientId,
|
|
2054
|
-
data,
|
|
2055
|
-
currentUser.uid,
|
|
2056
|
-
currentUser.roles
|
|
2057
|
-
);
|
|
2183
|
+
await createMedicalInfoUtil(this.db, patientId, data, currentUser.uid, currentUser.roles);
|
|
2058
2184
|
}
|
|
2059
2185
|
async getMedicalInfo(patientId) {
|
|
2060
2186
|
const currentUser = await this.getCurrentUser();
|
|
2061
|
-
return getMedicalInfoUtil(
|
|
2062
|
-
this.db,
|
|
2063
|
-
patientId,
|
|
2064
|
-
currentUser.uid,
|
|
2065
|
-
currentUser.roles
|
|
2066
|
-
);
|
|
2187
|
+
return getMedicalInfoUtil(this.db, patientId, currentUser.uid, currentUser.roles);
|
|
2067
2188
|
}
|
|
2068
2189
|
async getMedicalInfoByUserRef(userRef) {
|
|
2069
2190
|
const profile = await this.getPatientProfileByUserRef(userRef);
|
|
@@ -2095,21 +2216,11 @@ var PatientService = class extends BaseService {
|
|
|
2095
2216
|
}
|
|
2096
2217
|
async updateBlockingCondition(patientId, data) {
|
|
2097
2218
|
const currentUser = await this.getCurrentUser();
|
|
2098
|
-
await updateBlockingConditionUtil(
|
|
2099
|
-
this.db,
|
|
2100
|
-
patientId,
|
|
2101
|
-
data,
|
|
2102
|
-
currentUser.uid
|
|
2103
|
-
);
|
|
2219
|
+
await updateBlockingConditionUtil(this.db, patientId, data, currentUser.uid);
|
|
2104
2220
|
}
|
|
2105
2221
|
async removeBlockingCondition(patientId, conditionIndex) {
|
|
2106
2222
|
const currentUser = await this.getCurrentUser();
|
|
2107
|
-
await removeBlockingConditionUtil(
|
|
2108
|
-
this.db,
|
|
2109
|
-
patientId,
|
|
2110
|
-
conditionIndex,
|
|
2111
|
-
currentUser.uid
|
|
2112
|
-
);
|
|
2223
|
+
await removeBlockingConditionUtil(this.db, patientId, conditionIndex, currentUser.uid);
|
|
2113
2224
|
}
|
|
2114
2225
|
// Metode za rad sa kontraindikacijama
|
|
2115
2226
|
async addContraindication(patientId, data) {
|
|
@@ -2122,12 +2233,7 @@ var PatientService = class extends BaseService {
|
|
|
2122
2233
|
}
|
|
2123
2234
|
async removeContraindication(patientId, contraindicationIndex) {
|
|
2124
2235
|
const currentUser = await this.getCurrentUser();
|
|
2125
|
-
await removeContraindicationUtil(
|
|
2126
|
-
this.db,
|
|
2127
|
-
patientId,
|
|
2128
|
-
contraindicationIndex,
|
|
2129
|
-
currentUser.uid
|
|
2130
|
-
);
|
|
2236
|
+
await removeContraindicationUtil(this.db, patientId, contraindicationIndex, currentUser.uid);
|
|
2131
2237
|
}
|
|
2132
2238
|
// Metode za rad sa medikacijama
|
|
2133
2239
|
async addMedication(patientId, data) {
|
|
@@ -2140,12 +2246,7 @@ var PatientService = class extends BaseService {
|
|
|
2140
2246
|
}
|
|
2141
2247
|
async removeMedication(patientId, medicationIndex) {
|
|
2142
2248
|
const currentUser = await this.getCurrentUser();
|
|
2143
|
-
await removeMedicationUtil(
|
|
2144
|
-
this.db,
|
|
2145
|
-
patientId,
|
|
2146
|
-
medicationIndex,
|
|
2147
|
-
currentUser.uid
|
|
2148
|
-
);
|
|
2249
|
+
await removeMedicationUtil(this.db, patientId, medicationIndex, currentUser.uid);
|
|
2149
2250
|
}
|
|
2150
2251
|
// Pomoćne metode
|
|
2151
2252
|
async addExpoToken(patientId, token) {
|
|
@@ -2176,9 +2277,7 @@ var PatientService = class extends BaseService {
|
|
|
2176
2277
|
if (!this.auth.currentUser) {
|
|
2177
2278
|
throw new Error("No authenticated user");
|
|
2178
2279
|
}
|
|
2179
|
-
const userDoc = await (0, import_firestore9.getDoc)(
|
|
2180
|
-
(0, import_firestore9.doc)(this.db, "users", this.auth.currentUser.uid)
|
|
2181
|
-
);
|
|
2280
|
+
const userDoc = await (0, import_firestore9.getDoc)((0, import_firestore9.doc)(this.db, "users", this.auth.currentUser.uid));
|
|
2182
2281
|
if (!userDoc.exists()) {
|
|
2183
2282
|
throw new Error("User not found");
|
|
2184
2283
|
}
|
|
@@ -2228,6 +2327,35 @@ var PatientService = class extends BaseService {
|
|
|
2228
2327
|
async updatePatientProfileByUserRef(userRef, data) {
|
|
2229
2328
|
return updatePatientProfileByUserRefUtil(this.db, userRef, data);
|
|
2230
2329
|
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Searches for patient profiles based on clinic/practitioner association.
|
|
2332
|
+
* Requires information about the requester for security checks.
|
|
2333
|
+
*
|
|
2334
|
+
* @param {SearchPatientsParams} params - The search criteria (clinicId, practitionerId).
|
|
2335
|
+
* @param {RequesterInfo} requester - Information about the user performing the search (ID, role, associated IDs).
|
|
2336
|
+
* @returns {Promise<PatientProfile[]>} A promise resolving to an array of matching patient profiles.
|
|
2337
|
+
*/
|
|
2338
|
+
async searchPatients(params, requester) {
|
|
2339
|
+
console.log(
|
|
2340
|
+
`[PatientService.searchPatients] Initiating search with params:`,
|
|
2341
|
+
params,
|
|
2342
|
+
`by requester:`,
|
|
2343
|
+
requester
|
|
2344
|
+
);
|
|
2345
|
+
return searchPatientsUtil(this.db, params, requester);
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Gets all patient profiles.
|
|
2349
|
+
*
|
|
2350
|
+
* @param {Object} options - Optional parameters for pagination
|
|
2351
|
+
* @param {number} options.limit - Maximum number of profiles to return
|
|
2352
|
+
* @param {string} options.startAfter - The ID of the document to start after (for pagination)
|
|
2353
|
+
* @returns {Promise<PatientProfile[]>} A promise resolving to an array of all patient profiles.
|
|
2354
|
+
*/
|
|
2355
|
+
async getAllPatients(options) {
|
|
2356
|
+
console.log(`[PatientService.getAllPatients] Fetching patients with options:`, options);
|
|
2357
|
+
return getAllPatientsUtil(this.db, options);
|
|
2358
|
+
}
|
|
2231
2359
|
};
|
|
2232
2360
|
|
|
2233
2361
|
// src/services/clinic/utils/admin.utils.ts
|
|
@@ -2891,7 +3019,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
2891
3019
|
(0, import_firestore11.where)("clinicGroupId", "==", clinicGroupId)
|
|
2892
3020
|
);
|
|
2893
3021
|
const querySnapshot = await (0, import_firestore11.getDocs)(q);
|
|
2894
|
-
return querySnapshot.docs.map((
|
|
3022
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
2895
3023
|
}
|
|
2896
3024
|
async function updateClinicAdmin(db, adminId, data) {
|
|
2897
3025
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -3546,7 +3674,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3546
3674
|
(0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
|
|
3547
3675
|
);
|
|
3548
3676
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3549
|
-
return querySnapshot.docs.map((
|
|
3677
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3550
3678
|
}
|
|
3551
3679
|
/**
|
|
3552
3680
|
* Gets a token by its string value and validates it
|
|
@@ -3629,7 +3757,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3629
3757
|
(0, import_firestore13.where)("status", "==", "active" /* ACTIVE */)
|
|
3630
3758
|
);
|
|
3631
3759
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3632
|
-
return querySnapshot.docs.map((
|
|
3760
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3633
3761
|
}
|
|
3634
3762
|
/**
|
|
3635
3763
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -3641,7 +3769,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3641
3769
|
(0, import_firestore13.where)("isActive", "==", true)
|
|
3642
3770
|
);
|
|
3643
3771
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3644
|
-
return querySnapshot.docs.map((
|
|
3772
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3645
3773
|
}
|
|
3646
3774
|
/**
|
|
3647
3775
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -3653,7 +3781,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3653
3781
|
(0, import_firestore13.where)("status", "==", "draft" /* DRAFT */)
|
|
3654
3782
|
);
|
|
3655
3783
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3656
|
-
return querySnapshot.docs.map((
|
|
3784
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3657
3785
|
}
|
|
3658
3786
|
/**
|
|
3659
3787
|
* Ažurira profil zdravstvenog radnika
|
|
@@ -3962,7 +4090,7 @@ var UserService = class extends BaseService {
|
|
|
3962
4090
|
];
|
|
3963
4091
|
const q = (0, import_firestore14.query)((0, import_firestore14.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
3964
4092
|
const querySnapshot = await (0, import_firestore14.getDocs)(q);
|
|
3965
|
-
const users = querySnapshot.docs.map((
|
|
4093
|
+
const users = querySnapshot.docs.map((doc28) => doc28.data());
|
|
3966
4094
|
return Promise.all(users.map((userData) => userSchema.parse(userData)));
|
|
3967
4095
|
}
|
|
3968
4096
|
/**
|
|
@@ -4326,7 +4454,7 @@ async function getAllActiveGroups(db) {
|
|
|
4326
4454
|
(0, import_firestore15.where)("isActive", "==", true)
|
|
4327
4455
|
);
|
|
4328
4456
|
const querySnapshot = await (0, import_firestore15.getDocs)(q);
|
|
4329
|
-
return querySnapshot.docs.map((
|
|
4457
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
4330
4458
|
}
|
|
4331
4459
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
4332
4460
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -4988,7 +5116,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
4988
5116
|
(0, import_firestore16.where)("isActive", "==", true)
|
|
4989
5117
|
);
|
|
4990
5118
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
4991
|
-
return querySnapshot.docs.map((
|
|
5119
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
4992
5120
|
}
|
|
4993
5121
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
4994
5122
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -5200,7 +5328,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
5200
5328
|
}
|
|
5201
5329
|
const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5202
5330
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5203
|
-
return querySnapshot.docs.map((
|
|
5331
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
5204
5332
|
}
|
|
5205
5333
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
5206
5334
|
return getClinicsByAdmin(
|
|
@@ -5342,8 +5470,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
5342
5470
|
}
|
|
5343
5471
|
const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5344
5472
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5345
|
-
for (const
|
|
5346
|
-
const clinic =
|
|
5473
|
+
for (const doc28 of querySnapshot.docs) {
|
|
5474
|
+
const clinic = doc28.data();
|
|
5347
5475
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
5348
5476
|
[center.latitude, center.longitude],
|
|
5349
5477
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -6275,9 +6403,9 @@ var NotificationService = class extends BaseService {
|
|
|
6275
6403
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6276
6404
|
);
|
|
6277
6405
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6278
|
-
return querySnapshot.docs.map((
|
|
6279
|
-
id:
|
|
6280
|
-
...
|
|
6406
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6407
|
+
id: doc28.id,
|
|
6408
|
+
...doc28.data()
|
|
6281
6409
|
}));
|
|
6282
6410
|
}
|
|
6283
6411
|
/**
|
|
@@ -6291,9 +6419,9 @@ var NotificationService = class extends BaseService {
|
|
|
6291
6419
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6292
6420
|
);
|
|
6293
6421
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6294
|
-
return querySnapshot.docs.map((
|
|
6295
|
-
id:
|
|
6296
|
-
...
|
|
6422
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6423
|
+
id: doc28.id,
|
|
6424
|
+
...doc28.data()
|
|
6297
6425
|
}));
|
|
6298
6426
|
}
|
|
6299
6427
|
/**
|
|
@@ -6365,9 +6493,9 @@ var NotificationService = class extends BaseService {
|
|
|
6365
6493
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6366
6494
|
);
|
|
6367
6495
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6368
|
-
return querySnapshot.docs.map((
|
|
6369
|
-
id:
|
|
6370
|
-
...
|
|
6496
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6497
|
+
id: doc28.id,
|
|
6498
|
+
...doc28.data()
|
|
6371
6499
|
}));
|
|
6372
6500
|
}
|
|
6373
6501
|
/**
|
|
@@ -6380,9 +6508,9 @@ var NotificationService = class extends BaseService {
|
|
|
6380
6508
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6381
6509
|
);
|
|
6382
6510
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6383
|
-
return querySnapshot.docs.map((
|
|
6384
|
-
id:
|
|
6385
|
-
...
|
|
6511
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6512
|
+
id: doc28.id,
|
|
6513
|
+
...doc28.data()
|
|
6386
6514
|
}));
|
|
6387
6515
|
}
|
|
6388
6516
|
};
|
|
@@ -6530,7 +6658,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6530
6658
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6531
6659
|
);
|
|
6532
6660
|
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6533
|
-
return snapshot.docs.map((
|
|
6661
|
+
return snapshot.docs.map((doc28) => doc28.data());
|
|
6534
6662
|
}
|
|
6535
6663
|
/**
|
|
6536
6664
|
* Gets all procedures for a practitioner
|
|
@@ -6544,7 +6672,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6544
6672
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6545
6673
|
);
|
|
6546
6674
|
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6547
|
-
return snapshot.docs.map((
|
|
6675
|
+
return snapshot.docs.map((doc28) => doc28.data());
|
|
6548
6676
|
}
|
|
6549
6677
|
/**
|
|
6550
6678
|
* Updates a procedure
|
|
@@ -6724,9 +6852,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6724
6852
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6725
6853
|
const templates = [];
|
|
6726
6854
|
let lastVisible = null;
|
|
6727
|
-
querySnapshot.forEach((
|
|
6728
|
-
templates.push(
|
|
6729
|
-
lastVisible =
|
|
6855
|
+
querySnapshot.forEach((doc28) => {
|
|
6856
|
+
templates.push(doc28.data());
|
|
6857
|
+
lastVisible = doc28;
|
|
6730
6858
|
});
|
|
6731
6859
|
return {
|
|
6732
6860
|
templates,
|
|
@@ -6754,9 +6882,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6754
6882
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6755
6883
|
const templates = [];
|
|
6756
6884
|
let lastVisible = null;
|
|
6757
|
-
querySnapshot.forEach((
|
|
6758
|
-
templates.push(
|
|
6759
|
-
lastVisible =
|
|
6885
|
+
querySnapshot.forEach((doc28) => {
|
|
6886
|
+
templates.push(doc28.data());
|
|
6887
|
+
lastVisible = doc28;
|
|
6760
6888
|
});
|
|
6761
6889
|
return {
|
|
6762
6890
|
templates,
|
|
@@ -6783,9 +6911,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6783
6911
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6784
6912
|
const templates = [];
|
|
6785
6913
|
let lastVisible = null;
|
|
6786
|
-
querySnapshot.forEach((
|
|
6787
|
-
templates.push(
|
|
6788
|
-
lastVisible =
|
|
6914
|
+
querySnapshot.forEach((doc28) => {
|
|
6915
|
+
templates.push(doc28.data());
|
|
6916
|
+
lastVisible = doc28;
|
|
6789
6917
|
});
|
|
6790
6918
|
return {
|
|
6791
6919
|
templates,
|
|
@@ -6898,9 +7026,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6898
7026
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6899
7027
|
const documents = [];
|
|
6900
7028
|
let lastVisible = null;
|
|
6901
|
-
querySnapshot.forEach((
|
|
6902
|
-
documents.push(
|
|
6903
|
-
lastVisible =
|
|
7029
|
+
querySnapshot.forEach((doc28) => {
|
|
7030
|
+
documents.push(doc28.data());
|
|
7031
|
+
lastVisible = doc28;
|
|
6904
7032
|
});
|
|
6905
7033
|
return {
|
|
6906
7034
|
documents,
|
|
@@ -6927,9 +7055,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6927
7055
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6928
7056
|
const documents = [];
|
|
6929
7057
|
let lastVisible = null;
|
|
6930
|
-
querySnapshot.forEach((
|
|
6931
|
-
documents.push(
|
|
6932
|
-
lastVisible =
|
|
7058
|
+
querySnapshot.forEach((doc28) => {
|
|
7059
|
+
documents.push(doc28.data());
|
|
7060
|
+
lastVisible = doc28;
|
|
6933
7061
|
});
|
|
6934
7062
|
return {
|
|
6935
7063
|
documents,
|
|
@@ -6956,9 +7084,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6956
7084
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6957
7085
|
const documents = [];
|
|
6958
7086
|
let lastVisible = null;
|
|
6959
|
-
querySnapshot.forEach((
|
|
6960
|
-
documents.push(
|
|
6961
|
-
lastVisible =
|
|
7087
|
+
querySnapshot.forEach((doc28) => {
|
|
7088
|
+
documents.push(doc28.data());
|
|
7089
|
+
lastVisible = doc28;
|
|
6962
7090
|
});
|
|
6963
7091
|
return {
|
|
6964
7092
|
documents,
|
|
@@ -6985,9 +7113,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
6985
7113
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
6986
7114
|
const documents = [];
|
|
6987
7115
|
let lastVisible = null;
|
|
6988
|
-
querySnapshot.forEach((
|
|
6989
|
-
documents.push(
|
|
6990
|
-
lastVisible =
|
|
7116
|
+
querySnapshot.forEach((doc28) => {
|
|
7117
|
+
documents.push(doc28.data());
|
|
7118
|
+
lastVisible = doc28;
|
|
6991
7119
|
});
|
|
6992
7120
|
return {
|
|
6993
7121
|
documents,
|
|
@@ -7014,9 +7142,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7014
7142
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7015
7143
|
const documents = [];
|
|
7016
7144
|
let lastVisible = null;
|
|
7017
|
-
querySnapshot.forEach((
|
|
7018
|
-
documents.push(
|
|
7019
|
-
lastVisible =
|
|
7145
|
+
querySnapshot.forEach((doc28) => {
|
|
7146
|
+
documents.push(doc28.data());
|
|
7147
|
+
lastVisible = doc28;
|
|
7020
7148
|
});
|
|
7021
7149
|
return {
|
|
7022
7150
|
documents,
|
|
@@ -7026,7 +7154,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7026
7154
|
};
|
|
7027
7155
|
|
|
7028
7156
|
// src/services/calendar/calendar-refactored.service.ts
|
|
7029
|
-
var
|
|
7157
|
+
var import_firestore33 = require("firebase/firestore");
|
|
7030
7158
|
|
|
7031
7159
|
// src/types/calendar/synced-calendar.types.ts
|
|
7032
7160
|
var SyncedCalendarProvider = /* @__PURE__ */ ((SyncedCalendarProvider3) => {
|
|
@@ -7038,7 +7166,7 @@ var SyncedCalendarProvider = /* @__PURE__ */ ((SyncedCalendarProvider3) => {
|
|
|
7038
7166
|
var SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
|
|
7039
7167
|
|
|
7040
7168
|
// src/services/calendar/calendar-refactored.service.ts
|
|
7041
|
-
var
|
|
7169
|
+
var import_firestore34 = require("firebase/firestore");
|
|
7042
7170
|
|
|
7043
7171
|
// src/validations/calendar.schema.ts
|
|
7044
7172
|
var import_zod18 = require("zod");
|
|
@@ -7446,8 +7574,102 @@ async function updateAppointmentUtil(db, clinicId, practitionerId, patientId, ev
|
|
|
7446
7574
|
return clinicEvent;
|
|
7447
7575
|
}
|
|
7448
7576
|
|
|
7449
|
-
// src/services/calendar/utils/
|
|
7577
|
+
// src/services/calendar/utils/calendar-event.utils.ts
|
|
7450
7578
|
var import_firestore30 = require("firebase/firestore");
|
|
7579
|
+
async function searchCalendarEventsUtil(db, params) {
|
|
7580
|
+
const { searchLocation, entityId, ...filters } = params;
|
|
7581
|
+
let baseCollectionPath;
|
|
7582
|
+
const constraints = [];
|
|
7583
|
+
switch (searchLocation) {
|
|
7584
|
+
case "practitioner" /* PRACTITIONER */:
|
|
7585
|
+
if (!entityId) {
|
|
7586
|
+
throw new Error(
|
|
7587
|
+
"Practitioner ID (entityId) is required when searching practitioner calendar."
|
|
7588
|
+
);
|
|
7589
|
+
}
|
|
7590
|
+
baseCollectionPath = `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
7591
|
+
if (filters.practitionerId && filters.practitionerId !== entityId) {
|
|
7592
|
+
console.warn(
|
|
7593
|
+
`Provided practitionerId filter (${filters.practitionerId}) does not match search entityId (${entityId}). Returning empty results.`
|
|
7594
|
+
);
|
|
7595
|
+
return [];
|
|
7596
|
+
}
|
|
7597
|
+
filters.practitionerId = void 0;
|
|
7598
|
+
break;
|
|
7599
|
+
case "patient" /* PATIENT */:
|
|
7600
|
+
if (!entityId) {
|
|
7601
|
+
throw new Error(
|
|
7602
|
+
"Patient ID (entityId) is required when searching patient calendar."
|
|
7603
|
+
);
|
|
7604
|
+
}
|
|
7605
|
+
baseCollectionPath = `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
7606
|
+
if (filters.patientId && filters.patientId !== entityId) {
|
|
7607
|
+
console.warn(
|
|
7608
|
+
`Provided patientId filter (${filters.patientId}) does not match search entityId (${entityId}). Returning empty results.`
|
|
7609
|
+
);
|
|
7610
|
+
return [];
|
|
7611
|
+
}
|
|
7612
|
+
filters.patientId = void 0;
|
|
7613
|
+
break;
|
|
7614
|
+
case "clinic" /* CLINIC */:
|
|
7615
|
+
if (!entityId) {
|
|
7616
|
+
throw new Error(
|
|
7617
|
+
"Clinic ID (entityId) is required when searching clinic-related events."
|
|
7618
|
+
);
|
|
7619
|
+
}
|
|
7620
|
+
baseCollectionPath = CALENDAR_COLLECTION;
|
|
7621
|
+
constraints.push((0, import_firestore30.where)("clinicBranchId", "==", entityId));
|
|
7622
|
+
if (filters.clinicId && filters.clinicId !== entityId) {
|
|
7623
|
+
console.warn(
|
|
7624
|
+
`Provided clinicId filter (${filters.clinicId}) does not match search entityId (${entityId}). Returning empty results.`
|
|
7625
|
+
);
|
|
7626
|
+
return [];
|
|
7627
|
+
}
|
|
7628
|
+
filters.clinicId = void 0;
|
|
7629
|
+
break;
|
|
7630
|
+
default:
|
|
7631
|
+
throw new Error(`Invalid search location: ${searchLocation}`);
|
|
7632
|
+
}
|
|
7633
|
+
const collectionRef = (0, import_firestore30.collection)(db, baseCollectionPath);
|
|
7634
|
+
if (filters.clinicId) {
|
|
7635
|
+
constraints.push((0, import_firestore30.where)("clinicBranchId", "==", filters.clinicId));
|
|
7636
|
+
}
|
|
7637
|
+
if (filters.practitionerId) {
|
|
7638
|
+
constraints.push(
|
|
7639
|
+
(0, import_firestore30.where)("practitionerProfileId", "==", filters.practitionerId)
|
|
7640
|
+
);
|
|
7641
|
+
}
|
|
7642
|
+
if (filters.patientId) {
|
|
7643
|
+
constraints.push((0, import_firestore30.where)("patientProfileId", "==", filters.patientId));
|
|
7644
|
+
}
|
|
7645
|
+
if (filters.procedureId) {
|
|
7646
|
+
constraints.push((0, import_firestore30.where)("procedureId", "==", filters.procedureId));
|
|
7647
|
+
}
|
|
7648
|
+
if (filters.eventStatus) {
|
|
7649
|
+
constraints.push((0, import_firestore30.where)("status", "==", filters.eventStatus));
|
|
7650
|
+
}
|
|
7651
|
+
if (filters.eventType) {
|
|
7652
|
+
constraints.push((0, import_firestore30.where)("eventType", "==", filters.eventType));
|
|
7653
|
+
}
|
|
7654
|
+
if (filters.dateRange) {
|
|
7655
|
+
constraints.push((0, import_firestore30.where)("eventTime.start", ">=", filters.dateRange.start));
|
|
7656
|
+
constraints.push((0, import_firestore30.where)("eventTime.start", "<=", filters.dateRange.end));
|
|
7657
|
+
}
|
|
7658
|
+
try {
|
|
7659
|
+
const finalQuery = (0, import_firestore30.query)(collectionRef, ...constraints);
|
|
7660
|
+
const querySnapshot = await (0, import_firestore30.getDocs)(finalQuery);
|
|
7661
|
+
const events = querySnapshot.docs.map(
|
|
7662
|
+
(doc28) => ({ id: doc28.id, ...doc28.data() })
|
|
7663
|
+
);
|
|
7664
|
+
return events;
|
|
7665
|
+
} catch (error) {
|
|
7666
|
+
console.error("Error searching calendar events:", error);
|
|
7667
|
+
return [];
|
|
7668
|
+
}
|
|
7669
|
+
}
|
|
7670
|
+
|
|
7671
|
+
// src/services/calendar/utils/synced-calendar.utils.ts
|
|
7672
|
+
var import_firestore31 = require("firebase/firestore");
|
|
7451
7673
|
async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendarData, generateId2) {
|
|
7452
7674
|
const calendarId = generateId2();
|
|
7453
7675
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -7458,14 +7680,14 @@ async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
7458
7680
|
const newCalendar = {
|
|
7459
7681
|
id: calendarId,
|
|
7460
7682
|
...calendarData,
|
|
7461
|
-
createdAt: (0,
|
|
7462
|
-
updatedAt: (0,
|
|
7683
|
+
createdAt: (0, import_firestore31.serverTimestamp)(),
|
|
7684
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
7463
7685
|
};
|
|
7464
|
-
await (0,
|
|
7686
|
+
await (0, import_firestore31.setDoc)(calendarRef, newCalendar);
|
|
7465
7687
|
return {
|
|
7466
7688
|
...newCalendar,
|
|
7467
|
-
createdAt:
|
|
7468
|
-
updatedAt:
|
|
7689
|
+
createdAt: import_firestore31.Timestamp.now(),
|
|
7690
|
+
updatedAt: import_firestore31.Timestamp.now()
|
|
7469
7691
|
};
|
|
7470
7692
|
}
|
|
7471
7693
|
async function createPatientSyncedCalendarUtil(db, patientId, calendarData, generateId2) {
|
|
@@ -7474,14 +7696,14 @@ async function createPatientSyncedCalendarUtil(db, patientId, calendarData, gene
|
|
|
7474
7696
|
const newCalendar = {
|
|
7475
7697
|
id: calendarId,
|
|
7476
7698
|
...calendarData,
|
|
7477
|
-
createdAt: (0,
|
|
7478
|
-
updatedAt: (0,
|
|
7699
|
+
createdAt: (0, import_firestore31.serverTimestamp)(),
|
|
7700
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
7479
7701
|
};
|
|
7480
|
-
await (0,
|
|
7702
|
+
await (0, import_firestore31.setDoc)(calendarRef, newCalendar);
|
|
7481
7703
|
return {
|
|
7482
7704
|
...newCalendar,
|
|
7483
|
-
createdAt:
|
|
7484
|
-
updatedAt:
|
|
7705
|
+
createdAt: import_firestore31.Timestamp.now(),
|
|
7706
|
+
updatedAt: import_firestore31.Timestamp.now()
|
|
7485
7707
|
};
|
|
7486
7708
|
}
|
|
7487
7709
|
async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, generateId2) {
|
|
@@ -7490,14 +7712,14 @@ async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, genera
|
|
|
7490
7712
|
const newCalendar = {
|
|
7491
7713
|
id: calendarId,
|
|
7492
7714
|
...calendarData,
|
|
7493
|
-
createdAt: (0,
|
|
7494
|
-
updatedAt: (0,
|
|
7715
|
+
createdAt: (0, import_firestore31.serverTimestamp)(),
|
|
7716
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
7495
7717
|
};
|
|
7496
|
-
await (0,
|
|
7718
|
+
await (0, import_firestore31.setDoc)(calendarRef, newCalendar);
|
|
7497
7719
|
return {
|
|
7498
7720
|
...newCalendar,
|
|
7499
|
-
createdAt:
|
|
7500
|
-
updatedAt:
|
|
7721
|
+
createdAt: import_firestore31.Timestamp.now(),
|
|
7722
|
+
updatedAt: import_firestore31.Timestamp.now()
|
|
7501
7723
|
};
|
|
7502
7724
|
}
|
|
7503
7725
|
async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId) {
|
|
@@ -7506,54 +7728,54 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
|
|
|
7506
7728
|
practitionerId,
|
|
7507
7729
|
calendarId
|
|
7508
7730
|
);
|
|
7509
|
-
const calendarDoc = await (0,
|
|
7731
|
+
const calendarDoc = await (0, import_firestore31.getDoc)(calendarRef);
|
|
7510
7732
|
if (!calendarDoc.exists()) {
|
|
7511
7733
|
return null;
|
|
7512
7734
|
}
|
|
7513
7735
|
return calendarDoc.data();
|
|
7514
7736
|
}
|
|
7515
7737
|
async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
7516
|
-
const calendarsRef = (0,
|
|
7738
|
+
const calendarsRef = (0, import_firestore31.collection)(
|
|
7517
7739
|
db,
|
|
7518
7740
|
`practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
7519
7741
|
);
|
|
7520
|
-
const q = (0,
|
|
7521
|
-
const querySnapshot = await (0,
|
|
7522
|
-
return querySnapshot.docs.map((
|
|
7742
|
+
const q = (0, import_firestore31.query)(calendarsRef, (0, import_firestore31.orderBy)("createdAt", "desc"));
|
|
7743
|
+
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
7744
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
7523
7745
|
}
|
|
7524
7746
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
7525
7747
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
7526
|
-
const calendarDoc = await (0,
|
|
7748
|
+
const calendarDoc = await (0, import_firestore31.getDoc)(calendarRef);
|
|
7527
7749
|
if (!calendarDoc.exists()) {
|
|
7528
7750
|
return null;
|
|
7529
7751
|
}
|
|
7530
7752
|
return calendarDoc.data();
|
|
7531
7753
|
}
|
|
7532
7754
|
async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
7533
|
-
const calendarsRef = (0,
|
|
7755
|
+
const calendarsRef = (0, import_firestore31.collection)(
|
|
7534
7756
|
db,
|
|
7535
7757
|
`patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
7536
7758
|
);
|
|
7537
|
-
const q = (0,
|
|
7538
|
-
const querySnapshot = await (0,
|
|
7539
|
-
return querySnapshot.docs.map((
|
|
7759
|
+
const q = (0, import_firestore31.query)(calendarsRef, (0, import_firestore31.orderBy)("createdAt", "desc"));
|
|
7760
|
+
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
7761
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
7540
7762
|
}
|
|
7541
7763
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
7542
7764
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
7543
|
-
const calendarDoc = await (0,
|
|
7765
|
+
const calendarDoc = await (0, import_firestore31.getDoc)(calendarRef);
|
|
7544
7766
|
if (!calendarDoc.exists()) {
|
|
7545
7767
|
return null;
|
|
7546
7768
|
}
|
|
7547
7769
|
return calendarDoc.data();
|
|
7548
7770
|
}
|
|
7549
7771
|
async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
7550
|
-
const calendarsRef = (0,
|
|
7772
|
+
const calendarsRef = (0, import_firestore31.collection)(
|
|
7551
7773
|
db,
|
|
7552
7774
|
`clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
7553
7775
|
);
|
|
7554
|
-
const q = (0,
|
|
7555
|
-
const querySnapshot = await (0,
|
|
7556
|
-
return querySnapshot.docs.map((
|
|
7776
|
+
const q = (0, import_firestore31.query)(calendarsRef, (0, import_firestore31.orderBy)("createdAt", "desc"));
|
|
7777
|
+
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
7778
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
7557
7779
|
}
|
|
7558
7780
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
7559
7781
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -7563,10 +7785,10 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
7563
7785
|
);
|
|
7564
7786
|
const updates = {
|
|
7565
7787
|
...updateData,
|
|
7566
|
-
updatedAt: (0,
|
|
7788
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
7567
7789
|
};
|
|
7568
|
-
await (0,
|
|
7569
|
-
const updatedDoc = await (0,
|
|
7790
|
+
await (0, import_firestore31.updateDoc)(calendarRef, updates);
|
|
7791
|
+
const updatedDoc = await (0, import_firestore31.getDoc)(calendarRef);
|
|
7570
7792
|
if (!updatedDoc.exists()) {
|
|
7571
7793
|
throw new Error("Synced calendar not found after update");
|
|
7572
7794
|
}
|
|
@@ -7576,10 +7798,10 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
|
|
|
7576
7798
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
7577
7799
|
const updates = {
|
|
7578
7800
|
...updateData,
|
|
7579
|
-
updatedAt: (0,
|
|
7801
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
7580
7802
|
};
|
|
7581
|
-
await (0,
|
|
7582
|
-
const updatedDoc = await (0,
|
|
7803
|
+
await (0, import_firestore31.updateDoc)(calendarRef, updates);
|
|
7804
|
+
const updatedDoc = await (0, import_firestore31.getDoc)(calendarRef);
|
|
7583
7805
|
if (!updatedDoc.exists()) {
|
|
7584
7806
|
throw new Error("Synced calendar not found after update");
|
|
7585
7807
|
}
|
|
@@ -7589,10 +7811,10 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
|
|
|
7589
7811
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
7590
7812
|
const updates = {
|
|
7591
7813
|
...updateData,
|
|
7592
|
-
updatedAt: (0,
|
|
7814
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
7593
7815
|
};
|
|
7594
|
-
await (0,
|
|
7595
|
-
const updatedDoc = await (0,
|
|
7816
|
+
await (0, import_firestore31.updateDoc)(calendarRef, updates);
|
|
7817
|
+
const updatedDoc = await (0, import_firestore31.getDoc)(calendarRef);
|
|
7596
7818
|
if (!updatedDoc.exists()) {
|
|
7597
7819
|
throw new Error("Synced calendar not found after update");
|
|
7598
7820
|
}
|
|
@@ -7604,19 +7826,19 @@ async function deletePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
7604
7826
|
practitionerId,
|
|
7605
7827
|
calendarId
|
|
7606
7828
|
);
|
|
7607
|
-
await (0,
|
|
7829
|
+
await (0, import_firestore31.deleteDoc)(calendarRef);
|
|
7608
7830
|
}
|
|
7609
7831
|
async function deletePatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
7610
7832
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
7611
|
-
await (0,
|
|
7833
|
+
await (0, import_firestore31.deleteDoc)(calendarRef);
|
|
7612
7834
|
}
|
|
7613
7835
|
async function deleteClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
7614
7836
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
7615
|
-
await (0,
|
|
7837
|
+
await (0, import_firestore31.deleteDoc)(calendarRef);
|
|
7616
7838
|
}
|
|
7617
7839
|
async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarId) {
|
|
7618
7840
|
const updateData = {
|
|
7619
|
-
lastSyncedAt:
|
|
7841
|
+
lastSyncedAt: import_firestore31.Timestamp.now()
|
|
7620
7842
|
};
|
|
7621
7843
|
switch (entityType) {
|
|
7622
7844
|
case "practitioner":
|
|
@@ -7646,7 +7868,7 @@ async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarI
|
|
|
7646
7868
|
}
|
|
7647
7869
|
|
|
7648
7870
|
// src/services/calendar/utils/google-calendar.utils.ts
|
|
7649
|
-
var
|
|
7871
|
+
var import_firestore32 = require("firebase/firestore");
|
|
7650
7872
|
var GOOGLE_CALENDAR_API_URL = "https://www.googleapis.com/calendar/v3";
|
|
7651
7873
|
var GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token";
|
|
7652
7874
|
var CLIENT_ID = "your-client-id";
|
|
@@ -7766,7 +7988,7 @@ async function ensureValidToken(db, entityType, entityId, syncedCalendar) {
|
|
|
7766
7988
|
tokenExpiry.setSeconds(tokenExpiry.getSeconds() + expiresIn);
|
|
7767
7989
|
const updateData = {
|
|
7768
7990
|
accessToken,
|
|
7769
|
-
tokenExpiry:
|
|
7991
|
+
tokenExpiry: import_firestore32.Timestamp.fromDate(tokenExpiry)
|
|
7770
7992
|
};
|
|
7771
7993
|
switch (entityType) {
|
|
7772
7994
|
case "practitioner":
|
|
@@ -7941,8 +8163,8 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
|
|
|
7941
8163
|
eventName: googleEvent.summary || "External Event",
|
|
7942
8164
|
eventLocation: googleEvent.location,
|
|
7943
8165
|
eventTime: {
|
|
7944
|
-
start:
|
|
7945
|
-
end:
|
|
8166
|
+
start: import_firestore32.Timestamp.fromDate(start),
|
|
8167
|
+
end: import_firestore32.Timestamp.fromDate(end)
|
|
7946
8168
|
},
|
|
7947
8169
|
description: googleEvent.description || "",
|
|
7948
8170
|
// External events are always set as CONFIRMED - status updates will happen externally
|
|
@@ -7956,7 +8178,7 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
|
|
|
7956
8178
|
{
|
|
7957
8179
|
eventId: googleEvent.id,
|
|
7958
8180
|
syncedCalendarProvider: "google" /* GOOGLE */,
|
|
7959
|
-
syncedAt:
|
|
8181
|
+
syncedAt: import_firestore32.Timestamp.now()
|
|
7960
8182
|
}
|
|
7961
8183
|
]
|
|
7962
8184
|
};
|
|
@@ -8734,7 +8956,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
8734
8956
|
return 0;
|
|
8735
8957
|
}
|
|
8736
8958
|
let importedEventsCount = 0;
|
|
8737
|
-
const currentTime =
|
|
8959
|
+
const currentTime = import_firestore33.Timestamp.now();
|
|
8738
8960
|
for (const calendar of activeCalendars) {
|
|
8739
8961
|
try {
|
|
8740
8962
|
let externalEvents = [];
|
|
@@ -8801,7 +9023,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
8801
9023
|
async createDoctorBlockingEvent(doctorId, eventData) {
|
|
8802
9024
|
try {
|
|
8803
9025
|
const eventId = this.generateId();
|
|
8804
|
-
const eventRef = (0,
|
|
9026
|
+
const eventRef = (0, import_firestore34.doc)(
|
|
8805
9027
|
this.db,
|
|
8806
9028
|
PRACTITIONERS_COLLECTION,
|
|
8807
9029
|
doctorId,
|
|
@@ -8811,14 +9033,14 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
8811
9033
|
const newEvent = {
|
|
8812
9034
|
id: eventId,
|
|
8813
9035
|
...eventData,
|
|
8814
|
-
createdAt: (0,
|
|
8815
|
-
updatedAt: (0,
|
|
9036
|
+
createdAt: (0, import_firestore33.serverTimestamp)(),
|
|
9037
|
+
updatedAt: (0, import_firestore33.serverTimestamp)()
|
|
8816
9038
|
};
|
|
8817
|
-
await (0,
|
|
9039
|
+
await (0, import_firestore34.setDoc)(eventRef, newEvent);
|
|
8818
9040
|
return {
|
|
8819
9041
|
...newEvent,
|
|
8820
|
-
createdAt:
|
|
8821
|
-
updatedAt:
|
|
9042
|
+
createdAt: import_firestore33.Timestamp.now(),
|
|
9043
|
+
updatedAt: import_firestore33.Timestamp.now()
|
|
8822
9044
|
};
|
|
8823
9045
|
} catch (error) {
|
|
8824
9046
|
console.error(
|
|
@@ -8836,8 +9058,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
8836
9058
|
*/
|
|
8837
9059
|
async synchronizeExternalCalendars(lookbackDays = 7, lookforwardDays = 30) {
|
|
8838
9060
|
try {
|
|
8839
|
-
const practitionersRef = (0,
|
|
8840
|
-
const practitionersSnapshot = await (0,
|
|
9061
|
+
const practitionersRef = (0, import_firestore34.collection)(this.db, PRACTITIONERS_COLLECTION);
|
|
9062
|
+
const practitionersSnapshot = await (0, import_firestore34.getDocs)(practitionersRef);
|
|
8841
9063
|
const startDate = /* @__PURE__ */ new Date();
|
|
8842
9064
|
startDate.setDate(startDate.getDate() - lookbackDays);
|
|
8843
9065
|
const endDate = /* @__PURE__ */ new Date();
|
|
@@ -8895,22 +9117,22 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
8895
9117
|
async updateExistingEventsFromExternalCalendars(doctorId, startDate, endDate) {
|
|
8896
9118
|
var _a;
|
|
8897
9119
|
try {
|
|
8898
|
-
const eventsRef = (0,
|
|
9120
|
+
const eventsRef = (0, import_firestore34.collection)(
|
|
8899
9121
|
this.db,
|
|
8900
9122
|
PRACTITIONERS_COLLECTION,
|
|
8901
9123
|
doctorId,
|
|
8902
9124
|
CALENDAR_COLLECTION
|
|
8903
9125
|
);
|
|
8904
|
-
const q = (0,
|
|
9126
|
+
const q = (0, import_firestore34.query)(
|
|
8905
9127
|
eventsRef,
|
|
8906
|
-
(0,
|
|
8907
|
-
(0,
|
|
8908
|
-
(0,
|
|
9128
|
+
(0, import_firestore34.where)("syncStatus", "==", "external" /* EXTERNAL */),
|
|
9129
|
+
(0, import_firestore34.where)("eventTime.start", ">=", import_firestore33.Timestamp.fromDate(startDate)),
|
|
9130
|
+
(0, import_firestore34.where)("eventTime.start", "<=", import_firestore33.Timestamp.fromDate(endDate))
|
|
8909
9131
|
);
|
|
8910
|
-
const eventsSnapshot = await (0,
|
|
8911
|
-
const events = eventsSnapshot.docs.map((
|
|
8912
|
-
id:
|
|
8913
|
-
...
|
|
9132
|
+
const eventsSnapshot = await (0, import_firestore34.getDocs)(q);
|
|
9133
|
+
const events = eventsSnapshot.docs.map((doc28) => ({
|
|
9134
|
+
id: doc28.id,
|
|
9135
|
+
...doc28.data()
|
|
8914
9136
|
}));
|
|
8915
9137
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
8916
9138
|
doctorId
|
|
@@ -9014,21 +9236,21 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9014
9236
|
const endTime = new Date(
|
|
9015
9237
|
externalEvent.end.dateTime || externalEvent.end.date
|
|
9016
9238
|
);
|
|
9017
|
-
const eventRef = (0,
|
|
9239
|
+
const eventRef = (0, import_firestore34.doc)(
|
|
9018
9240
|
this.db,
|
|
9019
9241
|
PRACTITIONERS_COLLECTION,
|
|
9020
9242
|
doctorId,
|
|
9021
9243
|
CALENDAR_COLLECTION,
|
|
9022
9244
|
eventId
|
|
9023
9245
|
);
|
|
9024
|
-
await (0,
|
|
9246
|
+
await (0, import_firestore34.updateDoc)(eventRef, {
|
|
9025
9247
|
eventName: externalEvent.summary || "External Event",
|
|
9026
9248
|
eventTime: {
|
|
9027
|
-
start:
|
|
9028
|
-
end:
|
|
9249
|
+
start: import_firestore33.Timestamp.fromDate(startTime),
|
|
9250
|
+
end: import_firestore33.Timestamp.fromDate(endTime)
|
|
9029
9251
|
},
|
|
9030
9252
|
description: externalEvent.description || "",
|
|
9031
|
-
updatedAt: (0,
|
|
9253
|
+
updatedAt: (0, import_firestore33.serverTimestamp)()
|
|
9032
9254
|
});
|
|
9033
9255
|
console.log(`Updated local event ${eventId} from external event`);
|
|
9034
9256
|
} catch (error) {
|
|
@@ -9046,16 +9268,16 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9046
9268
|
*/
|
|
9047
9269
|
async updateEventStatus(doctorId, eventId, status) {
|
|
9048
9270
|
try {
|
|
9049
|
-
const eventRef = (0,
|
|
9271
|
+
const eventRef = (0, import_firestore34.doc)(
|
|
9050
9272
|
this.db,
|
|
9051
9273
|
PRACTITIONERS_COLLECTION,
|
|
9052
9274
|
doctorId,
|
|
9053
9275
|
CALENDAR_COLLECTION,
|
|
9054
9276
|
eventId
|
|
9055
9277
|
);
|
|
9056
|
-
await (0,
|
|
9278
|
+
await (0, import_firestore34.updateDoc)(eventRef, {
|
|
9057
9279
|
status,
|
|
9058
|
-
updatedAt: (0,
|
|
9280
|
+
updatedAt: (0, import_firestore33.serverTimestamp)()
|
|
9059
9281
|
});
|
|
9060
9282
|
console.log(`Updated event ${eventId} status to ${status}`);
|
|
9061
9283
|
} catch (error) {
|
|
@@ -9073,6 +9295,102 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9073
9295
|
`Setting up scheduled calendar sync job every ${interval} hours`
|
|
9074
9296
|
);
|
|
9075
9297
|
}
|
|
9298
|
+
/**
|
|
9299
|
+
* Searches for calendar events based on specified criteria.
|
|
9300
|
+
*
|
|
9301
|
+
* @param {SearchCalendarEventsParams} params - The search parameters.
|
|
9302
|
+
* @param {SearchLocationEnum} params.searchLocation - The primary location to search (practitioner, patient, or clinic).
|
|
9303
|
+
* @param {string} params.entityId - The ID of the entity (practitioner, patient, or clinic) to search within/for.
|
|
9304
|
+
* @param {string} [params.clinicId] - Optional clinic ID to filter by.
|
|
9305
|
+
* @param {string} [params.practitionerId] - Optional practitioner ID to filter by.
|
|
9306
|
+
* @param {string} [params.patientId] - Optional patient ID to filter by.
|
|
9307
|
+
* @param {string} [params.procedureId] - Optional procedure ID to filter by.
|
|
9308
|
+
* @param {DateRange} [params.dateRange] - Optional date range to filter by (event start time).
|
|
9309
|
+
* @param {CalendarEventStatus} [params.eventStatus] - Optional event status to filter by.
|
|
9310
|
+
* @param {CalendarEventType} [params.eventType] - Optional event type to filter by.
|
|
9311
|
+
* @returns {Promise<CalendarEvent[]>} A promise that resolves to an array of matching calendar events.
|
|
9312
|
+
* @throws {Error} If the search location requires an entity ID that is not provided.
|
|
9313
|
+
*/
|
|
9314
|
+
async searchCalendarEvents(params) {
|
|
9315
|
+
return searchCalendarEventsUtil(this.db, params);
|
|
9316
|
+
}
|
|
9317
|
+
/**
|
|
9318
|
+
* Gets a doctor's upcoming appointments for a specific date range
|
|
9319
|
+
*
|
|
9320
|
+
* @param {string} doctorId - ID of the practitioner
|
|
9321
|
+
* @param {Date} startDate - Start date of the range
|
|
9322
|
+
* @param {Date} endDate - End date of the range
|
|
9323
|
+
* @param {CalendarEventStatus} [status] - Optional status filter (defaults to CONFIRMED)
|
|
9324
|
+
* @returns {Promise<CalendarEvent[]>} A promise that resolves to an array of appointments
|
|
9325
|
+
*/
|
|
9326
|
+
async getPractitionerUpcomingAppointments(doctorId, startDate, endDate, status = "confirmed" /* CONFIRMED */) {
|
|
9327
|
+
const dateRange = {
|
|
9328
|
+
start: import_firestore33.Timestamp.fromDate(startDate),
|
|
9329
|
+
end: import_firestore33.Timestamp.fromDate(endDate)
|
|
9330
|
+
};
|
|
9331
|
+
const searchParams = {
|
|
9332
|
+
searchLocation: "practitioner" /* PRACTITIONER */,
|
|
9333
|
+
entityId: doctorId,
|
|
9334
|
+
dateRange,
|
|
9335
|
+
eventStatus: status,
|
|
9336
|
+
eventType: "appointment" /* APPOINTMENT */
|
|
9337
|
+
};
|
|
9338
|
+
return this.searchCalendarEvents(searchParams);
|
|
9339
|
+
}
|
|
9340
|
+
/**
|
|
9341
|
+
* Gets a patient's appointments for a specific date range
|
|
9342
|
+
*
|
|
9343
|
+
* @param {string} patientId - ID of the patient
|
|
9344
|
+
* @param {Date} startDate - Start date of the range
|
|
9345
|
+
* @param {Date} endDate - End date of the range
|
|
9346
|
+
* @param {CalendarEventStatus} [status] - Optional status filter (defaults to all non-canceled appointments)
|
|
9347
|
+
* @returns {Promise<CalendarEvent[]>} A promise that resolves to an array of appointments
|
|
9348
|
+
*/
|
|
9349
|
+
async getPatientAppointments(patientId, startDate, endDate, status) {
|
|
9350
|
+
const dateRange = {
|
|
9351
|
+
start: import_firestore33.Timestamp.fromDate(startDate),
|
|
9352
|
+
end: import_firestore33.Timestamp.fromDate(endDate)
|
|
9353
|
+
};
|
|
9354
|
+
const searchParams = {
|
|
9355
|
+
searchLocation: "patient" /* PATIENT */,
|
|
9356
|
+
entityId: patientId,
|
|
9357
|
+
dateRange,
|
|
9358
|
+
eventType: "appointment" /* APPOINTMENT */
|
|
9359
|
+
};
|
|
9360
|
+
if (status) {
|
|
9361
|
+
searchParams.eventStatus = status;
|
|
9362
|
+
}
|
|
9363
|
+
return this.searchCalendarEvents(searchParams);
|
|
9364
|
+
}
|
|
9365
|
+
/**
|
|
9366
|
+
* Gets all appointments for a clinic within a specific date range
|
|
9367
|
+
*
|
|
9368
|
+
* @param {string} clinicId - ID of the clinic
|
|
9369
|
+
* @param {Date} startDate - Start date of the range
|
|
9370
|
+
* @param {Date} endDate - End date of the range
|
|
9371
|
+
* @param {string} [doctorId] - Optional doctor ID to filter by
|
|
9372
|
+
* @param {CalendarEventStatus} [status] - Optional status filter
|
|
9373
|
+
* @returns {Promise<CalendarEvent[]>} A promise that resolves to an array of appointments
|
|
9374
|
+
*/
|
|
9375
|
+
async getClinicAppointments(clinicId, startDate, endDate, doctorId, status) {
|
|
9376
|
+
const dateRange = {
|
|
9377
|
+
start: import_firestore33.Timestamp.fromDate(startDate),
|
|
9378
|
+
end: import_firestore33.Timestamp.fromDate(endDate)
|
|
9379
|
+
};
|
|
9380
|
+
const searchParams = {
|
|
9381
|
+
searchLocation: "clinic" /* CLINIC */,
|
|
9382
|
+
entityId: clinicId,
|
|
9383
|
+
dateRange,
|
|
9384
|
+
eventType: "appointment" /* APPOINTMENT */
|
|
9385
|
+
};
|
|
9386
|
+
if (doctorId) {
|
|
9387
|
+
searchParams.practitionerId = doctorId;
|
|
9388
|
+
}
|
|
9389
|
+
if (status) {
|
|
9390
|
+
searchParams.eventStatus = status;
|
|
9391
|
+
}
|
|
9392
|
+
return this.searchCalendarEvents(searchParams);
|
|
9393
|
+
}
|
|
9076
9394
|
// #endregion
|
|
9077
9395
|
// #region Private Helper Methods
|
|
9078
9396
|
/**
|
|
@@ -9116,8 +9434,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9116
9434
|
const startDate = eventTime.start.toDate();
|
|
9117
9435
|
const startTime = startDate;
|
|
9118
9436
|
const endTime = eventTime.end.toDate();
|
|
9119
|
-
const practitionerRef = (0,
|
|
9120
|
-
const practitionerDoc = await (0,
|
|
9437
|
+
const practitionerRef = (0, import_firestore34.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
|
|
9438
|
+
const practitionerDoc = await (0, import_firestore34.getDoc)(practitionerRef);
|
|
9121
9439
|
if (!practitionerDoc.exists()) {
|
|
9122
9440
|
throw new Error(`Doctor with ID ${doctorId} not found`);
|
|
9123
9441
|
}
|
|
@@ -9174,8 +9492,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9174
9492
|
* @returns Updated calendar event
|
|
9175
9493
|
*/
|
|
9176
9494
|
async updateAppointmentStatus(appointmentId, clinicId, status) {
|
|
9177
|
-
const appointmentRef = (0,
|
|
9178
|
-
const appointmentDoc = await (0,
|
|
9495
|
+
const appointmentRef = (0, import_firestore34.doc)(this.db, CALENDAR_COLLECTION, appointmentId);
|
|
9496
|
+
const appointmentDoc = await (0, import_firestore34.getDoc)(appointmentRef);
|
|
9179
9497
|
if (!appointmentDoc.exists()) {
|
|
9180
9498
|
throw new Error(`Appointment with ID ${appointmentId} not found`);
|
|
9181
9499
|
}
|
|
@@ -9306,7 +9624,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9306
9624
|
const newSyncEvent = {
|
|
9307
9625
|
eventId: result.eventIds[0],
|
|
9308
9626
|
syncedCalendarProvider: calendar.provider,
|
|
9309
|
-
syncedAt:
|
|
9627
|
+
syncedAt: import_firestore33.Timestamp.now()
|
|
9310
9628
|
};
|
|
9311
9629
|
await this.updateEventWithSyncId(
|
|
9312
9630
|
entityType === "doctor" ? appointment.practitionerProfileId : appointment.patientProfileId,
|
|
@@ -9330,8 +9648,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9330
9648
|
async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
|
|
9331
9649
|
try {
|
|
9332
9650
|
const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
9333
|
-
const eventRef = (0,
|
|
9334
|
-
const eventDoc = await (0,
|
|
9651
|
+
const eventRef = (0, import_firestore34.doc)(this.db, collectionPath, eventId);
|
|
9652
|
+
const eventDoc = await (0, import_firestore34.getDoc)(eventRef);
|
|
9335
9653
|
if (eventDoc.exists()) {
|
|
9336
9654
|
const event = eventDoc.data();
|
|
9337
9655
|
const syncIds = [...event.syncedCalendarEventId || []];
|
|
@@ -9343,9 +9661,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9343
9661
|
} else {
|
|
9344
9662
|
syncIds.push(syncEvent);
|
|
9345
9663
|
}
|
|
9346
|
-
await (0,
|
|
9664
|
+
await (0, import_firestore34.updateDoc)(eventRef, {
|
|
9347
9665
|
syncedCalendarEventId: syncIds,
|
|
9348
|
-
updatedAt: (0,
|
|
9666
|
+
updatedAt: (0, import_firestore33.serverTimestamp)()
|
|
9349
9667
|
});
|
|
9350
9668
|
console.log(
|
|
9351
9669
|
`Updated event ${eventId} with sync ID ${syncEvent.eventId}`
|
|
@@ -9369,8 +9687,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9369
9687
|
* @returns Working hours for the clinic
|
|
9370
9688
|
*/
|
|
9371
9689
|
async getClinicWorkingHours(clinicId, date) {
|
|
9372
|
-
const clinicRef = (0,
|
|
9373
|
-
const clinicDoc = await (0,
|
|
9690
|
+
const clinicRef = (0, import_firestore34.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
9691
|
+
const clinicDoc = await (0, import_firestore34.getDoc)(clinicRef);
|
|
9374
9692
|
if (!clinicDoc.exists()) {
|
|
9375
9693
|
throw new Error(`Clinic with ID ${clinicId} not found`);
|
|
9376
9694
|
}
|
|
@@ -9398,8 +9716,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9398
9716
|
* @returns Doctor's schedule
|
|
9399
9717
|
*/
|
|
9400
9718
|
async getDoctorSchedule(doctorId, date) {
|
|
9401
|
-
const practitionerRef = (0,
|
|
9402
|
-
const practitionerDoc = await (0,
|
|
9719
|
+
const practitionerRef = (0, import_firestore34.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
|
|
9720
|
+
const practitionerDoc = await (0, import_firestore34.getDoc)(practitionerRef);
|
|
9403
9721
|
if (!practitionerDoc.exists()) {
|
|
9404
9722
|
throw new Error(`Doctor with ID ${doctorId} not found`);
|
|
9405
9723
|
}
|
|
@@ -9431,19 +9749,19 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9431
9749
|
startOfDay.setHours(0, 0, 0, 0);
|
|
9432
9750
|
const endOfDay = new Date(date);
|
|
9433
9751
|
endOfDay.setHours(23, 59, 59, 999);
|
|
9434
|
-
const appointmentsRef = (0,
|
|
9435
|
-
const q = (0,
|
|
9752
|
+
const appointmentsRef = (0, import_firestore34.collection)(this.db, CALENDAR_COLLECTION);
|
|
9753
|
+
const q = (0, import_firestore34.query)(
|
|
9436
9754
|
appointmentsRef,
|
|
9437
|
-
(0,
|
|
9438
|
-
(0,
|
|
9439
|
-
(0,
|
|
9440
|
-
(0,
|
|
9755
|
+
(0, import_firestore34.where)("practitionerProfileId", "==", doctorId),
|
|
9756
|
+
(0, import_firestore34.where)("eventTime.start", ">=", import_firestore33.Timestamp.fromDate(startOfDay)),
|
|
9757
|
+
(0, import_firestore34.where)("eventTime.start", "<=", import_firestore33.Timestamp.fromDate(endOfDay)),
|
|
9758
|
+
(0, import_firestore34.where)("status", "in", [
|
|
9441
9759
|
"confirmed" /* CONFIRMED */,
|
|
9442
9760
|
"pending" /* PENDING */
|
|
9443
9761
|
])
|
|
9444
9762
|
);
|
|
9445
|
-
const querySnapshot = await (0,
|
|
9446
|
-
return querySnapshot.docs.map((
|
|
9763
|
+
const querySnapshot = await (0, import_firestore34.getDocs)(q);
|
|
9764
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
9447
9765
|
}
|
|
9448
9766
|
/**
|
|
9449
9767
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -9500,11 +9818,11 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9500
9818
|
var _a;
|
|
9501
9819
|
try {
|
|
9502
9820
|
const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
|
|
9503
|
-
(0,
|
|
9504
|
-
(0,
|
|
9505
|
-
(0,
|
|
9506
|
-
(0,
|
|
9507
|
-
(0,
|
|
9821
|
+
(0, import_firestore34.getDoc)((0, import_firestore34.doc)(this.db, CLINICS_COLLECTION, clinicId)),
|
|
9822
|
+
(0, import_firestore34.getDoc)((0, import_firestore34.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId)),
|
|
9823
|
+
(0, import_firestore34.getDoc)((0, import_firestore34.doc)(this.db, PATIENTS_COLLECTION, patientId)),
|
|
9824
|
+
(0, import_firestore34.getDoc)(
|
|
9825
|
+
(0, import_firestore34.doc)(
|
|
9508
9826
|
this.db,
|
|
9509
9827
|
PATIENTS_COLLECTION,
|
|
9510
9828
|
patientId,
|
|
@@ -9537,7 +9855,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9537
9855
|
fullName: `${sensitiveData.firstName} ${sensitiveData.lastName}`,
|
|
9538
9856
|
email: sensitiveData.email || "",
|
|
9539
9857
|
phone: sensitiveData.phoneNumber || null,
|
|
9540
|
-
dateOfBirth: sensitiveData.dateOfBirth ||
|
|
9858
|
+
dateOfBirth: sensitiveData.dateOfBirth || import_firestore33.Timestamp.now(),
|
|
9541
9859
|
gender: sensitiveData.gender || "other" /* OTHER */
|
|
9542
9860
|
};
|
|
9543
9861
|
} else if (patientDoc.exists()) {
|
|
@@ -9546,7 +9864,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9546
9864
|
fullName: patientDoc.data().displayName,
|
|
9547
9865
|
email: ((_a = patientDoc.data().contactInfo) == null ? void 0 : _a.email) || "",
|
|
9548
9866
|
phone: patientDoc.data().phoneNumber || null,
|
|
9549
|
-
dateOfBirth: patientDoc.data().dateOfBirth ||
|
|
9867
|
+
dateOfBirth: patientDoc.data().dateOfBirth || import_firestore33.Timestamp.now(),
|
|
9550
9868
|
gender: patientDoc.data().gender || "other" /* OTHER */
|
|
9551
9869
|
};
|
|
9552
9870
|
}
|
|
@@ -9568,7 +9886,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9568
9886
|
};
|
|
9569
9887
|
|
|
9570
9888
|
// src/backoffice/services/brand.service.ts
|
|
9571
|
-
var
|
|
9889
|
+
var import_firestore35 = require("firebase/firestore");
|
|
9572
9890
|
|
|
9573
9891
|
// src/backoffice/types/brand.types.ts
|
|
9574
9892
|
var BRANDS_COLLECTION = "brands";
|
|
@@ -9579,7 +9897,7 @@ var BrandService = class extends BaseService {
|
|
|
9579
9897
|
* Gets reference to brands collection
|
|
9580
9898
|
*/
|
|
9581
9899
|
getBrandsRef() {
|
|
9582
|
-
return (0,
|
|
9900
|
+
return (0, import_firestore35.collection)(this.db, BRANDS_COLLECTION);
|
|
9583
9901
|
}
|
|
9584
9902
|
/**
|
|
9585
9903
|
* Creates a new brand
|
|
@@ -9592,19 +9910,19 @@ var BrandService = class extends BaseService {
|
|
|
9592
9910
|
updatedAt: now,
|
|
9593
9911
|
isActive: true
|
|
9594
9912
|
};
|
|
9595
|
-
const docRef = await (0,
|
|
9913
|
+
const docRef = await (0, import_firestore35.addDoc)(this.getBrandsRef(), newBrand);
|
|
9596
9914
|
return { id: docRef.id, ...newBrand };
|
|
9597
9915
|
}
|
|
9598
9916
|
/**
|
|
9599
9917
|
* Gets all active brands
|
|
9600
9918
|
*/
|
|
9601
9919
|
async getAll() {
|
|
9602
|
-
const q = (0,
|
|
9603
|
-
const snapshot = await (0,
|
|
9920
|
+
const q = (0, import_firestore35.query)(this.getBrandsRef(), (0, import_firestore35.where)("isActive", "==", true));
|
|
9921
|
+
const snapshot = await (0, import_firestore35.getDocs)(q);
|
|
9604
9922
|
return snapshot.docs.map(
|
|
9605
|
-
(
|
|
9606
|
-
id:
|
|
9607
|
-
...
|
|
9923
|
+
(doc28) => ({
|
|
9924
|
+
id: doc28.id,
|
|
9925
|
+
...doc28.data()
|
|
9608
9926
|
})
|
|
9609
9927
|
);
|
|
9610
9928
|
}
|
|
@@ -9616,8 +9934,8 @@ var BrandService = class extends BaseService {
|
|
|
9616
9934
|
...brand,
|
|
9617
9935
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9618
9936
|
};
|
|
9619
|
-
const docRef = (0,
|
|
9620
|
-
await (0,
|
|
9937
|
+
const docRef = (0, import_firestore35.doc)(this.getBrandsRef(), brandId);
|
|
9938
|
+
await (0, import_firestore35.updateDoc)(docRef, updateData);
|
|
9621
9939
|
return this.getById(brandId);
|
|
9622
9940
|
}
|
|
9623
9941
|
/**
|
|
@@ -9632,8 +9950,8 @@ var BrandService = class extends BaseService {
|
|
|
9632
9950
|
* Gets a brand by ID
|
|
9633
9951
|
*/
|
|
9634
9952
|
async getById(brandId) {
|
|
9635
|
-
const docRef = (0,
|
|
9636
|
-
const docSnap = await (0,
|
|
9953
|
+
const docRef = (0, import_firestore35.doc)(this.getBrandsRef(), brandId);
|
|
9954
|
+
const docSnap = await (0, import_firestore35.getDoc)(docRef);
|
|
9637
9955
|
if (!docSnap.exists()) return null;
|
|
9638
9956
|
return {
|
|
9639
9957
|
id: docSnap.id,
|
|
@@ -9643,7 +9961,7 @@ var BrandService = class extends BaseService {
|
|
|
9643
9961
|
};
|
|
9644
9962
|
|
|
9645
9963
|
// src/backoffice/services/category.service.ts
|
|
9646
|
-
var
|
|
9964
|
+
var import_firestore36 = require("firebase/firestore");
|
|
9647
9965
|
|
|
9648
9966
|
// src/backoffice/types/category.types.ts
|
|
9649
9967
|
var CATEGORIES_COLLECTION = "backoffice_categories";
|
|
@@ -9654,7 +9972,7 @@ var CategoryService = class extends BaseService {
|
|
|
9654
9972
|
* Referenca na Firestore kolekciju kategorija
|
|
9655
9973
|
*/
|
|
9656
9974
|
get categoriesRef() {
|
|
9657
|
-
return (0,
|
|
9975
|
+
return (0, import_firestore36.collection)(this.db, CATEGORIES_COLLECTION);
|
|
9658
9976
|
}
|
|
9659
9977
|
/**
|
|
9660
9978
|
* Kreira novu kategoriju u sistemu
|
|
@@ -9669,7 +9987,7 @@ var CategoryService = class extends BaseService {
|
|
|
9669
9987
|
updatedAt: now,
|
|
9670
9988
|
isActive: true
|
|
9671
9989
|
};
|
|
9672
|
-
const docRef = await (0,
|
|
9990
|
+
const docRef = await (0, import_firestore36.addDoc)(this.categoriesRef, newCategory);
|
|
9673
9991
|
return { id: docRef.id, ...newCategory };
|
|
9674
9992
|
}
|
|
9675
9993
|
/**
|
|
@@ -9677,12 +9995,12 @@ var CategoryService = class extends BaseService {
|
|
|
9677
9995
|
* @returns Lista aktivnih kategorija
|
|
9678
9996
|
*/
|
|
9679
9997
|
async getAll() {
|
|
9680
|
-
const q = (0,
|
|
9681
|
-
const snapshot = await (0,
|
|
9998
|
+
const q = (0, import_firestore36.query)(this.categoriesRef, (0, import_firestore36.where)("isActive", "==", true));
|
|
9999
|
+
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
9682
10000
|
return snapshot.docs.map(
|
|
9683
|
-
(
|
|
9684
|
-
id:
|
|
9685
|
-
...
|
|
10001
|
+
(doc28) => ({
|
|
10002
|
+
id: doc28.id,
|
|
10003
|
+
...doc28.data()
|
|
9686
10004
|
})
|
|
9687
10005
|
);
|
|
9688
10006
|
}
|
|
@@ -9692,16 +10010,16 @@ var CategoryService = class extends BaseService {
|
|
|
9692
10010
|
* @returns Lista kategorija koje pripadaju traženoj familiji
|
|
9693
10011
|
*/
|
|
9694
10012
|
async getAllByFamily(family) {
|
|
9695
|
-
const q = (0,
|
|
10013
|
+
const q = (0, import_firestore36.query)(
|
|
9696
10014
|
this.categoriesRef,
|
|
9697
|
-
(0,
|
|
9698
|
-
(0,
|
|
10015
|
+
(0, import_firestore36.where)("family", "==", family),
|
|
10016
|
+
(0, import_firestore36.where)("isActive", "==", true)
|
|
9699
10017
|
);
|
|
9700
|
-
const snapshot = await (0,
|
|
10018
|
+
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
9701
10019
|
return snapshot.docs.map(
|
|
9702
|
-
(
|
|
9703
|
-
id:
|
|
9704
|
-
...
|
|
10020
|
+
(doc28) => ({
|
|
10021
|
+
id: doc28.id,
|
|
10022
|
+
...doc28.data()
|
|
9705
10023
|
})
|
|
9706
10024
|
);
|
|
9707
10025
|
}
|
|
@@ -9716,8 +10034,8 @@ var CategoryService = class extends BaseService {
|
|
|
9716
10034
|
...category,
|
|
9717
10035
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9718
10036
|
};
|
|
9719
|
-
const docRef = (0,
|
|
9720
|
-
await (0,
|
|
10037
|
+
const docRef = (0, import_firestore36.doc)(this.categoriesRef, id);
|
|
10038
|
+
await (0, import_firestore36.updateDoc)(docRef, updateData);
|
|
9721
10039
|
return this.getById(id);
|
|
9722
10040
|
}
|
|
9723
10041
|
/**
|
|
@@ -9733,8 +10051,8 @@ var CategoryService = class extends BaseService {
|
|
|
9733
10051
|
* @returns Kategorija ili null ako ne postoji
|
|
9734
10052
|
*/
|
|
9735
10053
|
async getById(id) {
|
|
9736
|
-
const docRef = (0,
|
|
9737
|
-
const docSnap = await (0,
|
|
10054
|
+
const docRef = (0, import_firestore36.doc)(this.categoriesRef, id);
|
|
10055
|
+
const docSnap = await (0, import_firestore36.getDoc)(docRef);
|
|
9738
10056
|
if (!docSnap.exists()) return null;
|
|
9739
10057
|
return {
|
|
9740
10058
|
id: docSnap.id,
|
|
@@ -9744,7 +10062,7 @@ var CategoryService = class extends BaseService {
|
|
|
9744
10062
|
};
|
|
9745
10063
|
|
|
9746
10064
|
// src/backoffice/services/subcategory.service.ts
|
|
9747
|
-
var
|
|
10065
|
+
var import_firestore37 = require("firebase/firestore");
|
|
9748
10066
|
|
|
9749
10067
|
// src/backoffice/types/subcategory.types.ts
|
|
9750
10068
|
var SUBCATEGORIES_COLLECTION = "subcategories";
|
|
@@ -9756,7 +10074,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
9756
10074
|
* @param categoryId - ID roditeljske kategorije
|
|
9757
10075
|
*/
|
|
9758
10076
|
getSubcategoriesRef(categoryId) {
|
|
9759
|
-
return (0,
|
|
10077
|
+
return (0, import_firestore37.collection)(
|
|
9760
10078
|
this.db,
|
|
9761
10079
|
CATEGORIES_COLLECTION,
|
|
9762
10080
|
categoryId,
|
|
@@ -9778,7 +10096,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
9778
10096
|
updatedAt: now,
|
|
9779
10097
|
isActive: true
|
|
9780
10098
|
};
|
|
9781
|
-
const docRef = await (0,
|
|
10099
|
+
const docRef = await (0, import_firestore37.addDoc)(
|
|
9782
10100
|
this.getSubcategoriesRef(categoryId),
|
|
9783
10101
|
newSubcategory
|
|
9784
10102
|
);
|
|
@@ -9790,15 +10108,15 @@ var SubcategoryService = class extends BaseService {
|
|
|
9790
10108
|
* @returns Lista aktivnih podkategorija
|
|
9791
10109
|
*/
|
|
9792
10110
|
async getAllByCategoryId(categoryId) {
|
|
9793
|
-
const q = (0,
|
|
10111
|
+
const q = (0, import_firestore37.query)(
|
|
9794
10112
|
this.getSubcategoriesRef(categoryId),
|
|
9795
|
-
(0,
|
|
10113
|
+
(0, import_firestore37.where)("isActive", "==", true)
|
|
9796
10114
|
);
|
|
9797
|
-
const snapshot = await (0,
|
|
10115
|
+
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
9798
10116
|
return snapshot.docs.map(
|
|
9799
|
-
(
|
|
9800
|
-
id:
|
|
9801
|
-
...
|
|
10117
|
+
(doc28) => ({
|
|
10118
|
+
id: doc28.id,
|
|
10119
|
+
...doc28.data()
|
|
9802
10120
|
})
|
|
9803
10121
|
);
|
|
9804
10122
|
}
|
|
@@ -9814,8 +10132,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
9814
10132
|
...subcategory,
|
|
9815
10133
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9816
10134
|
};
|
|
9817
|
-
const docRef = (0,
|
|
9818
|
-
await (0,
|
|
10135
|
+
const docRef = (0, import_firestore37.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
10136
|
+
await (0, import_firestore37.updateDoc)(docRef, updateData);
|
|
9819
10137
|
return this.getById(categoryId, subcategoryId);
|
|
9820
10138
|
}
|
|
9821
10139
|
/**
|
|
@@ -9833,8 +10151,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
9833
10151
|
* @returns Podkategorija ili null ako ne postoji
|
|
9834
10152
|
*/
|
|
9835
10153
|
async getById(categoryId, subcategoryId) {
|
|
9836
|
-
const docRef = (0,
|
|
9837
|
-
const docSnap = await (0,
|
|
10154
|
+
const docRef = (0, import_firestore37.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
10155
|
+
const docSnap = await (0, import_firestore37.getDoc)(docRef);
|
|
9838
10156
|
if (!docSnap.exists()) return null;
|
|
9839
10157
|
return {
|
|
9840
10158
|
id: docSnap.id,
|
|
@@ -9844,7 +10162,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
9844
10162
|
};
|
|
9845
10163
|
|
|
9846
10164
|
// src/backoffice/services/technology.service.ts
|
|
9847
|
-
var
|
|
10165
|
+
var import_firestore38 = require("firebase/firestore");
|
|
9848
10166
|
|
|
9849
10167
|
// src/backoffice/types/technology.types.ts
|
|
9850
10168
|
var TECHNOLOGIES_COLLECTION = "technologies";
|
|
@@ -9859,7 +10177,7 @@ var TechnologyService = class extends BaseService {
|
|
|
9859
10177
|
* Vraća referencu na Firestore kolekciju tehnologija
|
|
9860
10178
|
*/
|
|
9861
10179
|
getTechnologiesRef() {
|
|
9862
|
-
return (0,
|
|
10180
|
+
return (0, import_firestore38.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
9863
10181
|
}
|
|
9864
10182
|
/**
|
|
9865
10183
|
* Kreira novu tehnologiju
|
|
@@ -9882,7 +10200,7 @@ var TechnologyService = class extends BaseService {
|
|
|
9882
10200
|
benefits: technology.benefits || [],
|
|
9883
10201
|
certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
|
|
9884
10202
|
};
|
|
9885
|
-
const docRef = await (0,
|
|
10203
|
+
const docRef = await (0, import_firestore38.addDoc)(this.getTechnologiesRef(), newTechnology);
|
|
9886
10204
|
return { id: docRef.id, ...newTechnology };
|
|
9887
10205
|
}
|
|
9888
10206
|
/**
|
|
@@ -9890,12 +10208,12 @@ var TechnologyService = class extends BaseService {
|
|
|
9890
10208
|
* @returns Lista aktivnih tehnologija
|
|
9891
10209
|
*/
|
|
9892
10210
|
async getAll() {
|
|
9893
|
-
const q = (0,
|
|
9894
|
-
const snapshot = await (0,
|
|
10211
|
+
const q = (0, import_firestore38.query)(this.getTechnologiesRef(), (0, import_firestore38.where)("isActive", "==", true));
|
|
10212
|
+
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
9895
10213
|
return snapshot.docs.map(
|
|
9896
|
-
(
|
|
9897
|
-
id:
|
|
9898
|
-
...
|
|
10214
|
+
(doc28) => ({
|
|
10215
|
+
id: doc28.id,
|
|
10216
|
+
...doc28.data()
|
|
9899
10217
|
})
|
|
9900
10218
|
);
|
|
9901
10219
|
}
|
|
@@ -9905,16 +10223,16 @@ var TechnologyService = class extends BaseService {
|
|
|
9905
10223
|
* @returns Lista aktivnih tehnologija
|
|
9906
10224
|
*/
|
|
9907
10225
|
async getAllByFamily(family) {
|
|
9908
|
-
const q = (0,
|
|
10226
|
+
const q = (0, import_firestore38.query)(
|
|
9909
10227
|
this.getTechnologiesRef(),
|
|
9910
|
-
(0,
|
|
9911
|
-
(0,
|
|
10228
|
+
(0, import_firestore38.where)("isActive", "==", true),
|
|
10229
|
+
(0, import_firestore38.where)("family", "==", family)
|
|
9912
10230
|
);
|
|
9913
|
-
const snapshot = await (0,
|
|
10231
|
+
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
9914
10232
|
return snapshot.docs.map(
|
|
9915
|
-
(
|
|
9916
|
-
id:
|
|
9917
|
-
...
|
|
10233
|
+
(doc28) => ({
|
|
10234
|
+
id: doc28.id,
|
|
10235
|
+
...doc28.data()
|
|
9918
10236
|
})
|
|
9919
10237
|
);
|
|
9920
10238
|
}
|
|
@@ -9924,16 +10242,16 @@ var TechnologyService = class extends BaseService {
|
|
|
9924
10242
|
* @returns Lista aktivnih tehnologija
|
|
9925
10243
|
*/
|
|
9926
10244
|
async getAllByCategoryId(categoryId) {
|
|
9927
|
-
const q = (0,
|
|
10245
|
+
const q = (0, import_firestore38.query)(
|
|
9928
10246
|
this.getTechnologiesRef(),
|
|
9929
|
-
(0,
|
|
9930
|
-
(0,
|
|
10247
|
+
(0, import_firestore38.where)("isActive", "==", true),
|
|
10248
|
+
(0, import_firestore38.where)("categoryId", "==", categoryId)
|
|
9931
10249
|
);
|
|
9932
|
-
const snapshot = await (0,
|
|
10250
|
+
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
9933
10251
|
return snapshot.docs.map(
|
|
9934
|
-
(
|
|
9935
|
-
id:
|
|
9936
|
-
...
|
|
10252
|
+
(doc28) => ({
|
|
10253
|
+
id: doc28.id,
|
|
10254
|
+
...doc28.data()
|
|
9937
10255
|
})
|
|
9938
10256
|
);
|
|
9939
10257
|
}
|
|
@@ -9943,16 +10261,16 @@ var TechnologyService = class extends BaseService {
|
|
|
9943
10261
|
* @returns Lista aktivnih tehnologija
|
|
9944
10262
|
*/
|
|
9945
10263
|
async getAllBySubcategoryId(subcategoryId) {
|
|
9946
|
-
const q = (0,
|
|
10264
|
+
const q = (0, import_firestore38.query)(
|
|
9947
10265
|
this.getTechnologiesRef(),
|
|
9948
|
-
(0,
|
|
9949
|
-
(0,
|
|
10266
|
+
(0, import_firestore38.where)("isActive", "==", true),
|
|
10267
|
+
(0, import_firestore38.where)("subcategoryId", "==", subcategoryId)
|
|
9950
10268
|
);
|
|
9951
|
-
const snapshot = await (0,
|
|
10269
|
+
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
9952
10270
|
return snapshot.docs.map(
|
|
9953
|
-
(
|
|
9954
|
-
id:
|
|
9955
|
-
...
|
|
10271
|
+
(doc28) => ({
|
|
10272
|
+
id: doc28.id,
|
|
10273
|
+
...doc28.data()
|
|
9956
10274
|
})
|
|
9957
10275
|
);
|
|
9958
10276
|
}
|
|
@@ -9967,8 +10285,8 @@ var TechnologyService = class extends BaseService {
|
|
|
9967
10285
|
...technology,
|
|
9968
10286
|
updatedAt: /* @__PURE__ */ new Date()
|
|
9969
10287
|
};
|
|
9970
|
-
const docRef = (0,
|
|
9971
|
-
await (0,
|
|
10288
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10289
|
+
await (0, import_firestore38.updateDoc)(docRef, updateData);
|
|
9972
10290
|
return this.getById(technologyId);
|
|
9973
10291
|
}
|
|
9974
10292
|
/**
|
|
@@ -9986,8 +10304,8 @@ var TechnologyService = class extends BaseService {
|
|
|
9986
10304
|
* @returns Tehnologija ili null ako ne postoji
|
|
9987
10305
|
*/
|
|
9988
10306
|
async getById(technologyId) {
|
|
9989
|
-
const docRef = (0,
|
|
9990
|
-
const docSnap = await (0,
|
|
10307
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10308
|
+
const docSnap = await (0, import_firestore38.getDoc)(docRef);
|
|
9991
10309
|
if (!docSnap.exists()) return null;
|
|
9992
10310
|
return {
|
|
9993
10311
|
id: docSnap.id,
|
|
@@ -10001,10 +10319,10 @@ var TechnologyService = class extends BaseService {
|
|
|
10001
10319
|
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
10002
10320
|
*/
|
|
10003
10321
|
async addRequirement(technologyId, requirement) {
|
|
10004
|
-
const docRef = (0,
|
|
10322
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10005
10323
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
10006
|
-
await (0,
|
|
10007
|
-
[requirementType]: (0,
|
|
10324
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10325
|
+
[requirementType]: (0, import_firestore38.arrayUnion)(requirement),
|
|
10008
10326
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10009
10327
|
});
|
|
10010
10328
|
return this.getById(technologyId);
|
|
@@ -10016,10 +10334,10 @@ var TechnologyService = class extends BaseService {
|
|
|
10016
10334
|
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
10017
10335
|
*/
|
|
10018
10336
|
async removeRequirement(technologyId, requirement) {
|
|
10019
|
-
const docRef = (0,
|
|
10337
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10020
10338
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
10021
|
-
await (0,
|
|
10022
|
-
[requirementType]: (0,
|
|
10339
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10340
|
+
[requirementType]: (0, import_firestore38.arrayRemove)(requirement),
|
|
10023
10341
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10024
10342
|
});
|
|
10025
10343
|
return this.getById(technologyId);
|
|
@@ -10056,9 +10374,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10056
10374
|
* @returns Ažurirana tehnologija
|
|
10057
10375
|
*/
|
|
10058
10376
|
async addBlockingCondition(technologyId, condition) {
|
|
10059
|
-
const docRef = (0,
|
|
10060
|
-
await (0,
|
|
10061
|
-
blockingConditions: (0,
|
|
10377
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10378
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10379
|
+
blockingConditions: (0, import_firestore38.arrayUnion)(condition),
|
|
10062
10380
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10063
10381
|
});
|
|
10064
10382
|
return this.getById(technologyId);
|
|
@@ -10070,9 +10388,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10070
10388
|
* @returns Ažurirana tehnologija
|
|
10071
10389
|
*/
|
|
10072
10390
|
async removeBlockingCondition(technologyId, condition) {
|
|
10073
|
-
const docRef = (0,
|
|
10074
|
-
await (0,
|
|
10075
|
-
blockingConditions: (0,
|
|
10391
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10392
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10393
|
+
blockingConditions: (0, import_firestore38.arrayRemove)(condition),
|
|
10076
10394
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10077
10395
|
});
|
|
10078
10396
|
return this.getById(technologyId);
|
|
@@ -10084,9 +10402,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10084
10402
|
* @returns Ažurirana tehnologija
|
|
10085
10403
|
*/
|
|
10086
10404
|
async addContraindication(technologyId, contraindication) {
|
|
10087
|
-
const docRef = (0,
|
|
10088
|
-
await (0,
|
|
10089
|
-
contraindications: (0,
|
|
10405
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10406
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10407
|
+
contraindications: (0, import_firestore38.arrayUnion)(contraindication),
|
|
10090
10408
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10091
10409
|
});
|
|
10092
10410
|
return this.getById(technologyId);
|
|
@@ -10098,9 +10416,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10098
10416
|
* @returns Ažurirana tehnologija
|
|
10099
10417
|
*/
|
|
10100
10418
|
async removeContraindication(technologyId, contraindication) {
|
|
10101
|
-
const docRef = (0,
|
|
10102
|
-
await (0,
|
|
10103
|
-
contraindications: (0,
|
|
10419
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10420
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10421
|
+
contraindications: (0, import_firestore38.arrayRemove)(contraindication),
|
|
10104
10422
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10105
10423
|
});
|
|
10106
10424
|
return this.getById(technologyId);
|
|
@@ -10112,9 +10430,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10112
10430
|
* @returns Ažurirana tehnologija
|
|
10113
10431
|
*/
|
|
10114
10432
|
async addBenefit(technologyId, benefit) {
|
|
10115
|
-
const docRef = (0,
|
|
10116
|
-
await (0,
|
|
10117
|
-
benefits: (0,
|
|
10433
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10434
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10435
|
+
benefits: (0, import_firestore38.arrayUnion)(benefit),
|
|
10118
10436
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10119
10437
|
});
|
|
10120
10438
|
return this.getById(technologyId);
|
|
@@ -10126,9 +10444,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10126
10444
|
* @returns Ažurirana tehnologija
|
|
10127
10445
|
*/
|
|
10128
10446
|
async removeBenefit(technologyId, benefit) {
|
|
10129
|
-
const docRef = (0,
|
|
10130
|
-
await (0,
|
|
10131
|
-
benefits: (0,
|
|
10447
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10448
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10449
|
+
benefits: (0, import_firestore38.arrayRemove)(benefit),
|
|
10132
10450
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10133
10451
|
});
|
|
10134
10452
|
return this.getById(technologyId);
|
|
@@ -10167,8 +10485,8 @@ var TechnologyService = class extends BaseService {
|
|
|
10167
10485
|
* @returns Ažurirana tehnologija
|
|
10168
10486
|
*/
|
|
10169
10487
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
10170
|
-
const docRef = (0,
|
|
10171
|
-
await (0,
|
|
10488
|
+
const docRef = (0, import_firestore38.doc)(this.getTechnologiesRef(), technologyId);
|
|
10489
|
+
await (0, import_firestore38.updateDoc)(docRef, {
|
|
10172
10490
|
certificationRequirement,
|
|
10173
10491
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10174
10492
|
});
|
|
@@ -10268,7 +10586,7 @@ var TechnologyService = class extends BaseService {
|
|
|
10268
10586
|
};
|
|
10269
10587
|
|
|
10270
10588
|
// src/backoffice/services/product.service.ts
|
|
10271
|
-
var
|
|
10589
|
+
var import_firestore39 = require("firebase/firestore");
|
|
10272
10590
|
|
|
10273
10591
|
// src/backoffice/types/product.types.ts
|
|
10274
10592
|
var PRODUCTS_COLLECTION = "products";
|
|
@@ -10281,7 +10599,7 @@ var ProductService = class extends BaseService {
|
|
|
10281
10599
|
* @returns Firestore collection reference
|
|
10282
10600
|
*/
|
|
10283
10601
|
getProductsRef(technologyId) {
|
|
10284
|
-
return (0,
|
|
10602
|
+
return (0, import_firestore39.collection)(
|
|
10285
10603
|
this.db,
|
|
10286
10604
|
TECHNOLOGIES_COLLECTION,
|
|
10287
10605
|
technologyId,
|
|
@@ -10301,7 +10619,7 @@ var ProductService = class extends BaseService {
|
|
|
10301
10619
|
updatedAt: now,
|
|
10302
10620
|
isActive: true
|
|
10303
10621
|
};
|
|
10304
|
-
const productRef = await (0,
|
|
10622
|
+
const productRef = await (0, import_firestore39.addDoc)(
|
|
10305
10623
|
this.getProductsRef(technologyId),
|
|
10306
10624
|
newProduct
|
|
10307
10625
|
);
|
|
@@ -10311,15 +10629,15 @@ var ProductService = class extends BaseService {
|
|
|
10311
10629
|
* Gets all products for a technology
|
|
10312
10630
|
*/
|
|
10313
10631
|
async getAllByTechnology(technologyId) {
|
|
10314
|
-
const q = (0,
|
|
10632
|
+
const q = (0, import_firestore39.query)(
|
|
10315
10633
|
this.getProductsRef(technologyId),
|
|
10316
|
-
(0,
|
|
10634
|
+
(0, import_firestore39.where)("isActive", "==", true)
|
|
10317
10635
|
);
|
|
10318
|
-
const snapshot = await (0,
|
|
10636
|
+
const snapshot = await (0, import_firestore39.getDocs)(q);
|
|
10319
10637
|
return snapshot.docs.map(
|
|
10320
|
-
(
|
|
10321
|
-
id:
|
|
10322
|
-
...
|
|
10638
|
+
(doc28) => ({
|
|
10639
|
+
id: doc28.id,
|
|
10640
|
+
...doc28.data()
|
|
10323
10641
|
})
|
|
10324
10642
|
);
|
|
10325
10643
|
}
|
|
@@ -10327,21 +10645,21 @@ var ProductService = class extends BaseService {
|
|
|
10327
10645
|
* Gets all products for a brand by filtering through all technologies
|
|
10328
10646
|
*/
|
|
10329
10647
|
async getAllByBrand(brandId) {
|
|
10330
|
-
const allTechnologiesRef = (0,
|
|
10331
|
-
const technologiesSnapshot = await (0,
|
|
10648
|
+
const allTechnologiesRef = (0, import_firestore39.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
10649
|
+
const technologiesSnapshot = await (0, import_firestore39.getDocs)(allTechnologiesRef);
|
|
10332
10650
|
const products = [];
|
|
10333
10651
|
for (const techDoc of technologiesSnapshot.docs) {
|
|
10334
|
-
const q = (0,
|
|
10652
|
+
const q = (0, import_firestore39.query)(
|
|
10335
10653
|
this.getProductsRef(techDoc.id),
|
|
10336
|
-
(0,
|
|
10337
|
-
(0,
|
|
10654
|
+
(0, import_firestore39.where)("brandId", "==", brandId),
|
|
10655
|
+
(0, import_firestore39.where)("isActive", "==", true)
|
|
10338
10656
|
);
|
|
10339
|
-
const snapshot = await (0,
|
|
10657
|
+
const snapshot = await (0, import_firestore39.getDocs)(q);
|
|
10340
10658
|
products.push(
|
|
10341
10659
|
...snapshot.docs.map(
|
|
10342
|
-
(
|
|
10343
|
-
id:
|
|
10344
|
-
...
|
|
10660
|
+
(doc28) => ({
|
|
10661
|
+
id: doc28.id,
|
|
10662
|
+
...doc28.data()
|
|
10345
10663
|
})
|
|
10346
10664
|
)
|
|
10347
10665
|
);
|
|
@@ -10356,8 +10674,8 @@ var ProductService = class extends BaseService {
|
|
|
10356
10674
|
...product,
|
|
10357
10675
|
updatedAt: /* @__PURE__ */ new Date()
|
|
10358
10676
|
};
|
|
10359
|
-
const docRef = (0,
|
|
10360
|
-
await (0,
|
|
10677
|
+
const docRef = (0, import_firestore39.doc)(this.getProductsRef(technologyId), productId);
|
|
10678
|
+
await (0, import_firestore39.updateDoc)(docRef, updateData);
|
|
10361
10679
|
return this.getById(technologyId, productId);
|
|
10362
10680
|
}
|
|
10363
10681
|
/**
|
|
@@ -10372,8 +10690,8 @@ var ProductService = class extends BaseService {
|
|
|
10372
10690
|
* Gets a product by ID
|
|
10373
10691
|
*/
|
|
10374
10692
|
async getById(technologyId, productId) {
|
|
10375
|
-
const docRef = (0,
|
|
10376
|
-
const docSnap = await (0,
|
|
10693
|
+
const docRef = (0, import_firestore39.doc)(this.getProductsRef(technologyId), productId);
|
|
10694
|
+
const docSnap = await (0, import_firestore39.getDoc)(docRef);
|
|
10377
10695
|
if (!docSnap.exists()) return null;
|
|
10378
10696
|
return {
|
|
10379
10697
|
id: docSnap.id,
|
|
@@ -10500,6 +10818,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
|
|
|
10500
10818
|
ProductService,
|
|
10501
10819
|
REGISTER_TOKENS_COLLECTION,
|
|
10502
10820
|
SYNCED_CALENDARS_COLLECTION,
|
|
10821
|
+
SearchLocationEnum,
|
|
10503
10822
|
SubcategoryService,
|
|
10504
10823
|
SubscriptionModel,
|
|
10505
10824
|
SyncedCalendarProvider,
|
|
@@ -10589,7 +10908,9 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
|
|
|
10589
10908
|
preRequirementNotificationSchema,
|
|
10590
10909
|
procedureCategorizationSchema,
|
|
10591
10910
|
procedureInfoSchema,
|
|
10911
|
+
requesterInfoSchema,
|
|
10592
10912
|
reviewInfoSchema,
|
|
10913
|
+
searchPatientsSchema,
|
|
10593
10914
|
serviceInfoSchema,
|
|
10594
10915
|
syncedCalendarEventSchema,
|
|
10595
10916
|
timeSlotSchema,
|