แก้รายชื่อแนบท้ายไม่แสดง
This commit is contained in:
parent
8a84d7faa8
commit
10207e76f0
5 changed files with 106 additions and 15 deletions
|
|
@ -18,6 +18,7 @@ namespace BMA.EHR.Application
|
||||||
services.AddTransient<CommandStatusRepository>();
|
services.AddTransient<CommandStatusRepository>();
|
||||||
services.AddTransient<InsigniaPeriodsRepository>();
|
services.AddTransient<InsigniaPeriodsRepository>();
|
||||||
services.AddTransient<RetirementRepository>();
|
services.AddTransient<RetirementRepository>();
|
||||||
|
services.AddTransient<UserProfileRepository>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,8 @@ using BMA.EHR.Domain.Models.MetaData;
|
||||||
using BMA.EHR.Domain.Models.Organizations;
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
using BMA.EHR.Domain.Models.Placement;
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Transactions;
|
|
||||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Commands
|
namespace BMA.EHR.Application.Repositories.Commands
|
||||||
|
|
@ -93,7 +91,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
throw new Exception(GlobalMessages.CommandNotFound);
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (command.Receivers != null || command!.Receivers!.Count > 0)
|
if (command.Receivers != null && command!.Receivers!.Count > 0)
|
||||||
{
|
{
|
||||||
return command.Receivers;
|
return command.Receivers;
|
||||||
}
|
}
|
||||||
|
|
@ -110,9 +108,10 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
|
|
||||||
// 2. Query
|
// 2. Query
|
||||||
var appointPeople = await _dbContext.Set<PlacementProfile>()
|
var appointPeople = await _dbContext.Set<PlacementProfile>()
|
||||||
|
.Include(x => x.Prefix)
|
||||||
.Include(x => x.OrganizationPosition)
|
.Include(x => x.OrganizationPosition)
|
||||||
.ThenInclude(x => x.Organization)
|
.ThenInclude(x => x.Organization)
|
||||||
//.Where(x => x.OrganizationPosition.Organization.Id )
|
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
|
||||||
.Where(x => !otherCommandReceivers.Contains(x.CitizenId!))
|
.Where(x => !otherCommandReceivers.Contains(x.CitizenId!))
|
||||||
.Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN")
|
.Where(x => x.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN")
|
||||||
.Where(x => x.Draft! == true)
|
.Where(x => x.Draft! == true)
|
||||||
|
|
@ -624,6 +623,26 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public async Task<Guid> GetRootOcIdAsync(Guid ocId)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var data = await _dbContext.Set<OrganizationEntity>().AsQueryable()
|
||||||
|
|
||||||
|
|
||||||
|
// .FirstOrDefaultAsync(o => o.Id == ocId);
|
||||||
|
|
||||||
|
// if(data == null)
|
||||||
|
// throw new Exception(GlobalMessages.OrganizationNotFound);
|
||||||
|
|
||||||
|
// return data.Government!.Id
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// throw;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
55
BMA.EHR.Application/Repositories/UserProfileRepository.cs
Normal file
55
BMA.EHR.Application/Repositories/UserProfileRepository.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Repositories
|
||||||
|
{
|
||||||
|
public class UserProfileRepository : GenericRepository<Guid, Profile>
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly IApplicationDBContext _dbContext;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Costructor and Destructor "
|
||||||
|
|
||||||
|
public UserProfileRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public Guid GetUserOCId(Guid keycloakId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = _dbContext.Set<ProfilePosition>()
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.Include(x => x.OrganizationPosition)
|
||||||
|
.ThenInclude(x => x.Organization)
|
||||||
|
.Where(x => x.Profile!.KeycloakId == keycloakId)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
|
return data.OrganizationPosition!.Organization!.Id;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Application.Repositories;
|
|
||||||
using BMA.EHR.Application.Repositories.Commands;
|
using BMA.EHR.Application.Repositories.Commands;
|
||||||
using BMA.EHR.Application.Requests.Commands;
|
using BMA.EHR.Application.Requests.Commands;
|
||||||
using BMA.EHR.Command.Service.Requests;
|
using BMA.EHR.Command.Service.Requests;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
using BMA.EHR.Domain.Models.Commands.Core;
|
using BMA.EHR.Domain.Models.Commands.Core;
|
||||||
using BMA.EHR.Domain.Models.MetaData;
|
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Components.Forms;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
@ -35,6 +32,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
private readonly PrefixRepository _prefixRepository;
|
private readonly PrefixRepository _prefixRepository;
|
||||||
private readonly CommandTypeRepository _commandTypeRepository;
|
private readonly CommandTypeRepository _commandTypeRepository;
|
||||||
private readonly CommandStatusRepository _commandStatusRepository;
|
private readonly CommandStatusRepository _commandStatusRepository;
|
||||||
|
private readonly UserProfileRepository _userProfileRepository;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -47,7 +45,8 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
IHttpContextAccessor httpContextAccessor,
|
IHttpContextAccessor httpContextAccessor,
|
||||||
PrefixRepository prefixRepository,
|
PrefixRepository prefixRepository,
|
||||||
CommandTypeRepository commandTypeRepository,
|
CommandTypeRepository commandTypeRepository,
|
||||||
CommandStatusRepository commandStatusRepository)
|
CommandStatusRepository commandStatusRepository,
|
||||||
|
UserProfileRepository userProfileRepository)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
@ -57,6 +56,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
_prefixRepository = prefixRepository;
|
_prefixRepository = prefixRepository;
|
||||||
_commandTypeRepository = commandTypeRepository;
|
_commandTypeRepository = commandTypeRepository;
|
||||||
_commandStatusRepository = commandStatusRepository;
|
_commandStatusRepository = commandStatusRepository;
|
||||||
|
_userProfileRepository = userProfileRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -69,6 +69,17 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
|
|
||||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
private Guid OcId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (UserId != null || UserId != "")
|
||||||
|
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||||
|
else
|
||||||
|
return Guid.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Methods "
|
#region " Methods "
|
||||||
|
|
@ -382,7 +393,9 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
ConclusionRegisterDate = req.conclusionRegisterDate,
|
ConclusionRegisterDate = req.conclusionRegisterDate,
|
||||||
ConclusionResultNo = req.conclusionResultNo,
|
ConclusionResultNo = req.conclusionResultNo,
|
||||||
ConclusionResultDate = req.conclusionResultDate,
|
ConclusionResultDate = req.conclusionResultDate,
|
||||||
CommandAffectDate = req.orderDate
|
CommandAffectDate = req.orderDate,
|
||||||
|
OwnerGovId = OcId
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = await _repository.AddAsync(inserted);
|
var result = await _repository.AddAsync(inserted);
|
||||||
|
|
@ -496,6 +509,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
{
|
{
|
||||||
// TODO : หาค่า Education มาแสดง
|
// TODO : หาค่า Education มาแสดง
|
||||||
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
|
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
|
||||||
|
.OrderBy(x => x.Sequence)
|
||||||
.Select(r => new
|
.Select(r => new
|
||||||
{
|
{
|
||||||
personId = r.Id,
|
personId = r.Id,
|
||||||
|
|
@ -515,8 +529,11 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PM7-27 : ข้อมูลเลือกรายชื่อออกคำสั่ง
|
/// PM7-27 : ข้อมูลเลือกรายชื่อออกคำสั่ง ** ยังไม่ได้กรองหน่วยงาน **
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// ** ยังไม่ได้กรองหน่วยงาน **
|
||||||
|
/// </remarks>
|
||||||
/// <param name="personalId">Record Id ของผู้รับคำสั่งในรายการบัญชีแนบท้าย</param>
|
/// <param name="personalId">Record Id ของผู้รับคำสั่งในรายการบัญชีแนบท้าย</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using BMA.EHR.Domain.Models.Base;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using BMA.EHR.Domain.Models.Base;
|
|
||||||
using BMA.EHR.Domain.Models.MetaData;
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace BMA.EHR.Domain.Models.Organizations
|
namespace BMA.EHR.Domain.Models.Organizations
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue