diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index d0890b6c..eef0eae1 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1465,7 +1465,7 @@ namespace BMA.EHR.Application.Repositories.Commands await ExecuteCommand12Async(command); break; case "C-PM-17": - await ExecuteCommand17Async(command); + await ExecuteCommand17Async(command); break; case "C-PM-18": await ExecuteCommand18Async(command); @@ -2030,7 +2030,7 @@ namespace BMA.EHR.Application.Repositories.Commands { foreach (var recv in command.Receivers) { - var data = await _dbContext.Set() + var data = await _dbContext.Set() .Include(x => x.Salaries) .ThenInclude(x => x.PositionLevel) .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId); @@ -3737,6 +3737,34 @@ namespace BMA.EHR.Application.Repositories.Commands #endregion + public async Task GetCommandProfileAsync(Guid commandTypeId, int year, string? posno) + { + try + { + var commandType = await _dbContext.Set() + .FirstOrDefaultAsync(x => x.Id == commandTypeId); + + if (commandType == null) + throw new Exception(GlobalMessages.CommandTypeNotFound); + + var profile = await _dbContext.Set() + .Where(x => x.CitizenId == "0000000000001") + .Select(x => new + { + Id = x.Id, + CitizenId = x.CitizenId, + FullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}", + PosNo = x.PosNo == null ? null : x.PosNo.Name, + Position = x.Position == null ? null : x.Position.Name, + }) + .ToListAsync(); + return profile; + } + catch + { + throw; + } + } #endregion } diff --git a/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs b/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs new file mode 100644 index 00000000..1af7fb64 --- /dev/null +++ b/BMA.EHR.Application/Requests/Commands/SearchProfileCommandRequest.cs @@ -0,0 +1,11 @@ +namespace BMA.EHR.Application.Requests.Commands +{ + public class SearchProfileCommandRequest + { + public Guid CommandTypeId { get; set; } + + public int Year { get; set; } + + public string? Posno { get; set; } + } +} diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index 90e005f8..75235641 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -233,7 +233,7 @@ namespace BMA.EHR.Command.Service.Controllers } } - + } catch { @@ -3424,6 +3424,31 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// แสดงชื่อผู้เกี่ยวข้องกับคำสั่ง + /// + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("search/profile/command")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetCommandProfileAsync([FromBody] SearchProfileCommandRequest req) + { + try + { + var data = await _repository.GetCommandProfileAsync(req.CommandTypeId, req.Year, req.Posno); + + return Success(data); + } + catch + { + throw; + } + } + #endregion } } diff --git a/BMA.EHR.Domain/Shared/GlobalMessages.cs b/BMA.EHR.Domain/Shared/GlobalMessages.cs index ed9e9a72..2678c379 100644 --- a/BMA.EHR.Domain/Shared/GlobalMessages.cs +++ b/BMA.EHR.Domain/Shared/GlobalMessages.cs @@ -110,6 +110,7 @@ #region " Command " public static readonly string CommandNotFound = "ไม่พบรายการคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง"; + public static readonly string CommandTypeNotFound = "ไม่พบรายการประเภทคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง"; public static readonly string MethodForCommandTypeNotImplement = "Method for this command type not implement!";