DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
08f9a85007
  1. 58
      src/Shentun.Peis.Application.Contracts/ImportLisResults/ImportResultByLisRequestNoInputDto.cs
  2. 202
      src/Shentun.Peis.Application/BeiJingMZAKExportDatas/BeiJingMZAKExportDataAppService.cs
  3. 56
      src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs
  4. 30
      src/Shentun.Peis.Domain/ColumnReferenceCodes/ColumnReferenceCodeManager.cs
  5. 2
      src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs
  6. 14999
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240623084107_init20240623001.Designer.cs
  7. 39
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20240623084107_init20240623001.cs
  8. 4
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

58
src/Shentun.Peis.Application.Contracts/ImportLisResults/ImportResultByLisRequestNoInputDto.cs

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.ImportLisResults
{
public class ImportResultByLisRequestNoInputDto
{
public string LisRequestNo { get; set; }
/// <summary>
/// 项目编号
/// </summary>
public string ItemId { get; set; }
/// <summary>
/// 项目名称
/// </summary>
public string ItemName { get; set; }
/// <summary>
/// 结果
/// </summary>
public string? Result { get; set; }
/// <summary>
/// 单位
/// </summary>
public string? Unit { get; set; }
/// <summary>
/// 参考范围
/// </summary>
public string? ReferenceRangeValue { get; set; }
/// <summary>
/// 危急值范围
/// </summary>
public string? CriticalRangeValue { get; set; }
/// <summary>
/// 危急值
/// </summary>
public string? CriticalValue { get; set; }
/// <summary>
/// 检查医生
/// </summary>
public string? CheckDoctorName { get; set; }
/// <summary>
/// 检查日期
/// </summary>
public DateTime? CheckDate { get; set; }
}
}

