|
|
|
@ -36,6 +36,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
private CustomerOrgRegisterDto _customerOrgRegisterDto; |
|
|
|
private List<PersonnelTypeDto> _personnelTypes; |
|
|
|
private List<CustomerOrgGroupDto> _customerOrgGroupDtos; |
|
|
|
private Guid _customerOrgRegisterId; |
|
|
|
private string _answerWebApiUrl; |
|
|
|
|
|
|
|
public ImportPatientRegisterPlugInsQztl(Guid thirdInterfaceId) : base(thirdInterfaceId) |
|
|
|
@ -48,54 +49,71 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override async Task ImportAsync() |
|
|
|
public override async Task<List<string>> ImportAsync(Guid customerOrgRegisterId) |
|
|
|
{ |
|
|
|
_customerOrgRegisterId = customerOrgRegisterId; |
|
|
|
if(_customerOrgRegisterId == Guid.Empty) |
|
|
|
{ |
|
|
|
throw new Exception("customerOrgRegisterId参数不能为空"); |
|
|
|
} |
|
|
|
await LoginAsync(); |
|
|
|
await InitAsync(); |
|
|
|
|
|
|
|
var errorList = new List<string>(); |
|
|
|
var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); |
|
|
|
if (qztlPatientRegisterFromInterface == null) |
|
|
|
{ |
|
|
|
return; |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
//删除人员
|
|
|
|
if(qztlPatientRegisterFromInterface.delIds != null) |
|
|
|
if (qztlPatientRegisterFromInterface.delIds != null) |
|
|
|
{ |
|
|
|
foreach (var deleteUserId in qztlPatientRegisterFromInterface.delIds) |
|
|
|
{ |
|
|
|
var patientRegister = await GetPatientRegisterByPlanUserId(deleteUserId); |
|
|
|
if (patientRegister == null) |
|
|
|
var error = deleteUserId; |
|
|
|
try |
|
|
|
{ |
|
|
|
continue; |
|
|
|
|
|
|
|
var patientRegister = await GetPatientRegisterByPlanUserId(deleteUserId); |
|
|
|
if (patientRegister == null) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (patientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration && |
|
|
|
patientRegister.CompleteFlag != PatientRegisterCompleteFlag.Registration) |
|
|
|
{ |
|
|
|
//已检人员不允许删除
|
|
|
|
continue; |
|
|
|
} |
|
|
|
var patientRegisterInputDto = new PatientRegisterIdInputDto() |
|
|
|
{ |
|
|
|
PatientRegisterId = patientRegister.PatientRegisterId |
|
|
|
}; |
|
|
|
await CallAppServiceAsync<PatientRegisterIdInputDto, object>( |
|
|
|
"api/app/PatientRegister/DeleteById", patientRegisterInputDto); |
|
|
|
//发送答复通知
|
|
|
|
var succesIds = new List<string>(); |
|
|
|
var deleteIds = new List<string>(); |
|
|
|
deleteIds.Add(deleteUserId); |
|
|
|
await AnswerOk(succesIds, deleteIds); |
|
|
|
} |
|
|
|
if (patientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration && |
|
|
|
patientRegister.CompleteFlag != PatientRegisterCompleteFlag.Registration) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
//已检人员不允许删除
|
|
|
|
errorList.Add(error + ex.Message); |
|
|
|
continue; |
|
|
|
} |
|
|
|
var patientRegisterInputDto = new PatientRegisterIdInputDto() |
|
|
|
{ |
|
|
|
PatientRegisterId = patientRegister.PatientRegisterId |
|
|
|
}; |
|
|
|
await CallAppServiceAsync<PatientRegisterIdInputDto, object>( |
|
|
|
"api/app/PatientRegister/DeleteById", patientRegisterInputDto); |
|
|
|
//发送答复通知
|
|
|
|
var succesIds = new List<string>(); |
|
|
|
var deleteIds = new List<string>(); |
|
|
|
deleteIds.Add(deleteUserId); |
|
|
|
await AnswerOk(succesIds, deleteIds); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (qztlPatientRegisterFromInterface.plans == null) |
|
|
|
{ |
|
|
|
return; |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
//设置导入人员信息
|
|
|
|
foreach (var patient in qztlPatientRegisterFromInterface.plans) |
|
|
|
{ |
|
|
|
var error = $"姓名:{patient.personName},身份证:{patient.cardId}"; |
|
|
|
try |
|
|
|
{ |
|
|
|
//婚姻状况
|
|
|
|
@ -177,7 +195,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
_customerOrgGroupDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDto>>( |
|
|
|
"api/app/customer-org-group/in-customer-org-id/" + _importCustomerOrgId.ToString() |
|
|
|
, Guid.Empty, "get"); |
|
|
|
customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); |
|
|
|
customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); |
|
|
|
if (customerOrgGroupDto == null) |
|
|
|
{ |
|
|
|
throw new Exception("没有复检这个分组"); |
|
|
|
@ -237,7 +255,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
IsNoPlanUserIdComplete = true; |
|
|
|
} |
|
|
|
//已经登记了该PlanUserId的不再登记
|
|
|
|
if(!string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.Planuserid == patient.id.ToString()) |
|
|
|
if (!string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.Planuserid == patient.id.ToString()) |
|
|
|
{ |
|
|
|
await AnswerOk(succesIds, deleteIds); |
|
|
|
IsNoPlanUserIdComplete = true; |
|
|
|
@ -346,24 +364,32 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
|
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
if (ex.Message.Contains("人员信息姓名和性别和原来的信息都不一致") || |
|
|
|
ex.Message.Contains("身份证号解析出的性别与填入的性别不一致")) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
errorList.Add(error + ",错误信息:"+ex.Message); |
|
|
|
continue; |
|
|
|
//throw new Exception(error + ex.Message);
|
|
|
|
//if (ex.Message.Contains("人员信息姓名和性别和原来的信息都不一致") ||
|
|
|
|
// ex.Message.Contains("身份证号解析出的性别与填入的性别不一致"))
|
|
|
|
//{
|
|
|
|
// continue;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// throw ex;
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return errorList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public async Task InitAsync() |
|
|
|
{ |
|
|
|
if (_customerOrgRegisterId == Guid.Empty) |
|
|
|
{ |
|
|
|
throw new Exception("customerOrgRegisterId参数不能为空"); |
|
|
|
} |
|
|
|
var customerOrgIdStr = InterfaceConfig.GetSection("Interface").GetSection("单位编号").Value; |
|
|
|
_hospitalId = InterfaceConfig.GetSection("Interface").GetSection("HospitalId").Value; |
|
|
|
_aesKEY = InterfaceConfig.GetSection("Interface").GetSection("aesKEY").Value; |
|
|
|
@ -372,6 +398,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (!Guid.TryParse(customerOrgIdStr, out _importCustomerOrgId)) |
|
|
|
{ |
|
|
|
throw new Exception("单位编号不正确"); |
|
|
|
@ -388,20 +415,20 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
{ |
|
|
|
string sql; |
|
|
|
sql = @"
|
|
|
|
SELECT id as customer_org_id, |
|
|
|
display_name as customer_org_name, |
|
|
|
parent_id , |
|
|
|
path_code |
|
|
|
from |
|
|
|
customer_org |
|
|
|
where id = @CustomerOrgId |
|
|
|
SELECT customer_org.id as customer_org_id, |
|
|
|
customer_org.display_name as customer_org_name, |
|
|
|
customer_org.parent_id as parent_id, |
|
|
|
customer_org.path_code as path_code |
|
|
|
from customer_org ,customer_org_register |
|
|
|
where customer_org.id = customer_org_register.customer_org_id and |
|
|
|
customer_org_register.id = @CustomerOrgRegisterId |
|
|
|
";
|
|
|
|
var customerOrgForPlugInss = (await conn.QueryAsync<CustomerOrgForPlugIns>(sql, |
|
|
|
new { CustomerOrgId = _importCustomerOrgId })).FirstOrDefault(); |
|
|
|
new { CustomerOrgRegisterId = _customerOrgRegisterId })).FirstOrDefault(); |
|
|
|
|
|
|
|
if (customerOrgForPlugInss == null) |
|
|
|
{ |
|
|
|
throw new Exception("单位编号不正确,找不到单位"); |
|
|
|
throw new Exception("单位登记次数不正确,找不到单位"); |
|
|
|
} |
|
|
|
|
|
|
|
var year = customerOrgForPlugInss.CustomerOrgName.Substring( |
|
|
|
@ -417,6 +444,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
} |
|
|
|
|
|
|
|
_year = year; |
|
|
|
_importCustomerOrgId = customerOrgForPlugInss.CustomerOrgId; |
|
|
|
} |
|
|
|
//加载单位信息
|
|
|
|
_customerOrgDto = await CallAppServiceAsync<CustomerOrgIdInputDto, CustomerOrgDto>( |
|
|
|
@ -425,10 +453,10 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
CustomerOrgId = _importCustomerOrgId, |
|
|
|
}); |
|
|
|
//加载单位登记信息
|
|
|
|
_customerOrgRegisterDto = await CallAppServiceAsync<CustomerOrgIdInputDto, CustomerOrgRegisterDto>( |
|
|
|
"api/app/CustomerOrgRegister/GetLastCustomerOrgRegisterByCustomerOrgId", new CustomerOrgIdInputDto() |
|
|
|
_customerOrgRegisterDto = await CallAppServiceAsync<CustomerOrgRegisterIdInputDto, CustomerOrgRegisterDto>( |
|
|
|
"api/app/CustomerOrgRegister/GetById", new CustomerOrgRegisterIdInputDto() |
|
|
|
{ |
|
|
|
CustomerOrgId = _importCustomerOrgId, |
|
|
|
CustomerOrgRegisterId = _customerOrgRegisterId, |
|
|
|
}); |
|
|
|
//加载人员类别列表
|
|
|
|
_personnelTypes = await CallAppServiceAsync<string, List<PersonnelTypeDto>>("api/app/PersonnelType/GetAll", ""); |
|
|
|
@ -454,7 +482,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
} |
|
|
|
public async Task<PatientRegisterQztl> GetPatientRegisterByPlanUserId(string planUserId) |
|
|
|
{ |
|
|
|
if(string.IsNullOrWhiteSpace(planUserId)) |
|
|
|
if (string.IsNullOrWhiteSpace(planUserId)) |
|
|
|
{ |
|
|
|
throw new Exception("planUserId不能为空"); |
|
|
|
} |
|
|
|
|