Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
# Conflicts: # src/controllers/PositionController.ts
This commit is contained in:
commit
e329157cda
2 changed files with 84 additions and 0 deletions
|
|
@ -944,6 +944,7 @@ export class PositionController extends Controller {
|
|||
let checkChildConditions: any = {};
|
||||
let keywordAsInt: any;
|
||||
let searchShortName = "";
|
||||
let labelName = "";
|
||||
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
|
|
@ -1082,6 +1083,21 @@ export class PositionController extends Controller {
|
|||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
|
|
@ -1499,6 +1515,69 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRevisionId = org.orgRevisionId;
|
||||
}
|
||||
}
|
||||
const type0LastPosMasterNo =
|
||||
requestBody.type == 0
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type1LastPosMasterNo =
|
||||
requestBody.type == 1
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type2LastPosMasterNo =
|
||||
requestBody.type == 2
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type3LastPosMasterNo =
|
||||
requestBody.type == 3
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type4LastPosMasterNo =
|
||||
requestBody.type == 4
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const allLastPosMasterNo = [
|
||||
...type0LastPosMasterNo,
|
||||
...type1LastPosMasterNo,
|
||||
...type2LastPosMasterNo,
|
||||
...type3LastPosMasterNo,
|
||||
...type4LastPosMasterNo,
|
||||
];
|
||||
|
||||
const maxPosMasterNo = Math.max(...allLastPosMasterNo.map((pos) => pos.posMasterNo), 0);
|
||||
|
||||
const maxPosMasterOrder = Math.max(...allLastPosMasterNo.map((pos) => pos.posMasterOrder), 0);
|
||||
|
||||
posMaster.posMasterNo = maxPosMasterNo + 1;
|
||||
posMaster.posMasterOrder = maxPosMasterOrder + 1;
|
||||
posMaster.createdUserId = request.user.sub;
|
||||
posMaster.createdFullName = request.user.name;
|
||||
posMaster.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue