Merge branch 'develop' into adiDev

# Conflicts:
#	src/entities/view/viewDirector.ts
#	src/entities/view/viewDirectorActing.ts
This commit is contained in:
AdisakKanthawilang 2024-11-08 14:08:56 +07:00
commit d7c18c07df
8 changed files with 385 additions and 114 deletions

View file

@ -1324,6 +1324,7 @@ export class CommandController extends Controller {
RemarkHorizontal: x.remarkHorizontal,
RemarkVertical: x.remarkVertical,
CommandYear: command.commandYear,
CommandExcecuteDate: command.commandExcecuteDate
})),
})
.then(async (res) => {

View file

@ -5278,11 +5278,15 @@ export class ProfileController extends Controller {
"current_holders",
"current_holders.orgRoot",
"profileSalary",
"profileEducations"
],
order: {
profileSalary: {
order: "DESC",
},
// profileSalary: {
// order: "DESC",
// },
profileEducations: {
createdAt: "DESC"
}
},
});
if (!profile) {
@ -5461,6 +5465,9 @@ export class ProfileController extends Controller {
isPosmasterAct: data.length > 0,
posmasterAct: data,
salary: profile ? profile.amount : null,
education: profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}-${profile.profileEducations[0].field ?? ""}`
: "-"
};
if (_profile.child4Id != null) {

View file

@ -3833,11 +3833,15 @@ export class ProfileEmployeeController extends Controller {
"current_holders",
"current_holders.orgRoot",
"profileSalary",
"profileEducations"
],
order: {
profileSalary: {
order: "DESC",
},
// profileSalary: {
// order: "DESC",
// },
profileEducations: {
createdAt: "DESC"
}
},
});
if (!profile) {
@ -3961,6 +3965,9 @@ export class ProfileEmployeeController extends Controller {
posNo: shortName,
salary:
profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
education: profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}-${profile.profileEducations[0].field ?? ""}`
: "-"
};
if (_profile.child4Id != null) {

View file

@ -3416,7 +3416,12 @@ export class ProfileEmployeeTempController extends Controller {
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
const profile = await this.profileRepo.findOne({
where: { id: id },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileEducations"],
order: {
profileEducations: {
createdAt: "DESC"
}
}
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
@ -3536,6 +3541,9 @@ export class ProfileEmployeeTempController extends Controller {
node: null,
nodeId: null,
posNo: shortName,
education: profile && profile.profileEducations.length > 0
? `${profile.profileEducations[0].degree ?? ""}-${profile.profileEducations[0].field ?? ""}`
: "-"
};
if (_profile.child4Id != null) {

View file

@ -1,4 +1,4 @@
import { Body, Controller, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
import { Body, Controller, Get, Path, Post, Put, Request, Route, Security, Tags } from "tsoa";
import { AppDataSource } from "../database/data-source";
import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error";
@ -15,10 +15,12 @@ import { MetaWorkflow } from "../entities/MetaWorkflow";
import { MetaState } from "../entities/MetaState";
import { MetaStateOperator } from "../entities/MetaStateOperator";
import { PosMaster } from "../entities/PosMaster";
import { In, IsNull, Not } from "typeorm";
import { Brackets, In, IsNull, Not } from "typeorm";
import { Assign } from "../entities/Assign";
import { PosMasterAct } from "../entities/PosMasterAct";
import { getAllJSDocTagsOfKind } from "typescript";
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
import { viewDirector } from "../entities/view/viewDirector";
@Route("api/v1/org/workflow")
@Tags("Workflow")
@ -715,32 +717,31 @@ export class WorkflowController extends Controller {
*
*
*/
@Get("commander/{type}")
async getProfilePlacement(@Request() req: RequestWithUser, @Path() type: string) {
@Put("commander/{type}")
async getProfilePlacement(
@Request() request: RequestWithUser,
@Path() type: string,
@Body()
body: {
isAct: boolean;
keyword: string;
page: number;
pageSize: number;
},
) {
const posMasterUser = await this.posMasterRepo.findOne({
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
current_holder: { keycloak: req.user.sub },
current_holder: { keycloak: request.user.sub },
},
relations: ["current_holder", "current_holder.posType", "current_holder.posLevel"],
});
if (!posMasterUser || !posMasterUser.orgRootId)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
let _posMasters = [];
let sortPosmaster: any = {
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
isDirector: true,
current_holderId: Not(IsNull()),
orgRootId: posMasterUser.orgRootId,
},
relations: [
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
"positions",
"positions.posExecutive",
],
let condition: any = {
isDirector: true,
orgRootId: posMasterUser.orgRootId,
};
if (type.trim().toLowerCase() == "OPERATE") {
@ -755,24 +756,13 @@ export class WorkflowController extends Controller {
(posMasterUser.current_holder.posType.posTypeName == "วิชาการ" &&
posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญการ")
) {
sortPosmaster = {
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
isDirector: true,
current_holderId: Not(IsNull()),
orgRootId: posMasterUser.orgRootId,
orgChild1Id: IsNull(),
orgChild2Id: IsNull(),
orgChild3Id: IsNull(),
orgChild4Id: IsNull(),
},
relations: [
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
"positions",
"positions.posExecutive",
],
condition = {
isDirector: true,
orgRootId: posMasterUser.orgRootId,
orgChild1Id: IsNull(),
orgChild2Id: IsNull(),
orgChild3Id: IsNull(),
orgChild4Id: IsNull(),
};
} else if (
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
@ -782,80 +772,131 @@ export class WorkflowController extends Controller {
(posMasterUser.current_holder.posType.posTypeName == "อำนวยการ" &&
posMasterUser.current_holder.posLevel.posLevelName == "ต้น")
) {
sortPosmaster = {
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
isDirector: true,
current_holderId: Not(IsNull()),
orgRoot: {
isDeputy: true,
},
orgChild1Id: IsNull(),
orgChild2Id: IsNull(),
orgChild3Id: IsNull(),
orgChild4Id: IsNull(),
},
relations: [
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
"positions",
"positions.posExecutive",
],
condition = {
isDirector: true,
isDeputy: true,
orgChild1Id: IsNull(),
orgChild2Id: IsNull(),
orgChild3Id: IsNull(),
orgChild4Id: IsNull(),
};
} else {
}
}
const posMasters = await this.posMasterRepo.find(sortPosmaster);
_posMasters = posMasters.map((data) => ({
id: data.current_holderId || null,
prefix: data.current_holder?.prefix || null,
firstName: data.current_holder?.firstName || null,
lastName: data.current_holder?.lastName || null,
position: data.current_holder?.position || null,
posLevel: data.current_holder?.posLevel?.posLevelName || null,
posType: data.current_holder?.posType?.posTypeName || null,
posExecutiveName:
data.positions?.filter((x) => x.positionIsSelected == true)[0]?.posExecutive
?.posExecutiveName || null,
actFullName: null,
}));
const posMasterActs = await this.posMasterActRepo.find({
where: {
posMasterId: In(posMasters.map((x) => x.id)),
posMasterChild: {
current_holderId: Not(In(posMasters.map((x) => x.current_holderId))),
},
},
relations: [
"posMaster",
"posMaster.current_holder",
"posMasterChild",
"posMasterChild.positions",
"posMasterChild.positions.posExecutive",
"posMasterChild.current_holder",
"posMasterChild.current_holder.posLevel",
"posMasterChild.current_holder.posType",
],
});
posMasterActs.map((x) => {
let item: any = {
id: x.posMasterChild?.current_holderId || null,
prefix: x.posMasterChild?.current_holder?.prefix || "",
firstName: x.posMasterChild?.current_holder?.firstName || "",
lastName: x.posMasterChild?.current_holder?.lastName || "",
position: x.posMasterChild?.current_holder?.position || "",
posLevel: x.posMasterChild?.current_holder?.posLevel?.posLevelName || "",
posType: x.posMasterChild?.current_holder?.posType?.posTypeName || "",
posExecutiveName:
x.posMasterChild?.positions?.filter((x) => x.positionIsSelected == true)[0]?.posExecutive
?.posExecutiveName || "",
actFullName: `${x.posMaster?.current_holder?.prefix || ""}${x.posMaster?.current_holder?.firstName || ""} ${x.posMaster?.current_holder?.lastName || ""}`,
};
_posMasters.push(item);
});
return new HttpSuccess(_posMasters);
if (body.isAct == true) {
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
.createQueryBuilder("viewDirectorActing")
.andWhere(condition)
.andWhere(
new Brackets((qb) => {
qb.orWhere(
body.keyword != null && body.keyword != ""
? "CONCAT(viewDirectorActing.prefix,viewDirectorActing.firstName,' ',viewDirectorActing.lastName) LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirectorActing.citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirectorActing.position LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirectorActing.posLevel LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirectorActing.posType LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirectorActing.actFullName LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
);
}),
)
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
return new HttpSuccess({ data: lists, total });
} else {
const [lists, total] = await AppDataSource.getRepository(viewDirector)
.createQueryBuilder("viewDirector")
.andWhere(condition)
.andWhere(
new Brackets((qb) => {
qb.orWhere(
body.keyword != null && body.keyword != ""
? "CONCAT(viewDirector.prefix,viewDirector.firstName,' ',viewDirector.lastName) LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirector.citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirector.position LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirector.posLevel LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
body.keyword != null && body.keyword != ""
? "viewDirector.posType LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
);
}),
)
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
return new HttpSuccess({ data: lists, total });
}
}
/**

View file

@ -64,10 +64,22 @@ export class viewDirector {
@ViewColumn()
posType: string;
@ViewColumn()
posExecutiveName: string;
@ViewColumn()
isDirector: boolean;
@ViewColumn()
isDeputy: boolean;
@ViewColumn()
orgRootId: string;
@ViewColumn()
orgChild1Id: string;
@ViewColumn()
orgChild2Id: string;
@ViewColumn()
orgChild3Id: string;
@ViewColumn()
orgChild4Id: string;
@ViewColumn()
actFullNameId: string;
@ViewColumn()
actFullName: string;

View file

@ -72,12 +72,24 @@ export class viewDirectorActing {
@ViewColumn()
posType: string;
@ViewColumn()
posExecutiveName: string;
@ViewColumn()
isDirector: boolean;
@ViewColumn()
isDeputy: boolean;
@ViewColumn()
isDirectorChild: boolean;
@ViewColumn()
orgRootId: string;
@ViewColumn()
orgChild1Id: string;
@ViewColumn()
orgChild2Id: string;
@ViewColumn()
orgChild3Id: string;
@ViewColumn()
orgChild4Id: string;
@ViewColumn()
actFullNameId: string;
@ViewColumn()
actFullName: string;

View file

@ -0,0 +1,183 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileempAddDutyTimeId11730975784560 implements MigrationInterface {
name = 'UpdateTableProfileempAddDutyTimeId11730975784560'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]);
await queryRunner.query(`DROP VIEW \`view_director\``);
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]);
await queryRunner.query(`DROP VIEW \`view_director_acting\``);
await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT
\`profileChild\`.\`id\` AS \`Id\`,
\`profileChild\`.\`prefix\` AS \`prefix\`,
\`profileChild\`.\`firstName\` AS \`firstName\`,
\`profileChild\`.\`lastName\` AS \`lastName\`,
\`profileChild\`.\`citizenId\` AS \`citizenId\`,
\`profileChild\`.\`position\` AS \`position\`,
CONCAT((CASE
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\`
ELSE \`orgChild4Child\`.\`orgChild4ShortName\`
END),
\`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`,
\`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`,
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
NULL AS \`posExecutiveName\`,
\`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`,
CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`,
\`profileChild\`.\`id\`) AS \`key\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`actFullNameId\`,
CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`,
' ',
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\`
FROM
((((((((((((\`bma_ehr_organization_demo\`.\`posMasterAct\`
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`);
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `orgRootChild`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1Child`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2Child`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3Child`.`orgChild3ShortName`\n ELSE `orgChild4Child`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `posMasterChild`.`isDirector` AS `isDirectorChild`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `profileChild`.`id`) AS `key`,\n `bma_ehr_organization_demo`.`profile`.`id` AS `actFullNameId`,\n CONCAT(`bma_ehr_organization_demo`.`profile`.`prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName`,\n ' ',\n `bma_ehr_organization_demo`.`profile`.`lastName`) AS `actFullName`\n FROM\n ((((((((((((`bma_ehr_organization_demo`.`posMasterAct`\n JOIN `bma_ehr_organization_demo`.`posMaster` `posMasterChild` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` `orgRootChild` ON ((`posMasterChild`.`orgRootId` = `orgRootChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` `orgChild1Child` ON ((`posMasterChild`.`orgChild1Id` = `orgChild1Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` `orgChild2Child` ON ((`posMasterChild`.`orgChild2Id` = `orgChild2Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` `orgChild3Child` ON ((`posMasterChild`.`orgChild3Id` = `orgChild3Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` `orgChild4Child` ON ((`posMasterChild`.`orgChild4Id` = `orgChild4Child`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`profileChild`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`profileChild`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posMaster` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterId` = `bma_ehr_organization_demo`.`posMaster`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))"]);
await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT
\`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`,
CONCAT((CASE
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgRoot\`.\`orgRootShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild1\`.\`orgChild1ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild2\`.\`orgChild2ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild3\`.\`orgChild3ShortName\`
ELSE \`bma_ehr_organization_demo\`.\`orgChild4\`.\`orgChild4ShortName\`
END),
\`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`,
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
NULL AS \`posExecutiveName\`,
\`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`,
CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`id\`) AS \`key\`,
NULL AS \`actFullNameId\`,
NULL AS \`actFullName\`
FROM
((((((((\`bma_ehr_organization_demo\`.\`posMaster\`
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` = \`bma_ehr_organization_demo\`.\`orgChild1\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` = \`bma_ehr_organization_demo\`.\`orgChild2\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` = \`bma_ehr_organization_demo\`.\`orgChild3\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` = \`bma_ehr_organization_demo\`.\`orgChild4\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`);
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `bma_ehr_organization_demo`.`profile`.`id` AS `Id`,\n `bma_ehr_organization_demo`.`profile`.`prefix` AS `prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName` AS `firstName`,\n `bma_ehr_organization_demo`.`profile`.`lastName` AS `lastName`,\n `bma_ehr_organization_demo`.`profile`.`citizenId` AS `citizenId`,\n `bma_ehr_organization_demo`.`profile`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgRoot`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild1`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild2`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild3`.`orgChild3ShortName`\n ELSE `bma_ehr_organization_demo`.`orgChild4`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `bma_ehr_organization_demo`.`profile`.`id`) AS `key`,\n NULL AS `actFullNameId`,\n NULL AS `actFullName`\n FROM\n ((((((((`bma_ehr_organization_demo`.`posMaster`\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` = `bma_ehr_organization_demo`.`orgChild1`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` = `bma_ehr_organization_demo`.`orgChild2`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` = `bma_ehr_organization_demo`.`orgChild3`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` = `bma_ehr_organization_demo`.`orgChild4`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`bma_ehr_organization_demo`.`profile`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`bma_ehr_organization_demo`.`profile`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))"]);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]);
await queryRunner.query(`DROP VIEW \`view_director\``);
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]);
await queryRunner.query(`DROP VIEW \`view_director_acting\``);
await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT
\`profileChild\`.\`id\` AS \`Id\`,
\`profileChild\`.\`prefix\` AS \`prefix\`,
\`profileChild\`.\`firstName\` AS \`firstName\`,
\`profileChild\`.\`lastName\` AS \`lastName\`,
\`profileChild\`.\`citizenId\` AS \`citizenId\`,
\`profileChild\`.\`position\` AS \`position\`,
CONCAT((CASE
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\`
ELSE \`orgChild4Child\`.\`orgChild4ShortName\`
END),
\`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`,
\`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`,
\`posMaster\`.\`isDirector\` AS \`isDirector\`,
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
CONCAT(\`posMaster\`.\`id\`,
\`profileChild\`.\`id\`) AS \`key\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`actFullNameId\`,
CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`,
' ',
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\`
FROM
(((((((((((\`bma_ehr_organization_demo\`.\`posMasterAct\`
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`);
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `orgRootChild`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1Child`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2Child`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3Child`.`orgChild3ShortName`\n ELSE `orgChild4Child`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `posMasterChild`.`isDirector` AS `isDirectorChild`,\n `posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n CONCAT(`posMaster`.`id`,\n `profileChild`.`id`) AS `key`,\n `bma_ehr_organization_demo`.`profile`.`id` AS `actFullNameId`,\n CONCAT(`bma_ehr_organization_demo`.`profile`.`prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName`,\n ' ',\n `bma_ehr_organization_demo`.`profile`.`lastName`) AS `actFullName`\n FROM\n (((((((((((`bma_ehr_organization_demo`.`posMasterAct`\n JOIN `bma_ehr_organization_demo`.`posMaster` `posMasterChild` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` `orgRootChild` ON ((`posMasterChild`.`orgRootId` = `orgRootChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` `orgChild1Child` ON ((`posMasterChild`.`orgChild1Id` = `orgChild1Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` `orgChild2Child` ON ((`posMasterChild`.`orgChild2Id` = `orgChild2Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` `orgChild3Child` ON ((`posMasterChild`.`orgChild3Id` = `orgChild3Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` `orgChild4Child` ON ((`posMasterChild`.`orgChild4Id` = `orgChild4Child`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`profileChild`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`profileChild`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posMaster` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterId` = `bma_ehr_organization_demo`.`posMaster`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))"]);
await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT
\`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`,
CONCAT((CASE
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgRoot\`.\`orgRootShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild1\`.\`orgChild1ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild2\`.\`orgChild2ShortName\`
WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild3\`.\`orgChild3ShortName\`
ELSE \`bma_ehr_organization_demo\`.\`orgChild4\`.\`orgChild4ShortName\`
END),
\`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`,
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`id\`) AS \`key\`,
NULL AS \`actFullNameId\`,
NULL AS \`actFullName\`
FROM
((((((((\`bma_ehr_organization_demo\`.\`posMaster\`
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` = \`bma_ehr_organization_demo\`.\`orgChild1\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` = \`bma_ehr_organization_demo\`.\`orgChild2\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` = \`bma_ehr_organization_demo\`.\`orgChild3\`.\`id\`)))
LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` = \`bma_ehr_organization_demo\`.\`orgChild4\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`);
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `bma_ehr_organization_demo`.`profile`.`id` AS `Id`,\n `bma_ehr_organization_demo`.`profile`.`prefix` AS `prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName` AS `firstName`,\n `bma_ehr_organization_demo`.`profile`.`lastName` AS `lastName`,\n `bma_ehr_organization_demo`.`profile`.`citizenId` AS `citizenId`,\n `bma_ehr_organization_demo`.`profile`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgRoot`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild1`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild2`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild3`.`orgChild3ShortName`\n ELSE `bma_ehr_organization_demo`.`orgChild4`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `bma_ehr_organization_demo`.`profile`.`id`) AS `key`,\n NULL AS `actFullNameId`,\n NULL AS `actFullName`\n FROM\n ((((((((`bma_ehr_organization_demo`.`posMaster`\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` = `bma_ehr_organization_demo`.`orgChild1`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` = `bma_ehr_organization_demo`.`orgChild2`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` = `bma_ehr_organization_demo`.`orgChild3`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` = `bma_ehr_organization_demo`.`orgChild4`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`bma_ehr_organization_demo`.`profile`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`bma_ehr_organization_demo`.`profile`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))"]);
}
}