@blackcode_sa/metaestetics-api 1.5.17 → 1.5.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +188 -219
- package/dist/index.mjs +320 -354
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/services/calendar/utils/calendar-event.utils.ts +2 -2
- package/src/services/patient/patient.service.ts +73 -129
- package/src/services/patient/utils/profile.utils.ts +123 -127
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,
|
|
@@ -315,6 +316,12 @@ var CalendarEventType = /* @__PURE__ */ ((CalendarEventType3) => {
|
|
|
315
316
|
return CalendarEventType3;
|
|
316
317
|
})(CalendarEventType || {});
|
|
317
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 || {});
|
|
318
325
|
|
|
319
326
|
// src/types/index.ts
|
|
320
327
|
var UserRole = /* @__PURE__ */ ((UserRole2) => {
|
|
@@ -1473,9 +1480,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1473
1480
|
var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
1474
1481
|
const validatedData = updateAllergySchema.parse(data);
|
|
1475
1482
|
const { allergyIndex, ...updateData } = validatedData;
|
|
1476
|
-
const
|
|
1477
|
-
if (!
|
|
1478
|
-
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();
|
|
1479
1486
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1480
1487
|
throw new Error("Invalid allergy index");
|
|
1481
1488
|
}
|
|
@@ -1491,9 +1498,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1491
1498
|
});
|
|
1492
1499
|
};
|
|
1493
1500
|
var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
|
|
1494
|
-
const
|
|
1495
|
-
if (!
|
|
1496
|
-
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();
|
|
1497
1504
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1498
1505
|
throw new Error("Invalid allergy index");
|
|
1499
1506
|
}
|
|
@@ -1518,9 +1525,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1518
1525
|
var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
1519
1526
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
1520
1527
|
const { conditionIndex, ...updateData } = validatedData;
|
|
1521
|
-
const
|
|
1522
|
-
if (!
|
|
1523
|
-
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();
|
|
1524
1531
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1525
1532
|
throw new Error("Invalid blocking condition index");
|
|
1526
1533
|
}
|
|
@@ -1536,9 +1543,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1536
1543
|
});
|
|
1537
1544
|
};
|
|
1538
1545
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
|
|
1539
|
-
const
|
|
1540
|
-
if (!
|
|
1541
|
-
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();
|
|
1542
1549
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1543
1550
|
throw new Error("Invalid blocking condition index");
|
|
1544
1551
|
}
|
|
@@ -1563,9 +1570,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1563
1570
|
var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
1564
1571
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
1565
1572
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
1566
|
-
const
|
|
1567
|
-
if (!
|
|
1568
|
-
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();
|
|
1569
1576
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1570
1577
|
throw new Error("Invalid contraindication index");
|
|
1571
1578
|
}
|
|
@@ -1581,9 +1588,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1581
1588
|
});
|
|
1582
1589
|
};
|
|
1583
1590
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
|
|
1584
|
-
const
|
|
1585
|
-
if (!
|
|
1586
|
-
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();
|
|
1587
1594
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1588
1595
|
throw new Error("Invalid contraindication index");
|
|
1589
1596
|
}
|
|
@@ -1608,9 +1615,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1608
1615
|
var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
1609
1616
|
const validatedData = updateMedicationSchema.parse(data);
|
|
1610
1617
|
const { medicationIndex, ...updateData } = validatedData;
|
|
1611
|
-
const
|
|
1612
|
-
if (!
|
|
1613
|
-
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();
|
|
1614
1621
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1615
1622
|
throw new Error("Invalid medication index");
|
|
1616
1623
|
}
|
|
@@ -1626,9 +1633,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1626
1633
|
});
|
|
1627
1634
|
};
|
|
1628
1635
|
var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
|
|
1629
|
-
const
|
|
1630
|
-
if (!
|
|
1631
|
-
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();
|
|
1632
1639
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1633
1640
|
throw new Error("Invalid medication index");
|
|
1634
1641
|
}
|
|
@@ -1688,58 +1695,36 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
|
|
|
1688
1695
|
);
|
|
1689
1696
|
sensitiveInfoSuccess = true;
|
|
1690
1697
|
} catch (sensitiveError) {
|
|
1691
|
-
console.error(
|
|
1692
|
-
`[createPatientProfileUtil] Error creating sensitive info:`,
|
|
1693
|
-
sensitiveError
|
|
1694
|
-
);
|
|
1698
|
+
console.error(`[createPatientProfileUtil] Error creating sensitive info:`, sensitiveError);
|
|
1695
1699
|
}
|
|
1696
1700
|
console.log(`[createPatientProfileUtil] Creating medical info document`);
|
|
1697
1701
|
let medicalInfoSuccess = false;
|
|
1698
1702
|
try {
|
|
1699
1703
|
await ensureMedicalInfoExists(db, patientId, validatedData.userRef);
|
|
1700
|
-
console.log(
|
|
1701
|
-
`[createPatientProfileUtil] Medical info document created successfully`
|
|
1702
|
-
);
|
|
1704
|
+
console.log(`[createPatientProfileUtil] Medical info document created successfully`);
|
|
1703
1705
|
medicalInfoSuccess = true;
|
|
1704
1706
|
} catch (medicalError) {
|
|
1705
|
-
console.error(
|
|
1706
|
-
`[createPatientProfileUtil] Error creating medical info:`,
|
|
1707
|
-
medicalError
|
|
1708
|
-
);
|
|
1707
|
+
console.error(`[createPatientProfileUtil] Error creating medical info:`, medicalError);
|
|
1709
1708
|
}
|
|
1710
1709
|
if (!sensitiveInfoSuccess || !medicalInfoSuccess) {
|
|
1711
|
-
console.log(
|
|
1712
|
-
`[createPatientProfileUtil] Using fallback method to create documents`
|
|
1713
|
-
);
|
|
1710
|
+
console.log(`[createPatientProfileUtil] Using fallback method to create documents`);
|
|
1714
1711
|
try {
|
|
1715
1712
|
await testCreateSubDocuments(db, patientId, validatedData.userRef);
|
|
1716
|
-
console.log(
|
|
1717
|
-
`[createPatientProfileUtil] Fallback method completed successfully`
|
|
1718
|
-
);
|
|
1713
|
+
console.log(`[createPatientProfileUtil] Fallback method completed successfully`);
|
|
1719
1714
|
} catch (fallbackError) {
|
|
1720
|
-
console.error(
|
|
1721
|
-
`[createPatientProfileUtil] Fallback method failed:`,
|
|
1722
|
-
fallbackError
|
|
1723
|
-
);
|
|
1715
|
+
console.error(`[createPatientProfileUtil] Fallback method failed:`, fallbackError);
|
|
1724
1716
|
}
|
|
1725
1717
|
}
|
|
1726
1718
|
console.log(`[createPatientProfileUtil] Verifying patient document exists`);
|
|
1727
1719
|
const patientDoc = await (0, import_firestore6.getDoc)(getPatientDocRef(db, patientId));
|
|
1728
1720
|
if (!patientDoc.exists()) {
|
|
1729
|
-
console.error(
|
|
1730
|
-
`[createPatientProfileUtil] Patient document not found after creation`
|
|
1731
|
-
);
|
|
1721
|
+
console.error(`[createPatientProfileUtil] Patient document not found after creation`);
|
|
1732
1722
|
throw new Error("Failed to create patient profile");
|
|
1733
1723
|
}
|
|
1734
|
-
console.log(
|
|
1735
|
-
`[createPatientProfileUtil] Patient profile creation completed successfully`
|
|
1736
|
-
);
|
|
1724
|
+
console.log(`[createPatientProfileUtil] Patient profile creation completed successfully`);
|
|
1737
1725
|
return patientDoc.data();
|
|
1738
1726
|
} catch (error) {
|
|
1739
|
-
console.error(
|
|
1740
|
-
`[createPatientProfileUtil] Error in patient profile creation:`,
|
|
1741
|
-
error
|
|
1742
|
-
);
|
|
1727
|
+
console.error(`[createPatientProfileUtil] Error in patient profile creation:`, error);
|
|
1743
1728
|
if (error instanceof import_zod7.z.ZodError) {
|
|
1744
1729
|
throw new Error("Invalid patient data: " + error.message);
|
|
1745
1730
|
}
|
|
@@ -1805,9 +1790,7 @@ var updatePatientProfileByUserRefUtil = async (db, userRef, data) => {
|
|
|
1805
1790
|
return updatePatientProfileUtil(db, patientData.id, data);
|
|
1806
1791
|
} catch (error) {
|
|
1807
1792
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1808
|
-
throw new Error(
|
|
1809
|
-
`Failed to update patient profile by user ref: ${errorMessage}`
|
|
1810
|
-
);
|
|
1793
|
+
throw new Error(`Failed to update patient profile by user ref: ${errorMessage}`);
|
|
1811
1794
|
}
|
|
1812
1795
|
};
|
|
1813
1796
|
var uploadProfilePhotoUtil = async (storage, patientId, file) => {
|
|
@@ -1858,9 +1841,7 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
1858
1841
|
try {
|
|
1859
1842
|
console.log(`[testCreateSubDocuments] Testing sensitive info creation`);
|
|
1860
1843
|
const sensitiveInfoRef = getSensitiveInfoDocRef(db, patientId);
|
|
1861
|
-
console.log(
|
|
1862
|
-
`[testCreateSubDocuments] Sensitive info path: ${sensitiveInfoRef.path}`
|
|
1863
|
-
);
|
|
1844
|
+
console.log(`[testCreateSubDocuments] Sensitive info path: ${sensitiveInfoRef.path}`);
|
|
1864
1845
|
const defaultSensitiveInfo = {
|
|
1865
1846
|
patientId,
|
|
1866
1847
|
userRef,
|
|
@@ -1875,14 +1856,10 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
1875
1856
|
updatedAt: import_firestore6.Timestamp.now()
|
|
1876
1857
|
};
|
|
1877
1858
|
await (0, import_firestore6.setDoc)(sensitiveInfoRef, defaultSensitiveInfo);
|
|
1878
|
-
console.log(
|
|
1879
|
-
`[testCreateSubDocuments] Sensitive info document created directly`
|
|
1880
|
-
);
|
|
1859
|
+
console.log(`[testCreateSubDocuments] Sensitive info document created directly`);
|
|
1881
1860
|
console.log(`[testCreateSubDocuments] Testing medical info creation`);
|
|
1882
1861
|
const medicalInfoRef = getMedicalInfoDocRef(db, patientId);
|
|
1883
|
-
console.log(
|
|
1884
|
-
`[testCreateSubDocuments] Medical info path: ${medicalInfoRef.path}`
|
|
1885
|
-
);
|
|
1862
|
+
console.log(`[testCreateSubDocuments] Medical info path: ${medicalInfoRef.path}`);
|
|
1886
1863
|
const defaultMedicalInfo = {
|
|
1887
1864
|
...DEFAULT_MEDICAL_INFO,
|
|
1888
1865
|
patientId,
|
|
@@ -1890,9 +1867,7 @@ var testCreateSubDocuments = async (db, patientId, userRef) => {
|
|
|
1890
1867
|
updatedBy: userRef
|
|
1891
1868
|
};
|
|
1892
1869
|
await (0, import_firestore6.setDoc)(medicalInfoRef, defaultMedicalInfo);
|
|
1893
|
-
console.log(
|
|
1894
|
-
`[testCreateSubDocuments] Medical info document created directly`
|
|
1895
|
-
);
|
|
1870
|
+
console.log(`[testCreateSubDocuments] Medical info document created directly`);
|
|
1896
1871
|
console.log(`[testCreateSubDocuments] Test completed successfully`);
|
|
1897
1872
|
} catch (error) {
|
|
1898
1873
|
console.error(`[testCreateSubDocuments] Error:`, error);
|
|
@@ -1906,9 +1881,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
1906
1881
|
const patientsCollectionRef = (0, import_firestore6.collection)(db, PATIENTS_COLLECTION);
|
|
1907
1882
|
if (requester.role === "clinic_admin") {
|
|
1908
1883
|
if (!requester.associatedClinicId) {
|
|
1909
|
-
throw new Error(
|
|
1910
|
-
"Associated clinic ID is required for clinic admin search."
|
|
1911
|
-
);
|
|
1884
|
+
throw new Error("Associated clinic ID is required for clinic admin search.");
|
|
1912
1885
|
}
|
|
1913
1886
|
if (params.clinicId && params.clinicId !== requester.associatedClinicId) {
|
|
1914
1887
|
console.warn(
|
|
@@ -1916,19 +1889,13 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
1916
1889
|
);
|
|
1917
1890
|
return [];
|
|
1918
1891
|
}
|
|
1919
|
-
constraints.push(
|
|
1920
|
-
(0, import_firestore6.where)("clinicIds", "array-contains", requester.associatedClinicId)
|
|
1921
|
-
);
|
|
1892
|
+
constraints.push((0, import_firestore6.where)("clinicIds", "array-contains", requester.associatedClinicId));
|
|
1922
1893
|
if (params.practitionerId) {
|
|
1923
|
-
constraints.push(
|
|
1924
|
-
(0, import_firestore6.where)("doctorIds", "array-contains", params.practitionerId)
|
|
1925
|
-
);
|
|
1894
|
+
constraints.push((0, import_firestore6.where)("doctorIds", "array-contains", params.practitionerId));
|
|
1926
1895
|
}
|
|
1927
1896
|
} else if (requester.role === "practitioner") {
|
|
1928
1897
|
if (!requester.associatedPractitionerId) {
|
|
1929
|
-
throw new Error(
|
|
1930
|
-
"Associated practitioner ID is required for practitioner search."
|
|
1931
|
-
);
|
|
1898
|
+
throw new Error("Associated practitioner ID is required for practitioner search.");
|
|
1932
1899
|
}
|
|
1933
1900
|
if (params.practitionerId && params.practitionerId !== requester.associatedPractitionerId) {
|
|
1934
1901
|
console.warn(
|
|
@@ -1936,9 +1903,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
1936
1903
|
);
|
|
1937
1904
|
return [];
|
|
1938
1905
|
}
|
|
1939
|
-
constraints.push(
|
|
1940
|
-
(0, import_firestore6.where)("doctorIds", "array-contains", requester.associatedPractitionerId)
|
|
1941
|
-
);
|
|
1906
|
+
constraints.push((0, import_firestore6.where)("doctorIds", "array-contains", requester.associatedPractitionerId));
|
|
1942
1907
|
if (params.clinicId) {
|
|
1943
1908
|
constraints.push((0, import_firestore6.where)("clinicIds", "array-contains", params.clinicId));
|
|
1944
1909
|
}
|
|
@@ -1948,18 +1913,42 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
1948
1913
|
try {
|
|
1949
1914
|
const finalQuery = (0, import_firestore6.query)(patientsCollectionRef, ...constraints);
|
|
1950
1915
|
const querySnapshot = await (0, import_firestore6.getDocs)(finalQuery);
|
|
1951
|
-
const patients = querySnapshot.docs.map(
|
|
1952
|
-
|
|
1953
|
-
);
|
|
1954
|
-
console.log(
|
|
1955
|
-
`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
|
|
1956
|
-
);
|
|
1916
|
+
const patients = querySnapshot.docs.map((doc28) => doc28.data());
|
|
1917
|
+
console.log(`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`);
|
|
1957
1918
|
return patients;
|
|
1958
1919
|
} catch (error) {
|
|
1959
1920
|
console.error("[searchPatientsUtil] Error searching patients:", error);
|
|
1960
1921
|
return [];
|
|
1961
1922
|
}
|
|
1962
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
|
+
};
|
|
1963
1952
|
|
|
1964
1953
|
// src/services/patient/utils/location.utils.ts
|
|
1965
1954
|
var import_firestore7 = require("firebase/firestore");
|
|
@@ -2191,22 +2180,11 @@ var PatientService = class extends BaseService {
|
|
|
2191
2180
|
// Metode za rad sa medicinskim informacijama
|
|
2192
2181
|
async createMedicalInfo(patientId, data) {
|
|
2193
2182
|
const currentUser = await this.getCurrentUser();
|
|
2194
|
-
await createMedicalInfoUtil(
|
|
2195
|
-
this.db,
|
|
2196
|
-
patientId,
|
|
2197
|
-
data,
|
|
2198
|
-
currentUser.uid,
|
|
2199
|
-
currentUser.roles
|
|
2200
|
-
);
|
|
2183
|
+
await createMedicalInfoUtil(this.db, patientId, data, currentUser.uid, currentUser.roles);
|
|
2201
2184
|
}
|
|
2202
2185
|
async getMedicalInfo(patientId) {
|
|
2203
2186
|
const currentUser = await this.getCurrentUser();
|
|
2204
|
-
return getMedicalInfoUtil(
|
|
2205
|
-
this.db,
|
|
2206
|
-
patientId,
|
|
2207
|
-
currentUser.uid,
|
|
2208
|
-
currentUser.roles
|
|
2209
|
-
);
|
|
2187
|
+
return getMedicalInfoUtil(this.db, patientId, currentUser.uid, currentUser.roles);
|
|
2210
2188
|
}
|
|
2211
2189
|
async getMedicalInfoByUserRef(userRef) {
|
|
2212
2190
|
const profile = await this.getPatientProfileByUserRef(userRef);
|
|
@@ -2238,21 +2216,11 @@ var PatientService = class extends BaseService {
|
|
|
2238
2216
|
}
|
|
2239
2217
|
async updateBlockingCondition(patientId, data) {
|
|
2240
2218
|
const currentUser = await this.getCurrentUser();
|
|
2241
|
-
await updateBlockingConditionUtil(
|
|
2242
|
-
this.db,
|
|
2243
|
-
patientId,
|
|
2244
|
-
data,
|
|
2245
|
-
currentUser.uid
|
|
2246
|
-
);
|
|
2219
|
+
await updateBlockingConditionUtil(this.db, patientId, data, currentUser.uid);
|
|
2247
2220
|
}
|
|
2248
2221
|
async removeBlockingCondition(patientId, conditionIndex) {
|
|
2249
2222
|
const currentUser = await this.getCurrentUser();
|
|
2250
|
-
await removeBlockingConditionUtil(
|
|
2251
|
-
this.db,
|
|
2252
|
-
patientId,
|
|
2253
|
-
conditionIndex,
|
|
2254
|
-
currentUser.uid
|
|
2255
|
-
);
|
|
2223
|
+
await removeBlockingConditionUtil(this.db, patientId, conditionIndex, currentUser.uid);
|
|
2256
2224
|
}
|
|
2257
2225
|
// Metode za rad sa kontraindikacijama
|
|
2258
2226
|
async addContraindication(patientId, data) {
|
|
@@ -2265,12 +2233,7 @@ var PatientService = class extends BaseService {
|
|
|
2265
2233
|
}
|
|
2266
2234
|
async removeContraindication(patientId, contraindicationIndex) {
|
|
2267
2235
|
const currentUser = await this.getCurrentUser();
|
|
2268
|
-
await removeContraindicationUtil(
|
|
2269
|
-
this.db,
|
|
2270
|
-
patientId,
|
|
2271
|
-
contraindicationIndex,
|
|
2272
|
-
currentUser.uid
|
|
2273
|
-
);
|
|
2236
|
+
await removeContraindicationUtil(this.db, patientId, contraindicationIndex, currentUser.uid);
|
|
2274
2237
|
}
|
|
2275
2238
|
// Metode za rad sa medikacijama
|
|
2276
2239
|
async addMedication(patientId, data) {
|
|
@@ -2283,12 +2246,7 @@ var PatientService = class extends BaseService {
|
|
|
2283
2246
|
}
|
|
2284
2247
|
async removeMedication(patientId, medicationIndex) {
|
|
2285
2248
|
const currentUser = await this.getCurrentUser();
|
|
2286
|
-
await removeMedicationUtil(
|
|
2287
|
-
this.db,
|
|
2288
|
-
patientId,
|
|
2289
|
-
medicationIndex,
|
|
2290
|
-
currentUser.uid
|
|
2291
|
-
);
|
|
2249
|
+
await removeMedicationUtil(this.db, patientId, medicationIndex, currentUser.uid);
|
|
2292
2250
|
}
|
|
2293
2251
|
// Pomoćne metode
|
|
2294
2252
|
async addExpoToken(patientId, token) {
|
|
@@ -2319,9 +2277,7 @@ var PatientService = class extends BaseService {
|
|
|
2319
2277
|
if (!this.auth.currentUser) {
|
|
2320
2278
|
throw new Error("No authenticated user");
|
|
2321
2279
|
}
|
|
2322
|
-
const userDoc = await (0, import_firestore9.getDoc)(
|
|
2323
|
-
(0, import_firestore9.doc)(this.db, "users", this.auth.currentUser.uid)
|
|
2324
|
-
);
|
|
2280
|
+
const userDoc = await (0, import_firestore9.getDoc)((0, import_firestore9.doc)(this.db, "users", this.auth.currentUser.uid));
|
|
2325
2281
|
if (!userDoc.exists()) {
|
|
2326
2282
|
throw new Error("User not found");
|
|
2327
2283
|
}
|
|
@@ -2388,6 +2344,18 @@ var PatientService = class extends BaseService {
|
|
|
2388
2344
|
);
|
|
2389
2345
|
return searchPatientsUtil(this.db, params, requester);
|
|
2390
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
|
+
}
|
|
2391
2359
|
};
|
|
2392
2360
|
|
|
2393
2361
|
// src/services/clinic/utils/admin.utils.ts
|
|
@@ -3051,7 +3019,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
3051
3019
|
(0, import_firestore11.where)("clinicGroupId", "==", clinicGroupId)
|
|
3052
3020
|
);
|
|
3053
3021
|
const querySnapshot = await (0, import_firestore11.getDocs)(q);
|
|
3054
|
-
return querySnapshot.docs.map((
|
|
3022
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3055
3023
|
}
|
|
3056
3024
|
async function updateClinicAdmin(db, adminId, data) {
|
|
3057
3025
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -3706,7 +3674,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3706
3674
|
(0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
|
|
3707
3675
|
);
|
|
3708
3676
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3709
|
-
return querySnapshot.docs.map((
|
|
3677
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3710
3678
|
}
|
|
3711
3679
|
/**
|
|
3712
3680
|
* Gets a token by its string value and validates it
|
|
@@ -3789,7 +3757,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3789
3757
|
(0, import_firestore13.where)("status", "==", "active" /* ACTIVE */)
|
|
3790
3758
|
);
|
|
3791
3759
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3792
|
-
return querySnapshot.docs.map((
|
|
3760
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3793
3761
|
}
|
|
3794
3762
|
/**
|
|
3795
3763
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -3801,7 +3769,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3801
3769
|
(0, import_firestore13.where)("isActive", "==", true)
|
|
3802
3770
|
);
|
|
3803
3771
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3804
|
-
return querySnapshot.docs.map((
|
|
3772
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3805
3773
|
}
|
|
3806
3774
|
/**
|
|
3807
3775
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -3813,7 +3781,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3813
3781
|
(0, import_firestore13.where)("status", "==", "draft" /* DRAFT */)
|
|
3814
3782
|
);
|
|
3815
3783
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3816
|
-
return querySnapshot.docs.map((
|
|
3784
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
3817
3785
|
}
|
|
3818
3786
|
/**
|
|
3819
3787
|
* Ažurira profil zdravstvenog radnika
|
|
@@ -4122,7 +4090,7 @@ var UserService = class extends BaseService {
|
|
|
4122
4090
|
];
|
|
4123
4091
|
const q = (0, import_firestore14.query)((0, import_firestore14.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
4124
4092
|
const querySnapshot = await (0, import_firestore14.getDocs)(q);
|
|
4125
|
-
const users = querySnapshot.docs.map((
|
|
4093
|
+
const users = querySnapshot.docs.map((doc28) => doc28.data());
|
|
4126
4094
|
return Promise.all(users.map((userData) => userSchema.parse(userData)));
|
|
4127
4095
|
}
|
|
4128
4096
|
/**
|
|
@@ -4486,7 +4454,7 @@ async function getAllActiveGroups(db) {
|
|
|
4486
4454
|
(0, import_firestore15.where)("isActive", "==", true)
|
|
4487
4455
|
);
|
|
4488
4456
|
const querySnapshot = await (0, import_firestore15.getDocs)(q);
|
|
4489
|
-
return querySnapshot.docs.map((
|
|
4457
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
4490
4458
|
}
|
|
4491
4459
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
4492
4460
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -5148,7 +5116,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
5148
5116
|
(0, import_firestore16.where)("isActive", "==", true)
|
|
5149
5117
|
);
|
|
5150
5118
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5151
|
-
return querySnapshot.docs.map((
|
|
5119
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
5152
5120
|
}
|
|
5153
5121
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
5154
5122
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -5360,7 +5328,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
5360
5328
|
}
|
|
5361
5329
|
const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5362
5330
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5363
|
-
return querySnapshot.docs.map((
|
|
5331
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
5364
5332
|
}
|
|
5365
5333
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
5366
5334
|
return getClinicsByAdmin(
|
|
@@ -5502,8 +5470,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
5502
5470
|
}
|
|
5503
5471
|
const q = (0, import_firestore18.query)((0, import_firestore18.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5504
5472
|
const querySnapshot = await (0, import_firestore18.getDocs)(q);
|
|
5505
|
-
for (const
|
|
5506
|
-
const clinic =
|
|
5473
|
+
for (const doc28 of querySnapshot.docs) {
|
|
5474
|
+
const clinic = doc28.data();
|
|
5507
5475
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
5508
5476
|
[center.latitude, center.longitude],
|
|
5509
5477
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -6435,9 +6403,9 @@ var NotificationService = class extends BaseService {
|
|
|
6435
6403
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6436
6404
|
);
|
|
6437
6405
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6438
|
-
return querySnapshot.docs.map((
|
|
6439
|
-
id:
|
|
6440
|
-
...
|
|
6406
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6407
|
+
id: doc28.id,
|
|
6408
|
+
...doc28.data()
|
|
6441
6409
|
}));
|
|
6442
6410
|
}
|
|
6443
6411
|
/**
|
|
@@ -6451,9 +6419,9 @@ var NotificationService = class extends BaseService {
|
|
|
6451
6419
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6452
6420
|
);
|
|
6453
6421
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6454
|
-
return querySnapshot.docs.map((
|
|
6455
|
-
id:
|
|
6456
|
-
...
|
|
6422
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6423
|
+
id: doc28.id,
|
|
6424
|
+
...doc28.data()
|
|
6457
6425
|
}));
|
|
6458
6426
|
}
|
|
6459
6427
|
/**
|
|
@@ -6525,9 +6493,9 @@ var NotificationService = class extends BaseService {
|
|
|
6525
6493
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6526
6494
|
);
|
|
6527
6495
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6528
|
-
return querySnapshot.docs.map((
|
|
6529
|
-
id:
|
|
6530
|
-
...
|
|
6496
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6497
|
+
id: doc28.id,
|
|
6498
|
+
...doc28.data()
|
|
6531
6499
|
}));
|
|
6532
6500
|
}
|
|
6533
6501
|
/**
|
|
@@ -6540,9 +6508,9 @@ var NotificationService = class extends BaseService {
|
|
|
6540
6508
|
(0, import_firestore20.orderBy)("notificationTime", "desc")
|
|
6541
6509
|
);
|
|
6542
6510
|
const querySnapshot = await (0, import_firestore20.getDocs)(q);
|
|
6543
|
-
return querySnapshot.docs.map((
|
|
6544
|
-
id:
|
|
6545
|
-
...
|
|
6511
|
+
return querySnapshot.docs.map((doc28) => ({
|
|
6512
|
+
id: doc28.id,
|
|
6513
|
+
...doc28.data()
|
|
6546
6514
|
}));
|
|
6547
6515
|
}
|
|
6548
6516
|
};
|
|
@@ -6690,7 +6658,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6690
6658
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6691
6659
|
);
|
|
6692
6660
|
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6693
|
-
return snapshot.docs.map((
|
|
6661
|
+
return snapshot.docs.map((doc28) => doc28.data());
|
|
6694
6662
|
}
|
|
6695
6663
|
/**
|
|
6696
6664
|
* Gets all procedures for a practitioner
|
|
@@ -6704,7 +6672,7 @@ var ProcedureService = class extends BaseService {
|
|
|
6704
6672
|
(0, import_firestore21.where)("isActive", "==", true)
|
|
6705
6673
|
);
|
|
6706
6674
|
const snapshot = await (0, import_firestore21.getDocs)(q);
|
|
6707
|
-
return snapshot.docs.map((
|
|
6675
|
+
return snapshot.docs.map((doc28) => doc28.data());
|
|
6708
6676
|
}
|
|
6709
6677
|
/**
|
|
6710
6678
|
* Updates a procedure
|
|
@@ -6884,9 +6852,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6884
6852
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6885
6853
|
const templates = [];
|
|
6886
6854
|
let lastVisible = null;
|
|
6887
|
-
querySnapshot.forEach((
|
|
6888
|
-
templates.push(
|
|
6889
|
-
lastVisible =
|
|
6855
|
+
querySnapshot.forEach((doc28) => {
|
|
6856
|
+
templates.push(doc28.data());
|
|
6857
|
+
lastVisible = doc28;
|
|
6890
6858
|
});
|
|
6891
6859
|
return {
|
|
6892
6860
|
templates,
|
|
@@ -6914,9 +6882,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6914
6882
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6915
6883
|
const templates = [];
|
|
6916
6884
|
let lastVisible = null;
|
|
6917
|
-
querySnapshot.forEach((
|
|
6918
|
-
templates.push(
|
|
6919
|
-
lastVisible =
|
|
6885
|
+
querySnapshot.forEach((doc28) => {
|
|
6886
|
+
templates.push(doc28.data());
|
|
6887
|
+
lastVisible = doc28;
|
|
6920
6888
|
});
|
|
6921
6889
|
return {
|
|
6922
6890
|
templates,
|
|
@@ -6943,9 +6911,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
6943
6911
|
const querySnapshot = await (0, import_firestore22.getDocs)(q);
|
|
6944
6912
|
const templates = [];
|
|
6945
6913
|
let lastVisible = null;
|
|
6946
|
-
querySnapshot.forEach((
|
|
6947
|
-
templates.push(
|
|
6948
|
-
lastVisible =
|
|
6914
|
+
querySnapshot.forEach((doc28) => {
|
|
6915
|
+
templates.push(doc28.data());
|
|
6916
|
+
lastVisible = doc28;
|
|
6949
6917
|
});
|
|
6950
6918
|
return {
|
|
6951
6919
|
templates,
|
|
@@ -7058,9 +7026,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7058
7026
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7059
7027
|
const documents = [];
|
|
7060
7028
|
let lastVisible = null;
|
|
7061
|
-
querySnapshot.forEach((
|
|
7062
|
-
documents.push(
|
|
7063
|
-
lastVisible =
|
|
7029
|
+
querySnapshot.forEach((doc28) => {
|
|
7030
|
+
documents.push(doc28.data());
|
|
7031
|
+
lastVisible = doc28;
|
|
7064
7032
|
});
|
|
7065
7033
|
return {
|
|
7066
7034
|
documents,
|
|
@@ -7087,9 +7055,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7087
7055
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7088
7056
|
const documents = [];
|
|
7089
7057
|
let lastVisible = null;
|
|
7090
|
-
querySnapshot.forEach((
|
|
7091
|
-
documents.push(
|
|
7092
|
-
lastVisible =
|
|
7058
|
+
querySnapshot.forEach((doc28) => {
|
|
7059
|
+
documents.push(doc28.data());
|
|
7060
|
+
lastVisible = doc28;
|
|
7093
7061
|
});
|
|
7094
7062
|
return {
|
|
7095
7063
|
documents,
|
|
@@ -7116,9 +7084,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7116
7084
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7117
7085
|
const documents = [];
|
|
7118
7086
|
let lastVisible = null;
|
|
7119
|
-
querySnapshot.forEach((
|
|
7120
|
-
documents.push(
|
|
7121
|
-
lastVisible =
|
|
7087
|
+
querySnapshot.forEach((doc28) => {
|
|
7088
|
+
documents.push(doc28.data());
|
|
7089
|
+
lastVisible = doc28;
|
|
7122
7090
|
});
|
|
7123
7091
|
return {
|
|
7124
7092
|
documents,
|
|
@@ -7145,9 +7113,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7145
7113
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7146
7114
|
const documents = [];
|
|
7147
7115
|
let lastVisible = null;
|
|
7148
|
-
querySnapshot.forEach((
|
|
7149
|
-
documents.push(
|
|
7150
|
-
lastVisible =
|
|
7116
|
+
querySnapshot.forEach((doc28) => {
|
|
7117
|
+
documents.push(doc28.data());
|
|
7118
|
+
lastVisible = doc28;
|
|
7151
7119
|
});
|
|
7152
7120
|
return {
|
|
7153
7121
|
documents,
|
|
@@ -7174,9 +7142,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7174
7142
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7175
7143
|
const documents = [];
|
|
7176
7144
|
let lastVisible = null;
|
|
7177
|
-
querySnapshot.forEach((
|
|
7178
|
-
documents.push(
|
|
7179
|
-
lastVisible =
|
|
7145
|
+
querySnapshot.forEach((doc28) => {
|
|
7146
|
+
documents.push(doc28.data());
|
|
7147
|
+
lastVisible = doc28;
|
|
7180
7148
|
});
|
|
7181
7149
|
return {
|
|
7182
7150
|
documents,
|
|
@@ -7649,7 +7617,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
7649
7617
|
"Clinic ID (entityId) is required when searching clinic-related events."
|
|
7650
7618
|
);
|
|
7651
7619
|
}
|
|
7652
|
-
baseCollectionPath = CALENDAR_COLLECTION
|
|
7620
|
+
baseCollectionPath = `${CLINICS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
7653
7621
|
constraints.push((0, import_firestore30.where)("clinicBranchId", "==", entityId));
|
|
7654
7622
|
if (filters.clinicId && filters.clinicId !== entityId) {
|
|
7655
7623
|
console.warn(
|
|
@@ -7691,7 +7659,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
7691
7659
|
const finalQuery = (0, import_firestore30.query)(collectionRef, ...constraints);
|
|
7692
7660
|
const querySnapshot = await (0, import_firestore30.getDocs)(finalQuery);
|
|
7693
7661
|
const events = querySnapshot.docs.map(
|
|
7694
|
-
(
|
|
7662
|
+
(doc28) => ({ id: doc28.id, ...doc28.data() })
|
|
7695
7663
|
);
|
|
7696
7664
|
return events;
|
|
7697
7665
|
} catch (error) {
|
|
@@ -7773,7 +7741,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
7773
7741
|
);
|
|
7774
7742
|
const q = (0, import_firestore31.query)(calendarsRef, (0, import_firestore31.orderBy)("createdAt", "desc"));
|
|
7775
7743
|
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
7776
|
-
return querySnapshot.docs.map((
|
|
7744
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
7777
7745
|
}
|
|
7778
7746
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
7779
7747
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -7790,7 +7758,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
7790
7758
|
);
|
|
7791
7759
|
const q = (0, import_firestore31.query)(calendarsRef, (0, import_firestore31.orderBy)("createdAt", "desc"));
|
|
7792
7760
|
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
7793
|
-
return querySnapshot.docs.map((
|
|
7761
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
7794
7762
|
}
|
|
7795
7763
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
7796
7764
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -7807,7 +7775,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
7807
7775
|
);
|
|
7808
7776
|
const q = (0, import_firestore31.query)(calendarsRef, (0, import_firestore31.orderBy)("createdAt", "desc"));
|
|
7809
7777
|
const querySnapshot = await (0, import_firestore31.getDocs)(q);
|
|
7810
|
-
return querySnapshot.docs.map((
|
|
7778
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
7811
7779
|
}
|
|
7812
7780
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
7813
7781
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -9162,9 +9130,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9162
9130
|
(0, import_firestore34.where)("eventTime.start", "<=", import_firestore33.Timestamp.fromDate(endDate))
|
|
9163
9131
|
);
|
|
9164
9132
|
const eventsSnapshot = await (0, import_firestore34.getDocs)(q);
|
|
9165
|
-
const events = eventsSnapshot.docs.map((
|
|
9166
|
-
id:
|
|
9167
|
-
...
|
|
9133
|
+
const events = eventsSnapshot.docs.map((doc28) => ({
|
|
9134
|
+
id: doc28.id,
|
|
9135
|
+
...doc28.data()
|
|
9168
9136
|
}));
|
|
9169
9137
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
9170
9138
|
doctorId
|
|
@@ -9793,7 +9761,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9793
9761
|
])
|
|
9794
9762
|
);
|
|
9795
9763
|
const querySnapshot = await (0, import_firestore34.getDocs)(q);
|
|
9796
|
-
return querySnapshot.docs.map((
|
|
9764
|
+
return querySnapshot.docs.map((doc28) => doc28.data());
|
|
9797
9765
|
}
|
|
9798
9766
|
/**
|
|
9799
9767
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -9952,9 +9920,9 @@ var BrandService = class extends BaseService {
|
|
|
9952
9920
|
const q = (0, import_firestore35.query)(this.getBrandsRef(), (0, import_firestore35.where)("isActive", "==", true));
|
|
9953
9921
|
const snapshot = await (0, import_firestore35.getDocs)(q);
|
|
9954
9922
|
return snapshot.docs.map(
|
|
9955
|
-
(
|
|
9956
|
-
id:
|
|
9957
|
-
...
|
|
9923
|
+
(doc28) => ({
|
|
9924
|
+
id: doc28.id,
|
|
9925
|
+
...doc28.data()
|
|
9958
9926
|
})
|
|
9959
9927
|
);
|
|
9960
9928
|
}
|
|
@@ -10030,9 +9998,9 @@ var CategoryService = class extends BaseService {
|
|
|
10030
9998
|
const q = (0, import_firestore36.query)(this.categoriesRef, (0, import_firestore36.where)("isActive", "==", true));
|
|
10031
9999
|
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
10032
10000
|
return snapshot.docs.map(
|
|
10033
|
-
(
|
|
10034
|
-
id:
|
|
10035
|
-
...
|
|
10001
|
+
(doc28) => ({
|
|
10002
|
+
id: doc28.id,
|
|
10003
|
+
...doc28.data()
|
|
10036
10004
|
})
|
|
10037
10005
|
);
|
|
10038
10006
|
}
|
|
@@ -10049,9 +10017,9 @@ var CategoryService = class extends BaseService {
|
|
|
10049
10017
|
);
|
|
10050
10018
|
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
10051
10019
|
return snapshot.docs.map(
|
|
10052
|
-
(
|
|
10053
|
-
id:
|
|
10054
|
-
...
|
|
10020
|
+
(doc28) => ({
|
|
10021
|
+
id: doc28.id,
|
|
10022
|
+
...doc28.data()
|
|
10055
10023
|
})
|
|
10056
10024
|
);
|
|
10057
10025
|
}
|
|
@@ -10146,9 +10114,9 @@ var SubcategoryService = class extends BaseService {
|
|
|
10146
10114
|
);
|
|
10147
10115
|
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
10148
10116
|
return snapshot.docs.map(
|
|
10149
|
-
(
|
|
10150
|
-
id:
|
|
10151
|
-
...
|
|
10117
|
+
(doc28) => ({
|
|
10118
|
+
id: doc28.id,
|
|
10119
|
+
...doc28.data()
|
|
10152
10120
|
})
|
|
10153
10121
|
);
|
|
10154
10122
|
}
|
|
@@ -10243,9 +10211,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10243
10211
|
const q = (0, import_firestore38.query)(this.getTechnologiesRef(), (0, import_firestore38.where)("isActive", "==", true));
|
|
10244
10212
|
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
10245
10213
|
return snapshot.docs.map(
|
|
10246
|
-
(
|
|
10247
|
-
id:
|
|
10248
|
-
...
|
|
10214
|
+
(doc28) => ({
|
|
10215
|
+
id: doc28.id,
|
|
10216
|
+
...doc28.data()
|
|
10249
10217
|
})
|
|
10250
10218
|
);
|
|
10251
10219
|
}
|
|
@@ -10262,9 +10230,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10262
10230
|
);
|
|
10263
10231
|
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
10264
10232
|
return snapshot.docs.map(
|
|
10265
|
-
(
|
|
10266
|
-
id:
|
|
10267
|
-
...
|
|
10233
|
+
(doc28) => ({
|
|
10234
|
+
id: doc28.id,
|
|
10235
|
+
...doc28.data()
|
|
10268
10236
|
})
|
|
10269
10237
|
);
|
|
10270
10238
|
}
|
|
@@ -10281,9 +10249,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10281
10249
|
);
|
|
10282
10250
|
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
10283
10251
|
return snapshot.docs.map(
|
|
10284
|
-
(
|
|
10285
|
-
id:
|
|
10286
|
-
...
|
|
10252
|
+
(doc28) => ({
|
|
10253
|
+
id: doc28.id,
|
|
10254
|
+
...doc28.data()
|
|
10287
10255
|
})
|
|
10288
10256
|
);
|
|
10289
10257
|
}
|
|
@@ -10300,9 +10268,9 @@ var TechnologyService = class extends BaseService {
|
|
|
10300
10268
|
);
|
|
10301
10269
|
const snapshot = await (0, import_firestore38.getDocs)(q);
|
|
10302
10270
|
return snapshot.docs.map(
|
|
10303
|
-
(
|
|
10304
|
-
id:
|
|
10305
|
-
...
|
|
10271
|
+
(doc28) => ({
|
|
10272
|
+
id: doc28.id,
|
|
10273
|
+
...doc28.data()
|
|
10306
10274
|
})
|
|
10307
10275
|
);
|
|
10308
10276
|
}
|
|
@@ -10667,9 +10635,9 @@ var ProductService = class extends BaseService {
|
|
|
10667
10635
|
);
|
|
10668
10636
|
const snapshot = await (0, import_firestore39.getDocs)(q);
|
|
10669
10637
|
return snapshot.docs.map(
|
|
10670
|
-
(
|
|
10671
|
-
id:
|
|
10672
|
-
...
|
|
10638
|
+
(doc28) => ({
|
|
10639
|
+
id: doc28.id,
|
|
10640
|
+
...doc28.data()
|
|
10673
10641
|
})
|
|
10674
10642
|
);
|
|
10675
10643
|
}
|
|
@@ -10689,9 +10657,9 @@ var ProductService = class extends BaseService {
|
|
|
10689
10657
|
const snapshot = await (0, import_firestore39.getDocs)(q);
|
|
10690
10658
|
products.push(
|
|
10691
10659
|
...snapshot.docs.map(
|
|
10692
|
-
(
|
|
10693
|
-
id:
|
|
10694
|
-
...
|
|
10660
|
+
(doc28) => ({
|
|
10661
|
+
id: doc28.id,
|
|
10662
|
+
...doc28.data()
|
|
10695
10663
|
})
|
|
10696
10664
|
)
|
|
10697
10665
|
);
|
|
@@ -10850,6 +10818,7 @@ var notificationSchema = import_zod19.z.discriminatedUnion("notificationType", [
|
|
|
10850
10818
|
ProductService,
|
|
10851
10819
|
REGISTER_TOKENS_COLLECTION,
|
|
10852
10820
|
SYNCED_CALENDARS_COLLECTION,
|
|
10821
|
+
SearchLocationEnum,
|
|
10853
10822
|
SubcategoryService,
|
|
10854
10823
|
SubscriptionModel,
|
|
10855
10824
|
SyncedCalendarProvider,
|