@blackcode_sa/metaestetics-api 1.15.17-staging.3 → 1.15.17-staging.5
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 +3 -1
- package/dist/admin/index.d.ts +3 -1
- package/dist/index.d.mts +84 -4
- package/dist/index.d.ts +84 -4
- package/dist/index.js +111 -143
- package/dist/index.mjs +250 -283
- package/package.json +1 -1
- package/src/config/tiers.config.ts +3 -27
- package/src/services/auth/auth.service.ts +14 -48
- package/src/services/clinic/clinic-group.service.ts +13 -6
- package/src/services/clinic/utils/clinic-group.utils.ts +95 -87
- package/src/types/clinic/index.ts +8 -1
- package/src/types/clinic/rbac.types.ts +0 -1
- package/src/types/concern/index.ts +66 -0
- package/src/types/index.ts +3 -0
- package/src/validations/clinic.schema.ts +9 -3
package/dist/index.mjs
CHANGED
|
@@ -466,7 +466,6 @@ var PractitionerInviteStatus = /* @__PURE__ */ ((PractitionerInviteStatus2) => {
|
|
|
466
466
|
var ClinicRole = /* @__PURE__ */ ((ClinicRole2) => {
|
|
467
467
|
ClinicRole2["OWNER"] = "owner";
|
|
468
468
|
ClinicRole2["ADMIN"] = "admin";
|
|
469
|
-
ClinicRole2["DOCTOR"] = "doctor";
|
|
470
469
|
ClinicRole2["RECEPTIONIST"] = "receptionist";
|
|
471
470
|
ClinicRole2["ASSISTANT"] = "assistant";
|
|
472
471
|
return ClinicRole2;
|
|
@@ -483,11 +482,11 @@ var StaffInviteStatus = /* @__PURE__ */ ((StaffInviteStatus2) => {
|
|
|
483
482
|
var CLINIC_GROUPS_COLLECTION = "clinic_groups";
|
|
484
483
|
var CLINIC_ADMINS_COLLECTION = "clinic_admins";
|
|
485
484
|
var CLINICS_COLLECTION = "clinics";
|
|
486
|
-
var AdminTokenStatus = /* @__PURE__ */ ((
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return
|
|
485
|
+
var AdminTokenStatus = /* @__PURE__ */ ((AdminTokenStatus3) => {
|
|
486
|
+
AdminTokenStatus3["ACTIVE"] = "active";
|
|
487
|
+
AdminTokenStatus3["USED"] = "used";
|
|
488
|
+
AdminTokenStatus3["EXPIRED"] = "expired";
|
|
489
|
+
return AdminTokenStatus3;
|
|
491
490
|
})(AdminTokenStatus || {});
|
|
492
491
|
var SubscriptionModel = /* @__PURE__ */ ((SubscriptionModel2) => {
|
|
493
492
|
SubscriptionModel2["NO_SUBSCRIPTION"] = "no_subscription";
|
|
@@ -2005,7 +2004,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2005
2004
|
* @param limit - Number of top procedures to return
|
|
2006
2005
|
* @returns Array of procedure popularity metrics
|
|
2007
2006
|
*/
|
|
2008
|
-
async getProcedurePopularity(dateRange,
|
|
2007
|
+
async getProcedurePopularity(dateRange, limit23 = 10) {
|
|
2009
2008
|
const appointments = await this.fetchAppointments(void 0, dateRange);
|
|
2010
2009
|
const completed = getCompletedAppointments(appointments);
|
|
2011
2010
|
const procedureMap = /* @__PURE__ */ new Map();
|
|
@@ -2034,7 +2033,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2034
2033
|
completedCount: data.count,
|
|
2035
2034
|
rank: 0
|
|
2036
2035
|
// Will be set after sorting
|
|
2037
|
-
})).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0,
|
|
2036
|
+
})).sort((a, b) => b.appointmentCount - a.appointmentCount).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
|
|
2038
2037
|
}
|
|
2039
2038
|
/**
|
|
2040
2039
|
* Get procedure profitability metrics
|
|
@@ -2043,7 +2042,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2043
2042
|
* @param limit - Number of top procedures to return
|
|
2044
2043
|
* @returns Array of procedure profitability metrics
|
|
2045
2044
|
*/
|
|
2046
|
-
async getProcedureProfitability(dateRange,
|
|
2045
|
+
async getProcedureProfitability(dateRange, limit23 = 10) {
|
|
2047
2046
|
const appointments = await this.fetchAppointments(void 0, dateRange);
|
|
2048
2047
|
const completed = getCompletedAppointments(appointments);
|
|
2049
2048
|
const procedureMap = /* @__PURE__ */ new Map();
|
|
@@ -2077,7 +2076,7 @@ var AnalyticsService = class extends BaseService {
|
|
|
2077
2076
|
appointmentCount: data.count,
|
|
2078
2077
|
rank: 0
|
|
2079
2078
|
// Will be set after sorting
|
|
2080
|
-
})).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0,
|
|
2079
|
+
})).sort((a, b) => b.totalRevenue - a.totalRevenue).slice(0, limit23).map((item, index) => ({ ...item, rank: index + 1 }));
|
|
2081
2080
|
}
|
|
2082
2081
|
// ==========================================
|
|
2083
2082
|
// Time Efficiency Analytics
|
|
@@ -4666,6 +4665,9 @@ var ResourceStatus = /* @__PURE__ */ ((ResourceStatus2) => {
|
|
|
4666
4665
|
return ResourceStatus2;
|
|
4667
4666
|
})(ResourceStatus || {});
|
|
4668
4667
|
|
|
4668
|
+
// src/types/concern/index.ts
|
|
4669
|
+
var CONCERNS_COLLECTION = "concerns";
|
|
4670
|
+
|
|
4669
4671
|
// src/types/system/planConfig.types.ts
|
|
4670
4672
|
var PLAN_CONFIG_PATH = "system/planConfig";
|
|
4671
4673
|
var PLAN_CONFIG_HISTORY_PATH = "system/planConfig/history";
|
|
@@ -5602,6 +5604,8 @@ var clinicAdminSchema = z9.object({
|
|
|
5602
5604
|
clinicsManagedInfo: z9.array(clinicInfoSchema),
|
|
5603
5605
|
contactInfo: contactPersonSchema,
|
|
5604
5606
|
roleTitle: z9.string(),
|
|
5607
|
+
role: z9.nativeEnum(ClinicRole).optional(),
|
|
5608
|
+
permissions: z9.record(z9.string(), z9.boolean()).optional(),
|
|
5605
5609
|
createdAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7)),
|
|
5606
5610
|
updatedAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7)),
|
|
5607
5611
|
isActive: z9.boolean()
|
|
@@ -5612,10 +5616,9 @@ var adminTokenSchema = z9.object({
|
|
|
5612
5616
|
email: z9.string().email().optional().nullable(),
|
|
5613
5617
|
status: z9.nativeEnum(AdminTokenStatus),
|
|
5614
5618
|
usedByUserRef: z9.string().optional(),
|
|
5619
|
+
clinicGroupId: z9.string(),
|
|
5615
5620
|
createdAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7)),
|
|
5616
|
-
// Timestamp
|
|
5617
5621
|
expiresAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7))
|
|
5618
|
-
// Timestamp
|
|
5619
5622
|
});
|
|
5620
5623
|
var stripeTransactionDataSchema = z9.object({
|
|
5621
5624
|
sessionId: z9.string().optional(),
|
|
@@ -5676,7 +5679,7 @@ var clinicGroupSchema = z9.object({
|
|
|
5676
5679
|
clinicsInfo: z9.array(clinicInfoSchema),
|
|
5677
5680
|
admins: z9.array(z9.string()),
|
|
5678
5681
|
adminsInfo: z9.array(adminInfoSchema),
|
|
5679
|
-
adminTokens: z9.array(adminTokenSchema),
|
|
5682
|
+
adminTokens: z9.array(adminTokenSchema).optional(),
|
|
5680
5683
|
ownerId: z9.string().nullable(),
|
|
5681
5684
|
createdAt: z9.instanceof(Date).or(z9.instanceof(Timestamp7)),
|
|
5682
5685
|
// Timestamp
|
|
@@ -5738,6 +5741,8 @@ var createClinicAdminSchema = z9.object({
|
|
|
5738
5741
|
clinicsManaged: z9.array(z9.string()),
|
|
5739
5742
|
contactInfo: contactPersonSchema,
|
|
5740
5743
|
roleTitle: z9.string(),
|
|
5744
|
+
role: z9.nativeEnum(ClinicRole).optional(),
|
|
5745
|
+
permissions: z9.record(z9.string(), z9.boolean()).optional(),
|
|
5741
5746
|
isActive: z9.boolean()
|
|
5742
5747
|
// clinicsManagedInfo is aggregated, not provided on creation
|
|
5743
5748
|
});
|
|
@@ -9743,9 +9748,6 @@ import {
|
|
|
9743
9748
|
OAuthProvider
|
|
9744
9749
|
} from "firebase/auth";
|
|
9745
9750
|
import {
|
|
9746
|
-
collection as collection22,
|
|
9747
|
-
query as query22,
|
|
9748
|
-
getDocs as getDocs22,
|
|
9749
9751
|
runTransaction
|
|
9750
9752
|
} from "firebase/firestore";
|
|
9751
9753
|
import { z as z28 } from "zod";
|
|
@@ -12868,32 +12870,6 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12868
12870
|
"settings.manage": true,
|
|
12869
12871
|
"billing.manage": false
|
|
12870
12872
|
},
|
|
12871
|
-
["doctor" /* DOCTOR */]: {
|
|
12872
|
-
"clinic.view": true,
|
|
12873
|
-
"clinic.edit": false,
|
|
12874
|
-
"reviews.view": true,
|
|
12875
|
-
"calendar.view": true,
|
|
12876
|
-
"appointments.view": true,
|
|
12877
|
-
"appointments.confirm": true,
|
|
12878
|
-
"appointments.cancel": true,
|
|
12879
|
-
"messaging": true,
|
|
12880
|
-
"procedures.view": true,
|
|
12881
|
-
"procedures.create": false,
|
|
12882
|
-
"procedures.edit": false,
|
|
12883
|
-
"procedures.delete": false,
|
|
12884
|
-
"resources.view": true,
|
|
12885
|
-
"resources.create": false,
|
|
12886
|
-
"resources.edit": false,
|
|
12887
|
-
"resources.delete": false,
|
|
12888
|
-
"patients.view": true,
|
|
12889
|
-
"patients.edit": true,
|
|
12890
|
-
"providers.view": true,
|
|
12891
|
-
"providers.manage": false,
|
|
12892
|
-
"analytics.view": true,
|
|
12893
|
-
"staff.manage": false,
|
|
12894
|
-
"settings.manage": false,
|
|
12895
|
-
"billing.manage": false
|
|
12896
|
-
},
|
|
12897
12873
|
["receptionist" /* RECEPTIONIST */]: {
|
|
12898
12874
|
"clinic.view": true,
|
|
12899
12875
|
"clinic.edit": false,
|
|
@@ -15617,13 +15593,16 @@ var BillingTransactionsService = class extends BaseService {
|
|
|
15617
15593
|
// src/services/clinic/utils/clinic-group.utils.ts
|
|
15618
15594
|
import {
|
|
15619
15595
|
collection as collection17,
|
|
15596
|
+
collectionGroup as collectionGroup2,
|
|
15620
15597
|
doc as doc28,
|
|
15621
15598
|
getDoc as getDoc30,
|
|
15622
15599
|
getDocs as getDocs17,
|
|
15623
15600
|
query as query17,
|
|
15624
15601
|
where as where17,
|
|
15602
|
+
limit as limit9,
|
|
15625
15603
|
updateDoc as updateDoc24,
|
|
15626
15604
|
setDoc as setDoc17,
|
|
15605
|
+
deleteDoc as deleteDoc6,
|
|
15627
15606
|
Timestamp as Timestamp20
|
|
15628
15607
|
} from "firebase/firestore";
|
|
15629
15608
|
import { geohashForLocation as geohashForLocation2 } from "geofire-common";
|
|
@@ -15779,6 +15758,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
15779
15758
|
admins: [ownerId],
|
|
15780
15759
|
adminsInfo: [],
|
|
15781
15760
|
adminTokens: [],
|
|
15761
|
+
// @deprecated — tokens now in subcollection, kept for backward compat
|
|
15782
15762
|
ownerId,
|
|
15783
15763
|
createdAt: now,
|
|
15784
15764
|
updatedAt: now,
|
|
@@ -15963,6 +15943,10 @@ async function deactivateClinicGroup(db, groupId, app) {
|
|
|
15963
15943
|
app
|
|
15964
15944
|
);
|
|
15965
15945
|
}
|
|
15946
|
+
var ADMIN_TOKENS_SUBCOLLECTION = "adminTokens";
|
|
15947
|
+
function adminTokensRef(db, groupId) {
|
|
15948
|
+
return collection17(db, CLINIC_GROUPS_COLLECTION, groupId, ADMIN_TOKENS_SUBCOLLECTION);
|
|
15949
|
+
}
|
|
15966
15950
|
async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
15967
15951
|
const group = await getClinicGroup(db, groupId);
|
|
15968
15952
|
if (!group) {
|
|
@@ -15978,68 +15962,60 @@ async function createAdminToken(db, groupId, creatorAdminId, app, data) {
|
|
|
15978
15962
|
now.seconds + expiresInDays * 24 * 60 * 60,
|
|
15979
15963
|
now.nanoseconds
|
|
15980
15964
|
);
|
|
15965
|
+
const tokenRef = doc28(adminTokensRef(db, groupId));
|
|
15981
15966
|
const token = {
|
|
15982
|
-
id:
|
|
15967
|
+
id: tokenRef.id,
|
|
15983
15968
|
token: generateId(),
|
|
15984
15969
|
status: "active" /* ACTIVE */,
|
|
15985
15970
|
email,
|
|
15971
|
+
clinicGroupId: groupId,
|
|
15986
15972
|
createdAt: now,
|
|
15987
15973
|
expiresAt
|
|
15988
15974
|
};
|
|
15989
|
-
await
|
|
15990
|
-
db,
|
|
15991
|
-
groupId,
|
|
15992
|
-
{
|
|
15993
|
-
adminTokens: [...group.adminTokens, token]
|
|
15994
|
-
},
|
|
15995
|
-
app
|
|
15996
|
-
);
|
|
15975
|
+
await setDoc17(tokenRef, token);
|
|
15997
15976
|
return token;
|
|
15998
15977
|
}
|
|
15999
|
-
async function verifyAndUseAdminToken(db, groupId,
|
|
16000
|
-
const
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
15978
|
+
async function verifyAndUseAdminToken(db, groupId, tokenValue, userRef, app) {
|
|
15979
|
+
const tokensQuery = query17(
|
|
15980
|
+
adminTokensRef(db, groupId),
|
|
15981
|
+
where17("token", "==", tokenValue),
|
|
15982
|
+
limit9(1)
|
|
15983
|
+
);
|
|
15984
|
+
const snapshot = await getDocs17(tokensQuery);
|
|
15985
|
+
if (snapshot.empty) {
|
|
16006
15986
|
throw new Error("Admin token not found");
|
|
16007
15987
|
}
|
|
15988
|
+
const tokenDoc = snapshot.docs[0];
|
|
15989
|
+
const adminToken = tokenDoc.data();
|
|
16008
15990
|
if (adminToken.status !== "active" /* ACTIVE */) {
|
|
16009
15991
|
throw new Error("Admin token is not active");
|
|
16010
15992
|
}
|
|
16011
15993
|
const now = Timestamp20.now();
|
|
16012
15994
|
if (adminToken.expiresAt.seconds < now.seconds) {
|
|
16013
|
-
|
|
16014
|
-
(t) => t.id === adminToken.id ? { ...t, status: "expired" /* EXPIRED */ } : t
|
|
16015
|
-
);
|
|
16016
|
-
await updateClinicGroup(
|
|
16017
|
-
db,
|
|
16018
|
-
groupId,
|
|
16019
|
-
{
|
|
16020
|
-
adminTokens: updatedTokens2
|
|
16021
|
-
},
|
|
16022
|
-
app
|
|
16023
|
-
);
|
|
15995
|
+
await updateDoc24(tokenDoc.ref, { status: "expired" /* EXPIRED */ });
|
|
16024
15996
|
throw new Error("Admin token has expired");
|
|
16025
15997
|
}
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
usedByUserRef: userRef
|
|
16031
|
-
} : t
|
|
16032
|
-
);
|
|
16033
|
-
await updateClinicGroup(
|
|
16034
|
-
db,
|
|
16035
|
-
groupId,
|
|
16036
|
-
{
|
|
16037
|
-
adminTokens: updatedTokens
|
|
16038
|
-
},
|
|
16039
|
-
app
|
|
16040
|
-
);
|
|
15998
|
+
await updateDoc24(tokenDoc.ref, {
|
|
15999
|
+
status: "used" /* USED */,
|
|
16000
|
+
usedByUserRef: userRef
|
|
16001
|
+
});
|
|
16041
16002
|
return true;
|
|
16042
16003
|
}
|
|
16004
|
+
async function findAdminTokenByValue(db, tokenValue) {
|
|
16005
|
+
const tokensQuery = query17(
|
|
16006
|
+
collectionGroup2(db, ADMIN_TOKENS_SUBCOLLECTION),
|
|
16007
|
+
where17("token", "==", tokenValue),
|
|
16008
|
+
where17("status", "==", "active" /* ACTIVE */),
|
|
16009
|
+
limit9(1)
|
|
16010
|
+
);
|
|
16011
|
+
const snapshot = await getDocs17(tokensQuery);
|
|
16012
|
+
if (snapshot.empty) return null;
|
|
16013
|
+
const tokenData = snapshot.docs[0].data();
|
|
16014
|
+
return {
|
|
16015
|
+
token: tokenData,
|
|
16016
|
+
clinicGroupId: tokenData.clinicGroupId
|
|
16017
|
+
};
|
|
16018
|
+
}
|
|
16043
16019
|
async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
|
|
16044
16020
|
const group = await getClinicGroup(db, groupId);
|
|
16045
16021
|
if (!group) {
|
|
@@ -16048,15 +16024,7 @@ async function deleteAdminToken(db, groupId, tokenId, adminId, app) {
|
|
|
16048
16024
|
if (!group.admins.includes(adminId)) {
|
|
16049
16025
|
throw new Error("Admin does not belong to this clinic group");
|
|
16050
16026
|
}
|
|
16051
|
-
|
|
16052
|
-
await updateClinicGroup(
|
|
16053
|
-
db,
|
|
16054
|
-
groupId,
|
|
16055
|
-
{
|
|
16056
|
-
adminTokens: updatedTokens
|
|
16057
|
-
},
|
|
16058
|
-
app
|
|
16059
|
-
);
|
|
16027
|
+
await deleteDoc6(doc28(adminTokensRef(db, groupId), tokenId));
|
|
16060
16028
|
}
|
|
16061
16029
|
async function getActiveAdminTokens(db, groupId, adminId, app) {
|
|
16062
16030
|
const group = await getClinicGroup(db, groupId);
|
|
@@ -16066,7 +16034,23 @@ async function getActiveAdminTokens(db, groupId, adminId, app) {
|
|
|
16066
16034
|
if (!group.admins.includes(adminId)) {
|
|
16067
16035
|
throw new Error("Admin does not belong to this clinic group");
|
|
16068
16036
|
}
|
|
16069
|
-
|
|
16037
|
+
const tokensQuery = query17(
|
|
16038
|
+
adminTokensRef(db, groupId),
|
|
16039
|
+
where17("status", "==", "active" /* ACTIVE */)
|
|
16040
|
+
);
|
|
16041
|
+
const snapshot = await getDocs17(tokensQuery);
|
|
16042
|
+
return snapshot.docs.map((d) => d.data());
|
|
16043
|
+
}
|
|
16044
|
+
async function getAllAdminTokens(db, groupId, adminId, app) {
|
|
16045
|
+
const group = await getClinicGroup(db, groupId);
|
|
16046
|
+
if (!group) {
|
|
16047
|
+
throw new Error("Clinic group not found");
|
|
16048
|
+
}
|
|
16049
|
+
if (!group.admins.includes(adminId)) {
|
|
16050
|
+
throw new Error("Admin does not belong to this clinic group");
|
|
16051
|
+
}
|
|
16052
|
+
const snapshot = await getDocs17(adminTokensRef(db, groupId));
|
|
16053
|
+
return snapshot.docs.map((d) => d.data());
|
|
16070
16054
|
}
|
|
16071
16055
|
|
|
16072
16056
|
// src/services/clinic/clinic-group.service.ts
|
|
@@ -16196,11 +16180,19 @@ var ClinicGroupService = class extends BaseService {
|
|
|
16196
16180
|
async getActiveAdminTokens(groupId, adminId) {
|
|
16197
16181
|
return getActiveAdminTokens(this.db, groupId, adminId, this.app);
|
|
16198
16182
|
}
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16183
|
+
/**
|
|
16184
|
+
* Gets ALL admin tokens for a clinic group (all statuses)
|
|
16185
|
+
*/
|
|
16186
|
+
async getAllAdminTokens(groupId, adminId) {
|
|
16187
|
+
return getAllAdminTokens(this.db, groupId, adminId, this.app);
|
|
16188
|
+
}
|
|
16189
|
+
/**
|
|
16190
|
+
* Finds an admin token by its value across all clinic groups.
|
|
16191
|
+
* Uses a collection group query for O(1) lookup.
|
|
16192
|
+
*/
|
|
16193
|
+
async findAdminTokenByValue(tokenValue) {
|
|
16194
|
+
return findAdminTokenByValue(this.db, tokenValue);
|
|
16195
|
+
}
|
|
16204
16196
|
/**
|
|
16205
16197
|
* Updates the onboarding status for a clinic group
|
|
16206
16198
|
*
|
|
@@ -16298,7 +16290,7 @@ import {
|
|
|
16298
16290
|
updateDoc as updateDoc25,
|
|
16299
16291
|
setDoc as setDoc18,
|
|
16300
16292
|
Timestamp as Timestamp21,
|
|
16301
|
-
limit as
|
|
16293
|
+
limit as limit10,
|
|
16302
16294
|
startAfter as startAfter8
|
|
16303
16295
|
} from "firebase/firestore";
|
|
16304
16296
|
import {
|
|
@@ -16587,10 +16579,10 @@ async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners
|
|
|
16587
16579
|
clinicsQuery = query18(
|
|
16588
16580
|
clinicsCollection,
|
|
16589
16581
|
startAfter8(lastDoc),
|
|
16590
|
-
|
|
16582
|
+
limit10(pagination)
|
|
16591
16583
|
);
|
|
16592
16584
|
} else {
|
|
16593
|
-
clinicsQuery = query18(clinicsCollection,
|
|
16585
|
+
clinicsQuery = query18(clinicsCollection, limit10(pagination));
|
|
16594
16586
|
}
|
|
16595
16587
|
}
|
|
16596
16588
|
const clinicsSnapshot = await getDocs18(clinicsQuery);
|
|
@@ -16783,8 +16775,8 @@ import {
|
|
|
16783
16775
|
where as where20,
|
|
16784
16776
|
getDocs as getDocs20,
|
|
16785
16777
|
startAfter as startAfter9,
|
|
16786
|
-
limit as
|
|
16787
|
-
orderBy as
|
|
16778
|
+
limit as limit11,
|
|
16779
|
+
orderBy as orderBy7
|
|
16788
16780
|
} from "firebase/firestore";
|
|
16789
16781
|
import { geohashQueryBounds as geohashQueryBounds3, distanceBetween as distanceBetween4 } from "geofire-common";
|
|
16790
16782
|
async function getClinicsByFilters(db, filters) {
|
|
@@ -16871,7 +16863,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16871
16863
|
const constraints = getBaseConstraints();
|
|
16872
16864
|
constraints.push(where20("nameLower", ">=", searchTerm));
|
|
16873
16865
|
constraints.push(where20("nameLower", "<=", searchTerm + "\uF8FF"));
|
|
16874
|
-
constraints.push(
|
|
16866
|
+
constraints.push(orderBy7("nameLower"));
|
|
16875
16867
|
if (filters.lastDoc) {
|
|
16876
16868
|
if (typeof filters.lastDoc.data === "function") {
|
|
16877
16869
|
constraints.push(startAfter9(filters.lastDoc));
|
|
@@ -16881,7 +16873,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16881
16873
|
constraints.push(startAfter9(filters.lastDoc));
|
|
16882
16874
|
}
|
|
16883
16875
|
}
|
|
16884
|
-
constraints.push(
|
|
16876
|
+
constraints.push(limit11(filters.pagination || 5));
|
|
16885
16877
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16886
16878
|
const querySnapshot = await getDocs20(q);
|
|
16887
16879
|
let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
|
|
@@ -16906,7 +16898,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16906
16898
|
const constraints = getBaseConstraints();
|
|
16907
16899
|
constraints.push(where20("name", ">=", searchTerm));
|
|
16908
16900
|
constraints.push(where20("name", "<=", searchTerm + "\uF8FF"));
|
|
16909
|
-
constraints.push(
|
|
16901
|
+
constraints.push(orderBy7("name"));
|
|
16910
16902
|
if (filters.lastDoc) {
|
|
16911
16903
|
if (typeof filters.lastDoc.data === "function") {
|
|
16912
16904
|
constraints.push(startAfter9(filters.lastDoc));
|
|
@@ -16916,7 +16908,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16916
16908
|
constraints.push(startAfter9(filters.lastDoc));
|
|
16917
16909
|
}
|
|
16918
16910
|
}
|
|
16919
|
-
constraints.push(
|
|
16911
|
+
constraints.push(limit11(filters.pagination || 5));
|
|
16920
16912
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16921
16913
|
const querySnapshot = await getDocs20(q);
|
|
16922
16914
|
let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
|
|
@@ -16939,7 +16931,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16939
16931
|
"[CLINIC_SERVICE] Strategy 3: Using createdAt ordering with client-side filtering"
|
|
16940
16932
|
);
|
|
16941
16933
|
const constraints = getBaseConstraints();
|
|
16942
|
-
constraints.push(
|
|
16934
|
+
constraints.push(orderBy7("createdAt", "desc"));
|
|
16943
16935
|
if (filters.lastDoc) {
|
|
16944
16936
|
if (typeof filters.lastDoc.data === "function") {
|
|
16945
16937
|
constraints.push(startAfter9(filters.lastDoc));
|
|
@@ -16949,7 +16941,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16949
16941
|
constraints.push(startAfter9(filters.lastDoc));
|
|
16950
16942
|
}
|
|
16951
16943
|
}
|
|
16952
|
-
constraints.push(
|
|
16944
|
+
constraints.push(limit11(filters.pagination || 5));
|
|
16953
16945
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16954
16946
|
const querySnapshot = await getDocs20(q);
|
|
16955
16947
|
let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
|
|
@@ -16967,8 +16959,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16967
16959
|
console.log("[CLINIC_SERVICE] Strategy 4: Minimal fallback");
|
|
16968
16960
|
const constraints = [
|
|
16969
16961
|
where20("isActive", "==", true),
|
|
16970
|
-
|
|
16971
|
-
|
|
16962
|
+
orderBy7("createdAt", "desc"),
|
|
16963
|
+
limit11(filters.pagination || 5)
|
|
16972
16964
|
];
|
|
16973
16965
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16974
16966
|
const querySnapshot = await getDocs20(q);
|
|
@@ -17894,46 +17886,20 @@ var AuthService = class extends BaseService {
|
|
|
17894
17886
|
console.log("[AUTH] Invite token provided", {
|
|
17895
17887
|
token: data.inviteToken
|
|
17896
17888
|
});
|
|
17897
|
-
console.log("[AUTH] Searching for token
|
|
17898
|
-
const
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
let foundGroup = null;
|
|
17902
|
-
let foundToken = null;
|
|
17903
|
-
console.log("[AUTH] Found", querySnapshot.size, "clinic groups to check");
|
|
17904
|
-
for (const docSnapshot of querySnapshot.docs) {
|
|
17905
|
-
const group = docSnapshot.data();
|
|
17906
|
-
console.log("[AUTH] Checking group", {
|
|
17907
|
-
groupId: group.id,
|
|
17908
|
-
groupName: group.name
|
|
17909
|
-
});
|
|
17910
|
-
const token = group.adminTokens.find((t) => {
|
|
17911
|
-
const isMatch = t.token === data.inviteToken && t.status === "active" /* ACTIVE */ && new Date(t.expiresAt.toDate()) > /* @__PURE__ */ new Date();
|
|
17912
|
-
console.log("[AUTH] Checking token", {
|
|
17913
|
-
tokenId: t.id,
|
|
17914
|
-
tokenMatch: t.token === data.inviteToken,
|
|
17915
|
-
tokenStatus: t.status,
|
|
17916
|
-
tokenActive: t.status === "active" /* ACTIVE */,
|
|
17917
|
-
tokenExpiry: new Date(t.expiresAt.toDate()),
|
|
17918
|
-
tokenExpired: new Date(t.expiresAt.toDate()) <= /* @__PURE__ */ new Date(),
|
|
17919
|
-
isMatch
|
|
17920
|
-
});
|
|
17921
|
-
return isMatch;
|
|
17922
|
-
});
|
|
17923
|
-
if (token) {
|
|
17924
|
-
foundGroup = group;
|
|
17925
|
-
foundToken = token;
|
|
17926
|
-
console.log("[AUTH] Found matching token in group", {
|
|
17927
|
-
groupId: group.id,
|
|
17928
|
-
tokenId: token.id
|
|
17929
|
-
});
|
|
17930
|
-
break;
|
|
17931
|
-
}
|
|
17932
|
-
}
|
|
17933
|
-
if (!foundGroup || !foundToken) {
|
|
17934
|
-
console.error("[AUTH] No valid token found in any clinic group");
|
|
17889
|
+
console.log("[AUTH] Searching for token via collection group query");
|
|
17890
|
+
const tokenResult = await clinicGroupService.findAdminTokenByValue(data.inviteToken);
|
|
17891
|
+
if (!tokenResult) {
|
|
17892
|
+
console.error("[AUTH] No valid active token found");
|
|
17935
17893
|
throw new Error("Invalid or expired invite token");
|
|
17936
17894
|
}
|
|
17895
|
+
console.log("[AUTH] Found matching token", {
|
|
17896
|
+
tokenId: tokenResult.token.id,
|
|
17897
|
+
clinicGroupId: tokenResult.clinicGroupId
|
|
17898
|
+
});
|
|
17899
|
+
const foundGroup = await clinicGroupService.getClinicGroup(tokenResult.clinicGroupId);
|
|
17900
|
+
if (!foundGroup) {
|
|
17901
|
+
throw new Error("Clinic group not found for token");
|
|
17902
|
+
}
|
|
17937
17903
|
clinicGroup = foundGroup;
|
|
17938
17904
|
console.log("[AUTH] Creating clinic admin");
|
|
17939
17905
|
const createClinicAdminData = {
|
|
@@ -18763,7 +18729,7 @@ import {
|
|
|
18763
18729
|
deleteDoc as deleteDoc10,
|
|
18764
18730
|
query as query23,
|
|
18765
18731
|
where as where23,
|
|
18766
|
-
orderBy as
|
|
18732
|
+
orderBy as orderBy9,
|
|
18767
18733
|
Timestamp as Timestamp24,
|
|
18768
18734
|
serverTimestamp as serverTimestamp25
|
|
18769
18735
|
} from "firebase/firestore";
|
|
@@ -18867,7 +18833,7 @@ import {
|
|
|
18867
18833
|
deleteDoc as deleteDoc11,
|
|
18868
18834
|
query as query24,
|
|
18869
18835
|
where as where24,
|
|
18870
|
-
orderBy as
|
|
18836
|
+
orderBy as orderBy10,
|
|
18871
18837
|
Timestamp as Timestamp25,
|
|
18872
18838
|
serverTimestamp as serverTimestamp26
|
|
18873
18839
|
} from "firebase/firestore";
|
|
@@ -18911,7 +18877,7 @@ import {
|
|
|
18911
18877
|
deleteDoc as deleteDoc12,
|
|
18912
18878
|
query as query25,
|
|
18913
18879
|
where as where25,
|
|
18914
|
-
orderBy as
|
|
18880
|
+
orderBy as orderBy11,
|
|
18915
18881
|
Timestamp as Timestamp26,
|
|
18916
18882
|
serverTimestamp as serverTimestamp27
|
|
18917
18883
|
} from "firebase/firestore";
|
|
@@ -19014,7 +18980,7 @@ import {
|
|
|
19014
18980
|
deleteDoc as deleteDoc13,
|
|
19015
18981
|
query as query26,
|
|
19016
18982
|
where as where26,
|
|
19017
|
-
orderBy as
|
|
18983
|
+
orderBy as orderBy12,
|
|
19018
18984
|
Timestamp as Timestamp27,
|
|
19019
18985
|
serverTimestamp as serverTimestamp28
|
|
19020
18986
|
} from "firebase/firestore";
|
|
@@ -19141,7 +19107,7 @@ import {
|
|
|
19141
19107
|
updateDoc as updateDoc32,
|
|
19142
19108
|
deleteDoc as deleteDoc14,
|
|
19143
19109
|
query as query27,
|
|
19144
|
-
orderBy as
|
|
19110
|
+
orderBy as orderBy13,
|
|
19145
19111
|
Timestamp as Timestamp28,
|
|
19146
19112
|
serverTimestamp as serverTimestamp29
|
|
19147
19113
|
} from "firebase/firestore";
|
|
@@ -19214,7 +19180,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
19214
19180
|
db,
|
|
19215
19181
|
`practitioners/${practitionerId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
19216
19182
|
);
|
|
19217
|
-
const q = query27(calendarsRef,
|
|
19183
|
+
const q = query27(calendarsRef, orderBy13("createdAt", "desc"));
|
|
19218
19184
|
const querySnapshot = await getDocs27(q);
|
|
19219
19185
|
return querySnapshot.docs.map((doc54) => doc54.data());
|
|
19220
19186
|
}
|
|
@@ -19231,7 +19197,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
19231
19197
|
db,
|
|
19232
19198
|
`patients/${patientId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
19233
19199
|
);
|
|
19234
|
-
const q = query27(calendarsRef,
|
|
19200
|
+
const q = query27(calendarsRef, orderBy13("createdAt", "desc"));
|
|
19235
19201
|
const querySnapshot = await getDocs27(q);
|
|
19236
19202
|
return querySnapshot.docs.map((doc54) => doc54.data());
|
|
19237
19203
|
}
|
|
@@ -19248,7 +19214,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
19248
19214
|
db,
|
|
19249
19215
|
`clinics/${clinicId}/${SYNCED_CALENDARS_COLLECTION}`
|
|
19250
19216
|
);
|
|
19251
|
-
const q = query27(calendarsRef,
|
|
19217
|
+
const q = query27(calendarsRef, orderBy13("createdAt", "desc"));
|
|
19252
19218
|
const querySnapshot = await getDocs27(q);
|
|
19253
19219
|
return querySnapshot.docs.map((doc54) => doc54.data());
|
|
19254
19220
|
}
|
|
@@ -21690,8 +21656,8 @@ import {
|
|
|
21690
21656
|
deleteDoc as deleteDoc16,
|
|
21691
21657
|
Timestamp as Timestamp32,
|
|
21692
21658
|
serverTimestamp as serverTimestamp32,
|
|
21693
|
-
orderBy as
|
|
21694
|
-
limit as
|
|
21659
|
+
orderBy as orderBy14,
|
|
21660
|
+
limit as limit13
|
|
21695
21661
|
} from "firebase/firestore";
|
|
21696
21662
|
var PractitionerInviteService = class extends BaseService {
|
|
21697
21663
|
constructor(db, auth, app) {
|
|
@@ -21786,7 +21752,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21786
21752
|
try {
|
|
21787
21753
|
const constraints = [
|
|
21788
21754
|
where29("practitionerId", "==", practitionerId),
|
|
21789
|
-
|
|
21755
|
+
orderBy14("createdAt", "desc")
|
|
21790
21756
|
];
|
|
21791
21757
|
if (statusFilter && statusFilter.length > 0) {
|
|
21792
21758
|
constraints.push(where29("status", "in", statusFilter));
|
|
@@ -21815,7 +21781,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21815
21781
|
try {
|
|
21816
21782
|
const constraints = [
|
|
21817
21783
|
where29("clinicId", "==", clinicId),
|
|
21818
|
-
|
|
21784
|
+
orderBy14("createdAt", "desc")
|
|
21819
21785
|
];
|
|
21820
21786
|
if (statusFilter && statusFilter.length > 0) {
|
|
21821
21787
|
constraints.push(where29("status", "in", statusFilter));
|
|
@@ -21971,9 +21937,9 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21971
21937
|
}
|
|
21972
21938
|
const orderField = filters.orderBy || "createdAt";
|
|
21973
21939
|
const orderDirection = filters.orderDirection || "desc";
|
|
21974
|
-
constraints.push(
|
|
21940
|
+
constraints.push(orderBy14(orderField, orderDirection));
|
|
21975
21941
|
if (filters.limit) {
|
|
21976
|
-
constraints.push(
|
|
21942
|
+
constraints.push(limit13(filters.limit));
|
|
21977
21943
|
}
|
|
21978
21944
|
const q = query29(
|
|
21979
21945
|
collection29(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
@@ -22064,8 +22030,8 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
22064
22030
|
collection29(this.db, PRACTITIONER_INVITES_COLLECTION),
|
|
22065
22031
|
where29("practitionerId", "==", practitionerId),
|
|
22066
22032
|
where29("clinicId", "==", clinicId),
|
|
22067
|
-
|
|
22068
|
-
|
|
22033
|
+
orderBy14("createdAt", "desc"),
|
|
22034
|
+
limit13(1)
|
|
22069
22035
|
);
|
|
22070
22036
|
const querySnapshot = await getDocs29(q);
|
|
22071
22037
|
if (querySnapshot.empty) {
|
|
@@ -22093,8 +22059,8 @@ import {
|
|
|
22093
22059
|
deleteDoc as deleteDoc17,
|
|
22094
22060
|
query as query30,
|
|
22095
22061
|
where as where30,
|
|
22096
|
-
orderBy as
|
|
22097
|
-
limit as
|
|
22062
|
+
orderBy as orderBy15,
|
|
22063
|
+
limit as limit14,
|
|
22098
22064
|
startAfter as startAfter11
|
|
22099
22065
|
} from "firebase/firestore";
|
|
22100
22066
|
import { getCountFromServer as getCountFromServer2 } from "firebase/firestore";
|
|
@@ -22249,7 +22215,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22249
22215
|
this.db,
|
|
22250
22216
|
`${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions`
|
|
22251
22217
|
);
|
|
22252
|
-
const q = query30(versionsCollectionRef,
|
|
22218
|
+
const q = query30(versionsCollectionRef, orderBy15("version", "desc"));
|
|
22253
22219
|
const querySnapshot = await getDocs30(q);
|
|
22254
22220
|
const versions = [];
|
|
22255
22221
|
querySnapshot.forEach((doc54) => {
|
|
@@ -22275,8 +22241,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22275
22241
|
let q = query30(
|
|
22276
22242
|
this.collectionRef,
|
|
22277
22243
|
where30("isActive", "==", true),
|
|
22278
|
-
|
|
22279
|
-
|
|
22244
|
+
orderBy15("updatedAt", "desc"),
|
|
22245
|
+
limit14(pageSize)
|
|
22280
22246
|
);
|
|
22281
22247
|
if (lastDoc) {
|
|
22282
22248
|
q = query30(q, startAfter11(lastDoc));
|
|
@@ -22308,9 +22274,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22308
22274
|
} = options;
|
|
22309
22275
|
const constraints = [
|
|
22310
22276
|
where30("isActive", "==", true),
|
|
22311
|
-
|
|
22312
|
-
|
|
22313
|
-
|
|
22277
|
+
orderBy15("sortingOrder", "asc"),
|
|
22278
|
+
orderBy15("title", "asc"),
|
|
22279
|
+
limit14(pageSize)
|
|
22314
22280
|
];
|
|
22315
22281
|
if (isUserForm !== void 0) {
|
|
22316
22282
|
constraints.push(where30("isUserForm", "==", isUserForm));
|
|
@@ -22366,7 +22332,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22366
22332
|
const q = query30(
|
|
22367
22333
|
this.collectionRef,
|
|
22368
22334
|
where30("isActive", "==", true),
|
|
22369
|
-
|
|
22335
|
+
orderBy15("title", "asc")
|
|
22370
22336
|
);
|
|
22371
22337
|
const querySnapshot = await getDocs30(q);
|
|
22372
22338
|
const templates = [];
|
|
@@ -22387,8 +22353,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22387
22353
|
this.collectionRef,
|
|
22388
22354
|
where30("isActive", "==", true),
|
|
22389
22355
|
where30("tags", "array-contains-any", tags),
|
|
22390
|
-
|
|
22391
|
-
|
|
22356
|
+
orderBy15("updatedAt", "desc"),
|
|
22357
|
+
limit14(pageSize)
|
|
22392
22358
|
);
|
|
22393
22359
|
if (lastDoc) {
|
|
22394
22360
|
q = query30(q, startAfter11(lastDoc));
|
|
@@ -22416,8 +22382,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22416
22382
|
let q = query30(
|
|
22417
22383
|
this.collectionRef,
|
|
22418
22384
|
where30("createdBy", "==", userId),
|
|
22419
|
-
|
|
22420
|
-
|
|
22385
|
+
orderBy15("updatedAt", "desc"),
|
|
22386
|
+
limit14(pageSize)
|
|
22421
22387
|
);
|
|
22422
22388
|
if (lastDoc) {
|
|
22423
22389
|
q = query30(q, startAfter11(lastDoc));
|
|
@@ -22443,7 +22409,7 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22443
22409
|
let q = query30(
|
|
22444
22410
|
this.collectionRef,
|
|
22445
22411
|
where30("isActive", "==", true),
|
|
22446
|
-
|
|
22412
|
+
orderBy15("updatedAt", "desc")
|
|
22447
22413
|
);
|
|
22448
22414
|
if ((options == null ? void 0 : options.isUserForm) !== void 0) {
|
|
22449
22415
|
q = query30(q, where30("isUserForm", "==", options.isUserForm));
|
|
@@ -22469,8 +22435,8 @@ import {
|
|
|
22469
22435
|
setDoc as setDoc30,
|
|
22470
22436
|
updateDoc as updateDoc37,
|
|
22471
22437
|
query as query31,
|
|
22472
|
-
orderBy as
|
|
22473
|
-
limit as
|
|
22438
|
+
orderBy as orderBy16,
|
|
22439
|
+
limit as limit15,
|
|
22474
22440
|
startAfter as startAfter12
|
|
22475
22441
|
} from "firebase/firestore";
|
|
22476
22442
|
var FilledDocumentService = class extends BaseService {
|
|
@@ -22627,8 +22593,8 @@ var FilledDocumentService = class extends BaseService {
|
|
|
22627
22593
|
);
|
|
22628
22594
|
let q = query31(
|
|
22629
22595
|
subcollectionRef,
|
|
22630
|
-
|
|
22631
|
-
|
|
22596
|
+
orderBy16("updatedAt", "desc"),
|
|
22597
|
+
limit15(pageSize)
|
|
22632
22598
|
);
|
|
22633
22599
|
if (lastDoc) {
|
|
22634
22600
|
q = query31(q, startAfter12(lastDoc));
|
|
@@ -22651,8 +22617,8 @@ var FilledDocumentService = class extends BaseService {
|
|
|
22651
22617
|
);
|
|
22652
22618
|
let q = query31(
|
|
22653
22619
|
subcollectionRef,
|
|
22654
|
-
|
|
22655
|
-
|
|
22620
|
+
orderBy16("updatedAt", "desc"),
|
|
22621
|
+
limit15(pageSize)
|
|
22656
22622
|
);
|
|
22657
22623
|
if (lastDoc) {
|
|
22658
22624
|
q = query31(q, startAfter12(lastDoc));
|
|
@@ -22838,7 +22804,7 @@ import {
|
|
|
22838
22804
|
where as where32,
|
|
22839
22805
|
updateDoc as updateDoc38,
|
|
22840
22806
|
deleteDoc as deleteDoc18,
|
|
22841
|
-
orderBy as
|
|
22807
|
+
orderBy as orderBy17,
|
|
22842
22808
|
Timestamp as Timestamp34,
|
|
22843
22809
|
addDoc as addDoc3,
|
|
22844
22810
|
writeBatch as writeBatch5
|
|
@@ -22889,7 +22855,7 @@ var NotificationService = class extends BaseService {
|
|
|
22889
22855
|
const q = query32(
|
|
22890
22856
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22891
22857
|
where32("userId", "==", userId),
|
|
22892
|
-
|
|
22858
|
+
orderBy17("notificationTime", "desc")
|
|
22893
22859
|
);
|
|
22894
22860
|
const querySnapshot = await getDocs32(q);
|
|
22895
22861
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22905,7 +22871,7 @@ var NotificationService = class extends BaseService {
|
|
|
22905
22871
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22906
22872
|
where32("userId", "==", userId),
|
|
22907
22873
|
where32("isRead", "==", false),
|
|
22908
|
-
|
|
22874
|
+
orderBy17("notificationTime", "desc")
|
|
22909
22875
|
);
|
|
22910
22876
|
const querySnapshot = await getDocs32(q);
|
|
22911
22877
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22979,7 +22945,7 @@ var NotificationService = class extends BaseService {
|
|
|
22979
22945
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22980
22946
|
where32("userId", "==", userId),
|
|
22981
22947
|
where32("notificationType", "==", type),
|
|
22982
|
-
|
|
22948
|
+
orderBy17("notificationTime", "desc")
|
|
22983
22949
|
);
|
|
22984
22950
|
const querySnapshot = await getDocs32(q);
|
|
22985
22951
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -22994,7 +22960,7 @@ var NotificationService = class extends BaseService {
|
|
|
22994
22960
|
const q = query32(
|
|
22995
22961
|
collection32(this.db, NOTIFICATIONS_COLLECTION),
|
|
22996
22962
|
where32("appointmentId", "==", appointmentId),
|
|
22997
|
-
|
|
22963
|
+
orderBy17("notificationTime", "desc")
|
|
22998
22964
|
);
|
|
22999
22965
|
const querySnapshot = await getDocs32(q);
|
|
23000
22966
|
return querySnapshot.docs.map((doc54) => ({
|
|
@@ -23013,8 +22979,8 @@ import {
|
|
|
23013
22979
|
doc as doc44,
|
|
23014
22980
|
updateDoc as updateDoc39,
|
|
23015
22981
|
Timestamp as Timestamp35,
|
|
23016
|
-
orderBy as
|
|
23017
|
-
limit as
|
|
22982
|
+
orderBy as orderBy18,
|
|
22983
|
+
limit as limit16,
|
|
23018
22984
|
startAfter as startAfter13,
|
|
23019
22985
|
getDoc as getDoc45
|
|
23020
22986
|
} from "firebase/firestore";
|
|
@@ -23061,7 +23027,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
23061
23027
|
*/
|
|
23062
23028
|
async getAllPatientRequirementInstances(patientId, filters, pageLimit = 20, lastVisible) {
|
|
23063
23029
|
const collRef = this.getPatientRequirementsCollectionRef(patientId);
|
|
23064
|
-
let q = query33(collRef,
|
|
23030
|
+
let q = query33(collRef, orderBy18("createdAt", "desc"));
|
|
23065
23031
|
const queryConstraints = [];
|
|
23066
23032
|
if ((filters == null ? void 0 : filters.appointmentId) && filters.appointmentId !== "all") {
|
|
23067
23033
|
queryConstraints.push(
|
|
@@ -23074,7 +23040,7 @@ var PatientRequirementsService = class extends BaseService {
|
|
|
23074
23040
|
if (lastVisible) {
|
|
23075
23041
|
queryConstraints.push(startAfter13(lastVisible));
|
|
23076
23042
|
}
|
|
23077
|
-
queryConstraints.push(
|
|
23043
|
+
queryConstraints.push(limit16(pageLimit));
|
|
23078
23044
|
q = query33(collRef, ...queryConstraints);
|
|
23079
23045
|
const snapshot = await getDocs33(q);
|
|
23080
23046
|
let requirements = snapshot.docs.map((docSnap) => {
|
|
@@ -23214,8 +23180,8 @@ import {
|
|
|
23214
23180
|
Timestamp as Timestamp36,
|
|
23215
23181
|
serverTimestamp as serverTimestamp35,
|
|
23216
23182
|
writeBatch as writeBatch6,
|
|
23217
|
-
orderBy as
|
|
23218
|
-
limit as
|
|
23183
|
+
orderBy as orderBy19,
|
|
23184
|
+
limit as limit17,
|
|
23219
23185
|
startAfter as startAfter14,
|
|
23220
23186
|
documentId as documentId2
|
|
23221
23187
|
} from "firebase/firestore";
|
|
@@ -24441,20 +24407,20 @@ var ProcedureService = class extends BaseService {
|
|
|
24441
24407
|
const proceduresCollection = collection34(this.db, PROCEDURES_COLLECTION);
|
|
24442
24408
|
let proceduresQuery = query34(proceduresCollection);
|
|
24443
24409
|
if (pagination && pagination > 0) {
|
|
24444
|
-
const { limit:
|
|
24410
|
+
const { limit: limit23, startAfter: startAfter20 } = await import("firebase/firestore");
|
|
24445
24411
|
if (lastDoc) {
|
|
24446
24412
|
proceduresQuery = query34(
|
|
24447
24413
|
proceduresCollection,
|
|
24448
|
-
|
|
24414
|
+
orderBy19("name"),
|
|
24449
24415
|
// Use imported orderBy
|
|
24450
24416
|
startAfter20(lastDoc),
|
|
24451
|
-
|
|
24417
|
+
limit23(pagination)
|
|
24452
24418
|
);
|
|
24453
24419
|
} else {
|
|
24454
|
-
proceduresQuery = query34(proceduresCollection,
|
|
24420
|
+
proceduresQuery = query34(proceduresCollection, orderBy19("name"), limit23(pagination));
|
|
24455
24421
|
}
|
|
24456
24422
|
} else {
|
|
24457
|
-
proceduresQuery = query34(proceduresCollection,
|
|
24423
|
+
proceduresQuery = query34(proceduresCollection, orderBy19("name"));
|
|
24458
24424
|
}
|
|
24459
24425
|
const proceduresSnapshot = await getDocs34(proceduresQuery);
|
|
24460
24426
|
let procedures = proceduresSnapshot.docs.map((doc54) => {
|
|
@@ -24637,7 +24603,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24637
24603
|
}
|
|
24638
24604
|
constraints.push(where34("nameLower", ">=", searchTerm));
|
|
24639
24605
|
constraints.push(where34("nameLower", "<=", searchTerm + "\uF8FF"));
|
|
24640
|
-
constraints.push(
|
|
24606
|
+
constraints.push(orderBy19("nameLower"));
|
|
24641
24607
|
if (filters.lastDoc) {
|
|
24642
24608
|
const cursorValues = this.getCursorValuesForStartAfter(filters.lastDoc, "nameLower");
|
|
24643
24609
|
if (cursorValues) {
|
|
@@ -24645,7 +24611,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24645
24611
|
console.log("[PROCEDURE_SERVICE] Strategy 1: Using cursor for pagination");
|
|
24646
24612
|
}
|
|
24647
24613
|
}
|
|
24648
|
-
constraints.push(
|
|
24614
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24649
24615
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24650
24616
|
const querySnapshot = await getDocs34(q);
|
|
24651
24617
|
let procedures = querySnapshot.docs.map(
|
|
@@ -24679,7 +24645,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24679
24645
|
}
|
|
24680
24646
|
constraints.push(where34("name", ">=", searchTerm));
|
|
24681
24647
|
constraints.push(where34("name", "<=", searchTerm + "\uF8FF"));
|
|
24682
|
-
constraints.push(
|
|
24648
|
+
constraints.push(orderBy19("name"));
|
|
24683
24649
|
if (filters.lastDoc) {
|
|
24684
24650
|
const cursorValues = this.getCursorValuesForStartAfter(filters.lastDoc, "name");
|
|
24685
24651
|
if (cursorValues) {
|
|
@@ -24687,7 +24653,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24687
24653
|
console.log("[PROCEDURE_SERVICE] Strategy 2: Using cursor for pagination");
|
|
24688
24654
|
}
|
|
24689
24655
|
}
|
|
24690
|
-
constraints.push(
|
|
24656
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24691
24657
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24692
24658
|
const querySnapshot = await getDocs34(q);
|
|
24693
24659
|
let procedures = querySnapshot.docs.map(
|
|
@@ -24753,7 +24719,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24753
24719
|
"[PROCEDURE_SERVICE] Strategy 3 Firestore constraints (nested filters excluded):",
|
|
24754
24720
|
constraints.map((c) => c.fieldPath || "unknown")
|
|
24755
24721
|
);
|
|
24756
|
-
constraints.push(
|
|
24722
|
+
constraints.push(orderBy19("createdAt", "desc"));
|
|
24757
24723
|
if (filters.lastDoc) {
|
|
24758
24724
|
const cursorValues = this.getCursorValuesForStartAfter(filters.lastDoc, "createdAt");
|
|
24759
24725
|
if (cursorValues) {
|
|
@@ -24761,7 +24727,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24761
24727
|
console.log("[PROCEDURE_SERVICE] Strategy 3: Using cursor for pagination");
|
|
24762
24728
|
}
|
|
24763
24729
|
}
|
|
24764
|
-
constraints.push(
|
|
24730
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24765
24731
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24766
24732
|
const querySnapshot = await getDocs34(q);
|
|
24767
24733
|
let procedures = querySnapshot.docs.map(
|
|
@@ -24799,7 +24765,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24799
24765
|
console.log("[PROCEDURE_SERVICE] Strategy 4: Minimal query fallback");
|
|
24800
24766
|
const constraints = [
|
|
24801
24767
|
where34("isActive", "==", filters.isActive !== void 0 ? filters.isActive : true),
|
|
24802
|
-
|
|
24768
|
+
orderBy19("createdAt", "desc")
|
|
24803
24769
|
];
|
|
24804
24770
|
if (filters.practitionerId) {
|
|
24805
24771
|
constraints.push(where34("practitionerId", "==", filters.practitionerId));
|
|
@@ -24814,7 +24780,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24814
24780
|
console.log("[PROCEDURE_SERVICE] Strategy 4: Using cursor for pagination");
|
|
24815
24781
|
}
|
|
24816
24782
|
}
|
|
24817
|
-
constraints.push(
|
|
24783
|
+
constraints.push(limit17(filters.pagination || 10));
|
|
24818
24784
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24819
24785
|
const querySnapshot = await getDocs34(q);
|
|
24820
24786
|
let procedures = querySnapshot.docs.map(
|
|
@@ -25203,7 +25169,7 @@ var ProcedureService = class extends BaseService {
|
|
|
25203
25169
|
const proceduresQuery = query34(
|
|
25204
25170
|
collection34(this.db, PROCEDURES_COLLECTION),
|
|
25205
25171
|
...constraints,
|
|
25206
|
-
|
|
25172
|
+
orderBy19("name", "asc")
|
|
25207
25173
|
);
|
|
25208
25174
|
const querySnapshot = await getDocs34(proceduresQuery);
|
|
25209
25175
|
let procedures = querySnapshot.docs.map((doc54) => ({
|
|
@@ -25225,7 +25191,7 @@ import {
|
|
|
25225
25191
|
deleteDoc as deleteDoc20,
|
|
25226
25192
|
query as query35,
|
|
25227
25193
|
where as where35,
|
|
25228
|
-
orderBy as
|
|
25194
|
+
orderBy as orderBy20,
|
|
25229
25195
|
writeBatch as writeBatch7,
|
|
25230
25196
|
updateDoc as updateDoc41,
|
|
25231
25197
|
serverTimestamp as serverTimestamp36,
|
|
@@ -25379,7 +25345,7 @@ var ResourceService = class extends BaseService {
|
|
|
25379
25345
|
async getResourcesByClinic(clinicBranchId) {
|
|
25380
25346
|
const q = query35(
|
|
25381
25347
|
this.getResourcesRef(clinicBranchId),
|
|
25382
|
-
|
|
25348
|
+
orderBy20("nameLower")
|
|
25383
25349
|
);
|
|
25384
25350
|
const snapshot = await getDocs35(q);
|
|
25385
25351
|
return snapshot.docs.map(
|
|
@@ -25393,7 +25359,7 @@ var ResourceService = class extends BaseService {
|
|
|
25393
25359
|
const q = query35(
|
|
25394
25360
|
this.getResourcesRef(clinicBranchId),
|
|
25395
25361
|
where35("status", "==", "active" /* ACTIVE */),
|
|
25396
|
-
|
|
25362
|
+
orderBy20("nameLower")
|
|
25397
25363
|
);
|
|
25398
25364
|
const snapshot = await getDocs35(q);
|
|
25399
25365
|
return snapshot.docs.map(
|
|
@@ -25511,7 +25477,7 @@ var ResourceService = class extends BaseService {
|
|
|
25511
25477
|
async getResourceInstances(clinicBranchId, resourceId) {
|
|
25512
25478
|
const q = query35(
|
|
25513
25479
|
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25514
|
-
|
|
25480
|
+
orderBy20("index")
|
|
25515
25481
|
);
|
|
25516
25482
|
const snapshot = await getDocs35(q);
|
|
25517
25483
|
return snapshot.docs.map(
|
|
@@ -25525,7 +25491,7 @@ var ResourceService = class extends BaseService {
|
|
|
25525
25491
|
const q = query35(
|
|
25526
25492
|
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25527
25493
|
where35("status", "==", "active" /* ACTIVE */),
|
|
25528
|
-
|
|
25494
|
+
orderBy20("index")
|
|
25529
25495
|
);
|
|
25530
25496
|
const snapshot = await getDocs35(q);
|
|
25531
25497
|
return snapshot.docs.map(
|
|
@@ -25545,7 +25511,7 @@ var ResourceService = class extends BaseService {
|
|
|
25545
25511
|
calendarRef,
|
|
25546
25512
|
where35("eventTime.start", ">=", start),
|
|
25547
25513
|
where35("eventTime.start", "<=", end),
|
|
25548
|
-
|
|
25514
|
+
orderBy20("eventTime.start")
|
|
25549
25515
|
);
|
|
25550
25516
|
const snapshot = await getDocs35(q);
|
|
25551
25517
|
return snapshot.docs.map(
|
|
@@ -25664,7 +25630,7 @@ var ResourceService = class extends BaseService {
|
|
|
25664
25630
|
const q = query35(
|
|
25665
25631
|
calendarRef,
|
|
25666
25632
|
where35("eventType", "==", "blocking" /* BLOCKING */),
|
|
25667
|
-
|
|
25633
|
+
orderBy20("eventTime.start")
|
|
25668
25634
|
);
|
|
25669
25635
|
const snapshot = await getDocs35(q);
|
|
25670
25636
|
return snapshot.docs.map(
|
|
@@ -26310,8 +26276,8 @@ import {
|
|
|
26310
26276
|
query as query37,
|
|
26311
26277
|
updateDoc as updateDoc42,
|
|
26312
26278
|
where as where37,
|
|
26313
|
-
limit as
|
|
26314
|
-
orderBy as
|
|
26279
|
+
limit as limit18,
|
|
26280
|
+
orderBy as orderBy21,
|
|
26315
26281
|
startAfter as startAfter15,
|
|
26316
26282
|
getCountFromServer as getCountFromServer3
|
|
26317
26283
|
} from "firebase/firestore";
|
|
@@ -26351,7 +26317,7 @@ var BrandService = class extends BaseService {
|
|
|
26351
26317
|
async getAll(rowsPerPage, searchTerm, lastVisible) {
|
|
26352
26318
|
const constraints = [
|
|
26353
26319
|
where37("isActive", "==", true),
|
|
26354
|
-
|
|
26320
|
+
orderBy21("name_lowercase")
|
|
26355
26321
|
];
|
|
26356
26322
|
if (searchTerm) {
|
|
26357
26323
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
@@ -26363,7 +26329,7 @@ var BrandService = class extends BaseService {
|
|
|
26363
26329
|
if (lastVisible) {
|
|
26364
26330
|
constraints.push(startAfter15(lastVisible));
|
|
26365
26331
|
}
|
|
26366
|
-
constraints.push(
|
|
26332
|
+
constraints.push(limit18(rowsPerPage));
|
|
26367
26333
|
const q = query37(this.getBrandsRef(), ...constraints);
|
|
26368
26334
|
const snapshot = await getDocs37(q);
|
|
26369
26335
|
const brands = snapshot.docs.map(
|
|
@@ -26399,7 +26365,7 @@ var BrandService = class extends BaseService {
|
|
|
26399
26365
|
const q = query37(
|
|
26400
26366
|
this.getBrandsRef(),
|
|
26401
26367
|
where37("isActive", "==", true),
|
|
26402
|
-
|
|
26368
|
+
orderBy21("name")
|
|
26403
26369
|
);
|
|
26404
26370
|
const snapshot = await getDocs37(q);
|
|
26405
26371
|
return snapshot.docs.map(
|
|
@@ -26469,9 +26435,9 @@ var BrandService = class extends BaseService {
|
|
|
26469
26435
|
if (!includeInactive) {
|
|
26470
26436
|
baseConstraints.push(where37("isActive", "==", true));
|
|
26471
26437
|
}
|
|
26472
|
-
baseConstraints.push(
|
|
26438
|
+
baseConstraints.push(orderBy21("name_lowercase"));
|
|
26473
26439
|
while (true) {
|
|
26474
|
-
const constraints = [...baseConstraints,
|
|
26440
|
+
const constraints = [...baseConstraints, limit18(PAGE_SIZE)];
|
|
26475
26441
|
if (cursor) constraints.push(startAfter15(cursor));
|
|
26476
26442
|
const q = query37(this.getBrandsRef(), ...constraints);
|
|
26477
26443
|
const snapshot = await getDocs37(q);
|
|
@@ -26520,8 +26486,8 @@ import {
|
|
|
26520
26486
|
doc as doc49,
|
|
26521
26487
|
getDoc as getDoc50,
|
|
26522
26488
|
getDocs as getDocs38,
|
|
26523
|
-
limit as
|
|
26524
|
-
orderBy as
|
|
26489
|
+
limit as limit19,
|
|
26490
|
+
orderBy as orderBy22,
|
|
26525
26491
|
query as query38,
|
|
26526
26492
|
startAfter as startAfter16,
|
|
26527
26493
|
updateDoc as updateDoc43,
|
|
@@ -26609,7 +26575,7 @@ var CategoryService = class extends BaseService {
|
|
|
26609
26575
|
this.categoriesRef,
|
|
26610
26576
|
where38("family", "==", family),
|
|
26611
26577
|
where38("isActive", "==", true),
|
|
26612
|
-
|
|
26578
|
+
orderBy22("name")
|
|
26613
26579
|
);
|
|
26614
26580
|
const snapshot = await getDocs38(q);
|
|
26615
26581
|
const categories = snapshot.docs.map(
|
|
@@ -26629,8 +26595,8 @@ var CategoryService = class extends BaseService {
|
|
|
26629
26595
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26630
26596
|
const constraints = [
|
|
26631
26597
|
where38("isActive", "==", active),
|
|
26632
|
-
|
|
26633
|
-
queryLimit ?
|
|
26598
|
+
orderBy22("name"),
|
|
26599
|
+
queryLimit ? limit19(queryLimit) : void 0,
|
|
26634
26600
|
lastVisible ? startAfter16(lastVisible) : void 0
|
|
26635
26601
|
].filter((c) => !!c);
|
|
26636
26602
|
const q = query38(this.categoriesRef, ...constraints);
|
|
@@ -26656,8 +26622,8 @@ var CategoryService = class extends BaseService {
|
|
|
26656
26622
|
const constraints = [
|
|
26657
26623
|
where38("family", "==", family),
|
|
26658
26624
|
where38("isActive", "==", active),
|
|
26659
|
-
|
|
26660
|
-
queryLimit ?
|
|
26625
|
+
orderBy22("name"),
|
|
26626
|
+
queryLimit ? limit19(queryLimit) : void 0,
|
|
26661
26627
|
lastVisible ? startAfter16(lastVisible) : void 0
|
|
26662
26628
|
].filter((c) => !!c);
|
|
26663
26629
|
const q = query38(this.categoriesRef, ...constraints);
|
|
@@ -26778,9 +26744,9 @@ var CategoryService = class extends BaseService {
|
|
|
26778
26744
|
if (!includeInactive) {
|
|
26779
26745
|
constraints.push(where38("isActive", "==", true));
|
|
26780
26746
|
}
|
|
26781
|
-
constraints.push(
|
|
26747
|
+
constraints.push(orderBy22("name"));
|
|
26782
26748
|
while (true) {
|
|
26783
|
-
const queryConstraints = [...constraints,
|
|
26749
|
+
const queryConstraints = [...constraints, limit19(PAGE_SIZE)];
|
|
26784
26750
|
if (cursor) queryConstraints.push(startAfter16(cursor));
|
|
26785
26751
|
const q = query38(this.categoriesRef, ...queryConstraints);
|
|
26786
26752
|
const snapshot = await getDocs38(q);
|
|
@@ -26826,13 +26792,13 @@ var CategoryService = class extends BaseService {
|
|
|
26826
26792
|
import {
|
|
26827
26793
|
addDoc as addDoc6,
|
|
26828
26794
|
collection as collection39,
|
|
26829
|
-
collectionGroup as
|
|
26795
|
+
collectionGroup as collectionGroup3,
|
|
26830
26796
|
deleteDoc as deleteDoc22,
|
|
26831
26797
|
doc as doc50,
|
|
26832
26798
|
getDoc as getDoc51,
|
|
26833
26799
|
getDocs as getDocs39,
|
|
26834
|
-
limit as
|
|
26835
|
-
orderBy as
|
|
26800
|
+
limit as limit20,
|
|
26801
|
+
orderBy as orderBy23,
|
|
26836
26802
|
query as query39,
|
|
26837
26803
|
setDoc as setDoc34,
|
|
26838
26804
|
startAfter as startAfter17,
|
|
@@ -26916,8 +26882,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
26916
26882
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26917
26883
|
const constraints = [
|
|
26918
26884
|
where39("isActive", "==", active),
|
|
26919
|
-
|
|
26920
|
-
queryLimit ?
|
|
26885
|
+
orderBy23("name"),
|
|
26886
|
+
queryLimit ? limit20(queryLimit) : void 0,
|
|
26921
26887
|
lastVisible ? startAfter17(lastVisible) : void 0
|
|
26922
26888
|
].filter((c) => !!c);
|
|
26923
26889
|
const q = query39(this.getSubcategoriesRef(categoryId), ...constraints);
|
|
@@ -26944,12 +26910,12 @@ var SubcategoryService = class extends BaseService {
|
|
|
26944
26910
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26945
26911
|
const constraints = [
|
|
26946
26912
|
where39("isActive", "==", active),
|
|
26947
|
-
|
|
26948
|
-
queryLimit ?
|
|
26913
|
+
orderBy23("name"),
|
|
26914
|
+
queryLimit ? limit20(queryLimit) : void 0,
|
|
26949
26915
|
lastVisible ? startAfter17(lastVisible) : void 0
|
|
26950
26916
|
].filter((c) => !!c);
|
|
26951
26917
|
const q = query39(
|
|
26952
|
-
|
|
26918
|
+
collectionGroup3(this.db, SUBCATEGORIES_COLLECTION),
|
|
26953
26919
|
...constraints
|
|
26954
26920
|
);
|
|
26955
26921
|
const querySnapshot = await getDocs39(q);
|
|
@@ -26988,7 +26954,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
26988
26954
|
*/
|
|
26989
26955
|
async getAllForFilter() {
|
|
26990
26956
|
const q = query39(
|
|
26991
|
-
|
|
26957
|
+
collectionGroup3(this.db, SUBCATEGORIES_COLLECTION),
|
|
26992
26958
|
where39("isActive", "==", true)
|
|
26993
26959
|
);
|
|
26994
26960
|
const querySnapshot = await getDocs39(q);
|
|
@@ -27139,12 +27105,12 @@ var SubcategoryService = class extends BaseService {
|
|
|
27139
27105
|
if (!includeInactive) {
|
|
27140
27106
|
constraints.push(where39("isActive", "==", true));
|
|
27141
27107
|
}
|
|
27142
|
-
constraints.push(
|
|
27108
|
+
constraints.push(orderBy23("name"));
|
|
27143
27109
|
while (true) {
|
|
27144
|
-
const queryConstraints = [...constraints,
|
|
27110
|
+
const queryConstraints = [...constraints, limit20(PAGE_SIZE)];
|
|
27145
27111
|
if (cursor) queryConstraints.push(startAfter17(cursor));
|
|
27146
27112
|
const q = query39(
|
|
27147
|
-
|
|
27113
|
+
collectionGroup3(this.db, SUBCATEGORIES_COLLECTION),
|
|
27148
27114
|
...queryConstraints
|
|
27149
27115
|
);
|
|
27150
27116
|
const snapshot = await getDocs39(q);
|
|
@@ -27193,8 +27159,8 @@ import {
|
|
|
27193
27159
|
doc as doc51,
|
|
27194
27160
|
getDoc as getDoc52,
|
|
27195
27161
|
getDocs as getDocs40,
|
|
27196
|
-
limit as
|
|
27197
|
-
orderBy as
|
|
27162
|
+
limit as limit21,
|
|
27163
|
+
orderBy as orderBy24,
|
|
27198
27164
|
query as query40,
|
|
27199
27165
|
startAfter as startAfter18,
|
|
27200
27166
|
updateDoc as updateDoc45,
|
|
@@ -27301,8 +27267,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27301
27267
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
27302
27268
|
const constraints = [
|
|
27303
27269
|
where40("isActive", "==", active),
|
|
27304
|
-
|
|
27305
|
-
queryLimit ?
|
|
27270
|
+
orderBy24("name"),
|
|
27271
|
+
queryLimit ? limit21(queryLimit) : void 0,
|
|
27306
27272
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
27307
27273
|
].filter((c) => !!c);
|
|
27308
27274
|
const q = query40(this.technologiesRef, ...constraints);
|
|
@@ -27328,8 +27294,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27328
27294
|
const constraints = [
|
|
27329
27295
|
where40("categoryId", "==", categoryId),
|
|
27330
27296
|
where40("isActive", "==", active),
|
|
27331
|
-
|
|
27332
|
-
queryLimit ?
|
|
27297
|
+
orderBy24("name"),
|
|
27298
|
+
queryLimit ? limit21(queryLimit) : void 0,
|
|
27333
27299
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
27334
27300
|
].filter((c) => !!c);
|
|
27335
27301
|
const q = query40(this.technologiesRef, ...constraints);
|
|
@@ -27355,8 +27321,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27355
27321
|
const constraints = [
|
|
27356
27322
|
where40("subcategoryId", "==", subcategoryId),
|
|
27357
27323
|
where40("isActive", "==", active),
|
|
27358
|
-
|
|
27359
|
-
queryLimit ?
|
|
27324
|
+
orderBy24("name"),
|
|
27325
|
+
queryLimit ? limit21(queryLimit) : void 0,
|
|
27360
27326
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
27361
27327
|
].filter((c) => !!c);
|
|
27362
27328
|
const q = query40(this.technologiesRef, ...constraints);
|
|
@@ -27829,7 +27795,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27829
27795
|
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27830
27796
|
where40("isActive", "==", true),
|
|
27831
27797
|
where40("subcategoryId", "==", subcategoryId),
|
|
27832
|
-
|
|
27798
|
+
orderBy24("name")
|
|
27833
27799
|
);
|
|
27834
27800
|
const snapshot = await getDocs40(q);
|
|
27835
27801
|
const technologies = snapshot.docs.map(
|
|
@@ -27851,7 +27817,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27851
27817
|
where40("isActive", "==", true),
|
|
27852
27818
|
where40("categoryId", "==", categoryId),
|
|
27853
27819
|
where40("subcategoryId", "==", subcategoryId),
|
|
27854
|
-
|
|
27820
|
+
orderBy24("name")
|
|
27855
27821
|
);
|
|
27856
27822
|
const snapshot = await getDocs40(q);
|
|
27857
27823
|
const technologies = snapshot.docs.map(
|
|
@@ -27869,7 +27835,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27869
27835
|
const q = query40(
|
|
27870
27836
|
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27871
27837
|
where40("isActive", "==", true),
|
|
27872
|
-
|
|
27838
|
+
orderBy24("name")
|
|
27873
27839
|
);
|
|
27874
27840
|
const snapshot = await getDocs40(q);
|
|
27875
27841
|
const technologies = snapshot.docs.map(
|
|
@@ -27922,7 +27888,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27922
27888
|
collection40(this.db, PRODUCTS_COLLECTION),
|
|
27923
27889
|
where40("assignedTechnologyIds", "array-contains", technologyId),
|
|
27924
27890
|
where40("isActive", "==", true),
|
|
27925
|
-
|
|
27891
|
+
orderBy24("name")
|
|
27926
27892
|
);
|
|
27927
27893
|
const snapshot = await getDocs40(q);
|
|
27928
27894
|
return snapshot.docs.map(
|
|
@@ -27939,7 +27905,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27939
27905
|
const q = query40(
|
|
27940
27906
|
collection40(this.db, PRODUCTS_COLLECTION),
|
|
27941
27907
|
where40("isActive", "==", true),
|
|
27942
|
-
|
|
27908
|
+
orderBy24("name")
|
|
27943
27909
|
);
|
|
27944
27910
|
const snapshot = await getDocs40(q);
|
|
27945
27911
|
const allProducts = snapshot.docs.map(
|
|
@@ -28037,9 +28003,9 @@ var TechnologyService = class extends BaseService {
|
|
|
28037
28003
|
if (!includeInactive) {
|
|
28038
28004
|
constraints.push(where40("isActive", "==", true));
|
|
28039
28005
|
}
|
|
28040
|
-
constraints.push(
|
|
28006
|
+
constraints.push(orderBy24("name"));
|
|
28041
28007
|
while (true) {
|
|
28042
|
-
const queryConstraints = [...constraints,
|
|
28008
|
+
const queryConstraints = [...constraints, limit21(PAGE_SIZE)];
|
|
28043
28009
|
if (cursor) queryConstraints.push(startAfter18(cursor));
|
|
28044
28010
|
const q = query40(this.technologiesRef, ...queryConstraints);
|
|
28045
28011
|
const snapshot = await getDocs40(q);
|
|
@@ -28107,15 +28073,15 @@ var TechnologyService = class extends BaseService {
|
|
|
28107
28073
|
import {
|
|
28108
28074
|
addDoc as addDoc8,
|
|
28109
28075
|
collection as collection41,
|
|
28110
|
-
collectionGroup as
|
|
28076
|
+
collectionGroup as collectionGroup4,
|
|
28111
28077
|
doc as doc52,
|
|
28112
28078
|
getDoc as getDoc53,
|
|
28113
28079
|
getDocs as getDocs41,
|
|
28114
28080
|
query as query41,
|
|
28115
28081
|
updateDoc as updateDoc46,
|
|
28116
28082
|
where as where41,
|
|
28117
|
-
limit as
|
|
28118
|
-
orderBy as
|
|
28083
|
+
limit as limit22,
|
|
28084
|
+
orderBy as orderBy25,
|
|
28119
28085
|
startAfter as startAfter19,
|
|
28120
28086
|
getCountFromServer as getCountFromServer7,
|
|
28121
28087
|
arrayUnion as arrayUnion10,
|
|
@@ -28160,7 +28126,7 @@ var ProductService = class extends BaseService {
|
|
|
28160
28126
|
*/
|
|
28161
28127
|
async getAll(options) {
|
|
28162
28128
|
const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
|
|
28163
|
-
const constraints = [where41("isActive", "==", true),
|
|
28129
|
+
const constraints = [where41("isActive", "==", true), orderBy25("name")];
|
|
28164
28130
|
if (categoryId) {
|
|
28165
28131
|
constraints.push(where41("categoryId", "==", categoryId));
|
|
28166
28132
|
}
|
|
@@ -28173,8 +28139,8 @@ var ProductService = class extends BaseService {
|
|
|
28173
28139
|
if (lastVisible) {
|
|
28174
28140
|
constraints.push(startAfter19(lastVisible));
|
|
28175
28141
|
}
|
|
28176
|
-
constraints.push(
|
|
28177
|
-
const q = query41(
|
|
28142
|
+
constraints.push(limit22(rowsPerPage));
|
|
28143
|
+
const q = query41(collectionGroup4(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
28178
28144
|
const snapshot = await getDocs41(q);
|
|
28179
28145
|
const products = snapshot.docs.map(
|
|
28180
28146
|
(doc54) => ({
|
|
@@ -28200,7 +28166,7 @@ var ProductService = class extends BaseService {
|
|
|
28200
28166
|
if (technologyId) {
|
|
28201
28167
|
constraints.push(where41("technologyId", "==", technologyId));
|
|
28202
28168
|
}
|
|
28203
|
-
const q = query41(
|
|
28169
|
+
const q = query41(collectionGroup4(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
28204
28170
|
const snapshot = await getCountFromServer7(q);
|
|
28205
28171
|
return snapshot.data().count;
|
|
28206
28172
|
}
|
|
@@ -28214,7 +28180,7 @@ var ProductService = class extends BaseService {
|
|
|
28214
28180
|
bySubcategory: {},
|
|
28215
28181
|
byTechnology: {}
|
|
28216
28182
|
};
|
|
28217
|
-
const q = query41(
|
|
28183
|
+
const q = query41(collectionGroup4(this.db, PRODUCTS_COLLECTION), where41("isActive", "==", true));
|
|
28218
28184
|
const snapshot = await getDocs41(q);
|
|
28219
28185
|
snapshot.docs.forEach((doc54) => {
|
|
28220
28186
|
const product = doc54.data();
|
|
@@ -28237,7 +28203,7 @@ var ProductService = class extends BaseService {
|
|
|
28237
28203
|
const q = query41(
|
|
28238
28204
|
this.getProductsRef(technologyId),
|
|
28239
28205
|
where41("isActive", "==", true),
|
|
28240
|
-
|
|
28206
|
+
orderBy25("name")
|
|
28241
28207
|
);
|
|
28242
28208
|
const snapshot = await getDocs41(q);
|
|
28243
28209
|
return snapshot.docs.map(
|
|
@@ -28333,7 +28299,7 @@ var ProductService = class extends BaseService {
|
|
|
28333
28299
|
brandId: brandId || "none",
|
|
28334
28300
|
category: category || "none"
|
|
28335
28301
|
});
|
|
28336
|
-
const constraints = [where41("isActive", "==", true),
|
|
28302
|
+
const constraints = [where41("isActive", "==", true), orderBy25("name")];
|
|
28337
28303
|
if (brandId) {
|
|
28338
28304
|
console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
|
|
28339
28305
|
constraints.push(where41("brandId", "==", brandId));
|
|
@@ -28345,7 +28311,7 @@ var ProductService = class extends BaseService {
|
|
|
28345
28311
|
if (lastVisible) {
|
|
28346
28312
|
constraints.push(startAfter19(lastVisible));
|
|
28347
28313
|
}
|
|
28348
|
-
constraints.push(
|
|
28314
|
+
constraints.push(limit22(rowsPerPage));
|
|
28349
28315
|
const q = query41(this.getTopLevelProductsRef(), ...constraints);
|
|
28350
28316
|
const snapshot = await getDocs41(q);
|
|
28351
28317
|
const products = snapshot.docs.map(
|
|
@@ -28417,7 +28383,7 @@ var ProductService = class extends BaseService {
|
|
|
28417
28383
|
this.getTopLevelProductsRef(),
|
|
28418
28384
|
where41("assignedTechnologyIds", "array-contains", technologyId),
|
|
28419
28385
|
where41("isActive", "==", true),
|
|
28420
|
-
|
|
28386
|
+
orderBy25("name")
|
|
28421
28387
|
);
|
|
28422
28388
|
const snapshot = await getDocs41(q);
|
|
28423
28389
|
return snapshot.docs.map(
|
|
@@ -28434,7 +28400,7 @@ var ProductService = class extends BaseService {
|
|
|
28434
28400
|
const q = query41(
|
|
28435
28401
|
this.getTopLevelProductsRef(),
|
|
28436
28402
|
where41("isActive", "==", true),
|
|
28437
|
-
|
|
28403
|
+
orderBy25("name")
|
|
28438
28404
|
);
|
|
28439
28405
|
const snapshot = await getDocs41(q);
|
|
28440
28406
|
const allProducts = snapshot.docs.map(
|
|
@@ -28458,7 +28424,7 @@ var ProductService = class extends BaseService {
|
|
|
28458
28424
|
this.getTopLevelProductsRef(),
|
|
28459
28425
|
where41("brandId", "==", brandId),
|
|
28460
28426
|
where41("isActive", "==", true),
|
|
28461
|
-
|
|
28427
|
+
orderBy25("name")
|
|
28462
28428
|
);
|
|
28463
28429
|
const snapshot = await getDocs41(q);
|
|
28464
28430
|
return snapshot.docs.map(
|
|
@@ -28496,9 +28462,9 @@ var ProductService = class extends BaseService {
|
|
|
28496
28462
|
if (!includeInactive) {
|
|
28497
28463
|
constraints.push(where41("isActive", "==", true));
|
|
28498
28464
|
}
|
|
28499
|
-
constraints.push(
|
|
28465
|
+
constraints.push(orderBy25("name"));
|
|
28500
28466
|
while (true) {
|
|
28501
|
-
const queryConstraints = [...constraints,
|
|
28467
|
+
const queryConstraints = [...constraints, limit22(PAGE_SIZE)];
|
|
28502
28468
|
if (cursor) queryConstraints.push(startAfter19(cursor));
|
|
28503
28469
|
const q = query41(this.getTopLevelProductsRef(), ...queryConstraints);
|
|
28504
28470
|
const snapshot = await getDocs41(q);
|
|
@@ -28593,9 +28559,9 @@ var ConstantsService = class extends BaseService {
|
|
|
28593
28559
|
*/
|
|
28594
28560
|
async getAllBenefits(options) {
|
|
28595
28561
|
const allBenefits = await this.getAllBenefitsForFilter();
|
|
28596
|
-
const { page, limit:
|
|
28597
|
-
const startIndex = page *
|
|
28598
|
-
const endIndex = startIndex +
|
|
28562
|
+
const { page, limit: limit23 } = options;
|
|
28563
|
+
const startIndex = page * limit23;
|
|
28564
|
+
const endIndex = startIndex + limit23;
|
|
28599
28565
|
const paginatedBenefits = allBenefits.slice(startIndex, endIndex);
|
|
28600
28566
|
return { benefits: paginatedBenefits, total: allBenefits.length };
|
|
28601
28567
|
}
|
|
@@ -28692,9 +28658,9 @@ var ConstantsService = class extends BaseService {
|
|
|
28692
28658
|
*/
|
|
28693
28659
|
async getAllContraindications(options) {
|
|
28694
28660
|
const allContraindications = await this.getAllContraindicationsForFilter();
|
|
28695
|
-
const { page, limit:
|
|
28696
|
-
const startIndex = page *
|
|
28697
|
-
const endIndex = startIndex +
|
|
28661
|
+
const { page, limit: limit23 } = options;
|
|
28662
|
+
const startIndex = page * limit23;
|
|
28663
|
+
const endIndex = startIndex + limit23;
|
|
28698
28664
|
const paginatedContraindications = allContraindications.slice(
|
|
28699
28665
|
startIndex,
|
|
28700
28666
|
endIndex
|
|
@@ -28914,6 +28880,7 @@ export {
|
|
|
28914
28880
|
CLINIC_ADMINS_COLLECTION,
|
|
28915
28881
|
CLINIC_ANALYTICS_SUBCOLLECTION,
|
|
28916
28882
|
CLINIC_GROUPS_COLLECTION,
|
|
28883
|
+
CONCERNS_COLLECTION,
|
|
28917
28884
|
CalendarEventStatus,
|
|
28918
28885
|
CalendarEventType,
|
|
28919
28886
|
CalendarServiceV2,
|