diff --git a/src/model/patient_guarantor.ts b/src/model/patient_guarantor.ts index 3a7558f..3f60041 100644 --- a/src/model/patient_guarantor.ts +++ b/src/model/patient_guarantor.ts @@ -6,18 +6,19 @@ import { PatientGuarantor } from "entity"; export class PatientGuarantorModel { static async list(filterObj = {}, filterAny: string = ""): Promise> { const repo = OrmHelper.DB.getRepository(PatientGuarantor); - let whereAttr: string[] = []; + let whereAttr = []; let whereVal: any = {}; - if (filterObj && Object.keys(filterObj).length > 0) { - whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filterObj, "patient_guarantor").whereAttr]; - whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filterObj, "patient_guarantor").whereVal }; + if (filterObj) { + const filterResult = CommonHelper.handleQueryFilter(filterObj); + whereAttr = [...whereAttr, ...filterResult.whereAttr]; + whereVal = { ...whereVal, ...filterResult.whereVal }; } if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) { const filterResult = CommonHelper.handleFilter({ filter: JSON.stringify({ any: filterAny }), col_any_eq: [], - col_any_like: ["patient_guarantor.name", "patient_guarantor.phone"], + col_any_like: ["guarantor_name", "phone"], }); if (filterResult.whereAttr && filterResult.whereAttr !== "") {