From 528ebda4658958a4d6b5734ec8c4d20cd8f40465 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Fri, 5 Jan 2024 09:25:03 +0700 Subject: [PATCH] =?UTF-8?q?api=20=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 21 +++++++++++++++ .../Controllers/OrderController.cs | 27 +++++++++++++++++++ .../DisciplineDirectorController.cs | 8 ++++++ 3 files changed, 56 insertions(+) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 6114ca7e..f991b298 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -8683,5 +8683,26 @@ namespace BMA.EHR.Application.Repositories.Commands #endregion + public async Task GetHistoryCommandByProfileAsync(string type, Guid id) + { + try + { + var command = await _dbContext.Set() + .Where(x => x.CommandType.Category == type.Trim().ToLower()) + .Where(x => x.Receivers.Where(x => x.RefPlacementProfileId == id).FirstOrDefault() != null) + .Select(x => new + { + CommandSubject = x.CommandSubject, + CreatedAt = x.CreatedAt, + LastUpdatedAt = x.LastUpdatedAt, + }) + .ToListAsync(); + return command; + } + catch + { + throw; + } + } } } diff --git a/BMA.EHR.Command.Service/Controllers/OrderController.cs b/BMA.EHR.Command.Service/Controllers/OrderController.cs index c1b2ad59..2f63e012 100644 --- a/BMA.EHR.Command.Service/Controllers/OrderController.cs +++ b/BMA.EHR.Command.Service/Controllers/OrderController.cs @@ -4698,6 +4698,33 @@ namespace BMA.EHR.Command.Service.Controllers } } + /// + /// แสดงประวัติการออกคำสั่ง + /// + /// ประเภทระบบคำสั่ง + /// Id ผู้ใช้งาน + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("history/{type}/{profileId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetHistoryCommandByProfileAsync(string type, Guid profileId) + { + try + { + var data = await _repository.GetHistoryCommandByProfileAsync(type, profileId); + + return Success(data); + } + catch + { + throw; + } + } + #endregion } } diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs index fda28913..383f8655 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineDirectorController.cs @@ -124,6 +124,10 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers [HttpPost()] public async Task> CreateDiscipline([FromBody] DisciplineDirectorRequest req) { + var dataDup = await _context.DisciplineDirectors.Where(x => x.FirstName == req.firstName && x.LastName == req.lastName).FirstOrDefaultAsync(); + if (dataDup != null) + return Error("ชื่อกรรมการนี้มีอยู่ในระบบแล้ว", StatusCodes.Status404NotFound); + var disciplineDirector = new Domain.Models.Discipline.DisciplineDirector { Prefix = req.prefix, @@ -155,6 +159,10 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers [HttpPut("{id:guid}")] public async Task> UpdateDiscipline(Guid id, [FromBody] DisciplineDirectorRequest req) { + var dataDup = await _context.DisciplineDirectors.Where(x => x.FirstName == req.firstName && x.LastName == req.lastName && x.Id != id).FirstOrDefaultAsync(); + if (dataDup != null) + return Error("ชื่อกรรมการนี้มีอยู่ในระบบแล้ว", StatusCodes.Status404NotFound); + var data = await _context.DisciplineDirectors.Where(x => x.Id == id).FirstOrDefaultAsync(); if (data == null) return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);