|
|
|
@ -54,11 +54,45 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
await InitAsync(); |
|
|
|
|
|
|
|
var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); |
|
|
|
if (qztlPatientRegisterFromInterface == null || !qztlPatientRegisterFromInterface.plans.Any()) |
|
|
|
if (qztlPatientRegisterFromInterface == null) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
//删除人员
|
|
|
|
if(qztlPatientRegisterFromInterface.delIds != null) |
|
|
|
{ |
|
|
|
foreach (var deleteUserId in qztlPatientRegisterFromInterface.delIds) |
|
|
|
{ |
|
|
|
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 (qztlPatientRegisterFromInterface.plans == null) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
//设置导入人员信息
|
|
|
|
foreach (var patient in qztlPatientRegisterFromInterface.plans) |
|
|
|
{ |
|
|
|
@ -186,6 +220,33 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
} |
|
|
|
customerOrgGroupDto = await GetCustomerOrgGroup(groupNames, sexId, maritalStatusId); |
|
|
|
} |
|
|
|
//没有planuserid的自动设置planuserid
|
|
|
|
var patientRegisters = await GetPatientRegisterByCustomerOrgRegisterIdWithIdNo(_customerOrgRegisterDto.Id, patient.cardId); |
|
|
|
var succesIds = new List<string>(); |
|
|
|
var deleteIds = new List<string>(); |
|
|
|
succesIds.Add(patient.id.ToString()); |
|
|
|
bool IsNoPlanUserIdComplete = false; |
|
|
|
foreach (var patintRegister in patientRegisters) |
|
|
|
{ |
|
|
|
//没有planUserId的更新planUserId
|
|
|
|
if (string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.PatientName == patient.personName) |
|
|
|
{ |
|
|
|
await UpdatePatientRegisterPlanUserId(patintRegister.PatientRegisterId, patient.id.ToString()); |
|
|
|
|
|
|
|
await AnswerOk(succesIds, deleteIds); |
|
|
|
IsNoPlanUserIdComplete = true; |
|
|
|
} |
|
|
|
//已经登记了该PlanUserId的不再登记
|
|
|
|
if(!string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.Planuserid == patient.id.ToString()) |
|
|
|
{ |
|
|
|
await AnswerOk(succesIds, deleteIds); |
|
|
|
IsNoPlanUserIdComplete = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (IsNoPlanUserIdComplete) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
//获取病人ID
|
|
|
|
|
|
|
|
var patientRegister = new CreatePatientRegisterDto() |
|
|
|
@ -259,7 +320,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
, Guid.Empty, "get"); |
|
|
|
if (!customerOrgGroupDetailOrAsbitemDtos.Any()) |
|
|
|
{ |
|
|
|
throw new Exception("分组未包含项目"); |
|
|
|
throw new Exception($"分组{customerOrgGroupDto.DisplayName}未包含项目"); |
|
|
|
} |
|
|
|
foreach (var asbitem in customerOrgGroupDetailOrAsbitemDtos) |
|
|
|
{ |
|
|
|
@ -277,9 +338,9 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
"api/PatientRegister/CreatePatientRegister", |
|
|
|
patientRegister); |
|
|
|
|
|
|
|
var succesIds = new List<string>(); |
|
|
|
var deleteIds = new List<string>(); |
|
|
|
succesIds.Add(patientRegister.Planuserid); |
|
|
|
//var succesIds = new List<string>();
|
|
|
|
//var deleteIds = new List<string>();
|
|
|
|
//succesIds.Add(patientRegister.Planuserid);
|
|
|
|
await AnswerOk(succesIds, deleteIds); |
|
|
|
} |
|
|
|
|
|
|
|
@ -380,16 +441,53 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl |
|
|
|
string sql; |
|
|
|
sql = @"
|
|
|
|
SELECT * |
|
|
|
from patient_register,patient_register_exter |
|
|
|
where patient_register.patient_register_id = patient_register_exter.patient_register_id and |
|
|
|
from patient_register,patient_register_exter,patient |
|
|
|
where patient_register.id = patient_register_exter.patient_register_id and |
|
|
|
patient_register.patient_id = patient.id and |
|
|
|
customer_org_register_id =@CustomerOrgRegisterId and |
|
|
|
id_no =@IdNo |
|
|
|
patient.id_no =@IdNo |
|
|
|
";
|
|
|
|
var patientRegisters = (await conn.QueryAsync<PatientRegisterQztl>(sql, |
|
|
|
new { CustomerOrgRegisterId = customerOrgRegisterId, IdNo = idNo })).ToList(); |
|
|
|
return patientRegisters; |
|
|
|
} |
|
|
|
} |
|
|
|
public async Task<PatientRegisterQztl> GetPatientRegisterByPlanUserId(string planUserId) |
|
|
|
{ |
|
|
|
if(string.IsNullOrWhiteSpace(planUserId)) |
|
|
|
{ |
|
|
|
throw new Exception("planUserId不能为空"); |
|
|
|
} |
|
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|
|
|
{ |
|
|
|
string sql; |
|
|
|
sql = @"
|
|
|
|
SELECT * |
|
|
|
from patient_register,patient_register_exter |
|
|
|
where patient_register.id = patient_register_exter.patient_register_id and |
|
|
|
patient_register_exter.planuserid =@PlanUserId |
|
|
|
";
|
|
|
|
var patientRegisters = (await conn.QueryAsync<PatientRegisterQztl>(sql, |
|
|
|
new { PlanUserId = planUserId })).FirstOrDefault(); |
|
|
|
return patientRegisters; |
|
|
|
} |
|
|
|
} |
|
|
|
public async Task UpdatePatientRegisterPlanUserId(Guid patientRegisterId, string planUserid) |
|
|
|
{ |
|
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|
|
|
{ |
|
|
|
string sql; |
|
|
|
sql = @"
|
|
|
|
update patient_register_exter |
|
|
|
set planuserid =@Planuserid |
|
|
|
where patient_register_id=@PatientRegisterId |
|
|
|
";
|
|
|
|
conn.Execute(sql, new { PatientRegisterId = patientRegisterId, Planuserid = planUserid }); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<QztlPatientRegisterFromInterface?> CallInterfaceServiceAsync() |
|
|
|
{ |
|
|
|
string baseAddress = InterfaceWebApiUrl; |
|
|
|
|