Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop

This commit is contained in:
Kittapath 2024-02-20 14:02:44 +07:00
commit f86aee6428

View file

@ -36,7 +36,7 @@ import { Position } from "../entities/Position";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
@Route("api/v1/org/pos") @Route("api/v1/org/pos")
@Tags("Position") @Tags("Position")
@Security("bearerAuth") // @Security("bearerAuth")
@Response( @Response(
HttpStatusCode.INTERNAL_SERVER_ERROR, HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
@ -851,6 +851,7 @@ export class PositionController extends Controller {
let typeCondition: any = {}; let typeCondition: any = {};
let checkChildConditions: any = {}; let checkChildConditions: any = {};
let keywordAsInt: any; let keywordAsInt: any;
let searchShortName = "";
if (body.type === 0) { if (body.type === 0) {
typeCondition = { typeCondition = {
@ -860,6 +861,9 @@ export class PositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild1Id: IsNull(), orgChild1Id: IsNull(),
}; };
searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else {
searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} }
} else if (body.type === 1) { } else if (body.type === 1) {
typeCondition = { typeCondition = {
@ -869,6 +873,9 @@ export class PositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild2Id: IsNull(), orgChild2Id: IsNull(),
}; };
searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else {
searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} }
} else if (body.type === 2) { } else if (body.type === 2) {
typeCondition = { typeCondition = {
@ -878,6 +885,9 @@ export class PositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild3Id: IsNull(), orgChild3Id: IsNull(),
}; };
searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else {
searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} }
} else if (body.type === 3) { } else if (body.type === 3) {
typeCondition = { typeCondition = {
@ -887,11 +897,15 @@ export class PositionController extends Controller {
checkChildConditions = { checkChildConditions = {
orgChild4Id: IsNull(), orgChild4Id: IsNull(),
}; };
searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} else {
searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%' or CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} }
} else if (body.type === 4) { } else if (body.type === 4) {
typeCondition = { typeCondition = {
orgChild4Id: body.id, orgChild4Id: body.id,
}; };
searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
} }
let findPosition: any; let findPosition: any;
let masterId = new Array(); let masterId = new Array();
@ -979,6 +993,7 @@ export class PositionController extends Controller {
.leftJoinAndSelect("posMaster.current_holder", "current_holder") .leftJoinAndSelect("posMaster.current_holder", "current_holder")
.leftJoinAndSelect("posMaster.next_holder", "next_holder") .leftJoinAndSelect("posMaster.next_holder", "next_holder")
.where(conditions) .where(conditions)
.orWhere(searchShortName)
.orWhere( .orWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.where( qb.where(