diagnosis & diagnotic procedure
This commit is contained in:
@ -198,4 +198,45 @@ export default class CommonHelper {
|
||||
|
||||
return { whereAttr, whereVal };
|
||||
}
|
||||
|
||||
static handleQueryFilter(filter: { [x: string]: any }): any {
|
||||
const whereAttr = [];
|
||||
const whereVal: any = {};
|
||||
|
||||
for (let p in filter) {
|
||||
let f = Array.isArray(filter[p]) ? filter[p] : String(filter[p]);
|
||||
|
||||
if (p !== "any") {
|
||||
if (!validate(f)) {
|
||||
if (p.endsWith("_from") || p.endsWith("_to")) {
|
||||
const baseField = p.replace(/_(from|to)$/, "");
|
||||
const fromKey = `${baseField}_from`;
|
||||
const toKey = `${baseField}_to`;
|
||||
|
||||
if (p.endsWith("_to") && !filter[p].includes(" ")) {
|
||||
filter[p] = `${filter[p]} 23:59:59`;
|
||||
f = filter[p];
|
||||
}
|
||||
|
||||
whereAttr.push(`${baseField} BETWEEN :_${fromKey} AND :_${toKey}`);
|
||||
} else if (f === "null") {
|
||||
whereAttr.push(`${p} IS NULL`);
|
||||
} else if (typeof f === "string" && f.includes("%")) {
|
||||
whereAttr.push(`${p} ILIKE :_${p}`);
|
||||
whereVal[`_${p}`] = p;
|
||||
} else if (Array.isArray(f)) {
|
||||
whereAttr.push(`${p} IN (:..._${p})`);
|
||||
} else {
|
||||
whereAttr.push(`${p} = :_${p}`);
|
||||
}
|
||||
} else {
|
||||
whereAttr.push(`${p} = :_${p}`);
|
||||
}
|
||||
|
||||
whereVal[`_${p}`] = f;
|
||||
}
|
||||
}
|
||||
|
||||
return { whereAttr, whereVal };
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
import config from 'config';
|
||||
import { DataSource } from "typeorm";
|
||||
import { ILogObj, Logger } from 'tslog';
|
||||
import { Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality } from 'entity'
|
||||
import { Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure } from 'entity'
|
||||
|
||||
export class OrmHelper {
|
||||
static DB: DataSource = null
|
||||
@ -20,7 +20,7 @@ export class OrmHelper {
|
||||
database: String(config.get("database.database")),
|
||||
synchronize: true,
|
||||
logging: config.get('database.logging'),
|
||||
entities: [Menu, Administrativu, Aldeia, District, Munisipo, Suco, Application, Nationality],
|
||||
entities: [Menu, Administrativu, Aldeia, District, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure],
|
||||
subscribers: [],
|
||||
migrations: [],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user