From 04f0075f4062d1e75750eeaeecad9cdd3b4469c1 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Fri, 26 Apr 2024 18:00:12 +0800
Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E6=A3=80=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BaseDataHandleAppService.cs | 64 ++++++++++++++-
.../PatientRegisterAppService.cs | 7 +-
.../SumSummaryReportAppService.cs | 79 ++++++++-----------
.../SumSummaryReportRepository.cs | 2 +-
4 files changed, 103 insertions(+), 49 deletions(-)
diff --git a/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs b/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
index 59b4238..a154095 100644
--- a/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
+++ b/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
@@ -49,7 +49,7 @@ namespace Shentun.Peis.DataMigrations
private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{
- ConnectionString = "Data Source=.;Initial Catalog=mypeis;User ID=sa;Password=123",
+ ConnectionString = "Data Source=.;Initial Catalog=mypeis;User ID=sa;Password=123;",
DbType = SqlSugar.DbType.SqlServer,
IsAutoCloseConnection = true
});
@@ -1951,7 +1951,8 @@ namespace Shentun.Peis.DataMigrations
Guid customerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId;
if (row["org_id"].ToString() != "00000")
{
- var customerOrgRegisterEnt = customerOrgRegisterList.Where(m => m.CustomerOrgId == customerOrgId
+ Guid topCustomerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.TableName == "customer_org" && m.OldKeyValue == row["org_id"].ToString().Substring(0, 5)).FirstOrDefault().NewKeyValue);
+ var customerOrgRegisterEnt = customerOrgRegisterList.Where(m => m.CustomerOrgId == topCustomerOrgId
&& m.MedicalTimes == (short)Convert.ToInt32(row["org_medical_times"].ToString())).FirstOrDefault();
if (customerOrgRegisterEnt != null)
{
@@ -2728,7 +2729,66 @@ namespace Shentun.Peis.DataMigrations
}
}
+ ///
+ /// 处理人员体检次数
+ ///
+ ///
+ public async Task TransferPersonPhohoData(int handcount)
+ {
+ string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register_customer_org_register'");
+
+ var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id)
+ .Where(m => m.CustomerOrgRegisterId == GuidFlag.PersonCustomerOrgRegisterId && m.CustomerOrgId != GuidFlag.PersonCustomerOrgId
+ && string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(handcount).ToList();
+
+ if (patientRegisterList.Any())
+ {
+ List customerOrgRegisterList = await _customerOrgRegisterRepository.GetListAsync();
+
+ foreach (var item in patientRegisterList)
+ {
+
+ using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
+ {
+ #region 转换成老系统PatientRegisterId
+ string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync())
+ .Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.Id.ToString()).FirstOrDefault().OldKeyValue;
+ #endregion
+
+ //老系统数据
+ var oldPatientRegisterEnt = Db.Ado.GetDataTable($"select org_medical_times,org_id from patient_register where patient_register_id='{oldPatientRegisterId}'");
+
+ string oldTopCustomerOrgId = oldPatientRegisterEnt.Rows[0][1].ToString().Substring(0, 5);
+
+ //一级单位ID
+ Guid customerOrgId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
+ .Where(m => m.TableName == "customer_org" && m.OldKeyValue == oldTopCustomerOrgId).FirstOrDefault().NewKeyValue);
+ short orgMedicalTimes = Convert.ToInt16(oldPatientRegisterEnt.Rows[0][0].ToString());
+
+ #region 转换单位体检次数ID 没有增加默认值
+ Guid customerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId;
+
+ var customerOrgRegisterEnt = customerOrgRegisterList.Where(m => m.CustomerOrgId == customerOrgId
+ && m.MedicalTimes == orgMedicalTimes).FirstOrDefault();
+ if (customerOrgRegisterEnt != null)
+ {
+ customerOrgRegisterId = customerOrgRegisterEnt.Id;
+
+ item.CustomerOrgRegisterId = customerOrgRegisterId;
+ await _patientRegisterRepository.UpdateAsync(item);
+ }
+ #endregion
+
+
+
+ await uow.CompleteAsync();
+
+ await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='patient_register_customer_org_register' ");
+ }
+ }
+ }
+ }
/////
///// 迁移人员图片数据
diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
index 77c18e9..7413c32 100644
--- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
+++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
@@ -624,8 +624,13 @@ namespace Shentun.Peis.PatientRegisters
{
throw new UserFriendlyException("未找到人员信息");
}
- ent = patientRegisterList.First();
+ patientRegisterList = patientRegisterList.Where(m => m.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration).ToList();
+ if (patientRegisterList.Count == 0)
+ {
+ throw new UserFriendlyException("该人未正式登记");
+ }
+ ent = patientRegisterList.First();
}
else
diff --git a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
index 22bb7dc..faffa42 100644
--- a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
+++ b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
@@ -3,13 +3,16 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualBasic;
+using NPOI.OpenXmlFormats.Wordprocessing;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Volo.Abp.Account;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
@@ -31,6 +34,8 @@ namespace Shentun.Peis.SumSummaryReports
private readonly IRepository _resultStatusRepository;
private readonly ISumSummaryReportRepository _sumSummaryReportRepository;
private readonly CacheService _cacheService;
+ private readonly IRepository _registerCheckSummaryRepository;
+ private readonly IRepository _asbitemRepository;
public SumSummaryReportAppService(
IRepository registerCheckRepository,
IRepository identityUserRepository,
@@ -39,8 +44,9 @@ namespace Shentun.Peis.SumSummaryReports
IRepository registerAsbitemRepository,
ISumSummaryReportRepository sumSummaryReportRepository,
IRepository resultStatusRepository,
- CacheService cacheService
- )
+ CacheService cacheService,
+ IRepository registerCheckSummaryRepository,
+ IRepository asbitemRepository)
{
this._registerCheckRepository = registerCheckRepository;
this._identityUserRepository = identityUserRepository;
@@ -50,6 +56,8 @@ namespace Shentun.Peis.SumSummaryReports
this._sumSummaryReportRepository = sumSummaryReportRepository;
_cacheService = cacheService;
_resultStatusRepository = resultStatusRepository;
+ _registerCheckSummaryRepository = registerCheckSummaryRepository;
+ _asbitemRepository = asbitemRepository;
}
///
@@ -68,7 +76,7 @@ namespace Shentun.Peis.SumSummaryReports
.Include(x => x.RegisterCheckAsbitems)
.ThenInclude(x => x.Asbitem)
.ThenInclude(x => x.ItemType)
- .ThenInclude(x=>x.MedicalReportType)
+ .ThenInclude(x => x.MedicalReportType)
.Include(x => x.RegisterCheckSummaries)
.Include(x => x.RegisterCheckItems)
.ThenInclude(x => x.Item)
@@ -89,7 +97,7 @@ namespace Shentun.Peis.SumSummaryReports
ItemName = sa.Item.DisplayName,
ItemResult = sa.Result,
ReferenceRangeValue = sa.ReferenceRangeValue,
- ResultStatusName = (resultStatus.Where(o=>o.Id == sa.ResultStatusId).FirstOrDefault() == null)? "": resultStatus.Where(o => o.Id == sa.ResultStatusId).FirstOrDefault().ReportPrompt,
+ ResultStatusName = (resultStatus.Where(o => o.Id == sa.ResultStatusId).FirstOrDefault() == null) ? "" : resultStatus.Where(o => o.Id == sa.ResultStatusId).FirstOrDefault().ReportPrompt,
Unit = sa.Unit
}).ToList(),
Summarys = s.RegisterCheckSummaries.Count > 0 ? s.RegisterCheckSummaries.Select(sb => new DetailedResultsList_Asbitem_Summary
@@ -125,49 +133,29 @@ namespace Shentun.Peis.SumSummaryReports
[HttpGet("api/app/sumsummaryreport/getitemtypecontrastlist")]
public async Task> GetItemTypeContrastListAsync(Guid PatientId)
{
-
-
List msg = new List();
- var userlist = await _identityUserRepository.GetListAsync();
-
- //var entlist = (await _registerCheckRepository.GetDbSetAsync())
- // .Include(x => x.RegisterAsbitem.PatientRegister)
- // .Include(x => x.RegisterAsbitem.Asbitem.ItemType)
- // .Include(x => x.RegisterCheckSummaries)
- // .Include(x => x.RegisterCheckItems)
- // .ThenInclude(x => x.Item)
- // .Where(m => m.RegisterAsbitem.PatientRegister.PatientId == PatientId)
- // .ToList();
-
- var entlist = (await _registerCheckRepository.GetDbSetAsync())
- .Include(x => x.RegisterCheckAsbitems)
- .ThenInclude(x => x.Asbitem)
- .ThenInclude(x => x.ItemType)
- .Include(x => x.RegisterCheckAsbitems)
- .ThenInclude(x => x.PatientRegister)
- .Include(x => x.RegisterCheckSummaries)
- .Include(x => x.RegisterCheckItems)
- .ThenInclude(x => x.Item)
- .Where(m => m.RegisterCheckAsbitems.First().PatientRegister.PatientId == PatientId)
- .ToList();
-
- ////查询所有项目类别
- //var ItemTypeNames = new HashSet(entlist.Select(s => s.RegisterAsbitem.Asbitem.ItemType.DisplayName).ToList()).ToList();
-
- //以registercheck表为主
- var registercheckList = entlist.Select(s => new ItemTypeContrastList_Result
- {
- ItemTypeName = string.Join("|", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.ItemType.DisplayName).ToList()),
- RegisterDate = DataHelper.ConversionDateToString(s.RegisterCheckAsbitems.First().PatientRegister.CreationTime),
- PatientRegisterId = s.RegisterCheckAsbitems.First().PatientRegisterId,
- Summarys = string.Join("|", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()) + ":" + string.Join(",", s.RegisterCheckSummaries.Select(sb => sb.Summary).ToList())
- }).ToList();
+ var query = from a in await _patientRegisterRepository.GetQueryableAsync()
+ join b in await _registerCheckRepository.GetQueryableAsync() on a.Id equals b.PatientRegisterId
+ join c in await _registerAsbitemRepository.GetQueryableAsync() on b.Id equals c.RegisterCheckId
+ join d in await _asbitemRepository.GetQueryableAsync() on c.AsbitemId equals d.Id into dd
+ from ad in dd.DefaultIfEmpty()
+ join e in await _itemTypeRepository.GetQueryableAsync() on ad.ItemTypeId equals e.Id
+ join f in await _registerCheckSummaryRepository.GetQueryableAsync() on b.Id equals f.RegisterCheckId into ff
+ from af in ff.DefaultIfEmpty()
+ where a.PatientId == PatientId && a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration
+ select new
+ {
+ RegisterDate = a.CreationTime,
+ PatientRegisterId = a.Id,
+ ItemTypeName = e.DisplayName,
+ Summary = af != null ? af.Summary : ""
+ };
- var grouplist = registercheckList.GroupBy(g => new { g.PatientRegisterId, g.ItemTypeName });
+ var grouplist = query.ToList().GroupBy(g => new { g.PatientRegisterId, g.ItemTypeName });
foreach (var g in grouplist)
{
@@ -176,8 +164,8 @@ namespace Shentun.Peis.SumSummaryReports
{
ItemTypeName = glist.FirstOrDefault().ItemTypeName,
- RegisterDate = glist.FirstOrDefault().RegisterDate,
- Summarys = string.Join("\n", glist.Select(s => s.Summarys).ToList())
+ RegisterDate = DataHelper.ConversionDateToString(glist.FirstOrDefault().RegisterDate),
+ Summarys = string.Join("\n", glist.Select(s => s.Summary).ToList())
};
msg.Add(resultlist);
}
@@ -205,7 +193,8 @@ namespace Shentun.Peis.SumSummaryReports
.ThenInclude(x => x.SumSummaryContents)
.Include(x => x.SumSuggestionHeaders)
.ThenInclude(x => x.SumSuggestionContents)
- .Where(m => m.PatientId == PatientId && (m.SumSummaryHeaders.Count > 0 || m.SumSuggestionHeaders.Count > 0))
+ .Where(m => m.PatientId == PatientId && (m.SumSummaryHeaders.Count > 0 || m.SumSuggestionHeaders.Count > 0)
+ && m.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration)
.ToList();
@@ -240,7 +229,7 @@ namespace Shentun.Peis.SumSummaryReports
.Include(x => x.Asbitem)
.Include(x => x.RegisterCheck)
.Include(x => x.PatientRegister)
- .Where(m => m.PatientRegister.PatientId == PatientId)
+ .Where(m => m.PatientRegister.PatientId == PatientId && m.PatientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration)
.ToList();
var grouplist = entlist.GroupBy(o => o.AsbitemId);
diff --git a/src/Shentun.Peis.EntityFrameworkCore/SumSummaryReports/SumSummaryReportRepository.cs b/src/Shentun.Peis.EntityFrameworkCore/SumSummaryReports/SumSummaryReportRepository.cs
index 91a7598..9b767a7 100644
--- a/src/Shentun.Peis.EntityFrameworkCore/SumSummaryReports/SumSummaryReportRepository.cs
+++ b/src/Shentun.Peis.EntityFrameworkCore/SumSummaryReports/SumSummaryReportRepository.cs
@@ -43,7 +43,7 @@ namespace Shentun.Peis.SumSummaryReports
join e in dbContext.RegisterChecks.DefaultIfEmpty() on a.RegisterCheckId equals e.Id
join f in dbContext.RegisterCheckAsbitems.DefaultIfEmpty() on e.Id equals f.RegisterCheckId
join g in dbContext.PatientRegisters.DefaultIfEmpty() on f.PatientRegisterId equals g.Id
- where (g.PatientId == PatientId && f.AsbitemId == AsbitemId)
+ where (g.PatientId == PatientId && f.AsbitemId == AsbitemId && g.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration)
select new HorizontalComparisonListEntity
{
CheckDate = DataHelper.ConversionDateToString(g.CreationTime),