feat(api): add keyword filter for guarantor list
Parse `filter.any` separately from structured filters and pass it to the model query so generic search can match guarantor name and phone.
This commit is contained in:
@ -38,8 +38,13 @@ export class PatientGuarantorController {
|
||||
let param: Paging = await schema.validateAsync(req.query);
|
||||
|
||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||
let filterAny = filter.any && filter.any !== "" ? filter.any : "";
|
||||
|
||||
var query = await PatientGuarantorModel.list(filter);
|
||||
let filterObj = { ...filter } as any;
|
||||
delete filterObj.any;
|
||||
filterObj = { ...filterObj };
|
||||
|
||||
var query = await PatientGuarantorModel.list(filterObj, filterAny);
|
||||
|
||||
const offset = (param.page - 1) * param.limit;
|
||||
let limit = param.limit;
|
||||
@ -110,7 +115,7 @@ export class PatientGuarantorController {
|
||||
|
||||
var query = await PatientGuarantorModel.list(filter);
|
||||
const data = await query.getMany();
|
||||
|
||||
|
||||
const filename = "patient_guarantor.csv";
|
||||
|
||||
res.setHeader('Content-Type', 'text/csv');
|
||||
@ -179,7 +184,8 @@ export class PatientGuarantorController {
|
||||
zip_code: Joi.string().max(10).required().label('Zip Code'),
|
||||
agreement_no: Joi.string().max(50).required().label('Agreement No.'),
|
||||
agreement_desc: Joi.string().max(512).optional().label('Agreement Description'),
|
||||
patient_group_id: Joi.string().guid({ version: 'uuidv4' }).required().label('Patient Group'), });
|
||||
patient_group_id: Joi.string().guid({ version: 'uuidv4' }).required().label('Patient Group'),
|
||||
});
|
||||
|
||||
const param: any = await schema.validateAsync(req.body);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user