@blackcode_sa/metaestetics-api 1.13.10 → 1.13.13
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 +127 -125
- package/dist/admin/index.d.ts +127 -125
- package/dist/backoffice/index.d.mts +23 -23
- package/dist/backoffice/index.d.ts +23 -23
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +98 -33
- package/dist/index.mjs +98 -33
- package/package.json +1 -1
- package/src/services/clinic/clinic.service.ts +15 -10
- package/src/services/clinic/utils/clinic.utils.ts +88 -10
- package/src/services/clinic/utils/filter.utils.ts +14 -0
- package/src/services/procedure/procedure.service.ts +29 -13
- package/src/types/clinic/index.ts +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -5300,6 +5300,8 @@ interface DoctorInfo {
|
|
|
5300
5300
|
photo: string | null;
|
|
5301
5301
|
rating: number;
|
|
5302
5302
|
services: string[];
|
|
5303
|
+
status?: PractitionerStatus;
|
|
5304
|
+
isActive?: boolean;
|
|
5303
5305
|
}
|
|
5304
5306
|
/**
|
|
5305
5307
|
* Interface for clinic
|
|
@@ -6598,12 +6600,14 @@ declare class ClinicService extends BaseService {
|
|
|
6598
6600
|
activateClinic(clinicId: string, adminId: string): Promise<void>;
|
|
6599
6601
|
/**
|
|
6600
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)
|
|
6601
6604
|
*/
|
|
6602
|
-
getClinic(clinicId: string): Promise<Clinic | null>;
|
|
6605
|
+
getClinic(clinicId: string, excludeDraftPractitioners?: boolean): Promise<Clinic | null>;
|
|
6603
6606
|
/**
|
|
6604
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)
|
|
6605
6609
|
*/
|
|
6606
|
-
getClinicsByGroup(groupId: string): Promise<Clinic[]>;
|
|
6610
|
+
getClinicsByGroup(groupId: string, excludeDraftPractitioners?: boolean): Promise<Clinic[]>;
|
|
6607
6611
|
/**
|
|
6608
6612
|
* Pretražuje klinike u određenom radijusu
|
|
6609
6613
|
*/
|
|
@@ -6630,15 +6634,15 @@ declare class ClinicService extends BaseService {
|
|
|
6630
6634
|
* Handles both URL strings and File uploads for media fields.
|
|
6631
6635
|
*/
|
|
6632
6636
|
createClinicBranch(clinicGroupId: string, setupData: ClinicBranchSetupData, adminId: string): Promise<Clinic>;
|
|
6633
|
-
getClinicById(clinicId: string): Promise<Clinic | null>;
|
|
6634
|
-
getAllClinics(pagination?: number, lastDoc?: any): Promise<{
|
|
6637
|
+
getClinicById(clinicId: string, excludeDraftPractitioners?: boolean): Promise<Clinic | null>;
|
|
6638
|
+
getAllClinics(pagination?: number, lastDoc?: any, excludeDraftPractitioners?: boolean): Promise<{
|
|
6635
6639
|
clinics: Clinic[];
|
|
6636
6640
|
lastDoc: any;
|
|
6637
6641
|
}>;
|
|
6638
6642
|
getAllClinicsInRange(center: {
|
|
6639
6643
|
latitude: number;
|
|
6640
6644
|
longitude: number;
|
|
6641
|
-
}, rangeInKm: number, pagination?: number, lastDoc?: any): Promise<{
|
|
6645
|
+
}, rangeInKm: number, pagination?: number, lastDoc?: any, excludeDraftPractitioners?: boolean): Promise<{
|
|
6642
6646
|
clinics: (Clinic & {
|
|
6643
6647
|
distance: number;
|
|
6644
6648
|
})[];
|
package/dist/index.js
CHANGED
|
@@ -13530,22 +13530,61 @@ 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
|
+
if (!excludeDraftPractitioners) {
|
|
13554
|
+
return clinic;
|
|
13555
|
+
}
|
|
13556
|
+
const filteredClinic = { ...clinic };
|
|
13557
|
+
if (filteredClinic.doctorsInfo && filteredClinic.doctorsInfo.length > 0) {
|
|
13558
|
+
const originalLength = filteredClinic.doctorsInfo.length;
|
|
13559
|
+
filteredClinic.doctorsInfo = filterDoctorsInfo(filteredClinic.doctorsInfo);
|
|
13560
|
+
if (filteredClinic.doctorsInfo.length !== originalLength) {
|
|
13561
|
+
console.log(
|
|
13562
|
+
`[CLINIC_UTILS] Filtered ${originalLength - filteredClinic.doctorsInfo.length} draft/inactive doctors from clinic ${clinic.id}`
|
|
13563
|
+
);
|
|
13564
|
+
}
|
|
13565
|
+
}
|
|
13566
|
+
return filteredClinic;
|
|
13567
|
+
}
|
|
13568
|
+
async function getClinic(db, clinicId, excludeDraftPractitioners = false) {
|
|
13534
13569
|
const docRef = (0, import_firestore36.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
13535
13570
|
const docSnap = await (0, import_firestore36.getDoc)(docRef);
|
|
13536
13571
|
if (docSnap.exists()) {
|
|
13537
|
-
|
|
13572
|
+
const clinicData = docSnap.data();
|
|
13573
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13538
13574
|
}
|
|
13539
13575
|
return null;
|
|
13540
13576
|
}
|
|
13541
|
-
async function getClinicsByGroup(db, groupId) {
|
|
13577
|
+
async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false) {
|
|
13542
13578
|
const q = (0, import_firestore36.query)(
|
|
13543
13579
|
(0, import_firestore36.collection)(db, CLINICS_COLLECTION),
|
|
13544
13580
|
(0, import_firestore36.where)("clinicGroupId", "==", groupId),
|
|
13545
13581
|
(0, import_firestore36.where)("isActive", "==", true)
|
|
13546
13582
|
);
|
|
13547
13583
|
const querySnapshot = await (0, import_firestore36.getDocs)(q);
|
|
13548
|
-
return querySnapshot.docs.map((doc47) =>
|
|
13584
|
+
return querySnapshot.docs.map((doc47) => {
|
|
13585
|
+
const clinicData = doc47.data();
|
|
13586
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13587
|
+
});
|
|
13549
13588
|
}
|
|
13550
13589
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
13551
13590
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -13750,7 +13789,7 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
|
|
|
13750
13789
|
clinicGroupService
|
|
13751
13790
|
);
|
|
13752
13791
|
}
|
|
13753
|
-
async function getClinicById(db, clinicId) {
|
|
13792
|
+
async function getClinicById(db, clinicId, excludeDraftPractitioners = false) {
|
|
13754
13793
|
try {
|
|
13755
13794
|
const clinicRef = (0, import_firestore36.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
13756
13795
|
const clinicSnapshot = await (0, import_firestore36.getDoc)(clinicRef);
|
|
@@ -13758,16 +13797,17 @@ async function getClinicById(db, clinicId) {
|
|
|
13758
13797
|
return null;
|
|
13759
13798
|
}
|
|
13760
13799
|
const clinicData = clinicSnapshot.data();
|
|
13761
|
-
|
|
13800
|
+
const clinicWithId = {
|
|
13762
13801
|
...clinicData,
|
|
13763
13802
|
id: clinicSnapshot.id
|
|
13764
13803
|
};
|
|
13804
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13765
13805
|
} catch (error) {
|
|
13766
13806
|
console.error("[CLINIC_UTILS] Error getting clinic by ID:", error);
|
|
13767
13807
|
throw error;
|
|
13768
13808
|
}
|
|
13769
13809
|
}
|
|
13770
|
-
async function getAllClinics(db, pagination, lastDoc) {
|
|
13810
|
+
async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13771
13811
|
try {
|
|
13772
13812
|
const clinicsCollection = (0, import_firestore36.collection)(db, CLINICS_COLLECTION);
|
|
13773
13813
|
let clinicsQuery = (0, import_firestore36.query)(clinicsCollection);
|
|
@@ -13786,10 +13826,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13786
13826
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
13787
13827
|
const clinics = clinicsSnapshot.docs.map((doc47) => {
|
|
13788
13828
|
const data = doc47.data();
|
|
13789
|
-
|
|
13829
|
+
const clinicWithId = {
|
|
13790
13830
|
...data,
|
|
13791
13831
|
id: doc47.id
|
|
13792
13832
|
};
|
|
13833
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13793
13834
|
});
|
|
13794
13835
|
return {
|
|
13795
13836
|
clinics,
|
|
@@ -13800,7 +13841,7 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13800
13841
|
throw error;
|
|
13801
13842
|
}
|
|
13802
13843
|
}
|
|
13803
|
-
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc) {
|
|
13844
|
+
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13804
13845
|
const bounds = (0, import_geofire_common4.geohashQueryBounds)(
|
|
13805
13846
|
[center.latitude, center.longitude],
|
|
13806
13847
|
rangeInKm * 1e3
|
|
@@ -13823,8 +13864,9 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
13823
13864
|
);
|
|
13824
13865
|
const distanceInKm = distance / 1e3;
|
|
13825
13866
|
if (distanceInKm <= rangeInKm) {
|
|
13867
|
+
const filteredClinic = filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners);
|
|
13826
13868
|
matchingClinics.push({
|
|
13827
|
-
...
|
|
13869
|
+
...filteredClinic,
|
|
13828
13870
|
distance: distanceInKm
|
|
13829
13871
|
});
|
|
13830
13872
|
}
|
|
@@ -14003,6 +14045,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14003
14045
|
uniqueMap.set(c.id, c);
|
|
14004
14046
|
}
|
|
14005
14047
|
let clinics = Array.from(uniqueMap.values());
|
|
14048
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14049
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14006
14050
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14007
14051
|
const pageSize = filters.pagination || 5;
|
|
14008
14052
|
let startIndex = 0;
|
|
@@ -14056,6 +14100,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14056
14100
|
const q = (0, import_firestore38.query)((0, import_firestore38.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
14057
14101
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
14058
14102
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14103
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14104
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14059
14105
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14060
14106
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14061
14107
|
console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
|
|
@@ -14088,6 +14134,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14088
14134
|
const q = (0, import_firestore38.query)((0, import_firestore38.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
14089
14135
|
const querySnapshot = await (0, import_firestore38.getDocs)(q);
|
|
14090
14136
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14137
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14138
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14091
14139
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14092
14140
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14093
14141
|
console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
|
|
@@ -14569,15 +14617,17 @@ var ClinicService = class extends BaseService {
|
|
|
14569
14617
|
}
|
|
14570
14618
|
/**
|
|
14571
14619
|
* Dohvata kliniku po ID-u
|
|
14620
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14572
14621
|
*/
|
|
14573
|
-
async getClinic(clinicId) {
|
|
14574
|
-
return getClinic(this.db, clinicId);
|
|
14622
|
+
async getClinic(clinicId, excludeDraftPractitioners = false) {
|
|
14623
|
+
return getClinic(this.db, clinicId, excludeDraftPractitioners);
|
|
14575
14624
|
}
|
|
14576
14625
|
/**
|
|
14577
14626
|
* Dohvata sve klinike u grupi
|
|
14627
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14578
14628
|
*/
|
|
14579
|
-
async getClinicsByGroup(groupId) {
|
|
14580
|
-
return getClinicsByGroup(this.db, groupId);
|
|
14629
|
+
async getClinicsByGroup(groupId, excludeDraftPractitioners = false) {
|
|
14630
|
+
return getClinicsByGroup(this.db, groupId, excludeDraftPractitioners);
|
|
14581
14631
|
}
|
|
14582
14632
|
/**
|
|
14583
14633
|
* Pretražuje klinike u određenom radijusu
|
|
@@ -14677,19 +14727,20 @@ var ClinicService = class extends BaseService {
|
|
|
14677
14727
|
});
|
|
14678
14728
|
return clinic;
|
|
14679
14729
|
}
|
|
14680
|
-
async getClinicById(clinicId) {
|
|
14681
|
-
return getClinicById(this.db, clinicId);
|
|
14730
|
+
async getClinicById(clinicId, excludeDraftPractitioners = false) {
|
|
14731
|
+
return getClinicById(this.db, clinicId, excludeDraftPractitioners);
|
|
14682
14732
|
}
|
|
14683
|
-
async getAllClinics(pagination, lastDoc) {
|
|
14684
|
-
return getAllClinics(this.db, pagination, lastDoc);
|
|
14733
|
+
async getAllClinics(pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14734
|
+
return getAllClinics(this.db, pagination, lastDoc, excludeDraftPractitioners);
|
|
14685
14735
|
}
|
|
14686
|
-
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc) {
|
|
14736
|
+
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14687
14737
|
return getAllClinicsInRange(
|
|
14688
14738
|
this.db,
|
|
14689
14739
|
center,
|
|
14690
14740
|
rangeInKm,
|
|
14691
14741
|
pagination,
|
|
14692
|
-
lastDoc
|
|
14742
|
+
lastDoc,
|
|
14743
|
+
excludeDraftPractitioners
|
|
14693
14744
|
);
|
|
14694
14745
|
}
|
|
14695
14746
|
/**
|
|
@@ -20271,7 +20322,11 @@ var ProcedureService = class extends BaseService {
|
|
|
20271
20322
|
photo: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : "",
|
|
20272
20323
|
// Default to empty string if not a processed URL
|
|
20273
20324
|
rating: ((_a = practitioner.reviewInfo) == null ? void 0 : _a.averageRating) || 0,
|
|
20274
|
-
services: practitioner.procedures || []
|
|
20325
|
+
services: practitioner.procedures || [],
|
|
20326
|
+
status: practitioner.status,
|
|
20327
|
+
// Include practitioner status for client-side filtering
|
|
20328
|
+
isActive: practitioner.isActive
|
|
20329
|
+
// Include isActive flag for client-side filtering
|
|
20275
20330
|
};
|
|
20276
20331
|
const { productsMetadata: _, productId: __, photos: ___, ...validatedDataWithoutProductsMetadata } = validatedData;
|
|
20277
20332
|
const newProcedure = {
|
|
@@ -20430,7 +20485,9 @@ var ProcedureService = class extends BaseService {
|
|
|
20430
20485
|
description: practitioner.basicInfo.bio || "",
|
|
20431
20486
|
photo: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : "",
|
|
20432
20487
|
rating: ((_c = practitioner.reviewInfo) == null ? void 0 : _c.averageRating) || 0,
|
|
20433
|
-
services: practitioner.procedures || []
|
|
20488
|
+
services: practitioner.procedures || [],
|
|
20489
|
+
status: practitioner.status,
|
|
20490
|
+
isActive: practitioner.isActive
|
|
20434
20491
|
};
|
|
20435
20492
|
const newProcedure = {
|
|
20436
20493
|
...sourceProcedure,
|
|
@@ -20927,7 +20984,9 @@ var ProcedureService = class extends BaseService {
|
|
|
20927
20984
|
photo: typeof newPractitioner.basicInfo.profileImageUrl === "string" ? newPractitioner.basicInfo.profileImageUrl : "",
|
|
20928
20985
|
// Default to empty string if not a processed URL
|
|
20929
20986
|
rating: ((_b = newPractitioner.reviewInfo) == null ? void 0 : _b.averageRating) || 0,
|
|
20930
|
-
services: newPractitioner.procedures || []
|
|
20987
|
+
services: newPractitioner.procedures || [],
|
|
20988
|
+
status: newPractitioner.status,
|
|
20989
|
+
isActive: newPractitioner.isActive
|
|
20931
20990
|
};
|
|
20932
20991
|
}
|
|
20933
20992
|
if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
|
|
@@ -21696,17 +21755,21 @@ var ProcedureService = class extends BaseService {
|
|
|
21696
21755
|
async getProceduresForMap() {
|
|
21697
21756
|
const proceduresRef = (0, import_firestore58.collection)(this.db, PROCEDURES_COLLECTION);
|
|
21698
21757
|
const snapshot = await (0, import_firestore58.getDocs)(proceduresRef);
|
|
21699
|
-
|
|
21758
|
+
let procedures = snapshot.docs.map((doc47) => ({
|
|
21759
|
+
id: doc47.id,
|
|
21760
|
+
...doc47.data()
|
|
21761
|
+
}));
|
|
21762
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21763
|
+
const proceduresForMap = procedures.map((procedure) => {
|
|
21700
21764
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21701
|
-
const data = doc47.data();
|
|
21702
21765
|
return {
|
|
21703
|
-
id:
|
|
21704
|
-
name:
|
|
21705
|
-
clinicId: (_a =
|
|
21706
|
-
clinicName: (_b =
|
|
21707
|
-
address: ((_d = (_c =
|
|
21708
|
-
latitude: (_f = (_e =
|
|
21709
|
-
longitude: (_h = (_g =
|
|
21766
|
+
id: procedure.id,
|
|
21767
|
+
name: procedure.name,
|
|
21768
|
+
clinicId: (_a = procedure.clinicInfo) == null ? void 0 : _a.id,
|
|
21769
|
+
clinicName: (_b = procedure.clinicInfo) == null ? void 0 : _b.name,
|
|
21770
|
+
address: ((_d = (_c = procedure.clinicInfo) == null ? void 0 : _c.location) == null ? void 0 : _d.address) || "",
|
|
21771
|
+
latitude: (_f = (_e = procedure.clinicInfo) == null ? void 0 : _e.location) == null ? void 0 : _f.latitude,
|
|
21772
|
+
longitude: (_h = (_g = procedure.clinicInfo) == null ? void 0 : _g.location) == null ? void 0 : _h.longitude
|
|
21710
21773
|
};
|
|
21711
21774
|
});
|
|
21712
21775
|
return proceduresForMap;
|
|
@@ -21743,10 +21806,12 @@ var ProcedureService = class extends BaseService {
|
|
|
21743
21806
|
(0, import_firestore58.orderBy)("name", "asc")
|
|
21744
21807
|
);
|
|
21745
21808
|
const querySnapshot = await (0, import_firestore58.getDocs)(proceduresQuery);
|
|
21746
|
-
|
|
21809
|
+
let procedures = querySnapshot.docs.map((doc47) => ({
|
|
21747
21810
|
id: doc47.id,
|
|
21748
21811
|
...doc47.data()
|
|
21749
21812
|
}));
|
|
21813
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21814
|
+
return procedures;
|
|
21750
21815
|
}
|
|
21751
21816
|
};
|
|
21752
21817
|
|
package/dist/index.mjs
CHANGED
|
@@ -13604,22 +13604,61 @@ 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
|
+
if (!excludeDraftPractitioners) {
|
|
13628
|
+
return clinic;
|
|
13629
|
+
}
|
|
13630
|
+
const filteredClinic = { ...clinic };
|
|
13631
|
+
if (filteredClinic.doctorsInfo && filteredClinic.doctorsInfo.length > 0) {
|
|
13632
|
+
const originalLength = filteredClinic.doctorsInfo.length;
|
|
13633
|
+
filteredClinic.doctorsInfo = filterDoctorsInfo(filteredClinic.doctorsInfo);
|
|
13634
|
+
if (filteredClinic.doctorsInfo.length !== originalLength) {
|
|
13635
|
+
console.log(
|
|
13636
|
+
`[CLINIC_UTILS] Filtered ${originalLength - filteredClinic.doctorsInfo.length} draft/inactive doctors from clinic ${clinic.id}`
|
|
13637
|
+
);
|
|
13638
|
+
}
|
|
13639
|
+
}
|
|
13640
|
+
return filteredClinic;
|
|
13641
|
+
}
|
|
13642
|
+
async function getClinic(db, clinicId, excludeDraftPractitioners = false) {
|
|
13608
13643
|
const docRef = doc23(db, CLINICS_COLLECTION, clinicId);
|
|
13609
13644
|
const docSnap = await getDoc25(docRef);
|
|
13610
13645
|
if (docSnap.exists()) {
|
|
13611
|
-
|
|
13646
|
+
const clinicData = docSnap.data();
|
|
13647
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13612
13648
|
}
|
|
13613
13649
|
return null;
|
|
13614
13650
|
}
|
|
13615
|
-
async function getClinicsByGroup(db, groupId) {
|
|
13651
|
+
async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false) {
|
|
13616
13652
|
const q = query17(
|
|
13617
13653
|
collection17(db, CLINICS_COLLECTION),
|
|
13618
13654
|
where17("clinicGroupId", "==", groupId),
|
|
13619
13655
|
where17("isActive", "==", true)
|
|
13620
13656
|
);
|
|
13621
13657
|
const querySnapshot = await getDocs17(q);
|
|
13622
|
-
return querySnapshot.docs.map((doc47) =>
|
|
13658
|
+
return querySnapshot.docs.map((doc47) => {
|
|
13659
|
+
const clinicData = doc47.data();
|
|
13660
|
+
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
13661
|
+
});
|
|
13623
13662
|
}
|
|
13624
13663
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
13625
13664
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -13824,7 +13863,7 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
|
|
|
13824
13863
|
clinicGroupService
|
|
13825
13864
|
);
|
|
13826
13865
|
}
|
|
13827
|
-
async function getClinicById(db, clinicId) {
|
|
13866
|
+
async function getClinicById(db, clinicId, excludeDraftPractitioners = false) {
|
|
13828
13867
|
try {
|
|
13829
13868
|
const clinicRef = doc23(db, CLINICS_COLLECTION, clinicId);
|
|
13830
13869
|
const clinicSnapshot = await getDoc25(clinicRef);
|
|
@@ -13832,16 +13871,17 @@ async function getClinicById(db, clinicId) {
|
|
|
13832
13871
|
return null;
|
|
13833
13872
|
}
|
|
13834
13873
|
const clinicData = clinicSnapshot.data();
|
|
13835
|
-
|
|
13874
|
+
const clinicWithId = {
|
|
13836
13875
|
...clinicData,
|
|
13837
13876
|
id: clinicSnapshot.id
|
|
13838
13877
|
};
|
|
13878
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13839
13879
|
} catch (error) {
|
|
13840
13880
|
console.error("[CLINIC_UTILS] Error getting clinic by ID:", error);
|
|
13841
13881
|
throw error;
|
|
13842
13882
|
}
|
|
13843
13883
|
}
|
|
13844
|
-
async function getAllClinics(db, pagination, lastDoc) {
|
|
13884
|
+
async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13845
13885
|
try {
|
|
13846
13886
|
const clinicsCollection = collection17(db, CLINICS_COLLECTION);
|
|
13847
13887
|
let clinicsQuery = query17(clinicsCollection);
|
|
@@ -13860,10 +13900,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13860
13900
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
13861
13901
|
const clinics = clinicsSnapshot.docs.map((doc47) => {
|
|
13862
13902
|
const data = doc47.data();
|
|
13863
|
-
|
|
13903
|
+
const clinicWithId = {
|
|
13864
13904
|
...data,
|
|
13865
13905
|
id: doc47.id
|
|
13866
13906
|
};
|
|
13907
|
+
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
13867
13908
|
});
|
|
13868
13909
|
return {
|
|
13869
13910
|
clinics,
|
|
@@ -13874,7 +13915,7 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
13874
13915
|
throw error;
|
|
13875
13916
|
}
|
|
13876
13917
|
}
|
|
13877
|
-
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc) {
|
|
13918
|
+
async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
13878
13919
|
const bounds = geohashQueryBounds(
|
|
13879
13920
|
[center.latitude, center.longitude],
|
|
13880
13921
|
rangeInKm * 1e3
|
|
@@ -13897,8 +13938,9 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
13897
13938
|
);
|
|
13898
13939
|
const distanceInKm = distance / 1e3;
|
|
13899
13940
|
if (distanceInKm <= rangeInKm) {
|
|
13941
|
+
const filteredClinic = filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners);
|
|
13900
13942
|
matchingClinics.push({
|
|
13901
|
-
...
|
|
13943
|
+
...filteredClinic,
|
|
13902
13944
|
distance: distanceInKm
|
|
13903
13945
|
});
|
|
13904
13946
|
}
|
|
@@ -14090,6 +14132,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14090
14132
|
uniqueMap.set(c.id, c);
|
|
14091
14133
|
}
|
|
14092
14134
|
let clinics = Array.from(uniqueMap.values());
|
|
14135
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14136
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14093
14137
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14094
14138
|
const pageSize = filters.pagination || 5;
|
|
14095
14139
|
let startIndex = 0;
|
|
@@ -14143,6 +14187,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14143
14187
|
const q = query19(collection19(db, CLINICS_COLLECTION), ...constraints);
|
|
14144
14188
|
const querySnapshot = await getDocs19(q);
|
|
14145
14189
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14190
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14191
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14146
14192
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14147
14193
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14148
14194
|
console.log(`[CLINIC_SERVICE] Strategy 1 success: ${clinics.length} clinics`);
|
|
@@ -14175,6 +14221,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
14175
14221
|
const q = query19(collection19(db, CLINICS_COLLECTION), ...constraints);
|
|
14176
14222
|
const querySnapshot = await getDocs19(q);
|
|
14177
14223
|
let clinics = querySnapshot.docs.map((doc47) => ({ ...doc47.data(), id: doc47.id }));
|
|
14224
|
+
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
14225
|
+
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
14178
14226
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
14179
14227
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14180
14228
|
console.log(`[CLINIC_SERVICE] Strategy 2 success: ${clinics.length} clinics`);
|
|
@@ -14656,15 +14704,17 @@ var ClinicService = class extends BaseService {
|
|
|
14656
14704
|
}
|
|
14657
14705
|
/**
|
|
14658
14706
|
* Dohvata kliniku po ID-u
|
|
14707
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14659
14708
|
*/
|
|
14660
|
-
async getClinic(clinicId) {
|
|
14661
|
-
return getClinic(this.db, clinicId);
|
|
14709
|
+
async getClinic(clinicId, excludeDraftPractitioners = false) {
|
|
14710
|
+
return getClinic(this.db, clinicId, excludeDraftPractitioners);
|
|
14662
14711
|
}
|
|
14663
14712
|
/**
|
|
14664
14713
|
* Dohvata sve klinike u grupi
|
|
14714
|
+
* @param excludeDraftPractitioners If true, filters out draft/inactive practitioners. If false (default), returns all practitioners (for admin views)
|
|
14665
14715
|
*/
|
|
14666
|
-
async getClinicsByGroup(groupId) {
|
|
14667
|
-
return getClinicsByGroup(this.db, groupId);
|
|
14716
|
+
async getClinicsByGroup(groupId, excludeDraftPractitioners = false) {
|
|
14717
|
+
return getClinicsByGroup(this.db, groupId, excludeDraftPractitioners);
|
|
14668
14718
|
}
|
|
14669
14719
|
/**
|
|
14670
14720
|
* Pretražuje klinike u određenom radijusu
|
|
@@ -14764,19 +14814,20 @@ var ClinicService = class extends BaseService {
|
|
|
14764
14814
|
});
|
|
14765
14815
|
return clinic;
|
|
14766
14816
|
}
|
|
14767
|
-
async getClinicById(clinicId) {
|
|
14768
|
-
return getClinicById(this.db, clinicId);
|
|
14817
|
+
async getClinicById(clinicId, excludeDraftPractitioners = false) {
|
|
14818
|
+
return getClinicById(this.db, clinicId, excludeDraftPractitioners);
|
|
14769
14819
|
}
|
|
14770
|
-
async getAllClinics(pagination, lastDoc) {
|
|
14771
|
-
return getAllClinics(this.db, pagination, lastDoc);
|
|
14820
|
+
async getAllClinics(pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14821
|
+
return getAllClinics(this.db, pagination, lastDoc, excludeDraftPractitioners);
|
|
14772
14822
|
}
|
|
14773
|
-
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc) {
|
|
14823
|
+
async getAllClinicsInRange(center, rangeInKm, pagination, lastDoc, excludeDraftPractitioners = false) {
|
|
14774
14824
|
return getAllClinicsInRange(
|
|
14775
14825
|
this.db,
|
|
14776
14826
|
center,
|
|
14777
14827
|
rangeInKm,
|
|
14778
14828
|
pagination,
|
|
14779
|
-
lastDoc
|
|
14829
|
+
lastDoc,
|
|
14830
|
+
excludeDraftPractitioners
|
|
14780
14831
|
);
|
|
14781
14832
|
}
|
|
14782
14833
|
/**
|
|
@@ -20507,7 +20558,11 @@ var ProcedureService = class extends BaseService {
|
|
|
20507
20558
|
photo: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : "",
|
|
20508
20559
|
// Default to empty string if not a processed URL
|
|
20509
20560
|
rating: ((_a = practitioner.reviewInfo) == null ? void 0 : _a.averageRating) || 0,
|
|
20510
|
-
services: practitioner.procedures || []
|
|
20561
|
+
services: practitioner.procedures || [],
|
|
20562
|
+
status: practitioner.status,
|
|
20563
|
+
// Include practitioner status for client-side filtering
|
|
20564
|
+
isActive: practitioner.isActive
|
|
20565
|
+
// Include isActive flag for client-side filtering
|
|
20511
20566
|
};
|
|
20512
20567
|
const { productsMetadata: _, productId: __, photos: ___, ...validatedDataWithoutProductsMetadata } = validatedData;
|
|
20513
20568
|
const newProcedure = {
|
|
@@ -20666,7 +20721,9 @@ var ProcedureService = class extends BaseService {
|
|
|
20666
20721
|
description: practitioner.basicInfo.bio || "",
|
|
20667
20722
|
photo: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : "",
|
|
20668
20723
|
rating: ((_c = practitioner.reviewInfo) == null ? void 0 : _c.averageRating) || 0,
|
|
20669
|
-
services: practitioner.procedures || []
|
|
20724
|
+
services: practitioner.procedures || [],
|
|
20725
|
+
status: practitioner.status,
|
|
20726
|
+
isActive: practitioner.isActive
|
|
20670
20727
|
};
|
|
20671
20728
|
const newProcedure = {
|
|
20672
20729
|
...sourceProcedure,
|
|
@@ -21163,7 +21220,9 @@ var ProcedureService = class extends BaseService {
|
|
|
21163
21220
|
photo: typeof newPractitioner.basicInfo.profileImageUrl === "string" ? newPractitioner.basicInfo.profileImageUrl : "",
|
|
21164
21221
|
// Default to empty string if not a processed URL
|
|
21165
21222
|
rating: ((_b = newPractitioner.reviewInfo) == null ? void 0 : _b.averageRating) || 0,
|
|
21166
|
-
services: newPractitioner.procedures || []
|
|
21223
|
+
services: newPractitioner.procedures || [],
|
|
21224
|
+
status: newPractitioner.status,
|
|
21225
|
+
isActive: newPractitioner.isActive
|
|
21167
21226
|
};
|
|
21168
21227
|
}
|
|
21169
21228
|
if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
|
|
@@ -21932,17 +21991,21 @@ var ProcedureService = class extends BaseService {
|
|
|
21932
21991
|
async getProceduresForMap() {
|
|
21933
21992
|
const proceduresRef = collection33(this.db, PROCEDURES_COLLECTION);
|
|
21934
21993
|
const snapshot = await getDocs33(proceduresRef);
|
|
21935
|
-
|
|
21994
|
+
let procedures = snapshot.docs.map((doc47) => ({
|
|
21995
|
+
id: doc47.id,
|
|
21996
|
+
...doc47.data()
|
|
21997
|
+
}));
|
|
21998
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
21999
|
+
const proceduresForMap = procedures.map((procedure) => {
|
|
21936
22000
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21937
|
-
const data = doc47.data();
|
|
21938
22001
|
return {
|
|
21939
|
-
id:
|
|
21940
|
-
name:
|
|
21941
|
-
clinicId: (_a =
|
|
21942
|
-
clinicName: (_b =
|
|
21943
|
-
address: ((_d = (_c =
|
|
21944
|
-
latitude: (_f = (_e =
|
|
21945
|
-
longitude: (_h = (_g =
|
|
22002
|
+
id: procedure.id,
|
|
22003
|
+
name: procedure.name,
|
|
22004
|
+
clinicId: (_a = procedure.clinicInfo) == null ? void 0 : _a.id,
|
|
22005
|
+
clinicName: (_b = procedure.clinicInfo) == null ? void 0 : _b.name,
|
|
22006
|
+
address: ((_d = (_c = procedure.clinicInfo) == null ? void 0 : _c.location) == null ? void 0 : _d.address) || "",
|
|
22007
|
+
latitude: (_f = (_e = procedure.clinicInfo) == null ? void 0 : _e.location) == null ? void 0 : _f.latitude,
|
|
22008
|
+
longitude: (_h = (_g = procedure.clinicInfo) == null ? void 0 : _g.location) == null ? void 0 : _h.longitude
|
|
21946
22009
|
};
|
|
21947
22010
|
});
|
|
21948
22011
|
return proceduresForMap;
|
|
@@ -21979,10 +22042,12 @@ var ProcedureService = class extends BaseService {
|
|
|
21979
22042
|
orderBy18("name", "asc")
|
|
21980
22043
|
);
|
|
21981
22044
|
const querySnapshot = await getDocs33(proceduresQuery);
|
|
21982
|
-
|
|
22045
|
+
let procedures = querySnapshot.docs.map((doc47) => ({
|
|
21983
22046
|
id: doc47.id,
|
|
21984
22047
|
...doc47.data()
|
|
21985
22048
|
}));
|
|
22049
|
+
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
22050
|
+
return procedures;
|
|
21986
22051
|
}
|
|
21987
22052
|
};
|
|
21988
22053
|
|
package/package.json
CHANGED