|
|
|
@ -103,6 +103,163 @@ namespace Shentun.Peis.OccupationalDiseases |
|
|
|
_poisonRepository = poisonRepository; |
|
|
|
} |
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// 创建职业病信息
|
|
|
|
///// </summary>
|
|
|
|
///// <returns></returns>
|
|
|
|
//[HttpPost("api/app/OccupationalDisease/CreateOccupationalDiseaseWithDetail")]
|
|
|
|
//public async Task<OccupationalDiseaseWithDetailByPatientRegisterIdDto> CreateOccupationalDiseaseWithDetailAsync(OccupationalDiseaseWithDetailInputDto input)
|
|
|
|
//{
|
|
|
|
// if (input == null)
|
|
|
|
// {
|
|
|
|
// throw new UserFriendlyException("请求参数有误");
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (input.PatientRegisterId == Guid.Empty)
|
|
|
|
// throw new UserFriendlyException("人员ID不正确");
|
|
|
|
|
|
|
|
// #region 基础信息
|
|
|
|
// if (input.PatientOccupationalDisease == null)
|
|
|
|
// throw new UserFriendlyException("职业病基础信息有误");
|
|
|
|
|
|
|
|
// var patientOccupationalDiseaseInput = ObjectMapper.Map<PatientOccupationalDiseaseInputDto, PatientOccupationalDisease>(input.PatientOccupationalDisease);
|
|
|
|
|
|
|
|
// patientOccupationalDiseaseInput.PatientRegisterId = input.PatientRegisterId;
|
|
|
|
|
|
|
|
// var patientOccupationalDiseaseEnt = await _patientOccupationalDiseaseRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId);
|
|
|
|
// if (patientOccupationalDiseaseEnt == null)
|
|
|
|
// {
|
|
|
|
|
|
|
|
// var entity = _patientOccupationalDiseaseManager.CreateAsync(patientOccupationalDiseaseInput);
|
|
|
|
// await _patientOccupationalDiseaseRepository.InsertAsync(entity, true);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// _patientOccupationalDiseaseManager.UpdateAsync(patientOccupationalDiseaseInput, patientOccupationalDiseaseEnt);
|
|
|
|
// await _patientOccupationalDiseaseRepository.UpdateAsync(patientOccupationalDiseaseEnt, true);
|
|
|
|
// }
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// #region 毒害因素
|
|
|
|
|
|
|
|
// var patientPoisonsInput = ObjectMapper.Map<List<PatientPoisonInputDto>, List<PatientPoison>>(input.PatientPoisons);
|
|
|
|
// await _patientPoisonRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId);
|
|
|
|
// List<PatientPoison> patientPoisonList = new List<PatientPoison>();
|
|
|
|
// foreach (var item in patientPoisonsInput)
|
|
|
|
// {
|
|
|
|
// if (patientPoisonList.Select(s => s.PoisonId).Contains(item.PoisonId))
|
|
|
|
// {
|
|
|
|
// string errPoisonName = "";
|
|
|
|
// var errPoison = await _poisonRepository.FirstOrDefaultAsync(f => f.Id == item.PoisonId);
|
|
|
|
// if (errPoison != null)
|
|
|
|
// errPoisonName = errPoison.DisplayName;
|
|
|
|
// throw new UserFriendlyException($"接害因素{errPoisonName}不能重复选择");
|
|
|
|
// }
|
|
|
|
// patientPoisonList.Add(new PatientPoison
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = input.PatientRegisterId,
|
|
|
|
// PoisonId = item.PoisonId,
|
|
|
|
// OccupationalAbnormalId = item.OccupationalAbnormalId
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await _patientPoisonRepository.InsertManyAsync(patientPoisonList, true);
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// #region 症状
|
|
|
|
|
|
|
|
// var patientSymptomsInput = ObjectMapper.Map<List<PatientSymptomInputDto>, List<PatientSymptom>>(input.PatientSymptoms);
|
|
|
|
// await _patientSymptomRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId);
|
|
|
|
// List<PatientSymptom> patientSymptomList = new List<PatientSymptom>();
|
|
|
|
// foreach (var item in patientSymptomsInput)
|
|
|
|
// {
|
|
|
|
// patientSymptomList.Add(new PatientSymptom
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = input.PatientRegisterId,
|
|
|
|
// Degree = item.Degree,
|
|
|
|
// SymptomId = item.SymptomId,
|
|
|
|
// TimeLength = item.TimeLength
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await _patientSymptomRepository.InsertManyAsync(patientSymptomList, true);
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// #region 职业病史
|
|
|
|
|
|
|
|
// var patientOccupationalMedicalHistorysInput = ObjectMapper.Map<List<PatientOccupationalMedicalHistoryInputDto>, List<PatientOccupationalMedicalHistory>>(input.PatientOccupationalMedicalHistorys);
|
|
|
|
// await _patientOccupationalMedicalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId);
|
|
|
|
// List<PatientOccupationalMedicalHistory> patientOccupationalMedicalHistoryList = new List<PatientOccupationalMedicalHistory>();
|
|
|
|
// foreach (var item in patientOccupationalMedicalHistorysInput)
|
|
|
|
// {
|
|
|
|
// patientOccupationalMedicalHistoryList.Add(new PatientOccupationalMedicalHistory
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = input.PatientRegisterId,
|
|
|
|
// DiagnosisDate = item.DiagnosisDate,
|
|
|
|
// DiagnosisHospital = item.DiagnosisHospital,
|
|
|
|
// IsRecovery = item.IsRecovery,
|
|
|
|
// OccupationalDisease = item.OccupationalDisease,
|
|
|
|
// TreatmentMethods = item.TreatmentMethods
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await _patientOccupationalMedicalHistoryRepository.InsertManyAsync(patientOccupationalMedicalHistoryList, true);
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// #region 既往病史
|
|
|
|
|
|
|
|
// var patientPastMedicalHistorysInput = ObjectMapper.Map<List<PatientPastMedicalHistoryInputDto>, List<PatientPastMedicalHistory>>(input.PatientPastMedicalHistorys);
|
|
|
|
// await _patientPastMedicalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId);
|
|
|
|
// List<PatientPastMedicalHistory> PatientPastMedicalHistoryList = new List<PatientPastMedicalHistory>();
|
|
|
|
// foreach (var item in patientPastMedicalHistorysInput)
|
|
|
|
// {
|
|
|
|
// PatientPastMedicalHistoryList.Add(new PatientPastMedicalHistory
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = input.PatientRegisterId,
|
|
|
|
// DiagnosisDate = item.DiagnosisDate,
|
|
|
|
// DiagnosisHospital = item.DiagnosisHospital,
|
|
|
|
// IsRecovery = item.IsRecovery,
|
|
|
|
// OccupationalDisease = item.OccupationalDisease,
|
|
|
|
// TreatmentMethods = item.TreatmentMethods
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await _patientPastMedicalHistoryRepository.InsertManyAsync(PatientPastMedicalHistoryList, true);
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// #region 职业史
|
|
|
|
|
|
|
|
// var patientOccupationalHistorysInput = ObjectMapper.Map<List<PatientOccupationalHistoryInputDto>, List<PatientOccupationalHistory>>(input.PatientOccupationalHistorys);
|
|
|
|
// await _patientOccupationalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId);
|
|
|
|
// List<PatientOccupationalHistory> patientOccupationalHistoryList = new List<PatientOccupationalHistory>();
|
|
|
|
// foreach (var item in patientOccupationalHistorysInput)
|
|
|
|
// {
|
|
|
|
// patientOccupationalHistoryList.Add(new PatientOccupationalHistory
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = input.PatientRegisterId,
|
|
|
|
// BeginDate = item.BeginDate,
|
|
|
|
// EndDate = item.EndDate,
|
|
|
|
// Org = item.Org,
|
|
|
|
// Poison = item.Poison,
|
|
|
|
// ProtectiveMeasures = item.ProtectiveMeasures,
|
|
|
|
// WorkShop = item.WorkShop,
|
|
|
|
// WorkType = item.WorkType
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await _patientOccupationalHistoryRepository.InsertManyAsync(patientOccupationalHistoryList, true);
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// return await GetOccupationalDiseaseWithDetailByPatientRegisterIdAsync(new PatientRegisterIdInputDto
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = input.PatientRegisterId
|
|
|
|
// });
|
|
|
|
//}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建职业病信息
|
|
|
|
/// </summary>
|
|
|
|
@ -119,139 +276,253 @@ namespace Shentun.Peis.OccupationalDiseases |
|
|
|
throw new UserFriendlyException("人员ID不正确"); |
|
|
|
|
|
|
|
#region 基础信息
|
|
|
|
if (input.PatientOccupationalDisease == null) |
|
|
|
throw new UserFriendlyException("职业病基础信息有误"); |
|
|
|
|
|
|
|
var patientOccupationalDiseaseInput = ObjectMapper.Map<PatientOccupationalDiseaseInputDto, PatientOccupationalDisease>(input.PatientOccupationalDisease); |
|
|
|
if (input.IsPatientOccupationalDiseaseUpdate == 'Y') |
|
|
|
{ |
|
|
|
if (input.PatientOccupationalDisease == null) |
|
|
|
throw new UserFriendlyException("职业病基础信息有误"); |
|
|
|
|
|
|
|
patientOccupationalDiseaseInput.PatientRegisterId = input.PatientRegisterId; |
|
|
|
var patientOccupationalDiseaseInput = ObjectMapper.Map<PatientOccupationalDiseaseInputDto, PatientOccupationalDisease>(input.PatientOccupationalDisease); |
|
|
|
|
|
|
|
var patientOccupationalDiseaseEnt = await _patientOccupationalDiseaseRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId); |
|
|
|
if (patientOccupationalDiseaseEnt == null) |
|
|
|
{ |
|
|
|
patientOccupationalDiseaseInput.PatientRegisterId = input.PatientRegisterId; |
|
|
|
|
|
|
|
var entity = _patientOccupationalDiseaseManager.CreateAsync(patientOccupationalDiseaseInput); |
|
|
|
await _patientOccupationalDiseaseRepository.InsertAsync(entity, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_patientOccupationalDiseaseManager.UpdateAsync(patientOccupationalDiseaseInput, patientOccupationalDiseaseEnt); |
|
|
|
await _patientOccupationalDiseaseRepository.UpdateAsync(patientOccupationalDiseaseEnt, true); |
|
|
|
var patientOccupationalDiseaseEnt = await _patientOccupationalDiseaseRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId); |
|
|
|
if (patientOccupationalDiseaseEnt == null) |
|
|
|
{ |
|
|
|
|
|
|
|
var entity = _patientOccupationalDiseaseManager.CreateAsync(patientOccupationalDiseaseInput); |
|
|
|
await _patientOccupationalDiseaseRepository.InsertAsync(entity, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_patientOccupationalDiseaseManager.UpdateAsync(patientOccupationalDiseaseInput, patientOccupationalDiseaseEnt); |
|
|
|
await _patientOccupationalDiseaseRepository.UpdateAsync(patientOccupationalDiseaseEnt, true); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 毒害因素
|
|
|
|
|
|
|
|
var patientPoisonsInput = ObjectMapper.Map<List<PatientPoisonInputDto>, List<PatientPoison>>(input.PatientPoisons); |
|
|
|
await _patientPoisonRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<PatientPoison> patientPoisonList = new List<PatientPoison>(); |
|
|
|
foreach (var item in patientPoisonsInput) |
|
|
|
if (input.IsPatientPoisonsUpdate == 'Y') |
|
|
|
{ |
|
|
|
if (patientPoisonList.Select(s => s.PoisonId).Contains(item.PoisonId)) |
|
|
|
var patientPoisonsInput = ObjectMapper.Map<List<PatientPoisonInputDto>, List<PatientPoison>>(input.PatientPoisons); |
|
|
|
//当前数据
|
|
|
|
List<PatientPoison> patientPoisonList = await _patientPoisonRepository.GetListAsync(m => m.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<Guid> newPoisonIds = new List<Guid>(); //新数据
|
|
|
|
foreach (var item in patientPoisonsInput) |
|
|
|
{ |
|
|
|
string errPoisonName = ""; |
|
|
|
var errPoison = await _poisonRepository.FirstOrDefaultAsync(f => f.Id == item.PoisonId); |
|
|
|
if (errPoison != null) |
|
|
|
errPoisonName = errPoison.DisplayName; |
|
|
|
throw new UserFriendlyException($"接害因素{errPoisonName}不能重复选择"); |
|
|
|
newPoisonIds.Add(item.PoisonId); |
|
|
|
|
|
|
|
var isPatientPoison = await _patientPoisonRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId && f.PoisonId == item.PoisonId); |
|
|
|
if (isPatientPoison == null) |
|
|
|
{ |
|
|
|
var patientPoisonEnt = new PatientPoison |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
PoisonId = item.PoisonId, |
|
|
|
OccupationalAbnormalId = item.OccupationalAbnormalId |
|
|
|
}; |
|
|
|
|
|
|
|
await _patientPoisonRepository.InsertAsync(patientPoisonEnt, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
isPatientPoison.OccupationalAbnormalId = item.OccupationalAbnormalId; |
|
|
|
|
|
|
|
await _patientPoisonRepository.UpdateAsync(isPatientPoison, true); |
|
|
|
} |
|
|
|
} |
|
|
|
patientPoisonList.Add(new PatientPoison |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
PoisonId = item.PoisonId, |
|
|
|
OccupationalAbnormalId = item.OccupationalAbnormalId |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
await _patientPoisonRepository.InsertManyAsync(patientPoisonList, true); |
|
|
|
//需要删除的数据
|
|
|
|
var deletePatientPoisonList = patientPoisonList.Where(m => !newPoisonIds.Contains(m.PoisonId)).ToList(); |
|
|
|
await _patientPoisonRepository.DeleteManyAsync(deletePatientPoisonList); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 症状
|
|
|
|
|
|
|
|
var patientSymptomsInput = ObjectMapper.Map<List<PatientSymptomInputDto>, List<PatientSymptom>>(input.PatientSymptoms); |
|
|
|
await _patientSymptomRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<PatientSymptom> patientSymptomList = new List<PatientSymptom>(); |
|
|
|
foreach (var item in patientSymptomsInput) |
|
|
|
if (input.IsPatientSymptomsUpdate == 'Y') |
|
|
|
{ |
|
|
|
patientSymptomList.Add(new PatientSymptom |
|
|
|
var patientSymptomsInput = ObjectMapper.Map<List<PatientSymptomInputDto>, List<PatientSymptom>>(input.PatientSymptoms); |
|
|
|
//当前数据
|
|
|
|
List<PatientSymptom> patientSymptomList = await _patientSymptomRepository.GetListAsync(m => m.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<Guid> newSymptomIds = new List<Guid>(); //新数据
|
|
|
|
|
|
|
|
foreach (var item in patientSymptomsInput) |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
Degree = item.Degree, |
|
|
|
SymptomId = item.SymptomId, |
|
|
|
TimeLength = item.TimeLength |
|
|
|
}); |
|
|
|
} |
|
|
|
newSymptomIds.Add(item.SymptomId); |
|
|
|
var isPatientSymptom = await _patientSymptomRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId && f.SymptomId == item.SymptomId); |
|
|
|
if (isPatientSymptom == null) |
|
|
|
{ |
|
|
|
var patientSymptomEnt = new PatientSymptom |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
Degree = item.Degree, |
|
|
|
SymptomId = item.SymptomId, |
|
|
|
TimeLength = item.TimeLength |
|
|
|
}; |
|
|
|
|
|
|
|
await _patientSymptomRepository.InsertAsync(patientSymptomEnt, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
isPatientSymptom.Degree = item.Degree; |
|
|
|
isPatientSymptom.TimeLength = item.TimeLength; |
|
|
|
|
|
|
|
await _patientSymptomRepository.UpdateAsync(isPatientSymptom, true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await _patientSymptomRepository.InsertManyAsync(patientSymptomList, true); |
|
|
|
//需要删除的数据
|
|
|
|
var deletePatientSymptomList = patientSymptomList.Where(m => !newSymptomIds.Contains(m.SymptomId)).ToList(); |
|
|
|
await _patientSymptomRepository.DeleteManyAsync(deletePatientSymptomList); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 职业病史
|
|
|
|
|
|
|
|
var patientOccupationalMedicalHistorysInput = ObjectMapper.Map<List<PatientOccupationalMedicalHistoryInputDto>, List<PatientOccupationalMedicalHistory>>(input.PatientOccupationalMedicalHistorys); |
|
|
|
await _patientOccupationalMedicalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<PatientOccupationalMedicalHistory> patientOccupationalMedicalHistoryList = new List<PatientOccupationalMedicalHistory>(); |
|
|
|
foreach (var item in patientOccupationalMedicalHistorysInput) |
|
|
|
if (input.IsPatientOccupationalMedicalHistorysUpdate == 'Y') |
|
|
|
{ |
|
|
|
patientOccupationalMedicalHistoryList.Add(new PatientOccupationalMedicalHistory |
|
|
|
var patientOccupationalMedicalHistorysInput = ObjectMapper.Map<List<PatientOccupationalMedicalHistoryInputDto>, List<PatientOccupationalMedicalHistory>>(input.PatientOccupationalMedicalHistorys); |
|
|
|
List<PatientOccupationalMedicalHistory> patientOccupationalMedicalHistoryList = await _patientOccupationalMedicalHistoryRepository.GetListAsync(m => m.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<Guid> newPatientOccupationalMedicalHistoryIds = new List<Guid>(); //新数据
|
|
|
|
foreach (var item in patientOccupationalMedicalHistorysInput) |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
DiagnosisDate = item.DiagnosisDate, |
|
|
|
DiagnosisHospital = item.DiagnosisHospital, |
|
|
|
IsRecovery = item.IsRecovery, |
|
|
|
OccupationalDisease = item.OccupationalDisease, |
|
|
|
TreatmentMethods = item.TreatmentMethods |
|
|
|
}); |
|
|
|
} |
|
|
|
var oldPatientOccupationalMedicalHistoryEnt = await _patientOccupationalMedicalHistoryRepository.FirstOrDefaultAsync(f => f.Id == item.Id); |
|
|
|
|
|
|
|
if (item.Id == Guid.Empty || oldPatientOccupationalMedicalHistoryEnt == null) |
|
|
|
{ |
|
|
|
var patientOccupationalMedicalHistoryEnt = new PatientOccupationalMedicalHistory |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
DiagnosisDate = item.DiagnosisDate, |
|
|
|
DiagnosisHospital = item.DiagnosisHospital, |
|
|
|
IsRecovery = item.IsRecovery, |
|
|
|
OccupationalDisease = item.OccupationalDisease, |
|
|
|
TreatmentMethods = item.TreatmentMethods |
|
|
|
}; |
|
|
|
|
|
|
|
await _patientOccupationalMedicalHistoryRepository.InsertAsync(patientOccupationalMedicalHistoryEnt, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
newPatientOccupationalMedicalHistoryIds.Add(item.Id); |
|
|
|
|
|
|
|
oldPatientOccupationalMedicalHistoryEnt.DiagnosisDate = item.DiagnosisDate; |
|
|
|
oldPatientOccupationalMedicalHistoryEnt.DiagnosisHospital = item.DiagnosisHospital; |
|
|
|
oldPatientOccupationalMedicalHistoryEnt.IsRecovery = item.IsRecovery; |
|
|
|
oldPatientOccupationalMedicalHistoryEnt.OccupationalDisease = item.OccupationalDisease; |
|
|
|
oldPatientOccupationalMedicalHistoryEnt.TreatmentMethods = item.TreatmentMethods; |
|
|
|
|
|
|
|
await _patientOccupationalMedicalHistoryRepository.InsertManyAsync(patientOccupationalMedicalHistoryList, true); |
|
|
|
await _patientOccupationalMedicalHistoryRepository.UpdateAsync(oldPatientOccupationalMedicalHistoryEnt, true); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//需要删除的数据
|
|
|
|
var deletePatientOccupationalMedicalHistoryList = patientOccupationalMedicalHistoryList.Where(m => !newPatientOccupationalMedicalHistoryIds.Contains(m.Id)).ToList(); |
|
|
|
await _patientOccupationalMedicalHistoryRepository.DeleteManyAsync(deletePatientOccupationalMedicalHistoryList); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 既往病史
|
|
|
|
|
|
|
|
var patientPastMedicalHistorysInput = ObjectMapper.Map<List<PatientPastMedicalHistoryInputDto>, List<PatientPastMedicalHistory>>(input.PatientPastMedicalHistorys); |
|
|
|
await _patientPastMedicalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<PatientPastMedicalHistory> PatientPastMedicalHistoryList = new List<PatientPastMedicalHistory>(); |
|
|
|
foreach (var item in patientPastMedicalHistorysInput) |
|
|
|
if (input.IsPatientPastMedicalHistorysUpdate == 'Y') |
|
|
|
{ |
|
|
|
PatientPastMedicalHistoryList.Add(new PatientPastMedicalHistory |
|
|
|
var patientPastMedicalHistorysInput = ObjectMapper.Map<List<PatientPastMedicalHistoryInputDto>, List<PatientPastMedicalHistory>>(input.PatientPastMedicalHistorys); |
|
|
|
List<PatientPastMedicalHistory> patientPastMedicalHistoryList = await _patientPastMedicalHistoryRepository.GetListAsync(m => m.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<Guid> newPatientPastMedicalHistoryIds = new List<Guid>(); //新数据
|
|
|
|
foreach (var item in patientPastMedicalHistorysInput) |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
DiagnosisDate = item.DiagnosisDate, |
|
|
|
DiagnosisHospital = item.DiagnosisHospital, |
|
|
|
IsRecovery = item.IsRecovery, |
|
|
|
OccupationalDisease = item.OccupationalDisease, |
|
|
|
TreatmentMethods = item.TreatmentMethods |
|
|
|
}); |
|
|
|
} |
|
|
|
var oldPatientPastMedicalHistoryEnt = await _patientPastMedicalHistoryRepository.FirstOrDefaultAsync(f => f.Id == item.Id); |
|
|
|
|
|
|
|
await _patientPastMedicalHistoryRepository.InsertManyAsync(PatientPastMedicalHistoryList, true); |
|
|
|
if (item.Id == Guid.Empty || oldPatientPastMedicalHistoryEnt == null) |
|
|
|
{ |
|
|
|
var patientPastMedicalHistoryEnt = new PatientPastMedicalHistory |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
DiagnosisDate = item.DiagnosisDate, |
|
|
|
DiagnosisHospital = item.DiagnosisHospital, |
|
|
|
IsRecovery = item.IsRecovery, |
|
|
|
OccupationalDisease = item.OccupationalDisease, |
|
|
|
TreatmentMethods = item.TreatmentMethods |
|
|
|
}; |
|
|
|
|
|
|
|
await _patientPastMedicalHistoryRepository.InsertAsync(patientPastMedicalHistoryEnt, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
newPatientPastMedicalHistoryIds.Add(item.Id); |
|
|
|
|
|
|
|
|
|
|
|
oldPatientPastMedicalHistoryEnt.DiagnosisDate = item.DiagnosisDate; |
|
|
|
oldPatientPastMedicalHistoryEnt.DiagnosisHospital = item.DiagnosisHospital; |
|
|
|
oldPatientPastMedicalHistoryEnt.IsRecovery = item.IsRecovery; |
|
|
|
oldPatientPastMedicalHistoryEnt.OccupationalDisease = item.OccupationalDisease; |
|
|
|
oldPatientPastMedicalHistoryEnt.TreatmentMethods = item.TreatmentMethods; |
|
|
|
|
|
|
|
await _patientPastMedicalHistoryRepository.UpdateAsync(oldPatientPastMedicalHistoryEnt, true); |
|
|
|
} |
|
|
|
} |
|
|
|
//需要删除的数据
|
|
|
|
var deletePatientPastMedicalHistoryList = patientPastMedicalHistoryList.Where(m => !newPatientPastMedicalHistoryIds.Contains(m.Id)).ToList(); |
|
|
|
await _patientPastMedicalHistoryRepository.DeleteManyAsync(deletePatientPastMedicalHistoryList); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 职业史
|
|
|
|
|
|
|
|
var patientOccupationalHistorysInput = ObjectMapper.Map<List<PatientOccupationalHistoryInputDto>, List<PatientOccupationalHistory>>(input.PatientOccupationalHistorys); |
|
|
|
await _patientOccupationalHistoryRepository.DeleteAsync(d => d.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<PatientOccupationalHistory> patientOccupationalHistoryList = new List<PatientOccupationalHistory>(); |
|
|
|
foreach (var item in patientOccupationalHistorysInput) |
|
|
|
if (input.IsPatientOccupationalHistorysUpdate == 'Y') |
|
|
|
{ |
|
|
|
patientOccupationalHistoryList.Add(new PatientOccupationalHistory |
|
|
|
var patientOccupationalHistorysInput = ObjectMapper.Map<List<PatientOccupationalHistoryInputDto>, List<PatientOccupationalHistory>>(input.PatientOccupationalHistorys); |
|
|
|
List<PatientOccupationalHistory> patientOccupationalHistoryList = await _patientOccupationalHistoryRepository.GetListAsync(m => m.PatientRegisterId == input.PatientRegisterId); |
|
|
|
List<Guid> newPatientOccupationalHistoryIds = new List<Guid>(); //新数据
|
|
|
|
foreach (var item in patientOccupationalHistorysInput) |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
BeginDate = item.BeginDate, |
|
|
|
EndDate = item.EndDate, |
|
|
|
Org = item.Org, |
|
|
|
Poison = item.Poison, |
|
|
|
ProtectiveMeasures = item.ProtectiveMeasures, |
|
|
|
WorkShop = item.WorkShop, |
|
|
|
WorkType = item.WorkType |
|
|
|
}); |
|
|
|
} |
|
|
|
var oldPatientOccupationalHistoryEnt = await _patientOccupationalHistoryRepository.FirstOrDefaultAsync(f => f.Id == item.Id); |
|
|
|
|
|
|
|
if (item.Id == Guid.Empty || oldPatientOccupationalHistoryEnt == null) |
|
|
|
{ |
|
|
|
var patientOccupationalHistoryEnt = new PatientOccupationalHistory |
|
|
|
{ |
|
|
|
PatientRegisterId = input.PatientRegisterId, |
|
|
|
BeginDate = item.BeginDate, |
|
|
|
EndDate = item.EndDate, |
|
|
|
Org = item.Org, |
|
|
|
Poison = item.Poison, |
|
|
|
ProtectiveMeasures = item.ProtectiveMeasures, |
|
|
|
WorkShop = item.WorkShop, |
|
|
|
WorkType = item.WorkType |
|
|
|
}; |
|
|
|
|
|
|
|
await _patientOccupationalHistoryRepository.InsertAsync(patientOccupationalHistoryEnt, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
newPatientOccupationalHistoryIds.Add(item.Id); |
|
|
|
|
|
|
|
oldPatientOccupationalHistoryEnt.BeginDate = item.BeginDate; |
|
|
|
oldPatientOccupationalHistoryEnt.EndDate = item.EndDate; |
|
|
|
oldPatientOccupationalHistoryEnt.Org = item.Org; |
|
|
|
oldPatientOccupationalHistoryEnt.Poison = item.Poison; |
|
|
|
oldPatientOccupationalHistoryEnt.ProtectiveMeasures = item.ProtectiveMeasures; |
|
|
|
oldPatientOccupationalHistoryEnt.WorkShop = item.WorkShop; |
|
|
|
oldPatientOccupationalHistoryEnt.WorkType = item.WorkType; |
|
|
|
|
|
|
|
await _patientOccupationalHistoryRepository.InsertManyAsync(patientOccupationalHistoryList, true); |
|
|
|
await _patientOccupationalHistoryRepository.UpdateAsync(oldPatientOccupationalHistoryEnt, true); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//需要删除的数据
|
|
|
|
var deletePatientOccupationalHistoryList = patientOccupationalHistoryList.Where(m => !newPatientOccupationalHistoryIds.Contains(m.Id)).ToList(); |
|
|
|
await _patientOccupationalHistoryRepository.DeleteManyAsync(deletePatientOccupationalHistoryList); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
return await GetOccupationalDiseaseWithDetailByPatientRegisterIdAsync(new PatientRegisterIdInputDto |
|
|
|
@ -261,6 +532,7 @@ namespace Shentun.Peis.OccupationalDiseases |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取职业病信息 根据人员登记ID
|
|
|
|
/// </summary>
|
|
|
|
|