From 26ccf67dad2fdbddf3ec9ac12e3da9c13d1fa951 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Fri, 28 Jun 2024 12:27:55 +0700 Subject: [PATCH] =?UTF-8?q?fix=20:=20=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=A2?= =?UTF-8?q?=E0=B9=8C=20+=20=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6?= =?UTF-8?q?=E0=B8=81=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=A2=E0=B9=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/InsigniaPeriodsRepository.cs | 3 +- .../Repositories/UserProfileRepository.cs | 20 ++++++++++ .../Requests/SaveToProfileRequest.cs | 2 +- .../Insignias/PostProfileInsigniaDto.cs | 39 +++++++++++++++++++ .../Controllers/InsigniaReceiveController.cs | 33 +++++++++++++++- 5 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index 8891e777..0f8b14f3 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -5179,10 +5179,9 @@ namespace BMA.EHR.Application.Repositories .Include(x => x.Document) //.Include(x => x.Organization) //.ThenInclude(x => x.OrganizationOrganization) - .Where(x => x.OrganizationId != null) .FirstOrDefaultAsync(x => x.Period.Id == period.Id && x.OrganizationId == ocId); - var oc = _userProfileRepository.GetOc(request.OrganizationId, 0, AccessToken); + var oc = _userProfileRepository.GetOc(ocId, 0, AccessToken); return new InsigniaResults { diff --git a/BMA.EHR.Application/Repositories/UserProfileRepository.cs b/BMA.EHR.Application/Repositories/UserProfileRepository.cs index e4a73fb9..ea8bae3a 100644 --- a/BMA.EHR.Application/Repositories/UserProfileRepository.cs +++ b/BMA.EHR.Application/Repositories/UserProfileRepository.cs @@ -1,4 +1,5 @@ using BMA.EHR.Application.Common.Interfaces; +using BMA.EHR.Application.Responses.Insignias; using BMA.EHR.Application.Responses.Organizations; using BMA.EHR.Application.Responses.Profiles; using BMA.EHR.Domain.Models.HR; @@ -533,6 +534,25 @@ namespace BMA.EHR.Application.Repositories } } + + public async Task PostProfileInsigniaAsync(PostProfileInsigniaDto body, string? accessToken) + { + try + { + var apiPath = $"{_configuration["API"]}/org/profile/insignia"; + + var profiles = new List(); + + var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body); + + } + catch + { + throw; + } + + } + #endregion } } diff --git a/BMA.EHR.Application/Requests/SaveToProfileRequest.cs b/BMA.EHR.Application/Requests/SaveToProfileRequest.cs index 98438ca0..8343bc1c 100644 --- a/BMA.EHR.Application/Requests/SaveToProfileRequest.cs +++ b/BMA.EHR.Application/Requests/SaveToProfileRequest.cs @@ -22,7 +22,7 @@ namespace BMA.EHR.Application.Requests public string InsigniaName { get; set; } public string InsigniaPage { get; set; } public string InsigniaNo { get; set; } - public int? Kp7InsigniaId { get; set; } + public Guid Kp7InsigniaId { get; set; } } public class DocReceive { diff --git a/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs b/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs new file mode 100644 index 00000000..903976f7 --- /dev/null +++ b/BMA.EHR.Application/Responses/Insignias/PostProfileInsigniaDto.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BMA.EHR.Application.Responses.Insignias +{ + public class PostProfileInsigniaDto + { + public Guid ProfileId { get; set; } + + public int Year { get; set; } = 0; + + public string No { get; set; } = string.Empty; + + public string Volume { get; set; } = string.Empty; + + public string Section { get; set; } = string.Empty; + + public string Page { get; set; } = string.Empty; + + public DateTime ReceiveDate { get; set; } = DateTime.MinValue; + + public Guid InsigniaId { get; set; } + + public DateTime DateAnnounce { get; set; } = DateTime.MinValue; + + public string Issue { get; set; } = string.Empty; + + public string VolumeNo { get; set; } = string.Empty; + + public DateTime? RefCommandDate { get; set; } + + public string RefCommandNo { get; set; } = string.Empty; + + public string Note { get; set; } = string.Empty; + } +} diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaReceiveController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaReceiveController.cs index dbe8338b..f9993b3d 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaReceiveController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaReceiveController.cs @@ -2,6 +2,7 @@ using BMA.EHR.Application.Repositories; using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Application.Requests; +using BMA.EHR.Application.Responses.Insignias; using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Models.Insignias; using BMA.EHR.Domain.Shared; @@ -26,19 +27,25 @@ namespace BMA.EHR.Insignia.Service.Controllers private readonly InsigniaPeriodsRepository _repository; private readonly NotificationRepository _repositoryNoti; + private readonly UserProfileRepository _userProfileRepository; + public InsigniaReceiveController(ApplicationDBContext context, MinIOService documentService, InsigniaPeriodsRepository repository, NotificationRepository repositoryNoti, - IHttpContextAccessor httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + UserProfileRepository userProfileRepository) { _context = context; _documentService = documentService; _repository = repository; _repositoryNoti = repositoryNoti; _httpContextAccessor = httpContextAccessor; + _userProfileRepository = userProfileRepository; } + private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"]; + [HttpGet("{type}/{ocId:length(36)}")] public async Task> GetInsigniaList(string type, Guid id, Guid ocId) { @@ -151,6 +158,28 @@ namespace BMA.EHR.Insignia.Service.Controllers if (items.Profile.Count() != 0) { + foreach(var p in items.Profile) + { + await _userProfileRepository.PostProfileInsigniaAsync(new PostProfileInsigniaDto + { + ProfileId = Guid.Parse(p.FkProfileId), + Year = item.InsigniaDateannounce.Value.Year, + No = p.InsigniaNo, + Volume = item.InsigniaVolume, + Section = item.InsigniaSection, + Page = p.InsigniaPage, + ReceiveDate = item.InsigniaDatereceive.Value, + InsigniaId = p.Kp7InsigniaId, + DateAnnounce = item.InsigniaDateannounce.Value, + Issue = item.InsigniaIssue, + VolumeNo = item.InsigniaVolumeno.Value.ToString(), + + + }, AccessToken); + } + + + // foreach (var i in items.Profile) // { // var profile = _context.Profiles.AsQueryable() @@ -208,7 +237,7 @@ namespace BMA.EHR.Insignia.Service.Controllers // return NotFound("Profile not found!!!"); // } } - _context.SaveChanges(); + //_context.SaveChanges(); return Success(); }