Report C-PM-13 Cover and Attachment

This commit is contained in:
Suphonchai Phoonsawat 2023-09-04 11:37:37 +07:00
parent 7b4d0e1ae6
commit 0eac2a0c61
6 changed files with 206 additions and 13 deletions

View file

@ -532,6 +532,52 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
public async Task<List<CommandType13Response>> GetCommandType13AttachmentAsync(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.Include(c => c.Command)
.Where(c => c.Command.Id == id)
.ToListAsync();
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementTransfer>()
on r.RefPlacementProfileId equals p.Id
join pf in _dbContext.Set<Profile>()
.Include(x => x.Position)
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
on r.CitizenId equals pf.CitizenId
select new CommandType13Response
{
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Organization = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
PositionName = pf.Position == null ? "" : pf.Position.Name,
PositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
PositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
PositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name,
Salary = pf.Salaries == null || pf.Salaries.Count == 0 ? 0 : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value,
ActiveDate = "",
ReceiveOrganizationName = r.Command!.ReceiveOrganizationName
})
.ToList();
return report_data;
}
catch
{
throw;
}
}
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
{
try

View file

@ -1841,6 +1841,8 @@ namespace BMA.EHR.Application.Repositories.Commands
.Include(x => x.Placement)
.Include(x => x.CommandType)
.Include(x => x.CommandStatus)
.OrderBy(x => x.CommandType.CommandCode)
.ThenByDescending(x => x.CommandAffectDate)
.ToListAsync();
}