@blackcode_sa/metaestetics-api 1.12.6 → 1.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/index.d.mts +51 -33
- package/dist/admin/index.d.ts +51 -33
- package/dist/index.d.mts +149 -34
- package/dist/index.d.ts +149 -34
- package/dist/index.js +1073 -924
- package/dist/index.mjs +833 -677
- package/package.json +1 -2
- package/src/services/clinic/billing-transactions.service.ts +217 -0
- package/src/services/clinic/clinic-group.service.ts +99 -102
- package/src/services/clinic/index.ts +5 -4
- package/src/types/clinic/preferences.types.ts +115 -97
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
AuthService: () => AuthService,
|
|
39
39
|
BaseService: () => BaseService,
|
|
40
40
|
BillingTransactionType: () => BillingTransactionType,
|
|
41
|
+
BillingTransactionsService: () => BillingTransactionsService,
|
|
41
42
|
BlockingCondition: () => BlockingCondition,
|
|
42
43
|
BrandService: () => BrandService,
|
|
43
44
|
CALENDAR_COLLECTION: () => CALENDAR_COLLECTION,
|
|
@@ -793,49 +794,67 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
|
793
794
|
var ClinicTag = /* @__PURE__ */ ((ClinicTag6) => {
|
|
794
795
|
ClinicTag6["PARKING"] = "parking";
|
|
795
796
|
ClinicTag6["WIFI"] = "wifi";
|
|
796
|
-
ClinicTag6["
|
|
797
|
-
ClinicTag6["
|
|
798
|
-
ClinicTag6["
|
|
799
|
-
ClinicTag6["
|
|
797
|
+
ClinicTag6["LUXURY_WAITING"] = "luxury_waiting";
|
|
798
|
+
ClinicTag6["REFRESHMENTS"] = "refreshments";
|
|
799
|
+
ClinicTag6["PRIVATE_ROOMS"] = "private_rooms";
|
|
800
|
+
ClinicTag6["RECOVERY_AREA"] = "recovery_area";
|
|
800
801
|
ClinicTag6["CARD_PAYMENT"] = "card_payment";
|
|
801
|
-
ClinicTag6["
|
|
802
|
-
ClinicTag6["
|
|
803
|
-
ClinicTag6["
|
|
804
|
-
ClinicTag6["
|
|
805
|
-
ClinicTag6["
|
|
806
|
-
ClinicTag6["
|
|
807
|
-
ClinicTag6["
|
|
808
|
-
ClinicTag6["
|
|
809
|
-
ClinicTag6["
|
|
810
|
-
ClinicTag6["
|
|
811
|
-
ClinicTag6["
|
|
812
|
-
ClinicTag6["
|
|
813
|
-
ClinicTag6["
|
|
814
|
-
ClinicTag6["
|
|
815
|
-
ClinicTag6["
|
|
816
|
-
ClinicTag6["
|
|
817
|
-
ClinicTag6["
|
|
818
|
-
ClinicTag6["
|
|
819
|
-
ClinicTag6["
|
|
820
|
-
ClinicTag6["
|
|
821
|
-
ClinicTag6["
|
|
822
|
-
ClinicTag6["
|
|
823
|
-
ClinicTag6["
|
|
824
|
-
ClinicTag6["
|
|
802
|
+
ClinicTag6["FINANCING"] = "financing";
|
|
803
|
+
ClinicTag6["FREE_CONSULTATION"] = "free_consultation";
|
|
804
|
+
ClinicTag6["VIRTUAL_CONSULTATION"] = "virtual_consultation";
|
|
805
|
+
ClinicTag6["BEFORE_AFTER_PHOTOS"] = "before_after_photos";
|
|
806
|
+
ClinicTag6["AFTERCARE_SUPPORT"] = "aftercare_support";
|
|
807
|
+
ClinicTag6["BOTOX"] = "botox";
|
|
808
|
+
ClinicTag6["DERMAL_FILLERS"] = "dermal_fillers";
|
|
809
|
+
ClinicTag6["LASER_HAIR_REMOVAL"] = "laser_hair_removal";
|
|
810
|
+
ClinicTag6["LASER_SKIN_RESURFACING"] = "laser_skin_resurfacing";
|
|
811
|
+
ClinicTag6["CHEMICAL_PEELS"] = "chemical_peels";
|
|
812
|
+
ClinicTag6["MICRONEEDLING"] = "microneedling";
|
|
813
|
+
ClinicTag6["COOLSCULPTING"] = "coolsculpting";
|
|
814
|
+
ClinicTag6["THREAD_LIFT"] = "thread_lift";
|
|
815
|
+
ClinicTag6["LIP_ENHANCEMENT"] = "lip_enhancement";
|
|
816
|
+
ClinicTag6["RHINOPLASTY"] = "rhinoplasty";
|
|
817
|
+
ClinicTag6["SKIN_TIGHTENING"] = "skin_tightening";
|
|
818
|
+
ClinicTag6["FAT_DISSOLVING"] = "fat_dissolving";
|
|
819
|
+
ClinicTag6["PRP_TREATMENT"] = "prp_treatment";
|
|
820
|
+
ClinicTag6["HYDRAFACIAL"] = "hydrafacial";
|
|
821
|
+
ClinicTag6["IPL_PHOTOFACIAL"] = "ipl_photofacial";
|
|
822
|
+
ClinicTag6["BODY_CONTOURING"] = "body_contouring";
|
|
823
|
+
ClinicTag6["FACELIFT"] = "facelift";
|
|
824
|
+
ClinicTag6["RHINOPLASTY_SURGICAL"] = "rhinoplasty_surgical";
|
|
825
|
+
ClinicTag6["BREAST_AUGMENTATION"] = "breast_augmentation";
|
|
826
|
+
ClinicTag6["BREAST_REDUCTION"] = "breast_reduction";
|
|
827
|
+
ClinicTag6["BREAST_LIFT"] = "breast_lift";
|
|
828
|
+
ClinicTag6["TUMMY_TUCK"] = "tummy_tuck";
|
|
829
|
+
ClinicTag6["LIPOSUCTION"] = "liposuction";
|
|
830
|
+
ClinicTag6["BBL"] = "bbl";
|
|
831
|
+
ClinicTag6["MOMMY_MAKEOVER"] = "mommy_makeover";
|
|
832
|
+
ClinicTag6["ARM_LIFT"] = "arm_lift";
|
|
833
|
+
ClinicTag6["THIGH_LIFT"] = "thigh_lift";
|
|
834
|
+
ClinicTag6["EYELID_SURGERY"] = "eyelid_surgery";
|
|
835
|
+
ClinicTag6["BROW_LIFT"] = "brow_lift";
|
|
836
|
+
ClinicTag6["NECK_LIFT"] = "neck_lift";
|
|
837
|
+
ClinicTag6["OTOPLASTY"] = "otoplasty";
|
|
838
|
+
ClinicTag6["LABIAPLASTY"] = "labiaplasty";
|
|
825
839
|
ClinicTag6["ONLINE_BOOKING"] = "online_booking";
|
|
826
840
|
ClinicTag6["MOBILE_APP"] = "mobile_app";
|
|
827
841
|
ClinicTag6["SMS_NOTIFICATIONS"] = "sms_notifications";
|
|
828
842
|
ClinicTag6["EMAIL_NOTIFICATIONS"] = "email_notifications";
|
|
843
|
+
ClinicTag6["VIRTUAL_TRY_ON"] = "virtual_try_on";
|
|
844
|
+
ClinicTag6["SKIN_ANALYSIS"] = "skin_analysis";
|
|
845
|
+
ClinicTag6["TREATMENT_TRACKING"] = "treatment_tracking";
|
|
846
|
+
ClinicTag6["LOYALTY_PROGRAM"] = "loyalty_program";
|
|
829
847
|
ClinicTag6["ENGLISH"] = "english";
|
|
830
|
-
ClinicTag6["SERBIAN"] = "serbian";
|
|
831
848
|
ClinicTag6["GERMAN"] = "german";
|
|
832
|
-
ClinicTag6["RUSSIAN"] = "russian";
|
|
833
|
-
ClinicTag6["CHINESE"] = "chinese";
|
|
834
|
-
ClinicTag6["SPANISH"] = "spanish";
|
|
835
849
|
ClinicTag6["FRENCH"] = "french";
|
|
850
|
+
ClinicTag6["SPANISH"] = "spanish";
|
|
851
|
+
ClinicTag6["ITALIAN"] = "italian";
|
|
852
|
+
ClinicTag6["DUTCH"] = "dutch";
|
|
853
|
+
ClinicTag6["RUSSIAN"] = "russian";
|
|
854
|
+
ClinicTag6["PORTUGUESE"] = "portuguese";
|
|
836
855
|
ClinicTag6["OPEN_24_7"] = "open_24_7";
|
|
837
856
|
ClinicTag6["WEEKEND_HOURS"] = "weekend_hours";
|
|
838
|
-
ClinicTag6["
|
|
857
|
+
ClinicTag6["EXTENDED_HOURS"] = "extended_hours";
|
|
839
858
|
ClinicTag6["HOLIDAY_HOURS"] = "holiday_hours";
|
|
840
859
|
return ClinicTag6;
|
|
841
860
|
})(ClinicTag || {});
|
|
@@ -2021,7 +2040,7 @@ var AppointmentService = class extends BaseService {
|
|
|
2021
2040
|
|
|
2022
2041
|
// src/services/auth/auth.service.ts
|
|
2023
2042
|
var import_auth7 = require("firebase/auth");
|
|
2024
|
-
var
|
|
2043
|
+
var import_firestore29 = require("firebase/firestore");
|
|
2025
2044
|
|
|
2026
2045
|
// src/types/user/index.ts
|
|
2027
2046
|
var UserRole = /* @__PURE__ */ ((UserRole2) => {
|
|
@@ -7784,8 +7803,143 @@ var UserService = class extends BaseService {
|
|
|
7784
7803
|
}
|
|
7785
7804
|
};
|
|
7786
7805
|
|
|
7787
|
-
// src/services/clinic/
|
|
7806
|
+
// src/services/clinic/billing-transactions.service.ts
|
|
7788
7807
|
var import_firestore23 = require("firebase/firestore");
|
|
7808
|
+
var BillingTransactionsService = class extends BaseService {
|
|
7809
|
+
constructor() {
|
|
7810
|
+
super(...arguments);
|
|
7811
|
+
this.BILLING_TRANSACTIONS_COLLECTION = "billingTransactions";
|
|
7812
|
+
}
|
|
7813
|
+
/**
|
|
7814
|
+
* Get billing transactions for a clinic group with pagination
|
|
7815
|
+
* @param clinicGroupId - The clinic group ID
|
|
7816
|
+
* @param options - Query options
|
|
7817
|
+
* @returns Promise with transactions and pagination info
|
|
7818
|
+
*/
|
|
7819
|
+
async getBillingTransactions(clinicGroupId, options = {}) {
|
|
7820
|
+
try {
|
|
7821
|
+
const { limit: queryLimit = 50, startAfter: startAfterDoc, transactionType } = options;
|
|
7822
|
+
const constraints = [];
|
|
7823
|
+
if (transactionType) {
|
|
7824
|
+
constraints.push((0, import_firestore23.where)("type", "==", transactionType));
|
|
7825
|
+
}
|
|
7826
|
+
constraints.push((0, import_firestore23.orderBy)("timestamp", "desc"));
|
|
7827
|
+
if (startAfterDoc) {
|
|
7828
|
+
constraints.push((0, import_firestore23.startAfter)(startAfterDoc));
|
|
7829
|
+
}
|
|
7830
|
+
constraints.push((0, import_firestore23.limit)(queryLimit + 1));
|
|
7831
|
+
const transactionsRef = (0, import_firestore23.collection)(
|
|
7832
|
+
this.db,
|
|
7833
|
+
CLINIC_GROUPS_COLLECTION,
|
|
7834
|
+
clinicGroupId,
|
|
7835
|
+
this.BILLING_TRANSACTIONS_COLLECTION
|
|
7836
|
+
);
|
|
7837
|
+
const q = (0, import_firestore23.query)(transactionsRef, ...constraints);
|
|
7838
|
+
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7839
|
+
const docs = querySnapshot.docs;
|
|
7840
|
+
const hasMore = docs.length > queryLimit;
|
|
7841
|
+
const transactions = docs.slice(0, queryLimit).map((doc38) => ({
|
|
7842
|
+
id: doc38.id,
|
|
7843
|
+
...doc38.data()
|
|
7844
|
+
}));
|
|
7845
|
+
const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
|
|
7846
|
+
return {
|
|
7847
|
+
transactions,
|
|
7848
|
+
lastDoc,
|
|
7849
|
+
hasMore
|
|
7850
|
+
};
|
|
7851
|
+
} catch (error) {
|
|
7852
|
+
console.error(
|
|
7853
|
+
`Error fetching billing transactions for clinic group ${clinicGroupId}:`,
|
|
7854
|
+
error
|
|
7855
|
+
);
|
|
7856
|
+
throw new Error(
|
|
7857
|
+
`Failed to fetch billing transactions: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
7858
|
+
);
|
|
7859
|
+
}
|
|
7860
|
+
}
|
|
7861
|
+
/**
|
|
7862
|
+
* Get recent billing transactions (last 10)
|
|
7863
|
+
* @param clinicGroupId - The clinic group ID
|
|
7864
|
+
* @returns Promise with recent transactions
|
|
7865
|
+
*/
|
|
7866
|
+
async getRecentBillingTransactions(clinicGroupId) {
|
|
7867
|
+
const result = await this.getBillingTransactions(clinicGroupId, { limit: 10 });
|
|
7868
|
+
return result.transactions;
|
|
7869
|
+
}
|
|
7870
|
+
/**
|
|
7871
|
+
* Get billing transactions by type
|
|
7872
|
+
* @param clinicGroupId - The clinic group ID
|
|
7873
|
+
* @param transactionType - The transaction type to filter by
|
|
7874
|
+
* @param options - Additional query options
|
|
7875
|
+
* @returns Promise with filtered transactions
|
|
7876
|
+
*/
|
|
7877
|
+
async getBillingTransactionsByType(clinicGroupId, transactionType, options = {}) {
|
|
7878
|
+
return this.getBillingTransactions(clinicGroupId, {
|
|
7879
|
+
...options,
|
|
7880
|
+
transactionType
|
|
7881
|
+
});
|
|
7882
|
+
}
|
|
7883
|
+
/**
|
|
7884
|
+
* Get subscription-related transactions only
|
|
7885
|
+
* @param clinicGroupId - The clinic group ID
|
|
7886
|
+
* @param options - Query options
|
|
7887
|
+
* @returns Promise with subscription transactions
|
|
7888
|
+
*/
|
|
7889
|
+
async getSubscriptionTransactions(clinicGroupId, options = {}) {
|
|
7890
|
+
try {
|
|
7891
|
+
const { limit: queryLimit = 50, startAfter: startAfterDoc } = options;
|
|
7892
|
+
const subscriptionTypes = [
|
|
7893
|
+
"subscription_created" /* SUBSCRIPTION_CREATED */,
|
|
7894
|
+
"subscription_activated" /* SUBSCRIPTION_ACTIVATED */,
|
|
7895
|
+
"subscription_renewed" /* SUBSCRIPTION_RENEWED */,
|
|
7896
|
+
"subscription_updated" /* SUBSCRIPTION_UPDATED */,
|
|
7897
|
+
"subscription_canceled" /* SUBSCRIPTION_CANCELED */,
|
|
7898
|
+
"subscription_reactivated" /* SUBSCRIPTION_REACTIVATED */,
|
|
7899
|
+
"subscription_deleted" /* SUBSCRIPTION_DELETED */
|
|
7900
|
+
];
|
|
7901
|
+
const constraints = [
|
|
7902
|
+
(0, import_firestore23.where)("type", "in", subscriptionTypes),
|
|
7903
|
+
(0, import_firestore23.orderBy)("timestamp", "desc")
|
|
7904
|
+
];
|
|
7905
|
+
if (startAfterDoc) {
|
|
7906
|
+
constraints.push((0, import_firestore23.startAfter)(startAfterDoc));
|
|
7907
|
+
}
|
|
7908
|
+
constraints.push((0, import_firestore23.limit)(queryLimit + 1));
|
|
7909
|
+
const transactionsRef = (0, import_firestore23.collection)(
|
|
7910
|
+
this.db,
|
|
7911
|
+
CLINIC_GROUPS_COLLECTION,
|
|
7912
|
+
clinicGroupId,
|
|
7913
|
+
this.BILLING_TRANSACTIONS_COLLECTION
|
|
7914
|
+
);
|
|
7915
|
+
const q = (0, import_firestore23.query)(transactionsRef, ...constraints);
|
|
7916
|
+
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7917
|
+
const docs = querySnapshot.docs;
|
|
7918
|
+
const hasMore = docs.length > queryLimit;
|
|
7919
|
+
const transactions = docs.slice(0, queryLimit).map((doc38) => ({
|
|
7920
|
+
id: doc38.id,
|
|
7921
|
+
...doc38.data()
|
|
7922
|
+
}));
|
|
7923
|
+
const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
|
|
7924
|
+
return {
|
|
7925
|
+
transactions,
|
|
7926
|
+
lastDoc,
|
|
7927
|
+
hasMore
|
|
7928
|
+
};
|
|
7929
|
+
} catch (error) {
|
|
7930
|
+
console.error(
|
|
7931
|
+
`Error fetching subscription transactions for clinic group ${clinicGroupId}:`,
|
|
7932
|
+
error
|
|
7933
|
+
);
|
|
7934
|
+
throw new Error(
|
|
7935
|
+
`Failed to fetch subscription transactions: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
7936
|
+
);
|
|
7937
|
+
}
|
|
7938
|
+
}
|
|
7939
|
+
};
|
|
7940
|
+
|
|
7941
|
+
// src/services/clinic/utils/clinic-group.utils.ts
|
|
7942
|
+
var import_firestore24 = require("firebase/firestore");
|
|
7789
7943
|
var import_geofire_common3 = require("geofire-common");
|
|
7790
7944
|
var import_zod18 = require("zod");
|
|
7791
7945
|
|
|
@@ -7902,9 +8056,9 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
7902
8056
|
throw geohashError;
|
|
7903
8057
|
}
|
|
7904
8058
|
}
|
|
7905
|
-
const now =
|
|
8059
|
+
const now = import_firestore24.Timestamp.now();
|
|
7906
8060
|
console.log("[CLINIC_GROUP] Preparing clinic group data object");
|
|
7907
|
-
const groupId = (0,
|
|
8061
|
+
const groupId = (0, import_firestore24.doc)((0, import_firestore24.collection)(db, CLINIC_GROUPS_COLLECTION)).id;
|
|
7908
8062
|
console.log("[CLINIC_GROUP] Logo value:", {
|
|
7909
8063
|
logoValue: validatedData.logo,
|
|
7910
8064
|
logoType: validatedData.logo === null ? "null" : typeof validatedData.logo
|
|
@@ -7954,7 +8108,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
7954
8108
|
groupId: groupData.id
|
|
7955
8109
|
});
|
|
7956
8110
|
try {
|
|
7957
|
-
await (0,
|
|
8111
|
+
await (0, import_firestore24.setDoc)((0, import_firestore24.doc)(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
|
|
7958
8112
|
console.log("[CLINIC_GROUP] Clinic group saved successfully");
|
|
7959
8113
|
} catch (firestoreError) {
|
|
7960
8114
|
console.error(
|
|
@@ -8000,19 +8154,19 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
8000
8154
|
}
|
|
8001
8155
|
}
|
|
8002
8156
|
async function getClinicGroup(db, groupId) {
|
|
8003
|
-
const docRef = (0,
|
|
8004
|
-
const docSnap = await (0,
|
|
8157
|
+
const docRef = (0, import_firestore24.doc)(db, CLINIC_GROUPS_COLLECTION, groupId);
|
|
8158
|
+
const docSnap = await (0, import_firestore24.getDoc)(docRef);
|
|
8005
8159
|
if (docSnap.exists()) {
|
|
8006
8160
|
return docSnap.data();
|
|
8007
8161
|
}
|
|
8008
8162
|
return null;
|
|
8009
8163
|
}
|
|
8010
8164
|
async function getAllActiveGroups(db) {
|
|
8011
|
-
const q = (0,
|
|
8012
|
-
(0,
|
|
8013
|
-
(0,
|
|
8165
|
+
const q = (0, import_firestore24.query)(
|
|
8166
|
+
(0, import_firestore24.collection)(db, CLINIC_GROUPS_COLLECTION),
|
|
8167
|
+
(0, import_firestore24.where)("isActive", "==", true)
|
|
8014
8168
|
);
|
|
8015
|
-
const querySnapshot = await (0,
|
|
8169
|
+
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
8016
8170
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
8017
8171
|
}
|
|
8018
8172
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
@@ -8041,10 +8195,10 @@ async function updateClinicGroup(db, groupId, data, app) {
|
|
|
8041
8195
|
}
|
|
8042
8196
|
updatedData = {
|
|
8043
8197
|
...updatedData,
|
|
8044
|
-
updatedAt:
|
|
8198
|
+
updatedAt: import_firestore24.Timestamp.now()
|
|
8045
8199
|
};
|
|
8046
8200
|
console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
|
|
8047
|
-
await (0,
|
|
8201
|
+
await (0, import_firestore24.updateDoc)((0, import_firestore24.doc)(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
|
|
8048
8202
|
console.log("[CLINIC_GROUP] Clinic group updated successfully");
|
|
8049
8203
|
const updatedGroup = await getClinicGroup(db, groupId);
|
|
8050
8204
|
if (!updatedGroup) {
|
|
@@ -8125,10 +8279,10 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
|
8125
8279
|
if (!group.admins.includes(creatorAdminId)) {
|
|
8126
8280
|
throw new Error("Admin does not belong to this clinic group");
|
|
8127
8281
|
}
|
|
8128
|
-
const now =
|
|
8282
|
+
const now = import_firestore24.Timestamp.now();
|
|
8129
8283
|
const expiresInDays = (data == null ? void 0 : data.expiresInDays) || 7;
|
|
8130
8284
|
const email = (data == null ? void 0 : data.email) || null;
|
|
8131
|
-
const expiresAt = new
|
|
8285
|
+
const expiresAt = new import_firestore24.Timestamp(
|
|
8132
8286
|
now.seconds + expiresInDays * 24 * 60 * 60,
|
|
8133
8287
|
now.nanoseconds
|
|
8134
8288
|
);
|
|
@@ -8162,7 +8316,7 @@ async function verifyAndUseAdminToken(db, groupId, token, userRef, app) {
|
|
|
8162
8316
|
if (adminToken.status !== "active" /* ACTIVE */) {
|
|
8163
8317
|
throw new Error("Admin token is not active");
|
|
8164
8318
|
}
|
|
8165
|
-
const now =
|
|
8319
|
+
const now = import_firestore24.Timestamp.now();
|
|
8166
8320
|
if (adminToken.expiresAt.seconds < now.seconds) {
|
|
8167
8321
|
const updatedTokens2 = group.adminTokens.map(
|
|
8168
8322
|
(t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
|
|
@@ -8228,6 +8382,7 @@ var ClinicGroupService = class extends BaseService {
|
|
|
8228
8382
|
constructor(db, auth, app, clinicAdminService) {
|
|
8229
8383
|
super(db, auth, app);
|
|
8230
8384
|
this.clinicAdminService = clinicAdminService;
|
|
8385
|
+
this.billingTransactionsService = new BillingTransactionsService(db, auth, app);
|
|
8231
8386
|
}
|
|
8232
8387
|
/**
|
|
8233
8388
|
* Kreira novu grupaciju klinika
|
|
@@ -8264,23 +8419,13 @@ var ClinicGroupService = class extends BaseService {
|
|
|
8264
8419
|
* Dodaje admina u grupaciju
|
|
8265
8420
|
*/
|
|
8266
8421
|
async addAdminToGroup(groupId, adminId) {
|
|
8267
|
-
return addAdminToGroup(
|
|
8268
|
-
this.db,
|
|
8269
|
-
groupId,
|
|
8270
|
-
adminId,
|
|
8271
|
-
this.app
|
|
8272
|
-
);
|
|
8422
|
+
return addAdminToGroup(this.db, groupId, adminId, this.app);
|
|
8273
8423
|
}
|
|
8274
8424
|
/**
|
|
8275
8425
|
* Uklanja admina iz grupacije
|
|
8276
8426
|
*/
|
|
8277
8427
|
async removeAdminFromGroup(groupId, adminId) {
|
|
8278
|
-
return removeAdminFromGroup(
|
|
8279
|
-
this.db,
|
|
8280
|
-
groupId,
|
|
8281
|
-
adminId,
|
|
8282
|
-
this.app
|
|
8283
|
-
);
|
|
8428
|
+
return removeAdminFromGroup(this.db, groupId, adminId, this.app);
|
|
8284
8429
|
}
|
|
8285
8430
|
/**
|
|
8286
8431
|
* Deaktivira grupaciju klinika
|
|
@@ -8320,10 +8465,7 @@ var ClinicGroupService = class extends BaseService {
|
|
|
8320
8465
|
logoUrl = uploadedLogoUrl;
|
|
8321
8466
|
}
|
|
8322
8467
|
} catch (error) {
|
|
8323
|
-
console.error(
|
|
8324
|
-
"[CLINIC_GROUP] Error processing logo in setupClinicGroup:",
|
|
8325
|
-
error
|
|
8326
|
-
);
|
|
8468
|
+
console.error("[CLINIC_GROUP] Error processing logo in setupClinicGroup:", error);
|
|
8327
8469
|
}
|
|
8328
8470
|
}
|
|
8329
8471
|
const updateData = {
|
|
@@ -8342,48 +8484,25 @@ var ClinicGroupService = class extends BaseService {
|
|
|
8342
8484
|
* Kreira admin token za grupaciju
|
|
8343
8485
|
*/
|
|
8344
8486
|
async createAdminToken(groupId, creatorAdminId, data) {
|
|
8345
|
-
return createAdminToken(
|
|
8346
|
-
this.db,
|
|
8347
|
-
groupId,
|
|
8348
|
-
creatorAdminId,
|
|
8349
|
-
this.app,
|
|
8350
|
-
data
|
|
8351
|
-
);
|
|
8487
|
+
return createAdminToken(this.db, groupId, creatorAdminId, this.app, data);
|
|
8352
8488
|
}
|
|
8353
8489
|
/**
|
|
8354
8490
|
* Verifikuje i koristi admin token
|
|
8355
8491
|
*/
|
|
8356
8492
|
async verifyAndUseAdminToken(groupId, token, userRef) {
|
|
8357
|
-
return verifyAndUseAdminToken(
|
|
8358
|
-
this.db,
|
|
8359
|
-
groupId,
|
|
8360
|
-
token,
|
|
8361
|
-
userRef,
|
|
8362
|
-
this.app
|
|
8363
|
-
);
|
|
8493
|
+
return verifyAndUseAdminToken(this.db, groupId, token, userRef, this.app);
|
|
8364
8494
|
}
|
|
8365
8495
|
/**
|
|
8366
8496
|
* Briše admin token
|
|
8367
8497
|
*/
|
|
8368
8498
|
async deleteAdminToken(groupId, tokenId, adminId) {
|
|
8369
|
-
return deleteAdminToken(
|
|
8370
|
-
this.db,
|
|
8371
|
-
groupId,
|
|
8372
|
-
tokenId,
|
|
8373
|
-
adminId,
|
|
8374
|
-
this.app
|
|
8375
|
-
);
|
|
8499
|
+
return deleteAdminToken(this.db, groupId, tokenId, adminId, this.app);
|
|
8376
8500
|
}
|
|
8377
8501
|
/**
|
|
8378
8502
|
* Dohvata aktivne admin tokene
|
|
8379
8503
|
*/
|
|
8380
8504
|
async getActiveAdminTokens(groupId, adminId) {
|
|
8381
|
-
return getActiveAdminTokens(
|
|
8382
|
-
this.db,
|
|
8383
|
-
groupId,
|
|
8384
|
-
adminId,
|
|
8385
|
-
this.app
|
|
8386
|
-
);
|
|
8505
|
+
return getActiveAdminTokens(this.db, groupId, adminId, this.app);
|
|
8387
8506
|
}
|
|
8388
8507
|
// TODO: Add a method to get all admin tokens for a clinic group (not just active ones)
|
|
8389
8508
|
// TODO: Refactor admin token methods not to add tokens to the clinicGroup document,
|
|
@@ -8427,33 +8546,62 @@ var ClinicGroupService = class extends BaseService {
|
|
|
8427
8546
|
console.log("[CLINIC_GROUP] Completing onboarding", { groupId });
|
|
8428
8547
|
return this.setOnboarding(groupId, { completed: true });
|
|
8429
8548
|
}
|
|
8549
|
+
/**
|
|
8550
|
+
* Get billing transactions for a clinic group
|
|
8551
|
+
*
|
|
8552
|
+
* @param groupId - The clinic group ID
|
|
8553
|
+
* @param options - Query options for pagination and filtering
|
|
8554
|
+
* @returns Promise with billing transactions and pagination info
|
|
8555
|
+
*/
|
|
8556
|
+
async getBillingTransactions(groupId, options = {}) {
|
|
8557
|
+
return this.billingTransactionsService.getBillingTransactions(groupId, options);
|
|
8558
|
+
}
|
|
8559
|
+
/**
|
|
8560
|
+
* Get recent billing transactions for a clinic group (last 10)
|
|
8561
|
+
*
|
|
8562
|
+
* @param groupId - The clinic group ID
|
|
8563
|
+
* @returns Promise with recent billing transactions
|
|
8564
|
+
*/
|
|
8565
|
+
async getRecentBillingTransactions(groupId) {
|
|
8566
|
+
return this.billingTransactionsService.getRecentBillingTransactions(groupId);
|
|
8567
|
+
}
|
|
8568
|
+
/**
|
|
8569
|
+
* Get subscription-related billing transactions for a clinic group
|
|
8570
|
+
*
|
|
8571
|
+
* @param groupId - The clinic group ID
|
|
8572
|
+
* @param options - Query options for pagination
|
|
8573
|
+
* @returns Promise with subscription transactions and pagination info
|
|
8574
|
+
*/
|
|
8575
|
+
async getSubscriptionTransactions(groupId, options = {}) {
|
|
8576
|
+
return this.billingTransactionsService.getSubscriptionTransactions(groupId, options);
|
|
8577
|
+
}
|
|
8430
8578
|
};
|
|
8431
8579
|
|
|
8432
8580
|
// src/services/clinic/clinic.service.ts
|
|
8433
|
-
var
|
|
8581
|
+
var import_firestore28 = require("firebase/firestore");
|
|
8434
8582
|
var import_functions2 = require("firebase/functions");
|
|
8435
8583
|
var import_geofire_common7 = require("geofire-common");
|
|
8436
8584
|
var import_zod20 = require("zod");
|
|
8437
8585
|
|
|
8438
8586
|
// src/services/clinic/utils/clinic.utils.ts
|
|
8439
|
-
var
|
|
8587
|
+
var import_firestore25 = require("firebase/firestore");
|
|
8440
8588
|
var import_geofire_common4 = require("geofire-common");
|
|
8441
8589
|
var import_zod19 = require("zod");
|
|
8442
8590
|
async function getClinic(db, clinicId) {
|
|
8443
|
-
const docRef = (0,
|
|
8444
|
-
const docSnap = await (0,
|
|
8591
|
+
const docRef = (0, import_firestore25.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
8592
|
+
const docSnap = await (0, import_firestore25.getDoc)(docRef);
|
|
8445
8593
|
if (docSnap.exists()) {
|
|
8446
8594
|
return docSnap.data();
|
|
8447
8595
|
}
|
|
8448
8596
|
return null;
|
|
8449
8597
|
}
|
|
8450
8598
|
async function getClinicsByGroup(db, groupId) {
|
|
8451
|
-
const q = (0,
|
|
8452
|
-
(0,
|
|
8453
|
-
(0,
|
|
8454
|
-
(0,
|
|
8599
|
+
const q = (0, import_firestore25.query)(
|
|
8600
|
+
(0, import_firestore25.collection)(db, CLINICS_COLLECTION),
|
|
8601
|
+
(0, import_firestore25.where)("clinicGroupId", "==", groupId),
|
|
8602
|
+
(0, import_firestore25.where)("isActive", "==", true)
|
|
8455
8603
|
);
|
|
8456
|
-
const querySnapshot = await (0,
|
|
8604
|
+
const querySnapshot = await (0, import_firestore25.getDocs)(q);
|
|
8457
8605
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
8458
8606
|
}
|
|
8459
8607
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
@@ -8609,11 +8757,11 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
|
|
|
8609
8757
|
}
|
|
8610
8758
|
updatedData = {
|
|
8611
8759
|
...updatedData,
|
|
8612
|
-
updatedAt:
|
|
8760
|
+
updatedAt: import_firestore25.Timestamp.now()
|
|
8613
8761
|
};
|
|
8614
8762
|
console.log("[CLINIC] Updating clinic in Firestore");
|
|
8615
8763
|
try {
|
|
8616
|
-
await (0,
|
|
8764
|
+
await (0, import_firestore25.updateDoc)((0, import_firestore25.doc)(db, CLINICS_COLLECTION, clinicId), updatedData);
|
|
8617
8765
|
console.log("[CLINIC] Clinic updated successfully");
|
|
8618
8766
|
} catch (updateError) {
|
|
8619
8767
|
console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
|
|
@@ -8642,12 +8790,12 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
8642
8790
|
if (clinicIds.length === 0) {
|
|
8643
8791
|
return [];
|
|
8644
8792
|
}
|
|
8645
|
-
const constraints = [(0,
|
|
8793
|
+
const constraints = [(0, import_firestore25.where)("id", "in", clinicIds)];
|
|
8646
8794
|
if (options.isActive !== void 0) {
|
|
8647
|
-
constraints.push((0,
|
|
8795
|
+
constraints.push((0, import_firestore25.where)("isActive", "==", options.isActive));
|
|
8648
8796
|
}
|
|
8649
|
-
const q = (0,
|
|
8650
|
-
const querySnapshot = await (0,
|
|
8797
|
+
const q = (0, import_firestore25.query)((0, import_firestore25.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
8798
|
+
const querySnapshot = await (0, import_firestore25.getDocs)(q);
|
|
8651
8799
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
8652
8800
|
}
|
|
8653
8801
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
@@ -8661,8 +8809,8 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
|
|
|
8661
8809
|
}
|
|
8662
8810
|
async function getClinicById(db, clinicId) {
|
|
8663
8811
|
try {
|
|
8664
|
-
const clinicRef = (0,
|
|
8665
|
-
const clinicSnapshot = await (0,
|
|
8812
|
+
const clinicRef = (0, import_firestore25.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
8813
|
+
const clinicSnapshot = await (0, import_firestore25.getDoc)(clinicRef);
|
|
8666
8814
|
if (!clinicSnapshot.exists()) {
|
|
8667
8815
|
return null;
|
|
8668
8816
|
}
|
|
@@ -8678,20 +8826,20 @@ async function getClinicById(db, clinicId) {
|
|
|
8678
8826
|
}
|
|
8679
8827
|
async function getAllClinics(db, pagination, lastDoc) {
|
|
8680
8828
|
try {
|
|
8681
|
-
const clinicsCollection = (0,
|
|
8682
|
-
let clinicsQuery = (0,
|
|
8829
|
+
const clinicsCollection = (0, import_firestore25.collection)(db, CLINICS_COLLECTION);
|
|
8830
|
+
let clinicsQuery = (0, import_firestore25.query)(clinicsCollection);
|
|
8683
8831
|
if (pagination && pagination > 0) {
|
|
8684
8832
|
if (lastDoc) {
|
|
8685
|
-
clinicsQuery = (0,
|
|
8833
|
+
clinicsQuery = (0, import_firestore25.query)(
|
|
8686
8834
|
clinicsCollection,
|
|
8687
|
-
(0,
|
|
8688
|
-
(0,
|
|
8835
|
+
(0, import_firestore25.startAfter)(lastDoc),
|
|
8836
|
+
(0, import_firestore25.limit)(pagination)
|
|
8689
8837
|
);
|
|
8690
8838
|
} else {
|
|
8691
|
-
clinicsQuery = (0,
|
|
8839
|
+
clinicsQuery = (0, import_firestore25.query)(clinicsCollection, (0, import_firestore25.limit)(pagination));
|
|
8692
8840
|
}
|
|
8693
8841
|
}
|
|
8694
|
-
const clinicsSnapshot = await (0,
|
|
8842
|
+
const clinicsSnapshot = await (0, import_firestore25.getDocs)(clinicsQuery);
|
|
8695
8843
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
8696
8844
|
const clinics = clinicsSnapshot.docs.map((doc38) => {
|
|
8697
8845
|
const data = doc38.data();
|
|
@@ -8718,12 +8866,12 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
8718
8866
|
let lastDocSnapshot = null;
|
|
8719
8867
|
for (const b of bounds) {
|
|
8720
8868
|
const constraints = [
|
|
8721
|
-
(0,
|
|
8722
|
-
(0,
|
|
8723
|
-
(0,
|
|
8869
|
+
(0, import_firestore25.where)("location.geohash", ">=", b[0]),
|
|
8870
|
+
(0, import_firestore25.where)("location.geohash", "<=", b[1]),
|
|
8871
|
+
(0, import_firestore25.where)("isActive", "==", true)
|
|
8724
8872
|
];
|
|
8725
|
-
const q = (0,
|
|
8726
|
-
const querySnapshot = await (0,
|
|
8873
|
+
const q = (0, import_firestore25.query)((0, import_firestore25.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
8874
|
+
const querySnapshot = await (0, import_firestore25.getDocs)(q);
|
|
8727
8875
|
for (const doc38 of querySnapshot.docs) {
|
|
8728
8876
|
const clinic = doc38.data();
|
|
8729
8877
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
@@ -8818,7 +8966,7 @@ async function removeTags(db, clinicId, adminId, tagsToRemove, clinicAdminServic
|
|
|
8818
8966
|
}
|
|
8819
8967
|
|
|
8820
8968
|
// src/services/clinic/utils/search.utils.ts
|
|
8821
|
-
var
|
|
8969
|
+
var import_firestore26 = require("firebase/firestore");
|
|
8822
8970
|
var import_geofire_common5 = require("geofire-common");
|
|
8823
8971
|
async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
8824
8972
|
const bounds = (0, import_geofire_common5.geohashQueryBounds)(
|
|
@@ -8828,20 +8976,20 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
8828
8976
|
const matchingDocs = [];
|
|
8829
8977
|
for (const b of bounds) {
|
|
8830
8978
|
const constraints = [
|
|
8831
|
-
(0,
|
|
8832
|
-
(0,
|
|
8833
|
-
(0,
|
|
8979
|
+
(0, import_firestore26.where)("location.geohash", ">=", b[0]),
|
|
8980
|
+
(0, import_firestore26.where)("location.geohash", "<=", b[1]),
|
|
8981
|
+
(0, import_firestore26.where)("isActive", "==", true)
|
|
8834
8982
|
];
|
|
8835
8983
|
if (filters == null ? void 0 : filters.services) {
|
|
8836
8984
|
constraints.push(
|
|
8837
|
-
(0,
|
|
8985
|
+
(0, import_firestore26.where)("services", "array-contains-any", filters.services)
|
|
8838
8986
|
);
|
|
8839
8987
|
}
|
|
8840
8988
|
if ((filters == null ? void 0 : filters.tags) && filters.tags.length > 0) {
|
|
8841
|
-
constraints.push((0,
|
|
8989
|
+
constraints.push((0, import_firestore26.where)("tags", "array-contains-any", filters.tags));
|
|
8842
8990
|
}
|
|
8843
|
-
const q = (0,
|
|
8844
|
-
const querySnapshot = await (0,
|
|
8991
|
+
const q = (0, import_firestore26.query)((0, import_firestore26.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
8992
|
+
const querySnapshot = await (0, import_firestore26.getDocs)(q);
|
|
8845
8993
|
for (const doc38 of querySnapshot.docs) {
|
|
8846
8994
|
const clinic = doc38.data();
|
|
8847
8995
|
const distance = (0, import_geofire_common5.distanceBetween)(
|
|
@@ -8868,7 +9016,7 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
8868
9016
|
}
|
|
8869
9017
|
|
|
8870
9018
|
// src/services/clinic/utils/filter.utils.ts
|
|
8871
|
-
var
|
|
9019
|
+
var import_firestore27 = require("firebase/firestore");
|
|
8872
9020
|
var import_geofire_common6 = require("geofire-common");
|
|
8873
9021
|
async function getClinicsByFilters(db, filters) {
|
|
8874
9022
|
var _a;
|
|
@@ -8896,15 +9044,15 @@ async function getClinicsByFilters(db, filters) {
|
|
|
8896
9044
|
const collected = [];
|
|
8897
9045
|
for (const b of bounds) {
|
|
8898
9046
|
const constraints = [
|
|
8899
|
-
(0,
|
|
8900
|
-
(0,
|
|
8901
|
-
(0,
|
|
9047
|
+
(0, import_firestore27.where)("location.geohash", ">=", b[0]),
|
|
9048
|
+
(0, import_firestore27.where)("location.geohash", "<=", b[1]),
|
|
9049
|
+
(0, import_firestore27.where)("isActive", "==", (_a = filters.isActive) != null ? _a : true)
|
|
8902
9050
|
];
|
|
8903
9051
|
if (filters.tags && filters.tags.length > 0) {
|
|
8904
|
-
constraints.push((0,
|
|
9052
|
+
constraints.push((0, import_firestore27.where)("tags", "array-contains", filters.tags[0]));
|
|
8905
9053
|
}
|
|
8906
|
-
const q0 = (0,
|
|
8907
|
-
const snap = await (0,
|
|
9054
|
+
const q0 = (0, import_firestore27.query)((0, import_firestore27.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
9055
|
+
const snap = await (0, import_firestore27.getDocs)(q0);
|
|
8908
9056
|
snap.docs.forEach((d) => collected.push({ ...d.data(), id: d.id }));
|
|
8909
9057
|
}
|
|
8910
9058
|
const uniqueMap = /* @__PURE__ */ new Map();
|
|
@@ -8932,15 +9080,15 @@ async function getClinicsByFilters(db, filters) {
|
|
|
8932
9080
|
const getBaseConstraints = () => {
|
|
8933
9081
|
var _a2;
|
|
8934
9082
|
const constraints = [];
|
|
8935
|
-
constraints.push((0,
|
|
9083
|
+
constraints.push((0, import_firestore27.where)("isActive", "==", (_a2 = filters.isActive) != null ? _a2 : true));
|
|
8936
9084
|
if (filters.tags && filters.tags.length > 0) {
|
|
8937
|
-
constraints.push((0,
|
|
9085
|
+
constraints.push((0, import_firestore27.where)("tags", "array-contains", filters.tags[0]));
|
|
8938
9086
|
}
|
|
8939
9087
|
if (filters.minRating !== void 0) {
|
|
8940
|
-
constraints.push((0,
|
|
9088
|
+
constraints.push((0, import_firestore27.where)("reviewInfo.averageRating", ">=", filters.minRating));
|
|
8941
9089
|
}
|
|
8942
9090
|
if (filters.maxRating !== void 0) {
|
|
8943
|
-
constraints.push((0,
|
|
9091
|
+
constraints.push((0, import_firestore27.where)("reviewInfo.averageRating", "<=", filters.maxRating));
|
|
8944
9092
|
}
|
|
8945
9093
|
return constraints;
|
|
8946
9094
|
};
|
|
@@ -8949,21 +9097,21 @@ async function getClinicsByFilters(db, filters) {
|
|
|
8949
9097
|
console.log("[CLINIC_SERVICE] Strategy 1: Trying nameLower search");
|
|
8950
9098
|
const searchTerm = filters.nameSearch.trim().toLowerCase();
|
|
8951
9099
|
const constraints = getBaseConstraints();
|
|
8952
|
-
constraints.push((0,
|
|
8953
|
-
constraints.push((0,
|
|
8954
|
-
constraints.push((0,
|
|
9100
|
+
constraints.push((0, import_firestore27.where)("nameLower", ">=", searchTerm));
|
|
9101
|
+
constraints.push((0, import_firestore27.where)("nameLower", "<=", searchTerm + "\uF8FF"));
|
|
9102
|
+
constraints.push((0, import_firestore27.orderBy)("nameLower"));
|
|
8955
9103
|
if (filters.lastDoc) {
|
|
8956
9104
|
if (typeof filters.lastDoc.data === "function") {
|
|
8957
|
-
constraints.push((0,
|
|
9105
|
+
constraints.push((0, import_firestore27.startAfter)(filters.lastDoc));
|
|
8958
9106
|
} else if (Array.isArray(filters.lastDoc)) {
|
|
8959
|
-
constraints.push((0,
|
|
9107
|
+
constraints.push((0, import_firestore27.startAfter)(...filters.lastDoc));
|
|
8960
9108
|
} else {
|
|
8961
|
-
constraints.push((0,
|
|
9109
|
+
constraints.push((0, import_firestore27.startAfter)(filters.lastDoc));
|
|
8962
9110
|
}
|
|
8963
9111
|
}
|
|
8964
|
-
constraints.push((0,
|
|
8965
|
-
const q = (0,
|
|
8966
|
-
const querySnapshot = await (0,
|
|
9112
|
+
constraints.push((0, import_firestore27.limit)(filters.pagination || 5));
|
|
9113
|
+
const q = (0, import_firestore27.query)((0, import_firestore27.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
9114
|
+
const querySnapshot = await (0, import_firestore27.getDocs)(q);
|
|
8967
9115
|
let clinics = querySnapshot.docs.map((doc38) => ({ ...doc38.data(), id: doc38.id }));
|
|
8968
9116
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
8969
9117
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -8981,21 +9129,21 @@ async function getClinicsByFilters(db, filters) {
|
|
|
8981
9129
|
console.log("[CLINIC_SERVICE] Strategy 2: Trying name field search");
|
|
8982
9130
|
const searchTerm = filters.nameSearch.trim().toLowerCase();
|
|
8983
9131
|
const constraints = getBaseConstraints();
|
|
8984
|
-
constraints.push((0,
|
|
8985
|
-
constraints.push((0,
|
|
8986
|
-
constraints.push((0,
|
|
9132
|
+
constraints.push((0, import_firestore27.where)("name", ">=", searchTerm));
|
|
9133
|
+
constraints.push((0, import_firestore27.where)("name", "<=", searchTerm + "\uF8FF"));
|
|
9134
|
+
constraints.push((0, import_firestore27.orderBy)("name"));
|
|
8987
9135
|
if (filters.lastDoc) {
|
|
8988
9136
|
if (typeof filters.lastDoc.data === "function") {
|
|
8989
|
-
constraints.push((0,
|
|
9137
|
+
constraints.push((0, import_firestore27.startAfter)(filters.lastDoc));
|
|
8990
9138
|
} else if (Array.isArray(filters.lastDoc)) {
|
|
8991
|
-
constraints.push((0,
|
|
9139
|
+
constraints.push((0, import_firestore27.startAfter)(...filters.lastDoc));
|
|
8992
9140
|
} else {
|
|
8993
|
-
constraints.push((0,
|
|
9141
|
+
constraints.push((0, import_firestore27.startAfter)(filters.lastDoc));
|
|
8994
9142
|
}
|
|
8995
9143
|
}
|
|
8996
|
-
constraints.push((0,
|
|
8997
|
-
const q = (0,
|
|
8998
|
-
const querySnapshot = await (0,
|
|
9144
|
+
constraints.push((0, import_firestore27.limit)(filters.pagination || 5));
|
|
9145
|
+
const q = (0, import_firestore27.query)((0, import_firestore27.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
9146
|
+
const querySnapshot = await (0, import_firestore27.getDocs)(q);
|
|
8999
9147
|
let clinics = querySnapshot.docs.map((doc38) => ({ ...doc38.data(), id: doc38.id }));
|
|
9000
9148
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
9001
9149
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -9013,19 +9161,19 @@ async function getClinicsByFilters(db, filters) {
|
|
|
9013
9161
|
"[CLINIC_SERVICE] Strategy 3: Using createdAt ordering with client-side filtering"
|
|
9014
9162
|
);
|
|
9015
9163
|
const constraints = getBaseConstraints();
|
|
9016
|
-
constraints.push((0,
|
|
9164
|
+
constraints.push((0, import_firestore27.orderBy)("createdAt", "desc"));
|
|
9017
9165
|
if (filters.lastDoc) {
|
|
9018
9166
|
if (typeof filters.lastDoc.data === "function") {
|
|
9019
|
-
constraints.push((0,
|
|
9167
|
+
constraints.push((0, import_firestore27.startAfter)(filters.lastDoc));
|
|
9020
9168
|
} else if (Array.isArray(filters.lastDoc)) {
|
|
9021
|
-
constraints.push((0,
|
|
9169
|
+
constraints.push((0, import_firestore27.startAfter)(...filters.lastDoc));
|
|
9022
9170
|
} else {
|
|
9023
|
-
constraints.push((0,
|
|
9171
|
+
constraints.push((0, import_firestore27.startAfter)(filters.lastDoc));
|
|
9024
9172
|
}
|
|
9025
9173
|
}
|
|
9026
|
-
constraints.push((0,
|
|
9027
|
-
const q = (0,
|
|
9028
|
-
const querySnapshot = await (0,
|
|
9174
|
+
constraints.push((0, import_firestore27.limit)(filters.pagination || 5));
|
|
9175
|
+
const q = (0, import_firestore27.query)((0, import_firestore27.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
9176
|
+
const querySnapshot = await (0, import_firestore27.getDocs)(q);
|
|
9029
9177
|
let clinics = querySnapshot.docs.map((doc38) => ({ ...doc38.data(), id: doc38.id }));
|
|
9030
9178
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
9031
9179
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -9040,12 +9188,12 @@ async function getClinicsByFilters(db, filters) {
|
|
|
9040
9188
|
try {
|
|
9041
9189
|
console.log("[CLINIC_SERVICE] Strategy 4: Minimal fallback");
|
|
9042
9190
|
const constraints = [
|
|
9043
|
-
(0,
|
|
9044
|
-
(0,
|
|
9045
|
-
(0,
|
|
9191
|
+
(0, import_firestore27.where)("isActive", "==", true),
|
|
9192
|
+
(0, import_firestore27.orderBy)("createdAt", "desc"),
|
|
9193
|
+
(0, import_firestore27.limit)(filters.pagination || 5)
|
|
9046
9194
|
];
|
|
9047
|
-
const q = (0,
|
|
9048
|
-
const querySnapshot = await (0,
|
|
9195
|
+
const q = (0, import_firestore27.query)((0, import_firestore27.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
9196
|
+
const querySnapshot = await (0, import_firestore27.getDocs)(q);
|
|
9049
9197
|
let clinics = querySnapshot.docs.map((doc38) => ({ ...doc38.data(), id: doc38.id }));
|
|
9050
9198
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
9051
9199
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -9351,16 +9499,16 @@ var ClinicService = class extends BaseService {
|
|
|
9351
9499
|
isActive: validatedData.isActive !== void 0 ? validatedData.isActive : true,
|
|
9352
9500
|
isVerified: validatedData.isVerified !== void 0 ? validatedData.isVerified : false,
|
|
9353
9501
|
logo: logoUrl,
|
|
9354
|
-
createdAt: (0,
|
|
9355
|
-
updatedAt: (0,
|
|
9502
|
+
createdAt: (0, import_firestore28.serverTimestamp)(),
|
|
9503
|
+
updatedAt: (0, import_firestore28.serverTimestamp)()
|
|
9356
9504
|
};
|
|
9357
|
-
const batch = (0,
|
|
9358
|
-
const clinicRef = (0,
|
|
9505
|
+
const batch = (0, import_firestore28.writeBatch)(this.db);
|
|
9506
|
+
const clinicRef = (0, import_firestore28.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
9359
9507
|
batch.set(clinicRef, clinicData);
|
|
9360
|
-
const adminRef = (0,
|
|
9508
|
+
const adminRef = (0, import_firestore28.doc)(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
|
|
9361
9509
|
batch.update(adminRef, {
|
|
9362
|
-
clinicsManaged: (0,
|
|
9363
|
-
updatedAt: (0,
|
|
9510
|
+
clinicsManaged: (0, import_firestore28.arrayUnion)(clinicId),
|
|
9511
|
+
updatedAt: (0, import_firestore28.serverTimestamp)()
|
|
9364
9512
|
});
|
|
9365
9513
|
await batch.commit();
|
|
9366
9514
|
console.log(`[ClinicService] Clinic created successfully: ${clinicId}`);
|
|
@@ -9381,8 +9529,8 @@ var ClinicService = class extends BaseService {
|
|
|
9381
9529
|
*/
|
|
9382
9530
|
async updateClinic(clinicId, data, adminId) {
|
|
9383
9531
|
try {
|
|
9384
|
-
const clinicRef = (0,
|
|
9385
|
-
const clinicDoc = await (0,
|
|
9532
|
+
const clinicRef = (0, import_firestore28.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
9533
|
+
const clinicDoc = await (0, import_firestore28.getDoc)(clinicRef);
|
|
9386
9534
|
if (!clinicDoc.exists()) {
|
|
9387
9535
|
throw new Error(`Clinic ${clinicId} not found`);
|
|
9388
9536
|
}
|
|
@@ -9446,8 +9594,8 @@ var ClinicService = class extends BaseService {
|
|
|
9446
9594
|
tz
|
|
9447
9595
|
};
|
|
9448
9596
|
}
|
|
9449
|
-
updatePayload.updatedAt = (0,
|
|
9450
|
-
await (0,
|
|
9597
|
+
updatePayload.updatedAt = (0, import_firestore28.serverTimestamp)();
|
|
9598
|
+
await (0, import_firestore28.updateDoc)(clinicRef, updatePayload);
|
|
9451
9599
|
console.log(`[ClinicService] Clinic ${clinicId} updated successfully`);
|
|
9452
9600
|
const updatedClinic = await this.getClinic(clinicId);
|
|
9453
9601
|
if (!updatedClinic) throw new Error("Failed to retrieve updated clinic");
|
|
@@ -9464,20 +9612,20 @@ var ClinicService = class extends BaseService {
|
|
|
9464
9612
|
* Deactivates a clinic.
|
|
9465
9613
|
*/
|
|
9466
9614
|
async deactivateClinic(clinicId, adminId) {
|
|
9467
|
-
const clinicRef = (0,
|
|
9468
|
-
await (0,
|
|
9615
|
+
const clinicRef = (0, import_firestore28.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
9616
|
+
await (0, import_firestore28.updateDoc)(clinicRef, {
|
|
9469
9617
|
isActive: false,
|
|
9470
|
-
updatedAt: (0,
|
|
9618
|
+
updatedAt: (0, import_firestore28.serverTimestamp)()
|
|
9471
9619
|
});
|
|
9472
9620
|
}
|
|
9473
9621
|
/**
|
|
9474
9622
|
* Activates a clinic.
|
|
9475
9623
|
*/
|
|
9476
9624
|
async activateClinic(clinicId, adminId) {
|
|
9477
|
-
const clinicRef = (0,
|
|
9478
|
-
await (0,
|
|
9625
|
+
const clinicRef = (0, import_firestore28.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
9626
|
+
await (0, import_firestore28.updateDoc)(clinicRef, {
|
|
9479
9627
|
isActive: true,
|
|
9480
|
-
updatedAt: (0,
|
|
9628
|
+
updatedAt: (0, import_firestore28.serverTimestamp)()
|
|
9481
9629
|
});
|
|
9482
9630
|
}
|
|
9483
9631
|
/**
|
|
@@ -9620,8 +9768,8 @@ var ClinicService = class extends BaseService {
|
|
|
9620
9768
|
* @returns Array of minimal clinic info for map
|
|
9621
9769
|
*/
|
|
9622
9770
|
async getClinicsForMap() {
|
|
9623
|
-
const clinicsRef = (0,
|
|
9624
|
-
const snapshot = await (0,
|
|
9771
|
+
const clinicsRef = (0, import_firestore28.collection)(this.db, CLINICS_COLLECTION);
|
|
9772
|
+
const snapshot = await (0, import_firestore28.getDocs)(clinicsRef);
|
|
9625
9773
|
const clinicsForMap = snapshot.docs.map((doc38) => {
|
|
9626
9774
|
var _a, _b, _c;
|
|
9627
9775
|
const data = doc38.data();
|
|
@@ -9970,9 +10118,9 @@ var AuthService = class extends BaseService {
|
|
|
9970
10118
|
token: data.inviteToken
|
|
9971
10119
|
});
|
|
9972
10120
|
console.log("[AUTH] Searching for token in clinic groups");
|
|
9973
|
-
const groupsRef = (0,
|
|
9974
|
-
const q = (0,
|
|
9975
|
-
const querySnapshot = await (0,
|
|
10121
|
+
const groupsRef = (0, import_firestore29.collection)(this.db, CLINIC_GROUPS_COLLECTION);
|
|
10122
|
+
const q = (0, import_firestore29.query)(groupsRef);
|
|
10123
|
+
const querySnapshot = await (0, import_firestore29.getDocs)(q);
|
|
9976
10124
|
let foundGroup = null;
|
|
9977
10125
|
let foundToken = null;
|
|
9978
10126
|
console.log(
|
|
@@ -10455,7 +10603,7 @@ var AuthService = class extends BaseService {
|
|
|
10455
10603
|
throw handleFirebaseError(firebaseError);
|
|
10456
10604
|
}
|
|
10457
10605
|
console.log("[AUTH] Starting Firestore transaction");
|
|
10458
|
-
const transactionResult = await (0,
|
|
10606
|
+
const transactionResult = await (0, import_firestore29.runTransaction)(
|
|
10459
10607
|
this.db,
|
|
10460
10608
|
async (transaction) => {
|
|
10461
10609
|
console.log(
|
|
@@ -10619,46 +10767,46 @@ var AuthService = class extends BaseService {
|
|
|
10619
10767
|
};
|
|
10620
10768
|
|
|
10621
10769
|
// src/services/calendar/calendar.v2.service.ts
|
|
10622
|
-
var import_firestore36 = require("firebase/firestore");
|
|
10623
10770
|
var import_firestore37 = require("firebase/firestore");
|
|
10771
|
+
var import_firestore38 = require("firebase/firestore");
|
|
10624
10772
|
|
|
10625
10773
|
// src/services/calendar/utils/clinic.utils.ts
|
|
10626
|
-
var
|
|
10774
|
+
var import_firestore31 = require("firebase/firestore");
|
|
10627
10775
|
|
|
10628
10776
|
// src/services/calendar/utils/docs.utils.ts
|
|
10629
|
-
var
|
|
10777
|
+
var import_firestore30 = require("firebase/firestore");
|
|
10630
10778
|
function getPractitionerCalendarEventDocRef(db, practitionerId, eventId) {
|
|
10631
|
-
return (0,
|
|
10779
|
+
return (0, import_firestore30.doc)(
|
|
10632
10780
|
db,
|
|
10633
10781
|
`${PRACTITIONERS_COLLECTION}/${practitionerId}/${CALENDAR_COLLECTION}/${eventId}`
|
|
10634
10782
|
);
|
|
10635
10783
|
}
|
|
10636
10784
|
function getPatientCalendarEventDocRef(db, patientId, eventId) {
|
|
10637
|
-
return (0,
|
|
10785
|
+
return (0, import_firestore30.doc)(
|
|
10638
10786
|
db,
|
|
10639
10787
|
`${PATIENTS_COLLECTION}/${patientId}/${CALENDAR_COLLECTION}/${eventId}`
|
|
10640
10788
|
);
|
|
10641
10789
|
}
|
|
10642
10790
|
function getClinicCalendarEventDocRef(db, clinicId, eventId) {
|
|
10643
|
-
return (0,
|
|
10791
|
+
return (0, import_firestore30.doc)(
|
|
10644
10792
|
db,
|
|
10645
10793
|
`${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}/${eventId}`
|
|
10646
10794
|
);
|
|
10647
10795
|
}
|
|
10648
10796
|
function getPractitionerSyncedCalendarDocRef(db, practitionerId, syncedCalendarId) {
|
|
10649
|
-
return (0,
|
|
10797
|
+
return (0, import_firestore30.doc)(
|
|
10650
10798
|
db,
|
|
10651
10799
|
`${PRACTITIONERS_COLLECTION}/${practitionerId}/syncedCalendars/${syncedCalendarId}`
|
|
10652
10800
|
);
|
|
10653
10801
|
}
|
|
10654
10802
|
function getPatientSyncedCalendarDocRef(db, patientId, syncedCalendarId) {
|
|
10655
|
-
return (0,
|
|
10803
|
+
return (0, import_firestore30.doc)(
|
|
10656
10804
|
db,
|
|
10657
10805
|
`${PATIENTS_COLLECTION}/${patientId}/syncedCalendars/${syncedCalendarId}`
|
|
10658
10806
|
);
|
|
10659
10807
|
}
|
|
10660
10808
|
function getClinicSyncedCalendarDocRef(db, clinicId, syncedCalendarId) {
|
|
10661
|
-
return (0,
|
|
10809
|
+
return (0, import_firestore30.doc)(
|
|
10662
10810
|
db,
|
|
10663
10811
|
`${CLINICS_COLLECTION}/${clinicId}/syncedCalendars/${syncedCalendarId}`
|
|
10664
10812
|
);
|
|
@@ -10671,31 +10819,31 @@ async function createClinicCalendarEventUtil(db, clinicId, eventData, generateId
|
|
|
10671
10819
|
const newEvent = {
|
|
10672
10820
|
id: eventId,
|
|
10673
10821
|
...eventData,
|
|
10674
|
-
createdAt: (0,
|
|
10675
|
-
updatedAt: (0,
|
|
10822
|
+
createdAt: (0, import_firestore31.serverTimestamp)(),
|
|
10823
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
10676
10824
|
};
|
|
10677
|
-
await (0,
|
|
10825
|
+
await (0, import_firestore31.setDoc)(eventRef, newEvent);
|
|
10678
10826
|
return {
|
|
10679
10827
|
...newEvent,
|
|
10680
|
-
createdAt:
|
|
10681
|
-
updatedAt:
|
|
10828
|
+
createdAt: import_firestore31.Timestamp.now(),
|
|
10829
|
+
updatedAt: import_firestore31.Timestamp.now()
|
|
10682
10830
|
};
|
|
10683
10831
|
}
|
|
10684
10832
|
async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData) {
|
|
10685
10833
|
const eventRef = getClinicCalendarEventDocRef(db, clinicId, eventId);
|
|
10686
10834
|
const updates = {
|
|
10687
10835
|
...updateData,
|
|
10688
|
-
updatedAt: (0,
|
|
10836
|
+
updatedAt: (0, import_firestore31.serverTimestamp)()
|
|
10689
10837
|
};
|
|
10690
|
-
await (0,
|
|
10691
|
-
const updatedDoc = await (0,
|
|
10838
|
+
await (0, import_firestore31.updateDoc)(eventRef, updates);
|
|
10839
|
+
const updatedDoc = await (0, import_firestore31.getDoc)(eventRef);
|
|
10692
10840
|
if (!updatedDoc.exists()) {
|
|
10693
10841
|
throw new Error("Event not found after update");
|
|
10694
10842
|
}
|
|
10695
10843
|
return updatedDoc.data();
|
|
10696
10844
|
}
|
|
10697
10845
|
async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
|
|
10698
|
-
const clinicDoc = await (0,
|
|
10846
|
+
const clinicDoc = await (0, import_firestore31.getDoc)((0, import_firestore31.doc)(db, `clinics/${clinicId}`));
|
|
10699
10847
|
if (!clinicDoc.exists()) {
|
|
10700
10848
|
throw new Error(`Clinic with ID ${clinicId} not found`);
|
|
10701
10849
|
}
|
|
@@ -10704,8 +10852,8 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
|
|
|
10704
10852
|
if (!clinicGroupId) {
|
|
10705
10853
|
return false;
|
|
10706
10854
|
}
|
|
10707
|
-
const clinicGroupDoc = await (0,
|
|
10708
|
-
(0,
|
|
10855
|
+
const clinicGroupDoc = await (0, import_firestore31.getDoc)(
|
|
10856
|
+
(0, import_firestore31.doc)(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
|
|
10709
10857
|
);
|
|
10710
10858
|
if (!clinicGroupDoc.exists()) {
|
|
10711
10859
|
return false;
|
|
@@ -10715,31 +10863,31 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
|
|
|
10715
10863
|
}
|
|
10716
10864
|
|
|
10717
10865
|
// src/services/calendar/utils/patient.utils.ts
|
|
10718
|
-
var
|
|
10866
|
+
var import_firestore32 = require("firebase/firestore");
|
|
10719
10867
|
async function createPatientCalendarEventUtil(db, patientId, eventData, generateId2) {
|
|
10720
10868
|
const eventId = generateId2();
|
|
10721
10869
|
const eventRef = getPatientCalendarEventDocRef(db, patientId, eventId);
|
|
10722
10870
|
const newEvent = {
|
|
10723
10871
|
id: eventId,
|
|
10724
10872
|
...eventData,
|
|
10725
|
-
createdAt: (0,
|
|
10726
|
-
updatedAt: (0,
|
|
10873
|
+
createdAt: (0, import_firestore32.serverTimestamp)(),
|
|
10874
|
+
updatedAt: (0, import_firestore32.serverTimestamp)()
|
|
10727
10875
|
};
|
|
10728
|
-
await (0,
|
|
10876
|
+
await (0, import_firestore32.setDoc)(eventRef, newEvent);
|
|
10729
10877
|
return {
|
|
10730
10878
|
...newEvent,
|
|
10731
|
-
createdAt:
|
|
10732
|
-
updatedAt:
|
|
10879
|
+
createdAt: import_firestore32.Timestamp.now(),
|
|
10880
|
+
updatedAt: import_firestore32.Timestamp.now()
|
|
10733
10881
|
};
|
|
10734
10882
|
}
|
|
10735
10883
|
async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData) {
|
|
10736
10884
|
const eventRef = getPatientCalendarEventDocRef(db, patientId, eventId);
|
|
10737
10885
|
const updates = {
|
|
10738
10886
|
...updateData,
|
|
10739
|
-
updatedAt: (0,
|
|
10887
|
+
updatedAt: (0, import_firestore32.serverTimestamp)()
|
|
10740
10888
|
};
|
|
10741
|
-
await (0,
|
|
10742
|
-
const updatedDoc = await (0,
|
|
10889
|
+
await (0, import_firestore32.updateDoc)(eventRef, updates);
|
|
10890
|
+
const updatedDoc = await (0, import_firestore32.getDoc)(eventRef);
|
|
10743
10891
|
if (!updatedDoc.exists()) {
|
|
10744
10892
|
throw new Error("Event not found after update");
|
|
10745
10893
|
}
|
|
@@ -10747,7 +10895,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
|
|
|
10747
10895
|
}
|
|
10748
10896
|
|
|
10749
10897
|
// src/services/calendar/utils/practitioner.utils.ts
|
|
10750
|
-
var
|
|
10898
|
+
var import_firestore33 = require("firebase/firestore");
|
|
10751
10899
|
async function createPractitionerCalendarEventUtil(db, practitionerId, eventData, generateId2) {
|
|
10752
10900
|
const eventId = generateId2();
|
|
10753
10901
|
const eventRef = getPractitionerCalendarEventDocRef(
|
|
@@ -10758,14 +10906,14 @@ async function createPractitionerCalendarEventUtil(db, practitionerId, eventData
|
|
|
10758
10906
|
const newEvent = {
|
|
10759
10907
|
id: eventId,
|
|
10760
10908
|
...eventData,
|
|
10761
|
-
createdAt: (0,
|
|
10762
|
-
updatedAt: (0,
|
|
10909
|
+
createdAt: (0, import_firestore33.serverTimestamp)(),
|
|
10910
|
+
updatedAt: (0, import_firestore33.serverTimestamp)()
|
|
10763
10911
|
};
|
|
10764
|
-
await (0,
|
|
10912
|
+
await (0, import_firestore33.setDoc)(eventRef, newEvent);
|
|
10765
10913
|
return {
|
|
10766
10914
|
...newEvent,
|
|
10767
|
-
createdAt:
|
|
10768
|
-
updatedAt:
|
|
10915
|
+
createdAt: import_firestore33.Timestamp.now(),
|
|
10916
|
+
updatedAt: import_firestore33.Timestamp.now()
|
|
10769
10917
|
};
|
|
10770
10918
|
}
|
|
10771
10919
|
async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId, updateData) {
|
|
@@ -10776,10 +10924,10 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
|
|
|
10776
10924
|
);
|
|
10777
10925
|
const updates = {
|
|
10778
10926
|
...updateData,
|
|
10779
|
-
updatedAt: (0,
|
|
10927
|
+
updatedAt: (0, import_firestore33.serverTimestamp)()
|
|
10780
10928
|
};
|
|
10781
|
-
await (0,
|
|
10782
|
-
const updatedDoc = await (0,
|
|
10929
|
+
await (0, import_firestore33.updateDoc)(eventRef, updates);
|
|
10930
|
+
const updatedDoc = await (0, import_firestore33.getDoc)(eventRef);
|
|
10783
10931
|
if (!updatedDoc.exists()) {
|
|
10784
10932
|
throw new Error("Event not found after update");
|
|
10785
10933
|
}
|
|
@@ -10837,7 +10985,7 @@ async function updateAppointmentUtil2(db, clinicId, practitionerId, patientId, e
|
|
|
10837
10985
|
}
|
|
10838
10986
|
|
|
10839
10987
|
// src/services/calendar/utils/calendar-event.utils.ts
|
|
10840
|
-
var
|
|
10988
|
+
var import_firestore34 = require("firebase/firestore");
|
|
10841
10989
|
async function searchCalendarEventsUtil(db, params) {
|
|
10842
10990
|
const { searchLocation, entityId, ...filters } = params;
|
|
10843
10991
|
let baseCollectionPath;
|
|
@@ -10880,7 +11028,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
10880
11028
|
);
|
|
10881
11029
|
}
|
|
10882
11030
|
baseCollectionPath = `${CLINICS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
10883
|
-
constraints.push((0,
|
|
11031
|
+
constraints.push((0, import_firestore34.where)("clinicBranchId", "==", entityId));
|
|
10884
11032
|
if (filters.clinicId && filters.clinicId !== entityId) {
|
|
10885
11033
|
console.warn(
|
|
10886
11034
|
`Provided clinicId filter (${filters.clinicId}) does not match search entityId (${entityId}). Returning empty results.`
|
|
@@ -10892,34 +11040,34 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
10892
11040
|
default:
|
|
10893
11041
|
throw new Error(`Invalid search location: ${searchLocation}`);
|
|
10894
11042
|
}
|
|
10895
|
-
const collectionRef = (0,
|
|
11043
|
+
const collectionRef = (0, import_firestore34.collection)(db, baseCollectionPath);
|
|
10896
11044
|
if (filters.clinicId) {
|
|
10897
|
-
constraints.push((0,
|
|
11045
|
+
constraints.push((0, import_firestore34.where)("clinicBranchId", "==", filters.clinicId));
|
|
10898
11046
|
}
|
|
10899
11047
|
if (filters.practitionerId) {
|
|
10900
11048
|
constraints.push(
|
|
10901
|
-
(0,
|
|
11049
|
+
(0, import_firestore34.where)("practitionerProfileId", "==", filters.practitionerId)
|
|
10902
11050
|
);
|
|
10903
11051
|
}
|
|
10904
11052
|
if (filters.patientId) {
|
|
10905
|
-
constraints.push((0,
|
|
11053
|
+
constraints.push((0, import_firestore34.where)("patientProfileId", "==", filters.patientId));
|
|
10906
11054
|
}
|
|
10907
11055
|
if (filters.procedureId) {
|
|
10908
|
-
constraints.push((0,
|
|
11056
|
+
constraints.push((0, import_firestore34.where)("procedureId", "==", filters.procedureId));
|
|
10909
11057
|
}
|
|
10910
11058
|
if (filters.eventStatus) {
|
|
10911
|
-
constraints.push((0,
|
|
11059
|
+
constraints.push((0, import_firestore34.where)("status", "==", filters.eventStatus));
|
|
10912
11060
|
}
|
|
10913
11061
|
if (filters.eventType) {
|
|
10914
|
-
constraints.push((0,
|
|
11062
|
+
constraints.push((0, import_firestore34.where)("eventType", "==", filters.eventType));
|
|
10915
11063
|
}
|
|
10916
11064
|
if (filters.dateRange) {
|
|
10917
|
-
constraints.push((0,
|
|
10918
|
-
constraints.push((0,
|
|
11065
|
+
constraints.push((0, import_firestore34.where)("eventTime.start", ">=", filters.dateRange.start));
|
|
11066
|
+
constraints.push((0, import_firestore34.where)("eventTime.start", "<=", filters.dateRange.end));
|
|
10919
11067
|
}
|
|
10920
11068
|
try {
|
|
10921
|
-
const finalQuery = (0,
|
|
10922
|
-
const querySnapshot = await (0,
|
|
11069
|
+
const finalQuery = (0, import_firestore34.query)(collectionRef, ...constraints);
|
|
11070
|
+
const querySnapshot = await (0, import_firestore34.getDocs)(finalQuery);
|
|
10923
11071
|
const events = querySnapshot.docs.map(
|
|
10924
11072
|
(doc38) => ({ id: doc38.id, ...doc38.data() })
|
|
10925
11073
|
);
|
|
@@ -10931,7 +11079,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
10931
11079
|
}
|
|
10932
11080
|
|
|
10933
11081
|
// src/services/calendar/utils/synced-calendar.utils.ts
|
|
10934
|
-
var
|
|
11082
|
+
var import_firestore35 = require("firebase/firestore");
|
|
10935
11083
|
async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendarData, generateId2) {
|
|
10936
11084
|
const calendarId = generateId2();
|
|
10937
11085
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -10942,14 +11090,14 @@ async function createPractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
10942
11090
|
const newCalendar = {
|
|
10943
11091
|
id: calendarId,
|
|
10944
11092
|
...calendarData,
|
|
10945
|
-
createdAt: (0,
|
|
10946
|
-
updatedAt: (0,
|
|
11093
|
+
createdAt: (0, import_firestore35.serverTimestamp)(),
|
|
11094
|
+
updatedAt: (0, import_firestore35.serverTimestamp)()
|
|
10947
11095
|
};
|
|
10948
|
-
await (0,
|
|
11096
|
+
await (0, import_firestore35.setDoc)(calendarRef, newCalendar);
|
|
10949
11097
|
return {
|
|
10950
11098
|
...newCalendar,
|
|
10951
|
-
createdAt:
|
|
10952
|
-
updatedAt:
|
|
11099
|
+
createdAt: import_firestore35.Timestamp.now(),
|
|
11100
|
+
updatedAt: import_firestore35.Timestamp.now()
|
|
10953
11101
|
};
|
|
10954
11102
|
}
|
|
10955
11103
|
async function createPatientSyncedCalendarUtil(db, patientId, calendarData, generateId2) {
|
|
@@ -10958,14 +11106,14 @@ async function createPatientSyncedCalendarUtil(db, patientId, calendarData, gene
|
|
|
10958
11106
|
const newCalendar = {
|
|
10959
11107
|
id: calendarId,
|
|
10960
11108
|
...calendarData,
|
|
10961
|
-
createdAt: (0,
|
|
10962
|
-
updatedAt: (0,
|
|
11109
|
+
createdAt: (0, import_firestore35.serverTimestamp)(),
|
|
11110
|
+
updatedAt: (0, import_firestore35.serverTimestamp)()
|
|
10963
11111
|
};
|
|
10964
|
-
await (0,
|
|
11112
|
+
await (0, import_firestore35.setDoc)(calendarRef, newCalendar);
|
|
10965
11113
|
return {
|
|
10966
11114
|
...newCalendar,
|
|
10967
|
-
createdAt:
|
|
10968
|
-
updatedAt:
|
|
11115
|
+
createdAt: import_firestore35.Timestamp.now(),
|
|
11116
|
+
updatedAt: import_firestore35.Timestamp.now()
|
|
10969
11117
|
};
|
|
10970
11118
|
}
|
|
10971
11119
|
async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, generateId2) {
|
|
@@ -10974,14 +11122,14 @@ async function createClinicSyncedCalendarUtil(db, clinicId, calendarData, genera
|
|
|
10974
11122
|
const newCalendar = {
|
|
10975
11123
|
id: calendarId,
|
|
10976
11124
|
...calendarData,
|
|
10977
|
-
createdAt: (0,
|
|
10978
|
-
updatedAt: (0,
|
|
11125
|
+
createdAt: (0, import_firestore35.serverTimestamp)(),
|
|
11126
|
+
updatedAt: (0, import_firestore35.serverTimestamp)()
|
|
10979
11127
|
};
|
|
10980
|
-
await (0,
|
|
11128
|
+
await (0, import_firestore35.setDoc)(calendarRef, newCalendar);
|
|
10981
11129
|
return {
|
|
10982
11130
|
...newCalendar,
|
|
10983
|
-
createdAt:
|
|
10984
|
-
updatedAt:
|
|
11131
|
+
createdAt: import_firestore35.Timestamp.now(),
|
|
11132
|
+
updatedAt: import_firestore35.Timestamp.now()
|
|
10985
11133
|
};
|
|
10986
11134
|
}
|
|
10987
11135
|
async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId) {
|
|
@@ -10990,53 +11138,53 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
|
|
|
10990
11138
|
practitionerId,
|
|
10991
11139
|
calendarId
|
|
10992
11140
|
);
|
|
10993
|
-
const calendarDoc = await (0,
|
|
11141
|
+
const calendarDoc = await (0, import_firestore35.getDoc)(calendarRef);
|
|
10994
11142
|
if (!calendarDoc.exists()) {
|
|
10995
11143
|
return null;
|
|
10996
11144
|
}
|
|
10997
11145
|
return calendarDoc.data();
|
|
10998
11146
|
}
|
|
10999
11147
|
async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
11000
|
-
const calendarsRef = (0,
|
|
11148
|
+
const calendarsRef = (0, import_firestore35.collection)(
|
|
11001
11149
|
db,
|
|
11002
11150
|
`practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
11003
11151
|
);
|
|
11004
|
-
const q = (0,
|
|
11005
|
-
const querySnapshot = await (0,
|
|
11152
|
+
const q = (0, import_firestore35.query)(calendarsRef, (0, import_firestore35.orderBy)("createdAt", "desc"));
|
|
11153
|
+
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
11006
11154
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
11007
11155
|
}
|
|
11008
11156
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
11009
11157
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
11010
|
-
const calendarDoc = await (0,
|
|
11158
|
+
const calendarDoc = await (0, import_firestore35.getDoc)(calendarRef);
|
|
11011
11159
|
if (!calendarDoc.exists()) {
|
|
11012
11160
|
return null;
|
|
11013
11161
|
}
|
|
11014
11162
|
return calendarDoc.data();
|
|
11015
11163
|
}
|
|
11016
11164
|
async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
11017
|
-
const calendarsRef = (0,
|
|
11165
|
+
const calendarsRef = (0, import_firestore35.collection)(
|
|
11018
11166
|
db,
|
|
11019
11167
|
`patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
11020
11168
|
);
|
|
11021
|
-
const q = (0,
|
|
11022
|
-
const querySnapshot = await (0,
|
|
11169
|
+
const q = (0, import_firestore35.query)(calendarsRef, (0, import_firestore35.orderBy)("createdAt", "desc"));
|
|
11170
|
+
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
11023
11171
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
11024
11172
|
}
|
|
11025
11173
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
11026
11174
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
11027
|
-
const calendarDoc = await (0,
|
|
11175
|
+
const calendarDoc = await (0, import_firestore35.getDoc)(calendarRef);
|
|
11028
11176
|
if (!calendarDoc.exists()) {
|
|
11029
11177
|
return null;
|
|
11030
11178
|
}
|
|
11031
11179
|
return calendarDoc.data();
|
|
11032
11180
|
}
|
|
11033
11181
|
async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
11034
|
-
const calendarsRef = (0,
|
|
11182
|
+
const calendarsRef = (0, import_firestore35.collection)(
|
|
11035
11183
|
db,
|
|
11036
11184
|
`clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
11037
11185
|
);
|
|
11038
|
-
const q = (0,
|
|
11039
|
-
const querySnapshot = await (0,
|
|
11186
|
+
const q = (0, import_firestore35.query)(calendarsRef, (0, import_firestore35.orderBy)("createdAt", "desc"));
|
|
11187
|
+
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
11040
11188
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
11041
11189
|
}
|
|
11042
11190
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
@@ -11047,10 +11195,10 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
11047
11195
|
);
|
|
11048
11196
|
const updates = {
|
|
11049
11197
|
...updateData,
|
|
11050
|
-
updatedAt: (0,
|
|
11198
|
+
updatedAt: (0, import_firestore35.serverTimestamp)()
|
|
11051
11199
|
};
|
|
11052
|
-
await (0,
|
|
11053
|
-
const updatedDoc = await (0,
|
|
11200
|
+
await (0, import_firestore35.updateDoc)(calendarRef, updates);
|
|
11201
|
+
const updatedDoc = await (0, import_firestore35.getDoc)(calendarRef);
|
|
11054
11202
|
if (!updatedDoc.exists()) {
|
|
11055
11203
|
throw new Error("Synced calendar not found after update");
|
|
11056
11204
|
}
|
|
@@ -11060,10 +11208,10 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
|
|
|
11060
11208
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
11061
11209
|
const updates = {
|
|
11062
11210
|
...updateData,
|
|
11063
|
-
updatedAt: (0,
|
|
11211
|
+
updatedAt: (0, import_firestore35.serverTimestamp)()
|
|
11064
11212
|
};
|
|
11065
|
-
await (0,
|
|
11066
|
-
const updatedDoc = await (0,
|
|
11213
|
+
await (0, import_firestore35.updateDoc)(calendarRef, updates);
|
|
11214
|
+
const updatedDoc = await (0, import_firestore35.getDoc)(calendarRef);
|
|
11067
11215
|
if (!updatedDoc.exists()) {
|
|
11068
11216
|
throw new Error("Synced calendar not found after update");
|
|
11069
11217
|
}
|
|
@@ -11073,10 +11221,10 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
|
|
|
11073
11221
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
11074
11222
|
const updates = {
|
|
11075
11223
|
...updateData,
|
|
11076
|
-
updatedAt: (0,
|
|
11224
|
+
updatedAt: (0, import_firestore35.serverTimestamp)()
|
|
11077
11225
|
};
|
|
11078
|
-
await (0,
|
|
11079
|
-
const updatedDoc = await (0,
|
|
11226
|
+
await (0, import_firestore35.updateDoc)(calendarRef, updates);
|
|
11227
|
+
const updatedDoc = await (0, import_firestore35.getDoc)(calendarRef);
|
|
11080
11228
|
if (!updatedDoc.exists()) {
|
|
11081
11229
|
throw new Error("Synced calendar not found after update");
|
|
11082
11230
|
}
|
|
@@ -11088,19 +11236,19 @@ async function deletePractitionerSyncedCalendarUtil(db, practitionerId, calendar
|
|
|
11088
11236
|
practitionerId,
|
|
11089
11237
|
calendarId
|
|
11090
11238
|
);
|
|
11091
|
-
await (0,
|
|
11239
|
+
await (0, import_firestore35.deleteDoc)(calendarRef);
|
|
11092
11240
|
}
|
|
11093
11241
|
async function deletePatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
11094
11242
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
11095
|
-
await (0,
|
|
11243
|
+
await (0, import_firestore35.deleteDoc)(calendarRef);
|
|
11096
11244
|
}
|
|
11097
11245
|
async function deleteClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
11098
11246
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
11099
|
-
await (0,
|
|
11247
|
+
await (0, import_firestore35.deleteDoc)(calendarRef);
|
|
11100
11248
|
}
|
|
11101
11249
|
async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarId) {
|
|
11102
11250
|
const updateData = {
|
|
11103
|
-
lastSyncedAt:
|
|
11251
|
+
lastSyncedAt: import_firestore35.Timestamp.now()
|
|
11104
11252
|
};
|
|
11105
11253
|
switch (entityType) {
|
|
11106
11254
|
case "practitioner":
|
|
@@ -11130,7 +11278,7 @@ async function updateLastSyncedTimestampUtil(db, entityType, entityId, calendarI
|
|
|
11130
11278
|
}
|
|
11131
11279
|
|
|
11132
11280
|
// src/services/calendar/utils/google-calendar.utils.ts
|
|
11133
|
-
var
|
|
11281
|
+
var import_firestore36 = require("firebase/firestore");
|
|
11134
11282
|
var GOOGLE_CALENDAR_API_URL = "https://www.googleapis.com/calendar/v3";
|
|
11135
11283
|
var GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token";
|
|
11136
11284
|
var CLIENT_ID = "your-client-id";
|
|
@@ -11250,7 +11398,7 @@ async function ensureValidToken(db, entityType, entityId, syncedCalendar) {
|
|
|
11250
11398
|
tokenExpiry.setSeconds(tokenExpiry.getSeconds() + expiresIn);
|
|
11251
11399
|
const updateData = {
|
|
11252
11400
|
accessToken,
|
|
11253
|
-
tokenExpiry:
|
|
11401
|
+
tokenExpiry: import_firestore36.Timestamp.fromDate(tokenExpiry)
|
|
11254
11402
|
};
|
|
11255
11403
|
switch (entityType) {
|
|
11256
11404
|
case "practitioner":
|
|
@@ -11425,8 +11573,8 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
|
|
|
11425
11573
|
eventName: googleEvent.summary || "External Event",
|
|
11426
11574
|
eventLocation: googleEvent.location,
|
|
11427
11575
|
eventTime: {
|
|
11428
|
-
start:
|
|
11429
|
-
end:
|
|
11576
|
+
start: import_firestore36.Timestamp.fromDate(start),
|
|
11577
|
+
end: import_firestore36.Timestamp.fromDate(end)
|
|
11430
11578
|
},
|
|
11431
11579
|
description: googleEvent.description || "",
|
|
11432
11580
|
// External events are always set as CONFIRMED - status updates will happen externally
|
|
@@ -11440,7 +11588,7 @@ function convertGoogleEventToCalendarEventUtil(googleEvent, entityId, entityType
|
|
|
11440
11588
|
{
|
|
11441
11589
|
eventId: googleEvent.id,
|
|
11442
11590
|
syncedCalendarProvider: "google" /* GOOGLE */,
|
|
11443
|
-
syncedAt:
|
|
11591
|
+
syncedAt: import_firestore36.Timestamp.now()
|
|
11444
11592
|
}
|
|
11445
11593
|
]
|
|
11446
11594
|
};
|
|
@@ -12218,7 +12366,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12218
12366
|
return 0;
|
|
12219
12367
|
}
|
|
12220
12368
|
let importedEventsCount = 0;
|
|
12221
|
-
const currentTime =
|
|
12369
|
+
const currentTime = import_firestore37.Timestamp.now();
|
|
12222
12370
|
for (const calendar of activeCalendars) {
|
|
12223
12371
|
try {
|
|
12224
12372
|
let externalEvents = [];
|
|
@@ -12285,7 +12433,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12285
12433
|
async createDoctorBlockingEvent(doctorId, eventData) {
|
|
12286
12434
|
try {
|
|
12287
12435
|
const eventId = this.generateId();
|
|
12288
|
-
const eventRef = (0,
|
|
12436
|
+
const eventRef = (0, import_firestore38.doc)(
|
|
12289
12437
|
this.db,
|
|
12290
12438
|
PRACTITIONERS_COLLECTION,
|
|
12291
12439
|
doctorId,
|
|
@@ -12295,14 +12443,14 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12295
12443
|
const newEvent = {
|
|
12296
12444
|
id: eventId,
|
|
12297
12445
|
...eventData,
|
|
12298
|
-
createdAt: (0,
|
|
12299
|
-
updatedAt: (0,
|
|
12446
|
+
createdAt: (0, import_firestore37.serverTimestamp)(),
|
|
12447
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
12300
12448
|
};
|
|
12301
|
-
await (0,
|
|
12449
|
+
await (0, import_firestore38.setDoc)(eventRef, newEvent);
|
|
12302
12450
|
return {
|
|
12303
12451
|
...newEvent,
|
|
12304
|
-
createdAt:
|
|
12305
|
-
updatedAt:
|
|
12452
|
+
createdAt: import_firestore37.Timestamp.now(),
|
|
12453
|
+
updatedAt: import_firestore37.Timestamp.now()
|
|
12306
12454
|
};
|
|
12307
12455
|
} catch (error) {
|
|
12308
12456
|
console.error(
|
|
@@ -12320,8 +12468,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12320
12468
|
*/
|
|
12321
12469
|
async synchronizeExternalCalendars(lookbackDays = 7, lookforwardDays = 30) {
|
|
12322
12470
|
try {
|
|
12323
|
-
const practitionersRef = (0,
|
|
12324
|
-
const practitionersSnapshot = await (0,
|
|
12471
|
+
const practitionersRef = (0, import_firestore38.collection)(this.db, PRACTITIONERS_COLLECTION);
|
|
12472
|
+
const practitionersSnapshot = await (0, import_firestore38.getDocs)(practitionersRef);
|
|
12325
12473
|
const startDate = /* @__PURE__ */ new Date();
|
|
12326
12474
|
startDate.setDate(startDate.getDate() - lookbackDays);
|
|
12327
12475
|
const endDate = /* @__PURE__ */ new Date();
|
|
@@ -12379,19 +12527,19 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12379
12527
|
async updateExistingEventsFromExternalCalendars(doctorId, startDate, endDate) {
|
|
12380
12528
|
var _a;
|
|
12381
12529
|
try {
|
|
12382
|
-
const eventsRef = (0,
|
|
12530
|
+
const eventsRef = (0, import_firestore38.collection)(
|
|
12383
12531
|
this.db,
|
|
12384
12532
|
PRACTITIONERS_COLLECTION,
|
|
12385
12533
|
doctorId,
|
|
12386
12534
|
CALENDAR_COLLECTION
|
|
12387
12535
|
);
|
|
12388
|
-
const q = (0,
|
|
12536
|
+
const q = (0, import_firestore38.query)(
|
|
12389
12537
|
eventsRef,
|
|
12390
|
-
(0,
|
|
12391
|
-
(0,
|
|
12392
|
-
(0,
|
|
12538
|
+
(0, import_firestore38.where)("syncStatus", "==", "external" /* EXTERNAL */),
|
|
12539
|
+
(0, import_firestore38.where)("eventTime.start", ">=", import_firestore37.Timestamp.fromDate(startDate)),
|
|
12540
|
+
(0, import_firestore38.where)("eventTime.start", "<=", import_firestore37.Timestamp.fromDate(endDate))
|
|
12393
12541
|
);
|
|
12394
|
-
const eventsSnapshot = await (0,
|
|
12542
|
+
const eventsSnapshot = await (0, import_firestore38.getDocs)(q);
|
|
12395
12543
|
const events = eventsSnapshot.docs.map((doc38) => ({
|
|
12396
12544
|
id: doc38.id,
|
|
12397
12545
|
...doc38.data()
|
|
@@ -12498,21 +12646,21 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12498
12646
|
const endTime = new Date(
|
|
12499
12647
|
externalEvent.end.dateTime || externalEvent.end.date
|
|
12500
12648
|
);
|
|
12501
|
-
const eventRef = (0,
|
|
12649
|
+
const eventRef = (0, import_firestore38.doc)(
|
|
12502
12650
|
this.db,
|
|
12503
12651
|
PRACTITIONERS_COLLECTION,
|
|
12504
12652
|
doctorId,
|
|
12505
12653
|
CALENDAR_COLLECTION,
|
|
12506
12654
|
eventId
|
|
12507
12655
|
);
|
|
12508
|
-
await (0,
|
|
12656
|
+
await (0, import_firestore38.updateDoc)(eventRef, {
|
|
12509
12657
|
eventName: externalEvent.summary || "External Event",
|
|
12510
12658
|
eventTime: {
|
|
12511
|
-
start:
|
|
12512
|
-
end:
|
|
12659
|
+
start: import_firestore37.Timestamp.fromDate(startTime),
|
|
12660
|
+
end: import_firestore37.Timestamp.fromDate(endTime)
|
|
12513
12661
|
},
|
|
12514
12662
|
description: externalEvent.description || "",
|
|
12515
|
-
updatedAt: (0,
|
|
12663
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
12516
12664
|
});
|
|
12517
12665
|
console.log(`Updated local event ${eventId} from external event`);
|
|
12518
12666
|
} catch (error) {
|
|
@@ -12530,16 +12678,16 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12530
12678
|
*/
|
|
12531
12679
|
async updateEventStatus(doctorId, eventId, status) {
|
|
12532
12680
|
try {
|
|
12533
|
-
const eventRef = (0,
|
|
12681
|
+
const eventRef = (0, import_firestore38.doc)(
|
|
12534
12682
|
this.db,
|
|
12535
12683
|
PRACTITIONERS_COLLECTION,
|
|
12536
12684
|
doctorId,
|
|
12537
12685
|
CALENDAR_COLLECTION,
|
|
12538
12686
|
eventId
|
|
12539
12687
|
);
|
|
12540
|
-
await (0,
|
|
12688
|
+
await (0, import_firestore38.updateDoc)(eventRef, {
|
|
12541
12689
|
status,
|
|
12542
|
-
updatedAt: (0,
|
|
12690
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
12543
12691
|
});
|
|
12544
12692
|
console.log(`Updated event ${eventId} status to ${status}`);
|
|
12545
12693
|
} catch (error) {
|
|
@@ -12587,8 +12735,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12587
12735
|
*/
|
|
12588
12736
|
async getPractitionerUpcomingAppointments(doctorId, startDate, endDate, status = "confirmed" /* CONFIRMED */) {
|
|
12589
12737
|
const dateRange = {
|
|
12590
|
-
start:
|
|
12591
|
-
end:
|
|
12738
|
+
start: import_firestore37.Timestamp.fromDate(startDate),
|
|
12739
|
+
end: import_firestore37.Timestamp.fromDate(endDate)
|
|
12592
12740
|
};
|
|
12593
12741
|
const searchParams = {
|
|
12594
12742
|
searchLocation: "practitioner" /* PRACTITIONER */,
|
|
@@ -12610,8 +12758,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12610
12758
|
*/
|
|
12611
12759
|
async getPatientAppointments(patientId, startDate, endDate, status) {
|
|
12612
12760
|
const dateRange = {
|
|
12613
|
-
start:
|
|
12614
|
-
end:
|
|
12761
|
+
start: import_firestore37.Timestamp.fromDate(startDate),
|
|
12762
|
+
end: import_firestore37.Timestamp.fromDate(endDate)
|
|
12615
12763
|
};
|
|
12616
12764
|
const searchParams = {
|
|
12617
12765
|
searchLocation: "patient" /* PATIENT */,
|
|
@@ -12636,8 +12784,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12636
12784
|
*/
|
|
12637
12785
|
async getClinicAppointments(clinicId, startDate, endDate, doctorId, status) {
|
|
12638
12786
|
const dateRange = {
|
|
12639
|
-
start:
|
|
12640
|
-
end:
|
|
12787
|
+
start: import_firestore37.Timestamp.fromDate(startDate),
|
|
12788
|
+
end: import_firestore37.Timestamp.fromDate(endDate)
|
|
12641
12789
|
};
|
|
12642
12790
|
const searchParams = {
|
|
12643
12791
|
searchLocation: "clinic" /* CLINIC */,
|
|
@@ -12696,8 +12844,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12696
12844
|
const startDate = eventTime.start.toDate();
|
|
12697
12845
|
const startTime = startDate;
|
|
12698
12846
|
const endTime = eventTime.end.toDate();
|
|
12699
|
-
const practitionerRef = (0,
|
|
12700
|
-
const practitionerDoc = await (0,
|
|
12847
|
+
const practitionerRef = (0, import_firestore38.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
|
|
12848
|
+
const practitionerDoc = await (0, import_firestore38.getDoc)(practitionerRef);
|
|
12701
12849
|
if (!practitionerDoc.exists()) {
|
|
12702
12850
|
throw new Error(`Doctor with ID ${doctorId} not found`);
|
|
12703
12851
|
}
|
|
@@ -12755,8 +12903,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12755
12903
|
*/
|
|
12756
12904
|
async updateAppointmentStatus(appointmentId, clinicId, status) {
|
|
12757
12905
|
const baseCollectionPath = `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}`;
|
|
12758
|
-
const appointmentRef = (0,
|
|
12759
|
-
const appointmentDoc = await (0,
|
|
12906
|
+
const appointmentRef = (0, import_firestore38.doc)(this.db, baseCollectionPath, appointmentId);
|
|
12907
|
+
const appointmentDoc = await (0, import_firestore38.getDoc)(appointmentRef);
|
|
12760
12908
|
if (!appointmentDoc.exists()) {
|
|
12761
12909
|
throw new Error(`Appointment with ID ${appointmentId} not found`);
|
|
12762
12910
|
}
|
|
@@ -12891,7 +13039,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12891
13039
|
const newSyncEvent = {
|
|
12892
13040
|
eventId: result.eventIds[0],
|
|
12893
13041
|
syncedCalendarProvider: calendar.provider,
|
|
12894
|
-
syncedAt:
|
|
13042
|
+
syncedAt: import_firestore37.Timestamp.now()
|
|
12895
13043
|
};
|
|
12896
13044
|
await this.updateEventWithSyncId(
|
|
12897
13045
|
entityType === "doctor" ? appointment.practitionerProfileId : appointment.patientProfileId,
|
|
@@ -12915,8 +13063,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12915
13063
|
async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
|
|
12916
13064
|
try {
|
|
12917
13065
|
const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
|
|
12918
|
-
const eventRef = (0,
|
|
12919
|
-
const eventDoc = await (0,
|
|
13066
|
+
const eventRef = (0, import_firestore38.doc)(this.db, collectionPath, eventId);
|
|
13067
|
+
const eventDoc = await (0, import_firestore38.getDoc)(eventRef);
|
|
12920
13068
|
if (eventDoc.exists()) {
|
|
12921
13069
|
const event = eventDoc.data();
|
|
12922
13070
|
const syncIds = [...event.syncedCalendarEventId || []];
|
|
@@ -12928,9 +13076,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12928
13076
|
} else {
|
|
12929
13077
|
syncIds.push(syncEvent);
|
|
12930
13078
|
}
|
|
12931
|
-
await (0,
|
|
13079
|
+
await (0, import_firestore38.updateDoc)(eventRef, {
|
|
12932
13080
|
syncedCalendarEventId: syncIds,
|
|
12933
|
-
updatedAt: (0,
|
|
13081
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
12934
13082
|
});
|
|
12935
13083
|
console.log(
|
|
12936
13084
|
`Updated event ${eventId} with sync ID ${syncEvent.eventId}`
|
|
@@ -12954,8 +13102,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12954
13102
|
* @returns Working hours for the clinic
|
|
12955
13103
|
*/
|
|
12956
13104
|
async getClinicWorkingHours(clinicId, date) {
|
|
12957
|
-
const clinicRef = (0,
|
|
12958
|
-
const clinicDoc = await (0,
|
|
13105
|
+
const clinicRef = (0, import_firestore38.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
13106
|
+
const clinicDoc = await (0, import_firestore38.getDoc)(clinicRef);
|
|
12959
13107
|
if (!clinicDoc.exists()) {
|
|
12960
13108
|
throw new Error(`Clinic with ID ${clinicId} not found`);
|
|
12961
13109
|
}
|
|
@@ -12983,8 +13131,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
12983
13131
|
* @returns Doctor's schedule
|
|
12984
13132
|
*/
|
|
12985
13133
|
async getDoctorSchedule(doctorId, date) {
|
|
12986
|
-
const practitionerRef = (0,
|
|
12987
|
-
const practitionerDoc = await (0,
|
|
13134
|
+
const practitionerRef = (0, import_firestore38.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId);
|
|
13135
|
+
const practitionerDoc = await (0, import_firestore38.getDoc)(practitionerRef);
|
|
12988
13136
|
if (!practitionerDoc.exists()) {
|
|
12989
13137
|
throw new Error(`Doctor with ID ${doctorId} not found`);
|
|
12990
13138
|
}
|
|
@@ -13016,18 +13164,18 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13016
13164
|
startOfDay.setHours(0, 0, 0, 0);
|
|
13017
13165
|
const endOfDay = new Date(date);
|
|
13018
13166
|
endOfDay.setHours(23, 59, 59, 999);
|
|
13019
|
-
const appointmentsRef = (0,
|
|
13020
|
-
const q = (0,
|
|
13167
|
+
const appointmentsRef = (0, import_firestore38.collection)(this.db, CALENDAR_COLLECTION);
|
|
13168
|
+
const q = (0, import_firestore38.query)(
|
|
13021
13169
|
appointmentsRef,
|
|
13022
|
-
(0,
|
|
13023
|
-
(0,
|
|
13024
|
-
(0,
|
|
13025
|
-
(0,
|
|
13170
|
+
(0, import_firestore38.where)("practitionerProfileId", "==", doctorId),
|
|
13171
|
+
(0, import_firestore38.where)("eventTime.start", ">=", import_firestore37.Timestamp.fromDate(startOfDay)),
|
|
13172
|
+
(0, import_firestore38.where)("eventTime.start", "<=", import_firestore37.Timestamp.fromDate(endOfDay)),
|
|
13173
|
+
(0, import_firestore38.where)("status", "in", [
|
|
13026
13174
|
"confirmed" /* CONFIRMED */,
|
|
13027
13175
|
"pending" /* PENDING */
|
|
13028
13176
|
])
|
|
13029
13177
|
);
|
|
13030
|
-
const querySnapshot = await (0,
|
|
13178
|
+
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
13031
13179
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
13032
13180
|
}
|
|
13033
13181
|
/**
|
|
@@ -13085,11 +13233,11 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13085
13233
|
var _a;
|
|
13086
13234
|
try {
|
|
13087
13235
|
const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
|
|
13088
|
-
(0,
|
|
13089
|
-
(0,
|
|
13090
|
-
(0,
|
|
13091
|
-
(0,
|
|
13092
|
-
(0,
|
|
13236
|
+
(0, import_firestore38.getDoc)((0, import_firestore38.doc)(this.db, CLINICS_COLLECTION, clinicId)),
|
|
13237
|
+
(0, import_firestore38.getDoc)((0, import_firestore38.doc)(this.db, PRACTITIONERS_COLLECTION, doctorId)),
|
|
13238
|
+
(0, import_firestore38.getDoc)((0, import_firestore38.doc)(this.db, PATIENTS_COLLECTION, patientId)),
|
|
13239
|
+
(0, import_firestore38.getDoc)(
|
|
13240
|
+
(0, import_firestore38.doc)(
|
|
13093
13241
|
this.db,
|
|
13094
13242
|
PATIENTS_COLLECTION,
|
|
13095
13243
|
patientId,
|
|
@@ -13122,7 +13270,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13122
13270
|
fullName: `${sensitiveData.firstName} ${sensitiveData.lastName}`,
|
|
13123
13271
|
email: sensitiveData.email || "",
|
|
13124
13272
|
phone: sensitiveData.phoneNumber || null,
|
|
13125
|
-
dateOfBirth: sensitiveData.dateOfBirth ||
|
|
13273
|
+
dateOfBirth: sensitiveData.dateOfBirth || import_firestore37.Timestamp.now(),
|
|
13126
13274
|
gender: sensitiveData.gender || "other" /* OTHER */
|
|
13127
13275
|
};
|
|
13128
13276
|
} else if (patientDoc.exists()) {
|
|
@@ -13131,7 +13279,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13131
13279
|
fullName: patientDoc.data().displayName,
|
|
13132
13280
|
email: ((_a = patientDoc.data().contactInfo) == null ? void 0 : _a.email) || "",
|
|
13133
13281
|
phone: patientDoc.data().phoneNumber || null,
|
|
13134
|
-
dateOfBirth: patientDoc.data().dateOfBirth ||
|
|
13282
|
+
dateOfBirth: patientDoc.data().dateOfBirth || import_firestore37.Timestamp.now(),
|
|
13135
13283
|
gender: patientDoc.data().gender || "other" /* OTHER */
|
|
13136
13284
|
};
|
|
13137
13285
|
}
|
|
@@ -13153,8 +13301,8 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
13153
13301
|
};
|
|
13154
13302
|
|
|
13155
13303
|
// src/services/calendar/calendar.v3.service.ts
|
|
13156
|
-
var import_firestore38 = require("firebase/firestore");
|
|
13157
13304
|
var import_firestore39 = require("firebase/firestore");
|
|
13305
|
+
var import_firestore40 = require("firebase/firestore");
|
|
13158
13306
|
var CalendarServiceV3 = class extends BaseService {
|
|
13159
13307
|
/**
|
|
13160
13308
|
* Creates a new CalendarServiceV3 instance
|
|
@@ -13178,7 +13326,7 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
13178
13326
|
params.entityType,
|
|
13179
13327
|
params.entityId
|
|
13180
13328
|
);
|
|
13181
|
-
const eventRef = (0,
|
|
13329
|
+
const eventRef = (0, import_firestore40.doc)(this.db, collectionPath, eventId);
|
|
13182
13330
|
const eventData = {
|
|
13183
13331
|
id: eventId,
|
|
13184
13332
|
eventName: params.eventName,
|
|
@@ -13188,19 +13336,19 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
13188
13336
|
status: "confirmed" /* CONFIRMED */,
|
|
13189
13337
|
// Blocking events are always confirmed
|
|
13190
13338
|
syncStatus: "internal" /* INTERNAL */,
|
|
13191
|
-
createdAt: (0,
|
|
13192
|
-
updatedAt: (0,
|
|
13339
|
+
createdAt: (0, import_firestore39.serverTimestamp)(),
|
|
13340
|
+
updatedAt: (0, import_firestore39.serverTimestamp)()
|
|
13193
13341
|
};
|
|
13194
13342
|
if (params.entityType === "practitioner") {
|
|
13195
13343
|
eventData.practitionerProfileId = params.entityId;
|
|
13196
13344
|
} else {
|
|
13197
13345
|
eventData.clinicBranchId = params.entityId;
|
|
13198
13346
|
}
|
|
13199
|
-
await (0,
|
|
13347
|
+
await (0, import_firestore40.setDoc)(eventRef, eventData);
|
|
13200
13348
|
return {
|
|
13201
13349
|
...eventData,
|
|
13202
|
-
createdAt:
|
|
13203
|
-
updatedAt:
|
|
13350
|
+
createdAt: import_firestore39.Timestamp.now(),
|
|
13351
|
+
updatedAt: import_firestore39.Timestamp.now()
|
|
13204
13352
|
};
|
|
13205
13353
|
}
|
|
13206
13354
|
/**
|
|
@@ -13213,13 +13361,13 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
13213
13361
|
params.entityType,
|
|
13214
13362
|
params.entityId
|
|
13215
13363
|
);
|
|
13216
|
-
const eventRef = (0,
|
|
13217
|
-
const eventDoc = await (0,
|
|
13364
|
+
const eventRef = (0, import_firestore40.doc)(this.db, collectionPath, params.eventId);
|
|
13365
|
+
const eventDoc = await (0, import_firestore40.getDoc)(eventRef);
|
|
13218
13366
|
if (!eventDoc.exists()) {
|
|
13219
13367
|
throw new Error(`Blocking event with ID ${params.eventId} not found`);
|
|
13220
13368
|
}
|
|
13221
13369
|
const updateData = {
|
|
13222
|
-
updatedAt: (0,
|
|
13370
|
+
updatedAt: (0, import_firestore39.serverTimestamp)()
|
|
13223
13371
|
};
|
|
13224
13372
|
if (params.eventName !== void 0) {
|
|
13225
13373
|
updateData.eventName = params.eventName;
|
|
@@ -13233,8 +13381,8 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
13233
13381
|
if (params.status !== void 0) {
|
|
13234
13382
|
updateData.status = params.status;
|
|
13235
13383
|
}
|
|
13236
|
-
await (0,
|
|
13237
|
-
const updatedEventDoc = await (0,
|
|
13384
|
+
await (0, import_firestore40.updateDoc)(eventRef, updateData);
|
|
13385
|
+
const updatedEventDoc = await (0, import_firestore40.getDoc)(eventRef);
|
|
13238
13386
|
return updatedEventDoc.data();
|
|
13239
13387
|
}
|
|
13240
13388
|
/**
|
|
@@ -13245,12 +13393,12 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
13245
13393
|
*/
|
|
13246
13394
|
async deleteBlockingEvent(entityType, entityId, eventId) {
|
|
13247
13395
|
const collectionPath = this.getEntityCalendarPath(entityType, entityId);
|
|
13248
|
-
const eventRef = (0,
|
|
13249
|
-
const eventDoc = await (0,
|
|
13396
|
+
const eventRef = (0, import_firestore40.doc)(this.db, collectionPath, eventId);
|
|
13397
|
+
const eventDoc = await (0, import_firestore40.getDoc)(eventRef);
|
|
13250
13398
|
if (!eventDoc.exists()) {
|
|
13251
13399
|
throw new Error(`Blocking event with ID ${eventId} not found`);
|
|
13252
13400
|
}
|
|
13253
|
-
await (0,
|
|
13401
|
+
await (0, import_firestore40.deleteDoc)(eventRef);
|
|
13254
13402
|
}
|
|
13255
13403
|
/**
|
|
13256
13404
|
* Gets a specific blocking event
|
|
@@ -13261,8 +13409,8 @@ var CalendarServiceV3 = class extends BaseService {
|
|
|
13261
13409
|
*/
|
|
13262
13410
|
async getBlockingEvent(entityType, entityId, eventId) {
|
|
13263
13411
|
const collectionPath = this.getEntityCalendarPath(entityType, entityId);
|
|
13264
|
-
const eventRef = (0,
|
|
13265
|
-
const eventDoc = await (0,
|
|
13412
|
+
const eventRef = (0, import_firestore40.doc)(this.db, collectionPath, eventId);
|
|
13413
|
+
const eventDoc = await (0, import_firestore40.getDoc)(eventRef);
|
|
13266
13414
|
if (!eventDoc.exists()) {
|
|
13267
13415
|
return null;
|
|
13268
13416
|
}
|
|
@@ -13455,7 +13603,7 @@ var ExternalCalendarService = class extends BaseService {
|
|
|
13455
13603
|
};
|
|
13456
13604
|
|
|
13457
13605
|
// src/services/clinic/practitioner-invite.service.ts
|
|
13458
|
-
var
|
|
13606
|
+
var import_firestore41 = require("firebase/firestore");
|
|
13459
13607
|
var PractitionerInviteService = class extends BaseService {
|
|
13460
13608
|
constructor(db, auth, app) {
|
|
13461
13609
|
super(db, auth, app);
|
|
@@ -13517,7 +13665,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13517
13665
|
message: message || null,
|
|
13518
13666
|
status: "pending" /* PENDING */
|
|
13519
13667
|
};
|
|
13520
|
-
const now =
|
|
13668
|
+
const now = import_firestore41.Timestamp.now();
|
|
13521
13669
|
const invite = {
|
|
13522
13670
|
id: inviteId,
|
|
13523
13671
|
...inviteData,
|
|
@@ -13528,8 +13676,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13528
13676
|
rejectedAt: null,
|
|
13529
13677
|
cancelledAt: null
|
|
13530
13678
|
};
|
|
13531
|
-
const docRef = (0,
|
|
13532
|
-
await (0,
|
|
13679
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
13680
|
+
await (0, import_firestore41.setDoc)(docRef, invite);
|
|
13533
13681
|
return invite;
|
|
13534
13682
|
} catch (error) {
|
|
13535
13683
|
console.error(
|
|
@@ -13548,17 +13696,17 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13548
13696
|
async getAllInvitesDoctor(practitionerId, statusFilter) {
|
|
13549
13697
|
try {
|
|
13550
13698
|
const constraints = [
|
|
13551
|
-
(0,
|
|
13552
|
-
(0,
|
|
13699
|
+
(0, import_firestore41.where)("practitionerId", "==", practitionerId),
|
|
13700
|
+
(0, import_firestore41.orderBy)("createdAt", "desc")
|
|
13553
13701
|
];
|
|
13554
13702
|
if (statusFilter && statusFilter.length > 0) {
|
|
13555
|
-
constraints.push((0,
|
|
13703
|
+
constraints.push((0, import_firestore41.where)("status", "in", statusFilter));
|
|
13556
13704
|
}
|
|
13557
|
-
const q = (0,
|
|
13558
|
-
(0,
|
|
13705
|
+
const q = (0, import_firestore41.query)(
|
|
13706
|
+
(0, import_firestore41.collection)(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
13559
13707
|
...constraints
|
|
13560
13708
|
);
|
|
13561
|
-
const querySnapshot = await (0,
|
|
13709
|
+
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13562
13710
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
13563
13711
|
} catch (error) {
|
|
13564
13712
|
console.error(
|
|
@@ -13577,17 +13725,17 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13577
13725
|
async getAllInvitesClinic(clinicId, statusFilter) {
|
|
13578
13726
|
try {
|
|
13579
13727
|
const constraints = [
|
|
13580
|
-
(0,
|
|
13581
|
-
(0,
|
|
13728
|
+
(0, import_firestore41.where)("clinicId", "==", clinicId),
|
|
13729
|
+
(0, import_firestore41.orderBy)("createdAt", "desc")
|
|
13582
13730
|
];
|
|
13583
13731
|
if (statusFilter && statusFilter.length > 0) {
|
|
13584
|
-
constraints.push((0,
|
|
13732
|
+
constraints.push((0, import_firestore41.where)("status", "in", statusFilter));
|
|
13585
13733
|
}
|
|
13586
|
-
const q = (0,
|
|
13587
|
-
(0,
|
|
13734
|
+
const q = (0, import_firestore41.query)(
|
|
13735
|
+
(0, import_firestore41.collection)(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
13588
13736
|
...constraints
|
|
13589
13737
|
);
|
|
13590
|
-
const querySnapshot = await (0,
|
|
13738
|
+
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13591
13739
|
return querySnapshot.docs.map((doc38) => doc38.data());
|
|
13592
13740
|
} catch (error) {
|
|
13593
13741
|
console.error(
|
|
@@ -13613,11 +13761,11 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13613
13761
|
}
|
|
13614
13762
|
const updateData = {
|
|
13615
13763
|
status: "accepted" /* ACCEPTED */,
|
|
13616
|
-
acceptedAt:
|
|
13617
|
-
updatedAt: (0,
|
|
13764
|
+
acceptedAt: import_firestore41.Timestamp.now(),
|
|
13765
|
+
updatedAt: (0, import_firestore41.serverTimestamp)()
|
|
13618
13766
|
};
|
|
13619
|
-
const docRef = (0,
|
|
13620
|
-
await (0,
|
|
13767
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
13768
|
+
await (0, import_firestore41.updateDoc)(docRef, updateData);
|
|
13621
13769
|
return await this.getInviteById(inviteId);
|
|
13622
13770
|
} catch (error) {
|
|
13623
13771
|
console.error(
|
|
@@ -13645,11 +13793,11 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13645
13793
|
const updateData = {
|
|
13646
13794
|
status: "rejected" /* REJECTED */,
|
|
13647
13795
|
rejectionReason: rejectionReason || null,
|
|
13648
|
-
rejectedAt:
|
|
13649
|
-
updatedAt: (0,
|
|
13796
|
+
rejectedAt: import_firestore41.Timestamp.now(),
|
|
13797
|
+
updatedAt: (0, import_firestore41.serverTimestamp)()
|
|
13650
13798
|
};
|
|
13651
|
-
const docRef = (0,
|
|
13652
|
-
await (0,
|
|
13799
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
13800
|
+
await (0, import_firestore41.updateDoc)(docRef, updateData);
|
|
13653
13801
|
return await this.getInviteById(inviteId);
|
|
13654
13802
|
} catch (error) {
|
|
13655
13803
|
console.error(
|
|
@@ -13677,11 +13825,11 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13677
13825
|
const updateData = {
|
|
13678
13826
|
status: "cancelled" /* CANCELLED */,
|
|
13679
13827
|
cancelReason: cancelReason || null,
|
|
13680
|
-
cancelledAt:
|
|
13681
|
-
updatedAt: (0,
|
|
13828
|
+
cancelledAt: import_firestore41.Timestamp.now(),
|
|
13829
|
+
updatedAt: (0, import_firestore41.serverTimestamp)()
|
|
13682
13830
|
};
|
|
13683
|
-
const docRef = (0,
|
|
13684
|
-
await (0,
|
|
13831
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
13832
|
+
await (0, import_firestore41.updateDoc)(docRef, updateData);
|
|
13685
13833
|
return await this.getInviteById(inviteId);
|
|
13686
13834
|
} catch (error) {
|
|
13687
13835
|
console.error(
|
|
@@ -13698,8 +13846,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13698
13846
|
*/
|
|
13699
13847
|
async getInviteById(inviteId) {
|
|
13700
13848
|
try {
|
|
13701
|
-
const docRef = (0,
|
|
13702
|
-
const docSnap = await (0,
|
|
13849
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
13850
|
+
const docSnap = await (0, import_firestore41.getDoc)(docRef);
|
|
13703
13851
|
if (docSnap.exists()) {
|
|
13704
13852
|
return docSnap.data();
|
|
13705
13853
|
}
|
|
@@ -13721,28 +13869,28 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13721
13869
|
try {
|
|
13722
13870
|
const constraints = [];
|
|
13723
13871
|
if (filters.practitionerId) {
|
|
13724
|
-
constraints.push((0,
|
|
13872
|
+
constraints.push((0, import_firestore41.where)("practitionerId", "==", filters.practitionerId));
|
|
13725
13873
|
}
|
|
13726
13874
|
if (filters.clinicId) {
|
|
13727
|
-
constraints.push((0,
|
|
13875
|
+
constraints.push((0, import_firestore41.where)("clinicId", "==", filters.clinicId));
|
|
13728
13876
|
}
|
|
13729
13877
|
if (filters.invitedBy) {
|
|
13730
|
-
constraints.push((0,
|
|
13878
|
+
constraints.push((0, import_firestore41.where)("invitedBy", "==", filters.invitedBy));
|
|
13731
13879
|
}
|
|
13732
13880
|
if (filters.status && filters.status.length > 0) {
|
|
13733
|
-
constraints.push((0,
|
|
13881
|
+
constraints.push((0, import_firestore41.where)("status", "in", filters.status));
|
|
13734
13882
|
}
|
|
13735
13883
|
const orderField = filters.orderBy || "createdAt";
|
|
13736
13884
|
const orderDirection = filters.orderDirection || "desc";
|
|
13737
|
-
constraints.push((0,
|
|
13885
|
+
constraints.push((0, import_firestore41.orderBy)(orderField, orderDirection));
|
|
13738
13886
|
if (filters.limit) {
|
|
13739
|
-
constraints.push((0,
|
|
13887
|
+
constraints.push((0, import_firestore41.limit)(filters.limit));
|
|
13740
13888
|
}
|
|
13741
|
-
const q = (0,
|
|
13742
|
-
(0,
|
|
13889
|
+
const q = (0, import_firestore41.query)(
|
|
13890
|
+
(0, import_firestore41.collection)(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
13743
13891
|
...constraints
|
|
13744
13892
|
);
|
|
13745
|
-
const querySnapshot = await (0,
|
|
13893
|
+
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13746
13894
|
let invites = querySnapshot.docs.map(
|
|
13747
13895
|
(doc38) => doc38.data()
|
|
13748
13896
|
);
|
|
@@ -13771,8 +13919,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13771
13919
|
*/
|
|
13772
13920
|
async deleteInvite(inviteId) {
|
|
13773
13921
|
try {
|
|
13774
|
-
const docRef = (0,
|
|
13775
|
-
await (0,
|
|
13922
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
|
|
13923
|
+
await (0, import_firestore41.deleteDoc)(docRef);
|
|
13776
13924
|
} catch (error) {
|
|
13777
13925
|
console.error(
|
|
13778
13926
|
"[PractitionerInviteService] Error deleting invite:",
|
|
@@ -13789,8 +13937,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13789
13937
|
*/
|
|
13790
13938
|
async getPractitionerById(practitionerId) {
|
|
13791
13939
|
try {
|
|
13792
|
-
const docRef = (0,
|
|
13793
|
-
const docSnap = await (0,
|
|
13940
|
+
const docRef = (0, import_firestore41.doc)(this.db, PRACTITIONERS_COLLECTION, practitionerId);
|
|
13941
|
+
const docSnap = await (0, import_firestore41.getDoc)(docRef);
|
|
13794
13942
|
return docSnap.exists() ? docSnap.data() : null;
|
|
13795
13943
|
} catch (error) {
|
|
13796
13944
|
console.error(
|
|
@@ -13807,8 +13955,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13807
13955
|
*/
|
|
13808
13956
|
async getClinicById(clinicId) {
|
|
13809
13957
|
try {
|
|
13810
|
-
const docRef = (0,
|
|
13811
|
-
const docSnap = await (0,
|
|
13958
|
+
const docRef = (0, import_firestore41.doc)(this.db, CLINICS_COLLECTION, clinicId);
|
|
13959
|
+
const docSnap = await (0, import_firestore41.getDoc)(docRef);
|
|
13812
13960
|
return docSnap.exists() ? docSnap.data() : null;
|
|
13813
13961
|
} catch (error) {
|
|
13814
13962
|
console.error("[PractitionerInviteService] Error getting clinic:", error);
|
|
@@ -13823,14 +13971,14 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13823
13971
|
*/
|
|
13824
13972
|
async findExistingInvite(practitionerId, clinicId) {
|
|
13825
13973
|
try {
|
|
13826
|
-
const q = (0,
|
|
13827
|
-
(0,
|
|
13828
|
-
(0,
|
|
13829
|
-
(0,
|
|
13830
|
-
(0,
|
|
13831
|
-
(0,
|
|
13832
|
-
);
|
|
13833
|
-
const querySnapshot = await (0,
|
|
13974
|
+
const q = (0, import_firestore41.query)(
|
|
13975
|
+
(0, import_firestore41.collection)(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
13976
|
+
(0, import_firestore41.where)("practitionerId", "==", practitionerId),
|
|
13977
|
+
(0, import_firestore41.where)("clinicId", "==", clinicId),
|
|
13978
|
+
(0, import_firestore41.orderBy)("createdAt", "desc"),
|
|
13979
|
+
(0, import_firestore41.limit)(1)
|
|
13980
|
+
);
|
|
13981
|
+
const querySnapshot = await (0, import_firestore41.getDocs)(q);
|
|
13834
13982
|
if (querySnapshot.empty) {
|
|
13835
13983
|
return null;
|
|
13836
13984
|
}
|
|
@@ -13846,12 +13994,12 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
13846
13994
|
};
|
|
13847
13995
|
|
|
13848
13996
|
// src/services/documentation-templates/documentation-template.service.ts
|
|
13849
|
-
var import_firestore41 = require("firebase/firestore");
|
|
13850
13997
|
var import_firestore42 = require("firebase/firestore");
|
|
13998
|
+
var import_firestore43 = require("firebase/firestore");
|
|
13851
13999
|
var DocumentationTemplateService = class extends BaseService {
|
|
13852
14000
|
constructor(...args) {
|
|
13853
14001
|
super(...args);
|
|
13854
|
-
this.collectionRef = (0,
|
|
14002
|
+
this.collectionRef = (0, import_firestore42.collection)(
|
|
13855
14003
|
this.db,
|
|
13856
14004
|
DOCUMENTATION_TEMPLATES_COLLECTION
|
|
13857
14005
|
);
|
|
@@ -13885,8 +14033,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13885
14033
|
isRequired: validatedData.isRequired || false,
|
|
13886
14034
|
sortingOrder: validatedData.sortingOrder || 0
|
|
13887
14035
|
};
|
|
13888
|
-
const docRef = (0,
|
|
13889
|
-
await (0,
|
|
14036
|
+
const docRef = (0, import_firestore42.doc)(this.collectionRef, templateId);
|
|
14037
|
+
await (0, import_firestore42.setDoc)(docRef, template);
|
|
13890
14038
|
return template;
|
|
13891
14039
|
}
|
|
13892
14040
|
/**
|
|
@@ -13896,8 +14044,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13896
14044
|
* @returns The template or null if not found
|
|
13897
14045
|
*/
|
|
13898
14046
|
async getTemplateById(templateId, version) {
|
|
13899
|
-
const docRef = (0,
|
|
13900
|
-
const docSnap = await (0,
|
|
14047
|
+
const docRef = (0, import_firestore42.doc)(this.collectionRef, templateId);
|
|
14048
|
+
const docSnap = await (0, import_firestore42.getDoc)(docRef);
|
|
13901
14049
|
if (!docSnap.exists()) {
|
|
13902
14050
|
return null;
|
|
13903
14051
|
}
|
|
@@ -13935,15 +14083,15 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13935
14083
|
if (!template) {
|
|
13936
14084
|
throw new Error(`Template with ID ${templateId} not found`);
|
|
13937
14085
|
}
|
|
13938
|
-
const versionsCollectionRef = (0,
|
|
14086
|
+
const versionsCollectionRef = (0, import_firestore42.collection)(
|
|
13939
14087
|
this.db,
|
|
13940
14088
|
`${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions`
|
|
13941
14089
|
);
|
|
13942
|
-
const versionDocRef = (0,
|
|
14090
|
+
const versionDocRef = (0, import_firestore42.doc)(
|
|
13943
14091
|
versionsCollectionRef,
|
|
13944
14092
|
template.version.toString()
|
|
13945
14093
|
);
|
|
13946
|
-
await (0,
|
|
14094
|
+
await (0, import_firestore42.setDoc)(versionDocRef, template);
|
|
13947
14095
|
let updatedElements = template.elements;
|
|
13948
14096
|
if (validatedData.elements) {
|
|
13949
14097
|
updatedElements = validatedData.elements.map((element) => ({
|
|
@@ -13967,9 +14115,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13967
14115
|
updatePayload.isUserForm = (_a = validatedData.isUserForm) != null ? _a : false;
|
|
13968
14116
|
updatePayload.isRequired = (_b = validatedData.isRequired) != null ? _b : false;
|
|
13969
14117
|
updatePayload.sortingOrder = (_c = validatedData.sortingOrder) != null ? _c : 0;
|
|
13970
|
-
const docRef = (0,
|
|
14118
|
+
const docRef = (0, import_firestore42.doc)(this.collectionRef, templateId);
|
|
13971
14119
|
console.log("Update payload", updatePayload);
|
|
13972
|
-
await (0,
|
|
14120
|
+
await (0, import_firestore42.updateDoc)(docRef, updatePayload);
|
|
13973
14121
|
return { ...template, ...updatePayload };
|
|
13974
14122
|
}
|
|
13975
14123
|
/**
|
|
@@ -13979,11 +14127,11 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13979
14127
|
* @returns The template version or null if not found
|
|
13980
14128
|
*/
|
|
13981
14129
|
async getTemplateVersion(templateId, versionNumber) {
|
|
13982
|
-
const versionDocRef = (0,
|
|
14130
|
+
const versionDocRef = (0, import_firestore42.doc)(
|
|
13983
14131
|
this.db,
|
|
13984
14132
|
`${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions/${versionNumber}`
|
|
13985
14133
|
);
|
|
13986
|
-
const versionDocSnap = await (0,
|
|
14134
|
+
const versionDocSnap = await (0, import_firestore42.getDoc)(versionDocRef);
|
|
13987
14135
|
if (!versionDocSnap.exists()) {
|
|
13988
14136
|
return null;
|
|
13989
14137
|
}
|
|
@@ -13995,12 +14143,12 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
13995
14143
|
* @returns Array of template versions
|
|
13996
14144
|
*/
|
|
13997
14145
|
async getTemplateOldVersions(templateId) {
|
|
13998
|
-
const versionsCollectionRef = (0,
|
|
14146
|
+
const versionsCollectionRef = (0, import_firestore42.collection)(
|
|
13999
14147
|
this.db,
|
|
14000
14148
|
`${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions`
|
|
14001
14149
|
);
|
|
14002
|
-
const q = (0,
|
|
14003
|
-
const querySnapshot = await (0,
|
|
14150
|
+
const q = (0, import_firestore42.query)(versionsCollectionRef, (0, import_firestore42.orderBy)("version", "desc"));
|
|
14151
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14004
14152
|
const versions = [];
|
|
14005
14153
|
querySnapshot.forEach((doc38) => {
|
|
14006
14154
|
versions.push(doc38.data());
|
|
@@ -14012,8 +14160,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14012
14160
|
* @param templateId - ID of the template to delete
|
|
14013
14161
|
*/
|
|
14014
14162
|
async deleteTemplate(templateId) {
|
|
14015
|
-
const docRef = (0,
|
|
14016
|
-
await (0,
|
|
14163
|
+
const docRef = (0, import_firestore42.doc)(this.collectionRef, templateId);
|
|
14164
|
+
await (0, import_firestore42.deleteDoc)(docRef);
|
|
14017
14165
|
}
|
|
14018
14166
|
/**
|
|
14019
14167
|
* Get all active templates
|
|
@@ -14022,16 +14170,16 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14022
14170
|
* @returns Array of templates and the last document for pagination
|
|
14023
14171
|
*/
|
|
14024
14172
|
async getActiveTemplates(pageSize = 20, lastDoc) {
|
|
14025
|
-
let q = (0,
|
|
14173
|
+
let q = (0, import_firestore42.query)(
|
|
14026
14174
|
this.collectionRef,
|
|
14027
|
-
(0,
|
|
14028
|
-
(0,
|
|
14029
|
-
(0,
|
|
14175
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
14176
|
+
(0, import_firestore42.orderBy)("updatedAt", "desc"),
|
|
14177
|
+
(0, import_firestore42.limit)(pageSize)
|
|
14030
14178
|
);
|
|
14031
14179
|
if (lastDoc) {
|
|
14032
|
-
q = (0,
|
|
14180
|
+
q = (0, import_firestore42.query)(q, (0, import_firestore42.startAfter)(lastDoc));
|
|
14033
14181
|
}
|
|
14034
|
-
const querySnapshot = await (0,
|
|
14182
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14035
14183
|
const templates = [];
|
|
14036
14184
|
let lastVisible = null;
|
|
14037
14185
|
querySnapshot.forEach((doc38) => {
|
|
@@ -14057,25 +14205,25 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14057
14205
|
sortingOrder
|
|
14058
14206
|
} = options;
|
|
14059
14207
|
const constraints = [
|
|
14060
|
-
(0,
|
|
14061
|
-
(0,
|
|
14062
|
-
(0,
|
|
14063
|
-
(0,
|
|
14208
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
14209
|
+
(0, import_firestore42.orderBy)("sortingOrder", "asc"),
|
|
14210
|
+
(0, import_firestore42.orderBy)("title", "asc"),
|
|
14211
|
+
(0, import_firestore42.limit)(pageSize)
|
|
14064
14212
|
];
|
|
14065
14213
|
if (isUserForm !== void 0) {
|
|
14066
|
-
constraints.push((0,
|
|
14214
|
+
constraints.push((0, import_firestore42.where)("isUserForm", "==", isUserForm));
|
|
14067
14215
|
}
|
|
14068
14216
|
if (isRequired !== void 0) {
|
|
14069
|
-
constraints.push((0,
|
|
14217
|
+
constraints.push((0, import_firestore42.where)("isRequired", "==", isRequired));
|
|
14070
14218
|
}
|
|
14071
14219
|
if (sortingOrder !== void 0) {
|
|
14072
|
-
constraints.push((0,
|
|
14220
|
+
constraints.push((0, import_firestore42.where)("sortingOrder", "==", sortingOrder));
|
|
14073
14221
|
}
|
|
14074
14222
|
if (lastDoc) {
|
|
14075
|
-
constraints.push((0,
|
|
14223
|
+
constraints.push((0, import_firestore42.startAfter)(lastDoc));
|
|
14076
14224
|
}
|
|
14077
|
-
const q = (0,
|
|
14078
|
-
const querySnapshot = await (0,
|
|
14225
|
+
const q = (0, import_firestore42.query)(this.collectionRef, ...constraints.filter((c) => c));
|
|
14226
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14079
14227
|
const templates = [];
|
|
14080
14228
|
let lastVisible = null;
|
|
14081
14229
|
querySnapshot.forEach((doc38) => {
|
|
@@ -14094,18 +14242,18 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14094
14242
|
*/
|
|
14095
14243
|
async getTemplatesCount(options) {
|
|
14096
14244
|
const { isUserForm, isRequired, sortingOrder } = options;
|
|
14097
|
-
const constraints = [(0,
|
|
14245
|
+
const constraints = [(0, import_firestore42.where)("isActive", "==", true)];
|
|
14098
14246
|
if (isUserForm !== void 0) {
|
|
14099
|
-
constraints.push((0,
|
|
14247
|
+
constraints.push((0, import_firestore42.where)("isUserForm", "==", isUserForm));
|
|
14100
14248
|
}
|
|
14101
14249
|
if (isRequired !== void 0) {
|
|
14102
|
-
constraints.push((0,
|
|
14250
|
+
constraints.push((0, import_firestore42.where)("isRequired", "==", isRequired));
|
|
14103
14251
|
}
|
|
14104
14252
|
if (sortingOrder !== void 0) {
|
|
14105
|
-
constraints.push((0,
|
|
14253
|
+
constraints.push((0, import_firestore42.where)("sortingOrder", "==", sortingOrder));
|
|
14106
14254
|
}
|
|
14107
|
-
const q = (0,
|
|
14108
|
-
const snapshot = await (0,
|
|
14255
|
+
const q = (0, import_firestore42.query)(this.collectionRef, ...constraints.filter((c) => c));
|
|
14256
|
+
const snapshot = await (0, import_firestore43.getCountFromServer)(q);
|
|
14109
14257
|
return snapshot.data().count;
|
|
14110
14258
|
}
|
|
14111
14259
|
/**
|
|
@@ -14113,12 +14261,12 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14113
14261
|
* @returns A promise that resolves to an array of all active templates.
|
|
14114
14262
|
*/
|
|
14115
14263
|
async getAllActiveTemplates() {
|
|
14116
|
-
const q = (0,
|
|
14264
|
+
const q = (0, import_firestore42.query)(
|
|
14117
14265
|
this.collectionRef,
|
|
14118
|
-
(0,
|
|
14119
|
-
(0,
|
|
14266
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
14267
|
+
(0, import_firestore42.orderBy)("title", "asc")
|
|
14120
14268
|
);
|
|
14121
|
-
const querySnapshot = await (0,
|
|
14269
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14122
14270
|
const templates = [];
|
|
14123
14271
|
querySnapshot.forEach((doc38) => {
|
|
14124
14272
|
templates.push(doc38.data());
|
|
@@ -14133,17 +14281,17 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14133
14281
|
* @returns Array of templates and the last document for pagination
|
|
14134
14282
|
*/
|
|
14135
14283
|
async getTemplatesByTags(tags, pageSize = 20, lastDoc) {
|
|
14136
|
-
let q = (0,
|
|
14284
|
+
let q = (0, import_firestore42.query)(
|
|
14137
14285
|
this.collectionRef,
|
|
14138
|
-
(0,
|
|
14139
|
-
(0,
|
|
14140
|
-
(0,
|
|
14141
|
-
(0,
|
|
14286
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
14287
|
+
(0, import_firestore42.where)("tags", "array-contains-any", tags),
|
|
14288
|
+
(0, import_firestore42.orderBy)("updatedAt", "desc"),
|
|
14289
|
+
(0, import_firestore42.limit)(pageSize)
|
|
14142
14290
|
);
|
|
14143
14291
|
if (lastDoc) {
|
|
14144
|
-
q = (0,
|
|
14292
|
+
q = (0, import_firestore42.query)(q, (0, import_firestore42.startAfter)(lastDoc));
|
|
14145
14293
|
}
|
|
14146
|
-
const querySnapshot = await (0,
|
|
14294
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14147
14295
|
const templates = [];
|
|
14148
14296
|
let lastVisible = null;
|
|
14149
14297
|
querySnapshot.forEach((doc38) => {
|
|
@@ -14163,16 +14311,16 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14163
14311
|
* @returns Array of templates and the last document for pagination
|
|
14164
14312
|
*/
|
|
14165
14313
|
async getTemplatesByCreator(userId, pageSize = 20, lastDoc) {
|
|
14166
|
-
let q = (0,
|
|
14314
|
+
let q = (0, import_firestore42.query)(
|
|
14167
14315
|
this.collectionRef,
|
|
14168
|
-
(0,
|
|
14169
|
-
(0,
|
|
14170
|
-
(0,
|
|
14316
|
+
(0, import_firestore42.where)("createdBy", "==", userId),
|
|
14317
|
+
(0, import_firestore42.orderBy)("updatedAt", "desc"),
|
|
14318
|
+
(0, import_firestore42.limit)(pageSize)
|
|
14171
14319
|
);
|
|
14172
14320
|
if (lastDoc) {
|
|
14173
|
-
q = (0,
|
|
14321
|
+
q = (0, import_firestore42.query)(q, (0, import_firestore42.startAfter)(lastDoc));
|
|
14174
14322
|
}
|
|
14175
|
-
const querySnapshot = await (0,
|
|
14323
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14176
14324
|
const templates = [];
|
|
14177
14325
|
let lastVisible = null;
|
|
14178
14326
|
querySnapshot.forEach((doc38) => {
|
|
@@ -14190,18 +14338,18 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14190
14338
|
* @returns Array of templates
|
|
14191
14339
|
*/
|
|
14192
14340
|
async getAllTemplatesForSelection(options) {
|
|
14193
|
-
let q = (0,
|
|
14341
|
+
let q = (0, import_firestore42.query)(
|
|
14194
14342
|
this.collectionRef,
|
|
14195
|
-
(0,
|
|
14196
|
-
(0,
|
|
14343
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
14344
|
+
(0, import_firestore42.orderBy)("updatedAt", "desc")
|
|
14197
14345
|
);
|
|
14198
14346
|
if ((options == null ? void 0 : options.isUserForm) !== void 0) {
|
|
14199
|
-
q = (0,
|
|
14347
|
+
q = (0, import_firestore42.query)(q, (0, import_firestore42.where)("isUserForm", "==", options.isUserForm));
|
|
14200
14348
|
}
|
|
14201
14349
|
if ((options == null ? void 0 : options.isRequired) !== void 0) {
|
|
14202
|
-
q = (0,
|
|
14350
|
+
q = (0, import_firestore42.query)(q, (0, import_firestore42.where)("isRequired", "==", options.isRequired));
|
|
14203
14351
|
}
|
|
14204
|
-
const querySnapshot = await (0,
|
|
14352
|
+
const querySnapshot = await (0, import_firestore42.getDocs)(q);
|
|
14205
14353
|
const templates = [];
|
|
14206
14354
|
querySnapshot.forEach((doc38) => {
|
|
14207
14355
|
templates.push(doc38.data());
|
|
@@ -14211,7 +14359,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
14211
14359
|
};
|
|
14212
14360
|
|
|
14213
14361
|
// src/services/documentation-templates/filled-document.service.ts
|
|
14214
|
-
var
|
|
14362
|
+
var import_firestore44 = require("firebase/firestore");
|
|
14215
14363
|
var FilledDocumentService = class extends BaseService {
|
|
14216
14364
|
constructor(...args) {
|
|
14217
14365
|
super(...args);
|
|
@@ -14266,7 +14414,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14266
14414
|
values: initialValues,
|
|
14267
14415
|
status: initialStatus
|
|
14268
14416
|
};
|
|
14269
|
-
const docRef = (0,
|
|
14417
|
+
const docRef = (0, import_firestore44.doc)(
|
|
14270
14418
|
this.db,
|
|
14271
14419
|
APPOINTMENTS_COLLECTION,
|
|
14272
14420
|
// Replaced "appointments"
|
|
@@ -14274,7 +14422,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14274
14422
|
formSubcollection,
|
|
14275
14423
|
documentId3
|
|
14276
14424
|
);
|
|
14277
|
-
await (0,
|
|
14425
|
+
await (0, import_firestore44.setDoc)(docRef, filledDocument);
|
|
14278
14426
|
return filledDocument;
|
|
14279
14427
|
}
|
|
14280
14428
|
/**
|
|
@@ -14286,7 +14434,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14286
14434
|
*/
|
|
14287
14435
|
async getFilledDocumentFromAppointmentById(appointmentId, formId, isUserForm) {
|
|
14288
14436
|
const formSubcollection = this.getFormSubcollectionPath(isUserForm);
|
|
14289
|
-
const docRef = (0,
|
|
14437
|
+
const docRef = (0, import_firestore44.doc)(
|
|
14290
14438
|
this.db,
|
|
14291
14439
|
APPOINTMENTS_COLLECTION,
|
|
14292
14440
|
// Replaced "appointments"
|
|
@@ -14294,7 +14442,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14294
14442
|
formSubcollection,
|
|
14295
14443
|
formId
|
|
14296
14444
|
);
|
|
14297
|
-
const docSnap = await (0,
|
|
14445
|
+
const docSnap = await (0, import_firestore44.getDoc)(docRef);
|
|
14298
14446
|
if (!docSnap.exists()) {
|
|
14299
14447
|
return null;
|
|
14300
14448
|
}
|
|
@@ -14311,7 +14459,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14311
14459
|
*/
|
|
14312
14460
|
async updateFilledDocumentInAppointment(appointmentId, formId, isUserForm, values, status) {
|
|
14313
14461
|
const formSubcollection = this.getFormSubcollectionPath(isUserForm);
|
|
14314
|
-
const docRef = (0,
|
|
14462
|
+
const docRef = (0, import_firestore44.doc)(
|
|
14315
14463
|
this.db,
|
|
14316
14464
|
APPOINTMENTS_COLLECTION,
|
|
14317
14465
|
// Replaced "appointments"
|
|
@@ -14343,7 +14491,7 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14343
14491
|
}
|
|
14344
14492
|
if (Object.keys(updatePayload).length === 1 && "updatedAt" in updatePayload) {
|
|
14345
14493
|
}
|
|
14346
|
-
await (0,
|
|
14494
|
+
await (0, import_firestore44.updateDoc)(docRef, updatePayload);
|
|
14347
14495
|
return { ...existingDoc, ...updatePayload };
|
|
14348
14496
|
}
|
|
14349
14497
|
/**
|
|
@@ -14353,20 +14501,20 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14353
14501
|
* @param lastDoc Last document from previous page for pagination.
|
|
14354
14502
|
*/
|
|
14355
14503
|
async getFilledUserFormsForAppointment(appointmentId, pageSize = 20, lastDoc) {
|
|
14356
|
-
const subcollectionRef = (0,
|
|
14504
|
+
const subcollectionRef = (0, import_firestore44.collection)(
|
|
14357
14505
|
this.db,
|
|
14358
14506
|
APPOINTMENTS_COLLECTION,
|
|
14359
14507
|
// Replaced "appointments"
|
|
14360
14508
|
appointmentId,
|
|
14361
14509
|
USER_FORMS_SUBCOLLECTION
|
|
14362
14510
|
);
|
|
14363
|
-
let q = (0,
|
|
14511
|
+
let q = (0, import_firestore44.query)(
|
|
14364
14512
|
subcollectionRef,
|
|
14365
|
-
(0,
|
|
14366
|
-
(0,
|
|
14513
|
+
(0, import_firestore44.orderBy)("updatedAt", "desc"),
|
|
14514
|
+
(0, import_firestore44.limit)(pageSize)
|
|
14367
14515
|
);
|
|
14368
14516
|
if (lastDoc) {
|
|
14369
|
-
q = (0,
|
|
14517
|
+
q = (0, import_firestore44.query)(q, (0, import_firestore44.startAfter)(lastDoc));
|
|
14370
14518
|
}
|
|
14371
14519
|
return this.executeQuery(q);
|
|
14372
14520
|
}
|
|
@@ -14377,26 +14525,26 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14377
14525
|
* @param lastDoc Last document from previous page for pagination.
|
|
14378
14526
|
*/
|
|
14379
14527
|
async getFilledDoctorFormsForAppointment(appointmentId, pageSize = 20, lastDoc) {
|
|
14380
|
-
const subcollectionRef = (0,
|
|
14528
|
+
const subcollectionRef = (0, import_firestore44.collection)(
|
|
14381
14529
|
this.db,
|
|
14382
14530
|
APPOINTMENTS_COLLECTION,
|
|
14383
14531
|
// Replaced "appointments"
|
|
14384
14532
|
appointmentId,
|
|
14385
14533
|
DOCTOR_FORMS_SUBCOLLECTION
|
|
14386
14534
|
);
|
|
14387
|
-
let q = (0,
|
|
14535
|
+
let q = (0, import_firestore44.query)(
|
|
14388
14536
|
subcollectionRef,
|
|
14389
|
-
(0,
|
|
14390
|
-
(0,
|
|
14537
|
+
(0, import_firestore44.orderBy)("updatedAt", "desc"),
|
|
14538
|
+
(0, import_firestore44.limit)(pageSize)
|
|
14391
14539
|
);
|
|
14392
14540
|
if (lastDoc) {
|
|
14393
|
-
q = (0,
|
|
14541
|
+
q = (0, import_firestore44.query)(q, (0, import_firestore44.startAfter)(lastDoc));
|
|
14394
14542
|
}
|
|
14395
14543
|
return this.executeQuery(q);
|
|
14396
14544
|
}
|
|
14397
14545
|
// Helper to execute query and return documents + lastDoc
|
|
14398
14546
|
async executeQuery(q) {
|
|
14399
|
-
const querySnapshot = await (0,
|
|
14547
|
+
const querySnapshot = await (0, import_firestore44.getDocs)(q);
|
|
14400
14548
|
const documents = [];
|
|
14401
14549
|
let lastVisible = null;
|
|
14402
14550
|
querySnapshot.forEach((doc38) => {
|
|
@@ -14560,14 +14708,14 @@ var FilledDocumentService = class extends BaseService {
|
|
|
14560
14708
|
};
|
|
14561
14709
|
|
|
14562
14710
|
// src/services/notifications/notification.service.ts
|
|
14563
|
-
var
|
|
14711
|
+
var import_firestore45 = require("firebase/firestore");
|
|
14564
14712
|
var NotificationService = class extends BaseService {
|
|
14565
14713
|
/**
|
|
14566
14714
|
* Kreira novu notifikaciju
|
|
14567
14715
|
*/
|
|
14568
14716
|
async createNotification(notification) {
|
|
14569
|
-
const notificationsRef = (0,
|
|
14570
|
-
const now =
|
|
14717
|
+
const notificationsRef = (0, import_firestore45.collection)(this.db, NOTIFICATIONS_COLLECTION);
|
|
14718
|
+
const now = import_firestore45.Timestamp.now();
|
|
14571
14719
|
const notificationData = {
|
|
14572
14720
|
...notification,
|
|
14573
14721
|
createdAt: now,
|
|
@@ -14576,7 +14724,7 @@ var NotificationService = class extends BaseService {
|
|
|
14576
14724
|
isRead: false,
|
|
14577
14725
|
userRole: notification.userRole || "patient" /* PATIENT */
|
|
14578
14726
|
};
|
|
14579
|
-
const docRef = await (0,
|
|
14727
|
+
const docRef = await (0, import_firestore45.addDoc)(notificationsRef, notificationData);
|
|
14580
14728
|
return {
|
|
14581
14729
|
...notificationData,
|
|
14582
14730
|
id: docRef.id
|
|
@@ -14586,12 +14734,12 @@ var NotificationService = class extends BaseService {
|
|
|
14586
14734
|
* Dohvata notifikaciju po ID-u
|
|
14587
14735
|
*/
|
|
14588
14736
|
async getNotification(notificationId) {
|
|
14589
|
-
const notificationRef = (0,
|
|
14737
|
+
const notificationRef = (0, import_firestore45.doc)(
|
|
14590
14738
|
this.db,
|
|
14591
14739
|
NOTIFICATIONS_COLLECTION,
|
|
14592
14740
|
notificationId
|
|
14593
14741
|
);
|
|
14594
|
-
const notificationDoc = await (0,
|
|
14742
|
+
const notificationDoc = await (0, import_firestore45.getDoc)(notificationRef);
|
|
14595
14743
|
if (!notificationDoc.exists()) {
|
|
14596
14744
|
return null;
|
|
14597
14745
|
}
|
|
@@ -14604,12 +14752,12 @@ var NotificationService = class extends BaseService {
|
|
|
14604
14752
|
* Dohvata sve notifikacije za korisnika
|
|
14605
14753
|
*/
|
|
14606
14754
|
async getUserNotifications(userId) {
|
|
14607
|
-
const q = (0,
|
|
14608
|
-
(0,
|
|
14609
|
-
(0,
|
|
14610
|
-
(0,
|
|
14755
|
+
const q = (0, import_firestore45.query)(
|
|
14756
|
+
(0, import_firestore45.collection)(this.db, NOTIFICATIONS_COLLECTION),
|
|
14757
|
+
(0, import_firestore45.where)("userId", "==", userId),
|
|
14758
|
+
(0, import_firestore45.orderBy)("notificationTime", "desc")
|
|
14611
14759
|
);
|
|
14612
|
-
const querySnapshot = await (0,
|
|
14760
|
+
const querySnapshot = await (0, import_firestore45.getDocs)(q);
|
|
14613
14761
|
return querySnapshot.docs.map((doc38) => ({
|
|
14614
14762
|
id: doc38.id,
|
|
14615
14763
|
...doc38.data()
|
|
@@ -14619,13 +14767,13 @@ var NotificationService = class extends BaseService {
|
|
|
14619
14767
|
* Dohvata nepročitane notifikacije za korisnika
|
|
14620
14768
|
*/
|
|
14621
14769
|
async getUnreadNotifications(userId) {
|
|
14622
|
-
const q = (0,
|
|
14623
|
-
(0,
|
|
14624
|
-
(0,
|
|
14625
|
-
(0,
|
|
14626
|
-
(0,
|
|
14770
|
+
const q = (0, import_firestore45.query)(
|
|
14771
|
+
(0, import_firestore45.collection)(this.db, NOTIFICATIONS_COLLECTION),
|
|
14772
|
+
(0, import_firestore45.where)("userId", "==", userId),
|
|
14773
|
+
(0, import_firestore45.where)("isRead", "==", false),
|
|
14774
|
+
(0, import_firestore45.orderBy)("notificationTime", "desc")
|
|
14627
14775
|
);
|
|
14628
|
-
const querySnapshot = await (0,
|
|
14776
|
+
const querySnapshot = await (0, import_firestore45.getDocs)(q);
|
|
14629
14777
|
return querySnapshot.docs.map((doc38) => ({
|
|
14630
14778
|
id: doc38.id,
|
|
14631
14779
|
...doc38.data()
|
|
@@ -14635,14 +14783,14 @@ var NotificationService = class extends BaseService {
|
|
|
14635
14783
|
* Označava notifikaciju kao pročitanu
|
|
14636
14784
|
*/
|
|
14637
14785
|
async markAsRead(notificationId) {
|
|
14638
|
-
const notificationRef = (0,
|
|
14786
|
+
const notificationRef = (0, import_firestore45.doc)(
|
|
14639
14787
|
this.db,
|
|
14640
14788
|
NOTIFICATIONS_COLLECTION,
|
|
14641
14789
|
notificationId
|
|
14642
14790
|
);
|
|
14643
|
-
await (0,
|
|
14791
|
+
await (0, import_firestore45.updateDoc)(notificationRef, {
|
|
14644
14792
|
isRead: true,
|
|
14645
|
-
updatedAt:
|
|
14793
|
+
updatedAt: import_firestore45.Timestamp.now()
|
|
14646
14794
|
});
|
|
14647
14795
|
}
|
|
14648
14796
|
/**
|
|
@@ -14650,16 +14798,16 @@ var NotificationService = class extends BaseService {
|
|
|
14650
14798
|
*/
|
|
14651
14799
|
async markAllAsRead(userId) {
|
|
14652
14800
|
const notifications = await this.getUnreadNotifications(userId);
|
|
14653
|
-
const batch = (0,
|
|
14801
|
+
const batch = (0, import_firestore45.writeBatch)(this.db);
|
|
14654
14802
|
notifications.forEach((notification) => {
|
|
14655
|
-
const notificationRef = (0,
|
|
14803
|
+
const notificationRef = (0, import_firestore45.doc)(
|
|
14656
14804
|
this.db,
|
|
14657
14805
|
NOTIFICATIONS_COLLECTION,
|
|
14658
14806
|
notification.id
|
|
14659
14807
|
);
|
|
14660
14808
|
batch.update(notificationRef, {
|
|
14661
14809
|
isRead: true,
|
|
14662
|
-
updatedAt:
|
|
14810
|
+
updatedAt: import_firestore45.Timestamp.now()
|
|
14663
14811
|
});
|
|
14664
14812
|
});
|
|
14665
14813
|
await batch.commit();
|
|
@@ -14668,38 +14816,38 @@ var NotificationService = class extends BaseService {
|
|
|
14668
14816
|
* Ažurira status notifikacije
|
|
14669
14817
|
*/
|
|
14670
14818
|
async updateNotificationStatus(notificationId, status) {
|
|
14671
|
-
const notificationRef = (0,
|
|
14819
|
+
const notificationRef = (0, import_firestore45.doc)(
|
|
14672
14820
|
this.db,
|
|
14673
14821
|
NOTIFICATIONS_COLLECTION,
|
|
14674
14822
|
notificationId
|
|
14675
14823
|
);
|
|
14676
|
-
await (0,
|
|
14824
|
+
await (0, import_firestore45.updateDoc)(notificationRef, {
|
|
14677
14825
|
status,
|
|
14678
|
-
updatedAt:
|
|
14826
|
+
updatedAt: import_firestore45.Timestamp.now()
|
|
14679
14827
|
});
|
|
14680
14828
|
}
|
|
14681
14829
|
/**
|
|
14682
14830
|
* Briše notifikaciju
|
|
14683
14831
|
*/
|
|
14684
14832
|
async deleteNotification(notificationId) {
|
|
14685
|
-
const notificationRef = (0,
|
|
14833
|
+
const notificationRef = (0, import_firestore45.doc)(
|
|
14686
14834
|
this.db,
|
|
14687
14835
|
NOTIFICATIONS_COLLECTION,
|
|
14688
14836
|
notificationId
|
|
14689
14837
|
);
|
|
14690
|
-
await (0,
|
|
14838
|
+
await (0, import_firestore45.deleteDoc)(notificationRef);
|
|
14691
14839
|
}
|
|
14692
14840
|
/**
|
|
14693
14841
|
* Dohvata notifikacije po tipu
|
|
14694
14842
|
*/
|
|
14695
14843
|
async getNotificationsByType(userId, type) {
|
|
14696
|
-
const q = (0,
|
|
14697
|
-
(0,
|
|
14698
|
-
(0,
|
|
14699
|
-
(0,
|
|
14700
|
-
(0,
|
|
14844
|
+
const q = (0, import_firestore45.query)(
|
|
14845
|
+
(0, import_firestore45.collection)(this.db, NOTIFICATIONS_COLLECTION),
|
|
14846
|
+
(0, import_firestore45.where)("userId", "==", userId),
|
|
14847
|
+
(0, import_firestore45.where)("notificationType", "==", type),
|
|
14848
|
+
(0, import_firestore45.orderBy)("notificationTime", "desc")
|
|
14701
14849
|
);
|
|
14702
|
-
const querySnapshot = await (0,
|
|
14850
|
+
const querySnapshot = await (0, import_firestore45.getDocs)(q);
|
|
14703
14851
|
return querySnapshot.docs.map((doc38) => ({
|
|
14704
14852
|
id: doc38.id,
|
|
14705
14853
|
...doc38.data()
|
|
@@ -14709,12 +14857,12 @@ var NotificationService = class extends BaseService {
|
|
|
14709
14857
|
* Dohvata notifikacije za određeni termin
|
|
14710
14858
|
*/
|
|
14711
14859
|
async getAppointmentNotifications(appointmentId) {
|
|
14712
|
-
const q = (0,
|
|
14713
|
-
(0,
|
|
14714
|
-
(0,
|
|
14715
|
-
(0,
|
|
14860
|
+
const q = (0, import_firestore45.query)(
|
|
14861
|
+
(0, import_firestore45.collection)(this.db, NOTIFICATIONS_COLLECTION),
|
|
14862
|
+
(0, import_firestore45.where)("appointmentId", "==", appointmentId),
|
|
14863
|
+
(0, import_firestore45.orderBy)("notificationTime", "desc")
|
|
14716
14864
|
);
|
|
14717
|
-
const querySnapshot = await (0,
|
|
14865
|
+
const querySnapshot = await (0, import_firestore45.getDocs)(q);
|
|
14718
14866
|
return querySnapshot.docs.map((doc38) => ({
|
|
14719
14867
|
id: doc38.id,
|
|
14720
14868
|
...doc38.data()
|
|
@@ -14723,19 +14871,19 @@ var NotificationService = class extends BaseService {
|
|
|
14723
14871
|
};
|
|
14724
14872
|
|
|
14725
14873
|
// src/services/patient/patientRequirements.service.ts
|
|
14726
|
-
var
|
|
14874
|
+
var import_firestore46 = require("firebase/firestore");
|
|
14727
14875
|
var PatientRequirementsService = class extends BaseService {
|
|
14728
14876
|
constructor(db, auth, app) {
|
|
14729
14877
|
super(db, auth, app);
|
|
14730
14878
|
}
|
|
14731
14879
|
getPatientRequirementsCollectionRef(patientId) {
|
|
14732
|
-
return (0,
|
|
14880
|
+
return (0, import_firestore46.collection)(
|
|
14733
14881
|
this.db,
|
|
14734
14882
|
`patients/${patientId}/${PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME}`
|
|
14735
14883
|
);
|
|
14736
14884
|
}
|
|
14737
14885
|
getPatientRequirementDocRef(patientId, instanceId) {
|
|
14738
|
-
return (0,
|
|
14886
|
+
return (0, import_firestore46.doc)(
|
|
14739
14887
|
this.getPatientRequirementsCollectionRef(patientId),
|
|
14740
14888
|
instanceId
|
|
14741
14889
|
);
|
|
@@ -14748,7 +14896,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14748
14896
|
*/
|
|
14749
14897
|
async getPatientRequirementInstance(patientId, instanceId) {
|
|
14750
14898
|
const docRef = this.getPatientRequirementDocRef(patientId, instanceId);
|
|
14751
|
-
const docSnap = await (0,
|
|
14899
|
+
const docSnap = await (0, import_firestore46.getDoc)(docRef);
|
|
14752
14900
|
if (!docSnap.exists()) {
|
|
14753
14901
|
return null;
|
|
14754
14902
|
}
|
|
@@ -14767,22 +14915,22 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14767
14915
|
*/
|
|
14768
14916
|
async getAllPatientRequirementInstances(patientId, filters, pageLimit = 20, lastVisible) {
|
|
14769
14917
|
const collRef = this.getPatientRequirementsCollectionRef(patientId);
|
|
14770
|
-
let q = (0,
|
|
14918
|
+
let q = (0, import_firestore46.query)(collRef, (0, import_firestore46.orderBy)("createdAt", "desc"));
|
|
14771
14919
|
const queryConstraints = [];
|
|
14772
14920
|
if ((filters == null ? void 0 : filters.appointmentId) && filters.appointmentId !== "all") {
|
|
14773
14921
|
queryConstraints.push(
|
|
14774
|
-
(0,
|
|
14922
|
+
(0, import_firestore46.where)("appointmentId", "==", filters.appointmentId)
|
|
14775
14923
|
);
|
|
14776
14924
|
}
|
|
14777
14925
|
if ((filters == null ? void 0 : filters.statuses) && filters.statuses.length > 0) {
|
|
14778
|
-
queryConstraints.push((0,
|
|
14926
|
+
queryConstraints.push((0, import_firestore46.where)("overallStatus", "in", filters.statuses));
|
|
14779
14927
|
}
|
|
14780
14928
|
if (lastVisible) {
|
|
14781
|
-
queryConstraints.push((0,
|
|
14929
|
+
queryConstraints.push((0, import_firestore46.startAfter)(lastVisible));
|
|
14782
14930
|
}
|
|
14783
|
-
queryConstraints.push((0,
|
|
14784
|
-
q = (0,
|
|
14785
|
-
const snapshot = await (0,
|
|
14931
|
+
queryConstraints.push((0, import_firestore46.limit)(pageLimit));
|
|
14932
|
+
q = (0, import_firestore46.query)(collRef, ...queryConstraints);
|
|
14933
|
+
const snapshot = await (0, import_firestore46.getDocs)(q);
|
|
14786
14934
|
let requirements = snapshot.docs.map((docSnap) => {
|
|
14787
14935
|
const data = docSnap.data();
|
|
14788
14936
|
return { id: docSnap.id, ...data };
|
|
@@ -14825,7 +14973,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14825
14973
|
*/
|
|
14826
14974
|
async completeInstruction(patientId, instanceId, instructionId) {
|
|
14827
14975
|
const instanceRef = this.getPatientRequirementDocRef(patientId, instanceId);
|
|
14828
|
-
const instanceSnap = await (0,
|
|
14976
|
+
const instanceSnap = await (0, import_firestore46.getDoc)(instanceRef);
|
|
14829
14977
|
if (!instanceSnap.exists()) {
|
|
14830
14978
|
throw new Error(
|
|
14831
14979
|
`PatientRequirementInstance ${instanceId} not found for patient ${patientId}.`
|
|
@@ -14853,7 +15001,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14853
15001
|
`Instruction ${instructionId} is in status ${instructionToUpdate.status} and cannot be marked as completed.`
|
|
14854
15002
|
);
|
|
14855
15003
|
}
|
|
14856
|
-
const now =
|
|
15004
|
+
const now = import_firestore46.Timestamp.now();
|
|
14857
15005
|
const updatedInstructions = [...instance.instructions];
|
|
14858
15006
|
updatedInstructions[instructionIndex] = {
|
|
14859
15007
|
...instructionToUpdate,
|
|
@@ -14880,7 +15028,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14880
15028
|
if (newOverallStatus !== instance.overallStatus) {
|
|
14881
15029
|
updatePayload.overallStatus = newOverallStatus;
|
|
14882
15030
|
}
|
|
14883
|
-
await (0,
|
|
15031
|
+
await (0, import_firestore46.updateDoc)(instanceRef, updatePayload);
|
|
14884
15032
|
return {
|
|
14885
15033
|
...instance,
|
|
14886
15034
|
instructions: updatedInstructions,
|
|
@@ -14893,7 +15041,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
14893
15041
|
};
|
|
14894
15042
|
|
|
14895
15043
|
// src/services/procedure/procedure.service.ts
|
|
14896
|
-
var
|
|
15044
|
+
var import_firestore47 = require("firebase/firestore");
|
|
14897
15045
|
|
|
14898
15046
|
// src/validations/procedure.schema.ts
|
|
14899
15047
|
var import_zod25 = require("zod");
|
|
@@ -15139,14 +15287,14 @@ var ProcedureService = class extends BaseService {
|
|
|
15139
15287
|
if (!category || !subcategory || !technology || !product) {
|
|
15140
15288
|
throw new Error("One or more required base entities not found");
|
|
15141
15289
|
}
|
|
15142
|
-
const clinicRef = (0,
|
|
15143
|
-
const clinicSnapshot = await (0,
|
|
15290
|
+
const clinicRef = (0, import_firestore47.doc)(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
|
|
15291
|
+
const clinicSnapshot = await (0, import_firestore47.getDoc)(clinicRef);
|
|
15144
15292
|
if (!clinicSnapshot.exists()) {
|
|
15145
15293
|
throw new Error(`Clinic with ID ${validatedData.clinicBranchId} not found`);
|
|
15146
15294
|
}
|
|
15147
15295
|
const clinic = clinicSnapshot.data();
|
|
15148
|
-
const practitionerRef = (0,
|
|
15149
|
-
const practitionerSnapshot = await (0,
|
|
15296
|
+
const practitionerRef = (0, import_firestore47.doc)(this.db, PRACTITIONERS_COLLECTION, validatedData.practitionerId);
|
|
15297
|
+
const practitionerSnapshot = await (0, import_firestore47.getDoc)(practitionerRef);
|
|
15150
15298
|
if (!practitionerSnapshot.exists()) {
|
|
15151
15299
|
throw new Error(`Practitioner with ID ${validatedData.practitionerId} not found`);
|
|
15152
15300
|
}
|
|
@@ -15221,13 +15369,13 @@ var ProcedureService = class extends BaseService {
|
|
|
15221
15369
|
isActive: true
|
|
15222
15370
|
// Default to active
|
|
15223
15371
|
};
|
|
15224
|
-
const procedureRef = (0,
|
|
15225
|
-
await (0,
|
|
15372
|
+
const procedureRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
15373
|
+
await (0, import_firestore47.setDoc)(procedureRef, {
|
|
15226
15374
|
...newProcedure,
|
|
15227
|
-
createdAt: (0,
|
|
15228
|
-
updatedAt: (0,
|
|
15375
|
+
createdAt: (0, import_firestore47.serverTimestamp)(),
|
|
15376
|
+
updatedAt: (0, import_firestore47.serverTimestamp)()
|
|
15229
15377
|
});
|
|
15230
|
-
const savedDoc = await (0,
|
|
15378
|
+
const savedDoc = await (0, import_firestore47.getDoc)(procedureRef);
|
|
15231
15379
|
return savedDoc.data();
|
|
15232
15380
|
}
|
|
15233
15381
|
/**
|
|
@@ -15250,7 +15398,7 @@ var ProcedureService = class extends BaseService {
|
|
|
15250
15398
|
this.subcategoryService.getById(validatedData.categoryId, validatedData.subcategoryId),
|
|
15251
15399
|
this.technologyService.getById(validatedData.technologyId),
|
|
15252
15400
|
this.productService.getById(validatedData.technologyId, validatedData.productId),
|
|
15253
|
-
(0,
|
|
15401
|
+
(0, import_firestore47.getDoc)((0, import_firestore47.doc)(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId))
|
|
15254
15402
|
]);
|
|
15255
15403
|
if (!category || !subcategory || !technology || !product) {
|
|
15256
15404
|
throw new Error("One or more required base entities not found");
|
|
@@ -15275,11 +15423,11 @@ var ProcedureService = class extends BaseService {
|
|
|
15275
15423
|
const practitionersMap = /* @__PURE__ */ new Map();
|
|
15276
15424
|
for (let i = 0; i < practitionerIds.length; i += 30) {
|
|
15277
15425
|
const chunk = practitionerIds.slice(i, i + 30);
|
|
15278
|
-
const practitionersQuery = (0,
|
|
15279
|
-
(0,
|
|
15280
|
-
(0,
|
|
15426
|
+
const practitionersQuery = (0, import_firestore47.query)(
|
|
15427
|
+
(0, import_firestore47.collection)(this.db, PRACTITIONERS_COLLECTION),
|
|
15428
|
+
(0, import_firestore47.where)((0, import_firestore47.documentId)(), "in", chunk)
|
|
15281
15429
|
);
|
|
15282
|
-
const practitionersSnapshot = await (0,
|
|
15430
|
+
const practitionersSnapshot = await (0, import_firestore47.getDocs)(practitionersQuery);
|
|
15283
15431
|
practitionersSnapshot.docs.forEach((doc38) => {
|
|
15284
15432
|
practitionersMap.set(doc38.id, doc38.data());
|
|
15285
15433
|
});
|
|
@@ -15289,7 +15437,7 @@ var ProcedureService = class extends BaseService {
|
|
|
15289
15437
|
const notFoundIds = practitionerIds.filter((id) => !foundIds.includes(id));
|
|
15290
15438
|
throw new Error(`The following practitioners were not found: ${notFoundIds.join(", ")}`);
|
|
15291
15439
|
}
|
|
15292
|
-
const batch = (0,
|
|
15440
|
+
const batch = (0, import_firestore47.writeBatch)(this.db);
|
|
15293
15441
|
const createdProcedureIds = [];
|
|
15294
15442
|
const clinicInfo = {
|
|
15295
15443
|
id: clinicSnapshot.id,
|
|
@@ -15311,7 +15459,7 @@ var ProcedureService = class extends BaseService {
|
|
|
15311
15459
|
};
|
|
15312
15460
|
const procedureId = this.generateId();
|
|
15313
15461
|
createdProcedureIds.push(procedureId);
|
|
15314
|
-
const procedureRef = (0,
|
|
15462
|
+
const procedureRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
15315
15463
|
const { productsMetadata: _, ...validatedDataWithoutProductsMetadata } = validatedData;
|
|
15316
15464
|
const newProcedure = {
|
|
15317
15465
|
id: procedureId,
|
|
@@ -15352,16 +15500,16 @@ var ProcedureService = class extends BaseService {
|
|
|
15352
15500
|
};
|
|
15353
15501
|
batch.set(procedureRef, {
|
|
15354
15502
|
...newProcedure,
|
|
15355
|
-
createdAt: (0,
|
|
15356
|
-
updatedAt: (0,
|
|
15503
|
+
createdAt: (0, import_firestore47.serverTimestamp)(),
|
|
15504
|
+
updatedAt: (0, import_firestore47.serverTimestamp)()
|
|
15357
15505
|
});
|
|
15358
15506
|
}
|
|
15359
15507
|
await batch.commit();
|
|
15360
15508
|
const fetchedProcedures = [];
|
|
15361
15509
|
for (let i = 0; i < createdProcedureIds.length; i += 30) {
|
|
15362
15510
|
const chunk = createdProcedureIds.slice(i, i + 30);
|
|
15363
|
-
const q = (0,
|
|
15364
|
-
const snapshot = await (0,
|
|
15511
|
+
const q = (0, import_firestore47.query)((0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION), (0, import_firestore47.where)((0, import_firestore47.documentId)(), "in", chunk));
|
|
15512
|
+
const snapshot = await (0, import_firestore47.getDocs)(q);
|
|
15365
15513
|
snapshot.forEach((doc38) => {
|
|
15366
15514
|
fetchedProcedures.push(doc38.data());
|
|
15367
15515
|
});
|
|
@@ -15374,8 +15522,8 @@ var ProcedureService = class extends BaseService {
|
|
|
15374
15522
|
* @returns The procedure if found, null otherwise
|
|
15375
15523
|
*/
|
|
15376
15524
|
async getProcedure(id) {
|
|
15377
|
-
const docRef = (0,
|
|
15378
|
-
const docSnap = await (0,
|
|
15525
|
+
const docRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, id);
|
|
15526
|
+
const docSnap = await (0, import_firestore47.getDoc)(docRef);
|
|
15379
15527
|
if (!docSnap.exists()) {
|
|
15380
15528
|
return null;
|
|
15381
15529
|
}
|
|
@@ -15387,12 +15535,12 @@ var ProcedureService = class extends BaseService {
|
|
|
15387
15535
|
* @returns List of procedures
|
|
15388
15536
|
*/
|
|
15389
15537
|
async getProceduresByClinicBranch(clinicBranchId) {
|
|
15390
|
-
const q = (0,
|
|
15391
|
-
(0,
|
|
15392
|
-
(0,
|
|
15393
|
-
(0,
|
|
15538
|
+
const q = (0, import_firestore47.query)(
|
|
15539
|
+
(0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION),
|
|
15540
|
+
(0, import_firestore47.where)("clinicBranchId", "==", clinicBranchId),
|
|
15541
|
+
(0, import_firestore47.where)("isActive", "==", true)
|
|
15394
15542
|
);
|
|
15395
|
-
const snapshot = await (0,
|
|
15543
|
+
const snapshot = await (0, import_firestore47.getDocs)(q);
|
|
15396
15544
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
15397
15545
|
}
|
|
15398
15546
|
/**
|
|
@@ -15401,12 +15549,12 @@ var ProcedureService = class extends BaseService {
|
|
|
15401
15549
|
* @returns List of procedures
|
|
15402
15550
|
*/
|
|
15403
15551
|
async getProceduresByPractitioner(practitionerId) {
|
|
15404
|
-
const q = (0,
|
|
15405
|
-
(0,
|
|
15406
|
-
(0,
|
|
15407
|
-
(0,
|
|
15552
|
+
const q = (0, import_firestore47.query)(
|
|
15553
|
+
(0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION),
|
|
15554
|
+
(0, import_firestore47.where)("practitionerId", "==", practitionerId),
|
|
15555
|
+
(0, import_firestore47.where)("isActive", "==", true)
|
|
15408
15556
|
);
|
|
15409
|
-
const snapshot = await (0,
|
|
15557
|
+
const snapshot = await (0, import_firestore47.getDocs)(q);
|
|
15410
15558
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
15411
15559
|
}
|
|
15412
15560
|
/**
|
|
@@ -15415,12 +15563,12 @@ var ProcedureService = class extends BaseService {
|
|
|
15415
15563
|
* @returns List of inactive procedures
|
|
15416
15564
|
*/
|
|
15417
15565
|
async getInactiveProceduresByPractitioner(practitionerId) {
|
|
15418
|
-
const q = (0,
|
|
15419
|
-
(0,
|
|
15420
|
-
(0,
|
|
15421
|
-
(0,
|
|
15566
|
+
const q = (0, import_firestore47.query)(
|
|
15567
|
+
(0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION),
|
|
15568
|
+
(0, import_firestore47.where)("practitionerId", "==", practitionerId),
|
|
15569
|
+
(0, import_firestore47.where)("isActive", "==", false)
|
|
15422
15570
|
);
|
|
15423
|
-
const snapshot = await (0,
|
|
15571
|
+
const snapshot = await (0, import_firestore47.getDocs)(q);
|
|
15424
15572
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
15425
15573
|
}
|
|
15426
15574
|
/**
|
|
@@ -15432,8 +15580,8 @@ var ProcedureService = class extends BaseService {
|
|
|
15432
15580
|
async updateProcedure(id, data) {
|
|
15433
15581
|
var _a, _b, _c, _d;
|
|
15434
15582
|
const validatedData = updateProcedureSchema.parse(data);
|
|
15435
|
-
const procedureRef = (0,
|
|
15436
|
-
const procedureSnapshot = await (0,
|
|
15583
|
+
const procedureRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, id);
|
|
15584
|
+
const procedureSnapshot = await (0, import_firestore47.getDoc)(procedureRef);
|
|
15437
15585
|
if (!procedureSnapshot.exists()) {
|
|
15438
15586
|
throw new Error(`Procedure with ID ${id} not found`);
|
|
15439
15587
|
}
|
|
@@ -15476,12 +15624,12 @@ var ProcedureService = class extends BaseService {
|
|
|
15476
15624
|
}
|
|
15477
15625
|
if (validatedData.practitionerId && validatedData.practitionerId !== oldPractitionerId) {
|
|
15478
15626
|
practitionerChanged = true;
|
|
15479
|
-
const newPractitionerRef = (0,
|
|
15627
|
+
const newPractitionerRef = (0, import_firestore47.doc)(
|
|
15480
15628
|
this.db,
|
|
15481
15629
|
PRACTITIONERS_COLLECTION,
|
|
15482
15630
|
validatedData.practitionerId
|
|
15483
15631
|
);
|
|
15484
|
-
const newPractitionerSnap = await (0,
|
|
15632
|
+
const newPractitionerSnap = await (0, import_firestore47.getDoc)(newPractitionerRef);
|
|
15485
15633
|
if (!newPractitionerSnap.exists())
|
|
15486
15634
|
throw new Error(`New Practitioner ${validatedData.practitionerId} not found`);
|
|
15487
15635
|
newPractitioner = newPractitionerSnap.data();
|
|
@@ -15497,8 +15645,8 @@ var ProcedureService = class extends BaseService {
|
|
|
15497
15645
|
}
|
|
15498
15646
|
if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
|
|
15499
15647
|
clinicChanged = true;
|
|
15500
|
-
const newClinicRef = (0,
|
|
15501
|
-
const newClinicSnap = await (0,
|
|
15648
|
+
const newClinicRef = (0, import_firestore47.doc)(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
|
|
15649
|
+
const newClinicSnap = await (0, import_firestore47.getDoc)(newClinicRef);
|
|
15502
15650
|
if (!newClinicSnap.exists())
|
|
15503
15651
|
throw new Error(`New Clinic ${validatedData.clinicBranchId} not found`);
|
|
15504
15652
|
newClinic = newClinicSnap.data();
|
|
@@ -15560,11 +15708,11 @@ var ProcedureService = class extends BaseService {
|
|
|
15560
15708
|
} else if (validatedData.productId) {
|
|
15561
15709
|
console.warn("Attempted to update product without a valid technologyId");
|
|
15562
15710
|
}
|
|
15563
|
-
await (0,
|
|
15711
|
+
await (0, import_firestore47.updateDoc)(procedureRef, {
|
|
15564
15712
|
...updatedProcedureData,
|
|
15565
|
-
updatedAt: (0,
|
|
15713
|
+
updatedAt: (0, import_firestore47.serverTimestamp)()
|
|
15566
15714
|
});
|
|
15567
|
-
const updatedSnapshot = await (0,
|
|
15715
|
+
const updatedSnapshot = await (0, import_firestore47.getDoc)(procedureRef);
|
|
15568
15716
|
return updatedSnapshot.data();
|
|
15569
15717
|
}
|
|
15570
15718
|
/**
|
|
@@ -15572,15 +15720,15 @@ var ProcedureService = class extends BaseService {
|
|
|
15572
15720
|
* @param id - The ID of the procedure to deactivate
|
|
15573
15721
|
*/
|
|
15574
15722
|
async deactivateProcedure(id) {
|
|
15575
|
-
const procedureRef = (0,
|
|
15576
|
-
const procedureSnap = await (0,
|
|
15723
|
+
const procedureRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, id);
|
|
15724
|
+
const procedureSnap = await (0, import_firestore47.getDoc)(procedureRef);
|
|
15577
15725
|
if (!procedureSnap.exists()) {
|
|
15578
15726
|
console.warn(`Procedure ${id} not found for deactivation.`);
|
|
15579
15727
|
return;
|
|
15580
15728
|
}
|
|
15581
|
-
await (0,
|
|
15729
|
+
await (0, import_firestore47.updateDoc)(procedureRef, {
|
|
15582
15730
|
isActive: false,
|
|
15583
|
-
updatedAt: (0,
|
|
15731
|
+
updatedAt: (0, import_firestore47.serverTimestamp)()
|
|
15584
15732
|
});
|
|
15585
15733
|
}
|
|
15586
15734
|
/**
|
|
@@ -15589,12 +15737,12 @@ var ProcedureService = class extends BaseService {
|
|
|
15589
15737
|
* @returns A boolean indicating if the deletion was successful
|
|
15590
15738
|
*/
|
|
15591
15739
|
async deleteProcedure(id) {
|
|
15592
|
-
const procedureRef = (0,
|
|
15593
|
-
const procedureSnapshot = await (0,
|
|
15740
|
+
const procedureRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, id);
|
|
15741
|
+
const procedureSnapshot = await (0, import_firestore47.getDoc)(procedureRef);
|
|
15594
15742
|
if (!procedureSnapshot.exists()) {
|
|
15595
15743
|
return false;
|
|
15596
15744
|
}
|
|
15597
|
-
await (0,
|
|
15745
|
+
await (0, import_firestore47.deleteDoc)(procedureRef);
|
|
15598
15746
|
return true;
|
|
15599
15747
|
}
|
|
15600
15748
|
/**
|
|
@@ -15620,25 +15768,25 @@ var ProcedureService = class extends BaseService {
|
|
|
15620
15768
|
*/
|
|
15621
15769
|
async getAllProcedures(pagination, lastDoc) {
|
|
15622
15770
|
try {
|
|
15623
|
-
const proceduresCollection = (0,
|
|
15624
|
-
let proceduresQuery = (0,
|
|
15771
|
+
const proceduresCollection = (0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION);
|
|
15772
|
+
let proceduresQuery = (0, import_firestore47.query)(proceduresCollection);
|
|
15625
15773
|
if (pagination && pagination > 0) {
|
|
15626
|
-
const { limit:
|
|
15774
|
+
const { limit: limit22, startAfter: startAfter20 } = await import("firebase/firestore");
|
|
15627
15775
|
if (lastDoc) {
|
|
15628
|
-
proceduresQuery = (0,
|
|
15776
|
+
proceduresQuery = (0, import_firestore47.query)(
|
|
15629
15777
|
proceduresCollection,
|
|
15630
|
-
(0,
|
|
15778
|
+
(0, import_firestore47.orderBy)("name"),
|
|
15631
15779
|
// Use imported orderBy
|
|
15632
|
-
|
|
15633
|
-
|
|
15780
|
+
startAfter20(lastDoc),
|
|
15781
|
+
limit22(pagination)
|
|
15634
15782
|
);
|
|
15635
15783
|
} else {
|
|
15636
|
-
proceduresQuery = (0,
|
|
15784
|
+
proceduresQuery = (0, import_firestore47.query)(proceduresCollection, (0, import_firestore47.orderBy)("name"), limit22(pagination));
|
|
15637
15785
|
}
|
|
15638
15786
|
} else {
|
|
15639
|
-
proceduresQuery = (0,
|
|
15787
|
+
proceduresQuery = (0, import_firestore47.query)(proceduresCollection, (0, import_firestore47.orderBy)("name"));
|
|
15640
15788
|
}
|
|
15641
|
-
const proceduresSnapshot = await (0,
|
|
15789
|
+
const proceduresSnapshot = await (0, import_firestore47.getDocs)(proceduresQuery);
|
|
15642
15790
|
const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
|
|
15643
15791
|
const procedures = proceduresSnapshot.docs.map((doc38) => {
|
|
15644
15792
|
const data = doc38.data();
|
|
@@ -15702,37 +15850,37 @@ var ProcedureService = class extends BaseService {
|
|
|
15702
15850
|
const getBaseConstraints = () => {
|
|
15703
15851
|
const constraints = [];
|
|
15704
15852
|
if (filters.isActive !== void 0) {
|
|
15705
|
-
constraints.push((0,
|
|
15853
|
+
constraints.push((0, import_firestore47.where)("isActive", "==", filters.isActive));
|
|
15706
15854
|
} else {
|
|
15707
|
-
constraints.push((0,
|
|
15855
|
+
constraints.push((0, import_firestore47.where)("isActive", "==", true));
|
|
15708
15856
|
}
|
|
15709
15857
|
if (filters.procedureFamily) {
|
|
15710
|
-
constraints.push((0,
|
|
15858
|
+
constraints.push((0, import_firestore47.where)("family", "==", filters.procedureFamily));
|
|
15711
15859
|
}
|
|
15712
15860
|
if (filters.procedureCategory) {
|
|
15713
|
-
constraints.push((0,
|
|
15861
|
+
constraints.push((0, import_firestore47.where)("category.id", "==", filters.procedureCategory));
|
|
15714
15862
|
}
|
|
15715
15863
|
if (filters.procedureSubcategory) {
|
|
15716
|
-
constraints.push((0,
|
|
15864
|
+
constraints.push((0, import_firestore47.where)("subcategory.id", "==", filters.procedureSubcategory));
|
|
15717
15865
|
}
|
|
15718
15866
|
if (filters.procedureTechnology) {
|
|
15719
|
-
constraints.push((0,
|
|
15867
|
+
constraints.push((0, import_firestore47.where)("technology.id", "==", filters.procedureTechnology));
|
|
15720
15868
|
}
|
|
15721
15869
|
if (filters.minPrice !== void 0) {
|
|
15722
|
-
constraints.push((0,
|
|
15870
|
+
constraints.push((0, import_firestore47.where)("price", ">=", filters.minPrice));
|
|
15723
15871
|
}
|
|
15724
15872
|
if (filters.maxPrice !== void 0) {
|
|
15725
|
-
constraints.push((0,
|
|
15873
|
+
constraints.push((0, import_firestore47.where)("price", "<=", filters.maxPrice));
|
|
15726
15874
|
}
|
|
15727
15875
|
if (filters.minRating !== void 0) {
|
|
15728
|
-
constraints.push((0,
|
|
15876
|
+
constraints.push((0, import_firestore47.where)("reviewInfo.averageRating", ">=", filters.minRating));
|
|
15729
15877
|
}
|
|
15730
15878
|
if (filters.maxRating !== void 0) {
|
|
15731
|
-
constraints.push((0,
|
|
15879
|
+
constraints.push((0, import_firestore47.where)("reviewInfo.averageRating", "<=", filters.maxRating));
|
|
15732
15880
|
}
|
|
15733
15881
|
if (filters.treatmentBenefits && filters.treatmentBenefits.length > 0) {
|
|
15734
15882
|
const benefitIdsToMatch = filters.treatmentBenefits;
|
|
15735
|
-
constraints.push((0,
|
|
15883
|
+
constraints.push((0, import_firestore47.where)("treatmentBenefitIds", "array-contains-any", benefitIdsToMatch));
|
|
15736
15884
|
}
|
|
15737
15885
|
return constraints;
|
|
15738
15886
|
};
|
|
@@ -15741,21 +15889,21 @@ var ProcedureService = class extends BaseService {
|
|
|
15741
15889
|
console.log("[PROCEDURE_SERVICE] Strategy 1: Trying nameLower search");
|
|
15742
15890
|
const searchTerm = filters.nameSearch.trim().toLowerCase();
|
|
15743
15891
|
const constraints = getBaseConstraints();
|
|
15744
|
-
constraints.push((0,
|
|
15745
|
-
constraints.push((0,
|
|
15746
|
-
constraints.push((0,
|
|
15892
|
+
constraints.push((0, import_firestore47.where)("nameLower", ">=", searchTerm));
|
|
15893
|
+
constraints.push((0, import_firestore47.where)("nameLower", "<=", searchTerm + "\uF8FF"));
|
|
15894
|
+
constraints.push((0, import_firestore47.orderBy)("nameLower"));
|
|
15747
15895
|
if (filters.lastDoc) {
|
|
15748
15896
|
if (typeof filters.lastDoc.data === "function") {
|
|
15749
|
-
constraints.push((0,
|
|
15897
|
+
constraints.push((0, import_firestore47.startAfter)(filters.lastDoc));
|
|
15750
15898
|
} else if (Array.isArray(filters.lastDoc)) {
|
|
15751
|
-
constraints.push((0,
|
|
15899
|
+
constraints.push((0, import_firestore47.startAfter)(...filters.lastDoc));
|
|
15752
15900
|
} else {
|
|
15753
|
-
constraints.push((0,
|
|
15901
|
+
constraints.push((0, import_firestore47.startAfter)(filters.lastDoc));
|
|
15754
15902
|
}
|
|
15755
15903
|
}
|
|
15756
|
-
constraints.push((0,
|
|
15757
|
-
const q = (0,
|
|
15758
|
-
const querySnapshot = await (0,
|
|
15904
|
+
constraints.push((0, import_firestore47.limit)(filters.pagination || 10));
|
|
15905
|
+
const q = (0, import_firestore47.query)((0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
15906
|
+
const querySnapshot = await (0, import_firestore47.getDocs)(q);
|
|
15759
15907
|
const procedures = querySnapshot.docs.map(
|
|
15760
15908
|
(doc38) => ({ ...doc38.data(), id: doc38.id })
|
|
15761
15909
|
);
|
|
@@ -15774,21 +15922,21 @@ var ProcedureService = class extends BaseService {
|
|
|
15774
15922
|
console.log("[PROCEDURE_SERVICE] Strategy 2: Trying name field search");
|
|
15775
15923
|
const searchTerm = filters.nameSearch.trim().toLowerCase();
|
|
15776
15924
|
const constraints = getBaseConstraints();
|
|
15777
|
-
constraints.push((0,
|
|
15778
|
-
constraints.push((0,
|
|
15779
|
-
constraints.push((0,
|
|
15925
|
+
constraints.push((0, import_firestore47.where)("name", ">=", searchTerm));
|
|
15926
|
+
constraints.push((0, import_firestore47.where)("name", "<=", searchTerm + "\uF8FF"));
|
|
15927
|
+
constraints.push((0, import_firestore47.orderBy)("name"));
|
|
15780
15928
|
if (filters.lastDoc) {
|
|
15781
15929
|
if (typeof filters.lastDoc.data === "function") {
|
|
15782
|
-
constraints.push((0,
|
|
15930
|
+
constraints.push((0, import_firestore47.startAfter)(filters.lastDoc));
|
|
15783
15931
|
} else if (Array.isArray(filters.lastDoc)) {
|
|
15784
|
-
constraints.push((0,
|
|
15932
|
+
constraints.push((0, import_firestore47.startAfter)(...filters.lastDoc));
|
|
15785
15933
|
} else {
|
|
15786
|
-
constraints.push((0,
|
|
15934
|
+
constraints.push((0, import_firestore47.startAfter)(filters.lastDoc));
|
|
15787
15935
|
}
|
|
15788
15936
|
}
|
|
15789
|
-
constraints.push((0,
|
|
15790
|
-
const q = (0,
|
|
15791
|
-
const querySnapshot = await (0,
|
|
15937
|
+
constraints.push((0, import_firestore47.limit)(filters.pagination || 10));
|
|
15938
|
+
const q = (0, import_firestore47.query)((0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
15939
|
+
const querySnapshot = await (0, import_firestore47.getDocs)(q);
|
|
15792
15940
|
const procedures = querySnapshot.docs.map(
|
|
15793
15941
|
(doc38) => ({ ...doc38.data(), id: doc38.id })
|
|
15794
15942
|
);
|
|
@@ -15807,19 +15955,19 @@ var ProcedureService = class extends BaseService {
|
|
|
15807
15955
|
"[PROCEDURE_SERVICE] Strategy 3: Using createdAt orderBy with client-side filtering"
|
|
15808
15956
|
);
|
|
15809
15957
|
const constraints = getBaseConstraints();
|
|
15810
|
-
constraints.push((0,
|
|
15958
|
+
constraints.push((0, import_firestore47.orderBy)("createdAt", "desc"));
|
|
15811
15959
|
if (filters.lastDoc) {
|
|
15812
15960
|
if (typeof filters.lastDoc.data === "function") {
|
|
15813
|
-
constraints.push((0,
|
|
15961
|
+
constraints.push((0, import_firestore47.startAfter)(filters.lastDoc));
|
|
15814
15962
|
} else if (Array.isArray(filters.lastDoc)) {
|
|
15815
|
-
constraints.push((0,
|
|
15963
|
+
constraints.push((0, import_firestore47.startAfter)(...filters.lastDoc));
|
|
15816
15964
|
} else {
|
|
15817
|
-
constraints.push((0,
|
|
15965
|
+
constraints.push((0, import_firestore47.startAfter)(filters.lastDoc));
|
|
15818
15966
|
}
|
|
15819
15967
|
}
|
|
15820
|
-
constraints.push((0,
|
|
15821
|
-
const q = (0,
|
|
15822
|
-
const querySnapshot = await (0,
|
|
15968
|
+
constraints.push((0, import_firestore47.limit)(filters.pagination || 10));
|
|
15969
|
+
const q = (0, import_firestore47.query)((0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
15970
|
+
const querySnapshot = await (0, import_firestore47.getDocs)(q);
|
|
15823
15971
|
let procedures = querySnapshot.docs.map(
|
|
15824
15972
|
(doc38) => ({ ...doc38.data(), id: doc38.id })
|
|
15825
15973
|
);
|
|
@@ -15836,12 +15984,12 @@ var ProcedureService = class extends BaseService {
|
|
|
15836
15984
|
try {
|
|
15837
15985
|
console.log("[PROCEDURE_SERVICE] Strategy 4: Minimal query fallback");
|
|
15838
15986
|
const constraints = [
|
|
15839
|
-
(0,
|
|
15840
|
-
(0,
|
|
15841
|
-
(0,
|
|
15987
|
+
(0, import_firestore47.where)("isActive", "==", true),
|
|
15988
|
+
(0, import_firestore47.orderBy)("createdAt", "desc"),
|
|
15989
|
+
(0, import_firestore47.limit)(filters.pagination || 10)
|
|
15842
15990
|
];
|
|
15843
|
-
const q = (0,
|
|
15844
|
-
const querySnapshot = await (0,
|
|
15991
|
+
const q = (0, import_firestore47.query)((0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
15992
|
+
const querySnapshot = await (0, import_firestore47.getDocs)(q);
|
|
15845
15993
|
let procedures = querySnapshot.docs.map(
|
|
15846
15994
|
(doc38) => ({ ...doc38.data(), id: doc38.id })
|
|
15847
15995
|
);
|
|
@@ -15985,11 +16133,11 @@ var ProcedureService = class extends BaseService {
|
|
|
15985
16133
|
const bounds = (0, import_geofire_common8.geohashQueryBounds)([location.latitude, location.longitude], radiusInKm * 1e3);
|
|
15986
16134
|
const fetches = bounds.map((b) => {
|
|
15987
16135
|
const constraints = [
|
|
15988
|
-
(0,
|
|
15989
|
-
(0,
|
|
15990
|
-
(0,
|
|
16136
|
+
(0, import_firestore47.where)("clinicInfo.location.geohash", ">=", b[0]),
|
|
16137
|
+
(0, import_firestore47.where)("clinicInfo.location.geohash", "<=", b[1]),
|
|
16138
|
+
(0, import_firestore47.where)("isActive", "==", filters.isActive !== void 0 ? filters.isActive : true)
|
|
15991
16139
|
];
|
|
15992
|
-
return (0,
|
|
16140
|
+
return (0, import_firestore47.getDocs)((0, import_firestore47.query)((0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION), ...constraints));
|
|
15993
16141
|
});
|
|
15994
16142
|
return Promise.all(fetches).then((snaps) => {
|
|
15995
16143
|
const collected = [];
|
|
@@ -16040,14 +16188,14 @@ var ProcedureService = class extends BaseService {
|
|
|
16040
16188
|
if (!category || !subcategory || !technology) {
|
|
16041
16189
|
throw new Error("One or more required base entities not found");
|
|
16042
16190
|
}
|
|
16043
|
-
const clinicRef = (0,
|
|
16044
|
-
const clinicSnapshot = await (0,
|
|
16191
|
+
const clinicRef = (0, import_firestore47.doc)(this.db, CLINICS_COLLECTION, data.clinicBranchId);
|
|
16192
|
+
const clinicSnapshot = await (0, import_firestore47.getDoc)(clinicRef);
|
|
16045
16193
|
if (!clinicSnapshot.exists()) {
|
|
16046
16194
|
throw new Error(`Clinic with ID ${data.clinicBranchId} not found`);
|
|
16047
16195
|
}
|
|
16048
16196
|
const clinic = clinicSnapshot.data();
|
|
16049
|
-
const practitionerRef = (0,
|
|
16050
|
-
const practitionerSnapshot = await (0,
|
|
16197
|
+
const practitionerRef = (0, import_firestore47.doc)(this.db, PRACTITIONERS_COLLECTION, data.practitionerId);
|
|
16198
|
+
const practitionerSnapshot = await (0, import_firestore47.getDoc)(practitionerRef);
|
|
16051
16199
|
if (!practitionerSnapshot.exists()) {
|
|
16052
16200
|
throw new Error(`Practitioner with ID ${data.practitionerId} not found`);
|
|
16053
16201
|
}
|
|
@@ -16126,13 +16274,13 @@ var ProcedureService = class extends BaseService {
|
|
|
16126
16274
|
},
|
|
16127
16275
|
isActive: true
|
|
16128
16276
|
};
|
|
16129
|
-
const procedureRef = (0,
|
|
16130
|
-
await (0,
|
|
16277
|
+
const procedureRef = (0, import_firestore47.doc)(this.db, PROCEDURES_COLLECTION, procedureId);
|
|
16278
|
+
await (0, import_firestore47.setDoc)(procedureRef, {
|
|
16131
16279
|
...newProcedure,
|
|
16132
|
-
createdAt: (0,
|
|
16133
|
-
updatedAt: (0,
|
|
16280
|
+
createdAt: (0, import_firestore47.serverTimestamp)(),
|
|
16281
|
+
updatedAt: (0, import_firestore47.serverTimestamp)()
|
|
16134
16282
|
});
|
|
16135
|
-
const savedDoc = await (0,
|
|
16283
|
+
const savedDoc = await (0, import_firestore47.getDoc)(procedureRef);
|
|
16136
16284
|
return savedDoc.data();
|
|
16137
16285
|
}
|
|
16138
16286
|
/**
|
|
@@ -16141,8 +16289,8 @@ var ProcedureService = class extends BaseService {
|
|
|
16141
16289
|
* @returns Array of minimal procedure info for map
|
|
16142
16290
|
*/
|
|
16143
16291
|
async getProceduresForMap() {
|
|
16144
|
-
const proceduresRef = (0,
|
|
16145
|
-
const snapshot = await (0,
|
|
16292
|
+
const proceduresRef = (0, import_firestore47.collection)(this.db, PROCEDURES_COLLECTION);
|
|
16293
|
+
const snapshot = await (0, import_firestore47.getDocs)(proceduresRef);
|
|
16146
16294
|
const proceduresForMap = snapshot.docs.map((doc38) => {
|
|
16147
16295
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16148
16296
|
const data = doc38.data();
|
|
@@ -16161,7 +16309,7 @@ var ProcedureService = class extends BaseService {
|
|
|
16161
16309
|
};
|
|
16162
16310
|
|
|
16163
16311
|
// src/services/reviews/reviews.service.ts
|
|
16164
|
-
var
|
|
16312
|
+
var import_firestore48 = require("firebase/firestore");
|
|
16165
16313
|
var import_zod26 = require("zod");
|
|
16166
16314
|
var ReviewService = class extends BaseService {
|
|
16167
16315
|
constructor(db, auth, app) {
|
|
@@ -16241,11 +16389,11 @@ var ReviewService = class extends BaseService {
|
|
|
16241
16389
|
updatedAt: now
|
|
16242
16390
|
};
|
|
16243
16391
|
reviewSchema.parse(review);
|
|
16244
|
-
const docRef = (0,
|
|
16245
|
-
await (0,
|
|
16392
|
+
const docRef = (0, import_firestore48.doc)(this.db, REVIEWS_COLLECTION, reviewId);
|
|
16393
|
+
await (0, import_firestore48.setDoc)(docRef, {
|
|
16246
16394
|
...review,
|
|
16247
|
-
createdAt: (0,
|
|
16248
|
-
updatedAt: (0,
|
|
16395
|
+
createdAt: (0, import_firestore48.serverTimestamp)(),
|
|
16396
|
+
updatedAt: (0, import_firestore48.serverTimestamp)()
|
|
16249
16397
|
});
|
|
16250
16398
|
return review;
|
|
16251
16399
|
} catch (error) {
|
|
@@ -16261,8 +16409,8 @@ var ReviewService = class extends BaseService {
|
|
|
16261
16409
|
* @returns The review if found, null otherwise
|
|
16262
16410
|
*/
|
|
16263
16411
|
async getReview(reviewId) {
|
|
16264
|
-
const docRef = (0,
|
|
16265
|
-
const docSnap = await (0,
|
|
16412
|
+
const docRef = (0, import_firestore48.doc)(this.db, REVIEWS_COLLECTION, reviewId);
|
|
16413
|
+
const docSnap = await (0, import_firestore48.getDoc)(docRef);
|
|
16266
16414
|
if (!docSnap.exists()) {
|
|
16267
16415
|
return null;
|
|
16268
16416
|
}
|
|
@@ -16274,11 +16422,11 @@ var ReviewService = class extends BaseService {
|
|
|
16274
16422
|
* @returns Array of reviews for the patient
|
|
16275
16423
|
*/
|
|
16276
16424
|
async getReviewsByPatient(patientId) {
|
|
16277
|
-
const q = (0,
|
|
16278
|
-
(0,
|
|
16279
|
-
(0,
|
|
16425
|
+
const q = (0, import_firestore48.query)(
|
|
16426
|
+
(0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
|
|
16427
|
+
(0, import_firestore48.where)("patientId", "==", patientId)
|
|
16280
16428
|
);
|
|
16281
|
-
const snapshot = await (0,
|
|
16429
|
+
const snapshot = await (0, import_firestore48.getDocs)(q);
|
|
16282
16430
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
16283
16431
|
}
|
|
16284
16432
|
/**
|
|
@@ -16287,11 +16435,11 @@ var ReviewService = class extends BaseService {
|
|
|
16287
16435
|
* @returns Array of reviews containing clinic reviews
|
|
16288
16436
|
*/
|
|
16289
16437
|
async getReviewsByClinic(clinicId) {
|
|
16290
|
-
const q = (0,
|
|
16291
|
-
(0,
|
|
16292
|
-
(0,
|
|
16438
|
+
const q = (0, import_firestore48.query)(
|
|
16439
|
+
(0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
|
|
16440
|
+
(0, import_firestore48.where)("clinicReview.clinicId", "==", clinicId)
|
|
16293
16441
|
);
|
|
16294
|
-
const snapshot = await (0,
|
|
16442
|
+
const snapshot = await (0, import_firestore48.getDocs)(q);
|
|
16295
16443
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
16296
16444
|
}
|
|
16297
16445
|
/**
|
|
@@ -16300,11 +16448,11 @@ var ReviewService = class extends BaseService {
|
|
|
16300
16448
|
* @returns Array of reviews containing practitioner reviews
|
|
16301
16449
|
*/
|
|
16302
16450
|
async getReviewsByPractitioner(practitionerId) {
|
|
16303
|
-
const q = (0,
|
|
16304
|
-
(0,
|
|
16305
|
-
(0,
|
|
16451
|
+
const q = (0, import_firestore48.query)(
|
|
16452
|
+
(0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
|
|
16453
|
+
(0, import_firestore48.where)("practitionerReview.practitionerId", "==", practitionerId)
|
|
16306
16454
|
);
|
|
16307
|
-
const snapshot = await (0,
|
|
16455
|
+
const snapshot = await (0, import_firestore48.getDocs)(q);
|
|
16308
16456
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
16309
16457
|
}
|
|
16310
16458
|
/**
|
|
@@ -16313,11 +16461,11 @@ var ReviewService = class extends BaseService {
|
|
|
16313
16461
|
* @returns Array of reviews containing procedure reviews
|
|
16314
16462
|
*/
|
|
16315
16463
|
async getReviewsByProcedure(procedureId) {
|
|
16316
|
-
const q = (0,
|
|
16317
|
-
(0,
|
|
16318
|
-
(0,
|
|
16464
|
+
const q = (0, import_firestore48.query)(
|
|
16465
|
+
(0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
|
|
16466
|
+
(0, import_firestore48.where)("procedureReview.procedureId", "==", procedureId)
|
|
16319
16467
|
);
|
|
16320
|
-
const snapshot = await (0,
|
|
16468
|
+
const snapshot = await (0, import_firestore48.getDocs)(q);
|
|
16321
16469
|
return snapshot.docs.map((doc38) => doc38.data());
|
|
16322
16470
|
}
|
|
16323
16471
|
/**
|
|
@@ -16326,11 +16474,11 @@ var ReviewService = class extends BaseService {
|
|
|
16326
16474
|
* @returns The review for the appointment if found, null otherwise
|
|
16327
16475
|
*/
|
|
16328
16476
|
async getReviewByAppointment(appointmentId) {
|
|
16329
|
-
const q = (0,
|
|
16330
|
-
(0,
|
|
16331
|
-
(0,
|
|
16477
|
+
const q = (0, import_firestore48.query)(
|
|
16478
|
+
(0, import_firestore48.collection)(this.db, REVIEWS_COLLECTION),
|
|
16479
|
+
(0, import_firestore48.where)("appointmentId", "==", appointmentId)
|
|
16332
16480
|
);
|
|
16333
|
-
const snapshot = await (0,
|
|
16481
|
+
const snapshot = await (0, import_firestore48.getDocs)(q);
|
|
16334
16482
|
if (snapshot.empty) {
|
|
16335
16483
|
return null;
|
|
16336
16484
|
}
|
|
@@ -16345,7 +16493,7 @@ var ReviewService = class extends BaseService {
|
|
|
16345
16493
|
if (!review) {
|
|
16346
16494
|
throw new Error(`Review with ID ${reviewId} not found`);
|
|
16347
16495
|
}
|
|
16348
|
-
await (0,
|
|
16496
|
+
await (0, import_firestore48.deleteDoc)((0, import_firestore48.doc)(this.db, REVIEWS_COLLECTION, reviewId));
|
|
16349
16497
|
}
|
|
16350
16498
|
/**
|
|
16351
16499
|
* Calculates the average of an array of numbers
|
|
@@ -16364,7 +16512,7 @@ var ReviewService = class extends BaseService {
|
|
|
16364
16512
|
|
|
16365
16513
|
// src/config/firebase.ts
|
|
16366
16514
|
var import_app = require("firebase/app");
|
|
16367
|
-
var
|
|
16515
|
+
var import_firestore49 = require("firebase/firestore");
|
|
16368
16516
|
var import_auth9 = require("firebase/auth");
|
|
16369
16517
|
var import_analytics = require("firebase/analytics");
|
|
16370
16518
|
var import_react_native = require("react-native");
|
|
@@ -16374,7 +16522,7 @@ var firebaseInstance = null;
|
|
|
16374
16522
|
var initializeFirebase = (config) => {
|
|
16375
16523
|
if (!firebaseInstance) {
|
|
16376
16524
|
const app = (0, import_app.initializeApp)(config);
|
|
16377
|
-
const db = (0,
|
|
16525
|
+
const db = (0, import_firestore49.getFirestore)(app);
|
|
16378
16526
|
const auth = (0, import_auth9.getAuth)(app);
|
|
16379
16527
|
const storage = (0, import_storage4.getStorage)(app);
|
|
16380
16528
|
const functions = (0, import_functions3.getFunctions)(app);
|
|
@@ -16416,7 +16564,7 @@ var getFirebaseFunctions = async () => {
|
|
|
16416
16564
|
};
|
|
16417
16565
|
|
|
16418
16566
|
// src/backoffice/services/brand.service.ts
|
|
16419
|
-
var
|
|
16567
|
+
var import_firestore50 = require("firebase/firestore");
|
|
16420
16568
|
|
|
16421
16569
|
// src/backoffice/types/brand.types.ts
|
|
16422
16570
|
var BRANDS_COLLECTION = "brands";
|
|
@@ -16427,7 +16575,7 @@ var BrandService = class extends BaseService {
|
|
|
16427
16575
|
* Gets reference to brands collection
|
|
16428
16576
|
*/
|
|
16429
16577
|
getBrandsRef() {
|
|
16430
|
-
return (0,
|
|
16578
|
+
return (0, import_firestore50.collection)(this.db, BRANDS_COLLECTION);
|
|
16431
16579
|
}
|
|
16432
16580
|
/**
|
|
16433
16581
|
* Creates a new brand
|
|
@@ -16441,7 +16589,7 @@ var BrandService = class extends BaseService {
|
|
|
16441
16589
|
updatedAt: now,
|
|
16442
16590
|
isActive: true
|
|
16443
16591
|
};
|
|
16444
|
-
const docRef = await (0,
|
|
16592
|
+
const docRef = await (0, import_firestore50.addDoc)(this.getBrandsRef(), newBrand);
|
|
16445
16593
|
return { id: docRef.id, ...newBrand };
|
|
16446
16594
|
}
|
|
16447
16595
|
/**
|
|
@@ -16452,22 +16600,22 @@ var BrandService = class extends BaseService {
|
|
|
16452
16600
|
*/
|
|
16453
16601
|
async getAll(rowsPerPage, searchTerm, lastVisible) {
|
|
16454
16602
|
const constraints = [
|
|
16455
|
-
(0,
|
|
16456
|
-
(0,
|
|
16603
|
+
(0, import_firestore50.where)("isActive", "==", true),
|
|
16604
|
+
(0, import_firestore50.orderBy)("name_lowercase")
|
|
16457
16605
|
];
|
|
16458
16606
|
if (searchTerm) {
|
|
16459
16607
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
16460
|
-
constraints.push((0,
|
|
16608
|
+
constraints.push((0, import_firestore50.where)("name_lowercase", ">=", lowercasedSearchTerm));
|
|
16461
16609
|
constraints.push(
|
|
16462
|
-
(0,
|
|
16610
|
+
(0, import_firestore50.where)("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
|
|
16463
16611
|
);
|
|
16464
16612
|
}
|
|
16465
16613
|
if (lastVisible) {
|
|
16466
|
-
constraints.push((0,
|
|
16614
|
+
constraints.push((0, import_firestore50.startAfter)(lastVisible));
|
|
16467
16615
|
}
|
|
16468
|
-
constraints.push((0,
|
|
16469
|
-
const q = (0,
|
|
16470
|
-
const snapshot = await (0,
|
|
16616
|
+
constraints.push((0, import_firestore50.limit)(rowsPerPage));
|
|
16617
|
+
const q = (0, import_firestore50.query)(this.getBrandsRef(), ...constraints);
|
|
16618
|
+
const snapshot = await (0, import_firestore50.getDocs)(q);
|
|
16471
16619
|
const brands = snapshot.docs.map(
|
|
16472
16620
|
(doc38) => ({
|
|
16473
16621
|
id: doc38.id,
|
|
@@ -16482,28 +16630,28 @@ var BrandService = class extends BaseService {
|
|
|
16482
16630
|
* @param searchTerm - An optional string to filter brand names by (starts-with search).
|
|
16483
16631
|
*/
|
|
16484
16632
|
async getBrandsCount(searchTerm) {
|
|
16485
|
-
const constraints = [(0,
|
|
16633
|
+
const constraints = [(0, import_firestore50.where)("isActive", "==", true)];
|
|
16486
16634
|
if (searchTerm) {
|
|
16487
16635
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
16488
|
-
constraints.push((0,
|
|
16636
|
+
constraints.push((0, import_firestore50.where)("name_lowercase", ">=", lowercasedSearchTerm));
|
|
16489
16637
|
constraints.push(
|
|
16490
|
-
(0,
|
|
16638
|
+
(0, import_firestore50.where)("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
|
|
16491
16639
|
);
|
|
16492
16640
|
}
|
|
16493
|
-
const q = (0,
|
|
16494
|
-
const snapshot = await (0,
|
|
16641
|
+
const q = (0, import_firestore50.query)(this.getBrandsRef(), ...constraints);
|
|
16642
|
+
const snapshot = await (0, import_firestore50.getCountFromServer)(q);
|
|
16495
16643
|
return snapshot.data().count;
|
|
16496
16644
|
}
|
|
16497
16645
|
/**
|
|
16498
16646
|
* Gets all active brands for filter dropdowns (not paginated).
|
|
16499
16647
|
*/
|
|
16500
16648
|
async getAllForFilter() {
|
|
16501
|
-
const q = (0,
|
|
16649
|
+
const q = (0, import_firestore50.query)(
|
|
16502
16650
|
this.getBrandsRef(),
|
|
16503
|
-
(0,
|
|
16504
|
-
(0,
|
|
16651
|
+
(0, import_firestore50.where)("isActive", "==", true),
|
|
16652
|
+
(0, import_firestore50.orderBy)("name")
|
|
16505
16653
|
);
|
|
16506
|
-
const snapshot = await (0,
|
|
16654
|
+
const snapshot = await (0, import_firestore50.getDocs)(q);
|
|
16507
16655
|
return snapshot.docs.map(
|
|
16508
16656
|
(doc38) => ({
|
|
16509
16657
|
id: doc38.id,
|
|
@@ -16522,8 +16670,8 @@ var BrandService = class extends BaseService {
|
|
|
16522
16670
|
if (brand.name) {
|
|
16523
16671
|
updateData.name_lowercase = brand.name.toLowerCase();
|
|
16524
16672
|
}
|
|
16525
|
-
const docRef = (0,
|
|
16526
|
-
await (0,
|
|
16673
|
+
const docRef = (0, import_firestore50.doc)(this.getBrandsRef(), brandId);
|
|
16674
|
+
await (0, import_firestore50.updateDoc)(docRef, updateData);
|
|
16527
16675
|
return this.getById(brandId);
|
|
16528
16676
|
}
|
|
16529
16677
|
/**
|
|
@@ -16538,8 +16686,8 @@ var BrandService = class extends BaseService {
|
|
|
16538
16686
|
* Gets a brand by ID
|
|
16539
16687
|
*/
|
|
16540
16688
|
async getById(brandId) {
|
|
16541
|
-
const docRef = (0,
|
|
16542
|
-
const docSnap = await (0,
|
|
16689
|
+
const docRef = (0, import_firestore50.doc)(this.getBrandsRef(), brandId);
|
|
16690
|
+
const docSnap = await (0, import_firestore50.getDoc)(docRef);
|
|
16543
16691
|
if (!docSnap.exists()) return null;
|
|
16544
16692
|
return {
|
|
16545
16693
|
id: docSnap.id,
|
|
@@ -16549,7 +16697,7 @@ var BrandService = class extends BaseService {
|
|
|
16549
16697
|
};
|
|
16550
16698
|
|
|
16551
16699
|
// src/backoffice/services/category.service.ts
|
|
16552
|
-
var
|
|
16700
|
+
var import_firestore51 = require("firebase/firestore");
|
|
16553
16701
|
|
|
16554
16702
|
// src/backoffice/types/category.types.ts
|
|
16555
16703
|
var CATEGORIES_COLLECTION = "backoffice_categories";
|
|
@@ -16560,7 +16708,7 @@ var CategoryService = class extends BaseService {
|
|
|
16560
16708
|
* Referenca na Firestore kolekciju kategorija
|
|
16561
16709
|
*/
|
|
16562
16710
|
get categoriesRef() {
|
|
16563
|
-
return (0,
|
|
16711
|
+
return (0, import_firestore51.collection)(this.db, CATEGORIES_COLLECTION);
|
|
16564
16712
|
}
|
|
16565
16713
|
/**
|
|
16566
16714
|
* Kreira novu kategoriju u sistemu
|
|
@@ -16575,7 +16723,7 @@ var CategoryService = class extends BaseService {
|
|
|
16575
16723
|
updatedAt: now,
|
|
16576
16724
|
isActive: true
|
|
16577
16725
|
};
|
|
16578
|
-
const docRef = await (0,
|
|
16726
|
+
const docRef = await (0, import_firestore51.addDoc)(this.categoriesRef, newCategory);
|
|
16579
16727
|
return { id: docRef.id, ...newCategory };
|
|
16580
16728
|
}
|
|
16581
16729
|
/**
|
|
@@ -16587,12 +16735,12 @@ var CategoryService = class extends BaseService {
|
|
|
16587
16735
|
const counts = {};
|
|
16588
16736
|
const families = Object.values(ProcedureFamily);
|
|
16589
16737
|
for (const family of families) {
|
|
16590
|
-
const q = (0,
|
|
16738
|
+
const q = (0, import_firestore51.query)(
|
|
16591
16739
|
this.categoriesRef,
|
|
16592
|
-
(0,
|
|
16593
|
-
(0,
|
|
16740
|
+
(0, import_firestore51.where)("family", "==", family),
|
|
16741
|
+
(0, import_firestore51.where)("isActive", "==", active)
|
|
16594
16742
|
);
|
|
16595
|
-
const snapshot = await (0,
|
|
16743
|
+
const snapshot = await (0, import_firestore51.getCountFromServer)(q);
|
|
16596
16744
|
counts[family] = snapshot.data().count;
|
|
16597
16745
|
}
|
|
16598
16746
|
return counts;
|
|
@@ -16602,8 +16750,8 @@ var CategoryService = class extends BaseService {
|
|
|
16602
16750
|
* @returns Lista svih aktivnih kategorija
|
|
16603
16751
|
*/
|
|
16604
16752
|
async getAllForFilter() {
|
|
16605
|
-
const q = (0,
|
|
16606
|
-
const snapshot = await (0,
|
|
16753
|
+
const q = (0, import_firestore51.query)(this.categoriesRef, (0, import_firestore51.where)("isActive", "==", true));
|
|
16754
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
16607
16755
|
return snapshot.docs.map(
|
|
16608
16756
|
(doc38) => ({
|
|
16609
16757
|
id: doc38.id,
|
|
@@ -16617,13 +16765,13 @@ var CategoryService = class extends BaseService {
|
|
|
16617
16765
|
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
16618
16766
|
*/
|
|
16619
16767
|
async getAllForFilterByFamily(family) {
|
|
16620
|
-
const q = (0,
|
|
16768
|
+
const q = (0, import_firestore51.query)(
|
|
16621
16769
|
this.categoriesRef,
|
|
16622
|
-
(0,
|
|
16623
|
-
(0,
|
|
16624
|
-
(0,
|
|
16770
|
+
(0, import_firestore51.where)("family", "==", family),
|
|
16771
|
+
(0, import_firestore51.where)("isActive", "==", true),
|
|
16772
|
+
(0, import_firestore51.orderBy)("name")
|
|
16625
16773
|
);
|
|
16626
|
-
const snapshot = await (0,
|
|
16774
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
16627
16775
|
return snapshot.docs.map(
|
|
16628
16776
|
(doc38) => ({
|
|
16629
16777
|
id: doc38.id,
|
|
@@ -16639,13 +16787,13 @@ var CategoryService = class extends BaseService {
|
|
|
16639
16787
|
async getAll(options = {}) {
|
|
16640
16788
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
16641
16789
|
const constraints = [
|
|
16642
|
-
(0,
|
|
16643
|
-
(0,
|
|
16644
|
-
queryLimit ? (0,
|
|
16645
|
-
lastVisible ? (0,
|
|
16790
|
+
(0, import_firestore51.where)("isActive", "==", active),
|
|
16791
|
+
(0, import_firestore51.orderBy)("name"),
|
|
16792
|
+
queryLimit ? (0, import_firestore51.limit)(queryLimit) : void 0,
|
|
16793
|
+
lastVisible ? (0, import_firestore51.startAfter)(lastVisible) : void 0
|
|
16646
16794
|
].filter((c) => !!c);
|
|
16647
|
-
const q = (0,
|
|
16648
|
-
const snapshot = await (0,
|
|
16795
|
+
const q = (0, import_firestore51.query)(this.categoriesRef, ...constraints);
|
|
16796
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
16649
16797
|
const categories = snapshot.docs.map(
|
|
16650
16798
|
(doc38) => ({
|
|
16651
16799
|
id: doc38.id,
|
|
@@ -16664,14 +16812,14 @@ var CategoryService = class extends BaseService {
|
|
|
16664
16812
|
async getAllByFamily(family, options = {}) {
|
|
16665
16813
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
16666
16814
|
const constraints = [
|
|
16667
|
-
(0,
|
|
16668
|
-
(0,
|
|
16669
|
-
(0,
|
|
16670
|
-
queryLimit ? (0,
|
|
16671
|
-
lastVisible ? (0,
|
|
16815
|
+
(0, import_firestore51.where)("family", "==", family),
|
|
16816
|
+
(0, import_firestore51.where)("isActive", "==", active),
|
|
16817
|
+
(0, import_firestore51.orderBy)("name"),
|
|
16818
|
+
queryLimit ? (0, import_firestore51.limit)(queryLimit) : void 0,
|
|
16819
|
+
lastVisible ? (0, import_firestore51.startAfter)(lastVisible) : void 0
|
|
16672
16820
|
].filter((c) => !!c);
|
|
16673
|
-
const q = (0,
|
|
16674
|
-
const snapshot = await (0,
|
|
16821
|
+
const q = (0, import_firestore51.query)(this.categoriesRef, ...constraints);
|
|
16822
|
+
const snapshot = await (0, import_firestore51.getDocs)(q);
|
|
16675
16823
|
const categories = snapshot.docs.map(
|
|
16676
16824
|
(doc38) => ({
|
|
16677
16825
|
id: doc38.id,
|
|
@@ -16692,8 +16840,8 @@ var CategoryService = class extends BaseService {
|
|
|
16692
16840
|
...category,
|
|
16693
16841
|
updatedAt: /* @__PURE__ */ new Date()
|
|
16694
16842
|
};
|
|
16695
|
-
const docRef = (0,
|
|
16696
|
-
await (0,
|
|
16843
|
+
const docRef = (0, import_firestore51.doc)(this.categoriesRef, id);
|
|
16844
|
+
await (0, import_firestore51.updateDoc)(docRef, updateData);
|
|
16697
16845
|
return this.getById(id);
|
|
16698
16846
|
}
|
|
16699
16847
|
/**
|
|
@@ -16716,8 +16864,8 @@ var CategoryService = class extends BaseService {
|
|
|
16716
16864
|
* @returns Kategorija ili null ako ne postoji
|
|
16717
16865
|
*/
|
|
16718
16866
|
async getById(id) {
|
|
16719
|
-
const docRef = (0,
|
|
16720
|
-
const docSnap = await (0,
|
|
16867
|
+
const docRef = (0, import_firestore51.doc)(this.categoriesRef, id);
|
|
16868
|
+
const docSnap = await (0, import_firestore51.getDoc)(docRef);
|
|
16721
16869
|
if (!docSnap.exists()) return null;
|
|
16722
16870
|
return {
|
|
16723
16871
|
id: docSnap.id,
|
|
@@ -16727,7 +16875,7 @@ var CategoryService = class extends BaseService {
|
|
|
16727
16875
|
};
|
|
16728
16876
|
|
|
16729
16877
|
// src/backoffice/services/subcategory.service.ts
|
|
16730
|
-
var
|
|
16878
|
+
var import_firestore52 = require("firebase/firestore");
|
|
16731
16879
|
|
|
16732
16880
|
// src/backoffice/types/subcategory.types.ts
|
|
16733
16881
|
var SUBCATEGORIES_COLLECTION = "subcategories";
|
|
@@ -16739,7 +16887,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
16739
16887
|
* @param categoryId - ID roditeljske kategorije
|
|
16740
16888
|
*/
|
|
16741
16889
|
getSubcategoriesRef(categoryId) {
|
|
16742
|
-
return (0,
|
|
16890
|
+
return (0, import_firestore52.collection)(
|
|
16743
16891
|
this.db,
|
|
16744
16892
|
CATEGORIES_COLLECTION,
|
|
16745
16893
|
categoryId,
|
|
@@ -16761,7 +16909,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
16761
16909
|
updatedAt: now,
|
|
16762
16910
|
isActive: true
|
|
16763
16911
|
};
|
|
16764
|
-
const docRef = await (0,
|
|
16912
|
+
const docRef = await (0, import_firestore52.addDoc)(
|
|
16765
16913
|
this.getSubcategoriesRef(categoryId),
|
|
16766
16914
|
newSubcategory
|
|
16767
16915
|
);
|
|
@@ -16773,14 +16921,14 @@ var SubcategoryService = class extends BaseService {
|
|
|
16773
16921
|
* @returns A record mapping category ID to subcategory count.
|
|
16774
16922
|
*/
|
|
16775
16923
|
async getSubcategoryCounts(active = true) {
|
|
16776
|
-
const categoriesRef = (0,
|
|
16777
|
-
const categoriesSnapshot = await (0,
|
|
16924
|
+
const categoriesRef = (0, import_firestore52.collection)(this.db, CATEGORIES_COLLECTION);
|
|
16925
|
+
const categoriesSnapshot = await (0, import_firestore52.getDocs)(categoriesRef);
|
|
16778
16926
|
const counts = {};
|
|
16779
16927
|
for (const categoryDoc of categoriesSnapshot.docs) {
|
|
16780
16928
|
const categoryId = categoryDoc.id;
|
|
16781
16929
|
const subcategoriesRef = this.getSubcategoriesRef(categoryId);
|
|
16782
|
-
const q = (0,
|
|
16783
|
-
const snapshot = await (0,
|
|
16930
|
+
const q = (0, import_firestore52.query)(subcategoriesRef, (0, import_firestore52.where)("isActive", "==", active));
|
|
16931
|
+
const snapshot = await (0, import_firestore52.getCountFromServer)(q);
|
|
16784
16932
|
counts[categoryId] = snapshot.data().count;
|
|
16785
16933
|
}
|
|
16786
16934
|
return counts;
|
|
@@ -16794,13 +16942,13 @@ var SubcategoryService = class extends BaseService {
|
|
|
16794
16942
|
async getAllByCategoryId(categoryId, options = {}) {
|
|
16795
16943
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
16796
16944
|
const constraints = [
|
|
16797
|
-
(0,
|
|
16798
|
-
(0,
|
|
16799
|
-
queryLimit ? (0,
|
|
16800
|
-
lastVisible ? (0,
|
|
16945
|
+
(0, import_firestore52.where)("isActive", "==", active),
|
|
16946
|
+
(0, import_firestore52.orderBy)("name"),
|
|
16947
|
+
queryLimit ? (0, import_firestore52.limit)(queryLimit) : void 0,
|
|
16948
|
+
lastVisible ? (0, import_firestore52.startAfter)(lastVisible) : void 0
|
|
16801
16949
|
].filter((c) => !!c);
|
|
16802
|
-
const q = (0,
|
|
16803
|
-
const querySnapshot = await (0,
|
|
16950
|
+
const q = (0, import_firestore52.query)(this.getSubcategoriesRef(categoryId), ...constraints);
|
|
16951
|
+
const querySnapshot = await (0, import_firestore52.getDocs)(q);
|
|
16804
16952
|
const subcategories = querySnapshot.docs.map(
|
|
16805
16953
|
(doc38) => ({
|
|
16806
16954
|
id: doc38.id,
|
|
@@ -16821,16 +16969,16 @@ var SubcategoryService = class extends BaseService {
|
|
|
16821
16969
|
async getAll(options = {}) {
|
|
16822
16970
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
16823
16971
|
const constraints = [
|
|
16824
|
-
(0,
|
|
16825
|
-
(0,
|
|
16826
|
-
queryLimit ? (0,
|
|
16827
|
-
lastVisible ? (0,
|
|
16972
|
+
(0, import_firestore52.where)("isActive", "==", active),
|
|
16973
|
+
(0, import_firestore52.orderBy)("name"),
|
|
16974
|
+
queryLimit ? (0, import_firestore52.limit)(queryLimit) : void 0,
|
|
16975
|
+
lastVisible ? (0, import_firestore52.startAfter)(lastVisible) : void 0
|
|
16828
16976
|
].filter((c) => !!c);
|
|
16829
|
-
const q = (0,
|
|
16830
|
-
(0,
|
|
16977
|
+
const q = (0, import_firestore52.query)(
|
|
16978
|
+
(0, import_firestore52.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
|
|
16831
16979
|
...constraints
|
|
16832
16980
|
);
|
|
16833
|
-
const querySnapshot = await (0,
|
|
16981
|
+
const querySnapshot = await (0, import_firestore52.getDocs)(q);
|
|
16834
16982
|
const subcategories = querySnapshot.docs.map(
|
|
16835
16983
|
(doc38) => ({
|
|
16836
16984
|
id: doc38.id,
|
|
@@ -16846,11 +16994,11 @@ var SubcategoryService = class extends BaseService {
|
|
|
16846
16994
|
* @returns Lista svih aktivnih subkategorija
|
|
16847
16995
|
*/
|
|
16848
16996
|
async getAllForFilterByCategoryId(categoryId) {
|
|
16849
|
-
const q = (0,
|
|
16997
|
+
const q = (0, import_firestore52.query)(
|
|
16850
16998
|
this.getSubcategoriesRef(categoryId),
|
|
16851
|
-
(0,
|
|
16999
|
+
(0, import_firestore52.where)("isActive", "==", true)
|
|
16852
17000
|
);
|
|
16853
|
-
const querySnapshot = await (0,
|
|
17001
|
+
const querySnapshot = await (0, import_firestore52.getDocs)(q);
|
|
16854
17002
|
return querySnapshot.docs.map(
|
|
16855
17003
|
(doc38) => ({
|
|
16856
17004
|
id: doc38.id,
|
|
@@ -16863,11 +17011,11 @@ var SubcategoryService = class extends BaseService {
|
|
|
16863
17011
|
* @returns Lista svih aktivnih subkategorija
|
|
16864
17012
|
*/
|
|
16865
17013
|
async getAllForFilter() {
|
|
16866
|
-
const q = (0,
|
|
16867
|
-
(0,
|
|
16868
|
-
(0,
|
|
17014
|
+
const q = (0, import_firestore52.query)(
|
|
17015
|
+
(0, import_firestore52.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
|
|
17016
|
+
(0, import_firestore52.where)("isActive", "==", true)
|
|
16869
17017
|
);
|
|
16870
|
-
const querySnapshot = await (0,
|
|
17018
|
+
const querySnapshot = await (0, import_firestore52.getDocs)(q);
|
|
16871
17019
|
return querySnapshot.docs.map(
|
|
16872
17020
|
(doc38) => ({
|
|
16873
17021
|
id: doc38.id,
|
|
@@ -16885,11 +17033,11 @@ var SubcategoryService = class extends BaseService {
|
|
|
16885
17033
|
async update(categoryId, subcategoryId, subcategory) {
|
|
16886
17034
|
const newCategoryId = subcategory.categoryId;
|
|
16887
17035
|
if (newCategoryId && newCategoryId !== categoryId) {
|
|
16888
|
-
const oldDocRef = (0,
|
|
17036
|
+
const oldDocRef = (0, import_firestore52.doc)(
|
|
16889
17037
|
this.getSubcategoriesRef(categoryId),
|
|
16890
17038
|
subcategoryId
|
|
16891
17039
|
);
|
|
16892
|
-
const docSnap = await (0,
|
|
17040
|
+
const docSnap = await (0, import_firestore52.getDoc)(oldDocRef);
|
|
16893
17041
|
if (!docSnap.exists()) {
|
|
16894
17042
|
throw new Error("Subcategory to update does not exist.");
|
|
16895
17043
|
}
|
|
@@ -16903,20 +17051,20 @@ var SubcategoryService = class extends BaseService {
|
|
|
16903
17051
|
// Preserve original creation date
|
|
16904
17052
|
updatedAt: /* @__PURE__ */ new Date()
|
|
16905
17053
|
};
|
|
16906
|
-
const newDocRef = (0,
|
|
17054
|
+
const newDocRef = (0, import_firestore52.doc)(
|
|
16907
17055
|
this.getSubcategoriesRef(newCategoryId),
|
|
16908
17056
|
subcategoryId
|
|
16909
17057
|
);
|
|
16910
|
-
await (0,
|
|
16911
|
-
await (0,
|
|
17058
|
+
await (0, import_firestore52.setDoc)(newDocRef, newData);
|
|
17059
|
+
await (0, import_firestore52.deleteDoc)(oldDocRef);
|
|
16912
17060
|
return { id: subcategoryId, ...newData };
|
|
16913
17061
|
} else {
|
|
16914
17062
|
const updateData = {
|
|
16915
17063
|
...subcategory,
|
|
16916
17064
|
updatedAt: /* @__PURE__ */ new Date()
|
|
16917
17065
|
};
|
|
16918
|
-
const docRef = (0,
|
|
16919
|
-
await (0,
|
|
17066
|
+
const docRef = (0, import_firestore52.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
17067
|
+
await (0, import_firestore52.updateDoc)(docRef, updateData);
|
|
16920
17068
|
return this.getById(categoryId, subcategoryId);
|
|
16921
17069
|
}
|
|
16922
17070
|
}
|
|
@@ -16943,8 +17091,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
16943
17091
|
* @returns Podkategorija ili null ako ne postoji
|
|
16944
17092
|
*/
|
|
16945
17093
|
async getById(categoryId, subcategoryId) {
|
|
16946
|
-
const docRef = (0,
|
|
16947
|
-
const docSnap = await (0,
|
|
17094
|
+
const docRef = (0, import_firestore52.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
17095
|
+
const docSnap = await (0, import_firestore52.getDoc)(docRef);
|
|
16948
17096
|
if (!docSnap.exists()) return null;
|
|
16949
17097
|
return {
|
|
16950
17098
|
id: docSnap.id,
|
|
@@ -16954,7 +17102,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
16954
17102
|
};
|
|
16955
17103
|
|
|
16956
17104
|
// src/backoffice/services/technology.service.ts
|
|
16957
|
-
var
|
|
17105
|
+
var import_firestore53 = require("firebase/firestore");
|
|
16958
17106
|
var DEFAULT_CERTIFICATION_REQUIREMENT = {
|
|
16959
17107
|
minimumLevel: "aesthetician" /* AESTHETICIAN */,
|
|
16960
17108
|
requiredSpecialties: []
|
|
@@ -16964,7 +17112,7 @@ var TechnologyService = class extends BaseService {
|
|
|
16964
17112
|
* Reference to the Firestore collection of technologies.
|
|
16965
17113
|
*/
|
|
16966
17114
|
get technologiesRef() {
|
|
16967
|
-
return (0,
|
|
17115
|
+
return (0, import_firestore53.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
16968
17116
|
}
|
|
16969
17117
|
/**
|
|
16970
17118
|
* Creates a new technology.
|
|
@@ -16992,7 +17140,7 @@ var TechnologyService = class extends BaseService {
|
|
|
16992
17140
|
if (technology.technicalDetails) {
|
|
16993
17141
|
newTechnology.technicalDetails = technology.technicalDetails;
|
|
16994
17142
|
}
|
|
16995
|
-
const docRef = await (0,
|
|
17143
|
+
const docRef = await (0, import_firestore53.addDoc)(this.technologiesRef, newTechnology);
|
|
16996
17144
|
return { id: docRef.id, ...newTechnology };
|
|
16997
17145
|
}
|
|
16998
17146
|
/**
|
|
@@ -17001,8 +17149,8 @@ var TechnologyService = class extends BaseService {
|
|
|
17001
17149
|
* @returns A record mapping subcategory ID to technology count.
|
|
17002
17150
|
*/
|
|
17003
17151
|
async getTechnologyCounts(active = true) {
|
|
17004
|
-
const q = (0,
|
|
17005
|
-
const snapshot = await (0,
|
|
17152
|
+
const q = (0, import_firestore53.query)(this.technologiesRef, (0, import_firestore53.where)("isActive", "==", active));
|
|
17153
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17006
17154
|
const counts = {};
|
|
17007
17155
|
snapshot.docs.forEach((doc38) => {
|
|
17008
17156
|
const tech = doc38.data();
|
|
@@ -17016,8 +17164,8 @@ var TechnologyService = class extends BaseService {
|
|
|
17016
17164
|
* @returns A record mapping category ID to technology count.
|
|
17017
17165
|
*/
|
|
17018
17166
|
async getTechnologyCountsByCategory(active = true) {
|
|
17019
|
-
const q = (0,
|
|
17020
|
-
const snapshot = await (0,
|
|
17167
|
+
const q = (0, import_firestore53.query)(this.technologiesRef, (0, import_firestore53.where)("isActive", "==", active));
|
|
17168
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17021
17169
|
const counts = {};
|
|
17022
17170
|
snapshot.docs.forEach((doc38) => {
|
|
17023
17171
|
const tech = doc38.data();
|
|
@@ -17033,13 +17181,13 @@ var TechnologyService = class extends BaseService {
|
|
|
17033
17181
|
async getAll(options = {}) {
|
|
17034
17182
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
17035
17183
|
const constraints = [
|
|
17036
|
-
(0,
|
|
17037
|
-
(0,
|
|
17038
|
-
queryLimit ? (0,
|
|
17039
|
-
lastVisible ? (0,
|
|
17184
|
+
(0, import_firestore53.where)("isActive", "==", active),
|
|
17185
|
+
(0, import_firestore53.orderBy)("name"),
|
|
17186
|
+
queryLimit ? (0, import_firestore53.limit)(queryLimit) : void 0,
|
|
17187
|
+
lastVisible ? (0, import_firestore53.startAfter)(lastVisible) : void 0
|
|
17040
17188
|
].filter((c) => !!c);
|
|
17041
|
-
const q = (0,
|
|
17042
|
-
const snapshot = await (0,
|
|
17189
|
+
const q = (0, import_firestore53.query)(this.technologiesRef, ...constraints);
|
|
17190
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17043
17191
|
const technologies = snapshot.docs.map(
|
|
17044
17192
|
(doc38) => ({
|
|
17045
17193
|
id: doc38.id,
|
|
@@ -17058,14 +17206,14 @@ var TechnologyService = class extends BaseService {
|
|
|
17058
17206
|
async getAllByCategoryId(categoryId, options = {}) {
|
|
17059
17207
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
17060
17208
|
const constraints = [
|
|
17061
|
-
(0,
|
|
17062
|
-
(0,
|
|
17063
|
-
(0,
|
|
17064
|
-
queryLimit ? (0,
|
|
17065
|
-
lastVisible ? (0,
|
|
17209
|
+
(0, import_firestore53.where)("categoryId", "==", categoryId),
|
|
17210
|
+
(0, import_firestore53.where)("isActive", "==", active),
|
|
17211
|
+
(0, import_firestore53.orderBy)("name"),
|
|
17212
|
+
queryLimit ? (0, import_firestore53.limit)(queryLimit) : void 0,
|
|
17213
|
+
lastVisible ? (0, import_firestore53.startAfter)(lastVisible) : void 0
|
|
17066
17214
|
].filter((c) => !!c);
|
|
17067
|
-
const q = (0,
|
|
17068
|
-
const snapshot = await (0,
|
|
17215
|
+
const q = (0, import_firestore53.query)(this.technologiesRef, ...constraints);
|
|
17216
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17069
17217
|
const technologies = snapshot.docs.map(
|
|
17070
17218
|
(doc38) => ({
|
|
17071
17219
|
id: doc38.id,
|
|
@@ -17084,14 +17232,14 @@ var TechnologyService = class extends BaseService {
|
|
|
17084
17232
|
async getAllBySubcategoryId(subcategoryId, options = {}) {
|
|
17085
17233
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
17086
17234
|
const constraints = [
|
|
17087
|
-
(0,
|
|
17088
|
-
(0,
|
|
17089
|
-
(0,
|
|
17090
|
-
queryLimit ? (0,
|
|
17091
|
-
lastVisible ? (0,
|
|
17235
|
+
(0, import_firestore53.where)("subcategoryId", "==", subcategoryId),
|
|
17236
|
+
(0, import_firestore53.where)("isActive", "==", active),
|
|
17237
|
+
(0, import_firestore53.orderBy)("name"),
|
|
17238
|
+
queryLimit ? (0, import_firestore53.limit)(queryLimit) : void 0,
|
|
17239
|
+
lastVisible ? (0, import_firestore53.startAfter)(lastVisible) : void 0
|
|
17092
17240
|
].filter((c) => !!c);
|
|
17093
|
-
const q = (0,
|
|
17094
|
-
const snapshot = await (0,
|
|
17241
|
+
const q = (0, import_firestore53.query)(this.technologiesRef, ...constraints);
|
|
17242
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17095
17243
|
const technologies = snapshot.docs.map(
|
|
17096
17244
|
(doc38) => ({
|
|
17097
17245
|
id: doc38.id,
|
|
@@ -17115,8 +17263,8 @@ var TechnologyService = class extends BaseService {
|
|
|
17115
17263
|
}
|
|
17116
17264
|
});
|
|
17117
17265
|
updateData.updatedAt = /* @__PURE__ */ new Date();
|
|
17118
|
-
const docRef = (0,
|
|
17119
|
-
await (0,
|
|
17266
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, id);
|
|
17267
|
+
await (0, import_firestore53.updateDoc)(docRef, updateData);
|
|
17120
17268
|
return this.getById(id);
|
|
17121
17269
|
}
|
|
17122
17270
|
/**
|
|
@@ -17139,8 +17287,8 @@ var TechnologyService = class extends BaseService {
|
|
|
17139
17287
|
* @returns The technology or null if it doesn't exist.
|
|
17140
17288
|
*/
|
|
17141
17289
|
async getById(id) {
|
|
17142
|
-
const docRef = (0,
|
|
17143
|
-
const docSnap = await (0,
|
|
17290
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, id);
|
|
17291
|
+
const docSnap = await (0, import_firestore53.getDoc)(docRef);
|
|
17144
17292
|
if (!docSnap.exists()) return null;
|
|
17145
17293
|
return {
|
|
17146
17294
|
id: docSnap.id,
|
|
@@ -17154,10 +17302,10 @@ var TechnologyService = class extends BaseService {
|
|
|
17154
17302
|
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
17155
17303
|
*/
|
|
17156
17304
|
async addRequirement(technologyId, requirement) {
|
|
17157
|
-
const docRef = (0,
|
|
17305
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17158
17306
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
17159
|
-
await (0,
|
|
17160
|
-
[requirementType]: (0,
|
|
17307
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17308
|
+
[requirementType]: (0, import_firestore53.arrayUnion)(requirement),
|
|
17161
17309
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17162
17310
|
});
|
|
17163
17311
|
return this.getById(technologyId);
|
|
@@ -17169,10 +17317,10 @@ var TechnologyService = class extends BaseService {
|
|
|
17169
17317
|
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
17170
17318
|
*/
|
|
17171
17319
|
async removeRequirement(technologyId, requirement) {
|
|
17172
|
-
const docRef = (0,
|
|
17320
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17173
17321
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
17174
|
-
await (0,
|
|
17175
|
-
[requirementType]: (0,
|
|
17322
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17323
|
+
[requirementType]: (0, import_firestore53.arrayRemove)(requirement),
|
|
17176
17324
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17177
17325
|
});
|
|
17178
17326
|
return this.getById(technologyId);
|
|
@@ -17209,9 +17357,9 @@ var TechnologyService = class extends BaseService {
|
|
|
17209
17357
|
* @returns Ažurirana tehnologija
|
|
17210
17358
|
*/
|
|
17211
17359
|
async addBlockingCondition(technologyId, condition) {
|
|
17212
|
-
const docRef = (0,
|
|
17213
|
-
await (0,
|
|
17214
|
-
blockingConditions: (0,
|
|
17360
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17361
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17362
|
+
blockingConditions: (0, import_firestore53.arrayUnion)(condition),
|
|
17215
17363
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17216
17364
|
});
|
|
17217
17365
|
return this.getById(technologyId);
|
|
@@ -17223,9 +17371,9 @@ var TechnologyService = class extends BaseService {
|
|
|
17223
17371
|
* @returns Ažurirana tehnologija
|
|
17224
17372
|
*/
|
|
17225
17373
|
async removeBlockingCondition(technologyId, condition) {
|
|
17226
|
-
const docRef = (0,
|
|
17227
|
-
await (0,
|
|
17228
|
-
blockingConditions: (0,
|
|
17374
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17375
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17376
|
+
blockingConditions: (0, import_firestore53.arrayRemove)(condition),
|
|
17229
17377
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17230
17378
|
});
|
|
17231
17379
|
return this.getById(technologyId);
|
|
@@ -17237,7 +17385,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17237
17385
|
* @returns Ažurirana tehnologija
|
|
17238
17386
|
*/
|
|
17239
17387
|
async addContraindication(technologyId, contraindication) {
|
|
17240
|
-
const docRef = (0,
|
|
17388
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17241
17389
|
const technology = await this.getById(technologyId);
|
|
17242
17390
|
if (!technology) {
|
|
17243
17391
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -17246,7 +17394,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17246
17394
|
if (existingContraindications.some((c) => c.id === contraindication.id)) {
|
|
17247
17395
|
return technology;
|
|
17248
17396
|
}
|
|
17249
|
-
await (0,
|
|
17397
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17250
17398
|
contraindications: [...existingContraindications, contraindication],
|
|
17251
17399
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17252
17400
|
});
|
|
@@ -17259,7 +17407,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17259
17407
|
* @returns Ažurirana tehnologija
|
|
17260
17408
|
*/
|
|
17261
17409
|
async removeContraindication(technologyId, contraindication) {
|
|
17262
|
-
const docRef = (0,
|
|
17410
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17263
17411
|
const technology = await this.getById(technologyId);
|
|
17264
17412
|
if (!technology) {
|
|
17265
17413
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -17267,7 +17415,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17267
17415
|
const updatedContraindications = (technology.contraindications || []).filter(
|
|
17268
17416
|
(c) => c.id !== contraindication.id
|
|
17269
17417
|
);
|
|
17270
|
-
await (0,
|
|
17418
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17271
17419
|
contraindications: updatedContraindications,
|
|
17272
17420
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17273
17421
|
});
|
|
@@ -17281,7 +17429,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17281
17429
|
* @returns The updated technology
|
|
17282
17430
|
*/
|
|
17283
17431
|
async updateContraindication(technologyId, contraindication) {
|
|
17284
|
-
const docRef = (0,
|
|
17432
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17285
17433
|
const technology = await this.getById(technologyId);
|
|
17286
17434
|
if (!technology) {
|
|
17287
17435
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -17296,7 +17444,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17296
17444
|
}
|
|
17297
17445
|
const updatedContraindications = [...contraindications];
|
|
17298
17446
|
updatedContraindications[index] = contraindication;
|
|
17299
|
-
await (0,
|
|
17447
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17300
17448
|
contraindications: updatedContraindications,
|
|
17301
17449
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17302
17450
|
});
|
|
@@ -17309,7 +17457,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17309
17457
|
* @returns Ažurirana tehnologija
|
|
17310
17458
|
*/
|
|
17311
17459
|
async addBenefit(technologyId, benefit) {
|
|
17312
|
-
const docRef = (0,
|
|
17460
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17313
17461
|
const technology = await this.getById(technologyId);
|
|
17314
17462
|
if (!technology) {
|
|
17315
17463
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -17318,7 +17466,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17318
17466
|
if (existingBenefits.some((b) => b.id === benefit.id)) {
|
|
17319
17467
|
return technology;
|
|
17320
17468
|
}
|
|
17321
|
-
await (0,
|
|
17469
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17322
17470
|
benefits: [...existingBenefits, benefit],
|
|
17323
17471
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17324
17472
|
});
|
|
@@ -17331,13 +17479,13 @@ var TechnologyService = class extends BaseService {
|
|
|
17331
17479
|
* @returns Ažurirana tehnologija
|
|
17332
17480
|
*/
|
|
17333
17481
|
async removeBenefit(technologyId, benefit) {
|
|
17334
|
-
const docRef = (0,
|
|
17482
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17335
17483
|
const technology = await this.getById(technologyId);
|
|
17336
17484
|
if (!technology) {
|
|
17337
17485
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
17338
17486
|
}
|
|
17339
17487
|
const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
|
|
17340
|
-
await (0,
|
|
17488
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17341
17489
|
benefits: updatedBenefits,
|
|
17342
17490
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17343
17491
|
});
|
|
@@ -17351,7 +17499,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17351
17499
|
* @returns The updated technology
|
|
17352
17500
|
*/
|
|
17353
17501
|
async updateBenefit(technologyId, benefit) {
|
|
17354
|
-
const docRef = (0,
|
|
17502
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17355
17503
|
const technology = await this.getById(technologyId);
|
|
17356
17504
|
if (!technology) {
|
|
17357
17505
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -17366,7 +17514,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17366
17514
|
}
|
|
17367
17515
|
const updatedBenefits = [...benefits];
|
|
17368
17516
|
updatedBenefits[index] = benefit;
|
|
17369
|
-
await (0,
|
|
17517
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17370
17518
|
benefits: updatedBenefits,
|
|
17371
17519
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17372
17520
|
});
|
|
@@ -17406,8 +17554,8 @@ var TechnologyService = class extends BaseService {
|
|
|
17406
17554
|
* @returns Ažurirana tehnologija
|
|
17407
17555
|
*/
|
|
17408
17556
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
17409
|
-
const docRef = (0,
|
|
17410
|
-
await (0,
|
|
17557
|
+
const docRef = (0, import_firestore53.doc)(this.technologiesRef, technologyId);
|
|
17558
|
+
await (0, import_firestore53.updateDoc)(docRef, {
|
|
17411
17559
|
certificationRequirement,
|
|
17412
17560
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17413
17561
|
});
|
|
@@ -17500,13 +17648,13 @@ var TechnologyService = class extends BaseService {
|
|
|
17500
17648
|
* @param subcategoryId - The ID of the subcategory.
|
|
17501
17649
|
*/
|
|
17502
17650
|
async getAllForFilterBySubcategory(subcategoryId) {
|
|
17503
|
-
const q = (0,
|
|
17504
|
-
(0,
|
|
17505
|
-
(0,
|
|
17506
|
-
(0,
|
|
17507
|
-
(0,
|
|
17651
|
+
const q = (0, import_firestore53.query)(
|
|
17652
|
+
(0, import_firestore53.collection)(this.db, TECHNOLOGIES_COLLECTION),
|
|
17653
|
+
(0, import_firestore53.where)("isActive", "==", true),
|
|
17654
|
+
(0, import_firestore53.where)("subcategoryId", "==", subcategoryId),
|
|
17655
|
+
(0, import_firestore53.orderBy)("name")
|
|
17508
17656
|
);
|
|
17509
|
-
const snapshot = await (0,
|
|
17657
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17510
17658
|
return snapshot.docs.map(
|
|
17511
17659
|
(doc38) => ({
|
|
17512
17660
|
id: doc38.id,
|
|
@@ -17520,14 +17668,14 @@ var TechnologyService = class extends BaseService {
|
|
|
17520
17668
|
* @param subcategoryId - The ID of the subcategory.
|
|
17521
17669
|
*/
|
|
17522
17670
|
async getAllForFilterBySubcategoryId(categoryId, subcategoryId) {
|
|
17523
|
-
const q = (0,
|
|
17524
|
-
(0,
|
|
17525
|
-
(0,
|
|
17526
|
-
(0,
|
|
17527
|
-
(0,
|
|
17528
|
-
(0,
|
|
17671
|
+
const q = (0, import_firestore53.query)(
|
|
17672
|
+
(0, import_firestore53.collection)(this.db, TECHNOLOGIES_COLLECTION),
|
|
17673
|
+
(0, import_firestore53.where)("isActive", "==", true),
|
|
17674
|
+
(0, import_firestore53.where)("categoryId", "==", categoryId),
|
|
17675
|
+
(0, import_firestore53.where)("subcategoryId", "==", subcategoryId),
|
|
17676
|
+
(0, import_firestore53.orderBy)("name")
|
|
17529
17677
|
);
|
|
17530
|
-
const snapshot = await (0,
|
|
17678
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17531
17679
|
return snapshot.docs.map(
|
|
17532
17680
|
(doc38) => ({
|
|
17533
17681
|
id: doc38.id,
|
|
@@ -17539,12 +17687,12 @@ var TechnologyService = class extends BaseService {
|
|
|
17539
17687
|
* Gets all active technologies for filter dropdowns.
|
|
17540
17688
|
*/
|
|
17541
17689
|
async getAllForFilter() {
|
|
17542
|
-
const q = (0,
|
|
17543
|
-
(0,
|
|
17544
|
-
(0,
|
|
17545
|
-
(0,
|
|
17690
|
+
const q = (0, import_firestore53.query)(
|
|
17691
|
+
(0, import_firestore53.collection)(this.db, TECHNOLOGIES_COLLECTION),
|
|
17692
|
+
(0, import_firestore53.where)("isActive", "==", true),
|
|
17693
|
+
(0, import_firestore53.orderBy)("name")
|
|
17546
17694
|
);
|
|
17547
|
-
const snapshot = await (0,
|
|
17695
|
+
const snapshot = await (0, import_firestore53.getDocs)(q);
|
|
17548
17696
|
return snapshot.docs.map(
|
|
17549
17697
|
(doc38) => ({
|
|
17550
17698
|
id: doc38.id,
|
|
@@ -17555,7 +17703,7 @@ var TechnologyService = class extends BaseService {
|
|
|
17555
17703
|
};
|
|
17556
17704
|
|
|
17557
17705
|
// src/backoffice/services/product.service.ts
|
|
17558
|
-
var
|
|
17706
|
+
var import_firestore54 = require("firebase/firestore");
|
|
17559
17707
|
|
|
17560
17708
|
// src/backoffice/types/product.types.ts
|
|
17561
17709
|
var PRODUCTS_COLLECTION = "products";
|
|
@@ -17568,7 +17716,7 @@ var ProductService = class extends BaseService {
|
|
|
17568
17716
|
* @returns Firestore collection reference
|
|
17569
17717
|
*/
|
|
17570
17718
|
getProductsRef(technologyId) {
|
|
17571
|
-
return (0,
|
|
17719
|
+
return (0, import_firestore54.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
17572
17720
|
}
|
|
17573
17721
|
/**
|
|
17574
17722
|
* Creates a new product under technology
|
|
@@ -17583,7 +17731,7 @@ var ProductService = class extends BaseService {
|
|
|
17583
17731
|
updatedAt: now,
|
|
17584
17732
|
isActive: true
|
|
17585
17733
|
};
|
|
17586
|
-
const productRef = await (0,
|
|
17734
|
+
const productRef = await (0, import_firestore54.addDoc)(this.getProductsRef(technologyId), newProduct);
|
|
17587
17735
|
return { id: productRef.id, ...newProduct };
|
|
17588
17736
|
}
|
|
17589
17737
|
/**
|
|
@@ -17592,22 +17740,22 @@ var ProductService = class extends BaseService {
|
|
|
17592
17740
|
*/
|
|
17593
17741
|
async getAll(options) {
|
|
17594
17742
|
const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
|
|
17595
|
-
const constraints = [(0,
|
|
17743
|
+
const constraints = [(0, import_firestore54.where)("isActive", "==", true), (0, import_firestore54.orderBy)("name")];
|
|
17596
17744
|
if (categoryId) {
|
|
17597
|
-
constraints.push((0,
|
|
17745
|
+
constraints.push((0, import_firestore54.where)("categoryId", "==", categoryId));
|
|
17598
17746
|
}
|
|
17599
17747
|
if (subcategoryId) {
|
|
17600
|
-
constraints.push((0,
|
|
17748
|
+
constraints.push((0, import_firestore54.where)("subcategoryId", "==", subcategoryId));
|
|
17601
17749
|
}
|
|
17602
17750
|
if (technologyId) {
|
|
17603
|
-
constraints.push((0,
|
|
17751
|
+
constraints.push((0, import_firestore54.where)("technologyId", "==", technologyId));
|
|
17604
17752
|
}
|
|
17605
17753
|
if (lastVisible) {
|
|
17606
|
-
constraints.push((0,
|
|
17754
|
+
constraints.push((0, import_firestore54.startAfter)(lastVisible));
|
|
17607
17755
|
}
|
|
17608
|
-
constraints.push((0,
|
|
17609
|
-
const q = (0,
|
|
17610
|
-
const snapshot = await (0,
|
|
17756
|
+
constraints.push((0, import_firestore54.limit)(rowsPerPage));
|
|
17757
|
+
const q = (0, import_firestore54.query)((0, import_firestore54.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
17758
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
17611
17759
|
const products = snapshot.docs.map(
|
|
17612
17760
|
(doc38) => ({
|
|
17613
17761
|
id: doc38.id,
|
|
@@ -17622,18 +17770,18 @@ var ProductService = class extends BaseService {
|
|
|
17622
17770
|
*/
|
|
17623
17771
|
async getProductsCount(options) {
|
|
17624
17772
|
const { categoryId, subcategoryId, technologyId } = options;
|
|
17625
|
-
const constraints = [(0,
|
|
17773
|
+
const constraints = [(0, import_firestore54.where)("isActive", "==", true)];
|
|
17626
17774
|
if (categoryId) {
|
|
17627
|
-
constraints.push((0,
|
|
17775
|
+
constraints.push((0, import_firestore54.where)("categoryId", "==", categoryId));
|
|
17628
17776
|
}
|
|
17629
17777
|
if (subcategoryId) {
|
|
17630
|
-
constraints.push((0,
|
|
17778
|
+
constraints.push((0, import_firestore54.where)("subcategoryId", "==", subcategoryId));
|
|
17631
17779
|
}
|
|
17632
17780
|
if (technologyId) {
|
|
17633
|
-
constraints.push((0,
|
|
17781
|
+
constraints.push((0, import_firestore54.where)("technologyId", "==", technologyId));
|
|
17634
17782
|
}
|
|
17635
|
-
const q = (0,
|
|
17636
|
-
const snapshot = await (0,
|
|
17783
|
+
const q = (0, import_firestore54.query)((0, import_firestore54.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
17784
|
+
const snapshot = await (0, import_firestore54.getCountFromServer)(q);
|
|
17637
17785
|
return snapshot.data().count;
|
|
17638
17786
|
}
|
|
17639
17787
|
/**
|
|
@@ -17641,8 +17789,8 @@ var ProductService = class extends BaseService {
|
|
|
17641
17789
|
* This uses a single collectionGroup query for efficiency.
|
|
17642
17790
|
*/
|
|
17643
17791
|
async getProductCounts() {
|
|
17644
|
-
const q = (0,
|
|
17645
|
-
const snapshot = await (0,
|
|
17792
|
+
const q = (0, import_firestore54.query)((0, import_firestore54.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore54.where)("isActive", "==", true));
|
|
17793
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
17646
17794
|
const counts = {
|
|
17647
17795
|
byCategory: {},
|
|
17648
17796
|
bySubcategory: {},
|
|
@@ -17670,12 +17818,12 @@ var ProductService = class extends BaseService {
|
|
|
17670
17818
|
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
17671
17819
|
*/
|
|
17672
17820
|
async getAllByTechnology(technologyId) {
|
|
17673
|
-
const q = (0,
|
|
17821
|
+
const q = (0, import_firestore54.query)(
|
|
17674
17822
|
this.getProductsRef(technologyId),
|
|
17675
|
-
(0,
|
|
17676
|
-
(0,
|
|
17823
|
+
(0, import_firestore54.where)("isActive", "==", true),
|
|
17824
|
+
(0, import_firestore54.orderBy)("name")
|
|
17677
17825
|
);
|
|
17678
|
-
const snapshot = await (0,
|
|
17826
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
17679
17827
|
return snapshot.docs.map(
|
|
17680
17828
|
(doc38) => ({
|
|
17681
17829
|
id: doc38.id,
|
|
@@ -17687,16 +17835,16 @@ var ProductService = class extends BaseService {
|
|
|
17687
17835
|
* Gets all products for a brand by filtering through all technologies
|
|
17688
17836
|
*/
|
|
17689
17837
|
async getAllByBrand(brandId) {
|
|
17690
|
-
const allTechnologiesRef = (0,
|
|
17691
|
-
const technologiesSnapshot = await (0,
|
|
17838
|
+
const allTechnologiesRef = (0, import_firestore54.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
17839
|
+
const technologiesSnapshot = await (0, import_firestore54.getDocs)(allTechnologiesRef);
|
|
17692
17840
|
const products = [];
|
|
17693
17841
|
for (const techDoc of technologiesSnapshot.docs) {
|
|
17694
|
-
const q = (0,
|
|
17842
|
+
const q = (0, import_firestore54.query)(
|
|
17695
17843
|
this.getProductsRef(techDoc.id),
|
|
17696
|
-
(0,
|
|
17697
|
-
(0,
|
|
17844
|
+
(0, import_firestore54.where)("brandId", "==", brandId),
|
|
17845
|
+
(0, import_firestore54.where)("isActive", "==", true)
|
|
17698
17846
|
);
|
|
17699
|
-
const snapshot = await (0,
|
|
17847
|
+
const snapshot = await (0, import_firestore54.getDocs)(q);
|
|
17700
17848
|
products.push(
|
|
17701
17849
|
...snapshot.docs.map(
|
|
17702
17850
|
(doc38) => ({
|
|
@@ -17716,8 +17864,8 @@ var ProductService = class extends BaseService {
|
|
|
17716
17864
|
...product,
|
|
17717
17865
|
updatedAt: /* @__PURE__ */ new Date()
|
|
17718
17866
|
};
|
|
17719
|
-
const docRef = (0,
|
|
17720
|
-
await (0,
|
|
17867
|
+
const docRef = (0, import_firestore54.doc)(this.getProductsRef(technologyId), productId);
|
|
17868
|
+
await (0, import_firestore54.updateDoc)(docRef, updateData);
|
|
17721
17869
|
return this.getById(technologyId, productId);
|
|
17722
17870
|
}
|
|
17723
17871
|
/**
|
|
@@ -17732,8 +17880,8 @@ var ProductService = class extends BaseService {
|
|
|
17732
17880
|
* Gets a product by ID
|
|
17733
17881
|
*/
|
|
17734
17882
|
async getById(technologyId, productId) {
|
|
17735
|
-
const docRef = (0,
|
|
17736
|
-
const docSnap = await (0,
|
|
17883
|
+
const docRef = (0, import_firestore54.doc)(this.getProductsRef(technologyId), productId);
|
|
17884
|
+
const docSnap = await (0, import_firestore54.getDoc)(docRef);
|
|
17737
17885
|
if (!docSnap.exists()) return null;
|
|
17738
17886
|
return {
|
|
17739
17887
|
id: docSnap.id,
|
|
@@ -17743,7 +17891,7 @@ var ProductService = class extends BaseService {
|
|
|
17743
17891
|
};
|
|
17744
17892
|
|
|
17745
17893
|
// src/backoffice/services/constants.service.ts
|
|
17746
|
-
var
|
|
17894
|
+
var import_firestore55 = require("firebase/firestore");
|
|
17747
17895
|
var ADMIN_CONSTANTS_COLLECTION = "admin-constants";
|
|
17748
17896
|
var TREATMENT_BENEFITS_DOC = "treatment-benefits";
|
|
17749
17897
|
var CONTRAINDICATIONS_DOC = "contraindications";
|
|
@@ -17754,7 +17902,7 @@ var ConstantsService = class extends BaseService {
|
|
|
17754
17902
|
* @type {DocumentReference}
|
|
17755
17903
|
*/
|
|
17756
17904
|
get treatmentBenefitsDocRef() {
|
|
17757
|
-
return (0,
|
|
17905
|
+
return (0, import_firestore55.doc)(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
|
|
17758
17906
|
}
|
|
17759
17907
|
/**
|
|
17760
17908
|
* @description Gets the reference to the document holding contraindications.
|
|
@@ -17762,7 +17910,7 @@ var ConstantsService = class extends BaseService {
|
|
|
17762
17910
|
* @type {DocumentReference}
|
|
17763
17911
|
*/
|
|
17764
17912
|
get contraindicationsDocRef() {
|
|
17765
|
-
return (0,
|
|
17913
|
+
return (0, import_firestore55.doc)(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
|
|
17766
17914
|
}
|
|
17767
17915
|
// =================================================================
|
|
17768
17916
|
// Treatment Benefits
|
|
@@ -17772,7 +17920,7 @@ var ConstantsService = class extends BaseService {
|
|
|
17772
17920
|
* @returns {Promise<TreatmentBenefitDynamic[]>} An array of all treatment benefits.
|
|
17773
17921
|
*/
|
|
17774
17922
|
async getAllBenefitsForFilter() {
|
|
17775
|
-
const docSnap = await (0,
|
|
17923
|
+
const docSnap = await (0, import_firestore55.getDoc)(this.treatmentBenefitsDocRef);
|
|
17776
17924
|
if (!docSnap.exists()) {
|
|
17777
17925
|
return [];
|
|
17778
17926
|
}
|
|
@@ -17785,9 +17933,9 @@ var ConstantsService = class extends BaseService {
|
|
|
17785
17933
|
*/
|
|
17786
17934
|
async getAllBenefits(options) {
|
|
17787
17935
|
const allBenefits = await this.getAllBenefitsForFilter();
|
|
17788
|
-
const { page, limit:
|
|
17789
|
-
const startIndex = page *
|
|
17790
|
-
const endIndex = startIndex +
|
|
17936
|
+
const { page, limit: limit22 } = options;
|
|
17937
|
+
const startIndex = page * limit22;
|
|
17938
|
+
const endIndex = startIndex + limit22;
|
|
17791
17939
|
const paginatedBenefits = allBenefits.slice(startIndex, endIndex);
|
|
17792
17940
|
return { benefits: paginatedBenefits, total: allBenefits.length };
|
|
17793
17941
|
}
|
|
@@ -17801,12 +17949,12 @@ var ConstantsService = class extends BaseService {
|
|
|
17801
17949
|
id: this.generateId(),
|
|
17802
17950
|
...benefit
|
|
17803
17951
|
};
|
|
17804
|
-
const docSnap = await (0,
|
|
17952
|
+
const docSnap = await (0, import_firestore55.getDoc)(this.treatmentBenefitsDocRef);
|
|
17805
17953
|
if (!docSnap.exists()) {
|
|
17806
|
-
await (0,
|
|
17954
|
+
await (0, import_firestore55.setDoc)(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
|
|
17807
17955
|
} else {
|
|
17808
|
-
await (0,
|
|
17809
|
-
benefits: (0,
|
|
17956
|
+
await (0, import_firestore55.updateDoc)(this.treatmentBenefitsDocRef, {
|
|
17957
|
+
benefits: (0, import_firestore55.arrayUnion)(newBenefit)
|
|
17810
17958
|
});
|
|
17811
17959
|
}
|
|
17812
17960
|
return newBenefit;
|
|
@@ -17845,7 +17993,7 @@ var ConstantsService = class extends BaseService {
|
|
|
17845
17993
|
throw new Error("Treatment benefit not found.");
|
|
17846
17994
|
}
|
|
17847
17995
|
benefits[benefitIndex] = benefit;
|
|
17848
|
-
await (0,
|
|
17996
|
+
await (0, import_firestore55.updateDoc)(this.treatmentBenefitsDocRef, { benefits });
|
|
17849
17997
|
return benefit;
|
|
17850
17998
|
}
|
|
17851
17999
|
/**
|
|
@@ -17859,8 +18007,8 @@ var ConstantsService = class extends BaseService {
|
|
|
17859
18007
|
if (!benefitToRemove) {
|
|
17860
18008
|
return;
|
|
17861
18009
|
}
|
|
17862
|
-
await (0,
|
|
17863
|
-
benefits: (0,
|
|
18010
|
+
await (0, import_firestore55.updateDoc)(this.treatmentBenefitsDocRef, {
|
|
18011
|
+
benefits: (0, import_firestore55.arrayRemove)(benefitToRemove)
|
|
17864
18012
|
});
|
|
17865
18013
|
}
|
|
17866
18014
|
// =================================================================
|
|
@@ -17871,7 +18019,7 @@ var ConstantsService = class extends BaseService {
|
|
|
17871
18019
|
* @returns {Promise<ContraindicationDynamic[]>} An array of all contraindications.
|
|
17872
18020
|
*/
|
|
17873
18021
|
async getAllContraindicationsForFilter() {
|
|
17874
|
-
const docSnap = await (0,
|
|
18022
|
+
const docSnap = await (0, import_firestore55.getDoc)(this.contraindicationsDocRef);
|
|
17875
18023
|
if (!docSnap.exists()) {
|
|
17876
18024
|
return [];
|
|
17877
18025
|
}
|
|
@@ -17884,9 +18032,9 @@ var ConstantsService = class extends BaseService {
|
|
|
17884
18032
|
*/
|
|
17885
18033
|
async getAllContraindications(options) {
|
|
17886
18034
|
const allContraindications = await this.getAllContraindicationsForFilter();
|
|
17887
|
-
const { page, limit:
|
|
17888
|
-
const startIndex = page *
|
|
17889
|
-
const endIndex = startIndex +
|
|
18035
|
+
const { page, limit: limit22 } = options;
|
|
18036
|
+
const startIndex = page * limit22;
|
|
18037
|
+
const endIndex = startIndex + limit22;
|
|
17890
18038
|
const paginatedContraindications = allContraindications.slice(
|
|
17891
18039
|
startIndex,
|
|
17892
18040
|
endIndex
|
|
@@ -17906,14 +18054,14 @@ var ConstantsService = class extends BaseService {
|
|
|
17906
18054
|
id: this.generateId(),
|
|
17907
18055
|
...contraindication
|
|
17908
18056
|
};
|
|
17909
|
-
const docSnap = await (0,
|
|
18057
|
+
const docSnap = await (0, import_firestore55.getDoc)(this.contraindicationsDocRef);
|
|
17910
18058
|
if (!docSnap.exists()) {
|
|
17911
|
-
await (0,
|
|
18059
|
+
await (0, import_firestore55.setDoc)(this.contraindicationsDocRef, {
|
|
17912
18060
|
contraindications: [newContraindication]
|
|
17913
18061
|
});
|
|
17914
18062
|
} else {
|
|
17915
|
-
await (0,
|
|
17916
|
-
contraindications: (0,
|
|
18063
|
+
await (0, import_firestore55.updateDoc)(this.contraindicationsDocRef, {
|
|
18064
|
+
contraindications: (0, import_firestore55.arrayUnion)(newContraindication)
|
|
17917
18065
|
});
|
|
17918
18066
|
}
|
|
17919
18067
|
return newContraindication;
|
|
@@ -17954,7 +18102,7 @@ var ConstantsService = class extends BaseService {
|
|
|
17954
18102
|
throw new Error("Contraindication not found.");
|
|
17955
18103
|
}
|
|
17956
18104
|
contraindications[index] = contraindication;
|
|
17957
|
-
await (0,
|
|
18105
|
+
await (0, import_firestore55.updateDoc)(this.contraindicationsDocRef, { contraindications });
|
|
17958
18106
|
return contraindication;
|
|
17959
18107
|
}
|
|
17960
18108
|
/**
|
|
@@ -17968,8 +18116,8 @@ var ConstantsService = class extends BaseService {
|
|
|
17968
18116
|
if (!toRemove) {
|
|
17969
18117
|
return;
|
|
17970
18118
|
}
|
|
17971
|
-
await (0,
|
|
17972
|
-
contraindications: (0,
|
|
18119
|
+
await (0, import_firestore55.updateDoc)(this.contraindicationsDocRef, {
|
|
18120
|
+
contraindications: (0, import_firestore55.arrayRemove)(toRemove)
|
|
17973
18121
|
});
|
|
17974
18122
|
}
|
|
17975
18123
|
};
|
|
@@ -18032,6 +18180,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
18032
18180
|
AuthService,
|
|
18033
18181
|
BaseService,
|
|
18034
18182
|
BillingTransactionType,
|
|
18183
|
+
BillingTransactionsService,
|
|
18035
18184
|
BlockingCondition,
|
|
18036
18185
|
BrandService,
|
|
18037
18186
|
CALENDAR_COLLECTION,
|