wxd 1 year ago
parent
commit
49ff090d4e
  1. 3
      src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
  2. 72
      src/Shentun.Peis.Application/FollowUps/FollowUpAppService.cs
  3. 19
      src/Shentun.Peis.Application/RegisterCheckItems/RegisterCheckItemAppService.cs
  4. 12
      src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs

3
src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs

@ -1988,11 +1988,12 @@ namespace Shentun.Peis.DiagnosisFunctions
if (registerCheckEnt != null)
{
registerCheckEnt.CriticalRangeValue = CriticalRangeValue;
registerCheckEnt.IsCriticalValue = isCriticalValue;
if (isCriticalValue == 'Y')
{
registerCheckEnt.CriticalValueCreatorId = _currentUser.Id;
registerCheckEnt.CriticalValueCreationTime = DateTime.Now;
registerCheckEnt.IsCriticalValue = isCriticalValue;
}
registerCheckEnt.FollowUpCreatorId = _currentUser.Id;
registerCheckEnt.FollowUpCreationTime = DateTime.Now;

72
src/Shentun.Peis.Application/FollowUps/FollowUpAppService.cs

@ -27,6 +27,8 @@ namespace Shentun.Peis.FollowUps
private readonly IRepository<SmsSend, Guid> _smsSendRepository;
private readonly SmsSendAppService _smsSendAppService;
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
private readonly IRepository<RegisterCheckItem> _registerCheckItemRepository;
public FollowUpAppService(
IRepository<FollowUp, Guid> followUpRepository,
CacheService cacheService,
@ -34,7 +36,9 @@ namespace Shentun.Peis.FollowUps
IRepository<PhoneFollowUp, Guid> phoneFollowUpRepository,
IRepository<SmsSend, Guid> smsSendRepository,
SmsSendAppService smsSendAppService,
IRepository<PatientRegister, Guid> patientRegisterRepository)
IRepository<PatientRegister, Guid> patientRegisterRepository,
IRepository<RegisterCheck, Guid> registerCheckRepository,
IRepository<RegisterCheckItem> registerCheckItemRepository)
{
_followUpRepository = followUpRepository;
_cacheService = cacheService;
@ -43,6 +47,8 @@ namespace Shentun.Peis.FollowUps
_smsSendRepository = smsSendRepository;
_smsSendAppService = smsSendAppService;
_patientRegisterRepository = patientRegisterRepository;
_registerCheckRepository = registerCheckRepository;
_registerCheckItemRepository = registerCheckItemRepository;
}
/// <summary>
@ -77,42 +83,58 @@ namespace Shentun.Peis.FollowUps
/// <returns></returns>
public async Task DeleteByPatientRegisterId(PatientRegisterIdInputDto input)
{
var isFollowUp = await _followUpRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId);
if (isFollowUp != null)
//检查是否所有项目都没有
var isFollowUpDelete = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId
join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckItem.RegisterCheckId
where patientRegister.Id == input.PatientRegisterId
&& (registerCheck.IsFollowUp == 'Y'
|| registerCheck.IsCriticalValue == 'Y'
|| registerCheckItem.IsCriticalValue == 'Y'
|| registerCheckItem.IsFollowUp == 'Y')
select patientRegister.Id
).Count();
if (isFollowUpDelete == 0)
{
var phoneFollowUpList = await _phoneFollowUpRepository.GetListAsync(m => m.FollowUpId == isFollowUp.Id);
var smsSendList = await _smsSendRepository.GetListAsync(m => m.FollowUpId == isFollowUp.Id);
bool isDelete = true; //是否需要删除
if (phoneFollowUpList.Any())
var isFollowUp = await _followUpRepository.FirstOrDefaultAsync(f => f.PatientRegisterId == input.PatientRegisterId);
if (isFollowUp != null)
{
isDelete = false;
phoneFollowUpList = phoneFollowUpList.Where(m => m.PlanFollowDate > DateTime.Now).ToList();
var phoneFollowUpList = await _phoneFollowUpRepository.GetListAsync(m => m.FollowUpId == isFollowUp.Id);
var smsSendList = await _smsSendRepository.GetListAsync(m => m.FollowUpId == isFollowUp.Id);
bool isDelete = true; //是否需要删除
if (phoneFollowUpList.Any())
{
await _phoneFollowUpRepository.DeleteManyAsync(phoneFollowUpList);
isDelete = false;
phoneFollowUpList = phoneFollowUpList.Where(m => m.PlanFollowDate > DateTime.Now).ToList();
if (phoneFollowUpList.Any())
{
await _phoneFollowUpRepository.DeleteManyAsync(phoneFollowUpList);
}
}
}
if (smsSendList.Any())
{
isDelete = false;
smsSendList = smsSendList.Where(m => m.PlanSendDate > DateTime.Now).ToList();
if (smsSendList.Any())
{
await _smsSendRepository.DeleteManyAsync(smsSendList);
//删除任务计划
var patientRegisterEnt = await _patientRegisterRepository.FirstOrDefaultAsync(f => f.Id == input.PatientRegisterId);
if (patientRegisterEnt != null)
isDelete = false;
smsSendList = smsSendList.Where(m => m.PlanSendDate > DateTime.Now).ToList();
if (smsSendList.Any())
{
await _smsSendAppService.DeleteCriticalSmsAsync(patientRegisterEnt, smsSendList.First().Content);
}
await _smsSendRepository.DeleteManyAsync(smsSendList);
//删除任务计划
var patientRegisterEnt = await _patientRegisterRepository.FirstOrDefaultAsync(f => f.Id == input.PatientRegisterId);
if (patientRegisterEnt != null)
{
await _smsSendAppService.DeleteCriticalSmsAsync(patientRegisterEnt, smsSendList.First().Content);
}
}
}
if (isDelete)
{
await _followUpRepository.DeleteAsync(isFollowUp);
}
}
if (isDelete)
{
await _followUpRepository.DeleteAsync(isFollowUp);
}
}
}

