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

This commit is contained in:
Warunee Tamkoo 2024-11-07 10:58:52 +07:00
commit 13ae3987c7
29 changed files with 2018 additions and 736 deletions

View file

@ -1388,6 +1388,11 @@ export class CommandController extends Controller {
const command = await this.commandRepository.findOne({ const command = await this.commandRepository.findOne({
where: { id }, where: { id },
relations: ["commandSigns"], relations: ["commandSigns"],
order: {
commandSigns: {
createdAt: "ASC",
},
},
}); });
if (!command) { if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
@ -1483,8 +1488,8 @@ export class CommandController extends Controller {
commandSign.lastUpdateFullName = request.user.name; commandSign.lastUpdateFullName = request.user.name;
commandSign.lastUpdatedAt = new Date(); commandSign.lastUpdatedAt = new Date();
await this.commandSignRepository.save(commandSign); await this.commandSignRepository.save(commandSign);
if(commandSign.isSignatory == true) if (commandSign.isSignatory == true)
await this.PutSelectPending(commandSign.commandId, { sign: true }, request); await this.PutSelectPending(commandSign.commandId, { sign: true }, request);
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1512,6 +1517,8 @@ export class CommandController extends Controller {
prefix: string | null; prefix: string | null;
firstName: string | null; firstName: string | null;
lastName: string | null; lastName: string | null;
remarkVertical?: string | null;
remarkHorizontal?: string | null;
}[]; }[];
}, },
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@ -1596,6 +1603,36 @@ export class CommandController extends Controller {
let commandRecive = new CommandRecive(); let commandRecive = new CommandRecive();
commandRecive = Object.assign(new CommandRecive(), item); commandRecive = Object.assign(new CommandRecive(), item);
commandRecive.order = order; commandRecive.order = order;
let salaryData = null_;
if (item.profileId) {
salaryData = await this.profileRepository.findOne({
where: {
id: item.profileId,
},
});
let null_: any = 0;
if (!salaryData) {
salaryData = await this.profileEmployeeRepository.findOne({
where: {
id: item.profileId,
},
});
}
commandRecive.amount = salaryData ? salaryData.amount : null_;
commandRecive.positionSalaryAmount = salaryData
? salaryData.positionSalaryAmount
: null_;
commandRecive.mouthSalaryAmount = salaryData ? salaryData.mouthSalaryAmount : null_;
} else {
commandRecive.amount = null_;
commandRecive.positionSalaryAmount = null_;
commandRecive.mouthSalaryAmount = null_;
}
commandRecive.remarkVertical =
item.remarkVertical == null ? null_ : item.remarkVertical;
commandRecive.remarkHorizontal =
item.remarkHorizontal == null ? null_ : item.remarkHorizontal;
commandRecive.order = order;
commandRecive.commandId = command.id; commandRecive.commandId = command.id;
commandRecive.createdUserId = request.user.sub; commandRecive.createdUserId = request.user.sub;
commandRecive.createdFullName = request.user.name; commandRecive.createdFullName = request.user.name;
@ -2431,6 +2468,7 @@ export class CommandController extends Controller {
date: item.date, date: item.date,
refCommandNo: item.refCommandNo, refCommandNo: item.refCommandNo,
templateDoc: item.salaryRef, templateDoc: item.salaryRef,
commandId: item.commandId,
position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null,
positionType: positionType:
profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null,
@ -2469,7 +2507,18 @@ export class CommandController extends Controller {
await this.salaryHistoryRepo.save(history); await this.salaryHistoryRepo.save(history);
}), }),
); );
const checkCommandType = await this.commandRepository.findOne({
where: { id: (body.data.length > 0 ? body.data[0].commandId?.toString() : "") },
relations: ["commandType"]
});
if(checkCommandType?.commandType.code == "C-PM-11") {
const profile = await this.profileRepository.find({ where: { id: In(body.data.map(x => x.profileId)) } });
const data = profile.map((x) => ({
...x,
isProbation: false,
}));
await this.profileRepository.save(data);
}
return new HttpSuccess(); return new HttpSuccess();
} }
@ -2949,7 +2998,34 @@ export class CommandController extends Controller {
posMasterId: profile.posmasterIdTemp, posMasterId: profile.posmasterIdTemp,
}, },
}); });
if (positionNew != null) { if (positionNew != null) {
// Create Keycloak
const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
firstName: profile.firstName,
lastName: profile.lastName,
// email: profile.email,
});
if (typeof userKeycloakId !== "string") {
throw new Error(userKeycloakId.errorMessage);
}
const list = await getRoles();
if (!Array.isArray(list))
throw new Error("Failed. Cannot get role(s) data from the server.");
const result = await addUserRoles(
userKeycloakId,
list
.filter((v) => v.name === "USER")
.map((x) => ({
id: x.id,
name: x.name,
})),
);
if (!result) throw new Error("Failed. Cannot set user's role.");
profile.keycloak = userKeycloakId;
// End Create Keycloak
positionNew.positionIsSelected = true; positionNew.positionIsSelected = true;
profile.posLevelId = positionNew.posLevelId; profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId; profile.posTypeId = positionNew.posTypeId;
@ -3058,7 +3134,6 @@ export class CommandController extends Controller {
body.refIds.map(async (item, i) => { body.refIds.map(async (item, i) => {
const posMasterAct = await this.posMasterActRepository.findOne({ const posMasterAct = await this.posMasterActRepository.findOne({
relations: [ relations: [
"posMaster",
"posMaster", "posMaster",
"posMaster.orgRoot", "posMaster.orgRoot",
"posMaster.orgChild1", "posMaster.orgChild1",
@ -3108,18 +3183,17 @@ export class CommandController extends Controller {
.join("/"); .join("/");
var _data = { var _data = {
no: Extension.ToThaiNumber((i + 1).toString()), no: Extension.ToThaiNumber((i + 1).toString()),
fullName: fullName: `${item.Prefix ?? ""}${item.FirstName ?? ""} ${item.LastName ?? ""}`,
posMasterAct.posMasterChild?.current_holder?.prefix ??
"" + posMasterAct.posMasterChild?.current_holder?.firstName ??
"" + " " + posMasterAct.posMasterChild?.current_holder?.lastName ??
null,
oc: oc:
(posMasterAct.posMasterChild?.current_holder?.position ?? "-") + /*(posMasterAct.posMasterChild?.current_holder?.position ?? "-") +
"/" + "/" +*/
(_organization ?? "-"), (_organization ?? "-"),
postype: posMasterAct.posMasterChild?.current_holder?.posType?.posTypeName ?? "-", postype: posMasterAct.posMasterChild?.current_holder?.posType?.posTypeName ?? "-",
poslevel: posMasterAct.posMasterChild?.current_holder?.posLevel?.posLevelName ?? "-", poslevel: posMasterAct.posMasterChild?.current_holder?.posLevel?.posLevelName ?? "-",
organizationNew: _organizationNew ?? "-", organizationNew:
/*(posMasterAct.posMaster?.current_holder?.position ?? "-") +
"/" +*/
(_organizationNew ?? "-"),
// date: Extension.ToThaiShortDate_noPrefix(new Date()), // date: Extension.ToThaiShortDate_noPrefix(new Date()),
dateStart: "-", dateStart: "-",
dateEnd: "-", dateEnd: "-",

View file

@ -5373,10 +5373,11 @@ export class OrganizationController extends Controller {
posMaster: await Promise.all( posMaster: await Promise.all(
orgRoot.posMasters orgRoot.posMasters
.filter( .filter(
(x) => x.orgChild1Id == null && x.current_holderId != null && x.posMasterOrder <= 3, (x) => x.orgChild1Id == null && x.current_holderId != null && x.posMasterOrder <= 3 && x.isDirector === true,
) )
.map(async (x) => ({ .map(async (x) => ({
posmasterId: x.id, posmasterId: x.id,
posNo: orgRoot.orgRootShortName + x.posMasterNo,
orgTreeId: orgRoot.id, orgTreeId: orgRoot.id,
orgLevel: 0, orgLevel: 0,
fullNameCurrentHolder: fullNameCurrentHolder:
@ -5411,10 +5412,12 @@ export class OrganizationController extends Controller {
(x) => (x) =>
x.orgChild2Id == null && x.orgChild2Id == null &&
x.current_holderId != null && x.current_holderId != null &&
x.posMasterOrder <= 3, x.posMasterOrder <= 3 &&
x.isDirector === true
) )
.map(async (x) => ({ .map(async (x) => ({
posmasterId: x.id, posmasterId: x.id,
posNo: orgChild1.orgChild1ShortName + x.posMasterNo,
orgTreeId: orgChild1.id, orgTreeId: orgChild1.id,
orgLevel: 1, orgLevel: 1,
fullNameCurrentHolder: fullNameCurrentHolder:
@ -5450,10 +5453,12 @@ export class OrganizationController extends Controller {
(x) => (x) =>
x.orgChild3Id == null && x.orgChild3Id == null &&
x.current_holderId != null && x.current_holderId != null &&
x.posMasterOrder <= 3, x.posMasterOrder <= 3 &&
x.isDirector === true,
) )
.map(async (x) => ({ .map(async (x) => ({
posmasterId: x.id, posmasterId: x.id,
posNo: orgChild2.orgChild2ShortName + x.posMasterNo,
orgTreeId: orgChild2.id, orgTreeId: orgChild2.id,
orgLevel: 2, orgLevel: 2,
fullNameCurrentHolder: fullNameCurrentHolder:
@ -5489,10 +5494,12 @@ export class OrganizationController extends Controller {
(x) => (x) =>
x.orgChild4Id == null && x.orgChild4Id == null &&
x.current_holderId != null && x.current_holderId != null &&
x.posMasterOrder <= 3, x.posMasterOrder <= 3 &&
x.isDirector === true,
) )
.map(async (x) => ({ .map(async (x) => ({
posmasterId: x.id, posmasterId: x.id,
posNo: orgChild3.orgChild3ShortName + x.posMasterNo,
orgTreeId: orgChild3.id, orgTreeId: orgChild3.id,
orgLevel: 3, orgLevel: 3,
fullNameCurrentHolder: fullNameCurrentHolder:
@ -5525,10 +5532,11 @@ export class OrganizationController extends Controller {
posMaster: await Promise.all( posMaster: await Promise.all(
orgChild4.posMasters orgChild4.posMasters
.filter( .filter(
(x) => x.current_holderId != null && x.posMasterOrder <= 3, (x) => x.current_holderId != null && x.posMasterOrder <= 3 && x.isDirector === true,
) )
.map(async (x) => ({ .map(async (x) => ({
posmasterId: x.id, posmasterId: x.id,
posNo: orgChild4.orgChild4ShortName + x.posMasterNo,
orgTreeId: orgChild4.id, orgTreeId: orgChild4.id,
orgLevel: 4, orgLevel: 4,
fullNameCurrentHolder: fullNameCurrentHolder:

View file

@ -254,6 +254,26 @@ export class PermissionController extends Controller {
return new HttpSuccess(res); return new HttpSuccess(res);
} }
/**
* API permission (dotnet api)
* @summary permission (dotnet api)
* @param {string} action action
* @param {string} system authSysId
*/
@Get("dotnet-org/{action}/{system}/{profileId}")
public async dotnetOrg(
@Request() req: RequestWithUser,
@Path() action: string,
@Path() system: string,
) {
if (!["CREATE", "DELETE", "GET", "LIST", "UPDATE"].includes(action)) {
throw new HttpError(HttpStatus.NOT_FOUND, "Action ไม่ถูกต้อง");
}
let res = await new permission().PermissionOrg(req, system.toLocaleUpperCase(), action);
return new HttpSuccess(res);
}
/** /**
* API permission (dotnet api) * API permission (dotnet api)
* @summary permission (dotnet api) * @summary permission (dotnet api)
@ -743,9 +763,7 @@ export class PermissionController extends Controller {
} }
@Get("checkOrg/{keycloakId}") @Get("checkOrg/{keycloakId}")
public async checkOrg( public async checkOrg(@Path() keycloakId: string) {
@Path() keycloakId: string,
) {
const redisClient = await this.redis.createClient({ const redisClient = await this.redis.createClient({
host: REDIS_HOST, host: REDIS_HOST,
port: REDIS_PORT, port: REDIS_PORT,
@ -768,64 +786,64 @@ export class PermissionController extends Controller {
// } // }
// } // }
let reply: any; let reply: any;
const orgRevision = await this.orgRevisionRepository.findOne({ const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"], select: ["id"],
where: { where: {
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
}, },
}); });
// if (profileType == "OFFICER") { // if (profileType == "OFFICER") {
const posMaster = await this.posMasterRepository.findOne({ const posMaster = await this.posMasterRepository.findOne({
where: { where: {
current_holderId: profile.id, current_holderId: profile.id,
orgRevisionId: orgRevision?.id, orgRevisionId: orgRevision?.id,
}, },
}); });
if (!posMaster) { if (!posMaster) {
reply = { reply = {
orgRootId: null, orgRootId: null,
orgChild1Id: null, orgChild1Id: null,
orgChild2Id: null, orgChild2Id: null,
orgChild3Id: null, orgChild3Id: null,
orgChild4Id: null, orgChild4Id: null,
}; };
} else { } else {
reply = { reply = {
orgRootId: posMaster.orgRootId, orgRootId: posMaster.orgRootId,
orgChild1Id: posMaster.orgChild1Id, orgChild1Id: posMaster.orgChild1Id,
orgChild2Id: posMaster.orgChild2Id, orgChild2Id: posMaster.orgChild2Id,
orgChild3Id: posMaster.orgChild3Id, orgChild3Id: posMaster.orgChild3Id,
orgChild4Id: posMaster.orgChild4Id, orgChild4Id: posMaster.orgChild4Id,
}; };
} }
redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply)); //Create Redis redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply)); //Create Redis
// } else { // } else {
// const posMaster = await this.posMasterEmpRepository.findOne({ // const posMaster = await this.posMasterEmpRepository.findOne({
// where: { // where: {
// current_holderId: profile.id, // current_holderId: profile.id,
// orgRevisionId: orgRevision?.id, // orgRevisionId: orgRevision?.id,
// }, // },
// }); // });
// if (!posMaster) { // if (!posMaster) {
// reply = { // reply = {
// orgRootId: null, // orgRootId: null,
// orgChild1Id: null, // orgChild1Id: null,
// orgChild2Id: null, // orgChild2Id: null,
// orgChild3Id: null, // orgChild3Id: null,
// orgChild4Id: null, // orgChild4Id: null,
// }; // };
// } else { // } else {
// reply = { // reply = {
// orgRootId: posMaster.orgRootId, // orgRootId: posMaster.orgRootId,
// orgChild1Id: posMaster.orgChild1Id, // orgChild1Id: posMaster.orgChild1Id,
// orgChild2Id: posMaster.orgChild2Id, // orgChild2Id: posMaster.orgChild2Id,
// orgChild3Id: posMaster.orgChild3Id, // orgChild3Id: posMaster.orgChild3Id,
// orgChild4Id: posMaster.orgChild4Id, // orgChild4Id: posMaster.orgChild4Id,
// }; // };
// } // }
// redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply)); // redisClient.setex("org_" + profile.id, 86400, JSON.stringify(reply));
// } // }
return new HttpSuccess(reply); return new HttpSuccess(reply);
} }

View file

@ -1695,157 +1695,156 @@ export class PositionController extends Controller {
child4: null, child4: null,
privilege: "OWNER", privilege: "OWNER",
}; };
const conditions = [ const conditions = [
{
...checkChildConditions,
...typeCondition,
...revisionCondition,
...(body.keyword &&
(masterId.length > 0
? { id: In(masterId) }
: { posMasterNo: Like(`%${body.keyword}%`) })),
},
];
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
.createQueryBuilder("posMaster")
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
.leftJoinAndSelect("posMaster.next_holder", "next_holder")
.leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
.where(conditions)
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `posMaster.orgRootId IN (:...root)`
: `posMaster.orgRootId is null`
: "1=1",
{ {
...checkChildConditions, root: _data.root,
...typeCondition,
...revisionCondition,
...(body.keyword &&
(masterId.length > 0
? { id: In(masterId) }
: { posMasterNo: Like(`%${body.keyword}%`) })),
}, },
]; )
.andWhere(
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `posMaster.orgChild1Id IN (:...child1)`
: `posMaster.orgChild1Id is null`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null
? `posMaster.orgChild2Id IN (:...child2)`
: `posMaster.orgChild2Id is null`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null
? `posMaster.orgChild3Id IN (:...child3)`
: `posMaster.orgChild3Id is null`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null
? `posMaster.orgChild4Id IN (:...child4)`
: `posMaster.orgChild4Id is null`
: "1=1",
{
child4: _data.child4,
},
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? body.isAll == false
? searchShortName
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
: "1=1",
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.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(
body.keyword != null && body.keyword != ""
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orderBy("posMaster.posMasterOrder", "ASC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
let [posMaster, total] = await AppDataSource.getRepository(PosMaster) //แก้ค้นหา
.createQueryBuilder("posMaster") let _position: any[] = [];
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot") let x: any = null;
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1") let y: any = null;
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2") if (body.keyword != null && body.keyword != "") {
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3") const position = await this.positionRepository.find({
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4") relations: ["posType", "posLevel", "posExecutive"],
.leftJoinAndSelect("posMaster.current_holder", "current_holder") where: { posMasterId: In(posMaster.map((x) => x.id)) },
.leftJoinAndSelect("posMaster.next_holder", "next_holder") order: { createdAt: "ASC" },
.leftJoinAndSelect("posMaster.orgRevision", "orgRevision") });
.where(conditions) for (let data of position) {
.andWhere( x = data.posMasterId;
_data.root != undefined && _data.root != null if (y != x) {
? _data.root[0] != null if (
? `posMaster.orgRootId IN (:...root)` data.positionName.includes(body.keyword) ||
: `posMaster.orgRootId is null` data.posType.posTypeName.includes(body.keyword) ||
: "1=1", data.posLevel.posLevelName.includes(body.keyword)
{ ) {
root: _data.root, _position.push(data);
},
)
.andWhere(
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `posMaster.orgChild1Id IN (:...child1)`
: `posMaster.orgChild1Id is null`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null
? `posMaster.orgChild2Id IN (:...child2)`
: `posMaster.orgChild2Id is null`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null
? `posMaster.orgChild3Id IN (:...child3)`
: `posMaster.orgChild3Id is null`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null
? `posMaster.orgChild4Id IN (:...child4)`
: `posMaster.orgChild4Id is null`
: "1=1",
{
child4: _data.child4,
},
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(
body.keyword != null && body.keyword != ""
? body.isAll == false
? searchShortName
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
: "1=1",
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.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(
body.keyword != null && body.keyword != ""
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
: "1=1",
{
keyword: `%${body.keyword}%`,
},
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition);
}),
)
.orderBy("posMaster.posMasterOrder", "ASC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
//แก้ค้นหา
let _position: any[] = [];
let x: any = null;
let y: any = null;
if (body.keyword != null && body.keyword != ""){
const position = await this.positionRepository.find({
relations: ["posType", "posLevel", "posExecutive"],
where: { posMasterId: In(posMaster.map(x => x.id))},
order: { createdAt: "ASC" }
});
for(let data of position){
x = data.posMasterId
if(y != x){
if(
data.positionName.includes(body.keyword) ||
data.posType.posTypeName.includes(body.keyword) ||
data.posLevel.posLevelName.includes(body.keyword)
){
_position.push(data);
}
} }
y = x;
} }
y = x;
} }
}
if(_position.length > 0){ if (_position.length > 0) {
posMaster = posMaster.filter((x) => _position.some(y => y.posMasterId === x.id)); posMaster = posMaster.filter((x) => _position.some((y) => y.posMasterId === x.id));
} }
const formattedData = await Promise.all( const formattedData = await Promise.all(
posMaster.map(async (posMaster) => { posMaster.map(async (posMaster) => {
@ -3312,10 +3311,10 @@ export class PositionController extends Controller {
.getManyAndCount(); .getManyAndCount();
const _posType = await this.posTypeRepository.find({ const _posType = await this.posTypeRepository.find({
where: { posTypeName: In(["ทั่วไป", "วิชาการ"]) } where: { posTypeName: In(["ทั่วไป", "วิชาการ"]) },
}); });
const _posLevel = await this.posLevelRepository.find({ const _posLevel = await this.posLevelRepository.find({
where: { posLevelName: In(["ปฏิบัติงาน", "ปฏิบัติการ"]) } where: { posLevelName: In(["ปฏิบัติงาน", "ปฏิบัติการ"]) },
}); });
const formattedData = await Promise.all( const formattedData = await Promise.all(
@ -3382,12 +3381,13 @@ export class PositionController extends Controller {
nodeId = posMaster.orgRootId; nodeId = posMaster.orgRootId;
} }
let _position: any let _position: any;
if( posLevel == null && posType == null && body.position != null) { if (posLevel == null && posType == null && body.position != null) {
_position = posMaster.positions _position = posMaster.positions
.filter((x:any) => .filter(
_posType.some((y:any) => y.id == x.posTypeId) && (x: any) =>
_posLevel.some((z:any) => z.id == x.posLevelId) _posType.some((y: any) => y.id == x.posTypeId) &&
_posLevel.some((z: any) => z.id == x.posLevelId),
) )
.map((position) => ({ .map((position) => ({
id: position.id, id: position.id,
@ -3405,8 +3405,7 @@ export class PositionController extends Controller {
positionIsSelected: position.positionIsSelected, positionIsSelected: position.positionIsSelected,
isSpecial: position.isSpecial, isSpecial: position.isSpecial,
})); }));
} } else {
else {
_position = posMaster.positions.map((position) => ({ _position = posMaster.positions.map((position) => ({
id: position.id, id: position.id,
positionName: position.positionName, positionName: position.positionName,
@ -4594,7 +4593,7 @@ export class PositionController extends Controller {
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4") .leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
.where(conditions) .where(conditions)
.andWhere({ .andWhere({
current_holderId: Not(IsNull()), current_holderId: IsNull(),
}) })
.andWhere( .andWhere(
_data.root != undefined && _data.root != null _data.root != undefined && _data.root != null

View file

@ -31,7 +31,7 @@ import {
UpdateProfileMother, UpdateProfileMother,
UpdateProfileCouple, UpdateProfileCouple,
} from "../entities/Profile"; } from "../entities/Profile";
import { Any, Brackets, In, IsNull, Like, Not } from "typeorm"; import { Brackets, IsNull, Like, Not } from "typeorm";
import { OrgRevision } from "../entities/OrgRevision"; import { OrgRevision } from "../entities/OrgRevision";
import { PosMaster } from "../entities/PosMaster"; import { PosMaster } from "../entities/PosMaster";
import { PosLevel } from "../entities/PosLevel"; import { PosLevel } from "../entities/PosLevel";
@ -40,7 +40,6 @@ import {
calculateAge, calculateAge,
calculateRetireDate, calculateRetireDate,
calculateRetireLaw, calculateRetireLaw,
calculateRetireYear,
removeProfileInOrganize, removeProfileInOrganize,
setLogDataDiff, setLogDataDiff,
} from "../interfaces/utils"; } from "../interfaces/utils";
@ -54,25 +53,22 @@ import { ProfileCertificate } from "../entities/ProfileCertificate";
import { ProfileTraining } from "../entities/ProfileTraining"; import { ProfileTraining } from "../entities/ProfileTraining";
import { ProfileDiscipline } from "../entities/ProfileDiscipline"; import { ProfileDiscipline } from "../entities/ProfileDiscipline";
import { ProfileEducation } from "../entities/ProfileEducation"; import { ProfileEducation } from "../entities/ProfileEducation";
import { CreateProfileSalary, ProfileSalary } from "../entities/ProfileSalary"; import { ProfileSalary } from "../entities/ProfileSalary";
import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple"; import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother"; import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather"; import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
import CallAPI from "../interfaces/call-api";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import { Prefixe } from "../entities/Prefixe";
import { ProfileInsignia } from "../entities/ProfileInsignia"; import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileDisciplineHistory } from "../entities/ProfileDisciplineHistory";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import { updateName } from "../keycloak"; import { updateName } from "../keycloak";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import { PosMasterAct } from "../entities/PosMasterAct"; import { PosMasterAct } from "../entities/PosMasterAct";
import axios from "axios"; import axios from "axios";
import { OrgChild1 } from "../entities/OrgChild1";
import { viewCommanderDirector } from "../entities/view/viewCommanderDirector";
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory"; import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory"; import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory"; import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
import { viewDirector } from "../entities/view/viewDirector";
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
@Route("api/v1/org/profile") @Route("api/v1/org/profile")
@Tags("Profile") @Tags("Profile")
@Security("bearerAuth") @Security("bearerAuth")
@ -105,17 +101,13 @@ export class ProfileController extends Controller {
private educationRepository = AppDataSource.getRepository(ProfileEducation); private educationRepository = AppDataSource.getRepository(ProfileEducation);
private salaryRepository = AppDataSource.getRepository(ProfileSalary); private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation); private profileEducationRepository = AppDataSource.getRepository(ProfileEducation);
private prefixRepo = AppDataSource.getRepository(Prefixe);
private provinceRepo = AppDataSource.getRepository(Province); private provinceRepo = AppDataSource.getRepository(Province);
private districtRepo = AppDataSource.getRepository(District); private districtRepo = AppDataSource.getRepository(District);
private subDistrictRepo = AppDataSource.getRepository(SubDistrict); private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia); private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private profileDisciplineRepo = AppDataSource.getRepository(ProfileDiscipline); private profileDisciplineRepo = AppDataSource.getRepository(ProfileDiscipline);
private disciplineHistoryRepository = AppDataSource.getRepository(ProfileDisciplineHistory);
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
private posMasterActRepository = AppDataSource.getRepository(PosMasterAct); private posMasterActRepository = AppDataSource.getRepository(PosMasterAct);
private orgChild1Repository = AppDataSource.getRepository(OrgChild1);
private viewCommanderDirectorRepository = AppDataSource.getRepository(viewCommanderDirector);
/** /**
* report * report
@ -237,54 +229,57 @@ export class ProfileController extends Controller {
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
}); });
const Education = educations.map((item) => ({ const Education = educations.map((item) => ({
Institute: item.institute ? item.institute : "-", institute: item.institute ? item.institute : "-",
Date: date:
item.startDate && item.endDate item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}` ? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
: "-", : "-",
Degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-", degree: item.degree && item.field ? `${item.degree} ${item.field}` : "-",
})); }));
const mapData = { const mapData = {
Id: profile.id, // Id: profile.id,
CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-", fullName: `${profile?.prefix}${profile?.firstName} ${profile?.lastName}`,
Prefix: profile.prefix != null ? profile.prefix : null, prefix: profile.prefix != null ? profile.prefix : null,
FirstName: profile.firstName != null ? profile.firstName : null, firstName: profile.firstName != null ? profile.firstName : null,
LastName: profile.lastName != null ? profile.lastName : null, lastName: profile.lastName != null ? profile.lastName : null,
DateOfBirth: citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-",
dateOfBirth:
profile.birthDate != null profile.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate))
: "-", : "-",
DateRetire: dateRetire:
profile.dateRetire != null profile.dateRetire != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire))
: "-", : "-",
RegistrationAddress: Extension.ToThaiNumber( salaryAmount:
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
),
SalaryAmount:
profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString()) ? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
: "-", : "-",
Education: Education, registrationAddress: Extension.ToThaiNumber(
AppointText: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
profile.dateAppoint != null ),
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint)) salaryDate:
: "-",
SalaryDate:
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date), Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date),
) )
: "-", : "-",
PositionName: profile.position != null ? profile.position : "-", positionName: profile.position != null ? profile.position : "-",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, appointText:
ImgUrl: ImgUrl profile.dateAppoint != null
? ImgUrl ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint))
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, : "-",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
educations: Education,
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
}; };
return new HttpSuccess(mapData); return new HttpSuccess({
template: "kp7",
reportName: "docx-report",
data: mapData,
});
} }
/** /**
@ -674,109 +669,96 @@ export class ProfileController extends Controller {
}, },
]; ];
const data = { const data = {
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`, fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
prefix: profiles?.prefix != null ? profiles.prefix : "", prefix: profiles?.prefix != null ? profiles.prefix : "",
firstName: profiles?.firstName != null ? profiles.firstName : "", firstName: profiles?.firstName != null ? profiles.firstName : "",
lastName: profiles?.lastName != null ? profiles.lastName : "", lastName: profiles?.lastName != null ? profiles.lastName : "",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
birthDate: profiles?.birthDate birthDate: profiles?.birthDate
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
: "", : "",
retireDate: retireDate:
profiles.dateRetireLaw != null profiles.dateRetireLaw != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
: "", : "",
appointDate: profiles?.dateAppoint appointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "", : "",
citizenId: citizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "", profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
fatherFullName: fatherFullName:
profileFamilyFather?.fatherPrefix || profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName || profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim() ? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null, : null,
motherFullName: motherFullName:
profileFamilyMother?.motherPrefix || profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName || profileFamilyMother?.motherFirstName ||
profileFamilyMother?.motherLastName profileFamilyMother?.motherLastName
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim() ? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
: null, : null,
coupleFullName: coupleFullName:
profileFamilyCouple?.couplePrefix || profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName || profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim() ? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim()
: null, : null,
coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null, coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
currentAddress: currentAddress:
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "", profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
currentSubDistrict: currentSubDistrict:
profiles.currentSubDistrict != null profiles.currentSubDistrict != null
? Extension.ToThaiNumber(profiles.currentSubDistrict.name) ? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
: "", : "",
currentDistrict: currentDistrict:
profiles.currentDistrict != null profiles.currentDistrict != null
? Extension.ToThaiNumber(profiles.currentDistrict.name) ? Extension.ToThaiNumber(profiles.currentDistrict.name)
: "", : "",
currentProvince: currentProvince:
profiles.currentProvince != null profiles.currentProvince != null
? Extension.ToThaiNumber(profiles.currentProvince.name) ? Extension.ToThaiNumber(profiles.currentProvince.name)
: "", : "",
telephone: telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "", profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
url: ImgUrl url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
? ImgUrl url1: _ImgUrl[0] ? _ImgUrl[0] : null,
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, yearUpload1: profiles.profileAvatars[0]
url1: _ImgUrl[0] ? _ImgUrl[0] : null, ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
url2: _ImgUrl[1] ? _ImgUrl[1] : null, : null,
url3: _ImgUrl[2] ? _ImgUrl[2] : null, url2: _ImgUrl[1] ? _ImgUrl[1] : null,
url4: _ImgUrl[3] ? _ImgUrl[3] : null, yearUpload2: profiles.profileAvatars[1]
url5: _ImgUrl[4] ? _ImgUrl[4] : null, ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[1].createdAt))
url6: _ImgUrl[5] ? _ImgUrl[5] : null, : null,
url7: _ImgUrl[6] ? _ImgUrl[6] : null, url3: _ImgUrl[2] ? _ImgUrl[2] : null,
yearUpload3: profiles.profileAvatars[2]
// BirthDay: profiles?.birthDate ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[2].createdAt))
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString()) : null,
// : null, url4: _ImgUrl[3] ? _ImgUrl[3] : null,
// BirthDayText: yearUpload4: profiles.profileAvatars[3]
// profiles.birthDate != null ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[3].createdAt))
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString()) : null,
// : "", url5: _ImgUrl[4] ? _ImgUrl[4] : null,
// BirthMonth: profiles?.birthDate yearUpload5: profiles.profileAvatars[4]
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString()) ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[4].createdAt))
// : null, // Months are zero-based : null,
// BirthYear: profiles?.birthDate url6: _ImgUrl[5] ? _ImgUrl[5] : null,
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString()) yearUpload6: profiles.profileAvatars[5]
// : null, ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[5].createdAt))
// BirthYearText: : null,
// profiles.birthDate != null url7: _ImgUrl[6] ? _ImgUrl[6] : null,
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString()) yearUpload7: profiles.profileAvatars[6]
// : "", ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt))
// Address: "", : null,
// District: "", insignias,
// Area: "", leaves,
// Province: "", certs,
// CouplePrefix: profileFamilyCouple?.couplePrefix ?? "", trainings,
// FatherPrefix: profileFamilyFather?.fatherPrefix ?? "", disciplines,
// MotherPrefix: profileFamilyMother?.motherPrefix ?? "", educations,
// Division: "", salarys,
// Institute: "", };
// StartDate: profiles?.dateStart
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateStart))
// : "",
// AvatarId: profiles?.avatar ?? null,
insignias,
leaves,
certs,
trainings,
disciplines,
educations,
salarys,
};
return new HttpSuccess({ return new HttpSuccess({
template: "kk1", template: "kk1",
@ -1280,8 +1262,8 @@ export class ProfileController extends Controller {
* *
* *
*/ */
@Post("commander-director") @Post("commander-director-act")
async getProfileCommanderDirector( async getProfileCommanderDirectorAct(
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@Body() body: { isDirector: boolean; keyword: string; page: number; pageSize: number }, @Body() body: { isDirector: boolean; keyword: string; page: number; pageSize: number },
) { ) {
@ -1302,14 +1284,14 @@ export class ProfileController extends Controller {
isDirector: true, isDirector: true,
}; };
} }
const [lists, total] = await AppDataSource.getRepository(viewCommanderDirector) const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
.createQueryBuilder("viewCommanderDirector") .createQueryBuilder("viewDirectorActing")
.andWhere(condition) .andWhere(condition)
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere( qb.orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "CONCAT(viewCommanderDirector.prefix,viewCommanderDirector.firstName,' ',viewCommanderDirector.lastName) LIKE :keyword" ? "CONCAT(viewDirectorActing.prefix,viewDirectorActing.firstName,' ',viewDirectorActing.lastName) LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -1317,7 +1299,7 @@ export class ProfileController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "viewCommanderDirector.citizenId LIKE :keyword" ? "viewDirectorActing.citizenId LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -1325,7 +1307,7 @@ export class ProfileController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "viewCommanderDirector.position LIKE :keyword" ? "viewDirectorActing.position LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -1333,7 +1315,7 @@ export class ProfileController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "viewCommanderDirector.posLevel LIKE :keyword" ? "viewDirectorActing.posLevel LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -1341,7 +1323,7 @@ export class ProfileController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "viewCommanderDirector.posType LIKE :keyword" ? "viewDirectorActing.posType LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -1349,7 +1331,7 @@ export class ProfileController extends Controller {
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
? "viewCommanderDirector.actFullName LIKE :keyword" ? "viewDirectorActing.actFullName LIKE :keyword"
: "1=1", : "1=1",
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
@ -1362,6 +1344,170 @@ export class ProfileController extends Controller {
.getManyAndCount(); .getManyAndCount();
return new HttpSuccess({ data: lists, total }); return new HttpSuccess({ data: lists, total });
} }
/**
*
*
*/
@Post("commander-director")
async getProfileCommanderDirector(
@Request() request: RequestWithUser,
@Body()
body: {
isAct: boolean;
isDirector: boolean;
keyword: string;
page: number;
pageSize: number;
},
) {
if (body.isAct == true) {
const posMaster = await this.posMasterRepo.findOne({
where: {
current_holder: { keycloak: request.user.sub },
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
});
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
let condition: any = {
orgRootId: posMaster.orgRootId || "",
};
// if (body.isDirector == true) {
condition = {
orgRootId: posMaster.orgRootId || "",
isDirector: 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 posMaster = await this.posMasterRepo.findOne({
where: {
current_holder: { keycloak: request.user.sub },
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
});
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
let condition: any = {
orgRootId: posMaster.orgRootId || "",
};
if (body.isDirector == true) {
condition = {
orgRootId: posMaster.orgRootId || "",
isDirector: true,
};
}
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 });
}
}
/** /**
* API User (ADMIN) * API User (ADMIN)
@ -2627,7 +2773,6 @@ export class ProfileController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
} }
let dateLeave_: any = body.date;
let null_: any = null; let null_: any = null;
profile.isLeave = false; profile.isLeave = false;
profile.leaveReason = null_; profile.leaveReason = null_;
@ -2700,7 +2845,6 @@ export class ProfileController extends Controller {
@Body() body: UpdateProfileReqEdit, @Body() body: UpdateProfileReqEdit,
) { ) {
const record = await this.profileRepo.findOneBy({ id }); const record = await this.profileRepo.findOneBy({ id });
const before = structuredClone(record);
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
@ -2749,15 +2893,14 @@ export class ProfileController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateProfileFather, @Body() body: UpdateProfileFather,
) { ) {
const profile = await this.profileRepo.findOneBy({ id: id });
const profile = await this.profileRepo.findOneBy({ id:id });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
let lastestData:any = await this.profileFamilyFatherRepository.findOne({ let lastestData: any = await this.profileFamilyFatherRepository.findOne({
where:{ profileId:id }, where: { profileId: id },
order:{ createdAt: "DESC" } order: { createdAt: "DESC" },
}); });
Object.keys(body).forEach((key) => { Object.keys(body).forEach((key) => {
@ -2766,9 +2909,9 @@ export class ProfileController extends Controller {
}); });
if (!lastestData) { if (!lastestData) {
lastestData = new ProfileFamilyFather(); lastestData = new ProfileFamilyFather();
Object.assign(lastestData, body); Object.assign(lastestData, body);
lastestData.profileId = id; lastestData.profileId = id;
} }
Object.assign(lastestData, body); Object.assign(lastestData, body);
@ -2801,15 +2944,14 @@ export class ProfileController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateProfileMother, @Body() body: UpdateProfileMother,
) { ) {
const profile = await this.profileRepo.findOneBy({ id: id });
const profile = await this.profileRepo.findOneBy({ id:id });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
let lastestData = await this.profileFamilyMotherRepository.findOne({ let lastestData = await this.profileFamilyMotherRepository.findOne({
where:{ profileId:id }, where: { profileId: id },
order:{ createdAt: "DESC" } order: { createdAt: "DESC" },
}); });
Object.keys(body).forEach((key) => { Object.keys(body).forEach((key) => {
@ -2853,15 +2995,14 @@ export class ProfileController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateProfileCouple, @Body() body: UpdateProfileCouple,
) { ) {
const profile = await this.profileRepo.findOneBy({ id: id });
const profile = await this.profileRepo.findOneBy({ id:id });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
let lastestData = await this.profileFamilyCoupleRepository.findOne({ let lastestData = await this.profileFamilyCoupleRepository.findOne({
where:{ profileId:id }, where: { profileId: id },
order:{ createdAt: "DESC" } order: { createdAt: "DESC" },
}); });
Object.keys(body).forEach((key) => { Object.keys(body).forEach((key) => {
@ -2999,8 +3140,6 @@ export class ProfileController extends Controller {
return new HttpSuccess(); return new HttpSuccess();
} }
/** /**
* API * API
* *
@ -3052,7 +3191,7 @@ export class ProfileController extends Controller {
async getProfileIdByKeycloak(@Request() request: RequestWithUser) { async getProfileIdByKeycloak(@Request() request: RequestWithUser) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { keycloak: request.user.sub }, where: { keycloak: request.user.sub },
select:["id"] select: ["id"],
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -3813,6 +3952,7 @@ export class ProfileController extends Controller {
position: `%${requestBody.position}%`, position: `%${requestBody.position}%`,
}, },
) )
.andWhere("profile.isLeave IS FALSE")
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.where( qb.where(
@ -3993,7 +4133,164 @@ export class ProfileController extends Controller {
}, },
}); });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); const profile = await this.profileEmpRepo.findOne({
where: { keycloak: request.user.sub },
relations: [
"posLevel",
"posType",
"current_holders",
"current_holders.orgRoot",
"profileSalarys",
],
order: {
profileSalarys: {
order: "DESC",
},
},
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
}
let orgRevisionPublish: any = await this.orgRevisionRepo
.createQueryBuilder("orgRevision")
.where("orgRevision.orgRevisionIsDraft = false")
.andWhere("orgRevision.orgRevisionIsCurrent = true")
.getOne();
if (!orgRevisionPublish) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
}
if (revisionId) {
orgRevisionPublish = await this.orgRevisionRepo
.createQueryBuilder("orgRevision")
.where("orgRevision.id = :revisionId", { revisionId })
.getOne();
if (!orgRevisionPublish) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
}
}
const posMaster =
profile.current_holders == null ||
profile.current_holders.length == 0 ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
const root =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
const child1 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild1;
const child2 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild2;
const child3 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild3;
const child4 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild4;
const position = await this.positionRepository.findOne({
relations: ["posExecutive"],
where: {
posMasterId: posMaster?.id,
},
});
const _profile: any = {
profileId: profile.id,
prefix: profile.prefix,
rank: profile.rank,
avatar: profile.avatar,
isProbation: profile.isProbation,
avatarName: profile.avatarName,
firstName: profile.firstName,
lastName: profile.lastName,
citizenId: profile.citizenId,
birthDate: profile.birthDate,
position: profile.position,
leaveDate: profile.dateLeave,
dateStart: profile.dateStart,
dateRetireLaw: profile.dateRetireLaw,
posMaster: posMaster == null ? null : posMaster.posMasterNo,
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName,
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
posTypeId: profile.posType == null ? null : profile.posType.id,
posExecutiveName:
position == null || position.posExecutive == null
? null
: position.posExecutive.posExecutiveName,
posExecutivePriority:
position == null || position.posExecutive == null
? null
: position.posExecutive.posExecutivePriority,
posExecutiveId:
position == null || position.posExecutive == null ? null : position.posExecutive.id,
rootId: root == null ? null : root.id,
root: root == null ? null : root.orgRootName,
rootShortName: root == null ? null : root.orgRootShortName,
child1Id: child1 == null ? null : child1.id,
child1: child1 == null ? null : child1.orgChild1Name,
child1ShortName: child1 == null ? null : child1.orgChild1ShortName,
child2Id: child2 == null ? null : child2.id,
child2: child2 == null ? null : child2.orgChild2Name,
child2ShortName: child2 == null ? null : child2.orgChild2ShortName,
child3Id: child3 == null ? null : child3.id,
child3: child3 == null ? null : child3.orgChild3Name,
child3ShortName: child3 == null ? null : child3.orgChild3ShortName,
child4Id: child4 == null ? null : child4.id,
child4: child4 == null ? null : child4.orgChild4Name,
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
node: null,
nodeId: null,
type: profile.employeeClass,
salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
};
if (_profile.child4Id != null) {
_profile.node = 4;
_profile.nodeId = _profile.child4Id;
} else if (_profile.child3Id != null) {
_profile.node = 3;
_profile.nodeId = _profile.child3Id;
} else if (_profile.child2Id != null) {
_profile.node = 2;
_profile.nodeId = _profile.child2Id;
} else if (_profile.child1Id != null) {
_profile.node = 1;
_profile.nodeId = _profile.child1Id;
} else if (_profile.rootId != null) {
_profile.node = 0;
_profile.nodeId = _profile.rootId;
}
return new HttpSuccess(_profile);
} }
let orgRevisionPublish: any = await this.orgRevisionRepo let orgRevisionPublish: any = await this.orgRevisionRepo
@ -4109,6 +4406,7 @@ export class ProfileController extends Controller {
child4ShortName: child4 == null ? null : child4.orgChild4ShortName, child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
node: null, node: null,
nodeId: null, nodeId: null,
type: "OFFICER",
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null, salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
}; };
@ -6705,7 +7003,6 @@ export class ProfileController extends Controller {
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const before = structuredClone(profile); const before = structuredClone(profile);
const _null: any = null;
profile.isLeave = requestBody.isLeave; profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason; profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave; profile.dateLeave = requestBody.dateLeave;
@ -7161,31 +7458,6 @@ export class ProfileController extends Controller {
.take(50) .take(50)
.getManyAndCount(); .getManyAndCount();
const profiles = await Promise.all(
profile.map(async (_data) => {
if (_data.current_holders.length == 0 && _data.next_holders.length == 0) {
const salary = await this.salaryRepository.find({
where: {
profileId: _data.id,
},
});
const insignia = await this.profileInsigniaRepo.find({
where: {
profileId: _data.id,
},
});
const discipline = await this.profileDisciplineRepo.find({
where: {
profileId: _data.id,
},
});
await this.salaryRepository.remove(salary);
await this.profileInsigniaRepo.remove(insignia);
await this.profileDisciplineRepo.remove(discipline);
await this.profileRepo.remove(_data);
}
}),
);
return new HttpSuccess(); return new HttpSuccess();
} }

View file

@ -66,6 +66,7 @@ import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import permission from "../interfaces/permission"; import permission from "../interfaces/permission";
import axios from "axios"; import axios from "axios";
import { Position } from "../entities/Position";
@Route("api/v1/org/profile-employee") @Route("api/v1/org/profile-employee")
@Tags("ProfileEmployee") @Tags("ProfileEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -107,6 +108,8 @@ export class ProfileEmployeeController extends Controller {
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation); private profileEducationRepository = AppDataSource.getRepository(ProfileEducation);
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia); private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave); private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
private positionRepository = AppDataSource.getRepository(Position);
/** /**
* report * report
* *
@ -238,46 +241,49 @@ export class ProfileEmployeeController extends Controller {
})); }));
const mapData = { const mapData = {
Id: profile.id, // Id: profile.id,
CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-", fullName: `${profile?.prefix}${profile?.firstName} ${profile?.lastName}`,
Prefix: profile.prefix != null ? profile.prefix : null, prefix: profile.prefix != null ? profile.prefix : null,
FirstName: profile.firstName != null ? profile.firstName : null, firstName: profile.firstName != null ? profile.firstName : null,
LastName: profile.lastName != null ? profile.lastName : null, lastName: profile.lastName != null ? profile.lastName : null,
DateOfBirth: citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "-",
dateOfBirth:
profile.birthDate != null profile.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate))
: "-", : "-",
DateRetire: dateRetire:
profile.dateRetire != null profile.dateRetire != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire))
: "-", : "-",
RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`, salaryAmount:
SalaryAmount:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null
? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString()) ? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString())
: "-", : "-",
Education: Education, registrationAddress: Extension.ToThaiNumber(
// profile.profileEducations.length > 0 && `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
// profile.profileEducations[profile.profileEducations.length - 1].institute != null ),
// ? profile.profileEducations[profile.profileEducations.length - 1].institute salaryDate:
// : "",
AppointText:
profile.dateAppoint != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint))
: "-",
SalaryDate:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(profile.profileSalarys[0].date), Extension.ToThaiShortDate_monthYear(profile.profileSalarys[0].date),
) )
: "-", : "-",
PositionName: profile.position != null ? profile.position : "-", positionName: profile.position != null ? profile.position : "-",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`, appointText:
ImgUrl: ImgUrl profile.dateAppoint != null
? ImgUrl ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint))
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`, : "-",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
educations: Education,
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
}; };
return new HttpSuccess({
template: "kp7",
reportName: "docx-report",
data: mapData,
});
return new HttpSuccess(mapData); return new HttpSuccess(mapData);
} }
@ -435,108 +441,14 @@ export class ProfileEmployeeController extends Controller {
const _child3 = child3 ? `${child3.orgChild3Name}/` : ""; const _child3 = child3 ? `${child3.orgChild3Name}/` : "";
const _child4 = child4 ? `${child4.orgChild4Name}/` : ""; const _child4 = child4 ? `${child4.orgChild4Name}/` : "";
const Profile = { const cert_raw = await this.certificateRepository.find({
CitizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
Prefix: profiles?.prefix != null ? profiles.prefix : "",
FirstName: profiles?.firstName != null ? profiles.firstName : "",
LastName: profiles?.lastName != null ? profiles.lastName : "",
FullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
BirthDay: profiles?.birthDate
? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString())
: null,
BirthDayText:
profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString())
: "",
BirthMonth: profiles?.birthDate
? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString())
: null, // Months are zero-based
BirthYear: profiles?.birthDate
? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString())
: null,
BirthYearText:
profiles.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString())
: "",
Address: "",
District: "",
Area: "",
Province: "",
Telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
CouplePrefix: profileFamilyCouple?.couplePrefix ?? "",
CoupleFullName:
profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastNameOld ?? ""}`.trim()
: null,
FatherPrefix: profileFamilyFather?.fatherPrefix ?? "",
FatherFullName:
profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null,
MotherPrefix: profileFamilyMother?.motherPrefix ?? "",
MotherFullName:
profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName ||
profileFamilyMother?.motherLastName
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
: null,
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
Division: "",
Institute: "",
StartDate: profiles?.dateStart
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateStart))
: "",
AppointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "",
BirthDate: profiles?.birthDate
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
: "",
RetireDate:
profiles.dateRetireLaw != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
: "",
CurrentAddress:
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
CurrentSubDistrict:
profiles.currentSubDistrict != null
? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
: "",
CurrentDistrict:
profiles.currentDistrict != null
? Extension.ToThaiNumber(profiles.currentDistrict.name)
: "",
CurrentProvince:
profiles.currentProvince != null
? Extension.ToThaiNumber(profiles.currentProvince.name)
: "",
// AvatarId: profiles?.avatar ?? null,
ImgUrl: ImgUrl
? ImgUrl
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
ImgUrl1: _ImgUrl[0] ? _ImgUrl[0] : null,
ImgUrl2: _ImgUrl[1] ? _ImgUrl[1] : null,
ImgUrl3: _ImgUrl[2] ? _ImgUrl[2] : null,
ImgUrl4: _ImgUrl[3] ? _ImgUrl[3] : null,
ImgUrl5: _ImgUrl[4] ? _ImgUrl[4] : null,
ImgUrl6: _ImgUrl[5] ? _ImgUrl[5] : null,
ImgUrl7: _ImgUrl[6] ? _ImgUrl[6] : null,
};
const certs = await this.certificateRepository.find({
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
select: ["certificateType", "issuer", "certificateNo", "issueDate"], select: ["certificateType", "issuer", "certificateNo", "issueDate"],
order: { createdAt: "ASC" },
}); });
const Cert = const certs =
certs.length > 0 cert_raw.length > 0
? certs.map((item) => ({ ? cert_raw.slice(-2).map((item) => ({
CertificateType: item.certificateType ?? null, CertificateType: item.certificateType ?? null,
Issuer: item.issuer ?? null, Issuer: item.issuer ?? null,
CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null, CertificateNo: Extension.ToThaiNumber(item.certificateNo) ?? null,
@ -550,13 +462,14 @@ export class ProfileEmployeeController extends Controller {
IssueDate: "-", IssueDate: "-",
}, },
]; ];
const trainings = await this.trainingRepository.find({ const training_raw = await this.trainingRepository.find({
select: ["startDate", "endDate", "place", "department"], select: ["startDate", "endDate", "place", "department"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { createdAt: "ASC" },
}); });
const Training = const trainings =
trainings.length > 0 training_raw.length > 0
? trainings.map((item) => ({ ? training_raw.slice(-2).map((item) => ({
Institute: item.department ?? "", Institute: item.department ?? "",
Start: Start:
item.startDate == null item.startDate == null
@ -586,13 +499,14 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const disciplines = await this.disciplineRepository.find({ const discipline_raw = await this.disciplineRepository.find({
select: ["refCommandDate", "refCommandNo", "detail"], select: ["refCommandDate", "refCommandNo", "detail"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { createdAt: "ASC" },
}); });
const Discipline = const disciplines =
disciplines.length > 0 discipline_raw.length > 0
? disciplines.map((item) => ({ ? discipline_raw.slice(-2).map((item) => ({
DisciplineYear: DisciplineYear:
Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ?? Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ??
null, null,
@ -607,14 +521,15 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const educations = await this.educationRepository.find({ const education_raw = await this.educationRepository.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { lastUpdatedAt: "DESC" }, // order: { lastUpdatedAt: "DESC" },
order: { createdAt: "ASC" },
}); });
const Education = const educations =
educations.length > 0 education_raw.length > 0
? educations.map((item) => ({ ? education_raw.slice(-2).map((item) => ({
Institute: item.institute, Institute: item.institute,
Start: Start:
item.startDate == null item.startDate == null
@ -643,7 +558,7 @@ export class ProfileEmployeeController extends Controller {
Field: "-", Field: "-",
}, },
]; ];
const salarys = await this.salaryRepository.find({ const salary_raw = await this.salaryRepository.find({
select: [ select: [
"date", "date",
"position", "position",
@ -659,9 +574,9 @@ export class ProfileEmployeeController extends Controller {
order: { order: "ASC" }, order: { order: "ASC" },
}); });
const Salary = const salarys =
salarys.length > 0 salary_raw.length > 0
? salarys.map((item) => ({ ? salary_raw.map((item) => ({
SalaryDate: item.date SalaryDate: item.date
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date))
: null, : null,
@ -697,7 +612,7 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const insignias = await this.profileInsigniaRepo.find({ const insignia_raw = await this.profileInsigniaRepo.find({
relations: { relations: {
insignia: { insignia: {
insigniaType: true, insigniaType: true,
@ -706,9 +621,9 @@ export class ProfileEmployeeController extends Controller {
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { receiveDate: "ASC" }, order: { receiveDate: "ASC" },
}); });
const Insignia = const insignias =
insignias.length > 0 insignia_raw.length > 0
? insignias.map((item) => ({ ? insignia_raw.map((item) => ({
ReceiveDate: item.receiveDate ReceiveDate: item.receiveDate
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.receiveDate))
: "", : "",
@ -741,14 +656,14 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const leaves = await this.profileLeaveRepository.find({ const leave_raw = await this.profileLeaveRepository.find({
relations: { leaveType: true }, relations: { leaveType: true },
where: { profileEmployeeId: id }, where: { profileEmployeeId: id },
order: { dateLeaveStart: "ASC" }, order: { dateLeaveStart: "ASC" },
}); });
const Leave = const leaves =
leaves.length > 0 leave_raw.length > 0
? leaves.map((item) => ({ ? leave_raw.map((item) => ({
LeaveTypeName: item.leaveType.name, LeaveTypeName: item.leaveType.name,
DateLeaveStart: item.dateLeaveStart DateLeaveStart: item.dateLeaveStart
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart)) ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
@ -763,15 +678,101 @@ export class ProfileEmployeeController extends Controller {
}, },
]; ];
const data = {
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
prefix: profiles?.prefix != null ? profiles.prefix : "",
firstName: profiles?.firstName != null ? profiles.firstName : "",
lastName: profiles?.lastName != null ? profiles.lastName : "",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
birthDate: profiles?.birthDate
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
: "",
retireDate:
profiles.dateRetireLaw != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
: "",
appointDate: profiles?.dateAppoint
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
: "",
citizenId:
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
fatherFullName:
profileFamilyFather?.fatherPrefix ||
profileFamilyFather?.fatherFirstName ||
profileFamilyFather?.fatherLastName
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
: null,
motherFullName:
profileFamilyMother?.motherPrefix ||
profileFamilyMother?.motherFirstName ||
profileFamilyMother?.motherLastName
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
: null,
coupleFullName:
profileFamilyCouple?.couplePrefix ||
profileFamilyCouple?.coupleFirstName ||
profileFamilyCouple?.coupleLastNameOld
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim()
: null,
coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
currentAddress:
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
currentSubDistrict:
profiles.currentSubDistrict != null
? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
: "",
currentDistrict:
profiles.currentDistrict != null
? Extension.ToThaiNumber(profiles.currentDistrict.name)
: "",
currentProvince:
profiles.currentProvince != null
? Extension.ToThaiNumber(profiles.currentProvince.name)
: "",
telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
url1: _ImgUrl[0] ? _ImgUrl[0] : null,
yearUpload1: profiles.profileAvatars[0]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt))
: null,
url2: _ImgUrl[1] ? _ImgUrl[1] : null,
yearUpload2: profiles.profileAvatars[1]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[1].createdAt))
: null,
url3: _ImgUrl[2] ? _ImgUrl[2] : null,
yearUpload3: profiles.profileAvatars[2]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[2].createdAt))
: null,
url4: _ImgUrl[3] ? _ImgUrl[3] : null,
yearUpload4: profiles.profileAvatars[3]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[3].createdAt))
: null,
url5: _ImgUrl[4] ? _ImgUrl[4] : null,
yearUpload5: profiles.profileAvatars[4]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[4].createdAt))
: null,
url6: _ImgUrl[5] ? _ImgUrl[5] : null,
yearUpload6: profiles.profileAvatars[5]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[5].createdAt))
: null,
url7: _ImgUrl[6] ? _ImgUrl[6] : null,
yearUpload7: profiles.profileAvatars[6]
? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt))
: null,
insignias,
leaves,
certs,
trainings,
disciplines,
educations,
salarys,
};
return new HttpSuccess({ return new HttpSuccess({
Profile: [Profile], template: "kk1-emp",
Cert, reportName: "docx-report",
Training, data: data,
Discipline,
Education,
Salary,
Insignia,
Leave,
}); });
} }
@ -1680,6 +1681,7 @@ export class ProfileEmployeeController extends Controller {
position: `%${requestBody.position}%`, position: `%${requestBody.position}%`,
}, },
) )
.andWhere("profileEmployee.isLeave IS FALSE")
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.where( qb.where(
@ -1873,98 +1875,106 @@ export class ProfileEmployeeController extends Controller {
orgRevisionPublish = await this.orgRevisionRepo orgRevisionPublish = await this.orgRevisionRepo
.createQueryBuilder("orgRevision") .createQueryBuilder("orgRevision")
.where("orgRevision.id = :revisionId", { revisionId }) .where("orgRevision.id = :revisionId", { revisionId })
// .andWhere("orgRevision.orgRevisionIsDraft = false")
// .andWhere("orgRevision.orgRevisionIsCurrent = true")
.getOne(); .getOne();
if (!orgRevisionPublish) { if (!orgRevisionPublish) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง");
} }
} }
const posMaster =
profile.current_holders == null ||
profile.current_holders.length == 0 ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
const root =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
const child1 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1;
const child2 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2;
const child3 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3;
const child4 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
const position = await this.positionRepository.findOne({
relations: ["posExecutive"],
where: {
posMasterId: posMaster?.id,
},
});
const _profile = { const _profile = {
profileId: profile.id, profileId: profile.id,
rank: profile.rank,
prefix: profile.prefix, prefix: profile.prefix,
rank: profile.rank,
avatar: profile.avatar,
isProbation: profile.isProbation,
avatarName: profile.avatarName,
firstName: profile.firstName, firstName: profile.firstName,
lastName: profile.lastName, lastName: profile.lastName,
citizenId: profile.citizenId, citizenId: profile.citizenId,
birthDate: profile.birthDate,
position: profile.position, position: profile.position,
leaveDate: profile.dateLeave,
dateStart: profile.dateStart,
dateRetireLaw: profile.dateRetireLaw,
posMaster: posMaster == null ? null : posMaster.posMasterNo,
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName, posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName,
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank, posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
posLevelId: profile.posLevel == null ? null : profile.posLevel.id, posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
posTypeName: profile.posType == null ? null : profile.posType.posTypeName, posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank, posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
posTypeId: profile.posType == null ? null : profile.posType.id, posTypeId: profile.posType == null ? null : profile.posType.id,
rootId: posExecutiveName:
profile.current_holders == null || position == null || position.posExecutive == null
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
null
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) : position.posExecutive.posExecutiveName,
?.orgRootId, posExecutivePriority:
root: position == null || position.posExecutive == null
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
null
? null ? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot : position.posExecutive.posExecutivePriority,
.orgRootName, posExecutiveId:
child1Id: position == null || position.posExecutive == null ? null : position.posExecutive.id,
profile.current_holders == null || rootId: root == null ? null : root.id,
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == root: root == null ? null : root.orgRootName,
null rootShortName: root == null ? null : root.orgRootShortName,
? null child1Id: child1 == null ? null : child1.id,
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) child1: child1 == null ? null : child1.orgChild1Name,
?.orgChild1Id, child1ShortName: child1 == null ? null : child1.orgChild1ShortName,
child1: child2Id: child2 == null ? null : child2.id,
profile.current_holders == null || child2: child2 == null ? null : child2.orgChild2Name,
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 == child2ShortName: child2 == null ? null : child2.orgChild2ShortName,
null child3Id: child3 == null ? null : child3.id,
? null child3: child3 == null ? null : child3.orgChild3Name,
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 child3ShortName: child3 == null ? null : child3.orgChild3ShortName,
.orgChild1Name, child4Id: child4 == null ? null : child4.id,
child2Id: child4: child4 == null ? null : child4.orgChild4Name,
profile.current_holders == null || child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 == node: null,
null nodeId: null,
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild2Id,
child2:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2
.orgChild2Name,
child3Id:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild3Id,
child3:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3
.orgChild3Name,
child4Id:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild4Id,
child4:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4
.orgChild4Name,
salary: salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null, profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
}; };

View file

@ -87,6 +87,7 @@ export class ProfileFamilyMotherController extends Controller {
motherPrefix: y.motherPrefix, motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName, motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName, motherLastName: y.motherLastName,
motherLastNameOld: y.motherLastNameOld,
motherCareer: y.motherCareer, motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId, motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive, motherLive: y.motherLive,
@ -127,6 +128,7 @@ export class ProfileFamilyMotherController extends Controller {
motherPrefix: y.motherPrefix, motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName, motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName, motherLastName: y.motherLastName,
motherLastNameOld: y.motherLastNameOld,
motherCareer: y.motherCareer, motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId, motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive, motherLive: y.motherLive,

View file

@ -87,6 +87,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
motherPrefix: y.motherPrefix, motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName, motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName, motherLastName: y.motherLastName,
motherLastNameOld: y.motherLastNameOld,
motherCareer: y.motherCareer, motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId, motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive, motherLive: y.motherLive,
@ -130,6 +131,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
motherPrefix: y.motherPrefix, motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName, motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName, motherLastName: y.motherLastName,
motherLastNameOld: y.motherLastNameOld,
motherCareer: y.motherCareer, motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId, motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive, motherLive: y.motherLive,

View file

@ -86,6 +86,7 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
motherPrefix: y.motherPrefix, motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName, motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName, motherLastName: y.motherLastName,
motherLastNameOld: y.motherLastNameOld,
motherCareer: y.motherCareer, motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId, motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive, motherLive: y.motherLive,
@ -129,6 +130,7 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
motherPrefix: y.motherPrefix, motherPrefix: y.motherPrefix,
motherFirstName: y.motherFirstName, motherFirstName: y.motherFirstName,
motherLastName: y.motherLastName, motherLastName: y.motherLastName,
motherLastNameOld: y.motherLastNameOld,
motherCareer: y.motherCareer, motherCareer: y.motherCareer,
motherCitizenId: y.motherCitizenId, motherCitizenId: y.motherCitizenId,
motherLive: y.motherLive, motherLive: y.motherLive,

View file

@ -883,7 +883,11 @@ export class WorkflowController extends Controller {
}); });
if (!profileOfficer) return new HttpSuccess({ isOfficer: false, isStaff: false }); if (!profileOfficer) return new HttpSuccess({ isOfficer: false, isStaff: false });
let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer; let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer;
return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer }); return new HttpSuccess({
isOfficer: isOfficer,
isStaff: !isOfficer,
isDirector: profileOfficer.isDirector,
});
} }
/** /**

View file

@ -6,7 +6,7 @@ import { CommandSend } from "./CommandSend";
export class CommandSendCC extends EntityBase { export class CommandSendCC extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "เพศ", comment: "ชื่อ",
length: 255, length: 255,
default: null, default: null,
}) })

View file

@ -1,4 +1,4 @@
import { Entity, Column, OneToMany, JoinColumn, ManyToOne } from "typeorm"; import { Entity, Column, OneToMany, JoinColumn, ManyToOne, Double } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster"; import { PosMaster } from "./PosMaster";
import { PosLevel } from "./PosLevel"; import { PosLevel } from "./PosLevel";
@ -307,6 +307,30 @@ export class Profile extends EntityBase {
}) })
bloodGroup: string; bloodGroup: string;
@Column({
comment: "เงินเดือนฐาน",
default: 0,
nullable: true,
type: "double",
})
amount: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,
nullable: true,
type: "double",
})
positionSalaryAmount: Double;
@Column({
comment: "เงินค่าตอบแทนรายเดือน",
default: 0,
nullable: true,
type: "double",
})
mouthSalaryAmount: Double;
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder) @OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
current_holders: PosMaster[]; current_holders: PosMaster[];

View file

@ -1,4 +1,4 @@
import { Entity, Column, OneToMany, ManyToOne } from "typeorm"; import { Entity, Column, OneToMany, ManyToOne, Double } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { EmployeePosLevel } from "./EmployeePosLevel"; import { EmployeePosLevel } from "./EmployeePosLevel";
import { EmployeePosType } from "./EmployeePosType"; import { EmployeePosType } from "./EmployeePosType";
@ -568,6 +568,30 @@ export class ProfileEmployee extends EntityBase {
}) })
employeeMoneyEmployer: string; employeeMoneyEmployer: string;
@Column({
comment: "เงินเดือนฐาน",
default: 0,
nullable: true,
type: "double",
})
amount: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,
nullable: true,
type: "double",
})
positionSalaryAmount: Double;
@Column({
comment: "เงินค่าตอบแทนรายเดือน",
default: 0,
nullable: true,
type: "double",
})
mouthSalaryAmount: Double;
@OneToMany(() => ProfileEmployeeInformationHistory, (v) => v.profileEmployeeInformation) @OneToMany(() => ProfileEmployeeInformationHistory, (v) => v.profileEmployeeInformation)
information_histories: ProfileEmployeeInformationHistory[]; information_histories: ProfileEmployeeInformationHistory[];

View file

@ -27,6 +27,13 @@ export class ProfileFamilyMother extends EntityBase {
}) })
motherLastName: string; motherLastName: string;
@Column({
nullable: true,
default: null,
comment: "นามสกุลมารดาเดิม",
})
motherLastNameOld: string;
@Column({ @Column({
nullable: true, nullable: true,
default: null, default: null,

View file

@ -25,6 +25,13 @@ export class ProfileFamilyMotherHistory extends EntityBase {
}) })
motherLastName: string; motherLastName: string;
@Column({
nullable: true,
default: null,
comment: "นามสกุลมารดาเดิม",
})
motherLastNameOld: string;
@Column({ @Column({
nullable: true, nullable: true,
default: null, default: null,

View file

@ -1,68 +0,0 @@
import { ViewColumn, ViewEntity } from "typeorm";
@ViewEntity({
expression: `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\`,
\`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\`,
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\`)))
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\`)))
UNION 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\`,
\`posMasterChild\`.\`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\`.\`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\`)))
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\`)))`,
})
export class viewCommanderDirector {
@ViewColumn()
id: string;
@ViewColumn()
prefix: string;
@ViewColumn()
firstName: string;
@ViewColumn()
lastName: string;
@ViewColumn()
citizenId: string;
@ViewColumn()
position: string;
@ViewColumn()
posLevel: string;
@ViewColumn()
posType: string;
@ViewColumn()
isDirector: boolean;
@ViewColumn()
orgRootId: string;
@ViewColumn()
actFullName: string;
}

View file

@ -8,14 +8,30 @@ import { ViewColumn, ViewEntity } from "typeorm";
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`, \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`, \`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`, \`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\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`,
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, \`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\` NULL AS \`actFullName\`
FROM FROM
(((\`bma_ehr_organization_demo\`.\`posMaster\` ((((((((\`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\`))) 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\`.\`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\`)))`, JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`,
}) })
@ -33,6 +49,8 @@ export class viewDirector {
@ViewColumn() @ViewColumn()
position: string; position: string;
@ViewColumn() @ViewColumn()
posNo: string;
@ViewColumn()
posLevel: string; posLevel: string;
@ViewColumn() @ViewColumn()
posType: string; posType: string;
@ -41,5 +59,9 @@ export class viewDirector {
@ViewColumn() @ViewColumn()
orgRootId: string; orgRootId: string;
@ViewColumn() @ViewColumn()
actFullNameId: string;
@ViewColumn()
actFullName: string; actFullName: string;
@ViewColumn()
key: string;
} }

View file

@ -8,24 +8,41 @@ import { ViewColumn, ViewEntity } from "typeorm";
\`profileChild\`.\`lastName\` AS \`lastName\`, \`profileChild\`.\`lastName\` AS \`lastName\`,
\`profileChild\`.\`citizenId\` AS \`citizenId\`, \`profileChild\`.\`citizenId\` AS \`citizenId\`,
\`profileChild\`.\`position\` AS \`position\`, \`profileChild\`.\`position\` AS \`position\`,
\`posMasterChild\`.\`isDirector\` AS \`isDirector\`, 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\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, \`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\`, CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`,
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`, \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`,
' ', ' ',
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\` \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\`
FROM FROM
((((((\`bma_ehr_organization_demo\`.\`posMasterAct\` (((((((((((\`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\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`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\`.\`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\`.\`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\`.\`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\`)))`, JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`,
}) })
export class viewCommanderDirector { export class viewDirectorActing {
@ViewColumn() @ViewColumn()
id: string; id: string;
@ViewColumn() @ViewColumn()
@ -39,13 +56,21 @@ export class viewCommanderDirector {
@ViewColumn() @ViewColumn()
position: string; position: string;
@ViewColumn() @ViewColumn()
posNo: string;
@ViewColumn()
posLevel: string; posLevel: string;
@ViewColumn() @ViewColumn()
posType: string; posType: string;
@ViewColumn() @ViewColumn()
isDirector: boolean; isDirector: boolean;
@ViewColumn() @ViewColumn()
isDirectorChild: boolean;
@ViewColumn()
orgRootId: string; orgRootId: string;
@ViewColumn() @ViewColumn()
actFullNameId: string;
@ViewColumn()
actFullName: string; actFullName: string;
@ViewColumn()
key: string;
} }

View file

@ -228,6 +228,13 @@ class Extension {
); );
} }
public static ToThaiShortYear(value: Date) {
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
return (
yy.toString()
);
}
public static sumObjectValues(array: any, propertyName: any) { public static sumObjectValues(array: any, propertyName: any) {
let sum = 0; let sum = 0;
for (let i = 0; i < array.length; i++) { for (let i = 0; i < array.length; i++) {

View file

@ -0,0 +1,58 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableCommandSign21730703510080 implements MigrationInterface {
name = 'AddTableCommandSign21730703510080'
public async up(queryRunner: QueryRunner): Promise<void> {
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\`,
\`posMasterChild\`.\`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\`.\`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\`)))
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 `posMasterChild`.`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`.`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 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\`,
\`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\`,
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\`)))
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 `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 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 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\``);
}
}

View file

@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdataTableProfileAddSalary1730773461743 implements MigrationInterface {
name = 'UpdataTableProfileAddSalary1730773461743'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`amount\` double NULL COMMENT 'เงินเดือนฐาน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`positionSalaryAmount\` double NULL COMMENT 'เงินประจำตำแหน่ง' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`mouthSalaryAmount\` double NULL COMMENT 'เงินค่าตอบแทนรายเดือน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`amount\` double NULL COMMENT 'เงินเดือนฐาน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`positionSalaryAmount\` double NULL COMMENT 'เงินประจำตำแหน่ง' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`mouthSalaryAmount\` double NULL COMMENT 'เงินค่าตอบแทนรายเดือน' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`mouthSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`positionSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`amount\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`mouthSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`positionSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`amount\``);
}
}

View file

@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdataTableProfileAddSalary11730774144012 implements MigrationInterface {
name = 'UpdataTableProfileAddSalary11730774144012'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`amount\` double NULL COMMENT 'เงินเดือนฐาน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`positionSalaryAmount\` double NULL COMMENT 'เงินประจำตำแหน่ง' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`mouthSalaryAmount\` double NULL COMMENT 'เงินค่าตอบแทนรายเดือน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`amount\` double NULL COMMENT 'เงินเดือนฐาน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`positionSalaryAmount\` double NULL COMMENT 'เงินประจำตำแหน่ง' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`mouthSalaryAmount\` double NULL COMMENT 'เงินค่าตอบแทนรายเดือน' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`mouthSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`positionSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`amount\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`mouthSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`positionSalaryAmount\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`amount\``);
}
}

View file

@ -0,0 +1,62 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableViewAddPosNo1730775622890 implements MigrationInterface {
name = 'UpdateTableViewAddPosNo1730775622890'
public async up(queryRunner: QueryRunner): Promise<void> {
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\`,
NULL AS \`posNo\`,
\`posMasterChild\`.\`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\`,
\`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\`)))
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 NULL AS `posNo`,\n `posMasterChild`.`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 `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 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\`,
NULL 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\`,
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\`)))
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 NULL 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 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 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\``);
}
}

View file

@ -0,0 +1,74 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableViewAddPosNo11730778247768 implements MigrationInterface {
name = 'UpdateTableViewAddPosNo11730778247768'
public async up(queryRunner: QueryRunner): Promise<void> {
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 \`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\`,
\`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 `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 `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\`,
NULL 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\`,
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\`)))
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 NULL 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 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 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\``);
}
}

View file

@ -0,0 +1,86 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableViewAddPosNo21730788285577 implements MigrationInterface {
name = 'UpdateTableViewAddPosNo21730788285577'
public async up(queryRunner: QueryRunner): Promise<void> {
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 \`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\`,
\`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 `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 `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\`,
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 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\``);
}
}

View file

@ -0,0 +1,89 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableAppointDirectorAddPosNo11730885124771 implements MigrationInterface {
name = 'UpdateTableAppointDirectorAddPosNo11730885124771'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`commandSendCC\` CHANGE \`name\` \`name\` varchar(255) NULL COMMENT 'ชื่อ'`);
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\`,
\`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 `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\`,
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 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(`ALTER TABLE \`commandSendCC\` CHANGE \`name\` \`name\` varchar(255) NULL COMMENT 'เพศ'`);
}
}

View file

@ -0,0 +1,91 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableAppointDirectorAddPosNo21730887635521 implements MigrationInterface {
name = 'UpdateTableAppointDirectorAddPosNo21730887635521'
public async up(queryRunner: QueryRunner): Promise<void> {
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(\`posMasterChild\`.\`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(`posMasterChild`.`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`)))"]);
}
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\``);
}
}

View file

@ -0,0 +1,91 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableAppointDirectorAddPosNo31730947807718 implements MigrationInterface {
name = 'UpdateTableAppointDirectorAddPosNo31730947807718'
public async up(queryRunner: QueryRunner): Promise<void> {
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`)))"]);
}
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\``);
}
}

View file

@ -0,0 +1,244 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfilefamAddMotherLastNameOld1730950041973 implements MigrationInterface {
name = 'UpdateTableProfilefamAddMotherLastNameOld1730950041973'
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_acting","bma_ehr_organization_demo"]);
// await queryRunner.query(`DROP VIEW \`view_director_acting\``);
// 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(`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(`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(`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(`ALTER TABLE \`profileFamilyMotherHistory\` ADD \`motherLastNameOld\` varchar(255) NULL COMMENT 'นามสกุลมารดาเดิม'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` ADD \`motherLastNameOld\` varchar(255) NULL COMMENT 'นามสกุลมารดาเดิม'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` DROP COLUMN \`motherLastNameOld\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` DROP COLUMN \`motherLastNameOld\``);
// 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\`,
// NULL AS \`posNo\`,
// \`posMasterChild\`.\`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\`,
// \`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\`)))
// 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 NULL AS `posNo`,\n `posMasterChild`.`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 `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 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\`,
// NULL 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\`,
// 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\`)))
// 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 NULL 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 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 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`)))"]);
// 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\`,
// NULL AS \`posNo\`,
// \`posMasterChild\`.\`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\`,
// \`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\`)))
// 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 NULL AS `posNo`,\n `posMasterChild`.`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 `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 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\`,
// NULL 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\`,
// 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\`)))
// 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 NULL 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 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 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`)))"]);
// 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\`,
// NULL AS \`posNo\`,
// \`posMasterChild\`.\`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\`,
// \`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\`)))
// 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 NULL AS `posNo`,\n `posMasterChild`.`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 `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 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\`,
// NULL 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\`,
// 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\`)))
// 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 NULL 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 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 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`)))"]);
// 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\`,
// NULL AS \`posNo\`,
// \`posMasterChild\`.\`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\`,
// \`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\`)))
// 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 NULL AS `posNo`,\n `posMasterChild`.`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 `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 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\`,
// NULL 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\`,
// 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\`)))
// 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 NULL 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 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 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`)))"]);
// 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\`,
// NULL AS \`posNo\`,
// \`posMasterChild\`.\`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\`,
// \`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\`)))
// 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 NULL AS `posNo`,\n `posMasterChild`.`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 `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 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`)))"]);
}
}