202
src/Shentun.Peis.Application/BeiJingMZAKExportDatas/BeiJingMZAKExportDataAppService.cs

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Shentun.Peis.ColumnReferences;
using Shentun.Peis.CustomerOrgs;
using Shentun.Peis.DataMigrations;
using Shentun.Peis.Enums;
@ -116,6 +117,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas
private readonly IConfiguration _configuration;
private readonly MyUserAppService _myUserAppService;
private readonly ColumnReferenceAppService _columnReferenceAppService;
public BeiJingMZAKExportDataAppService(
UnitOfWorkManager unitOfWorkManager,
IRepository<DeviceType, Guid> deviceTypeRepository,
@ -167,7 +169,8 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas
IRepository<SumSummaryContent, Guid> sumSummaryContentRepository,
IRepository<SumDiagnosis> sumDiagnosisRepository,
IConfiguration configuration,
MyUserAppService myUserAppService)
MyUserAppService myUserAppService,
ColumnReferenceAppService columnReferenceAppService)
{
_unitOfWorkManager = unitOfWorkManager;
_deviceTypeRepository = deviceTypeRepository;
@ -220,6 +223,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas
_sumDiagnosisRepository = sumDiagnosisRepository;
_configuration = configuration;
_myUserAppService = myUserAppService;
_columnReferenceAppService = columnReferenceAppService;
}
@ -2406,7 +2410,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas
continue;
}
//档案ID
Guid patientId = Guid.Empty;
@ -2981,7 +2985,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas
continue;
}
//档案ID
Guid patientId = Guid.Empty;
@ -3523,169 +3527,43 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas
#endregion
//#region 临时处理
//private int hangPatientRegisterUserCount = 0;
///// <summary>
///// 临时处理人员相关医生数据
///// </summary>
///// <param name="handCount"></param>
///// <param name="isGo"></param>
///// <returns></returns>
//[HttpPost("api/app/BeiJingMZAKExportData/TransferPatientRegisterUserData")]
//public async Task TransferPatientRegisterUserData(int handCount, bool isGo = false)
//{
// //处理 人员表 审核医生 总检医生
// //处理 RegisterCheck 审核医生 检查医生
// //当前导入的ID
// string nextKeyValue = oldDb.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register_user' ");
// var oldPatientRegisterList = await oldDb.Ado.GetDataTableAsync($"select top {handCount} * from patient_register where patient_register_id>'{nextKeyValue}' and patient_register_id<='20160523011706' order by patient_register_id asc");
// if (oldPatientRegisterList.Rows.Count > 0)
// {
// var userList = await _identityUserRepository.GetListAsync();
// foreach (DataRow row in oldPatientRegisterList.Rows)
// {
// hangPatientRegisterUserCount++;
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
// {
// string oldPatientRegisterId = row["patient_register_id"].ToString();
// var isDZPatientRegisterTemp = (await _fieldComparisonRepository.GetListAsync(f => f.TableName == "patient_register"
// && f.OldKeyValue == oldPatientRegisterId));
// var isDZPatientRegister = isDZPatientRegisterTemp.OrderByDescending(o => o.NewKeyValue).FirstOrDefault();
// if (isDZPatientRegister != null)
// {
// Guid newPatientRegisterId = Guid.Parse(isDZPatientRegister.NewKeyValue); //新ID
// var isPatientRegister = await _patientRegisterRepository.FirstOrDefaultAsync(f => f.Id == newPatientRegisterId);
// #region 转换审核医生ID
// Guid? AuditDoctorId = null;
// if (!string.IsNullOrWhiteSpace(row["audit_doctor"].ToString()))
// {
// var userEnt = userList.Where(m => m.Name == row["audit_doctor"].ToString().Trim()).FirstOrDefault();
// if (userEnt != null)
// {
// AuditDoctorId = userEnt.Id;
// }
// }
// #endregion
// #region 转换总检医生ID
// Guid? summaryDoctorId = null;
// if (!string.IsNullOrWhiteSpace(row["summary_doctor"].ToString()))
// {
// var userEnt = userList.Where(m => m.Name == row["summary_doctor"].ToString().Trim()).FirstOrDefault();
// if (userEnt != null)
// {
// summaryDoctorId = userEnt.Id;
// }
// }
// #endregion
// isPatientRegister.AuditDoctorId = AuditDoctorId;
// isPatientRegister.SummaryDoctorId = summaryDoctorId;
// await _patientRegisterRepository.UpdateAsync(isPatientRegister);
// #region 处理registercheck
// var oldRegisterAsbitemList = await oldDb.Ado.GetDataTableAsync($"select * from register_asbitem where patient_register_id='{oldPatientRegisterId}'");
// if (oldRegisterAsbitemList.Rows.Count > 0)
// {
// foreach (DataRow rowAsbitem in oldRegisterAsbitemList.Rows)
// {
// #region 转换审核医生ID
// Guid? auditorUserId = null;
// if (!string.IsNullOrWhiteSpace(rowAsbitem["audit_doctor"].ToString()))
// {
// var userEnt = userList.Where(m => m.Name == rowAsbitem["audit_doctor"].ToString().Trim()).FirstOrDefault();
// if (userEnt != null)
// {
// auditorUserId = userEnt.Id;
// }
// }
// #endregion
// #region 转换检查医生ID
// string checkDoctorId = null;
// if (!string.IsNullOrWhiteSpace(rowAsbitem["check_doctor"].ToString()))
// {
// var userEnt = userList.Where(m => m.Name == rowAsbitem["check_doctor"].ToString().Trim()).FirstOrDefault();
// if (userEnt != null)
// {
// checkDoctorId = userEnt.Id.ToString();
// }
// else
// {
// checkDoctorId = rowAsbitem["check_doctor"].ToString().Trim();
// }
// }
// #endregion
// #region 转换组合项目ID
// Guid newAsbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
// .Where(m => m.TableName == "asbitem" && m.OldKeyValue == rowAsbitem["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue);
// #endregion
// //需要处理的ID
// var newRegisterCheckId = (from registerCheck in await _registerCheckRepository.GetQueryableAsync()
// join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync()
// on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId
// where registerCheck.PatientRegisterId == newPatientRegisterId && registerCheckAsbitem.AsbitemId == newAsbitemId
// select registerCheck.Id).FirstOrDefault();
// var isRegisterCheck = await _registerCheckRepository.FirstOrDefaultAsync(f => f.Id == newRegisterCheckId);
// if (isRegisterCheck != null)
// {
// isRegisterCheck.CheckDoctorId = checkDoctorId;
// isRegisterCheck.AuditorUserId = auditorUserId;
// await _registerCheckRepository.UpdateAsync(isRegisterCheck);
// }
// }
// }
// #endregion
// }
/// <summary>
/// 迁移子项目对照数据
/// </summary>
/// <returns></returns>
public async Task TranferItemColumnReferenceData()
{
var oldColumnReferenceList = await oldDb.Ado.GetDataTableAsync($"select code_value,interface_code_value from column_reference_detail where column_reference_id=004 and interface_code_value!=''");
foreach (DataRow item in oldColumnReferenceList.Rows)
{
var fieldComparisonEnt = await _fieldComparisonRepository.FirstOrDefaultAsync(f => f.TableName == "item" && f.OldKeyValue == item["code_value"].ToString().Trim());
if (fieldComparisonEnt != null)
{
var newItemId = Guid.Parse(fieldComparisonEnt.NewKeyValue);
string oldInterfaceCodeValue = item["interface_code_value"].ToString();
string[] oldInterfaceCodeValues = oldInterfaceCodeValue.Split(',');
var inputDto = new UpdateColumnReferenceInterfaceDto
{
ColumnReferenceId = Guid.Parse("3a125a29-ae4d-1ba8-db69-cffd0c629fc0"),
AppCode = new UpdateColumnReferenceCodeDto { CodeValue = newItemId.ToString() },
InterfaceCodes = oldInterfaceCodeValues.Select(s => new UpdateColumnReferenceInterfaceCodeDto
{
CodeValue = s
}).ToList()
};
await _columnReferenceAppService.UpdateInterfaceCodeValuesAsync(inputDto);
}
}
}
// await oldDb.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{row["patient_register_id"].ToString()}',addtime=getdate(),handlecount+=1 where tablename='patient_register_user' ");
// await uow.CompleteAsync();
// }
// }
// _logger.LogInformation($"临时处理人员相关医生数据{oldPatientRegisterList.Rows.Count}条,当前总数{hangPatientRegisterUserCount}");
// if (isGo)
// await TransferPatientRegisterUserData(handCount, isGo);
// }
// else
// {
// _logger.LogInformation("临时处理人员相关医生数据已处理完");
// }
//}
//#endregion
#region 私有方法

