Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
344c277d1f
2 changed files with 201 additions and 29 deletions
|
|
@ -155,25 +155,15 @@ export class ReportController extends Controller {
|
|||
.orderBy("orgChild4.orgChild4Order", "ASC")
|
||||
.getMany()
|
||||
: [];
|
||||
const posMasters = await AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.where("posMaster.orgRevisionId IN (:...ids)", {
|
||||
ids: [orgRevision.id],
|
||||
})
|
||||
.select([
|
||||
"posMaster.id",
|
||||
"posMaster.posMasterNoPrefix",
|
||||
"posMaster.posMasterNo",
|
||||
"posMaster.posMasterNoSuffix",
|
||||
"posMaster.orgRootId",
|
||||
"posMaster.orgChild1Id",
|
||||
"posMaster.orgChild2Id",
|
||||
"posMaster.orgChild3Id",
|
||||
"posMaster.orgChild4Id",
|
||||
"posMaster.next_holder",
|
||||
])
|
||||
.orderBy("posMaster.posMasterOrder", "ASC")
|
||||
.getMany();
|
||||
|
||||
const posMasters = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRevision.id,
|
||||
},
|
||||
relations: ["next_holder", "current_holder"],
|
||||
order: { posMasterOrder: "ASC" },
|
||||
});
|
||||
|
||||
const positions = await this.positionRepository.find({
|
||||
where: {
|
||||
posMasterId: In(posMasters.map((posMaster: any) => posMaster.id)),
|
||||
|
|
@ -191,6 +181,19 @@ export class ReportController extends Controller {
|
|||
if (_orgRevisionActive.length > 0) orgRevisionActive = _orgRevisionActive[0];
|
||||
}
|
||||
|
||||
const posMasterOlds = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRevisionActive.id,
|
||||
},
|
||||
relations: ["next_holder", "current_holder"],
|
||||
});
|
||||
const positionOlds = await this.positionRepository.find({
|
||||
where: {
|
||||
posMasterId: In(posMasterOlds.map((posMaster: any) => posMaster.id)),
|
||||
},
|
||||
relations: ["posLevel", "posType", "posExecutive"],
|
||||
});
|
||||
|
||||
let data = new Array();
|
||||
await Promise.all(
|
||||
orgRootData.map(async (orgRoot) => {
|
||||
|
|
@ -202,18 +205,39 @@ export class ReportController extends Controller {
|
|||
posMasters
|
||||
.filter((posMaster) => posMaster.orgRootId === orgRoot.id)
|
||||
.map(async (posMaster) => {
|
||||
let posMasterOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
posMasterOld = posMasterOlds.find((posMasOld) =>
|
||||
posMasOld.current_holder == null
|
||||
? false
|
||||
: posMasOld.current_holder.id === posMaster.next_holder.id,
|
||||
);
|
||||
}
|
||||
let positionOld: any = null;
|
||||
if (posMasterOld != null)
|
||||
positionOld = positionOlds.find(
|
||||
(positionold) => positionold.posMasterId === posMasterOld.id,
|
||||
);
|
||||
return {
|
||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
fullname: `${posMaster.next_holder}`,
|
||||
// fullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
||||
profileFullname:
|
||||
posMaster.next_holder == null
|
||||
? null
|
||||
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
||||
profilePosMasterNo: posMasterOld == null ? null : posMasterOld.posMasterNo,
|
||||
profilePositionName: positionOld == null ? null : positionOld.positionName,
|
||||
profilePosType: positionOld == null ? null : positionOld.posType.posTypeName,
|
||||
profilePosLevel: positionOld == null ? null : positionOld.posLevel.posLevelName,
|
||||
profilePositionField: positionOld == null ? null : positionOld.positionField,
|
||||
positions: await Promise.all(
|
||||
positions
|
||||
.filter((position) => position.posMasterId === posMaster.id)
|
||||
.map(async (position) => {
|
||||
return {
|
||||
positionName: position.positionName,
|
||||
positionField: position.positionField,
|
||||
posType: position.posType == null ? null : position.posType.posTypeName,
|
||||
posLevel:
|
||||
position.posLevel == null ? null : position.posLevel.posLevelName,
|
||||
|
|
@ -242,10 +266,37 @@ export class ReportController extends Controller {
|
|||
posMasters
|
||||
.filter((posMaster) => posMaster.orgChild1Id === orgChild1.id)
|
||||
.map(async (posMaster) => {
|
||||
let posMasterOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
posMasterOld = posMasterOlds.find((posMasOld) =>
|
||||
posMasOld.current_holder == null
|
||||
? false
|
||||
: posMasOld.current_holder.id === posMaster.next_holder.id,
|
||||
);
|
||||
}
|
||||
let positionOld: any = null;
|
||||
if (posMasterOld != null)
|
||||
positionOld = positionOlds.find(
|
||||
(positionold) => positionold.posMasterId === posMasterOld.id,
|
||||
);
|
||||
return {
|
||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
fullname:
|
||||
posMaster.next_holder == null
|
||||
? null
|
||||
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
||||
profilePosMasterNo:
|
||||
posMasterOld == null ? null : posMasterOld.posMasterNo,
|
||||
profilePositionName:
|
||||
positionOld == null ? null : positionOld.positionName,
|
||||
profilePosType:
|
||||
positionOld == null ? null : positionOld.posType.posTypeName,
|
||||
profilePosLevel:
|
||||
positionOld == null ? null : positionOld.posLevel.posLevelName,
|
||||
profilePositionField:
|
||||
positionOld == null ? null : positionOld.positionField,
|
||||
positions: await Promise.all(
|
||||
positions
|
||||
.filter((position) => position.posMasterId === posMaster.id)
|
||||
|
|
@ -282,10 +333,37 @@ export class ReportController extends Controller {
|
|||
posMasters
|
||||
.filter((posMaster) => posMaster.orgChild2Id === orgChild2.id)
|
||||
.map(async (posMaster) => {
|
||||
let posMasterOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
posMasterOld = posMasterOlds.find((posMasOld) =>
|
||||
posMasOld.current_holder == null
|
||||
? false
|
||||
: posMasOld.current_holder.id === posMaster.next_holder.id,
|
||||
);
|
||||
}
|
||||
let positionOld: any = null;
|
||||
if (posMasterOld != null)
|
||||
positionOld = positionOlds.find(
|
||||
(positionold) => positionold.posMasterId === posMasterOld.id,
|
||||
);
|
||||
return {
|
||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
fullname:
|
||||
posMaster.next_holder == null
|
||||
? null
|
||||
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
||||
profilePosMasterNo:
|
||||
posMasterOld == null ? null : posMasterOld.posMasterNo,
|
||||
profilePositionName:
|
||||
positionOld == null ? null : positionOld.positionName,
|
||||
profilePosType:
|
||||
positionOld == null ? null : positionOld.posType.posTypeName,
|
||||
profilePosLevel:
|
||||
positionOld == null ? null : positionOld.posLevel.posLevelName,
|
||||
profilePositionField:
|
||||
positionOld == null ? null : positionOld.positionField,
|
||||
positions: await Promise.all(
|
||||
positions
|
||||
.filter((position) => position.posMasterId === posMaster.id)
|
||||
|
|
@ -324,10 +402,43 @@ export class ReportController extends Controller {
|
|||
posMasters
|
||||
.filter((posMaster) => posMaster.orgChild3Id === orgChild3.id)
|
||||
.map(async (posMaster) => {
|
||||
let posMasterOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
posMasterOld = posMasterOlds.find((posMasOld) =>
|
||||
posMasOld.current_holder == null
|
||||
? false
|
||||
: posMasOld.current_holder.id ===
|
||||
posMaster.next_holder.id,
|
||||
);
|
||||
}
|
||||
let positionOld: any = null;
|
||||
if (posMasterOld != null)
|
||||
positionOld = positionOlds.find(
|
||||
(positionold) =>
|
||||
positionold.posMasterId === posMasterOld.id,
|
||||
);
|
||||
return {
|
||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
fullname:
|
||||
posMaster.next_holder == null
|
||||
? null
|
||||
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
||||
profilePosMasterNo:
|
||||
posMasterOld == null ? null : posMasterOld.posMasterNo,
|
||||
profilePositionName:
|
||||
positionOld == null ? null : positionOld.positionName,
|
||||
profilePosType:
|
||||
positionOld == null
|
||||
? null
|
||||
: positionOld.posType.posTypeName,
|
||||
profilePosLevel:
|
||||
positionOld == null
|
||||
? null
|
||||
: positionOld.posLevel.posLevelName,
|
||||
profilePositionField:
|
||||
positionOld == null ? null : positionOld.positionField,
|
||||
positions: await Promise.all(
|
||||
positions
|
||||
.filter(
|
||||
|
|
@ -370,10 +481,47 @@ export class ReportController extends Controller {
|
|||
(posMaster) => posMaster.orgChild4Id === orgChild4.id,
|
||||
)
|
||||
.map(async (posMaster) => {
|
||||
let posMasterOld: any = null;
|
||||
if (posMaster.next_holder != null) {
|
||||
posMasterOld = posMasterOlds.find((posMasOld) =>
|
||||
posMasOld.current_holder == null
|
||||
? false
|
||||
: posMasOld.current_holder.id ===
|
||||
posMaster.next_holder.id,
|
||||
);
|
||||
}
|
||||
let positionOld: any = null;
|
||||
if (posMasterOld != null)
|
||||
positionOld = positionOlds.find(
|
||||
(positionold) =>
|
||||
positionold.posMasterId === posMasterOld.id,
|
||||
);
|
||||
return {
|
||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||
posMasterNo: posMaster.posMasterNo,
|
||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||
fullname:
|
||||
posMaster.next_holder == null
|
||||
? null
|
||||
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
||||
profilePosMasterNo:
|
||||
posMasterOld == null
|
||||
? null
|
||||
: posMasterOld.posMasterNo,
|
||||
profilePositionName:
|
||||
positionOld == null ? null : positionOld.positionName,
|
||||
profilePosType:
|
||||
positionOld == null
|
||||
? null
|
||||
: positionOld.posType.posTypeName,
|
||||
profilePosLevel:
|
||||
positionOld == null
|
||||
? null
|
||||
: positionOld.posLevel.posLevelName,
|
||||
profilePositionField:
|
||||
positionOld == null
|
||||
? null
|
||||
: positionOld.positionField,
|
||||
positions: await Promise.all(
|
||||
positions
|
||||
.filter(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue