Merge branch 'develop' into working
This commit is contained in:
commit
7b78dc6ce8
2 changed files with 173 additions and 74 deletions
|
|
@ -77,8 +77,13 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
// var retires = new List<dynamic>();
|
// var retires = new List<dynamic>();
|
||||||
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||||
dynamic rootOrder = new List<string>();
|
dynamic rootOrder = new List<string>();
|
||||||
|
dynamic child1Order = new List<string>();
|
||||||
|
dynamic child2Order = new List<string>();
|
||||||
|
dynamic child3Order = new List<string>();
|
||||||
|
dynamic child4Order = new List<string>();
|
||||||
dynamic posTypeNameOrder = new List<string>();
|
dynamic posTypeNameOrder = new List<string>();
|
||||||
dynamic posLevelNameOrder = new List<string>();
|
dynamic posLevelNameOrder = new List<string>();
|
||||||
|
dynamic hospital = new List<string>();
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
|
|
@ -92,8 +97,13 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
if (org != null && org.result != null)
|
if (org != null && org.result != null)
|
||||||
{
|
{
|
||||||
rootOrder = org.result.root;
|
rootOrder = org.result.root;
|
||||||
|
child1Order = org.result.child1;
|
||||||
|
child2Order = org.result.child2;
|
||||||
|
child3Order = org.result.child3;
|
||||||
|
child4Order = org.result.child4;
|
||||||
posTypeNameOrder = org.result.posTypeNameOrder;
|
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||||
posLevelNameOrder = org.result.posLevelNameOrder;
|
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||||
|
hospital = org.result.hospital;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (retire == null)
|
if (retire == null)
|
||||||
|
|
@ -147,35 +157,40 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
profiles = profiles.OrderBy(x => x.order).ToList();
|
profiles = profiles.OrderBy(x => x.order).ToList();
|
||||||
}
|
}
|
||||||
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
||||||
string previousRoot = null;
|
// string previousRoot = null;
|
||||||
string previousPosTypeName = null;
|
// string previousPosTypeName = null;
|
||||||
string previousPosLevelName = null;
|
// string previousPosLevelName = null;
|
||||||
if (profiles.Count > 0)
|
if (profiles.Count > 0)
|
||||||
{
|
{
|
||||||
mapProfiles = profiles
|
mapProfiles = profiles
|
||||||
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
// .OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
// .ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
// .ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
||||||
.Select((profile, index) =>
|
.Select((profile, index) =>
|
||||||
{
|
{
|
||||||
bool isDuplicateRoot = profile.root == previousRoot;
|
// bool isDuplicateRoot = profile.root == previousRoot;
|
||||||
previousRoot = profile.root;
|
// previousRoot = profile.root;
|
||||||
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
// bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
||||||
previousPosTypeName = profile.posTypeName;
|
// previousPosTypeName = profile.posTypeName;
|
||||||
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
// bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
||||||
previousPosLevelName = profile.posLevelName;
|
// previousPosLevelName = profile.posLevelName;
|
||||||
|
var _child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
||||||
|
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
||||||
|
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
||||||
|
(profile.child2 == null ? "" : profile.child2 + "\n") +
|
||||||
|
(profile.child1 == null ? "" : profile.child1 + "\n") +
|
||||||
|
(profile.reason == null ? "" : profile.reason);
|
||||||
|
int lastNewLinechild = _child.LastIndexOf('\n');
|
||||||
|
if (lastNewLinechild != -1)
|
||||||
|
{
|
||||||
|
_child = _child.Remove(lastNewLinechild, 1);
|
||||||
|
}
|
||||||
return new ProfileRetireJsonRequest
|
return new ProfileRetireJsonRequest
|
||||||
{
|
{
|
||||||
order = (index + 1).ToString().ToThaiNumber(),
|
order = $"{ (index + 1).ToString().ToThaiNumber() }. ลำดับที่ { (profile.order).ToString().ToThaiNumber() }",
|
||||||
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
||||||
root = (isDuplicateRoot ? "" : profile.root + "\n") +
|
root = "",
|
||||||
(isDuplicatePosType ? "" : profile.posTypeName + "\n") +
|
child = _child,
|
||||||
(isDuplicatePosLevel ? "" : profile.posLevelName),
|
|
||||||
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
|
||||||
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
|
||||||
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
|
||||||
(profile.child2 == null ? "" : profile.child2 + "\n") +
|
|
||||||
(profile.child1 == null ? "" : profile.child1),
|
|
||||||
position = profile.position != "" && profile.position != null ? profile.position : "-",
|
position = profile.position != "" && profile.position != null ? profile.position : "-",
|
||||||
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
|
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
|
||||||
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
|
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
|
||||||
|
|
@ -258,34 +273,65 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
// }
|
// }
|
||||||
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
||||||
string previousRoot = null;
|
string previousRoot = null;
|
||||||
|
string previousChild1 = null;
|
||||||
string previousPosTypeName = null;
|
string previousPosTypeName = null;
|
||||||
string previousPosLevelName = null;
|
string previousPosLevelName = null;
|
||||||
if (profile_retire.Count > 0)
|
if (profile_retire.Count > 0)
|
||||||
{
|
{
|
||||||
mapProfiles = profile_retire
|
if (retire.TypeReport == null)
|
||||||
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
{
|
||||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
profile_retire = profile_retire.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
||||||
.Select((profile, index) =>
|
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
||||||
|
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
||||||
|
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
|
||||||
|
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||||
|
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")).ToList();
|
||||||
|
}
|
||||||
|
mapProfiles = profile_retire.Select((profile, index) =>
|
||||||
{
|
{
|
||||||
bool isDuplicateRoot = profile.root == previousRoot;
|
bool isDuplicateRoot = profile.root == previousRoot;
|
||||||
previousRoot = profile.root;
|
previousRoot = profile.root;
|
||||||
|
if (isDuplicateRoot == false)
|
||||||
|
{
|
||||||
|
previousChild1 = null;
|
||||||
|
previousPosTypeName = null;
|
||||||
|
previousPosLevelName = null;
|
||||||
|
}
|
||||||
|
bool isDuplicateHospital = profile.child1 == previousChild1;
|
||||||
|
previousChild1 = profile.child1;
|
||||||
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
||||||
previousPosTypeName = profile.posTypeName;
|
previousPosTypeName = profile.posTypeName;
|
||||||
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
||||||
previousPosLevelName = profile.posLevelName;
|
previousPosLevelName = profile.posLevelName;
|
||||||
|
var _root = (isDuplicateRoot ? "" : profile.root + "\n") +
|
||||||
|
(isDuplicateHospital || !hospital.ToObject<List<string>>().Contains(profile.child1)
|
||||||
|
? ""
|
||||||
|
: profile.child1 + "\n") +
|
||||||
|
(isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") +
|
||||||
|
(isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}");
|
||||||
|
int lastNewLineroot = _root.LastIndexOf('\n');
|
||||||
|
if (lastNewLineroot != -1)
|
||||||
|
{
|
||||||
|
_root = _root.Remove(lastNewLineroot, 1);
|
||||||
|
}
|
||||||
|
var _child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
||||||
|
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
||||||
|
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
||||||
|
(profile.child2 == null ? "" : profile.child2 + "\n") +
|
||||||
|
(profile.child1 == null || hospital.ToObject<List<string>>().Contains(profile.child1) ? "" : profile.child1 + "\n") +
|
||||||
|
(profile.reason == null ? "" : profile.reason);
|
||||||
|
int lastNewLinechild = _child.LastIndexOf('\n');
|
||||||
|
if (lastNewLinechild != -1)
|
||||||
|
{
|
||||||
|
_child = _child.Remove(lastNewLinechild, 1);
|
||||||
|
}
|
||||||
return new ProfileRetireJsonRequest
|
return new ProfileRetireJsonRequest
|
||||||
{
|
{
|
||||||
order = (index + 1).ToString().ToThaiNumber(),
|
order = (index + 1).ToString().ToThaiNumber(),
|
||||||
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
||||||
root = (isDuplicateRoot ? "" : profile.root + "\n") +
|
root = _root,
|
||||||
(isDuplicatePosType ? "" : profile.posTypeName + "\n") +
|
child = _child,
|
||||||
(isDuplicatePosLevel ? "" : profile.posLevelName),
|
|
||||||
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
|
||||||
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
|
||||||
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
|
||||||
(profile.child2 == null ? "" : profile.child2 + "\n") +
|
|
||||||
(profile.child1 == null ? "" : profile.child1),
|
|
||||||
position = profile.position != "" && profile.position != null ? profile.position : "-",
|
position = profile.position != "" && profile.position != null ? profile.position : "-",
|
||||||
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
|
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
|
||||||
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
|
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
|
||||||
|
|
|
||||||
|
|
@ -408,8 +408,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var retires = new List<dynamic>();
|
||||||
|
var _apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||||
|
dynamic rootOrder = new List<string>();
|
||||||
|
dynamic posTypeNameOrder = new List<string>();
|
||||||
|
dynamic posLevelNameOrder = new List<string>();
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
|
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||||
|
var _res = await client.SendAsync(_req);
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||||
|
|
||||||
|
if (org != null && org.result != null)
|
||||||
|
{
|
||||||
|
rootOrder = org.result.root;
|
||||||
|
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||||
|
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
var order = 1;
|
var order = 1;
|
||||||
foreach (var profile in profiles)
|
foreach (var profile in profiles.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
|
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||||
|
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
|
||||||
{
|
{
|
||||||
var data = new RetirementProfile
|
var data = new RetirementProfile
|
||||||
{
|
{
|
||||||
|
|
@ -510,49 +534,78 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
return Error(GlobalMessages.RetirementNotCreated);
|
return Error(GlobalMessages.RetirementNotCreated);
|
||||||
if (req.Option == null)
|
if (req.Option == null)
|
||||||
req.Option = "EDIT";
|
req.Option = "EDIT";
|
||||||
|
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||||
|
dynamic rootOrder = new List<string>();
|
||||||
|
dynamic posTypeNameOrder = new List<string>();
|
||||||
|
dynamic posLevelNameOrder = new List<string>();
|
||||||
|
if(retire.TypeReport == null)
|
||||||
|
{
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization =
|
||||||
|
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
|
var _res = await client.SendAsync(_req);
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||||
|
|
||||||
|
if (org != null && org.result != null)
|
||||||
|
{
|
||||||
|
rootOrder = org.result.root;
|
||||||
|
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||||
|
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
var profile_old = await _context.RetirementProfiles
|
var profile_old = await _context.RetirementProfiles
|
||||||
.Where(x => x.RetirementPeriod == retire)
|
.Where(x => x.RetirementPeriod == retire)
|
||||||
.Select(x => new
|
|
||||||
{
|
|
||||||
order = x.Order,
|
|
||||||
id = x.Id,
|
|
||||||
reason = x.Reason,
|
|
||||||
remove = x.Remove,
|
|
||||||
profileId = x.profileId,
|
|
||||||
prefix = x.prefix,
|
|
||||||
firstName = x.firstName,
|
|
||||||
lastName = x.lastName,
|
|
||||||
citizenId = x.citizenId,
|
|
||||||
root = x.root,
|
|
||||||
rootId = x.rootId,
|
|
||||||
rootShortName = x.rootShortName,
|
|
||||||
child1 = x.child1,
|
|
||||||
child1Id = x.child1Id,
|
|
||||||
child1ShortName = x.child1ShortName,
|
|
||||||
child2 = x.child2,
|
|
||||||
child2Id = x.child2Id,
|
|
||||||
child2ShortName = x.child2ShortName,
|
|
||||||
child3 = x.child3,
|
|
||||||
child3Id = x.child3Id,
|
|
||||||
child3ShortName = x.child3ShortName,
|
|
||||||
child4 = x.child4,
|
|
||||||
child4Id = x.child4Id,
|
|
||||||
child4ShortName = x.child4ShortName,
|
|
||||||
posMasterNo = x.posMasterNo,
|
|
||||||
position = x.position,
|
|
||||||
posTypeId = x.posTypeId,
|
|
||||||
posTypeName = x.posTypeName,
|
|
||||||
posTypeRank = x.posTypeRank,
|
|
||||||
posLevelId = x.posLevelId,
|
|
||||||
posLevelName = x.posLevelName,
|
|
||||||
posLevelRank = x.posLevelRank,
|
|
||||||
posExecutiveId = x.posExecutiveId,
|
|
||||||
posExecutiveName = x.posExecutiveName,
|
|
||||||
posNo = x.posNo,
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var _profile_old = profile_old
|
||||||
|
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
|
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||||
|
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
||||||
|
.Select((x,index) => new
|
||||||
|
{
|
||||||
|
order = retire.TypeReport == null ? index + 1 : x.Order,
|
||||||
|
id = x.Id,
|
||||||
|
reason = x.Reason,
|
||||||
|
remove = x.Remove,
|
||||||
|
profileId = x.profileId,
|
||||||
|
prefix = x.prefix,
|
||||||
|
firstName = x.firstName,
|
||||||
|
lastName = x.lastName,
|
||||||
|
citizenId = x.citizenId,
|
||||||
|
root = x.root,
|
||||||
|
rootId = x.rootId,
|
||||||
|
rootShortName = x.rootShortName,
|
||||||
|
child1 = x.child1,
|
||||||
|
child1Id = x.child1Id,
|
||||||
|
child1ShortName = x.child1ShortName,
|
||||||
|
child2 = x.child2,
|
||||||
|
child2Id = x.child2Id,
|
||||||
|
child2ShortName = x.child2ShortName,
|
||||||
|
child3 = x.child3,
|
||||||
|
child3Id = x.child3Id,
|
||||||
|
child3ShortName = x.child3ShortName,
|
||||||
|
child4 = x.child4,
|
||||||
|
child4Id = x.child4Id,
|
||||||
|
child4ShortName = x.child4ShortName,
|
||||||
|
posMasterNo = x.posMasterNo,
|
||||||
|
position = x.position,
|
||||||
|
posTypeId = x.posTypeId,
|
||||||
|
posTypeName = x.posTypeName,
|
||||||
|
posTypeRank = x.posTypeRank,
|
||||||
|
posLevelId = x.posLevelId,
|
||||||
|
posLevelName = x.posLevelName,
|
||||||
|
posLevelRank = x.posLevelRank,
|
||||||
|
posExecutiveId = x.posExecutiveId,
|
||||||
|
posExecutiveName = x.posExecutiveName,
|
||||||
|
posNo = x.posNo,
|
||||||
|
});
|
||||||
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
|
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
|
||||||
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
|
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(_profile_old);
|
||||||
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
|
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
|
||||||
var history = new RetirementPeriodHistory
|
var history = new RetirementPeriodHistory
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue