From f1ad524b891b3e2adabdd48686627e674be31043 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 1 Jul 2024 22:33:19 +0700 Subject: [PATCH 1/7] fix preview invoice insignia --- .../Controllers/InsigniaRequestController.cs | 57 +------------------ 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index 01489df5..bf905cbc 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -1868,37 +1868,7 @@ namespace BMA.EHR.Insignia.Service.Controllers // continue; if (profile.Status != "DONE") { - // 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; - //} - + profile.Status = "DONE"; @@ -1924,29 +1894,7 @@ namespace BMA.EHR.Insignia.Service.Controllers }; await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken); - //await _context.ProfileInsignias.AddAsync(new ProfileInsignia - //{ - // Year = insigniaNote.Year, - // No = profile.No, - // Issue = profile.VolumeNo, - // VolumeNo = profile.VolumeNo, - // // Volume = profile.Volume, - // Section = profile.Section, - // Page = profile.Page, - // DateAnnounce = profile.Date, - // ReceiveDate = profile.DateReceive, - // InsigniaType = profile.RequestInsignia.InsigniaType == null ? null : profile.RequestInsignia.InsigniaType.Name, - // Insignia = profile.RequestInsignia, - // // RefCommandNo = req.RefCommandNo, - // // RefCommandDate = req.RefCommandDate, - // ProfileId = profile.ProfileId.Value, - // CreatedFullName = FullName ?? "System Administrator", - // CreatedUserId = UserId ?? "", - // CreatedAt = DateTime.Now, - // LastUpdateFullName = FullName ?? "System Administrator", - // LastUpdateUserId = UserId ?? "", - // LastUpdatedAt = DateTime.Now, - //}); + } } await _context.SaveChangesAsync(); @@ -2182,6 +2130,7 @@ namespace BMA.EHR.Insignia.Service.Controllers var _insigniaNoteProfiles = new List(); foreach (var item in items) { + if (item.CitizanId == null) continue; var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken); var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id); if (profile == null) From bc37746aa523bd09712e09338e71ae73e655deff Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 2 Jul 2024 02:39:45 +0700 Subject: [PATCH 2/7] api note/search fix timeout --- .../Controllers/InsigniaRequestController.cs | 105 +++++++++++++++--- 1 file changed, 90 insertions(+), 15 deletions(-) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index bf905cbc..807a2324 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -1392,25 +1392,22 @@ namespace BMA.EHR.Insignia.Service.Controllers .FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId); if (insigniaType == null) return Error(GlobalMessages.InsigniaTypeNotFound); - var insigniaNoteProfiles = await _context.InsigniaNoteProfiles + + var rawNoteProfiles = await _context.InsigniaNoteProfiles .Where(x => x.InsigniaNote == insigniaNote) .Where(x => x.RequestInsignia.InsigniaType == insigniaType) .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId)) .Select(x => new { Id = x.Id, - Prefix = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix, - Position = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Position, - ProfileType = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).ProfileType, - OcId = Guid.Empty, - CitizenId = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).CitizenId, - FullName = $"{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).LastName}", + Profile = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken), + OcId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), // TODO: ต้องมาแก้ไข RequestInsignia = x.RequestInsignia.Name, RequestInsigniaId = x.RequestInsignia.Id, RequestInsigniaShortName = x.RequestInsignia.ShortName, DateReceive = x.DateReceive, - OrganizationOrganizationSend = x.OrganizationOrganizationSend, - OrganizationOrganizationReceive = x.OrganizationOrganizationReceive, + OrganizationOrganizationSend = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode + OrganizationOrganizationReceive = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode Status = x.Status, Issue = x.Issue, Date = x.Date, @@ -1425,11 +1422,89 @@ namespace BMA.EHR.Insignia.Service.Controllers Salary = x.Salary, DateReceiveInsignia = x.DateReceiveInsignia, DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id, - OrgReceiveInsignia = x.OrgReceiveInsignia == null || x.OrgReceiveInsignia.OrganizationOrganization == null ? "-" : x.OrgReceiveInsignia.OrganizationOrganization.Name, + OrgReceiveInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode DateReturnInsignia = x.DateReturnInsignia, DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id, - OrgReturnInsignia = x.OrgReturnInsignia == null || x.OrgReturnInsignia.OrganizationOrganization == null ? "-" : x.OrgReturnInsignia.OrganizationOrganization.Name, - }).ToListAsync(); + OrgReturnInsignia = _userProfileRepository.GetOc(Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"), 0, AccessToken).Root, //hardcode + }) + .ToListAsync(); + + var insigniaNoteProfiles = rawNoteProfiles + .Select(x => new + { + Id = x.Id, + Prefix = x.Profile == null ? "" : x.Profile.Prefix, + Position = x.Profile == null ? "" : x.Profile.Position, + ProfileType = x.Profile == null ? "" : x.Profile.ProfileType, + x.OcId, + CitizenId = x.Profile == null ? "" : x.Profile.CitizenId, + FullName = x.Profile == null ? "" : $"{x.Profile.Prefix}{x.Profile.FirstName} {x.Profile.LastName}", + RequestInsignia = x.RequestInsignia, + RequestInsigniaId = x.RequestInsigniaId, + RequestInsigniaShortName = x.RequestInsigniaShortName, + DateReceive = x.DateReceive, + OrganizationOrganizationSend = x.OrganizationOrganizationSend, + OrganizationOrganizationReceive = x.OrganizationOrganizationReceive, + Status = x.Status, + Issue = x.Issue, + Date = x.Date, + VolumeNo = x.VolumeNo, + Section = x.Section, + Page = x.Page, + No = x.No, + DatePayment = x.DatePayment, + TypePayment = x.TypePayment, + Address = x.Address, + Number = x.Number, + Salary = x.Salary, + DateReceiveInsignia = x.DateReceiveInsignia, + DocReceiveInsignia = x.DocReceiveInsignia, + OrgReceiveInsignia = x.OrgReceiveInsignia, + DateReturnInsignia = x.DateReturnInsignia, + DocReturnInsignia = x.DocReturnInsignia, + OrgReturnInsignia = x.OrgReturnInsignia, + }) + .ToList(); + + //var insigniaNoteProfiles = await _context.InsigniaNoteProfiles + // .Where(x => x.InsigniaNote == insigniaNote) + // .Where(x => x.RequestInsignia.InsigniaType == insigniaType) + // .Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId)) + // .Select(x => new + // { + // Id = x.Id, + // Prefix = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix, + // Position = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Position, + // ProfileType = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).ProfileType, + // OcId = Guid.Empty, + // CitizenId = _userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).CitizenId, + // FullName = $"{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(x.ProfileId.Value, AccessToken).LastName}", + // RequestInsignia = x.RequestInsignia.Name, + // RequestInsigniaId = x.RequestInsignia.Id, + // RequestInsigniaShortName = x.RequestInsignia.ShortName, + // DateReceive = x.DateReceive, + // OrganizationOrganizationSend = x.OrganizationOrganizationSend, + // OrganizationOrganizationReceive = x.OrganizationOrganizationReceive, + // Status = x.Status, + // Issue = x.Issue, + // Date = x.Date, + // VolumeNo = x.VolumeNo, + // Section = x.Section, + // Page = x.Page, + // No = x.No, + // DatePayment = x.DatePayment, + // TypePayment = x.TypePayment, + // Address = x.Address, + // Number = x.Number, + // Salary = x.Salary, + // DateReceiveInsignia = x.DateReceiveInsignia, + // DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id, + // OrgReceiveInsignia = x.OrgReceiveInsignia == null || x.OrgReceiveInsignia.OrganizationOrganization == null ? "-" : x.OrgReceiveInsignia.OrganizationOrganization.Name, + // DateReturnInsignia = x.DateReturnInsignia, + // DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id, + // OrgReturnInsignia = x.OrgReturnInsignia == null || x.OrgReturnInsignia.OrganizationOrganization == null ? "-" : x.OrgReturnInsignia.OrganizationOrganization.Name, + // }).ToListAsync(); + var _insigniaNoteProfiles = new List(); foreach (var insigniaNoteProfile in insigniaNoteProfiles) { @@ -1447,7 +1522,7 @@ namespace BMA.EHR.Insignia.Service.Controllers insigniaNoteProfile.RequestInsigniaShortName, insigniaNoteProfile.DateReceive, insigniaNoteProfile.OrganizationOrganizationSend, - OrganizationOrganizationReceive = insigniaNoteProfile.OrganizationOrganizationReceive == null ? (insigniaNoteProfile.OcId == null ? null : FindOCFullPath(insigniaNoteProfile.OcId, true)) : insigniaNoteProfile.OrganizationOrganizationReceive, + insigniaNoteProfile.OrganizationOrganizationReceive, insigniaNoteProfile.Status, insigniaNoteProfile.Issue, insigniaNoteProfile.Date, @@ -1868,7 +1943,7 @@ namespace BMA.EHR.Insignia.Service.Controllers // continue; if (profile.Status != "DONE") { - + profile.Status = "DONE"; @@ -1894,7 +1969,7 @@ namespace BMA.EHR.Insignia.Service.Controllers }; await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken); - + } } await _context.SaveChangesAsync(); From 0234925827b0a44314c0ceeee6a5248e553e4545 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 2 Jul 2024 02:54:38 +0700 Subject: [PATCH 3/7] fix Put Note/{insigniaNoteId} API --- .../Controllers/InsigniaRequestController.cs | 64 ++++++++++++------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index 807a2324..2de7d289 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -1738,29 +1738,49 @@ namespace BMA.EHR.Insignia.Service.Controllers if (req.DateReceive != null && req.Date != null) { profileInsignia.Status = "DONE"; - await _context.ProfileInsignias.AddAsync(new ProfileInsignia + + var profileInsigniaBody = new PostProfileInsigniaDto { - Year = insigniaNote.Year, - No = req.No, - Issue = req.VolumeNo, - VolumeNo = req.VolumeNo, - //Volume = req.Volume, - Section = req.Section, - Page = req.Page, - DateAnnounce = req.Date, - ReceiveDate = req.DateReceive, - InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name, - Insignia = insignia, - // RefCommandNo = req.RefCommandNo, - // RefCommandDate = req.RefCommandDate, - ProfileId = profile.Id, - CreatedFullName = FullName ?? "System Administrator", - CreatedUserId = UserId ?? "", - CreatedAt = DateTime.Now, - LastUpdateFullName = FullName ?? "System Administrator", - LastUpdateUserId = UserId ?? "", - LastUpdatedAt = DateTime.Now, - }); + profileId = profileInsignia.ProfileId.Value, + year = insigniaNote.Year, + no = profileInsignia.No, + volumeNo = profileInsignia.VolumeNo, + section = profileInsignia.Section, + page = profileInsignia.Page, + receiveDate = profileInsignia.DateReceive.Value, + dateAnnounce = profileInsignia.Date.Value, + insigniaId = profileInsignia.RequestInsignia.Id, + issue = "", + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", + + }; + await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); + //await _context.ProfileInsignias.AddAsync(new ProfileInsignia + //{ + // Year = insigniaNote.Year, + // No = req.No, + // Issue = req.VolumeNo, + // VolumeNo = req.VolumeNo, + // //Volume = req.Volume, + // Section = req.Section, + // Page = req.Page, + // DateAnnounce = req.Date, + // ReceiveDate = req.DateReceive, + // InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name, + // Insignia = insignia, + // // RefCommandNo = req.RefCommandNo, + // // RefCommandDate = req.RefCommandDate, + // ProfileId = profile.Id, + // CreatedFullName = FullName ?? "System Administrator", + // CreatedUserId = UserId ?? "", + // CreatedAt = DateTime.Now, + // LastUpdateFullName = FullName ?? "System Administrator", + // LastUpdateUserId = UserId ?? "", + // LastUpdatedAt = DateTime.Now, + //}); } } } From 84bb010535fa7077fb9e8c9eb2d825bdf1ad8470 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 2 Jul 2024 03:25:11 +0700 Subject: [PATCH 4/7] =?UTF-8?q?fix=20=E0=B8=A2=E0=B8=B7=E0=B8=A1=E0=B8=84?= =?UTF-8?q?=E0=B8=B7=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/InsigniaManageController.cs | 107 ++++++++++++++++-- 1 file changed, 97 insertions(+), 10 deletions(-) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs index aee0304b..da09268a 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; using Newtonsoft.Json; +using OfficeOpenXml.Export.ToDataTable; using Swashbuckle.AspNetCore.Annotations; namespace BMA.EHR.Insignia.Service.Controllers @@ -437,6 +438,9 @@ namespace BMA.EHR.Insignia.Service.Controllers //var _organization = await _context.Organizations.AsQueryable() // .FirstOrDefaultAsync(x => x.Id == insigniaNoteProfile.Profile.OcId); + //TODO : Hardcode OCId + if (req.BorrowOrganizationId == null) req.BorrowOrganizationId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3"); + var organization = _userProfileRepository.GetOc(req.BorrowOrganizationId.Value, 0, AccessToken); //if (organization == null) // return Error(GlobalMessages.OrganizationNotFound); @@ -548,30 +552,27 @@ namespace BMA.EHR.Insignia.Service.Controllers .FirstOrDefaultAsync(x => x.Id == insigniaTypeId); if (insigniaType == null) return Error(GlobalMessages.InsigniaTypeNotFound); - var data = await _context.InsigniaManageProfiles.AsQueryable() + + + var rawData = await _context.InsigniaManageProfiles.AsQueryable() .Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType) .Where(x => year == 0 ? x.Id != null : x.InsigniaManageOrganiation.InsigniaManage.Year == year) .OrderByDescending(x => x.CreatedAt) .Select(p => new { Id = p.Id, + BorrowOrganization = p.BorrowOrganizationId == null ? null : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken), + ReturnOrganization = p.ReturnOrganizationId == null ? null : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken), + Profile = p.InsigniaNoteProfile.ProfileId == null ? null : _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken), + Status = p.Status, - BorrowOrganization = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).Root, - BorrowOrganizationId = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).RootId, BorrowDate = p.BorrowDate, ReturnDate = p.ReturnDate, - ReturnOrganization = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).Root, - ReturnOrganizationId = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).RootId, ReturnReason = p.ReturnReason, LastUpdatedAt = p.LastUpdatedAt, CreatedAt = p.CreatedAt, InsigniaNoteProfileId = p.InsigniaNoteProfile.Id, - Prefix = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix, - Position = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Position, - _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).CitizenId, - _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).ProfileType, - FullName = $"{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).LastName}", RequestInsignia = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.Name, RequestInsigniaId = p.InsigniaNoteProfile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.InsigniaNoteProfile.RequestInsignia.Id, RequestInsigniaShortName = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.ShortName, @@ -592,6 +593,92 @@ namespace BMA.EHR.Insignia.Service.Controllers p.InsigniaNoteProfile.Salary, }) .ToListAsync(); + + var data = rawData + .Select(p => new + { + p.Id, + p.Status, + BorrowOrganization = p.BorrowOrganization == null ? "" : p.BorrowOrganization.Root, + BorrowOrganizationId = p.BorrowOrganization == null ? Guid.Empty : p.BorrowOrganization.RootId, + p.BorrowDate, + p.ReturnDate, + ReturnOrganization = p.ReturnOrganization == null ? "" : p.ReturnOrganization.Root, + ReturnOrganizationId = p.ReturnOrganization == null ? Guid.Empty : p.ReturnOrganization.RootId, + p.ReturnReason, + p.LastUpdatedAt, + p.CreatedAt, + p.InsigniaNoteProfileId, + Prefix = p.Profile == null ? "" : p.Profile.Prefix, + Position = p.Profile == null ? "" : p.Profile.Position, + FullName = p.Profile == null ? "" : $"{p.Profile.Prefix}{p.Profile.FirstName} {p.Profile.LastName}", + p.RequestInsignia, + p.RequestInsigniaId, + p.RequestInsigniaShortName, + p.DateReceive, + p.OrganizationOrganizationSend, + p.OrganizationOrganizationReceive, + p.InsigniaNoteProfileStatus, + p.Issue, + p.Date, + p.VolumeNo, + p.Section, + p.Page, + p.No, + p.DatePayment, + p.TypePayment, + p.Address, + p.Number, + p.Salary, + + }) + .ToList(); + + //var data = await _context.InsigniaManageProfiles.AsQueryable() + // .Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType) + // .Where(x => year == 0 ? x.Id != null : x.InsigniaManageOrganiation.InsigniaManage.Year == year) + // .OrderByDescending(x => x.CreatedAt) + // .Select(p => new + // { + // Id = p.Id, + // Status = p.Status, + // BorrowOrganization = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).Root, + // BorrowOrganizationId = _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.BorrowOrganizationId!.Value, 0, AccessToken).RootId, + // BorrowDate = p.BorrowDate, + // ReturnDate = p.ReturnDate, + // ReturnOrganization = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? null : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).Root, + // ReturnOrganizationId = _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken) == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : _userProfileRepository.GetOc(p.ReturnOrganizationId!.Value, 0, AccessToken).RootId, + // ReturnReason = p.ReturnReason, + // LastUpdatedAt = p.LastUpdatedAt, + // CreatedAt = p.CreatedAt, + + // InsigniaNoteProfileId = p.InsigniaNoteProfile.Id, + // Prefix = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix, + // Position = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Position, + // _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).CitizenId, + // _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).ProfileType, + // FullName = $"{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).LastName}", + // RequestInsignia = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.Name, + // RequestInsigniaId = p.InsigniaNoteProfile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.InsigniaNoteProfile.RequestInsignia.Id, + // RequestInsigniaShortName = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.ShortName, + // p.InsigniaNoteProfile.DateReceive, + // p.InsigniaNoteProfile.OrganizationOrganizationSend, + // p.InsigniaNoteProfile.OrganizationOrganizationReceive, + // InsigniaNoteProfileStatus = p.InsigniaNoteProfile.Status, + // p.InsigniaNoteProfile.Issue, + // p.InsigniaNoteProfile.Date, + // p.InsigniaNoteProfile.VolumeNo, + // p.InsigniaNoteProfile.Section, + // p.InsigniaNoteProfile.Page, + // p.InsigniaNoteProfile.No, + // p.InsigniaNoteProfile.DatePayment, + // p.InsigniaNoteProfile.TypePayment, + // p.InsigniaNoteProfile.Address, + // p.InsigniaNoteProfile.Number, + // p.InsigniaNoteProfile.Salary, + // }) + // .ToListAsync(); + return Success(data); } From 3b6d444ad6df4db9b7b76faa3ead3aa03e346338 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 2 Jul 2024 03:35:06 +0700 Subject: [PATCH 5/7] Add Missing Field --- .../Controllers/InsigniaManageController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs index da09268a..9218d370 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaManageController.cs @@ -609,9 +609,11 @@ namespace BMA.EHR.Insignia.Service.Controllers p.LastUpdatedAt, p.CreatedAt, p.InsigniaNoteProfileId, + CitizenId = p.Profile == null ? "" : p.Profile.CitizenId, Prefix = p.Profile == null ? "" : p.Profile.Prefix, Position = p.Profile == null ? "" : p.Profile.Position, FullName = p.Profile == null ? "" : $"{p.Profile.Prefix}{p.Profile.FirstName} {p.Profile.LastName}", + ProfileType = p.Profile == null ? "" : p.Profile.ProfileType, p.RequestInsignia, p.RequestInsigniaId, p.RequestInsigniaShortName, From 619f54d8a928f6c733a8f2e471f22b80ba9c1f6e Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 2 Jul 2024 05:19:31 +0700 Subject: [PATCH 6/7] fix missing Error --- .../Controllers/InsigniaRequestController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index 2de7d289..5eb000a7 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -2210,6 +2210,7 @@ namespace BMA.EHR.Insignia.Service.Controllers var items = await ReadExcelImportInvoice(file); foreach (var item in items) { + if (item.CitizanId == null) continue; var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken); var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id); if (profile == null) From 509aefabffcb81eca7604494e55055106c468a80 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Tue, 2 Jul 2024 05:37:00 +0700 Subject: [PATCH 7/7] fix preview invoice api --- .../Controllers/InsigniaRequestController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index 5eb000a7..34b490f8 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -2228,6 +2228,8 @@ namespace BMA.EHR.Insignia.Service.Controllers { if (item.CitizanId == null) continue; var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken); + + if (pf == null) continue; var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id); if (profile == null) continue; @@ -2243,11 +2245,11 @@ namespace BMA.EHR.Insignia.Service.Controllers new { profile.Id, - Prefix = _userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).Prefix, - Position = _userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).Position, - _userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).CitizenId, - _userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).ProfileType, - FullName = $"{_userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(profile.Id, AccessToken).LastName}", + Prefix = pf.Prefix, + Position = pf.Position, + pf.CitizenId, + pf.ProfileType, + FullName = $"{pf.Prefix}{pf.FirstName} {pf.LastName}", RequestInsignia = profile.RequestInsignia == null ? null : profile.RequestInsignia.Name, RequestInsigniaId = profile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profile.RequestInsignia.Id, RequestInsigniaShortName = profile.RequestInsignia == null ? null : profile.RequestInsignia.ShortName,