diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index ea6f0e81..6e2ea314 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -31,6 +31,7 @@ namespace BMA.EHR.Command.Service.Controllers private readonly MinIOService _documentService; private readonly IHttpContextAccessor _httpContextAccessor; private readonly PrefixRepository _prefixRepository; + private readonly CommandTypeRepository _commandTypeRepository; #endregion @@ -41,7 +42,8 @@ namespace BMA.EHR.Command.Service.Controllers ApplicationDBContext context, MinIOService documentService, IHttpContextAccessor httpContextAccessor, - PrefixRepository prefixRepository) + PrefixRepository prefixRepository, + CommandTypeRepository commandTypeRepository) { _repository = repository; _context = context; @@ -49,6 +51,7 @@ namespace BMA.EHR.Command.Service.Controllers _httpContextAccessor = httpContextAccessor; _placementRepository = placementRepository; _prefixRepository = prefixRepository; + _commandTypeRepository = commandTypeRepository; } #endregion @@ -68,6 +71,9 @@ namespace BMA.EHR.Command.Service.Controllers /// /// แสดงปีเป็นปีพุทธศักราช โดยดึงจากข้อมูลที่มีในระบบ /// + /// + /// ถ้าไม่มีข้อมูลเลยจะ default ปีปัจจุบันให้ 1 รายการ + /// /// /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ @@ -76,22 +82,57 @@ namespace BMA.EHR.Command.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetFiscal() + public async Task> GetFiscalAsync() { var data = await _repository.GetAllAsync(); if (data != null) { var _data = data.GroupBy(x => x.CommandYear).Select(x => new { - Id = x.FirstOrDefault().CommandYear, - Name = x.FirstOrDefault().CommandYear + 543, + Id = x.FirstOrDefault().CommandYear.ToInteger().ToCeYear(), + Name = x.FirstOrDefault().CommandYear.ToInteger().ToThaiYear(), }).ToList(); + + if(_data == null || _data.Count == 0) + { + _data!.Add(new + { + Id = DateTime.Now.Year, + Name = DateTime.Now.Year.ToThaiYear() + }); + } + return Success(_data); } return Success(data); } + /// + /// แสดงประเภทคำสั่ง โดยดึงจากข้อมูลที่มีในระบบ + /// + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("order-type")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetCommandTypeAsync() + { + try + { + var data = (await _commandTypeRepository.GetAllAsync()).OrderBy(x => x.CommandCode); + + return Success(data); + } + catch + { + throw; + } + } + /// /// PM7-19 : หน้าจอรายการออกคำสั่ง ///