@blackcode_sa/metaestetics-api 1.13.11 → 1.13.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +109 -34
- package/dist/index.mjs +109 -34
- package/package.json +1 -1
- package/src/services/clinic/clinic.service.ts +15 -10
- package/src/services/clinic/utils/clinic.utils.ts +91 -10
- package/src/services/clinic/utils/filter.utils.ts +17 -0
- package/src/services/procedure/procedure.service.ts +42 -18
package/dist/index.d.mts
CHANGED
|
@@ -6600,12 +6600,14 @@ declare class ClinicService extends BaseService {
|
|
|
6600
6600
|
activateClinic(clinicId: string, adminId: string): Promise<void>;
|
|
6601
6601
|
/**
|
|
6602
6602
|
* Dohvata kliniku po ID-u
|
|
6603
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
6603
6604
|
*/
|
|
6604
|
-
getClinic(clinicId: string): Promise<Clinic | null>;
|
|
6605
|
+
getClinic(clinicId: string, excludeDraftPractitioners?: boolean): Promise<Clinic | null>;
|
|
6605
6606
|
/**
|
|
6606
6607
|
* Dohvata sve klinike u grupi
|
|
6608
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
6607
6609
|
*/
|
|
6608
|
-
getClinicsByGroup(groupId: string): Promise<Clinic[]>;
|
|
6610
|
+
getClinicsByGroup(groupId: string, excludeDraftPractitioners?: boolean): Promise<Clinic[]>;
|
|
6609
6611
|
/**
|
|
6610
6612
|
* Pretražuje klinike u određenom radijusu
|
|
6611
6613
|
*/
|
|
@@ -6632,15 +6634,15 @@ declare class ClinicService extends BaseService {
|
|
|
6632
6634
|
* Handles both URL strings and File uploads for media fields.
|
|
6633
6635
|
*/
|
|
6634
6636
|
createClinicBranch(clinicGroupId: string, setupData: ClinicBranchSetupData, adminId: string): Promise<Clinic>;
|
|
6635
|
-
getClinicById(clinicId: string): Promise<Clinic | null>;
|
|
6636
|
-
getAllClinics(pagination?: number, lastDoc?: any): Promise<{
|
|
6637
|
+
getClinicById(clinicId: string, excludeDraftPractitioners?: boolean): Promise<Clinic | null>;
|
|
6638
|
+
getAllClinics(pagination?: number, lastDoc?: any, excludeDraftPractitioners?: boolean): Promise<{
|
|
6637
6639
|
clinics: Clinic[];
|
|
6638
6640
|
lastDoc: any;
|
|
6639
6641
|
}>;
|
|
6640
6642
|
getAllClinicsInRange(center: {
|
|
6641
6643
|
latitude: number;
|
|
6642
6644
|
longitude: number;
|
|
6643
|
-
}, rangeInKm: number, pagination?: number, lastDoc?: any): Promise<{
|
|
6645
|
+
}, rangeInKm: number, pagination?: number, lastDoc?: any, excludeDraftPractitioners?: boolean): Promise<{
|
|
6644
6646
|
clinics: (Clinic & {
|
|
6645
6647
|
distance: number;
|
|
6646
6648
|
})[];
|
|
@@ -6895,6 +6897,7 @@ declare class ProcedureService extends BaseService {
|
|
|
6895
6897
|
isActive?: boolean;
|
|
6896
6898
|
practitionerId?: string;
|
|
6897
6899
|
clinicId?: string;
|
|
6900
|
+
excludeDraftPractitioners?: boolean;
|
|
6898
6901
|
}): Promise<{
|
|
6899
6902
|
procedures: (Procedure & {
|
|
6900
6903
|
distance?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -6600,12 +6600,14 @@ declare class ClinicService extends BaseService {
|
|
|
6600
6600
|
activateClinic(clinicId: string, adminId: string): Promise<void>;
|
|
6601
6601
|
/**
|
|
6602
6602
|
* Dohvata kliniku po ID-u
|
|
6603
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
6603
6604
|
*/
|
|
6604
|
-
getClinic(clinicId: string): Promise<Clinic | null>;
|
|
6605
|
+
getClinic(clinicId: string, excludeDraftPractitioners?: boolean): Promise<Clinic | null>;
|
|
6605
6606
|
/**
|
|
6606
6607
|
* Dohvata sve klinike u grupi
|
|
6608
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
6607
6609
|
*/
|
|
6608
|
-
getClinicsByGroup(groupId: string): Promise<Clinic[]>;
|
|
6610
|
+
getClinicsByGroup(groupId: string, excludeDraftPractitioners?: boolean): Promise<Clinic[]>;
|
|
6609
6611
|
/**
|
|
6610
6612
|
* Pretražuje klinike u određenom radijusu
|
|
6611
6613
|
*/
|
|
@@ -6632,15 +6634,15 @@ declare class ClinicService extends BaseService {
|
|
|
6632
6634
|
* Handles both URL strings and File uploads for media fields.
|
|
6633
6635
|
*/
|
|
6634
6636
|
createClinicBranch(clinicGroupId: string, setupData: ClinicBranchSetupData, adminId: string): Promise<Clinic>;
|
|
6635
|
-
getClinicById(clinicId: string): Promise<Clinic | null>;
|
|
6636
|
-
getAllClinics(pagination?: number, lastDoc?: any): Promise<{
|
|
6637
|
+
getClinicById(clinicId: string, excludeDraftPractitioners?: boolean): Promise<Clinic | null>;
|
|
6638
|
+
getAllClinics(pagination?: number, lastDoc?: any, excludeDraftPractitioners?: boolean): Promise<{
|
|
6637
6639
|
clinics: Clinic[];
|
|
6638
6640
|
lastDoc: any;
|
|
6639
6641
|
}>;
|
|
6640
6642
|
getAllClinicsInRange(center: {
|
|
6641
6643
|
latitude: number;
|
|
6642
6644
|
longitude: number;
|
|
6643
|
-
}, rangeInKm: number, pagination?: number, lastDoc?: any): Promise<{
|
|
6645
|
+
}, rangeInKm: number, pagination?: number, lastDoc?: any, excludeDraftPractitioners?: boolean): Promise<{
|
|
6644
6646
|
clinics: (Clinic & {
|
|
6645
6647
|
distance: number;
|
|
6646
6648
|
})[];
|
|
@@ -6895,6 +6897,7 @@ declare class ProcedureService extends BaseService {
|
|
|
6895
6897
|
isActive?: boolean;
|
|
6896
6898
|
practitionerId?: string;
|
|
6897
6899
|
clinicId?: string;
|
|
6900
|
+
excludeDraftPractitioners?: boolean;
|
|
6898
6901
|
}): Promise<{
|
|
6899
6902
|
procedures: (Procedure & {
|
|
6900
6903
|
distance?: number;
|
package/dist/index.js
CHANGED
|
@@ -13530,22 +13530,63 @@ var import_zod21 = require("zod");
|
|
|
13530
13530
|
var import_firestore36 = require("firebase/firestore");
|
|
13531
13531
|
var import_geofire_common4 = require("geofire-common");
|
|
13532
13532
|
var import_zod20 = require("zod");
|
|
13533
|
-
|
|
13533
|
+
function filterDoctorsInfo(doctorsInfo) {
|
|
13534
|
+
if (!doctorsInfo || doctorsInfo.length === 0) {
|
|
13535
|
+
return [];
|
|
13536
|
+
}
|
|
13537
|
+
return doctorsInfo.filter((doctor) => {
|
|
13538
|
+
if (doctor.status === "draft" /* DRAFT */) {
|
|
13539
|
+
console.log(`[CLINIC_UTILS] Filtering out draft practitioner ${doctor.id} from doctorsInfo`);
|
|
13540
|
+
return false;
|
|
13541
|
+
}
|
|
13542
|
+
if (doctor.isActive === false) {
|
|
13543
|
+
console.log(`[CLINIC_UTILS] Filtering out inactive practitioner ${doctor.id} from doctorsInfo`);
|
|
13544
|
+
return false;
|
|
13545
|
+
}
|
|
13546
|
+
return true;
|
|
13547
|
+
});
|
|
13548
|
+
}
|
|
13549
|
+
function filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners = false) {
|
|
13550
|
+
if (!clinic) {
|
|
13551
|
+
return clinic;
|
|
13552
|
+
}
|
|
13553
|
+
console.log(`[CLINIC_UTILS] filterClinicEmbeddedArrays called for clinic ${clinic.id} with excludeDraftPractitioners: ${excludeDraftPractitioners}`);
|
|
13554
|
+
if (!excludeDraftPractitioners) {
|
|
13555
|
+
console.log(`[CLINIC_UTILS] Skipping filtering for clinic ${clinic.id} (excludeDraftPractitioners is false)`);
|
|
13556
|
+
return clinic;
|
|
13557
|
+
}
|
|
13558
|
+
const filteredClinic = { ...clinic };
|
|
13559
|
+
if (filteredClinic.doctorsInfo && filteredClinic.doctorsInfo.length > 0) {
|
|
13560
|
+
const originalLength = filteredClinic.doctorsInfo.length;
|
|
13561
|
+
filteredClinic.doctorsInfo = filterDoctorsInfo(filteredClinic.doctorsInfo);
|
|
13562
|
+
if (filteredClinic.doctorsInfo.length !== originalLength) {
|
|
13563
|
+
console.log(
|
|
13564
|
+
`[CLINIC_UTILS] Filtered ${originalLength - filteredClinic.doctorsInfo.length} draft/inactive doctors from clinic ${clinic.id}`
|
|
13565
|
+
);
|
|
13566
|
+
}
|
|
13567
|
+
}
|
|
13568
|
+
return filteredClinic;
|
|
13569
|
+
}
|
|
13570
|
+
async function getClinic(db, clinicId, excludeDraftPractitioners = false) {
|
|
13534
13571
|
const docRef = (0, import_firestore36.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
13535
13572
|
const docSnap = await (0, import_firestore36.getDoc)(docRef);
|
|
13536
13573
|
if (docSnap.exists()) {
|
|
13537
|
-
|
|
13574
|
+
const clinicData = docSnap.data();
|
|
13575
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13538
13576
|
}
|
|
13539
13577
|
return null;
|
|
13540
13578
|
}
|
|
13541
|
-
async function getClinicsByGroup(db, groupId) {
|
|
13579
|
+
async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false) {
|
|
13542
13580
|
const q = (0, import_firestore36.query)(
|
|
13543
13581
|
(0, import_firestore36.collection)(db, CLINICS_COLLECTION),
|
|
13544
13582
|
(0, import_firestore36.where)("clinicGroupId", "==", groupId),
|
|
13545
13583
|
(0, import_firestore36.where)("isActive", "==", true)
|
|
13546
13584
|
);
|
|
13547
13585
|
const querySnapshot = await (0, import_firestore36.getDocs)(q);
|
|
13548
|
-
return querySnapshot.docs.map((doc47) =>
|
|
13586
|
+
return querySnapshot.docs.map((doc47) => {
|
|
13587
|
+
const clinicData = doc47.data();
|
|
13588
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13589
|
+
});
|
|
13549
13590
|
}
|
|
13550
13591
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
13551
13592
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -13750,7 +13791,7 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
|
|
|
13750
13791
|
clinicGroupService
|
|
13751
13792
|
);
|
|
13752
13793
|
}
|
|
13753
|
-
async function getClinicById(db, clinicId) {
|
|
13794
|
+
async function getClinicById(db, clinicId, excludeDraftPractitioners = false) {
|
|
13754
13795
|
try {
|
|
13755
13796
|
const clinicRef = (0, import_firestore36.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
13756
13797
|
const clinicSnapshot = await (0, import_firestore36.getDoc)(clinicRef);
|
|
@@ -13758,16 +13799,17 @@ async function getClinicById(db, clinicId) {
|
|
|
13758
13799
|
return null;
|
|
13759
13800
|
}
|
|
13760
13801
|
const clinicData = clinicSnapshot.data();
|
|
13761
|
-
|
|
13802
|
+
const clinicWithId = {
|
|
13762
13803
|
...clinicData,
|
|
13763
13804
|
id: clinicSnapshot.id
|
|
13764
13805
|
};
|
|
13806
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13765
13807
|
} catch (error) {
|
|
13766
13808
|
console.error("[CLINIC_UTILS] Error getting clinic by ID:", error);
|
|
13767
13809
|
throw error;
|
|
13768
13810
|
}
|
|
13769
13811
|
}
|
|
13770
|
-
async function getAllClinics(db, pagination, lastDoc) {
|
|
13812
|
+
async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13771
13813
|
try {
|
|
13772
13814
|
const clinicsCollection = (0, import_firestore36.collection)(db, CLINICS_COLLECTION);
|
|
13773
13815
|
let clinicsQuery = (0, import_firestore36.query)(clinicsCollection);
|
|
@@ -13786,10 +13828,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13786
13828
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
13787
13829
|
const clinics = clinicsSnapshot.docs.map((doc47) => {
|
|
13788
13830
|
const data = doc47.data();
|
|
13789
|
-
|
|
13831
|
+
const clinicWithId = {
|
|
13790
13832
|
...data,
|
|
13791
13833
|
id: doc47.id
|
|
13792
13834
|
};
|
|
13835
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13793
13836
|
});
|
|
13794
13837
|
return {
|
|
13795
13838
|
clinics,
|
|
@@ -13800,7 +13843,7 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13800
13843
|
throw error;
|
|
13801
13844
|
}
|
|
13802
13845
|
}
|
|
13803
|
-
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc) {
|
|
13846
|
+
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13804
13847
|
const bounds = (0, import_geofire_common4.geohashQueryBounds)(
|
|
13805
13848
|
[center.latitude, center.longitude],
|
|
13806
13849
|
rangeInKm * 1e3
|
|
@@ -13823,8 +13866,9 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
13823
13866
|
);
|
|
13824
13867
|
const distanceInKm = distance / 1e3;
|
|
13825
13868
|
if (distanceInKm <= rangeInKm) {
|
|
13869
|
+
const filteredClinic = filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners);
|
|
13826
13870
|
matchingClinics.push({
|
|
13827
|
-
...
|
|
13871
|
+
...filteredClinic,
|
|
13828
13872
|
distance: distanceInKm
|
|
13829
13873
|
});
|
|
13830
13874
|
}
|
|
@@ -14003,6 +14047,9 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14003
14047
|
uniqueMap.set(c.id, c);
|
|
14004
14048
|
}
|
|
14005
14049
|
let clinics = Array.from(uniqueMap.values());
|
|
14050
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14051
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
14052
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14006
14053
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14007
14054
|
const pageSize = filters.pagination || 5;
|
|
14008
14055
|
let startIndex = 0;
|
|
@@ -14056,6 +14103,9 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14056
14103
|
const q = (0, import_firestore38.query)((0, import_firestore38.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
14057
14104
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
14058
14105
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14106
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14107
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
14108
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14059
14109
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14060
14110
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14061
14111
|
console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
|
|
@@ -14088,6 +14138,9 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14088
14138
|
const q = (0, import_firestore38.query)((0, import_firestore38.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
14089
14139
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
14090
14140
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14141
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14142
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
14143
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14091
14144
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14092
14145
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14093
14146
|
console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
|
|
@@ -14569,15 +14622,17 @@ var ClinicService = class extends BaseService {
|
|
|
14569
14622
|
}
|
|
14570
14623
|
/**
|
|
14571
14624
|
* Dohvata kliniku po ID-u
|
|
14625
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14572
14626
|
*/
|
|
14573
|
-
async getClinic(clinicId) {
|
|
14574
|
-
return getClinic(this.db, clinicId);
|
|
14627
|
+
async getClinic(clinicId, excludeDraftPractitioners = false) {
|
|
14628
|
+
return getClinic(this.db, clinicId, excludeDraftPractitioners);
|
|
14575
14629
|
}
|
|
14576
14630
|
/**
|
|
14577
14631
|
* Dohvata sve klinike u grupi
|
|
14632
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14578
14633
|
*/
|
|
14579
|
-
async getClinicsByGroup(groupId) {
|
|
14580
|
-
return getClinicsByGroup(this.db, groupId);
|
|
14634
|
+
async getClinicsByGroup(groupId, excludeDraftPractitioners = false) {
|
|
14635
|
+
return getClinicsByGroup(this.db, groupId, excludeDraftPractitioners);
|
|
14581
14636
|
}
|
|
14582
14637
|
/**
|
|
14583
14638
|
* Pretražuje klinike u određenom radijusu
|
|
@@ -14677,19 +14732,20 @@ var ClinicService = class extends BaseService {
|
|
|
14677
14732
|
});
|
|
14678
14733
|
return clinic;
|
|
14679
14734
|
}
|
|
14680
|
-
async getClinicById(clinicId) {
|
|
14681
|
-
return getClinicById(this.db, clinicId);
|
|
14735
|
+
async getClinicById(clinicId, excludeDraftPractitioners = false) {
|
|
14736
|
+
return getClinicById(this.db, clinicId, excludeDraftPractitioners);
|
|
14682
14737
|
}
|
|
14683
|
-
async getAllClinics(pagination, lastDoc) {
|
|
14684
|
-
return getAllClinics(this.db, pagination, lastDoc);
|
|
14738
|
+
async getAllClinics(pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14739
|
+
return getAllClinics(this.db, pagination, lastDoc, excludeDraftPractitioners);
|
|
14685
14740
|
}
|
|
14686
|
-
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc) {
|
|
14741
|
+
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14687
14742
|
return getAllClinicsInRange(
|
|
14688
14743
|
this.db,
|
|
14689
14744
|
center,
|
|
14690
14745
|
rangeInKm,
|
|
14691
14746
|
pagination,
|
|
14692
|
-
lastDoc
|
|
14747
|
+
lastDoc,
|
|
14748
|
+
excludeDraftPractitioners
|
|
14693
14749
|
);
|
|
14694
14750
|
}
|
|
14695
14751
|
/**
|
|
@@ -20035,7 +20091,11 @@ var ProcedureService = class extends BaseService {
|
|
|
20035
20091
|
* @returns Filtered array of procedures (excluding invalid/inactive/draft practitioners)
|
|
20036
20092
|
*/
|
|
20037
20093
|
async filterDraftPractitionerProcedures(procedures) {
|
|
20094
|
+
console.log(`[ProcedureService] filterDraftPractitionerProcedures called with ${procedures.length} procedures, practitionerService available: ${!!this.practitionerService}`);
|
|
20038
20095
|
if (!this.practitionerService || procedures.length === 0) {
|
|
20096
|
+
if (!this.practitionerService) {
|
|
20097
|
+
console.warn("[ProcedureService] practitionerService not available - skipping filtering");
|
|
20098
|
+
}
|
|
20039
20099
|
return procedures;
|
|
20040
20100
|
}
|
|
20041
20101
|
try {
|
|
@@ -21130,6 +21190,7 @@ var ProcedureService = class extends BaseService {
|
|
|
21130
21190
|
async getProceduresByFilters(filters) {
|
|
21131
21191
|
try {
|
|
21132
21192
|
console.log("[PROCEDURE_SERVICE] Starting procedure filtering with multiple strategies");
|
|
21193
|
+
console.log("excludeDraftPractitioners is : ", filters.excludeDraftPractitioners);
|
|
21133
21194
|
if (filters.location && filters.radiusInKm) {
|
|
21134
21195
|
console.log("[PROCEDURE_SERVICE] Executing geo query:", {
|
|
21135
21196
|
location: filters.location,
|
|
@@ -21219,7 +21280,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21219
21280
|
if (hasNestedFilters) {
|
|
21220
21281
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21221
21282
|
}
|
|
21222
|
-
|
|
21283
|
+
if (filters.excludeDraftPractitioners) {
|
|
21284
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21285
|
+
}
|
|
21223
21286
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
21224
21287
|
console.log(`[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`);
|
|
21225
21288
|
if (procedures.length < (filters.pagination || 10)) {
|
|
@@ -21260,7 +21323,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21260
21323
|
if (hasNestedFilters) {
|
|
21261
21324
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21262
21325
|
}
|
|
21263
|
-
|
|
21326
|
+
if (filters.excludeDraftPractitioners) {
|
|
21327
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21328
|
+
}
|
|
21264
21329
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
21265
21330
|
console.log(`[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`);
|
|
21266
21331
|
if (procedures.length < (filters.pagination || 10)) {
|
|
@@ -21341,7 +21406,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21341
21406
|
}
|
|
21342
21407
|
});
|
|
21343
21408
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21344
|
-
|
|
21409
|
+
if (filters.excludeDraftPractitioners) {
|
|
21410
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21411
|
+
}
|
|
21345
21412
|
console.log("[PROCEDURE_SERVICE] After applyInMemoryFilters (Strategy 3):", {
|
|
21346
21413
|
procedureCount: procedures.length
|
|
21347
21414
|
});
|
|
@@ -21373,7 +21440,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21373
21440
|
(doc47) => ({ ...doc47.data(), id: doc47.id })
|
|
21374
21441
|
);
|
|
21375
21442
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21376
|
-
|
|
21443
|
+
if (filters.excludeDraftPractitioners) {
|
|
21444
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21445
|
+
}
|
|
21377
21446
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
21378
21447
|
console.log(`[PROCEDURE_SERVICE] Strategy 4 success: ${procedures.length} procedures`);
|
|
21379
21448
|
if (procedures.length < (filters.pagination || 10)) {
|
|
@@ -21704,17 +21773,21 @@ var ProcedureService = class extends BaseService {
|
|
|
21704
21773
|
async getProceduresForMap() {
|
|
21705
21774
|
const proceduresRef = (0, import_firestore58.collection)(this.db, PROCEDURES_COLLECTION);
|
|
21706
21775
|
const snapshot = await (0, import_firestore58.getDocs)(proceduresRef);
|
|
21707
|
-
|
|
21776
|
+
let procedures = snapshot.docs.map((doc47) => ({
|
|
21777
|
+
id: doc47.id,
|
|
21778
|
+
...doc47.data()
|
|
21779
|
+
}));
|
|
21780
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21781
|
+
const proceduresForMap = procedures.map((procedure) => {
|
|
21708
21782
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21709
|
-
const data = doc47.data();
|
|
21710
21783
|
return {
|
|
21711
|
-
id:
|
|
21712
|
-
name:
|
|
21713
|
-
clinicId: (_a =
|
|
21714
|
-
clinicName: (_b =
|
|
21715
|
-
address: ((_d = (_c =
|
|
21716
|
-
latitude: (_f = (_e =
|
|
21717
|
-
longitude: (_h = (_g =
|
|
21784
|
+
id: procedure.id,
|
|
21785
|
+
name: procedure.name,
|
|
21786
|
+
clinicId: (_a = procedure.clinicInfo) == null ? void 0 : _a.id,
|
|
21787
|
+
clinicName: (_b = procedure.clinicInfo) == null ? void 0 : _b.name,
|
|
21788
|
+
address: ((_d = (_c = procedure.clinicInfo) == null ? void 0 : _c.location) == null ? void 0 : _d.address) || "",
|
|
21789
|
+
latitude: (_f = (_e = procedure.clinicInfo) == null ? void 0 : _e.location) == null ? void 0 : _f.latitude,
|
|
21790
|
+
longitude: (_h = (_g = procedure.clinicInfo) == null ? void 0 : _g.location) == null ? void 0 : _h.longitude
|
|
21718
21791
|
};
|
|
21719
21792
|
});
|
|
21720
21793
|
return proceduresForMap;
|
|
@@ -21751,10 +21824,12 @@ var ProcedureService = class extends BaseService {
|
|
|
21751
21824
|
(0, import_firestore58.orderBy)("name", "asc")
|
|
21752
21825
|
);
|
|
21753
21826
|
const querySnapshot = await (0, import_firestore58.getDocs)(proceduresQuery);
|
|
21754
|
-
|
|
21827
|
+
let procedures = querySnapshot.docs.map((doc47) => ({
|
|
21755
21828
|
id: doc47.id,
|
|
21756
21829
|
...doc47.data()
|
|
21757
21830
|
}));
|
|
21831
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21832
|
+
return procedures;
|
|
21758
21833
|
}
|
|
21759
21834
|
};
|
|
21760
21835
|
|
package/dist/index.mjs
CHANGED
|
@@ -13604,22 +13604,63 @@ import {
|
|
|
13604
13604
|
geohashQueryBounds
|
|
13605
13605
|
} from "geofire-common";
|
|
13606
13606
|
import { z as z20 } from "zod";
|
|
13607
|
-
|
|
13607
|
+
function filterDoctorsInfo(doctorsInfo) {
|
|
13608
|
+
if (!doctorsInfo || doctorsInfo.length === 0) {
|
|
13609
|
+
return [];
|
|
13610
|
+
}
|
|
13611
|
+
return doctorsInfo.filter((doctor) => {
|
|
13612
|
+
if (doctor.status === "draft" /* DRAFT */) {
|
|
13613
|
+
console.log(`[CLINIC_UTILS] Filtering out draft practitioner ${doctor.id} from doctorsInfo`);
|
|
13614
|
+
return false;
|
|
13615
|
+
}
|
|
13616
|
+
if (doctor.isActive === false) {
|
|
13617
|
+
console.log(`[CLINIC_UTILS] Filtering out inactive practitioner ${doctor.id} from doctorsInfo`);
|
|
13618
|
+
return false;
|
|
13619
|
+
}
|
|
13620
|
+
return true;
|
|
13621
|
+
});
|
|
13622
|
+
}
|
|
13623
|
+
function filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners = false) {
|
|
13624
|
+
if (!clinic) {
|
|
13625
|
+
return clinic;
|
|
13626
|
+
}
|
|
13627
|
+
console.log(`[CLINIC_UTILS] filterClinicEmbeddedArrays called for clinic ${clinic.id} with excludeDraftPractitioners: ${excludeDraftPractitioners}`);
|
|
13628
|
+
if (!excludeDraftPractitioners) {
|
|
13629
|
+
console.log(`[CLINIC_UTILS] Skipping filtering for clinic ${clinic.id} (excludeDraftPractitioners is false)`);
|
|
13630
|
+
return clinic;
|
|
13631
|
+
}
|
|
13632
|
+
const filteredClinic = { ...clinic };
|
|
13633
|
+
if (filteredClinic.doctorsInfo && filteredClinic.doctorsInfo.length > 0) {
|
|
13634
|
+
const originalLength = filteredClinic.doctorsInfo.length;
|
|
13635
|
+
filteredClinic.doctorsInfo = filterDoctorsInfo(filteredClinic.doctorsInfo);
|
|
13636
|
+
if (filteredClinic.doctorsInfo.length !== originalLength) {
|
|
13637
|
+
console.log(
|
|
13638
|
+
`[CLINIC_UTILS] Filtered ${originalLength - filteredClinic.doctorsInfo.length} draft/inactive doctors from clinic ${clinic.id}`
|
|
13639
|
+
);
|
|
13640
|
+
}
|
|
13641
|
+
}
|
|
13642
|
+
return filteredClinic;
|
|
13643
|
+
}
|
|
13644
|
+
async function getClinic(db, clinicId, excludeDraftPractitioners = false) {
|
|
13608
13645
|
const docRef = doc23(db, CLINICS_COLLECTION, clinicId);
|
|
13609
13646
|
const docSnap = await getDoc25(docRef);
|
|
13610
13647
|
if (docSnap.exists()) {
|
|
13611
|
-
|
|
13648
|
+
const clinicData = docSnap.data();
|
|
13649
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13612
13650
|
}
|
|
13613
13651
|
return null;
|
|
13614
13652
|
}
|
|
13615
|
-
async function getClinicsByGroup(db, groupId) {
|
|
13653
|
+
async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false) {
|
|
13616
13654
|
const q = query17(
|
|
13617
13655
|
collection17(db, CLINICS_COLLECTION),
|
|
13618
13656
|
where17("clinicGroupId", "==", groupId),
|
|
13619
13657
|
where17("isActive", "==", true)
|
|
13620
13658
|
);
|
|
13621
13659
|
const querySnapshot = await getDocs17(q);
|
|
13622
|
-
return querySnapshot.docs.map((doc47) =>
|
|
13660
|
+
return querySnapshot.docs.map((doc47) => {
|
|
13661
|
+
const clinicData = doc47.data();
|
|
13662
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13663
|
+
});
|
|
13623
13664
|
}
|
|
13624
13665
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
13625
13666
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -13824,7 +13865,7 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
|
|
|
13824
13865
|
clinicGroupService
|
|
13825
13866
|
);
|
|
13826
13867
|
}
|
|
13827
|
-
async function getClinicById(db, clinicId) {
|
|
13868
|
+
async function getClinicById(db, clinicId, excludeDraftPractitioners = false) {
|
|
13828
13869
|
try {
|
|
13829
13870
|
const clinicRef = doc23(db, CLINICS_COLLECTION, clinicId);
|
|
13830
13871
|
const clinicSnapshot = await getDoc25(clinicRef);
|
|
@@ -13832,16 +13873,17 @@ async function getClinicById(db, clinicId) {
|
|
|
13832
13873
|
return null;
|
|
13833
13874
|
}
|
|
13834
13875
|
const clinicData = clinicSnapshot.data();
|
|
13835
|
-
|
|
13876
|
+
const clinicWithId = {
|
|
13836
13877
|
...clinicData,
|
|
13837
13878
|
id: clinicSnapshot.id
|
|
13838
13879
|
};
|
|
13880
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13839
13881
|
} catch (error) {
|
|
13840
13882
|
console.error("[CLINIC_UTILS] Error getting clinic by ID:", error);
|
|
13841
13883
|
throw error;
|
|
13842
13884
|
}
|
|
13843
13885
|
}
|
|
13844
|
-
async function getAllClinics(db, pagination, lastDoc) {
|
|
13886
|
+
async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13845
13887
|
try {
|
|
13846
13888
|
const clinicsCollection = collection17(db, CLINICS_COLLECTION);
|
|
13847
13889
|
let clinicsQuery = query17(clinicsCollection);
|
|
@@ -13860,10 +13902,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13860
13902
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
13861
13903
|
const clinics = clinicsSnapshot.docs.map((doc47) => {
|
|
13862
13904
|
const data = doc47.data();
|
|
13863
|
-
|
|
13905
|
+
const clinicWithId = {
|
|
13864
13906
|
...data,
|
|
13865
13907
|
id: doc47.id
|
|
13866
13908
|
};
|
|
13909
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13867
13910
|
});
|
|
13868
13911
|
return {
|
|
13869
13912
|
clinics,
|
|
@@ -13874,7 +13917,7 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13874
13917
|
throw error;
|
|
13875
13918
|
}
|
|
13876
13919
|
}
|
|
13877
|
-
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc) {
|
|
13920
|
+
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13878
13921
|
const bounds = geohashQueryBounds(
|
|
13879
13922
|
[center.latitude, center.longitude],
|
|
13880
13923
|
rangeInKm * 1e3
|
|
@@ -13897,8 +13940,9 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
13897
13940
|
);
|
|
13898
13941
|
const distanceInKm = distance / 1e3;
|
|
13899
13942
|
if (distanceInKm <= rangeInKm) {
|
|
13943
|
+
const filteredClinic = filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners);
|
|
13900
13944
|
matchingClinics.push({
|
|
13901
|
-
...
|
|
13945
|
+
...filteredClinic,
|
|
13902
13946
|
distance: distanceInKm
|
|
13903
13947
|
});
|
|
13904
13948
|
}
|
|
@@ -14090,6 +14134,9 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14090
14134
|
uniqueMap.set(c.id, c);
|
|
14091
14135
|
}
|
|
14092
14136
|
let clinics = Array.from(uniqueMap.values());
|
|
14137
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14138
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
14139
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14093
14140
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14094
14141
|
const pageSize = filters.pagination || 5;
|
|
14095
14142
|
let startIndex = 0;
|
|
@@ -14143,6 +14190,9 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14143
14190
|
const q = query19(collection19(db, CLINICS_COLLECTION), ...constraints);
|
|
14144
14191
|
const querySnapshot = await getDocs19(q);
|
|
14145
14192
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14193
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14194
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
14195
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14146
14196
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14147
14197
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14148
14198
|
console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
|
|
@@ -14175,6 +14225,9 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14175
14225
|
const q = query19(collection19(db, CLINICS_COLLECTION), ...constraints);
|
|
14176
14226
|
const querySnapshot = await getDocs19(q);
|
|
14177
14227
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14228
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14229
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
14230
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14178
14231
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14179
14232
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14180
14233
|
console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
|
|
@@ -14656,15 +14709,17 @@ var ClinicService = class extends BaseService {
|
|
|
14656
14709
|
}
|
|
14657
14710
|
/**
|
|
14658
14711
|
* Dohvata kliniku po ID-u
|
|
14712
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14659
14713
|
*/
|
|
14660
|
-
async getClinic(clinicId) {
|
|
14661
|
-
return getClinic(this.db, clinicId);
|
|
14714
|
+
async getClinic(clinicId, excludeDraftPractitioners = false) {
|
|
14715
|
+
return getClinic(this.db, clinicId, excludeDraftPractitioners);
|
|
14662
14716
|
}
|
|
14663
14717
|
/**
|
|
14664
14718
|
* Dohvata sve klinike u grupi
|
|
14719
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14665
14720
|
*/
|
|
14666
|
-
async getClinicsByGroup(groupId) {
|
|
14667
|
-
return getClinicsByGroup(this.db, groupId);
|
|
14721
|
+
async getClinicsByGroup(groupId, excludeDraftPractitioners = false) {
|
|
14722
|
+
return getClinicsByGroup(this.db, groupId, excludeDraftPractitioners);
|
|
14668
14723
|
}
|
|
14669
14724
|
/**
|
|
14670
14725
|
* Pretražuje klinike u određenom radijusu
|
|
@@ -14764,19 +14819,20 @@ var ClinicService = class extends BaseService {
|
|
|
14764
14819
|
});
|
|
14765
14820
|
return clinic;
|
|
14766
14821
|
}
|
|
14767
|
-
async getClinicById(clinicId) {
|
|
14768
|
-
return getClinicById(this.db, clinicId);
|
|
14822
|
+
async getClinicById(clinicId, excludeDraftPractitioners = false) {
|
|
14823
|
+
return getClinicById(this.db, clinicId, excludeDraftPractitioners);
|
|
14769
14824
|
}
|
|
14770
|
-
async getAllClinics(pagination, lastDoc) {
|
|
14771
|
-
return getAllClinics(this.db, pagination, lastDoc);
|
|
14825
|
+
async getAllClinics(pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14826
|
+
return getAllClinics(this.db, pagination, lastDoc, excludeDraftPractitioners);
|
|
14772
14827
|
}
|
|
14773
|
-
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc) {
|
|
14828
|
+
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14774
14829
|
return getAllClinicsInRange(
|
|
14775
14830
|
this.db,
|
|
14776
14831
|
center,
|
|
14777
14832
|
rangeInKm,
|
|
14778
14833
|
pagination,
|
|
14779
|
-
lastDoc
|
|
14834
|
+
lastDoc,
|
|
14835
|
+
excludeDraftPractitioners
|
|
14780
14836
|
);
|
|
14781
14837
|
}
|
|
14782
14838
|
/**
|
|
@@ -20271,7 +20327,11 @@ var ProcedureService = class extends BaseService {
|
|
|
20271
20327
|
* @returns Filtered array of procedures (excluding invalid/inactive/draft practitioners)
|
|
20272
20328
|
*/
|
|
20273
20329
|
async filterDraftPractitionerProcedures(procedures) {
|
|
20330
|
+
console.log(`[ProcedureService] filterDraftPractitionerProcedures called with ${procedures.length} procedures, practitionerService available: ${!!this.practitionerService}`);
|
|
20274
20331
|
if (!this.practitionerService || procedures.length === 0) {
|
|
20332
|
+
if (!this.practitionerService) {
|
|
20333
|
+
console.warn("[ProcedureService] practitionerService not available - skipping filtering");
|
|
20334
|
+
}
|
|
20275
20335
|
return procedures;
|
|
20276
20336
|
}
|
|
20277
20337
|
try {
|
|
@@ -21366,6 +21426,7 @@ var ProcedureService = class extends BaseService {
|
|
|
21366
21426
|
async getProceduresByFilters(filters) {
|
|
21367
21427
|
try {
|
|
21368
21428
|
console.log("[PROCEDURE_SERVICE] Starting procedure filtering with multiple strategies");
|
|
21429
|
+
console.log("excludeDraftPractitioners is : ", filters.excludeDraftPractitioners);
|
|
21369
21430
|
if (filters.location && filters.radiusInKm) {
|
|
21370
21431
|
console.log("[PROCEDURE_SERVICE] Executing geo query:", {
|
|
21371
21432
|
location: filters.location,
|
|
@@ -21455,7 +21516,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21455
21516
|
if (hasNestedFilters) {
|
|
21456
21517
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21457
21518
|
}
|
|
21458
|
-
|
|
21519
|
+
if (filters.excludeDraftPractitioners) {
|
|
21520
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21521
|
+
}
|
|
21459
21522
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
21460
21523
|
console.log(`[PROCEDURE_SERVICE] Strategy 1 success: ${procedures.length} procedures`);
|
|
21461
21524
|
if (procedures.length < (filters.pagination || 10)) {
|
|
@@ -21496,7 +21559,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21496
21559
|
if (hasNestedFilters) {
|
|
21497
21560
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21498
21561
|
}
|
|
21499
|
-
|
|
21562
|
+
if (filters.excludeDraftPractitioners) {
|
|
21563
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21564
|
+
}
|
|
21500
21565
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
21501
21566
|
console.log(`[PROCEDURE_SERVICE] Strategy 2 success: ${procedures.length} procedures`);
|
|
21502
21567
|
if (procedures.length < (filters.pagination || 10)) {
|
|
@@ -21577,7 +21642,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21577
21642
|
}
|
|
21578
21643
|
});
|
|
21579
21644
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21580
|
-
|
|
21645
|
+
if (filters.excludeDraftPractitioners) {
|
|
21646
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21647
|
+
}
|
|
21581
21648
|
console.log("[PROCEDURE_SERVICE] After applyInMemoryFilters (Strategy 3):", {
|
|
21582
21649
|
procedureCount: procedures.length
|
|
21583
21650
|
});
|
|
@@ -21609,7 +21676,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21609
21676
|
(doc47) => ({ ...doc47.data(), id: doc47.id })
|
|
21610
21677
|
);
|
|
21611
21678
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
21612
|
-
|
|
21679
|
+
if (filters.excludeDraftPractitioners) {
|
|
21680
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21681
|
+
}
|
|
21613
21682
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
21614
21683
|
console.log(`[PROCEDURE_SERVICE] Strategy 4 success: ${procedures.length} procedures`);
|
|
21615
21684
|
if (procedures.length < (filters.pagination || 10)) {
|
|
@@ -21940,17 +22009,21 @@ var ProcedureService = class extends BaseService {
|
|
|
21940
22009
|
async getProceduresForMap() {
|
|
21941
22010
|
const proceduresRef = collection33(this.db, PROCEDURES_COLLECTION);
|
|
21942
22011
|
const snapshot = await getDocs33(proceduresRef);
|
|
21943
|
-
|
|
22012
|
+
let procedures = snapshot.docs.map((doc47) => ({
|
|
22013
|
+
id: doc47.id,
|
|
22014
|
+
...doc47.data()
|
|
22015
|
+
}));
|
|
22016
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
22017
|
+
const proceduresForMap = procedures.map((procedure) => {
|
|
21944
22018
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21945
|
-
const data = doc47.data();
|
|
21946
22019
|
return {
|
|
21947
|
-
id:
|
|
21948
|
-
name:
|
|
21949
|
-
clinicId: (_a =
|
|
21950
|
-
clinicName: (_b =
|
|
21951
|
-
address: ((_d = (_c =
|
|
21952
|
-
latitude: (_f = (_e =
|
|
21953
|
-
longitude: (_h = (_g =
|
|
22020
|
+
id: procedure.id,
|
|
22021
|
+
name: procedure.name,
|
|
22022
|
+
clinicId: (_a = procedure.clinicInfo) == null ? void 0 : _a.id,
|
|
22023
|
+
clinicName: (_b = procedure.clinicInfo) == null ? void 0 : _b.name,
|
|
22024
|
+
address: ((_d = (_c = procedure.clinicInfo) == null ? void 0 : _c.location) == null ? void 0 : _d.address) || "",
|
|
22025
|
+
latitude: (_f = (_e = procedure.clinicInfo) == null ? void 0 : _e.location) == null ? void 0 : _f.latitude,
|
|
22026
|
+
longitude: (_h = (_g = procedure.clinicInfo) == null ? void 0 : _g.location) == null ? void 0 : _h.longitude
|
|
21954
22027
|
};
|
|
21955
22028
|
});
|
|
21956
22029
|
return proceduresForMap;
|
|
@@ -21987,10 +22060,12 @@ var ProcedureService = class extends BaseService {
|
|
|
21987
22060
|
orderBy18("name", "asc")
|
|
21988
22061
|
);
|
|
21989
22062
|
const querySnapshot = await getDocs33(proceduresQuery);
|
|
21990
|
-
|
|
22063
|
+
let procedures = querySnapshot.docs.map((doc47) => ({
|
|
21991
22064
|
id: doc47.id,
|
|
21992
22065
|
...doc47.data()
|
|
21993
22066
|
}));
|
|
22067
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
22068
|
+
return procedures;
|
|
21994
22069
|
}
|
|
21995
22070
|
};
|
|
21996
22071
|
|
package/package.json
CHANGED
|
@@ -468,16 +468,18 @@ export class ClinicService extends BaseService {
|
|
|
468
468
|
|
|
469
469
|
/**
|
|
470
470
|
* Dohvata kliniku po ID-u
|
|
471
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
471
472
|
*/
|
|
472
|
-
async getClinic(clinicId: string): Promise<Clinic | null> {
|
|
473
|
-
return ClinicUtils.getClinic(this.db, clinicId);
|
|
473
|
+
async getClinic(clinicId: string, excludeDraftPractitioners: boolean = false): Promise<Clinic | null> {
|
|
474
|
+
return ClinicUtils.getClinic(this.db, clinicId, excludeDraftPractitioners);
|
|
474
475
|
}
|
|
475
476
|
|
|
476
477
|
/**
|
|
477
478
|
* Dohvata sve klinike u grupi
|
|
479
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
478
480
|
*/
|
|
479
|
-
async getClinicsByGroup(groupId: string): Promise<Clinic[]> {
|
|
480
|
-
return ClinicUtils.getClinicsByGroup(this.db, groupId);
|
|
481
|
+
async getClinicsByGroup(groupId: string, excludeDraftPractitioners: boolean = false): Promise<Clinic[]> {
|
|
482
|
+
return ClinicUtils.getClinicsByGroup(this.db, groupId, excludeDraftPractitioners);
|
|
481
483
|
}
|
|
482
484
|
|
|
483
485
|
/**
|
|
@@ -624,29 +626,32 @@ export class ClinicService extends BaseService {
|
|
|
624
626
|
return clinic;
|
|
625
627
|
}
|
|
626
628
|
|
|
627
|
-
async getClinicById(clinicId: string): Promise<Clinic | null> {
|
|
628
|
-
return ClinicUtils.getClinicById(this.db, clinicId);
|
|
629
|
+
async getClinicById(clinicId: string, excludeDraftPractitioners: boolean = false): Promise<Clinic | null> {
|
|
630
|
+
return ClinicUtils.getClinicById(this.db, clinicId, excludeDraftPractitioners);
|
|
629
631
|
}
|
|
630
632
|
|
|
631
633
|
async getAllClinics(
|
|
632
634
|
pagination?: number,
|
|
633
|
-
lastDoc?: any
|
|
635
|
+
lastDoc?: any,
|
|
636
|
+
excludeDraftPractitioners: boolean = false
|
|
634
637
|
): Promise<{ clinics: Clinic[]; lastDoc: any }> {
|
|
635
|
-
return ClinicUtils.getAllClinics(this.db, pagination, lastDoc);
|
|
638
|
+
return ClinicUtils.getAllClinics(this.db, pagination, lastDoc, excludeDraftPractitioners);
|
|
636
639
|
}
|
|
637
640
|
|
|
638
641
|
async getAllClinicsInRange(
|
|
639
642
|
center: { latitude: number; longitude: number },
|
|
640
643
|
rangeInKm: number,
|
|
641
644
|
pagination?: number,
|
|
642
|
-
lastDoc?: any
|
|
645
|
+
lastDoc?: any,
|
|
646
|
+
excludeDraftPractitioners: boolean = false
|
|
643
647
|
): Promise<{ clinics: (Clinic & { distance: number })[]; lastDoc: any }> {
|
|
644
648
|
return ClinicUtils.getAllClinicsInRange(
|
|
645
649
|
this.db,
|
|
646
650
|
center,
|
|
647
651
|
rangeInKm,
|
|
648
652
|
pagination,
|
|
649
|
-
lastDoc
|
|
653
|
+
lastDoc,
|
|
654
|
+
excludeDraftPractitioners
|
|
650
655
|
);
|
|
651
656
|
}
|
|
652
657
|
|
|
@@ -24,7 +24,9 @@ import {
|
|
|
24
24
|
ClinicGroup,
|
|
25
25
|
ClinicBranchSetupData,
|
|
26
26
|
ClinicLocation,
|
|
27
|
+
DoctorInfo,
|
|
27
28
|
} from "../../../types/clinic";
|
|
29
|
+
import { PractitionerStatus } from "../../../types/practitioner";
|
|
28
30
|
import {
|
|
29
31
|
geohashForLocation,
|
|
30
32
|
distanceBetween,
|
|
@@ -384,15 +386,84 @@ export async function createClinic(
|
|
|
384
386
|
* @param clinicId - ID of the clinic to get
|
|
385
387
|
* @returns The clinic or null if not found
|
|
386
388
|
*/
|
|
389
|
+
/**
|
|
390
|
+
* Filters out draft/inactive practitioners from doctorsInfo array
|
|
391
|
+
* @param doctorsInfo Array of doctor info objects
|
|
392
|
+
* @returns Filtered array excluding draft or inactive practitioners
|
|
393
|
+
*/
|
|
394
|
+
function filterDoctorsInfo(doctorsInfo: DoctorInfo[]): DoctorInfo[] {
|
|
395
|
+
if (!doctorsInfo || doctorsInfo.length === 0) {
|
|
396
|
+
return [];
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return doctorsInfo.filter((doctor) => {
|
|
400
|
+
// Filter out if status is DRAFT
|
|
401
|
+
if (doctor.status === PractitionerStatus.DRAFT) {
|
|
402
|
+
console.log(`[CLINIC_UTILS] Filtering out draft practitioner ${doctor.id} from doctorsInfo`);
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Filter out if isActive is explicitly false
|
|
407
|
+
if (doctor.isActive === false) {
|
|
408
|
+
console.log(`[CLINIC_UTILS] Filtering out inactive practitioner ${doctor.id} from doctorsInfo`);
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Include if status is ACTIVE or undefined (backward compatibility) and isActive is true or undefined
|
|
413
|
+
return true;
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Filters embedded arrays in a Clinic object to exclude draft/inactive practitioners
|
|
419
|
+
* @param clinic Clinic object to filter
|
|
420
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
421
|
+
* @returns Clinic object with filtered embedded arrays
|
|
422
|
+
*/
|
|
423
|
+
export function filterClinicEmbeddedArrays(clinic: Clinic, excludeDraftPractitioners: boolean = false): Clinic {
|
|
424
|
+
if (!clinic) {
|
|
425
|
+
return clinic;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
console.log(`[CLINIC_UTILS] filterClinicEmbeddedArrays called for clinic ${clinic.id} with excludeDraftPractitioners: ${excludeDraftPractitioners}`);
|
|
429
|
+
|
|
430
|
+
// If excluding drafts is disabled (default), return clinic as-is (for admin views)
|
|
431
|
+
if (!excludeDraftPractitioners) {
|
|
432
|
+
console.log(`[CLINIC_UTILS] Skipping filtering for clinic ${clinic.id} (excludeDraftPractitioners is false)`);
|
|
433
|
+
return clinic;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const filteredClinic = { ...clinic };
|
|
437
|
+
|
|
438
|
+
// Filter doctorsInfo array
|
|
439
|
+
if (filteredClinic.doctorsInfo && filteredClinic.doctorsInfo.length > 0) {
|
|
440
|
+
const originalLength = filteredClinic.doctorsInfo.length;
|
|
441
|
+
filteredClinic.doctorsInfo = filterDoctorsInfo(filteredClinic.doctorsInfo);
|
|
442
|
+
if (filteredClinic.doctorsInfo.length !== originalLength) {
|
|
443
|
+
console.log(
|
|
444
|
+
`[CLINIC_UTILS] Filtered ${originalLength - filteredClinic.doctorsInfo.length} draft/inactive doctors from clinic ${clinic.id}`
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Note: proceduresInfo doesn't have embedded status/isActive, so we rely on
|
|
450
|
+
// Cloud Functions to not include procedures from draft/inactive practitioners.
|
|
451
|
+
// If needed, we could add additional filtering here by checking practitioner status.
|
|
452
|
+
|
|
453
|
+
return filteredClinic;
|
|
454
|
+
}
|
|
455
|
+
|
|
387
456
|
export async function getClinic(
|
|
388
457
|
db: Firestore,
|
|
389
|
-
clinicId: string
|
|
458
|
+
clinicId: string,
|
|
459
|
+
excludeDraftPractitioners: boolean = false
|
|
390
460
|
): Promise<Clinic | null> {
|
|
391
461
|
const docRef = doc(db, CLINICS_COLLECTION, clinicId);
|
|
392
462
|
const docSnap = await getDoc(docRef);
|
|
393
463
|
|
|
394
464
|
if (docSnap.exists()) {
|
|
395
|
-
|
|
465
|
+
const clinicData = docSnap.data() as Clinic;
|
|
466
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
396
467
|
}
|
|
397
468
|
|
|
398
469
|
return null;
|
|
@@ -406,7 +477,8 @@ export async function getClinic(
|
|
|
406
477
|
*/
|
|
407
478
|
export async function getClinicsByGroup(
|
|
408
479
|
db: Firestore,
|
|
409
|
-
groupId: string
|
|
480
|
+
groupId: string,
|
|
481
|
+
excludeDraftPractitioners: boolean = false
|
|
410
482
|
): Promise<Clinic[]> {
|
|
411
483
|
const q = query(
|
|
412
484
|
collection(db, CLINICS_COLLECTION),
|
|
@@ -415,7 +487,10 @@ export async function getClinicsByGroup(
|
|
|
415
487
|
);
|
|
416
488
|
|
|
417
489
|
const querySnapshot = await getDocs(q);
|
|
418
|
-
return querySnapshot.docs.map((doc) =>
|
|
490
|
+
return querySnapshot.docs.map((doc) => {
|
|
491
|
+
const clinicData = doc.data() as Clinic;
|
|
492
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
493
|
+
});
|
|
419
494
|
}
|
|
420
495
|
|
|
421
496
|
/**
|
|
@@ -789,7 +864,8 @@ export async function getActiveClinicsByAdmin(
|
|
|
789
864
|
*/
|
|
790
865
|
export async function getClinicById(
|
|
791
866
|
db: Firestore,
|
|
792
|
-
clinicId: string
|
|
867
|
+
clinicId: string,
|
|
868
|
+
excludeDraftPractitioners: boolean = false
|
|
793
869
|
): Promise<Clinic | null> {
|
|
794
870
|
try {
|
|
795
871
|
const clinicRef = doc(db, CLINICS_COLLECTION, clinicId);
|
|
@@ -800,10 +876,11 @@ export async function getClinicById(
|
|
|
800
876
|
}
|
|
801
877
|
|
|
802
878
|
const clinicData = clinicSnapshot.data() as Clinic;
|
|
803
|
-
|
|
879
|
+
const clinicWithId = {
|
|
804
880
|
...clinicData,
|
|
805
881
|
id: clinicSnapshot.id,
|
|
806
882
|
};
|
|
883
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
807
884
|
} catch (error) {
|
|
808
885
|
console.error("[CLINIC_UTILS] Error getting clinic by ID:", error);
|
|
809
886
|
throw error;
|
|
@@ -821,7 +898,8 @@ export async function getClinicById(
|
|
|
821
898
|
export async function getAllClinics(
|
|
822
899
|
db: Firestore,
|
|
823
900
|
pagination?: number,
|
|
824
|
-
lastDoc?: any
|
|
901
|
+
lastDoc?: any,
|
|
902
|
+
excludeDraftPractitioners: boolean = false
|
|
825
903
|
): Promise<{ clinics: Clinic[]; lastDoc: any }> {
|
|
826
904
|
try {
|
|
827
905
|
const clinicsCollection = collection(db, CLINICS_COLLECTION);
|
|
@@ -845,10 +923,11 @@ export async function getAllClinics(
|
|
|
845
923
|
|
|
846
924
|
const clinics = clinicsSnapshot.docs.map((doc) => {
|
|
847
925
|
const data = doc.data() as Clinic;
|
|
848
|
-
|
|
926
|
+
const clinicWithId = {
|
|
849
927
|
...data,
|
|
850
928
|
id: doc.id,
|
|
851
929
|
};
|
|
930
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
852
931
|
});
|
|
853
932
|
|
|
854
933
|
return {
|
|
@@ -876,7 +955,8 @@ export async function getAllClinicsInRange(
|
|
|
876
955
|
center: { latitude: number; longitude: number },
|
|
877
956
|
rangeInKm: number,
|
|
878
957
|
pagination?: number,
|
|
879
|
-
lastDoc?: any
|
|
958
|
+
lastDoc?: any,
|
|
959
|
+
excludeDraftPractitioners: boolean = false
|
|
880
960
|
): Promise<{ clinics: (Clinic & { distance: number })[]; lastDoc: any }> {
|
|
881
961
|
const bounds = geohashQueryBounds(
|
|
882
962
|
[center.latitude, center.longitude],
|
|
@@ -907,8 +987,9 @@ export async function getAllClinicsInRange(
|
|
|
907
987
|
const distanceInKm = distance / 1000;
|
|
908
988
|
|
|
909
989
|
if (distanceInKm <= rangeInKm) {
|
|
990
|
+
const filteredClinic = filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners);
|
|
910
991
|
matchingClinics.push({
|
|
911
|
-
...
|
|
992
|
+
...filteredClinic,
|
|
912
993
|
distance: distanceInKm,
|
|
913
994
|
});
|
|
914
995
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from 'firebase/firestore';
|
|
13
13
|
import { Clinic, ClinicTag, CLINICS_COLLECTION } from '../../../types/clinic';
|
|
14
14
|
import { geohashQueryBounds, distanceBetween } from 'geofire-common';
|
|
15
|
+
import { filterClinicEmbeddedArrays } from './clinic.utils';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Get clinics based on multiple filtering criteria with fallback strategies
|
|
@@ -36,6 +37,7 @@ export async function getClinicsByFilters(
|
|
|
36
37
|
pagination?: number;
|
|
37
38
|
lastDoc?: any;
|
|
38
39
|
isActive?: boolean;
|
|
40
|
+
excludeDraftPractitioners?: boolean; // If true, filters out draft/inactive practitioners. If false (default), returns all
|
|
39
41
|
},
|
|
40
42
|
): Promise<{
|
|
41
43
|
clinics: (Clinic & { distance?: number })[];
|
|
@@ -94,6 +96,11 @@ export async function getClinicsByFilters(
|
|
|
94
96
|
}
|
|
95
97
|
let clinics = Array.from(uniqueMap.values());
|
|
96
98
|
|
|
99
|
+
// Filter embedded arrays (draft/inactive practitioners) only if explicitly requested
|
|
100
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true; // Default to false (show all)
|
|
101
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
102
|
+
clinics = clinics.map(clinic => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
103
|
+
|
|
97
104
|
// Apply all remaining filters and compute exact distance + sorting
|
|
98
105
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
99
106
|
|
|
@@ -162,6 +169,11 @@ export async function getClinicsByFilters(
|
|
|
162
169
|
const querySnapshot = await getDocs(q);
|
|
163
170
|
let clinics = querySnapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id } as Clinic));
|
|
164
171
|
|
|
172
|
+
// Filter embedded arrays (draft/inactive practitioners) only if explicitly requested
|
|
173
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true; // Default to false (show all)
|
|
174
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
175
|
+
clinics = clinics.map(clinic => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
176
|
+
|
|
165
177
|
// Apply in-memory filters
|
|
166
178
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
167
179
|
|
|
@@ -205,6 +217,11 @@ export async function getClinicsByFilters(
|
|
|
205
217
|
const querySnapshot = await getDocs(q);
|
|
206
218
|
let clinics = querySnapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id } as Clinic));
|
|
207
219
|
|
|
220
|
+
// Filter embedded arrays (draft/inactive practitioners) only if explicitly requested
|
|
221
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true; // Default to false (show all)
|
|
222
|
+
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
223
|
+
clinics = clinics.map(clinic => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
224
|
+
|
|
208
225
|
// Apply in-memory filters
|
|
209
226
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
210
227
|
|
|
@@ -105,7 +105,11 @@ export class ProcedureService extends BaseService {
|
|
|
105
105
|
private async filterDraftPractitionerProcedures(
|
|
106
106
|
procedures: Procedure[]
|
|
107
107
|
): Promise<Procedure[]> {
|
|
108
|
+
console.log(`[ProcedureService] filterDraftPractitionerProcedures called with ${procedures.length} procedures, practitionerService available: ${!!this.practitionerService}`);
|
|
108
109
|
if (!this.practitionerService || procedures.length === 0) {
|
|
110
|
+
if (!this.practitionerService) {
|
|
111
|
+
console.warn('[ProcedureService] practitionerService not available - skipping filtering');
|
|
112
|
+
}
|
|
109
113
|
return procedures;
|
|
110
114
|
}
|
|
111
115
|
|
|
@@ -1533,12 +1537,14 @@ export class ProcedureService extends BaseService {
|
|
|
1533
1537
|
isActive?: boolean;
|
|
1534
1538
|
practitionerId?: string;
|
|
1535
1539
|
clinicId?: string;
|
|
1540
|
+
excludeDraftPractitioners?: boolean;
|
|
1536
1541
|
}): Promise<{
|
|
1537
1542
|
procedures: (Procedure & { distance?: number })[];
|
|
1538
1543
|
lastDoc: any;
|
|
1539
1544
|
}> {
|
|
1540
1545
|
try {
|
|
1541
1546
|
console.log('[PROCEDURE_SERVICE] Starting procedure filtering with multiple strategies');
|
|
1547
|
+
console.log("excludeDraftPractitioners is : ", filters.excludeDraftPractitioners)
|
|
1542
1548
|
|
|
1543
1549
|
// Geo query debug i validacija
|
|
1544
1550
|
if (filters.location && filters.radiusInKm) {
|
|
@@ -1652,8 +1658,10 @@ export class ProcedureService extends BaseService {
|
|
|
1652
1658
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
1653
1659
|
}
|
|
1654
1660
|
|
|
1655
|
-
// Filter out procedures from draft practitioners
|
|
1656
|
-
|
|
1661
|
+
// Filter out procedures from draft practitioners if requested
|
|
1662
|
+
if (filters.excludeDraftPractitioners) {
|
|
1663
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
1664
|
+
}
|
|
1657
1665
|
|
|
1658
1666
|
const lastDoc =
|
|
1659
1667
|
querySnapshot.docs.length > 0
|
|
@@ -1713,7 +1721,9 @@ export class ProcedureService extends BaseService {
|
|
|
1713
1721
|
}
|
|
1714
1722
|
|
|
1715
1723
|
// Filter out procedures from draft practitioners
|
|
1716
|
-
|
|
1724
|
+
if(filters.excludeDraftPractitioners){
|
|
1725
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
1726
|
+
}
|
|
1717
1727
|
|
|
1718
1728
|
const lastDoc =
|
|
1719
1729
|
querySnapshot.docs.length > 0
|
|
@@ -1826,7 +1836,9 @@ export class ProcedureService extends BaseService {
|
|
|
1826
1836
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
1827
1837
|
|
|
1828
1838
|
// Filter out procedures from draft practitioners
|
|
1829
|
-
|
|
1839
|
+
if(filters.excludeDraftPractitioners){
|
|
1840
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
1841
|
+
}
|
|
1830
1842
|
|
|
1831
1843
|
console.log('[PROCEDURE_SERVICE] After applyInMemoryFilters (Strategy 3):', {
|
|
1832
1844
|
procedureCount: procedures.length,
|
|
@@ -1870,7 +1882,9 @@ export class ProcedureService extends BaseService {
|
|
|
1870
1882
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
1871
1883
|
|
|
1872
1884
|
// Filter out procedures from draft practitioners
|
|
1873
|
-
|
|
1885
|
+
if(filters.excludeDraftPractitioners){
|
|
1886
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
1887
|
+
}
|
|
1874
1888
|
|
|
1875
1889
|
const lastDoc =
|
|
1876
1890
|
querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -2300,18 +2314,23 @@ export class ProcedureService extends BaseService {
|
|
|
2300
2314
|
> {
|
|
2301
2315
|
const proceduresRef = collection(this.db, PROCEDURES_COLLECTION);
|
|
2302
2316
|
const snapshot = await getDocs(proceduresRef);
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2317
|
+
let procedures = snapshot.docs.map(doc => ({
|
|
2318
|
+
id: doc.id,
|
|
2319
|
+
...doc.data(),
|
|
2320
|
+
} as Procedure));
|
|
2321
|
+
|
|
2322
|
+
// Filter out procedures with draft/inactive practitioners
|
|
2323
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
2324
|
+
|
|
2325
|
+
const proceduresForMap = procedures.map(procedure => ({
|
|
2326
|
+
id: procedure.id,
|
|
2327
|
+
name: procedure.name,
|
|
2328
|
+
clinicId: procedure.clinicInfo?.id,
|
|
2329
|
+
clinicName: procedure.clinicInfo?.name,
|
|
2330
|
+
address: procedure.clinicInfo?.location?.address || '',
|
|
2331
|
+
latitude: procedure.clinicInfo?.location?.latitude,
|
|
2332
|
+
longitude: procedure.clinicInfo?.location?.longitude,
|
|
2333
|
+
}));
|
|
2315
2334
|
return proceduresForMap;
|
|
2316
2335
|
}
|
|
2317
2336
|
|
|
@@ -2363,9 +2382,14 @@ export class ProcedureService extends BaseService {
|
|
|
2363
2382
|
|
|
2364
2383
|
const querySnapshot = await getDocs(proceduresQuery);
|
|
2365
2384
|
|
|
2366
|
-
|
|
2385
|
+
let procedures = querySnapshot.docs.map(doc => ({
|
|
2367
2386
|
id: doc.id,
|
|
2368
2387
|
...doc.data(),
|
|
2369
2388
|
} as Procedure));
|
|
2389
|
+
|
|
2390
|
+
// Filter out procedures with draft/inactive practitioners
|
|
2391
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
2392
|
+
|
|
2393
|
+
return procedures;
|
|
2370
2394
|
}
|
|
2371
2395
|
}
|