DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
4e989f2930
  1. 64
      src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs
  2. 7
      src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
  3. 79
      src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
  4. 2
      src/Shentun.Peis.EntityFrameworkCore/SumSummaryReports/SumSummaryReportRepository.cs

64
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
}
}
/// <summary>
/// 处理人员体检次数
/// </summary>
/// <returns></returns>
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<CustomerOrgRegister> 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' ");
}
}
}
}
///// <summary>
///// 迁移人员图片数据

7
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

79
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<ResultStatus> _resultStatusRepository;
private readonly ISumSummaryReportRepository _sumSummaryReportRepository;
private readonly CacheService _cacheService;
private readonly IRepository<RegisterCheckSummary, Guid> _registerCheckSummaryRepository;
private readonly IRepository<Asbitem, Guid> _asbitemRepository;
public SumSummaryReportAppService(
IRepository<RegisterCheck, Guid> registerCheckRepository,
IRepository<IdentityUser, Guid> identityUserRepository,
@ -39,8 +44,9 @@ namespace Shentun.Peis.SumSummaryReports
IRepository<RegisterCheckAsbitem, Guid> registerAsbitemRepository,
ISumSummaryReportRepository sumSummaryReportRepository,
IRepository<ResultStatus> resultStatusRepository,
CacheService cacheService
)
CacheService cacheService,
IRepository<RegisterCheckSummary, Guid> registerCheckSummaryRepository,
IRepository<Asbitem, Guid> 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;
}
/// <summary>
@ -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<List<ItemTypeContrastListDto>> GetItemTypeContrastListAsync(Guid PatientId)
{
List<ItemTypeContrastListDto> msg = new List<ItemTypeContrastListDto>();
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<string>(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);

2
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),

Loading…
Cancel
Save