19
src/Shentun.Peis.Application/RegisterCheckItems/RegisterCheckItemAppService.cs

@ -409,7 +409,7 @@ namespace Shentun.Peis.RegisterCheckItems
}
if (input.IsCriticalValue == 'Y' && registerCheckItemEnt.CriticalValueCreatorId == null)
{
registerCheckItemEnt.CriticalValueCreatorId = _currentUser.Id;
@ -444,11 +444,20 @@ namespace Shentun.Peis.RegisterCheckItems
}
else
{
//删除随访表记录
await _followUpAppService.DeleteByPatientRegisterId(new PatientRegisterIdInputDto
var registerCheckItemCount = await _registerCheckItemRepository.CountAsync(c => c.RegisterCheckId == input.RegisterCheckId && (c.IsFollowUp == 'Y' || c.IsCriticalValue == 'Y'));
if (registerCheckItemCount == 0)
{
PatientRegisterId = registerCheckEnt.PatientRegisterId
});
//更新registerCheck
registerCheckEnt.IsCriticalValue = registerCheckItemEnt.IsCriticalValue;
registerCheckEnt.IsFollowUp= registerCheckItemEnt.IsFollowUp;
await _registerCheckRepository.UpdateAsync(registerCheckEnt);
//删除随访表记录
await _followUpAppService.DeleteByPatientRegisterId(new PatientRegisterIdInputDto
{
PatientRegisterId = registerCheckEnt.PatientRegisterId
});
}
}
}

12
src/Shentun.Peis.Application/RegisterChecks/RegisterCheckAppService.cs

@ -736,6 +736,18 @@ namespace Shentun.Peis.RegisterChecks
}
else
{
#region 更新明细项目的危急值跟随访值状态
var registerCheckItemList = await _registerCheckItemRepository.GetListAsync(m => m.RegisterCheckId == input.RegisterCheckId);
foreach (var registerCheckItem in registerCheckItemList)
{
registerCheckItem.IsCriticalValue = registerCheckEnt.IsCriticalValue;
registerCheckItem.IsFollowUp = registerCheckEnt.IsFollowUp;
}
await _registerCheckItemRepository.UpdateManyAsync(registerCheckItemList);
#endregion
//删除随访表记录
await _followUpAppService.DeleteByPatientRegisterId(new PatientRegisterIdInputDto
{

Loading…
Cancel
Save