56
src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using NPOI.SS.Formula.Functions;
using NPOI.Util;
using Shentun.Peis.ColumnReferenceCodes;
using Shentun.Peis.DiagnosisFunctions;
using Shentun.Peis.Enums;
using Shentun.Peis.Items;
@ -64,6 +65,7 @@ namespace Shentun.Peis.ImportLisResults
private List<ReferenceRange> _referenceRanges;
private static bool _isRunning = false;
private static readonly object lockObject = new object();
private readonly ColumnReferenceCodeManager _columnReferenceCodeManager;
public ImportLisResultAppService(IRepository<RegisterCheck, Guid> registerCheckRepository,
IRepository<RegisterCheckItem> registerCheckItemRepository,
IRepository<PatientRegister, Guid> patientRegisterRepository,
@ -88,7 +90,8 @@ namespace Shentun.Peis.ImportLisResults
ItemManager itemManager,
UnitManager unitManager,
RegisterCheckAppService registerCheckAppService,
IRepository<ThirdInterface> thirdInterfaceRepository)
IRepository<ThirdInterface> thirdInterfaceRepository,
ColumnReferenceCodeManager columnReferenceCodeManager)
{
_registerCheckRepository = registerCheckRepository;
_userRepository = userRepository;
@ -116,6 +119,7 @@ namespace Shentun.Peis.ImportLisResults
_unitManager = unitManager;
_registerCheckAppService = registerCheckAppService;
_thirdInterfaceRepository = thirdInterfaceRepository;
_columnReferenceCodeManager = columnReferenceCodeManager;
}
/// <summary>
/// 从第三方接口导入结果
@ -420,29 +424,51 @@ namespace Shentun.Peis.ImportLisResults
/// </summary>
/// <returns></returns>
[HttpPost("api/app/ImportLisResult/ImportResultByLisRequestNo")]
public async Task ImportResultByLisRequestNoAsync(LisRequestNoInputDto input)
public async Task ImportResultByLisRequestNoAsync(ImportResultByLisRequestNoInputDto input)
{
if (input == null)
throw new UserFriendlyException("请求参数无效");
var query = (from lisRequest in await _lisRequestRepository.GetQueryableAsync()
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on lisRequest.Id equals registerCheckAsbitem.LisRequestId
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on registerCheckAsbitem.RegisterCheckId equals registerCheck.Id
where lisRequest.LisRequestNo == input.LisRequestNo
select new
{
registerCheck.PatientRegisterId
}).FirstOrDefault();
var thirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(o => o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ImportLisResult);
if(thirdInterface==null)
throw new UserFriendlyException($"未配置检验导入的参数");
if (query == null)
var parmValue = thirdInterface.ParmValue;
var configurationBuilder = new ConfigurationBuilder()
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
var config = configurationBuilder.Build();
Guid execOrganizationUnitId =Guid.Parse(config.GetSection("Interface").GetSection("ExecOrganizationUnitId").Value);
Guid columnReferenId = Guid.Parse(config.GetSection("Interface").GetSection("ColumnReferenId").Value);
string codeValue = await _columnReferenceCodeManager.GetColumnReferenCodeValueAsync(columnReferenId, input.ItemId);
if (string.IsNullOrWhiteSpace(codeValue))
{
throw new UserFriendlyException("检验单号不存在");
throw new UserFriendlyException($"项目编号:{input.ItemId}没有对照");
}
Guid itemId = Guid.Parse(codeValue);
await ImportResultByPatientRegisterIdAsync(new PatientRegisterIdInputDto
List<CreateImportLisResultDto> inputDtoList = new List<CreateImportLisResultDto>();
var inputDto = new CreateImportLisResultDto
{
PatientRegisterId = query.PatientRegisterId
});
CheckDate = input.CheckDate,
CheckDoctorName = input.CheckDoctorName,
CriticalRangeValue = input.CriticalRangeValue,
CriticalValue = input.CriticalValue,
ExecOrganizationUnitId = execOrganizationUnitId,
ItemId = itemId,
ItemName = input.ItemName,
LisRequestNo = input.LisRequestNo,
ReferenceRangeValue = input.ReferenceRangeValue,
ReportPrompt = "",
ResultStatusId = null,
Result = input.Result,
Unit = input.Unit
};
inputDtoList.Add(inputDto);
await ImportResultAsync(inputDtoList);
}
}
}

