From 8d7ca40e00f15884dda1a37f63b01dff5de93ebe Mon Sep 17 00:00:00 2001 From: moss <> Date: Fri, 28 Mar 2025 11:32:53 +0700 Subject: [PATCH] sort report retire --- .../Reports/RetireReportRepository.cs | 57 +++++++------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs index d5f86dda..49b4dceb 100644 --- a/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/RetireReportRepository.cs @@ -174,23 +174,17 @@ namespace BMA.EHR.Application.Repositories.Reports // previousPosTypeName = profile.posTypeName; // bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName; // 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 { order = $"{ (index + 1).ToString().ToThaiNumber() }. ลำดับที่ { (profile.order).ToString().ToThaiNumber() }", fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}", root = "", - child = _child, + 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), position = profile.position != "" && profile.position != null ? profile.position : "-", posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-", reason = profile.reason != "" && profile.reason != null ? profile.reason : "-", @@ -300,38 +294,29 @@ namespace BMA.EHR.Application.Repositories.Reports } bool isDuplicateHospital = profile.child1 == previousChild1; previousChild1 = profile.child1; + if (isDuplicateHospital == false) + { + previousPosTypeName = null; + previousPosLevelName = null; + } bool isDuplicatePosType = profile.posTypeName == previousPosTypeName; previousPosTypeName = profile.posTypeName; bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName; previousPosLevelName = profile.posLevelName; - var _root = (isDuplicateRoot ? "" : profile.root + "\n") + - (isDuplicateHospital || !hospital.ToObject>().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>().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 { order = (index + 1).ToString().ToThaiNumber(), fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}", - root = _root, - child = _child, + root = (isDuplicateRoot ? "" : profile.root + "\n") + + (isDuplicateHospital || !hospital.ToObject>().Contains(profile.child1) ? "" : profile.child1 + "\n") + + (isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") + + (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 || hospital.ToObject>().Contains(profile.child1) ? "" : profile.child1 + "\n") + + (profile.reason == null ? "" : profile.reason), position = profile.position != "" && profile.position != null ? profile.position : "-", posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-", reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",