Update เอกสารแนบท้าย
This commit is contained in:
parent
7fa7304954
commit
dbcf1d31b6
4 changed files with 125 additions and 7 deletions
|
|
@ -312,6 +312,47 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region " Documents "
|
||||||
|
|
||||||
|
public async Task<List<CommandDocument>> GetCommandDocumentAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var docs = await _dbContext.Set<CommandDocument>()
|
||||||
|
.Include(x => x.Command)
|
||||||
|
.Include(x => x.Document)
|
||||||
|
.Where(x => x.Command.Id == id)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return docs;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public async Task UpdateCommandInfo(Guid id, string orderNo, string orderYear, DateTime signDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _dbContext.Set<Command>().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if(command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
command.CommandExcecuteDate = signDate;
|
||||||
|
command.CommandNo = orderNo;
|
||||||
|
command.CommandYear = orderYear;
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Application.Repositories;
|
|
||||||
using BMA.EHR.Application.Repositories.Commands;
|
using BMA.EHR.Application.Repositories.Commands;
|
||||||
using BMA.EHR.Command.Service.Requests;
|
using BMA.EHR.Command.Service.Requests;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
|
|
@ -9,9 +8,8 @@ using BMA.EHR.Domain.Models.MetaData;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
|
@ -469,7 +467,6 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PM7-32 : บันทึกช่องทางการส่งสำเนาคำสั่ง
|
/// PM7-32 : บันทึกช่องทางการส่งสำเนาคำสั่ง
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
|
@ -484,7 +481,7 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
{
|
{
|
||||||
// transform
|
// transform
|
||||||
var deploys = new List<CommandDeployment>();
|
var deploys = new List<CommandDeployment>();
|
||||||
foreach(var p in req)
|
foreach (var p in req)
|
||||||
{
|
{
|
||||||
var updated = await _repository.GetCommandDeploymentById(p.PersonalId);
|
var updated = await _repository.GetCommandDeploymentById(p.PersonalId);
|
||||||
updated!.IsSendInbox = p.InboxChannel;
|
updated!.IsSendInbox = p.InboxChannel;
|
||||||
|
|
@ -527,6 +524,75 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region " Documents "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-34 : ข้อมูลรายละเอียดคำสั่งและแนบท้าย
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("attachment/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetCommandAttatchmentAsync(Guid orderId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _repository.GetByIdAsync(orderId);
|
||||||
|
if(command == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
|
var documents = await _repository.GetCommandDocumentAsync(orderId);
|
||||||
|
var cover = documents.Where(x => x.Category.Trim().ToLower() == "cover").FirstOrDefault();
|
||||||
|
var attach = documents.Where(x => x.Category.Trim().ToLower() == "attachment").FirstOrDefault();
|
||||||
|
|
||||||
|
var result = new
|
||||||
|
{
|
||||||
|
orderNo=command.CommandNo,
|
||||||
|
orderYear=command.CommandYear,
|
||||||
|
signDate = command.CommandExcecuteDate,
|
||||||
|
orderFileUrl = cover == null ? null : _documentService.ImagesPath(cover.Document.ObjectRefId),
|
||||||
|
attachmentFileUrl = attach == null ? null : _documentService.ImagesPath(attach.Document.ObjectRefId),
|
||||||
|
};
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PM7-37 : บันทึกข้อมูลคำสั่งและแนบท้าย
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orderId">Record Id ของคำสั่ง</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("attachment/{orderId}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdateCommandExecuteAsync(Guid orderId, [FromBody] UpdateCommandExecuteRequest req)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _repository.UpdateCommandInfo(orderId, req.OrderNo, req.OrderYear, req.SignDate);
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace BMA.EHR.Command.Service.Requests
|
||||||
|
{
|
||||||
|
public class UpdateCommandExecuteRequest
|
||||||
|
{
|
||||||
|
public string OrderNo { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string OrderYear { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime SignDate { get; set; } = DateTime.Now.Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories
|
namespace BMA.EHR.Application.Repositories
|
||||||
{
|
{
|
||||||
|
|
@ -210,6 +209,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public List<Guid> GetAllIdByRoot(Guid? id)
|
public List<Guid> GetAllIdByRoot(Guid? id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue