Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-08-19 21:04:00 +07:00
commit 16e55269dc
7 changed files with 42 additions and 19 deletions

View file

@ -1220,7 +1220,7 @@ namespace BMA.EHR.Application.Repositories.Commands
if (data == null) if (data == null)
throw new Exception(GlobalMessages.OrganizationNotFound); throw new Exception(GlobalMessages.OrganizationNotFound);
return data.OrganizationAgencyId!.Value; return data.OrganizationAgencyId == null ? ocId : data.OrganizationAgencyId!.Value;
} }
catch catch
{ {
@ -1260,12 +1260,12 @@ namespace BMA.EHR.Application.Repositories.Commands
} }
} }
public async Task<List<KeyValueItemResponse>> GetOrgApproverAsync(Guid ocId) public async Task<List<OrganizationApproverResponse>> GetOrgApproverAsync(Guid ocId)
{ {
try try
{ {
if (ocId == Guid.Empty) if (ocId == Guid.Empty)
return new List<KeyValueItemResponse>() { new KeyValueItemResponse { Id = Guid.Empty, Name = "ปลัดกรุงเทพมหานคร" } }; return new List<OrganizationApproverResponse>() { new OrganizationApproverResponse { Id = Guid.Empty, Name = "", PositionName = "ปลัดกรุงเทพมหานคร" } };
else else
{ {
//var ret = new List<KeyValueItemResponse>(); //var ret = new List<KeyValueItemResponse>();
@ -1278,12 +1278,20 @@ namespace BMA.EHR.Application.Repositories.Commands
.ThenInclude(x => x!.Organization) .ThenInclude(x => x!.Organization)
.Include(x => x.OrganizationPosition) .Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster) .ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionPath)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionExecutive)
.Where(x => x.OrganizationPosition!.Organization!.Id == ocId && .Where(x => x.OrganizationPosition!.Organization!.Id == ocId &&
x.OrganizationPosition!.PositionMaster!.IsDirector == true) x.OrganizationPosition!.PositionMaster!.IsDirector == true)
.Select(x => new KeyValueItemResponse .Select(x => new OrganizationApproverResponse
{ {
Id = x.Profile!.Id, Id = x.Profile!.Id,
Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}" Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}",
PositionName = x.OrganizationPosition!.PositionMaster!.PositionExecutive != null ?
x.OrganizationPosition!.PositionMaster!.PositionExecutive!.Name
:
x.OrganizationPosition!.PositionMaster!.PositionPath == null ? "" : x.OrganizationPosition!.PositionMaster!.PositionPath!.Name
}) })
.ToListAsync(); .ToListAsync();
@ -1302,19 +1310,27 @@ namespace BMA.EHR.Application.Repositories.Commands
.ThenInclude(x => x!.Organization) .ThenInclude(x => x!.Organization)
.Include(x => x.OrganizationPosition) .Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster) .ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionPath)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionExecutive)
.Where(x => x.OrganizationPosition!.Organization!.Id == oc.Parent.Id && .Where(x => x.OrganizationPosition!.Organization!.Id == oc.Parent.Id &&
x.OrganizationPosition!.PositionMaster!.IsDirector == true) x.OrganizationPosition!.PositionMaster!.IsDirector == true)
.Select(x => new KeyValueItemResponse .Select(x => new OrganizationApproverResponse
{ {
Id = x.Profile!.Id, Id = x.Profile!.Id,
Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}" Name = $"{x.Profile!.Prefix!.Name}{x.Profile!.FirstName} {x.Profile!.LastName}",
PositionName = x.OrganizationPosition!.PositionMaster!.PositionExecutive != null ?
x.OrganizationPosition!.PositionMaster!.PositionExecutive!.Name
:
x.OrganizationPosition!.PositionMaster!.PositionPath == null ? "" : x.OrganizationPosition!.PositionMaster!.PositionPath!.Name
}) })
.ToListAsync(); .ToListAsync();
return parentProfilePosition; return parentProfilePosition;
} }
else else
return new List<KeyValueItemResponse>(); return new List<OrganizationApproverResponse>();
} }
} }
} }

View file

@ -14,7 +14,6 @@ namespace BMA.EHR.Application.Repositories
private readonly DbSet<T> _dbSet; private readonly DbSet<T> _dbSet;
private readonly IHttpContextAccessor _httpContextAccessor; private readonly IHttpContextAccessor _httpContextAccessor;
#endregion #endregion
#region " Constructor and Destructor " #region " Constructor and Destructor "
@ -38,8 +37,6 @@ namespace BMA.EHR.Application.Repositories
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1"); protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
#endregion #endregion
#region " Methods " #region " Methods "
@ -63,7 +60,6 @@ namespace BMA.EHR.Application.Repositories
(entity as EntityBase).CreatedAt = DateTime.Now; (entity as EntityBase).CreatedAt = DateTime.Now;
} }
await _dbSet.AddAsync(entity); await _dbSet.AddAsync(entity);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses
{
public class OrganizationApproverResponse
{
public Guid Id { get; set; } = Guid.Empty;
public string Name { get; set; } = string.Empty;
public string PositionName { get; set; } = string.Empty;
}
}

View file

@ -381,7 +381,7 @@ namespace BMA.EHR.Command.Service.Controllers
{ {
var inserted = new Domain.Models.Commands.Core.Command var inserted = new Domain.Models.Commands.Core.Command
{ {
CommandNo = req.orderNo.ToString(), CommandNo = req.orderNo,
CommandYear = req.orderYear.ToString(), CommandYear = req.orderYear.ToString(),
CommandSubject = req.orderTitle, CommandSubject = req.orderTitle,
PositionName = req.registerPosition, PositionName = req.registerPosition,
@ -433,7 +433,7 @@ namespace BMA.EHR.Command.Service.Controllers
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue); var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId); var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
order.CommandNo = req.orderNo.ToString(); order.CommandNo = req.orderNo;
order.CommandYear = req.orderYear.ToString(); order.CommandYear = req.orderYear.ToString();
order.CommandSubject = req.orderTitle; order.CommandSubject = req.orderTitle;
order.PositionName = req.registerPosition; order.PositionName = req.registerPosition;

View file

@ -4,9 +4,9 @@
{ {
public Guid orderTypeValue { get; set; } public Guid orderTypeValue { get; set; }
public string orderTitle { get; set; } public string orderTitle { get; set; } = string.Empty;
public int orderNo { get; set; } public string orderNo { get; set; } = string.Empty;
public int orderYear { get; set; } public int orderYear { get; set; }

View file

@ -18,7 +18,7 @@
}, },
"Jwt": { "Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://identity.frappet.com/realms/bma-ehr" "Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
}, },
"EPPlus": { "EPPlus": {
"ExcelPackage": { "ExcelPackage": {

View file

@ -1,6 +1,6 @@
{ {
"realm": "bma-ehr", "realm": "bma-ehr",
"auth-server-url": "https://identity.frappet.com", "auth-server-url": "https://id.frappet.synology.me",
"ssl-required": "external", "ssl-required": "external",
"resource": "bma-ehr", "resource": "bma-ehr",
"public-client": true "public-client": true