You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3861 lines
182 KiB
3861 lines
182 KiB
using log4net.Plugin;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Query;
|
|
using Microsoft.Extensions.DependencyModel;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using NPOI.DDF;
|
|
using NPOI.SS.Formula.Functions;
|
|
using NUglify.Helpers;
|
|
using Shentun.Peis.CustomerOrgs;
|
|
using Shentun.Peis.Enums;
|
|
using Shentun.Peis.ItemTypes;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.MyUser;
|
|
using Shentun.Peis.RegisterCheckItems;
|
|
using Shentun.Peis.Sexs;
|
|
using Shentun.Utilities;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Runtime.Loader;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Uow;
|
|
using Volo.Abp.Users;
|
|
using Xceed.Document.NET;
|
|
|
|
namespace Shentun.Peis.DataMigrations
|
|
{
|
|
/// <summary>
|
|
/// 基础数据处理
|
|
/// </summary>
|
|
//[Authorize]
|
|
//[RemoteService(false)]
|
|
public class BaseDataHandleAppService : ApplicationService
|
|
{
|
|
|
|
private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = "server=.;uid=sa;pwd=123;database=mypeis;Encrypt=false;",
|
|
DbType = SqlSugar.DbType.SqlServer,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
|
|
//private readonly SqlSugarClient PgDb = new SqlSugarClient(new ConnectionConfig()
|
|
//{
|
|
// ConnectionString = "Host=140.143.162.39;Port=5432;Database=ShentunPeis070703;User ID=postgres;Password=shentun123;",
|
|
// DbType = SqlSugar.DbType.PostgreSQL,
|
|
// IsAutoCloseConnection = true
|
|
//});
|
|
|
|
//修改时间用
|
|
private readonly SqlSugarClient PgNWDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = "Host=10.1.12.140;Port=5432;Database=ShentunPeis0508;User ID=postgres;Password=st123;",
|
|
DbType = SqlSugar.DbType.PostgreSQL,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
|
|
|
|
|
|
|
|
//默认指引类别ID
|
|
private readonly char defaultGuidTypeId = '0';
|
|
//默认体检报告类别ID
|
|
private readonly char defaultMedicalReportTypeId = '0';
|
|
//默认体检中心
|
|
private readonly Guid defaultMedicalCenterId = Guid.Parse("0de5b78a-731d-4f80-b262-655ebbf04581");
|
|
//默认体检结论类别
|
|
private readonly string defaultMedicalConclusionType = "01";
|
|
//默认容器ID
|
|
private readonly Guid defaultSampleContainerId = Guid.Parse("3a126a07-eb42-a369-99e4-114a2629d714");
|
|
//默认单位性质ID
|
|
private readonly Guid defaultOrgTypeId = Guid.Parse("3a126a08-9607-fe40-e5da-6daa01712468");
|
|
|
|
private readonly IRepository<DeviceType, Guid> _deviceTypeRepository;
|
|
private readonly IRepository<ItemType, Guid> _itemTypeRepository;
|
|
private readonly ItemTypeManager _itemTypeManager;
|
|
private readonly IRepository<Unit, Guid> _unitRepository;
|
|
private readonly IRepository<MedicalType, Guid> _medicalTypeRepository;
|
|
private readonly IRepository<PersonnelType, Guid> _personnelTypeRepository;
|
|
private readonly IRepository<InvoiceItemType, Guid> _invoiceItemTypeRepository;
|
|
private readonly IRepository<FieldComparison, Guid> _fieldComparisonRepository;
|
|
private readonly IRepository<SampleType, Guid> _sampleTypeRepository;
|
|
private readonly IRepository<Item, Guid> _itemRepository;
|
|
private readonly IRepository<ReferenceRange, Guid> _referenceRangeRepository;
|
|
private readonly IRepository<Asbitem, Guid> _asbitemRepository;
|
|
private readonly IRepository<AsbitemDetail> _asbitemDetailRepository;
|
|
private readonly IRepository<MedicalPackage, Guid> _medicalPackageRepository;
|
|
private readonly IRepository<MedicalPackageDetail> _medicalPackageDetailRepository;
|
|
private readonly IRepository<Diagnosis, Guid> _diagnosisRepository;
|
|
private readonly IRepository<Suggestion, Guid> _suggestionRepository;
|
|
private readonly IRepository<ItemResultTemplate, Guid> _itemResultTemplateRepository;
|
|
private readonly IRepository<ItemResultMatch, Guid> _ItemResultMatchRepository;
|
|
private readonly MyUserAppService _myUserAppService;
|
|
private readonly IRepository<MenuInfo, Guid> _menuInfoRepository;
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
|
|
private readonly CustomerOrgManager _customerOrgManager;
|
|
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
|
|
private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository;
|
|
private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository;
|
|
private readonly IRepository<Patient, Guid> _patientRepository;
|
|
private readonly IRepository<Nation> _nationRepository;
|
|
private readonly ILogger<BaseDataHandleAppService> _logger;
|
|
private readonly IRepository<IdentityUser, Guid> _identityUserRepository;
|
|
private readonly IRepository<MedicalConclusion, Guid> _medicalConclusionRepository;
|
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
|
|
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
|
|
private readonly IRepository<RegisterCheckAsbitem, Guid> _registerCheckAsbitemRepository;
|
|
private readonly IRepository<RegisterCheckItem> _registerCheckItemRepository;
|
|
private readonly RegisterCheckItemManager _registerCheckItemManager;
|
|
private readonly UnitOfWorkManager _unitOfWorkManager;
|
|
private readonly IRepository<RegisterCheckSummary, Guid> _registerCheckSummaryRepository;
|
|
private readonly IRepository<SumSummaryHeader, Guid> _sumSummaryHeaderRepository;
|
|
private readonly IRepository<SumSummaryContent, Guid> _sumSummaryContentRepository;
|
|
private readonly IRepository<SumSuggestionHeader, Guid> _sumSuggestionHeaderRepository;
|
|
private readonly IRepository<SumSuggestionContent, Guid> _sumSuggestionContentRepository;
|
|
private readonly IRepository<SumDiagnosis> _sumDiagnosisRepository;
|
|
private readonly IRepository<Report, string> _reportRepository;
|
|
private readonly IRepository<ReportFormat, string> _reportFormatRepository;
|
|
private readonly IRepository<ReportFormatTemplate, string> _reportFormatTemplateRepository;
|
|
private readonly IRepository<SampleGroup, Guid> _sampleGroupRepository;
|
|
private readonly IRepository<SampleGroupDetail> _sampleGroupDetailRepository;
|
|
private readonly IRepository<SysParmType> _sysParmTypeRepository;
|
|
private readonly IRepository<SysParm> _sysParmRepository;
|
|
private readonly IRepository<SysParmValue> _sysParmValueRepository;
|
|
private readonly IRepository<CollectItemType, Guid> _collectItemTypeRepository;
|
|
private readonly IRepository<PatientRegisterExter> _patientRegisterExterRepository;
|
|
private readonly IRepository<AsbitemGuide> _asbitemGuideRepository;
|
|
|
|
private Dictionary<string, string> veryPatientNo = new Dictionary<string, string>();
|
|
|
|
public BaseDataHandleAppService(
|
|
IRepository<DeviceType, Guid> deviceTypeRepository,
|
|
IRepository<ItemType, Guid> itemTypeRepository,
|
|
ItemTypeManager itemTypeManager,
|
|
IRepository<Unit, Guid> unitRepository,
|
|
IRepository<MedicalType, Guid> medicalTypeRepository,
|
|
IRepository<PersonnelType, Guid> personnelTypeRepository,
|
|
IRepository<InvoiceItemType, Guid> invoiceItemTypeRepository,
|
|
IRepository<FieldComparison, Guid> fieldComparisonRepository,
|
|
IRepository<SampleType, Guid> sampleTypeRepository,
|
|
IRepository<Item, Guid> itemRepository,
|
|
IRepository<ReferenceRange, Guid> referenceRangeRepository,
|
|
IRepository<Asbitem, Guid> asbitemRepository,
|
|
IRepository<AsbitemDetail> asbitemDetailRepository,
|
|
IRepository<MedicalPackage, Guid> medicalPackageRepository,
|
|
IRepository<MedicalPackageDetail> medicalPackageDetailRepository,
|
|
IRepository<ItemResultTemplate, Guid> itemResultTemplateRepository,
|
|
IRepository<ItemResultMatch, Guid> itemResultMatchRepository,
|
|
IRepository<Diagnosis, Guid> diagnosisRepository,
|
|
IRepository<Suggestion, Guid> suggestionRepository,
|
|
MyUserAppService myUserAppService,
|
|
IRepository<MenuInfo, Guid> menuInfoRepository,
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository,
|
|
CustomerOrgManager customerOrgManager,
|
|
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository,
|
|
IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository,
|
|
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository,
|
|
IRepository<Nation> nationRepository,
|
|
IRepository<Patient, Guid> patientRepository,
|
|
ILogger<BaseDataHandleAppService> logger,
|
|
IRepository<IdentityUser, Guid> identityUserRepository,
|
|
IRepository<MedicalConclusion, Guid> medicalConclusionRepository,
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository,
|
|
IRepository<RegisterCheck, Guid> registerCheckRepository,
|
|
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemRepository,
|
|
IRepository<RegisterCheckItem> registerCheckItemRepository,
|
|
RegisterCheckItemManager registerCheckItemManager,
|
|
UnitOfWorkManager unitOfWorkManager,
|
|
IRepository<RegisterCheckSummary, Guid> registerCheckSummaryRepository,
|
|
IRepository<SumSummaryHeader, Guid> sumSummaryHeaderRepository,
|
|
IRepository<SumSummaryContent, Guid> sumSummaryContentRepository,
|
|
IRepository<SumSuggestionHeader, Guid> sumSuggestionHeaderRepository,
|
|
IRepository<SumSuggestionContent, Guid> sumSuggestionContentRepository,
|
|
IRepository<SumDiagnosis> sumDiagnosisRepository,
|
|
IRepository<Report, string> reportRepository,
|
|
IRepository<ReportFormat, string> reportFormatRepository,
|
|
IRepository<ReportFormatTemplate, string> reportFormatTemplateRepository,
|
|
IRepository<SampleGroup, Guid> sampleGroupRepository,
|
|
IRepository<SampleGroupDetail> sampleGroupDetailRepository,
|
|
IRepository<SysParmType> sysParmTypeRepository,
|
|
IRepository<SysParm> sysParmRepository,
|
|
IRepository<SysParmValue> sysParmValueRepository,
|
|
IRepository<CollectItemType, Guid> collectItemTypeRepository,
|
|
IRepository<PatientRegisterExter> patientRegisterExterRepository,
|
|
IRepository<AsbitemGuide> asbitemGuideRepository)
|
|
{
|
|
_deviceTypeRepository = deviceTypeRepository;
|
|
_itemTypeRepository = itemTypeRepository;
|
|
_itemTypeManager = itemTypeManager;
|
|
_unitRepository = unitRepository;
|
|
_medicalTypeRepository = medicalTypeRepository;
|
|
_personnelTypeRepository = personnelTypeRepository;
|
|
_invoiceItemTypeRepository = invoiceItemTypeRepository;
|
|
_fieldComparisonRepository = fieldComparisonRepository;
|
|
_sampleTypeRepository = sampleTypeRepository;
|
|
_itemRepository = itemRepository;
|
|
_referenceRangeRepository = referenceRangeRepository;
|
|
_asbitemRepository = asbitemRepository;
|
|
_asbitemDetailRepository = asbitemDetailRepository;
|
|
_medicalPackageRepository = medicalPackageRepository;
|
|
_medicalPackageDetailRepository = medicalPackageDetailRepository;
|
|
_itemResultTemplateRepository = itemResultTemplateRepository;
|
|
_ItemResultMatchRepository = itemResultMatchRepository;
|
|
_diagnosisRepository = diagnosisRepository;
|
|
_suggestionRepository = suggestionRepository;
|
|
_myUserAppService = myUserAppService;
|
|
_menuInfoRepository = menuInfoRepository;
|
|
_customerOrgRepository = customerOrgRepository;
|
|
_customerOrgManager = customerOrgManager;
|
|
_customerOrgRegisterRepository = customerOrgRegisterRepository;
|
|
_customerOrgGroupRepository = customerOrgGroupRepository;
|
|
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
|
|
_nationRepository = nationRepository;
|
|
_patientRepository = patientRepository;
|
|
_logger = logger;
|
|
_identityUserRepository = identityUserRepository;
|
|
_medicalConclusionRepository = medicalConclusionRepository;
|
|
_patientRegisterRepository = patientRegisterRepository;
|
|
_registerCheckRepository = registerCheckRepository;
|
|
_registerCheckAsbitemRepository = registerCheckAsbitemRepository;
|
|
_registerCheckItemRepository = registerCheckItemRepository;
|
|
_registerCheckItemManager = registerCheckItemManager;
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|
_registerCheckSummaryRepository = registerCheckSummaryRepository;
|
|
_sumSummaryHeaderRepository = sumSummaryHeaderRepository;
|
|
_sumSummaryContentRepository = sumSummaryContentRepository;
|
|
_sumSuggestionHeaderRepository = sumSuggestionHeaderRepository;
|
|
_sumSuggestionContentRepository = sumSuggestionContentRepository;
|
|
_sumDiagnosisRepository = sumDiagnosisRepository;
|
|
_reportRepository = reportRepository;
|
|
_reportFormatRepository = reportFormatRepository;
|
|
_reportFormatTemplateRepository = reportFormatTemplateRepository;
|
|
_sampleGroupRepository = sampleGroupRepository;
|
|
_sampleGroupDetailRepository = sampleGroupDetailRepository;
|
|
_sysParmTypeRepository = sysParmTypeRepository;
|
|
_sysParmRepository = sysParmRepository;
|
|
_sysParmValueRepository = sysParmValueRepository;
|
|
_collectItemTypeRepository = collectItemTypeRepository;
|
|
_patientRegisterExterRepository = patientRegisterExterRepository;
|
|
_asbitemGuideRepository = asbitemGuideRepository;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 手动添加字段对照
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task CreateFieldComparisonAsync(CreateFieldComparisonDto input)
|
|
{
|
|
FieldComparison fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = input.NewKeyValue,
|
|
OldKeyValue = input.OldKeyValue,
|
|
TableName = input.TableName
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 处理基础数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task HandBaseData()
|
|
{
|
|
await TransferDeviceTypeData();
|
|
await TransferUnitData();
|
|
await TransferMedicalTypeData();
|
|
await TransferPersonnelTypeData();
|
|
await TransferInvoiceItemTypeData();
|
|
await TransferCollectItemTypeData();
|
|
await TransferItemTypeData();
|
|
await TransferSampleTypeData();
|
|
await TransferNationData();
|
|
await TransferMedicalConclusionData();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 处理基础项目相关数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task HandBaseItemData()
|
|
{
|
|
await TransferItemData();
|
|
await TransferAsbitemData();
|
|
await TransferAsbitemDetailData();
|
|
await TransferMedicalPackageData();
|
|
await TransferMedicalPackageDetailData();
|
|
await TransferDiagnosisData();
|
|
await TransferSuggestionData();
|
|
await TransferItemResultTemplateData();
|
|
await TransferItemResultMatchData();
|
|
await TransferReferenceRangeData();
|
|
await TransferSampleGroupData();
|
|
await TransferSampleGroupDetailData();
|
|
await TransferTopCustomerOrgData();
|
|
await TransferTwoCustomerOrgData();
|
|
await TransferThreeCustomerOrgData();
|
|
await TransferCustomerOrgRegisterData();
|
|
await TransferCustomerOrgGroupData();
|
|
await TransferCustomerOrgGroupDetailData();
|
|
}
|
|
|
|
#region 基础数据
|
|
|
|
/// <summary>
|
|
/// 迁移仪器类别数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferDeviceTypeData()
|
|
{
|
|
var count = await _deviceTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldDeviceTypeList = await Db.Ado.GetDataTableAsync("select device_type_id,device_type_name from device_type order by display_order asc");
|
|
if (oldDeviceTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldDeviceTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid deviceTypeId = GuidGenerator.Create();
|
|
|
|
var data = new DeviceType(deviceTypeId)
|
|
{
|
|
CheckTypeFlag = '0',
|
|
DisplayName = row["device_type_name"].ToString(),
|
|
DisplayOrder = oldDeviceTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["device_type_name"].ToString())
|
|
};
|
|
|
|
await _deviceTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "device_type",
|
|
FieldName = "id",
|
|
NewKeyValue = deviceTypeId.ToString(),
|
|
OldKeyValue = row["device_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
|
|
_logger.LogInformation($"仪器类别数据处理完毕,处理数量{oldDeviceTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("仪器类别数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移数值单位数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferUnitData()
|
|
{
|
|
var count = await _unitRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldUnitList = await Db.Ado.GetDataTableAsync("select unit_id,unit_name from unit order by display_order asc");
|
|
if (oldUnitList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldUnitList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid unitId = GuidGenerator.Create();
|
|
var data = new Unit(unitId)
|
|
{
|
|
DisplayName = row["unit_name"].ToString(),
|
|
DisplayOrder = oldUnitList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["unit_name"].ToString())
|
|
};
|
|
|
|
await _unitRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "unit",
|
|
FieldName = "id",
|
|
NewKeyValue = unitId.ToString(),
|
|
OldKeyValue = row["unit_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
_logger.LogInformation($"数值单位数据处理完毕,处理数量{oldUnitList.Rows.Count}");
|
|
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"数值单位数据已存在,未处理");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移体检类别数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferMedicalTypeData()
|
|
{
|
|
var count = await _medicalTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldMedicalTypeList = await Db.Ado.GetDataTableAsync("select medical_type_id,medical_type_name from medical_type order by display_order asc");
|
|
if (oldMedicalTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldMedicalTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid medicalTypeId = GuidGenerator.Create();
|
|
var data = new MedicalType(medicalTypeId)
|
|
{
|
|
DisplayName = row["medical_type_name"].ToString(),
|
|
DisplayOrder = oldMedicalTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["medical_type_name"].ToString())
|
|
};
|
|
|
|
await _medicalTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "medical_type",
|
|
FieldName = "id",
|
|
NewKeyValue = medicalTypeId.ToString(),
|
|
OldKeyValue = row["medical_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
_logger.LogInformation($"体检类别数据处理完毕,处理数量{oldMedicalTypeList.Rows.Count}");
|
|
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"体检类别数据已存在,未处理");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移人员类别数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferPersonnelTypeData()
|
|
{
|
|
var count = await _personnelTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldPersonnelTypeList = await Db.Ado.GetDataTableAsync("select personnel_type_id,personnel_type_name from personnel_type order by display_order asc");
|
|
if (oldPersonnelTypeList.Rows.Count > 0)
|
|
{
|
|
|
|
|
|
foreach (DataRow row in oldPersonnelTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid personnelTypeId = GuidGenerator.Create();
|
|
|
|
var data = new PersonnelType(personnelTypeId)
|
|
{
|
|
DisplayName = row["personnel_type_name"].ToString(),
|
|
DisplayOrder = oldPersonnelTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["personnel_type_name"].ToString())
|
|
};
|
|
|
|
await _personnelTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "personnel_type",
|
|
FieldName = "id",
|
|
NewKeyValue = personnelTypeId.ToString(),
|
|
OldKeyValue = row["personnel_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"人员类别数据处理完毕,处理数量{oldPersonnelTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"人员类别数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移发票项目类别数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferInvoiceItemTypeData()
|
|
{
|
|
var count = await _invoiceItemTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldInvoiceItemTypeList = await Db.Ado.GetDataTableAsync("select invoice_item_type_id,invoice_item_type_name from invoice_item_type order by display_order asc");
|
|
if (oldInvoiceItemTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldInvoiceItemTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid invoiceItemTypeId = GuidGenerator.Create();
|
|
|
|
var data = new InvoiceItemType(invoiceItemTypeId)
|
|
{
|
|
DisplayName = row["invoice_item_type_name"].ToString(),
|
|
DisplayOrder = oldInvoiceItemTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["invoice_item_type_name"].ToString())
|
|
};
|
|
|
|
await _invoiceItemTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "invoice_item_type",
|
|
FieldName = "id",
|
|
NewKeyValue = invoiceItemTypeId.ToString(),
|
|
OldKeyValue = row["invoice_item_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"发票项目类别数据处理完毕,处理数量{oldInvoiceItemTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"发票项目类别数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移汇总项目类别数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferCollectItemTypeData()
|
|
{
|
|
var count = await _collectItemTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldCollectItemTypeList = await Db.Ado.GetDataTableAsync("select collect_item_type_id,collect_item_type_name,invoice_item_type_id from collect_item_type order by display_order asc");
|
|
if (oldCollectItemTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldCollectItemTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid collectItemTypeId = GuidGenerator.Create();
|
|
|
|
|
|
Guid invoiceItemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "invoice_item_type" && m.OldKeyValue == row["invoice_item_type_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var data = new CollectItemType(collectItemTypeId)
|
|
{
|
|
DisplayName = row["collect_item_type_name"].ToString(),
|
|
DisplayOrder = oldCollectItemTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["collect_item_type_name"].ToString()),
|
|
InvoiceItemTypeId = invoiceItemTypeId
|
|
};
|
|
|
|
await _collectItemTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "collect_item_type",
|
|
FieldName = "id",
|
|
NewKeyValue = collectItemTypeId.ToString(),
|
|
OldKeyValue = row["collect_item_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
_logger.LogInformation($"汇总项目类别数据处理完毕,处理数量{oldCollectItemTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"汇总项目类别数据已存在,未处理");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移项目类别-科室数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferItemTypeData()
|
|
{
|
|
var count = await _itemTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldItemTypeList = await Db.Ado.GetDataTableAsync("select department_id,department_type,department_name,merge_asbitem_flag,print_pacs_barcode_flag from department order by display_order asc");
|
|
if (oldItemTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldItemTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid itemTypeId = GuidGenerator.Create();
|
|
|
|
var data = new ItemType(itemTypeId)
|
|
{
|
|
DisplayName = row["department_name"].ToString(),
|
|
DisplayOrder = oldItemTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["department_name"].ToString()),
|
|
CheckTypeFlag = Convert.ToChar(row["department_type"]),
|
|
GuidTypeId = defaultGuidTypeId,
|
|
IsMergeAsbitem = Convert.ToChar(row["merge_asbitem_flag"]),
|
|
IsWrap = 'N',
|
|
MedicalReportTypeId = defaultMedicalReportTypeId,
|
|
ParentId = null,
|
|
PathCode = _itemTypeManager.CreatePathCode(null).Result,
|
|
IsCheckRequest = Convert.ToChar(row["print_pacs_barcode_flag"])
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "item_type",
|
|
FieldName = "id",
|
|
NewKeyValue = itemTypeId.ToString(),
|
|
OldKeyValue = row["department_id"].ToString()
|
|
};
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"项目类别数据处理完毕,处理数量{oldItemTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"项目类别数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移标本类型数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferSampleTypeData()
|
|
{
|
|
var count = await _sampleTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldSampleTypeList = await Db.Ado.GetDataTableAsync("select specimen_type_id,specimen_type_name from specimen_type order by display_order asc");
|
|
if (oldSampleTypeList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldSampleTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid sampleTypeId = GuidGenerator.Create();
|
|
|
|
var data = new SampleType(sampleTypeId)
|
|
{
|
|
DisplayName = row["specimen_type_name"].ToString(),
|
|
DisplayOrder = oldSampleTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["specimen_type_name"].ToString())
|
|
};
|
|
|
|
await _sampleTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "sample_type",
|
|
FieldName = "id",
|
|
NewKeyValue = sampleTypeId.ToString(),
|
|
OldKeyValue = row["specimen_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
}
|
|
_logger.LogInformation($"标本类型数据处理完毕,处理数量{oldSampleTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"标本类型数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 民族数据对照
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferNationData()
|
|
{
|
|
var newNationList = await _nationRepository.GetListAsync();
|
|
var oldNationList = await Db.Ado.GetDataTableAsync("select * from nation");
|
|
|
|
if (oldNationList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldNationList.Rows)
|
|
{
|
|
string oldName = row["nation_name"].ToString(); //老系统名称
|
|
var newNationEnt = newNationList.Where(m => m.DisplayName.Contains(oldName)).FirstOrDefault();
|
|
if (newNationEnt != null)
|
|
{
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = newNationEnt.Id.ToString(),
|
|
OldKeyValue = row["nation_id"].ToString(),
|
|
TableName = "nation"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
}
|
|
|
|
}
|
|
|
|
_logger.LogInformation($"民族数据处理完毕,处理数量{oldNationList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"民族数据无需处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移体检结论数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferMedicalConclusionData()
|
|
{
|
|
var count = await _medicalConclusionRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldMedicalConclusionList = await Db.Ado.GetDataTableAsync("select medical_conclusion_id,medical_conclusion_name from medical_conclusion order by display_order asc");
|
|
if (oldMedicalConclusionList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldMedicalConclusionList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid medicalConclusionId = GuidGenerator.Create();
|
|
|
|
var data = new MedicalConclusion(medicalConclusionId)
|
|
{
|
|
DisplayName = row["medical_conclusion_name"].ToString(),
|
|
DisplayOrder = oldMedicalConclusionList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["medical_conclusion_name"].ToString()),
|
|
MedicalConclusionTypeId = defaultMedicalConclusionType
|
|
};
|
|
|
|
await _medicalConclusionRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "medical_conclusion",
|
|
FieldName = "id",
|
|
NewKeyValue = medicalConclusionId.ToString(),
|
|
OldKeyValue = row["medical_conclusion_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检结论数据处理完毕,处理数量{oldMedicalConclusionList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检结论数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 基础项目相关数据
|
|
|
|
/// <summary>
|
|
/// 迁移项目数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferItemData()
|
|
{
|
|
var count = await _itemRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldItemList = await Db.Ado.GetDataTableAsync("select a.* from item as a left join department as b on a.department_id=b.department_id order by b.display_order,a.display_order");
|
|
if (oldItemList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldItemList.Rows)
|
|
{
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
#region 根据仪器类别生成二级科室
|
|
|
|
var itemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item_type" && m.OldKeyValue == row["department_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid? deviceTypeId = null;
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["device_type_id"].ToString()))
|
|
{
|
|
deviceTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "device_type" && m.OldKeyValue == row["device_type_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var itemTypeEnt = await _itemTypeRepository.GetAsync(itemTypeId);
|
|
var deviceTypeEnt = await _deviceTypeRepository.GetAsync(deviceTypeId.Value);
|
|
|
|
|
|
var itemTypeChildEnt = await _itemTypeRepository.FirstOrDefaultAsync(m => m.ParentId == itemTypeEnt.Id && m.DisplayName == deviceTypeEnt.DisplayName);
|
|
if (itemTypeChildEnt == null)
|
|
{
|
|
Guid autoItemTypeId = GuidGenerator.Create();
|
|
|
|
#region 排序值
|
|
|
|
int displayOrder = (await _itemTypeRepository.CountAsync(m => m.ParentId == itemTypeEnt.Id)) + 1;
|
|
|
|
#endregion
|
|
|
|
var item_type_data = new ItemType(autoItemTypeId)
|
|
{
|
|
DisplayName = deviceTypeEnt.DisplayName,
|
|
DisplayOrder = displayOrder,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(deviceTypeEnt.DisplayName),
|
|
CheckTypeFlag = itemTypeEnt.CheckTypeFlag,
|
|
GuidTypeId = itemTypeEnt.GuidTypeId,
|
|
IsMergeAsbitem = itemTypeEnt.IsMergeAsbitem,
|
|
IsWrap = itemTypeEnt.IsWrap,
|
|
MedicalReportTypeId = itemTypeEnt.MedicalReportTypeId,
|
|
ParentId = itemTypeEnt.Id,
|
|
PathCode = _itemTypeManager.CreatePathCode(itemTypeEnt.Id).Result,
|
|
IsCheckRequest = itemTypeEnt.IsCheckRequest
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(item_type_data);
|
|
itemTypeId = autoItemTypeId;
|
|
}
|
|
else
|
|
{
|
|
itemTypeId = itemTypeChildEnt.Id;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
Guid? unitId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["unit_id"].ToString()))
|
|
unitId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "unit" && m.OldKeyValue == row["unit_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid itemId = GuidGenerator.Create();
|
|
|
|
var data = new Item(itemId)
|
|
{
|
|
DisplayName = row["item_name"].ToString(),
|
|
DisplayOrder = oldItemList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["item_name"].ToString()),
|
|
CalculationFunction = "",
|
|
DefaultResult = row["default_result"].ToString(),
|
|
DiagnosisFunction = "",
|
|
EnglishShortName = row["english_abbreviation"].ToString(),
|
|
InputCheck = row["input_check"].ToString(),
|
|
IsActive = Convert.ToChar(row["valid_flag"].ToString()),
|
|
IsCalculationItem = 'N',
|
|
IsContinueProcess = 'N',
|
|
IsDiagnosisFunction = 'N',
|
|
IsNameIntoSummary = Convert.ToChar(row["name_into_summary_flag"]),
|
|
IsProduceSummary = Convert.ToChar(row["produce_summary_flag"]),
|
|
ItemTypeId = itemTypeId,
|
|
LineModeFlag = '0',
|
|
Price = Convert.ToDecimal(row["price"]),
|
|
PriceItemId = null,
|
|
ReferenceRangeTypeFlag = Convert.ToChar(row["reference_range_type"]),
|
|
ResultTemplateTypeFlag = '0',
|
|
UnitId = unitId,
|
|
DeviceTypeId = deviceTypeId
|
|
};
|
|
|
|
await _itemRepository.InsertAsync(data);
|
|
|
|
if (row["reference_range_type"].ToString() == "2" && !string.IsNullOrWhiteSpace(row["reference_range_value"].ToString()))
|
|
{
|
|
//增加字符型参考范围到参考范围表
|
|
|
|
Guid referenceRangeId = GuidGenerator.Create();
|
|
|
|
var referenceRange = new ReferenceRange(referenceRangeId)
|
|
{
|
|
AgeLowerLimit = 0,
|
|
AgeUpperLimit = 200,
|
|
CriticalRangeValue = "",
|
|
ItemId = itemId,
|
|
ForSexId = ForSexFlag.All,
|
|
LowerDiagnosisId = null,
|
|
ReferenceRangeTypeFlag = ItemReferenceRangeTypeFlag.Character,
|
|
UpperDiagnosisId = null,
|
|
ReferenceRangeValue = row["reference_range_value"].ToString()
|
|
};
|
|
|
|
//referenceRanges.Add(referenceRange);
|
|
await _referenceRangeRepository.InsertAsync(referenceRange);
|
|
}
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "item",
|
|
FieldName = "id",
|
|
NewKeyValue = itemId.ToString(),
|
|
OldKeyValue = row["item_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"项目数据处理完毕,处理数量{oldItemList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("项目数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移组合项目数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferAsbitemData()
|
|
{
|
|
var count = await _asbitemRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldAsbitemList = await Db.Ado.GetDataTableAsync("select a.* from asbitem as a left join department as b on a.department_id=b.department_id order by b.display_order,a.display_order ");
|
|
if (oldAsbitemList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldAsbitemList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
#region 根据仪器类别生成二级科室
|
|
|
|
var itemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item_type" && m.OldKeyValue == row["department_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid? deviceTypeId = null;
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["device_type_id"].ToString()))
|
|
{
|
|
deviceTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "device_type" && m.OldKeyValue == row["device_type_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var itemTypeEnt = await _itemTypeRepository.GetAsync(itemTypeId);
|
|
var deviceTypeEnt = await _deviceTypeRepository.GetAsync(deviceTypeId.Value);
|
|
|
|
|
|
var itemTypeChildEnt = await _itemTypeRepository.FirstOrDefaultAsync(m => m.ParentId == itemTypeEnt.Id && m.DisplayName == deviceTypeEnt.DisplayName);
|
|
if (itemTypeChildEnt == null)
|
|
{
|
|
Guid autoItemTypeId = GuidGenerator.Create();
|
|
|
|
#region 排序值
|
|
|
|
int displayOrder = (await _itemTypeRepository.CountAsync(m => m.ParentId == itemTypeEnt.Id)) + 1;
|
|
|
|
#endregion
|
|
|
|
var item_type_data = new ItemType(autoItemTypeId)
|
|
{
|
|
DisplayName = deviceTypeEnt.DisplayName,
|
|
DisplayOrder = displayOrder,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(deviceTypeEnt.DisplayName),
|
|
CheckTypeFlag = itemTypeEnt.CheckTypeFlag,
|
|
GuidTypeId = itemTypeEnt.GuidTypeId,
|
|
IsMergeAsbitem = itemTypeEnt.IsMergeAsbitem,
|
|
IsWrap = itemTypeEnt.IsWrap,
|
|
MedicalReportTypeId = itemTypeEnt.MedicalReportTypeId,
|
|
ParentId = itemTypeEnt.Id,
|
|
PathCode = _itemTypeManager.CreatePathCode(itemTypeEnt.Id).Result,
|
|
IsCheckRequest = itemTypeEnt.IsCheckRequest
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(item_type_data);
|
|
itemTypeId = autoItemTypeId;
|
|
}
|
|
else
|
|
{
|
|
itemTypeId = itemTypeChildEnt.Id;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
Guid collectItemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "collect_item_type" && m.OldKeyValue == row["collect_item_type_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid asbitemId = GuidGenerator.Create();
|
|
|
|
|
|
var data = new Asbitem(asbitemId)
|
|
{
|
|
DisplayName = row["asbitem_name"].ToString(),
|
|
DisplayOrder = oldAsbitemList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["asbitem_name"].ToString()),
|
|
DefaultResult = row["default_result"].ToString(),
|
|
DiagnosisFunction = "",
|
|
IsActive = Convert.ToChar(row["valid_flag"].ToString()),
|
|
IsContinueProcess = 'N',
|
|
IsDiagnosisFunction = 'N',
|
|
ItemTypeId = itemTypeId,
|
|
Price = Convert.ToDecimal(row["price"]),
|
|
DeviceTypeId = deviceTypeId,
|
|
ClinicalMeaning = row["clinical_meaning"].ToString(),
|
|
ForSexId = ConvertForSex(row["for_sex_id"].ToString()),
|
|
CollectItemTypeId = collectItemTypeId,
|
|
//InvoiceItemTypeId = InvoiceItemTypeId,
|
|
IsBeforeEat = Convert.ToChar(row["before_eat_flag"].ToString()),
|
|
IsCheck = Convert.ToChar(row["check_flag"].ToString()),
|
|
IsItemResultMerger = Convert.ToChar(row["item_result_merger_flag"].ToString()),
|
|
IsPictureRotate = Convert.ToChar(row["picture_rotate_flag"].ToString()),
|
|
QueueTime = string.IsNullOrEmpty(row["queue_time"].ToString()) ? 0 : Convert.ToDecimal(row["queue_time"].ToString()),
|
|
ShortName = row["short_name"].ToString()
|
|
};
|
|
|
|
await _asbitemRepository.InsertAsync(data);
|
|
|
|
|
|
#region 指引信息
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["prompt"].ToString()))
|
|
{
|
|
var asbitemGuideData = new AsbitemGuide
|
|
{
|
|
AsbitemId = asbitemId,
|
|
ForSexId = ForSexFlag.All,
|
|
Guide = row["prompt"].ToString(),
|
|
MedicalCenterId = defaultMedicalCenterId
|
|
};
|
|
|
|
await _asbitemGuideRepository.InsertAsync(asbitemGuideData);
|
|
}
|
|
|
|
#endregion
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "asbitem",
|
|
FieldName = "id",
|
|
NewKeyValue = asbitemId.ToString(),
|
|
OldKeyValue = row["asbitem_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"组合项目数据处理完毕,处理数量{oldAsbitemList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("组合项目数据已存在,未处理");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移组合项目明细数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferAsbitemDetailData()
|
|
{
|
|
var count = await _asbitemDetailRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldAsbitemDetailList = await Db.Ado.GetDataTableAsync("select * from asbitem_detail ");
|
|
if (oldAsbitemDetailList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldAsbitemDetailList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid asbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
Guid itemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
var data = new AsbitemDetail
|
|
{
|
|
AsbitemId = asbitemId,
|
|
ItemId = itemId
|
|
};
|
|
|
|
await _asbitemDetailRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"组合项目明细数据处理完毕,处理数量{oldAsbitemDetailList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("组合项目明细数据已存在,未处理");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移体检套餐数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferMedicalPackageData()
|
|
{
|
|
var count = await _medicalPackageRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldMedicalPackageList = await Db.Ado.GetDataTableAsync("select * from medical_package order by display_order");
|
|
if (oldMedicalPackageList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldMedicalPackageList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid medicalPackageId = GuidGenerator.Create();
|
|
|
|
var data = new MedicalPackage(medicalPackageId)
|
|
{
|
|
DisplayName = row["medical_package_name"].ToString(),
|
|
DisplayOrder = oldMedicalPackageList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["medical_package_name"].ToString()),
|
|
ForSexId = ConvertForSex(row["for_sex_id"].ToString()),
|
|
IsActive = Convert.ToChar(row["valid_flag"].ToString()),
|
|
Price = Convert.ToDecimal(row["price"].ToString()),
|
|
Remark = row["remark"].ToString()
|
|
};
|
|
|
|
await _medicalPackageRepository.InsertAsync(data);
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "medical_package",
|
|
FieldName = "id",
|
|
NewKeyValue = medicalPackageId.ToString(),
|
|
OldKeyValue = row["medical_package_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检套餐数据处理完毕,处理数量{oldMedicalPackageList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检套餐数据已存在,未处理");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移体检套餐明细数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferMedicalPackageDetailData()
|
|
{
|
|
var count = await _medicalPackageDetailRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldMedicalPackageDetailList = await Db.Ado.GetDataTableAsync("select * from medical_package_detail ");
|
|
if (oldMedicalPackageDetailList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldMedicalPackageDetailList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid asbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
Guid MedicalPackageId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "medical_package" && m.OldKeyValue == row["medical_package_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var asbitemEnt = await _asbitemRepository.GetAsync(asbitemId);
|
|
|
|
var data = new MedicalPackageDetail
|
|
{
|
|
AsbitemId = asbitemId,
|
|
Amount = 1,
|
|
MedicalPackageId = MedicalPackageId,
|
|
Price = asbitemEnt.Price
|
|
};
|
|
|
|
await _medicalPackageDetailRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检套餐明细数据处理完毕,处理数量{oldMedicalPackageDetailList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检套餐明细数据已存在,未处理");
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移诊断设置数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferDiagnosisData()
|
|
{
|
|
var count = await _diagnosisRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldDiagnosisList = await Db.Ado.GetDataTableAsync("select a.* from diagnosis as a left join department as b on a.department_id=b.department_id order by b.display_order,a.display_order ");
|
|
if (oldDiagnosisList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldDiagnosisList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
#region 根据仪器类别生成二级科室
|
|
|
|
var itemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item_type" && m.OldKeyValue == row["department_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid? deviceTypeId = null;
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["device_type_id"].ToString()))
|
|
{
|
|
var fieldComparisonEnt = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "device_type" && m.OldKeyValue == row["device_type_id"].ToString()).FirstOrDefault();
|
|
if (fieldComparisonEnt != null)
|
|
{
|
|
deviceTypeId = Guid.Parse(fieldComparisonEnt.NewKeyValue);
|
|
var itemTypeEnt = await _itemTypeRepository.GetAsync(itemTypeId);
|
|
var deviceTypeEnt = await _deviceTypeRepository.GetAsync(deviceTypeId.Value);
|
|
|
|
|
|
var itemTypeChildEnt = await _itemTypeRepository.FirstOrDefaultAsync(m => m.ParentId == itemTypeEnt.Id && m.DisplayName == deviceTypeEnt.DisplayName);
|
|
if (itemTypeChildEnt == null)
|
|
{
|
|
Guid autoItemTypeId = GuidGenerator.Create();
|
|
|
|
#region 排序值
|
|
|
|
int displayOrder = (await _itemTypeRepository.CountAsync(m => m.ParentId == itemTypeEnt.Id)) + 1;
|
|
|
|
#endregion
|
|
|
|
var item_type_data = new ItemType(autoItemTypeId)
|
|
{
|
|
DisplayName = deviceTypeEnt.DisplayName,
|
|
DisplayOrder = displayOrder,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(deviceTypeEnt.DisplayName),
|
|
CheckTypeFlag = itemTypeEnt.CheckTypeFlag,
|
|
GuidTypeId = itemTypeEnt.GuidTypeId,
|
|
IsMergeAsbitem = itemTypeEnt.IsMergeAsbitem,
|
|
IsWrap = itemTypeEnt.IsWrap,
|
|
MedicalReportTypeId = itemTypeEnt.MedicalReportTypeId,
|
|
ParentId = itemTypeEnt.Id,
|
|
PathCode = _itemTypeManager.CreatePathCode(itemTypeEnt.Id).Result,
|
|
IsCheckRequest = itemTypeEnt.IsCheckRequest
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(item_type_data);
|
|
itemTypeId = autoItemTypeId;
|
|
}
|
|
else
|
|
{
|
|
itemTypeId = itemTypeChildEnt.Id;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
Guid diagnosisId = GuidGenerator.Create();
|
|
|
|
var data = new Diagnosis(diagnosisId)
|
|
{
|
|
DisplayName = row["diagnosis_name"].ToString(),
|
|
DisplayOrder = oldDiagnosisList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["diagnosis_name"].ToString()),
|
|
ItemTypeId = itemTypeId,
|
|
DiagnosisLevelId = 1,
|
|
ForSexId = 'A',
|
|
IsIll = Convert.ToChar(row["ill_flag"].ToString()),
|
|
IsSummaryTemplate = Convert.ToChar(row["template_flag"].ToString()),
|
|
SuggestionName = row["suggestion_name"].ToString()
|
|
};
|
|
|
|
await _diagnosisRepository.InsertAsync(data);
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "diagnosis",
|
|
FieldName = "id",
|
|
NewKeyValue = diagnosisId.ToString(),
|
|
OldKeyValue = row["diagnosis_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"诊断设置数据处理完毕,处理数量{oldDiagnosisList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("诊断设置数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移诊断建议数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferSuggestionData()
|
|
{
|
|
var count = await _suggestionRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldSuggestionList = await Db.Ado.GetDataTableAsync("select * from suggestion order by display_order,suggestion_id ");
|
|
if (oldSuggestionList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldSuggestionList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
Guid DiagnosisId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "diagnosis" && m.OldKeyValue == row["diagnosis_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid suggestionId = GuidGenerator.Create();
|
|
|
|
var data = new Suggestion(suggestionId)
|
|
{
|
|
DisplayOrder = oldSuggestionList.Rows.IndexOf(row) + 1,
|
|
DiagnosisId = DiagnosisId,
|
|
SuggestionType = SuggestionTypeFlag.HealthGuidance,
|
|
SuggestionContent = row["suggestion_content"].ToString()
|
|
};
|
|
|
|
await _suggestionRepository.InsertAsync(data);
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "suggestion",
|
|
FieldName = "id",
|
|
NewKeyValue = suggestionId.ToString(),
|
|
OldKeyValue = row["suggestion_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"诊断建议数据处理完毕,处理数量{oldSuggestionList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("诊断建议数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移项目结果模板数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferItemResultTemplateData()
|
|
{
|
|
var count = await _itemResultTemplateRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldItemResultTemplateList = await Db.Ado.GetDataTableAsync("select * from item_result_template order by display_order,item_result_template_id ");
|
|
if (oldItemResultTemplateList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldItemResultTemplateList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid? DiagnosisId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["diagnosis_id"].ToString()))
|
|
{
|
|
var fieldComparisonDiagnosisEnt = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "diagnosis" && m.OldKeyValue == row["diagnosis_id"].ToString()).FirstOrDefault();
|
|
if (fieldComparisonDiagnosisEnt != null)
|
|
{
|
|
DiagnosisId = Guid.Parse(fieldComparisonDiagnosisEnt.NewKeyValue);
|
|
}
|
|
}
|
|
|
|
Guid ItemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid itemResultTemplateId = GuidGenerator.Create();
|
|
|
|
var data = new ItemResultTemplate(itemResultTemplateId)
|
|
{
|
|
DisplayOrder = oldItemResultTemplateList.Rows.IndexOf(row) + 1,
|
|
DiagnosisId = DiagnosisId,
|
|
IsNameIntoSummary = Convert.ToChar(row["name_into_summary_flag"].ToString()),
|
|
IsResultIntoSummary = Convert.ToChar(row["result_into_summary_flag"].ToString()),
|
|
ItemId = ItemId,
|
|
Result = row["result"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["result"].ToString()),
|
|
ResultStatusId = row["result_status_id"].ToString()
|
|
};
|
|
|
|
await _itemResultTemplateRepository.InsertAsync(data);
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "item_result_template",
|
|
FieldName = "id",
|
|
NewKeyValue = itemResultTemplateId.ToString(),
|
|
OldKeyValue = row["item_result_template_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"项目结果模板数据处理完毕,处理数量{oldItemResultTemplateList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("项目结果模板数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移项目结果匹配数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferItemResultMatchData()
|
|
{
|
|
var count = await _ItemResultMatchRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldItemResultMatchList = await Db.Ado.GetDataTableAsync("select * from item_result_match order by display_order,item_result_match_id ");
|
|
if (oldItemResultMatchList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldItemResultMatchList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
var fieldComparisonDiagnosisEnt = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "diagnosis" && m.OldKeyValue == row["diagnosis_id"].ToString()).FirstOrDefault();
|
|
if (fieldComparisonDiagnosisEnt != null)
|
|
{
|
|
Guid DiagnosisId = Guid.Parse(fieldComparisonDiagnosisEnt.NewKeyValue);
|
|
Guid ItemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid itemResultMatchId = GuidGenerator.Create();
|
|
|
|
var data = new ItemResultMatch(itemResultMatchId)
|
|
{
|
|
DisplayOrder = oldItemResultMatchList.Rows.IndexOf(row) + 1,
|
|
DiagnosisId = DiagnosisId,
|
|
ItemId = ItemId,
|
|
Result = row["result"].ToString()
|
|
};
|
|
|
|
var ent = await _ItemResultMatchRepository.InsertAsync(data, true);
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "item_result_match",
|
|
FieldName = "id",
|
|
NewKeyValue = ent.Id.ToString(),
|
|
OldKeyValue = row["item_result_match_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
}
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"项目结果匹配数据处理完毕,处理数量{oldItemResultMatchList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("项目结果匹配数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移项目参考范围数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferReferenceRangeData()
|
|
{
|
|
var count = (await _referenceRangeRepository.GetQueryableAsync()).Where(m => m.ReferenceRangeTypeFlag != ItemReferenceRangeTypeFlag.Character).Count();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldReferenceRangeList = await Db.Ado.GetDataTableAsync("select * from reference_range order by reference_range_id ");
|
|
if (oldReferenceRangeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldReferenceRangeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid? LowerDiagnosisId = null;
|
|
Guid? UpperDiagnosisId = null;
|
|
|
|
var fieldComparisonLowerDiagnosisEnt = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "diagnosis" && m.OldKeyValue == row["lower_diagnosis_id"].ToString()).FirstOrDefault();
|
|
var fieldComparisonUpperDiagnosisEnt = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "diagnosis" && m.OldKeyValue == row["upper_diagnosis_id"].ToString()).FirstOrDefault();
|
|
if (fieldComparisonLowerDiagnosisEnt != null)
|
|
{
|
|
LowerDiagnosisId = Guid.Parse(fieldComparisonLowerDiagnosisEnt.NewKeyValue);
|
|
}
|
|
if (fieldComparisonUpperDiagnosisEnt != null)
|
|
{
|
|
UpperDiagnosisId = Guid.Parse(fieldComparisonUpperDiagnosisEnt.NewKeyValue);
|
|
}
|
|
|
|
Guid ItemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid referenceRangeId = GuidGenerator.Create();
|
|
|
|
var data = new ReferenceRange(referenceRangeId)
|
|
{
|
|
ItemId = ItemId,
|
|
AgeLowerLimit = (short)Convert.ToInt32(row["age_lower_limit"].ToString()),
|
|
AgeUpperLimit = (short)Convert.ToInt32(row["age_upper_limit"].ToString()),
|
|
CriticalRangeValue = string.Empty,
|
|
ForSexId = ConvertForSex(row["for_sex_id"].ToString()),
|
|
LowerDiagnosisId = LowerDiagnosisId,
|
|
ReferenceRangeTypeFlag = ItemReferenceRangeTypeFlag.Number,
|
|
ReferenceRangeValue = Convert.ToDecimal(row["lower_limit"].ToString()).ToString("#0.####") + "-" + Convert.ToDecimal(row["upper_limit"].ToString()).ToString("#0.####"),
|
|
UpperDiagnosisId = UpperDiagnosisId
|
|
};
|
|
|
|
await _referenceRangeRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"项目参考范围数据处理完毕,处理数量{oldReferenceRangeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("项目参考范围数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移条码分组数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferSampleGroupData()
|
|
{
|
|
var count = await _sampleGroupRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
//获取一条条码类型的数据
|
|
Guid defaultSampleTypeId = Guid.Empty;
|
|
var sampleTypeEnt = await _sampleTypeRepository.FirstOrDefaultAsync();
|
|
if (sampleTypeEnt != null)
|
|
{
|
|
defaultSampleTypeId = sampleTypeEnt.Id;
|
|
}
|
|
if (defaultSampleTypeId != Guid.Empty)
|
|
{
|
|
var oldSampleGroupList = await Db.Ado.GetDataTableAsync("select * from vessels_type order by display_order");
|
|
if (oldSampleGroupList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldSampleGroupList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
#region 转成成新的标本类型ID
|
|
|
|
Guid newSampleTypeId = defaultSampleTypeId; //默认取其他 ID
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["specimen_type_id"].ToString()))
|
|
{
|
|
var oldSampleType = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "sample_type" && m.OldKeyValue == row["specimen_type_id"].ToString()).FirstOrDefault();
|
|
if (oldSampleType != null)
|
|
{
|
|
newSampleTypeId = Guid.Parse(oldSampleType.NewKeyValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
Guid sampleGroupId = GuidGenerator.Create();
|
|
|
|
var data = new SampleGroup(sampleGroupId)
|
|
{
|
|
DisplayName = row["vessels_type_name"].ToString(),
|
|
DisplayOrder = oldSampleGroupList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["vessels_type_name"].ToString()),
|
|
SampleContainerId = defaultSampleContainerId,
|
|
SampleTypeId = newSampleTypeId
|
|
};
|
|
|
|
await _sampleGroupRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "sample_group",
|
|
FieldName = "id",
|
|
NewKeyValue = sampleGroupId.ToString(),
|
|
OldKeyValue = row["vessels_type_id"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
_logger.LogInformation($"条码分组数据处理完毕,处理数量{oldSampleGroupList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"条码类型未获取到默认数据,跳过条码分组数据处理");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("条码分组数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移条码分组明细数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferSampleGroupDetailData()
|
|
{
|
|
var count = await _sampleGroupDetailRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldSampleGroupDetailList = await Db.Ado.GetDataTableAsync("select * from vessels_type_detail ");
|
|
if (oldSampleGroupDetailList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldSampleGroupDetailList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid newSampleGroupId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "sample_group" && m.OldKeyValue == row["vessels_type_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid newAsbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var data = new SampleGroupDetail
|
|
{
|
|
AsbitemId = newAsbitemId,
|
|
SampleGroupId = newSampleGroupId
|
|
};
|
|
|
|
await _sampleGroupDetailRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"条码分组明细数据处理完毕,处理数量{oldSampleGroupDetailList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("条码分组明细数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移体检单位数据 一级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferTopCustomerOrgData()
|
|
{
|
|
var count = await _customerOrgRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldCustomerOrgList = await Db.Ado.GetDataTableAsync("select * from org where len(org_id)=5 order by display_order asc");
|
|
if (oldCustomerOrgList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldCustomerOrgList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid customerOrgId = GuidGenerator.Create();
|
|
|
|
#region 备注 导入联系人姓名、电话
|
|
string remark = "";
|
|
if (!string.IsNullOrWhiteSpace(row["linkman"].ToString()))
|
|
{
|
|
remark = row["linkman"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(row["telephone"].ToString()))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(remark))
|
|
{
|
|
remark += "|" + row["telephone"].ToString();
|
|
}
|
|
else
|
|
{
|
|
remark = row["telephone"].ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
var data = new CustomerOrg(customerOrgId)
|
|
{
|
|
Accounts = row["accounts"].ToString(),
|
|
Address = row["address"].ToString(),
|
|
Bank = row["bank"].ToString(),
|
|
DisplayName = row["org_name"].ToString(),
|
|
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
|
|
Fax = row["fax"].ToString(),
|
|
InvoiceName = row["org_name"].ToString(),
|
|
IsActive = 'Y',
|
|
IsLock = Convert.ToChar(row["lock_flag"].ToString()),
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
OrgTypeId = defaultOrgTypeId, //默认为私营
|
|
ParentId = null,
|
|
PathCode = (oldCustomerOrgList.Rows.IndexOf(row) + 1).ToString().PadLeft(5, '0'),
|
|
PostalCode = row["postalcode"].ToString(),
|
|
Remark = remark,
|
|
ShortName = row["short_name"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["org_name"].ToString()),
|
|
Telephone = row["telephone"].ToString(),
|
|
};
|
|
|
|
await _customerOrgRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgId.ToString(),
|
|
OldKeyValue = row["org_id"].ToString(),
|
|
TableName = "customer_org"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检单位一级数据处理完毕,处理数量{oldCustomerOrgList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检单位一级数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移体检单位数据 二级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferTwoCustomerOrgData()
|
|
{
|
|
var count = (await _customerOrgRepository.GetQueryableAsync()).Where(m => m.PathCode.Length > 5).Count();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldCustomerOrgList = await Db.Ado.GetDataTableAsync("select * from [dbo].[org] where len(org_id)=8 order by org_id asc");
|
|
if (oldCustomerOrgList.Rows.Count > 0)
|
|
{
|
|
List<CustomerOrg> customerOrgList = await _customerOrgRepository.GetListAsync(m => m.ParentId == null);
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
|
|
foreach (DataRow row in oldCustomerOrgList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
#region 查找上级ID
|
|
string oldId = row["org_id"].ToString();
|
|
string oldParentId = oldId.Substring(0, 5);
|
|
Guid parentId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == oldParentId).FirstOrDefault().NewKeyValue);
|
|
#endregion
|
|
|
|
|
|
Guid customerOrgId = GuidGenerator.Create();
|
|
|
|
#region 备注 导入联系人姓名、电话
|
|
string remark = "";
|
|
if (!string.IsNullOrWhiteSpace(row["linkman"].ToString()))
|
|
{
|
|
remark = row["linkman"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(row["telephone"].ToString()))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(remark))
|
|
{
|
|
remark += "|" + row["telephone"].ToString();
|
|
}
|
|
else
|
|
{
|
|
remark = row["telephone"].ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
var data = new CustomerOrg(customerOrgId)
|
|
{
|
|
Accounts = row["accounts"].ToString(),
|
|
Address = row["address"].ToString(),
|
|
Bank = row["bank"].ToString(),
|
|
DisplayName = row["org_name"].ToString(),
|
|
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
|
|
Fax = row["fax"].ToString(),
|
|
InvoiceName = row["org_name"].ToString(),
|
|
IsActive = 'Y',
|
|
IsLock = Convert.ToChar(row["lock_flag"].ToString()),
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
OrgTypeId = defaultOrgTypeId, //默认为私营
|
|
ParentId = parentId,
|
|
PathCode = _customerOrgManager.CreatePathCode(parentId).Result,
|
|
PostalCode = row["postalcode"].ToString(),
|
|
Remark = remark,
|
|
ShortName = row["short_name"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["org_name"].ToString()),
|
|
Telephone = row["telephone"].ToString(),
|
|
};
|
|
|
|
await _customerOrgRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgId.ToString(),
|
|
OldKeyValue = row["org_id"].ToString(),
|
|
TableName = "customer_org"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
_logger.LogInformation($"体检单位二级数据处理完毕,处理数量{oldCustomerOrgList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检单位二级数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移体检单位数据 三级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferThreeCustomerOrgData()
|
|
{
|
|
var count = (await _customerOrgRepository.GetQueryableAsync()).Where(m => m.PathCode.Length > 11).Count();
|
|
if (count == 0)
|
|
{
|
|
var oldCustomerOrgList = await Db.Ado.GetDataTableAsync("select * from [dbo].[org] where len(org_id)=11 order by org_id asc");
|
|
if (oldCustomerOrgList.Rows.Count > 0)
|
|
{
|
|
List<CustomerOrg> customerOrgList = await _customerOrgRepository.GetListAsync(m => m.ParentId == null);
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
|
|
foreach (DataRow row in oldCustomerOrgList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
#region 查找上级ID
|
|
string oldId = row["org_id"].ToString();
|
|
string oldParentId = oldId.Substring(0, 8);
|
|
Guid parentId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == oldParentId).FirstOrDefault().NewKeyValue);
|
|
#endregion
|
|
|
|
|
|
Guid customerOrgId = GuidGenerator.Create();
|
|
|
|
#region 备注 导入联系人姓名、电话
|
|
string remark = "";
|
|
if (!string.IsNullOrWhiteSpace(row["linkman"].ToString()))
|
|
{
|
|
remark = row["linkman"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(row["telephone"].ToString()))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(remark))
|
|
{
|
|
remark += "|" + row["telephone"].ToString();
|
|
}
|
|
else
|
|
{
|
|
remark = row["telephone"].ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
var data = new CustomerOrg(customerOrgId)
|
|
{
|
|
Accounts = row["accounts"].ToString(),
|
|
Address = row["address"].ToString(),
|
|
Bank = row["bank"].ToString(),
|
|
DisplayName = row["org_name"].ToString(),
|
|
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
|
|
Fax = row["fax"].ToString(),
|
|
InvoiceName = row["org_name"].ToString(),
|
|
IsActive = 'Y',
|
|
IsLock = Convert.ToChar(row["lock_flag"].ToString()),
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
OrgTypeId = defaultOrgTypeId, //默认为私营
|
|
ParentId = parentId,
|
|
PathCode = _customerOrgManager.CreatePathCode(parentId).Result,
|
|
PostalCode = row["postalcode"].ToString(),
|
|
Remark = remark,
|
|
ShortName = row["short_name"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["org_name"].ToString()),
|
|
Telephone = row["telephone"].ToString(),
|
|
};
|
|
|
|
await _customerOrgRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgId.ToString(),
|
|
OldKeyValue = row["org_id"].ToString(),
|
|
TableName = "customer_org"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检单位三级数据处理完毕,处理数量{oldCustomerOrgList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检单位三级数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移单位体检次数数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferCustomerOrgRegisterData()
|
|
{
|
|
var count = await _customerOrgRegisterRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldCustomerOrgRegisterList = await Db.Ado.GetDataTableAsync("select * from org_medical_register order by org_medical_times");
|
|
if (oldCustomerOrgRegisterList.Rows.Count > 0)
|
|
{
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
|
|
foreach (DataRow row in oldCustomerOrgRegisterList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["org_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
Guid customerOrgRegisterId = GuidGenerator.Create();
|
|
|
|
if (customerOrgId == GuidFlag.PersonCustomerOrgId)
|
|
customerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId;
|
|
var data = new CustomerOrgRegister(customerOrgRegisterId)
|
|
{
|
|
BeginTime = Convert.ToDateTime(row["start_time"].ToString()),
|
|
CustomerOrgId = customerOrgId,
|
|
EndTime = !string.IsNullOrWhiteSpace(row["end_time"].ToString()) ? Convert.ToDateTime(row["end_time"].ToString()) : null,
|
|
IsComplete = Convert.ToChar(row["complete_flag"].ToString()),
|
|
MedicalTimes = (short)Convert.ToInt32(row["org_medical_times"].ToString()),
|
|
RegisterName = "",
|
|
RegisterNo = ""
|
|
};
|
|
|
|
await _customerOrgRegisterRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"单位体检次数数据处理完毕,处理数量{oldCustomerOrgRegisterList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("单位体检次数数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移单位分组
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferCustomerOrgGroupData()
|
|
{
|
|
var count = await _customerOrgGroupRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldCustomerOrgGroupList = await Db.Ado.GetDataTableAsync("select * from org_group order by display_order asc");
|
|
if (oldCustomerOrgGroupList.Rows.Count > 0)
|
|
{
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
List<CustomerOrgRegister> customerOrgRegisterList = await _customerOrgRegisterRepository.GetListAsync();
|
|
|
|
foreach (DataRow row in oldCustomerOrgGroupList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
//新系统单位ID
|
|
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["org_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
Guid customerOrgRegisterId = customerOrgRegisterList.Where(m => m.CustomerOrgId == customerOrgId
|
|
&& m.MedicalTimes == (short)Convert.ToInt32(row["org_medical_times"].ToString())).FirstOrDefault().Id;
|
|
Guid customerOrgGroupId = GuidGenerator.Create();
|
|
|
|
var data = new CustomerOrgGroup(customerOrgGroupId)
|
|
{
|
|
AgeLowerLimit = (short)Convert.ToInt32(row["age_lower_limit"].ToString()),
|
|
AgeUpperLimit = (short)Convert.ToInt32(row["age_upper_limit"].ToString()),
|
|
CustomerOrgRegisterId = customerOrgRegisterId,
|
|
DisplayName = row["org_group_name"].ToString(),
|
|
DisplayOrder = oldCustomerOrgGroupList.Rows.IndexOf(row) + 1,
|
|
ForSexId = ConvertForSex(row["for_sex_id"].ToString()),
|
|
JobPost = row["job_post"].ToString(),
|
|
JobTitle = row["job_title"].ToString(),
|
|
MaritalStatusId = Convert.ToChar(row["marital_status_id"].ToString()),
|
|
Price = Convert.ToDecimal(row["price"].ToString()),
|
|
Remark = row["remark"].ToString()
|
|
};
|
|
|
|
await _customerOrgGroupRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgGroupId.ToString(),
|
|
OldKeyValue = row["org_group_id"].ToString(),
|
|
TableName = "customer_org_group"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"单位分组数据处理完毕,处理数量{oldCustomerOrgGroupList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("单位分组数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移单位分组明细数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task TransferCustomerOrgGroupDetailData()
|
|
{
|
|
var count = await _customerOrgGroupDetailRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldCustomerOrgGroupList = await Db.Ado.GetDataTableAsync("select * from org_group_detail ");
|
|
if (oldCustomerOrgGroupList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldCustomerOrgGroupList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
//新系统单位分组ID
|
|
Guid customerOrgGroupId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "customer_org_group" && m.OldKeyValue == row["org_group_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
Guid asbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var data = new CustomerOrgGroupDetail
|
|
{
|
|
AsbitemId = asbitemId,
|
|
CustomerOrgGroupId = customerOrgGroupId,
|
|
Price = Convert.ToDecimal(row["price"].ToString()),
|
|
Amount = 1
|
|
};
|
|
|
|
await _customerOrgGroupDetailRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"单位分组明细数据处理完毕,处理数量{oldCustomerOrgGroupList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("单位分组明细数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 人员登记
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移人员登记数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferPatientRegisterData()
|
|
{
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register' ");
|
|
|
|
var oldPatientRegisterList = await Db.Ado.GetDataTableAsync($"select top 1000 * from patient_register where patient_register_id>'{nextKeyValue}' order by patient_register_id asc");
|
|
|
|
|
|
if (oldPatientRegisterList.Rows.Count > 0)
|
|
{
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set starttime=getdate() where tablename='patient_register' ");
|
|
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync();
|
|
var userList = await _identityUserRepository.GetListAsync();
|
|
List<CustomerOrgRegister> customerOrgRegisterList = await _customerOrgRegisterRepository.GetListAsync();
|
|
|
|
foreach (DataRow row in oldPatientRegisterList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
//档案ID
|
|
Guid patientId = Guid.Empty;
|
|
|
|
#region 处理档案,未找到档案就生成
|
|
|
|
var patientEnt = await _patientRepository.FirstOrDefaultAsync(m => m.PatientNo == row["patient_id"].ToString());
|
|
if (patientEnt == null)
|
|
{
|
|
string nationId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["nation_id"].ToString()))
|
|
{
|
|
nationId = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "nation" && m.OldKeyValue == row["nation_id"].ToString()).FirstOrDefault().NewKeyValue;
|
|
}
|
|
|
|
Guid autoPatientId = GuidGenerator.Create(); //档案ID
|
|
|
|
var dataPatient = new Patient(autoPatientId)
|
|
{
|
|
Address = row["address"].ToString(),
|
|
BirthDate = string.IsNullOrEmpty(row["birth_date"].ToString()) ? null : Convert.ToDateTime(row["birth_date"].ToString()),
|
|
BirthPlaceId = null,
|
|
DisplayName = row["name"].ToString(),
|
|
Email = row["email"].ToString(),
|
|
IdNo = row["id_card_no"].ToString(),
|
|
MaritalStatusId = Convert.ToChar(row["marital_status_id"].ToString()),
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
MobileTelephone = row["mobile_telephone"].ToString(),
|
|
NationId = nationId,
|
|
PatientNo = row["patient_id"].ToString(),
|
|
PatientPassword = row["patient_password"].ToString(),
|
|
PostalCode = row["postalcode"].ToString(),
|
|
SexId = ConvertSex(row["sex_id"].ToString()),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["name"].ToString()),
|
|
Telephone = row["telephone"].ToString()
|
|
};
|
|
|
|
await _patientRepository.InsertAsync(dataPatient, true);
|
|
patientId = autoPatientId;
|
|
}
|
|
else
|
|
{
|
|
patientId = patientEnt.Id;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
Guid patientRegisterId = GuidGenerator.Create(); //生成登记ID
|
|
|
|
#region 转换审核医生ID
|
|
Guid? AuditDoctorId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["audit_doctor"].ToString()))
|
|
{
|
|
var userEnt = userList.Where(m => m.UserName == row["audit_doctor"].ToString().Trim()).FirstOrDefault();
|
|
if (userEnt != null)
|
|
{
|
|
AuditDoctorId = userEnt.Id;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 转换单位分组ID
|
|
Guid? customerOrgGroupId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["org_group_id"].ToString()))
|
|
{
|
|
var customerOrgGroupEnt = fieldComparisonList.Where(m => m.TableName == "customer_org_group" && m.OldKeyValue == row["org_group_id"].ToString()).FirstOrDefault();
|
|
if (customerOrgGroupEnt != null)
|
|
{
|
|
customerOrgGroupId = Guid.Parse(customerOrgGroupEnt.NewKeyValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 转换单位ID 部门
|
|
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.TableName == "customer_org" && m.OldKeyValue == row["org_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
#endregion
|
|
|
|
#region 转换单位体检次数ID 没有增加默认值
|
|
Guid customerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId;
|
|
if (row["org_id"].ToString() != "00000")
|
|
{
|
|
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)
|
|
{
|
|
customerOrgRegisterId = customerOrgRegisterEnt.Id;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 转换体检结论ID
|
|
Guid? medicalConclusionId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["medical_conclusion_id"].ToString()))
|
|
{
|
|
var medicalConclusionEnt = fieldComparisonList.Where(m => m.TableName == "medical_conclusion"
|
|
&& m.OldKeyValue == row["medical_conclusion_id"].ToString()).FirstOrDefault();
|
|
if (medicalConclusionEnt != null)
|
|
{
|
|
medicalConclusionId = Guid.Parse(medicalConclusionEnt.NewKeyValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 转换套餐ID
|
|
Guid? medicalPackageId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["medical_package_id"].ToString()))
|
|
{
|
|
var medicalPackageEnt = fieldComparisonList.Where(m => m.TableName == "medical_package" && m.OldKeyValue == row["medical_package_id"].ToString()).FirstOrDefault();
|
|
if (medicalPackageEnt != null)
|
|
{
|
|
medicalPackageId = Guid.Parse(medicalPackageEnt.NewKeyValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 转换体检类别ID
|
|
Guid? medicalTypeId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["medical_type_id"].ToString()))
|
|
{
|
|
var medicalTypeEnt = fieldComparisonList.Where(m => m.TableName == "medical_type" && m.OldKeyValue == row["medical_type_id"].ToString()).FirstOrDefault();
|
|
if (medicalTypeEnt != null)
|
|
{
|
|
medicalTypeId = Guid.Parse(medicalTypeEnt.NewKeyValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 转换人员类别ID
|
|
Guid? personnelTypeId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["personnel_type_id"].ToString()))
|
|
{
|
|
var personnelTypeEnt = fieldComparisonList.Where(m => m.TableName == "personnel_type" && m.OldKeyValue == row["personnel_type_id"].ToString()).FirstOrDefault();
|
|
if (personnelTypeEnt != null)
|
|
{
|
|
personnelTypeId = Guid.Parse(personnelTypeEnt.NewKeyValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 转换总检医生ID
|
|
Guid? summaryDoctorId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["summary_doctor"].ToString()))
|
|
{
|
|
var userEnt = userList.Where(m => m.UserName == row["summary_doctor"].ToString().Trim()).FirstOrDefault();
|
|
if (userEnt != null)
|
|
{
|
|
summaryDoctorId = userEnt.Id;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 上传图片,获取地址
|
|
|
|
string photo = "";
|
|
if (!string.IsNullOrEmpty(row["photograph"].ToString()))
|
|
{
|
|
photo = UpLoadImg(patientRegisterId, Convert.ToDateTime(row["register_date"].ToString()), (byte[])row["photograph"]);
|
|
}
|
|
|
|
#endregion
|
|
|
|
var data = new PatientRegister(patientRegisterId)
|
|
{
|
|
BirthDate = string.IsNullOrEmpty(row["birth_date"].ToString()) ? null : Convert.ToDateTime(row["birth_date"].ToString()),
|
|
MaritalStatusId = Convert.ToChar(row["marital_status_id"].ToString()),
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
SexId = ConvertSex(row["sex_id"].ToString()),
|
|
Age = string.IsNullOrWhiteSpace(row["age"].ToString()) ? null : Convert.ToInt16(row["age"].ToString()),
|
|
AuditDate = string.IsNullOrWhiteSpace(row["audit_date"].ToString()) ? null : Convert.ToDateTime(row["audit_date"].ToString()),
|
|
AuditDoctorId = AuditDoctorId,
|
|
CompleteFlag = Convert.ToChar(row["complete_flag"].ToString()),
|
|
CustomerOrgGroupId = customerOrgGroupId,
|
|
CustomerOrgId = customerOrgId,
|
|
CustomerOrgRegisterId = customerOrgRegisterId,
|
|
GuidePrintTimes = string.IsNullOrWhiteSpace(row["instruct_print_times"].ToString()) ? (short)0 : Convert.ToInt16(row["instruct_print_times"].ToString()),
|
|
InterposeMeasure = null,
|
|
IsAudit = string.IsNullOrWhiteSpace(row["audit_flag"].ToString()) ? 'N' : Convert.ToChar(row["audit_flag"].ToString()),
|
|
IsLock = string.IsNullOrWhiteSpace(row["lock_flag"].ToString()) ? 'N' : Convert.ToChar(row["lock_flag"].ToString()),
|
|
IsMedicalStart = string.IsNullOrWhiteSpace(row["medical_start_flag"].ToString()) ? 'N' : Convert.ToChar(row["medical_start_flag"].ToString()),
|
|
IsNameHide = string.IsNullOrWhiteSpace(row["name_encrypt_flag"].ToString()) ? 'N' : Convert.ToChar(row["name_encrypt_flag"].ToString()),
|
|
IsPhoneFollow = 'N',
|
|
IsRecoverGuide = string.IsNullOrWhiteSpace(row["recover_form_flag"].ToString()) ? 'N' : Convert.ToChar(row["recover_form_flag"].ToString()),
|
|
IsUpload = string.IsNullOrWhiteSpace(row["upload_flag"].ToString()) ? 'N' : Convert.ToChar(row["upload_flag"].ToString()),
|
|
IsVip = string.IsNullOrWhiteSpace(row["vip_flag"].ToString()) ? 'N' : Convert.ToChar(row["vip_flag"].ToString()),
|
|
JobCardNo = row["job_card_no"].ToString(),
|
|
JobPost = row["job_post"].ToString(),
|
|
JobTitle = row["job_title"].ToString(),
|
|
MedicalCardNo = row["medical_card_no"].ToString(),
|
|
MedicalConclusionId = medicalConclusionId,
|
|
MedicalPackageId = medicalPackageId,
|
|
MedicalStartDate = string.IsNullOrEmpty(row["medical_start_date"].ToString()) ? null : Convert.ToDateTime(row["medical_start_date"].ToString()),
|
|
MedicalTimes = Convert.ToInt16(row["medical_times"].ToString()),
|
|
MedicalTypeId = medicalTypeId,
|
|
PatientId = patientId,
|
|
PatientName = row["name"].ToString(),
|
|
PatientRegisterNo = row["barcode_no"].ToString(),
|
|
PersonnelTypeId = personnelTypeId,
|
|
Photo = photo,
|
|
Remark = row["remark"].ToString(),
|
|
ReportPrintTimes = Convert.ToInt16(row["report_print_times"].ToString()),
|
|
Salesman = row["salesman"].ToString(),
|
|
SexHormoneTermId = null,
|
|
SummaryDate = string.IsNullOrEmpty(row["summary_date"].ToString()) ? null : Convert.ToDateTime(row["summary_date"].ToString()),
|
|
SummaryDoctorId = summaryDoctorId,
|
|
ThirdInfo = row["third_info"].ToString(),
|
|
};
|
|
|
|
await _patientRegisterRepository.InsertAsync(data);
|
|
|
|
|
|
#region 人员登记扩展
|
|
|
|
var patientRegisterExterData = new PatientRegisterExter
|
|
{
|
|
IsQztlImport = Convert.ToChar(row["is_qztl_import"].ToString()),
|
|
PatientRegisterId = patientRegisterId,
|
|
Planuserid = row["planuserid"].ToString(),
|
|
QztlIsCw = Convert.ToChar(row["qztl_is_cw"].ToString()),
|
|
QztlIsCy = Convert.ToChar(row["qztl_is_cy"].ToString()),
|
|
QztlIsFj = Convert.ToChar(row["qztl_is_fj"].ToString()),
|
|
QztlIsGt = Convert.ToChar(row["qztl_is_gt"].ToString()),
|
|
QztlIsMain = Convert.ToChar(row["qztl_is_main"].ToString()),
|
|
QztlIsWh = Convert.ToChar(row["qztl_is_wh"].ToString()),
|
|
QztlType = string.IsNullOrEmpty(row["qztl_type"].ToString()) ? null : Convert.ToChar(row["qztl_type"].ToString()),
|
|
Remark2 = row["remark2"].ToString(),
|
|
Remark3 = row["remark3"].ToString(),
|
|
Remark4 = row["remark4"].ToString(),
|
|
UploadQztlFlag = Convert.ToChar(row["upload_qztl_flag"].ToString())
|
|
};
|
|
|
|
await _patientRegisterExterRepository.InsertAsync(patientRegisterExterData);
|
|
|
|
#endregion
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = patientRegisterId.ToString(),
|
|
OldKeyValue = row["patient_register_id"].ToString(),
|
|
TableName = "patient_register"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{row["patient_register_id"].ToString()}',addtime=getdate(),handlecount+=1 where tablename='patient_register' ");
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
_logger.LogInformation($"人员数据处理{oldPatientRegisterList.Rows.Count}条");
|
|
|
|
await TransferPatientRegisterData();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("人员数据已处理完");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移检查单 组合项目 查询register_asbitem
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferRegisterCheckData()
|
|
{
|
|
//记录patient_register Id
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check'");
|
|
|
|
var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
.Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(1000).ToList();
|
|
|
|
|
|
if (patientRegisterList.Any())
|
|
{
|
|
var userList = await _identityUserRepository.GetListAsync();
|
|
|
|
foreach (var item in patientRegisterList)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
List<RegisterCheck> registerCheckInsert = new List<RegisterCheck>();
|
|
List<RegisterCheckAsbitem> registerCheckAsbitemInsert = new List<RegisterCheckAsbitem>();
|
|
|
|
#region 转换成老系统ID
|
|
string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.Id.ToString()).FirstOrDefault().OldKeyValue;
|
|
#endregion
|
|
|
|
var oldRegisterAsbitemList = await Db.Ado.GetDataTableAsync($"select * from register_asbitem where patient_register_id='{oldPatientRegisterId}'");
|
|
|
|
if (oldRegisterAsbitemList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldRegisterAsbitemList.Rows)
|
|
{
|
|
#region 转换审核医生ID
|
|
Guid? auditorUserId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["audit_doctor"].ToString()))
|
|
{
|
|
var userEnt = userList.Where(m => m.UserName == row["audit_doctor"].ToString().Trim()).FirstOrDefault();
|
|
if (userEnt != null)
|
|
{
|
|
auditorUserId = userEnt.Id;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 转换检查医生ID
|
|
string checkDoctorId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["check_doctor"].ToString()))
|
|
{
|
|
var userEnt = userList.Where(m => m.UserName == row["check_doctor"].ToString().Trim()).FirstOrDefault();
|
|
if (userEnt != null)
|
|
{
|
|
checkDoctorId = userEnt.Id.ToString();
|
|
}
|
|
else
|
|
{
|
|
checkDoctorId = row["check_doctor"].ToString().Trim();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
Guid registerCheckId = GuidGenerator.Create();
|
|
var data = new RegisterCheck(registerCheckId)
|
|
{
|
|
AuditorUserId = auditorUserId,
|
|
AuditTime = string.IsNullOrEmpty(row["audit_date"].ToString()) ? null : Convert.ToDateTime(row["audit_date"].ToString()),
|
|
CheckDate = string.IsNullOrEmpty(row["check_date"].ToString()) ? null : Convert.ToDateTime(row["check_date"].ToString()),
|
|
CheckDoctorId = checkDoctorId,
|
|
CheckRequestNo = "",
|
|
CheckRequestPrintTimes = (short)1,
|
|
CompleteFlag = Convert.ToChar(row["complete_flag"].ToString()),
|
|
CriticalValue = null,
|
|
CriticalValueCreateDate = null,
|
|
CriticalValueFlag = null,
|
|
CriticalValueProcessContent = null,
|
|
CriticalValueProcessDate = null,
|
|
CriticalValueProcessDoctor = null,
|
|
CriticalValueProcessFlag = null,
|
|
IsAudit = string.IsNullOrEmpty(row["audit_flag"].ToString()) ? 'N' : Convert.ToChar(row["audit_flag"].ToString()),
|
|
IsLock = string.IsNullOrEmpty(row["lock_flag"].ToString()) ? 'N' : Convert.ToChar(row["lock_flag"].ToString()),
|
|
PatientRegisterId = item.Id,
|
|
ThirdInfo = row["third_info"].ToString()
|
|
};
|
|
|
|
registerCheckInsert.Add(data);
|
|
|
|
Guid registerCheckAsbitemId = GuidGenerator.Create();
|
|
|
|
#region 转换组合项目ID
|
|
Guid newAsbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
#endregion
|
|
|
|
var dataRegisterAsbitem = new RegisterCheckAsbitem(registerCheckAsbitemId)
|
|
{
|
|
Amount = 1,
|
|
IsCharge = Convert.ToChar(row["charge_flag"].ToString()),
|
|
AsbitemId = newAsbitemId,
|
|
ChargePrice = Convert.ToDecimal(row["price"].ToString()),
|
|
GroupPackageId = null,
|
|
LisRequestId = null,
|
|
PatientRegisterId = item.Id,
|
|
PayTypeFlag = Convert.ToChar(row["payment_mode"].ToString()),
|
|
RegisterCheckId = registerCheckId,
|
|
StandardPrice = Convert.ToDecimal(row["standard_price"].ToString())
|
|
};
|
|
|
|
registerCheckAsbitemInsert.Add(dataRegisterAsbitem);
|
|
}
|
|
}
|
|
|
|
|
|
if (registerCheckInsert.Any())
|
|
await _registerCheckRepository.InsertManyAsync(registerCheckInsert);
|
|
if (registerCheckAsbitemInsert.Any())
|
|
await _registerCheckAsbitemRepository.InsertManyAsync(registerCheckAsbitemInsert);
|
|
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='register_check' ");
|
|
|
|
}
|
|
}
|
|
|
|
await TransferRegisterCheckData();
|
|
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("检查单、登记组合项目已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移明细项目 查询register_item
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferRegisterCheckItemData()
|
|
{
|
|
//记录register_check_asbitem Id
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_item'");
|
|
|
|
var registerCheckAsbitemList = (await _registerCheckAsbitemRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
.Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(1000).ToList();
|
|
|
|
|
|
if (registerCheckAsbitemList.Any())
|
|
{
|
|
|
|
foreach (var item in registerCheckAsbitemList)
|
|
{
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
List<RegisterCheckItem> registerCheckItemInsert = new List<RegisterCheckItem>();
|
|
|
|
#region 转换成老系统PatientRegisterId
|
|
string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.PatientRegisterId.ToString()).FirstOrDefault().OldKeyValue;
|
|
#endregion
|
|
|
|
#region 转换成老系统AsbitemId
|
|
string oldAsbitemId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "asbitem" && m.NewKeyValue == item.AsbitemId.ToString()).FirstOrDefault().OldKeyValue;
|
|
#endregion
|
|
|
|
var oldRegisterCheckItemList = await Db.Ado.GetDataTableAsync($"select * from register_item where patient_register_id='{oldPatientRegisterId}' and asbitem_id='{oldAsbitemId}'");
|
|
|
|
if (oldRegisterCheckItemList.Rows.Count > 0)
|
|
{
|
|
|
|
foreach (DataRow row in oldRegisterCheckItemList.Rows)
|
|
{
|
|
#region 转换项目ID 老转新
|
|
Guid newItemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
#endregion
|
|
|
|
|
|
var data = new RegisterCheckItem
|
|
{
|
|
CheckDate = string.IsNullOrEmpty(row["check_date"].ToString()) ? null : Convert.ToDateTime(row["check_date"].ToString()),
|
|
CriticalValue = null,
|
|
CheckDoctorName = row["check_doctor"].ToString().Trim(),
|
|
CriticalRangeValue = null,
|
|
ItemId = newItemId,
|
|
ReferenceRangeValue = row["reference_range_value"].ToString(),
|
|
RegisterCheckId = item.RegisterCheckId,
|
|
Result = row["result"].ToString(),
|
|
ResultStatusId = _registerCheckItemManager.GetResultStatusId(row["result"].ToString(), row["reference_range_value"].ToString()),
|
|
Unit = row["Unit"].ToString()
|
|
};
|
|
|
|
registerCheckItemInsert.Add(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (registerCheckItemInsert.Any())
|
|
await _registerCheckItemRepository.InsertManyAsync(registerCheckItemInsert);
|
|
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='register_check_item' ");
|
|
}
|
|
}
|
|
|
|
await TransferRegisterCheckItemData();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("明细项目已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移医生小结 查询register_asbitem
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferRegisterCheckSummaryData()
|
|
{
|
|
//记录register_check id
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_summary'");
|
|
|
|
var registerCheckAsbitemList = (from registerCheckQuery in await _registerCheckRepository.GetQueryableAsync()
|
|
join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId
|
|
orderby registerCheckQuery.Id ascending
|
|
where string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0
|
|
select new
|
|
{
|
|
PatientRegisterId = registerCheckQuery.PatientRegisterId,
|
|
RegisterCheckId = registerCheckQuery.Id,
|
|
AsbitemId = registerCheckAsbitemQuery.AsbitemId
|
|
}).ToList();
|
|
|
|
if (registerCheckAsbitemList.Any())
|
|
{
|
|
|
|
foreach (var item in registerCheckAsbitemList)
|
|
{
|
|
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.PatientRegisterId.ToString()).FirstOrDefault().OldKeyValue;
|
|
#endregion
|
|
|
|
#region 转换成老系统AsbitemId
|
|
string oldAsbitemId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "asbitem" && m.NewKeyValue == item.AsbitemId.ToString()).FirstOrDefault().OldKeyValue;
|
|
#endregion
|
|
|
|
var oldSummary = await Db.Ado.GetStringAsync($"select summary from register_asbitem where patient_register_id='{oldPatientRegisterId}' and asbitem_id='{oldAsbitemId}'");
|
|
if (!string.IsNullOrWhiteSpace(oldSummary))
|
|
{
|
|
var data = new RegisterCheckSummary
|
|
{
|
|
RegisterCheckId = item.RegisterCheckId,
|
|
DisplayOrder = 1,
|
|
Summary = oldSummary,
|
|
SummaryFlag = '0'
|
|
};
|
|
|
|
|
|
await _registerCheckSummaryRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.RegisterCheckId}',addtime=getdate(),handlecount+=1 where tablename='register_check_summary' ");
|
|
}
|
|
}
|
|
|
|
await TransferRegisterCheckSummaryData();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("医生小结已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移总检综述 查询patient_register
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferSumSummaryData()
|
|
{
|
|
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='sum_summary'");
|
|
|
|
var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
.Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(1000).ToList();
|
|
|
|
|
|
if (patientRegisterList.Any())
|
|
{
|
|
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 oldSummary = await Db.Ado.GetStringAsync($"select summary from patient_register where patient_register_id='{oldPatientRegisterId}' ");
|
|
|
|
if (!string.IsNullOrWhiteSpace(oldSummary))
|
|
{
|
|
|
|
Guid sumSummaryHeaderId = GuidGenerator.Create();
|
|
|
|
var dataSumSummaryHeader = new SumSummaryHeader(sumSummaryHeaderId)
|
|
{
|
|
DisplayOrder = 1,
|
|
SummaryFlag = '0',
|
|
PatientRegisterId = item.Id,
|
|
SummaryTitle = "."
|
|
};
|
|
|
|
await _sumSummaryHeaderRepository.InsertAsync(dataSumSummaryHeader);
|
|
|
|
Guid sumSummaryContentId = GuidGenerator.Create();
|
|
var dataSumSummaryContent = new SumSummaryContent(sumSummaryContentId)
|
|
{
|
|
DisplayOrder = 1,
|
|
SumSummaryHeaderId = sumSummaryHeaderId,
|
|
SummaryContent = oldSummary
|
|
};
|
|
|
|
await _sumSummaryContentRepository.InsertAsync(dataSumSummaryContent);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='sum_summary' ");
|
|
}
|
|
}
|
|
|
|
await TransferSumSummaryData();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("总检综述已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移总检建议 查询patient_register
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferSumSuggestionData()
|
|
{
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='sum_suggestion'");
|
|
|
|
var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
.Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(1000).ToList();
|
|
|
|
if (patientRegisterList.Any())
|
|
{
|
|
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 oldSuggestion = await Db.Ado.GetStringAsync($"select suggestion from patient_register where patient_register_id='{oldPatientRegisterId}' ");
|
|
|
|
if (!string.IsNullOrWhiteSpace(oldSuggestion))
|
|
{
|
|
|
|
Guid sumSuggestionHeaderId = GuidGenerator.Create();
|
|
|
|
var dataSumSuggestionHeader = new SumSuggestionHeader(sumSuggestionHeaderId)
|
|
{
|
|
DisplayOrder = 1,
|
|
SuggestionFlag = '0',
|
|
PatientRegisterId = item.Id,
|
|
SuggestionTitle = "."
|
|
};
|
|
|
|
await _sumSuggestionHeaderRepository.InsertAsync(dataSumSuggestionHeader);
|
|
|
|
Guid sumSuggestionContentId = GuidGenerator.Create();
|
|
var dataSumSuggestionContent = new SumSuggestionContent(sumSuggestionContentId)
|
|
{
|
|
DisplayOrder = 1,
|
|
SuggestionContent = oldSuggestion,
|
|
SuggestionType = SuggestionTypeFlag.HealthGuidance,
|
|
SumSuggestionHeaderId = sumSuggestionHeaderId
|
|
};
|
|
|
|
await _sumSuggestionContentRepository.InsertAsync(dataSumSuggestionContent);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='sum_suggestion' ");
|
|
}
|
|
}
|
|
|
|
await TransferSumSuggestionData();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("总检建议已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移总症诊断 查询summary_diagnosis
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task TransferSumDiagnosisData()
|
|
{
|
|
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='sum_diagnosis'");
|
|
|
|
var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
.Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(1000).ToList();
|
|
|
|
if (patientRegisterList.Any())
|
|
{
|
|
|
|
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 oldSummaryDiagnosis = await Db.Ado.GetDataTableAsync($"select diagnosis_id from summary_diagnosis where patient_register_id='{oldPatientRegisterId}' order by display_order asc ");
|
|
|
|
if (oldSummaryDiagnosis.Rows.Count > 0)
|
|
{
|
|
//获取建议头
|
|
var sumSuggestionHeaderEnt = await _sumSuggestionHeaderRepository.FirstOrDefaultAsync(m => m.PatientRegisterId == item.Id);
|
|
if (sumSuggestionHeaderEnt != null)
|
|
{
|
|
List<SumDiagnosis> sumDiagnosisInsert = new List<SumDiagnosis>();
|
|
|
|
foreach (DataRow row in oldSummaryDiagnosis.Rows)
|
|
{
|
|
var diagnosisEnt = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
.Where(m => m.TableName == "diagnosis" && m.OldKeyValue == row["diagnosis_id"].ToString()).FirstOrDefault();
|
|
if (diagnosisEnt != null)
|
|
{
|
|
|
|
var dataSumDiagnosis = new SumDiagnosis
|
|
{
|
|
DisplayOrder = oldSummaryDiagnosis.Rows.IndexOf(row) + 1,
|
|
PatientRegisterId = item.Id,
|
|
DiagnosisId = Guid.Parse(diagnosisEnt.NewKeyValue),
|
|
SumSuggestionHeaderId = sumSuggestionHeaderEnt.Id
|
|
};
|
|
|
|
sumDiagnosisInsert.Add(dataSumDiagnosis);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (sumDiagnosisInsert.Any())
|
|
await _sumDiagnosisRepository.InsertManyAsync(sumDiagnosisInsert);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='sum_diagnosis' ");
|
|
}
|
|
}
|
|
|
|
await TransferSumDiagnosisData();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("总症诊断已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 爆改人员登记创建日期跟创建者
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task HandPatientRegisterDoctor()
|
|
{
|
|
|
|
string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='hand_patient_register'");
|
|
|
|
var oldPatientRegisterList = await Db.Ado.GetDataTableAsync($"select top 1000 patient_register_id,register_doctor,register_date from patient_register where patient_register_id>'{nextKeyValue}' order by patient_register_id asc ");
|
|
if (oldPatientRegisterList.Rows.Count > 0)
|
|
{
|
|
var userList = await _identityUserRepository.GetListAsync();
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "patient_register");
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
foreach (DataRow row in oldPatientRegisterList.Rows)
|
|
{
|
|
Guid patientRegisterId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["patient_register_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid registerDoctorId = Guid.Parse("3a11fe49-5719-0e9e-dd44-0c4aff0900b0");
|
|
var registerDoctorEnt = userList.Where(m => m.UserName == row["register_doctor"].ToString().Trim()).FirstOrDefault();
|
|
if (registerDoctorEnt != null)
|
|
{
|
|
registerDoctorId = registerDoctorEnt.Id;
|
|
}
|
|
|
|
|
|
|
|
string sql_update = $"update patient_register set creator_id='{registerDoctorId}',creation_time='{Convert.ToDateTime(row["register_date"]).ToString("yyyy-MM-dd HH:mm:ss")}'";
|
|
|
|
|
|
sql_update += $" where id='{patientRegisterId}' ";
|
|
|
|
await PgNWDb.Ado.ExecuteCommandAsync(sql_update);
|
|
|
|
await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{row["patient_register_id"].ToString()}',addtime=getdate(),handlecount+=1 where tablename='hand_patient_register' ");
|
|
|
|
}
|
|
|
|
await HandPatientRegisterDoctor();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("爆改人员登记创建日期跟创建者已处理完");
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 暂时不用
|
|
///// <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>
|
|
///// 迁移档案数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task TransferPatientData()
|
|
//{
|
|
|
|
|
|
// List<Patient> dataList = new List<Patient>();
|
|
|
|
|
|
|
|
|
|
// var oldPatientList = await Db.Ado.GetDataTableAsync("select top 500 patient_id,nation_id,address," +
|
|
// "birth_date,name,email,id_card_no,marital_status_id,mobile_telephone,patient_password,postalcode,telephone,sex_id " +
|
|
// "from patient_register where is_hand is null order by patient_register_id asc");
|
|
|
|
// List<string> tempPatientNos = new List<string>();
|
|
|
|
// if (oldPatientList.Rows.Count > 0)
|
|
// {
|
|
// List<FieldComparison> fieldComparisons = new List<FieldComparison>();
|
|
// List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "nation");
|
|
|
|
// foreach (DataRow row in oldPatientList.Rows)
|
|
// {
|
|
|
|
// if (!tempPatientNos.Contains(row["patient_id"].ToString()))
|
|
// {
|
|
// string nationId = null;
|
|
// if (!string.IsNullOrWhiteSpace(row["nation_id"].ToString()))
|
|
// {
|
|
|
|
// nationId = fieldComparisonList.Where(m => m.OldKeyValue == row["nation_id"].ToString()).FirstOrDefault().NewKeyValue;
|
|
// }
|
|
|
|
// Guid PatientId = GuidGenerator.Create(); //档案ID
|
|
|
|
// var data = new Patient(PatientId)
|
|
// {
|
|
// Address = row["address"].ToString(),
|
|
// BirthDate = string.IsNullOrEmpty(row["birth_date"].ToString()) ? null : Convert.ToDateTime(row["birth_date"].ToString()),
|
|
// BirthPlaceId = null,
|
|
// DisplayName = row["name"].ToString(),
|
|
// Email = row["email"].ToString(),
|
|
// IdNo = row["id_card_no"].ToString(),
|
|
// MaritalStatusId = Convert.ToChar(row["marital_status_id"].ToString()),
|
|
// MedicalCenterId = defaultMedicalCenterId,
|
|
// MobileTelephone = row["mobile_telephone"].ToString(),
|
|
// NationId = nationId,
|
|
// PatientNo = row["patient_id"].ToString(),
|
|
// PatientPassword = row["patient_password"].ToString(),
|
|
// PostalCode = row["postalcode"].ToString(),
|
|
// SexId = ConvertSex(row["sex_id"].ToString()),
|
|
// SimpleCode = LanguageConverter.GetPYSimpleCode(row["name"].ToString()),
|
|
// Telephone = row["telephone"].ToString()
|
|
// };
|
|
|
|
// dataList.Add(data);
|
|
|
|
// fieldComparisons.Add(new FieldComparison
|
|
// {
|
|
// FieldName = "id",
|
|
// NewKeyValue = PatientId.ToString(),
|
|
// OldKeyValue = row["patient_id"].ToString(),
|
|
// TableName = "patient"
|
|
// });
|
|
|
|
// #region 增加标识
|
|
// veryPatientNo.Add(row["patient_id"].ToString(), row["patient_id"].ToString());
|
|
// #endregion
|
|
// }
|
|
|
|
// tempPatientNos.Add(row["patient_id"].ToString());
|
|
// }
|
|
|
|
// if (dataList.Any())
|
|
// await _patientRepository.InsertManyAsync(dataList);
|
|
// if (fieldComparisons.Any())
|
|
// await _fieldComparisonRepository.InsertManyAsync(fieldComparisons);
|
|
|
|
|
|
// #region 修改状态
|
|
|
|
// Thread.Sleep(100);
|
|
|
|
// await Db.Ado.ExecuteCommandAsync("update patient_register set is_hand='Y' where patient_id in (@ids) ", new { ids = tempPatientNos });
|
|
|
|
// #endregion
|
|
// _logger.LogInformation($"当前时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},迁移数据{dataList.Count}");
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
///// 迁移后台用户数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[RemoteService(false)]
|
|
//public async Task TransferUserData()
|
|
//{
|
|
|
|
// var oldUserList = await Db.Ado.GetDataTableAsync("select * from users");
|
|
// if (oldUserList.Rows.Count > 0)
|
|
// {
|
|
|
|
// foreach (DataRow row in oldUserList.Rows)
|
|
// {
|
|
// var userEnt = new IdentityUserCreateNoEmailDto
|
|
// {
|
|
// Email = "",
|
|
// IsActive = row["valid_flag"].ToString() == "Y" ? true : false,
|
|
// LockoutEnabled = false,
|
|
// Name = row["user_name"].ToString(),
|
|
// Password = row["password"].ToString(),
|
|
// PhoneNumber = "",
|
|
// RoleNames = new string[] { "admin" },
|
|
// Surname = "",
|
|
// UserName = row["user_id"].ToString()
|
|
// };
|
|
|
|
// await _myUserAppService.CreateAsync(userEnt);
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 迁移菜单
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[RemoteService(false)]
|
|
//public async Task TransferMenuInfoData()
|
|
//{
|
|
// var oldMenuInfoList = await PgDb.Ado.GetDataTableAsync("select * from menu_info");
|
|
// if (oldMenuInfoList.Rows.Count > 0)
|
|
// {
|
|
|
|
// List<MenuInfo> dataList = new List<MenuInfo>();
|
|
|
|
// foreach (DataRow menuInfo in oldMenuInfoList.Rows)
|
|
// {
|
|
// var data = new MenuInfo(Guid.Parse(menuInfo["id"].ToString()))
|
|
// {
|
|
// DisplayName = menuInfo["display_name"].ToString(),
|
|
// DisplayOrder = Convert.ToInt32(menuInfo["display_order"].ToString()),
|
|
// IconName = menuInfo["icon_name"].ToString(),
|
|
// IsActive = Convert.ToChar(menuInfo["is_active"].ToString()),
|
|
// MenuType = Convert.ToChar(menuInfo["menu_type"].ToString()),
|
|
// ParentId = !string.IsNullOrWhiteSpace(menuInfo["parent_id"].ToString()) ? Guid.Parse(menuInfo["parent_id"].ToString()) : null,
|
|
// RouteUrl = menuInfo["route_url"].ToString(),
|
|
// SimpleCode = menuInfo["simple_code"].ToString()
|
|
// };
|
|
|
|
// dataList.Add(data);
|
|
|
|
// }
|
|
|
|
// if (dataList.Any())
|
|
// await _menuInfoRepository.InsertManyAsync(dataList);
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
//}
|
|
|
|
|
|
//#region 迁移报表数据
|
|
|
|
///// <summary>
|
|
///// 迁移云端报表数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task TransferReportData()
|
|
//{
|
|
// var oldReportList = await PgDb.Ado.GetDataTableAsync("select id,display_name,is_active from report ");
|
|
|
|
// if (oldReportList.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldReportList.Rows)
|
|
// {
|
|
// Report reportEntity = new Report
|
|
// {
|
|
// DisplayName = row["display_name"].ToString(),
|
|
// IsActive = Convert.ToChar(row["is_active"].ToString())
|
|
// };
|
|
|
|
// reportEntity.SetId(row["id"].ToString());
|
|
|
|
// await _reportRepository.InsertAsync(reportEntity, true);
|
|
|
|
|
|
// }
|
|
// }
|
|
|
|
// var oldReportFormatList = await PgDb.Ado.GetDataTableAsync("select id,display_name,is_default,report_id from report_format ");
|
|
|
|
// if (oldReportFormatList.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldReportFormatList.Rows)
|
|
// {
|
|
// ReportFormat reportFormatEntity = new ReportFormat
|
|
// {
|
|
// DisplayName = row["display_name"].ToString(),
|
|
// IsDefault = Convert.ToChar(row["is_default"].ToString()),
|
|
// ReportId = row["report_id"].ToString()
|
|
// };
|
|
|
|
// reportFormatEntity.SetId(row["id"].ToString());
|
|
|
|
// await _reportFormatRepository.InsertAsync(reportFormatEntity, true);
|
|
|
|
// }
|
|
// }
|
|
|
|
// var oldReportFormatTemplateList = await PgDb.Ado.GetDataTableAsync("select id,display_name,report_format_id,template_file_type,template_file,data_set_json,is_system,is_default from report_format_template ");
|
|
|
|
// if (oldReportFormatTemplateList.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldReportFormatTemplateList.Rows)
|
|
// {
|
|
// ReportFormatTemplate reportFormatTemplateEntity = new ReportFormatTemplate
|
|
// {
|
|
// DisplayName = row["display_name"].ToString(),
|
|
// IsDefault = Convert.ToChar(row["is_default"].ToString()),
|
|
// DataSetJson = row["data_set_json"].ToString(),
|
|
// IsSystem = Convert.ToChar(row["is_system"].ToString()),
|
|
// ReportFormatId = row["report_format_id"].ToString(),
|
|
// TemplateFile = row["template_file"].ToString(),
|
|
// TemplateFileType = Convert.ToChar(row["template_file_type"].ToString())
|
|
// };
|
|
|
|
// reportFormatTemplateEntity.SetId(row["id"].ToString());
|
|
|
|
// await _reportFormatTemplateRepository.InsertAsync(reportFormatTemplateEntity, true);
|
|
|
|
// }
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//#region 迁移系统参数
|
|
|
|
///// <summary>
|
|
///// 迁移系统参数类别数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task TransferSysParmTypeData()
|
|
//{
|
|
// var oldSysParmType = await PgDb.Ado.GetDataTableAsync("select * from sys_parm_type ");
|
|
|
|
|
|
// if (oldSysParmType.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldSysParmType.Rows)
|
|
// {
|
|
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
// {
|
|
// SysParmType data = new SysParmType
|
|
// {
|
|
// Id = row["id"].ToString(),
|
|
// DisplayName = row["display_name"].ToString(),
|
|
// DisplayOrder = Convert.ToInt32(row["display_order"].ToString()),
|
|
// ParentId = row["parent_id"].ToString(),
|
|
// SimpleCode = row["simple_code"].ToString()
|
|
// };
|
|
|
|
// await _sysParmTypeRepository.InsertAsync(data, true);
|
|
|
|
// await uow.CompleteAsync();
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 迁移系统参数数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task TransferSysParmData()
|
|
//{
|
|
// var oldSysParm = await PgDb.Ado.GetDataTableAsync("select * from sys_parm ");
|
|
|
|
|
|
// if (oldSysParm.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldSysParm.Rows)
|
|
// {
|
|
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
// {
|
|
// SysParm data = new SysParm
|
|
// {
|
|
// Id = row["id"].ToString(),
|
|
// DisplayName = row["display_name"].ToString(),
|
|
// DisplayOrder = Convert.ToInt32(row["display_order"].ToString()),
|
|
// IsPublic = Convert.ToChar(row["is_public"].ToString()),
|
|
// Remark = row["remark"].ToString(),
|
|
// ValueType = Convert.ToChar(row["value_type"].ToString()),
|
|
// SysParmTypeId = row["sys_parm_type_id"].ToString(),
|
|
// SimpleCode = row["simple_code"].ToString()
|
|
// };
|
|
|
|
// await _sysParmRepository.InsertAsync(data, true);
|
|
|
|
// await uow.CompleteAsync();
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 迁移系统参数值数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task TransferSysParmValueData()
|
|
//{
|
|
// var oldSysParmValue = await PgDb.Ado.GetDataTableAsync("select * from sys_parm_value where medical_center_id='00000000-0000-0000-0000-000000000000' ");
|
|
|
|
|
|
// if (oldSysParmValue.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldSysParmValue.Rows)
|
|
// {
|
|
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
// {
|
|
// SysParmValue data = new SysParmValue
|
|
// {
|
|
// SysParmId = row["sys_parm_id"].ToString(),
|
|
// Remark = row["remark"].ToString(),
|
|
// MedicalCenterId = Guid.Empty,
|
|
// ParmValue = row["parm_value"].ToString()
|
|
// };
|
|
|
|
// await _sysParmValueRepository.InsertAsync(data, true);
|
|
|
|
// await uow.CompleteAsync();
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//#endregion
|
|
|
|
///// <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_photo'");
|
|
|
|
// var patientRegisterList = (await _patientRegisterRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
// .Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).Take(handcount).ToList();
|
|
|
|
// if (patientRegisterList.Any())
|
|
// {
|
|
|
|
// 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 photograph = await Db.Ado.GetScalarAsync($"select photograph from patient_register where patient_register_id='{oldPatientRegisterId}' ");
|
|
|
|
// #region 上传图片,获取地址
|
|
|
|
// if (photograph != null && !string.IsNullOrEmpty(photograph.ToString()))
|
|
// {
|
|
// string photo = UpLoadImg(item.Id, item.CreationTime, (byte[])photograph);
|
|
|
|
// item.Photo = photo;
|
|
|
|
// 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_photo' ");
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
|
|
|
|
///// <summary>
|
|
///// 纠正登记项目明细数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task CorrectRegisterCheckItemData()
|
|
//{
|
|
// string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_asbitem_2'");
|
|
|
|
// //var registerCheckAsbitemList = (await _registerCheckAsbitemRepository.GetQueryableAsync()).OrderBy(o => o.Id)
|
|
// // .Where(m => string.Compare(m.Id.ToString(), nextKeyValue) > 0).ToList();
|
|
// var registerCheckAsbitemList = (from registerCheckQuery in (await _registerCheckRepository.GetQueryableAsync()).Include(x => x.RegisterCheckItems)
|
|
// join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId
|
|
// orderby registerCheckQuery.Id ascending
|
|
// where (registerCheckQuery.RegisterCheckItems.Count == 0 && string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0)
|
|
// select registerCheckAsbitemQuery).ToList();
|
|
|
|
|
|
|
|
// if (registerCheckAsbitemList.Any())
|
|
// {
|
|
|
|
// foreach (var item in registerCheckAsbitemList)
|
|
// {
|
|
|
|
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
// {
|
|
|
|
// List<RegisterCheckItem> registerCheckItemInsert = new List<RegisterCheckItem>();
|
|
|
|
// #region 转换成老系统PatientRegisterId
|
|
// string oldPatientRegisterId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
// .Where(m => m.TableName == "patient_register" && m.NewKeyValue == item.PatientRegisterId.ToString()).FirstOrDefault().OldKeyValue;
|
|
// #endregion
|
|
|
|
// #region 转换成老系统AsbitemId
|
|
// string oldAsbitemId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
// .Where(m => m.TableName == "asbitem" && m.NewKeyValue == item.AsbitemId.ToString()).FirstOrDefault().OldKeyValue;
|
|
// #endregion
|
|
|
|
// var oldRegisterCheckItemList = await Db.Ado.GetDataTableAsync($"select * from register_item where patient_register_id='{oldPatientRegisterId}' and asbitem_id='{oldAsbitemId}'");
|
|
|
|
// if (oldRegisterCheckItemList.Rows.Count > 0)
|
|
// {
|
|
|
|
// foreach (DataRow row in oldRegisterCheckItemList.Rows)
|
|
// {
|
|
// #region 转换项目ID 老转新
|
|
// Guid newItemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync())
|
|
// .Where(m => m.TableName == "item" && m.OldKeyValue == row["item_id"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
// #endregion
|
|
|
|
|
|
// var data = new RegisterCheckItem
|
|
// {
|
|
// CheckDate = string.IsNullOrEmpty(row["check_date"].ToString()) ? null : Convert.ToDateTime(row["check_date"].ToString()),
|
|
// CriticalValue = null,
|
|
// CheckDoctorName = row["check_doctor"].ToString().Trim(),
|
|
// CriticalRangeValue = null,
|
|
// ItemId = newItemId,
|
|
// ReferenceRangeValue = row["reference_range_value"].ToString(),
|
|
// RegisterCheckId = item.RegisterCheckId,
|
|
// Result = row["result"].ToString(),
|
|
// ResultStatusId = _registerCheckItemManager.GetResultStatusId(row["result"].ToString(), row["reference_range_value"].ToString()),
|
|
// Unit = row["Unit"].ToString()
|
|
// };
|
|
|
|
// registerCheckItemInsert.Add(data);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (registerCheckItemInsert.Any())
|
|
// await _registerCheckItemRepository.InsertManyAsync(registerCheckItemInsert);
|
|
|
|
|
|
// await uow.CompleteAsync();
|
|
|
|
|
|
// await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.Id}',addtime=getdate(),handlecount+=1 where tablename='register_check_asbitem_2' ");
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
///// 纠正医生小结数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public async Task CorrectRegisterCheckSummaryData()
|
|
//{
|
|
// string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='register_check_summary_2'");
|
|
|
|
// //var registerCheckAsbitemList = (from registerCheckQuery in await _registerCheckRepository.GetQueryableAsync()
|
|
// // join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId
|
|
// // orderby registerCheckQuery.Id ascending
|
|
// // where string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0
|
|
// // select new
|
|
// // {
|
|
// // PatientRegisterId = registerCheckQuery.PatientRegisterId,
|
|
// // RegisterCheckId = registerCheckQuery.Id,
|
|
// // AsbitemId = registerCheckAsbitemQuery.AsbitemId
|
|
// // }).ToList();
|
|
|
|
// var registerCheckAsbitemList = (from registerCheckQuery in (await _registerCheckRepository.GetQueryableAsync()).Include(x => x.RegisterCheckSummaries).AsQueryable()
|
|
// join registerCheckAsbitemQuery in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheckQuery.Id equals registerCheckAsbitemQuery.RegisterCheckId
|
|
// orderby registerCheckQuery.Id ascending
|
|
// where (registerCheckQuery.RegisterCheckSummaries.Count == 0 && string.Compare(registerCheckQuery.Id.ToString(), nextKeyValue) > 0)
|
|
// select new
|
|
// {
|
|
// PatientRegisterId = registerCheckQuery.PatientRegisterId,
|
|
// RegisterCheckId = registerCheckQuery.Id,
|
|
// AsbitemId = registerCheckAsbitemQuery.AsbitemId
|
|
// }).ToList();
|
|
// if (registerCheckAsbitemList.Any())
|
|
// {
|
|
|
|
// foreach (var item in registerCheckAsbitemList)
|
|
// {
|
|
// 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.PatientRegisterId.ToString()).FirstOrDefault().OldKeyValue;
|
|
// #endregion
|
|
|
|
// #region 转换成老系统AsbitemId
|
|
// string oldAsbitemId = (await _fieldComparisonRepository.GetQueryableAsync())
|
|
// .Where(m => m.TableName == "asbitem" && m.NewKeyValue == item.AsbitemId.ToString()).FirstOrDefault().OldKeyValue;
|
|
// #endregion
|
|
|
|
// var oldSummary = await Db.Ado.GetStringAsync($"select summary from register_asbitem where patient_register_id='{oldPatientRegisterId}' and asbitem_id='{oldAsbitemId}'");
|
|
// if (!string.IsNullOrWhiteSpace(oldSummary))
|
|
// {
|
|
// var data = new RegisterCheckSummary
|
|
// {
|
|
// RegisterCheckId = item.RegisterCheckId,
|
|
// DisplayOrder = 1,
|
|
// Summary = oldSummary,
|
|
// SummaryFlag = '0'
|
|
// };
|
|
|
|
|
|
// await _registerCheckSummaryRepository.InsertAsync(data);
|
|
|
|
// await uow.CompleteAsync();
|
|
// }
|
|
// await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{item.RegisterCheckId}',addtime=getdate(),handlecount+=1 where tablename='register_check_summary_2' ");
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
private void LoadDLL()
|
|
{
|
|
// 定义dll文件夹路径
|
|
string dllFolderPath = Path.Combine(AppContext.BaseDirectory, "MyPlugs");
|
|
|
|
DirectoryInfo directoryInfo = new DirectoryInfo(dllFolderPath);
|
|
FileInfo[] files = directoryInfo.GetFiles("*.dll", SearchOption.AllDirectories);
|
|
|
|
foreach (FileInfo file in files)
|
|
{
|
|
Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName);
|
|
|
|
Type interfaceType = assembly.GetTypes().Where(m => m.IsInterface == true && m.Name == "ITestHello").FirstOrDefault();
|
|
Type classType = assembly.GetTypes().Where(m => m.IsInterface == false && m.Name == "TestHello").FirstOrDefault();
|
|
|
|
if (interfaceType != null && classType != null)
|
|
{
|
|
object instance = Activator.CreateInstance(classType);
|
|
// 获取方法信息
|
|
MethodInfo method = classType.GetMethod("PrintMsg");
|
|
|
|
// 执行方法
|
|
var ss = method.Invoke(instance, null);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 转换老系统适用性别
|
|
/// </summary>
|
|
/// <param name="forSexId"></param>
|
|
/// <returns></returns>
|
|
private char ConvertForSex(string forSexId)
|
|
{
|
|
if (forSexId == "0")
|
|
{
|
|
return 'M';
|
|
}
|
|
else if (forSexId == "1")
|
|
{
|
|
return 'F';
|
|
}
|
|
else
|
|
{
|
|
return 'A';
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 转换老系统性别
|
|
/// </summary>
|
|
/// <param name="SexId"></param>
|
|
/// <returns></returns>
|
|
private char ConvertSex(string SexId)
|
|
{
|
|
if (SexId == "0")
|
|
{
|
|
return 'M';
|
|
}
|
|
else if (SexId == "1")
|
|
{
|
|
return 'F';
|
|
}
|
|
else
|
|
{
|
|
return 'U';
|
|
}
|
|
}
|
|
|
|
private string UpLoadImg(Guid PatientRegisterId, DateTime time, byte[] Photo)
|
|
{
|
|
string imgurl = $"photo/{time.Year}/{time.Month}/{time.Day}/" + PatientRegisterId;
|
|
var isupload = ImageHelper.ByteToImage(Photo, imgurl);
|
|
if (!string.IsNullOrEmpty(isupload))
|
|
return isupload;
|
|
else
|
|
return "";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|