30
src/Shentun.Peis.Domain/ColumnReferenceCodes/ColumnReferenceCodeManager.cs

@ -32,14 +32,14 @@ namespace Shentun.Peis.ColumnReferenceCodes
)
{
DataHelper.CheckEntityIsNull(entity);
return new ColumnReferenceCode(
GuidGenerator.Create()
)
{
ColumnReferenceId = entity.ColumnReferenceId,
CodeValue = entity.CodeValue,
FilterCodeValue = entity.FilterCodeValue,
ColumnReferenceId = entity.ColumnReferenceId,
CodeValue = entity.CodeValue,
FilterCodeValue = entity.FilterCodeValue,
};
}
@ -51,7 +51,7 @@ namespace Shentun.Peis.ColumnReferenceCodes
{
DataHelper.CheckEntityIsNull(sourceEntity);
DataHelper.CheckEntityIsNull(targetEntity);
targetEntity.CodeValue = sourceEntity.CodeValue;
targetEntity.FilterCodeValue = sourceEntity.FilterCodeValue;
}
@ -63,5 +63,25 @@ namespace Shentun.Peis.ColumnReferenceCodes
await _repository.DeleteAsync(entity);
}
/// <summary>
/// 获取字段对照的本系统相应的值
/// </summary>
/// <param name="columnReferenceId"></param>
/// <param name="interfaceCodeValue"></param>
/// <returns></returns>
public async Task<string> GetColumnReferenCodeValueAsync(Guid columnReferenceId, string interfaceCodeValue)
{
var codeValue = (from columnReferenceCode in await _repository.GetQueryableAsync()
join columnReferenceInterface in await _columnReferenceInterfaceRepository.GetQueryableAsync()
on columnReferenceCode.Id equals columnReferenceInterface.ColumnReferenceCodeId
where columnReferenceCode.ColumnReferenceId == columnReferenceId && columnReferenceInterface.InterfaceCodeValue == interfaceCodeValue
select columnReferenceCode.CodeValue).FirstOrDefault();
if (!string.IsNullOrWhiteSpace(codeValue))
return codeValue;
else
return "";
}
}
}

2
src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs

@ -93,7 +93,7 @@ namespace Shentun.Peis.Models
/// 姓名
/// </summary>
[Column("patient_name")]
[StringLength(20)]
[StringLength(50)]
public string PatientName { get; set; } = null!;
/// <summary>

14999
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240623084107_init20240623001.Designer.cs
File diff suppressed because it is too large
View File

39
src/Shentun.Peis.EntityFrameworkCore/Migrations/20240623084107_init20240623001.cs

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class init20240623001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "patient_name",
table: "patient_register",
type: "character varying(50)",
maxLength: 50,
nullable: false,
comment: "姓名",
oldClrType: typeof(string),
oldType: "character varying(20)",
oldMaxLength: 20,
oldComment: "姓名");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "patient_name",
table: "patient_register",
type: "character varying(20)",
maxLength: 20,
nullable: false,
comment: "姓名",
oldClrType: typeof(string),
oldType: "character varying(50)",
oldMaxLength: 50,
oldComment: "姓名");
}
}
}

4
src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

@ -7258,8 +7258,8 @@ namespace Shentun.Peis.Migrations
b.Property<string>("PatientName")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("patient_name")
.HasComment("姓名");

Loading…
Cancel
Save