diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index cf77fef5..213a2937 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1240,7 +1240,16 @@ namespace BMA.EHR.Application.Repositories.Commands var rootOcId = await GetRootOcIdAsync(UserOrganizationId); - var oc = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == rootOcId); + var oc = await _dbContext.Set() + .Include(x => x.OrganizationOrganization) + .Select(x => new KeyValueItemResponse + { + Id = x.Id, + Name = x.OrganizationOrganization!.Name + }) + .FirstOrDefaultAsync(x => x.Id == rootOcId); + if (oc != null) + ret.Add(oc); return ret; } diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index b6b4f81e..b3b1be0d 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -1145,6 +1145,57 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// แสดงรายชื่อหน่วยงานสำหรับเลือกเพื่อออกคำสั่ง + /// + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("organizations")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetCommandOrganizationAsync() + { + try + { + var data = await _repository.GetCommandOrgAsync(); + + return Success(data); + } + catch + { + throw; + } + } + + /// + /// แสดงชื่อผู้อนุมัติในรายการคำสั่ง + /// + /// Id ของหน่วยงานที่เลือกเพื่อออกคำสั่ง + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("approver/{ocId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetCommandOrganizationApproverAsync(Guid ocId) + { + try + { + var data = await _repository.GetOrgApproverAsync(ocId); + + return Success(data); + } + catch + { + throw; + } + } + #endregion } }