From 1a528e4a91a4c95d1648d6a30c514c45ef238b66 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Thu, 3 Aug 2023 11:52:11 +0700 Subject: [PATCH] =?UTF-8?q?Add=20-=20API=20=E0=B9=81=E0=B8=AA=E0=B8=94?= =?UTF-8?q?=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A0=E0=B8=97=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=20Edit=20-=20API?= =?UTF-8?q?=20=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=E0=B8=9B=E0=B8=B5=20?= =?UTF-8?q?=E0=B8=96=E0=B9=89=E0=B8=B2=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=B5=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=E0=B8=9B?= =?UTF-8?q?=E0=B8=B5=E0=B8=9B=E0=B8=B1=E0=B8=88=E0=B8=88=E0=B8=B8=E0=B8=9A?= =?UTF-8?q?=E0=B8=B1=E0=B8=99=E0=B9=83=E0=B8=AB=E0=B9=89=201=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) 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 : หน้าจอรายการออกคำสั่ง ///