Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop

This commit is contained in:
Kittapath 2024-07-02 09:41:49 +07:00
commit ca90b44c74
2 changed files with 239 additions and 103 deletions

View file

@ -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,94 @@ 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,
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,
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);
}

View file

@ -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<dynamic>();
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,
@ -1663,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,
//});
}
}
}
@ -1868,36 +1963,6 @@ 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;
//}
@ -1924,29 +1989,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();
@ -2167,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)
@ -2182,7 +2226,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
var _insigniaNoteProfiles = new List<dynamic>();
foreach (var item in items)
{
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;
@ -2198,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,