Browse Source

危急值生成规则

master
wxd 1 year ago
parent
commit
a91fb9f0f9
  1. 50
      src/Shentun.Peis.Application.Contracts/PhoneFollowUps/AutoCreatePhoneFollowUpDto.cs
  2. 4
      src/Shentun.Peis.Application.Contracts/PhoneFollowUps/CreatePhoneFollowUpDto.cs
  3. 19
      src/Shentun.Peis.Application.Contracts/SmsSends/AutoCreateSmsSendDto.cs
  4. 97
      src/Shentun.Peis.Application/PhoneFollowUps/PhoneFollowUpAppService.cs
  5. 103
      src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs

50
src/Shentun.Peis.Application.Contracts/PhoneFollowUps/AutoCreatePhoneFollowUpDto.cs

@ -6,22 +6,56 @@ using System.Text;
namespace Shentun.Peis.PhoneFollowUps
{
//public class AutoCreatePhoneFollowUpDto
//{
// /// <summary>
// /// 0-corn表达式 1-按天 2-按周 3-按月 4-按年
// /// </summary>
// public char FollowUpMode { get; set; } = '0';
// /// <summary>
// /// FollowUpMode为0时 为corn表达式 其他模式为具体数字
// /// </summary>
// public string ModeValue { get; set; }
// /// <summary>
// /// 截止时间 采用corn表达式时需要截止日期
// /// </summary>
// public string EndDate { get; set; }
// /// <summary>
// /// 随访主表ID
// /// </summary>
// public Guid FollowUpId { get; set; }
// /// <summary>
// /// 随访内容
// /// </summary>
// public string FollowUpContent { get; set; }
// /// <summary>
// /// 回复内容
// /// </summary>
// public string ReplyContent { get; set; }
//}
public class AutoCreatePhoneFollowUpDto
{
/// <summary>
/// 0-corn表达式 1-按天 2-按周 3-按月 4-按年
/// 开始时间
/// </summary>
public char FollowUpMode { get; set; } = '0';
public string StartDate { get; set; }
/// <summary>
/// FollowUpMode为0时 为corn表达式 其他模式为具体数字
/// 间隔天数
/// </summary>
public string ModeValue { get; set; }
public int IntervalDays { get; set; } = 1;
/// <summary>
/// 截止时间 采用corn表达式时需要截止日期
/// 生成次数
/// </summary>
public string EndDate { get; set; }
public int GenerateCount { get; set; } = 1;
/// <summary>
/// 随访主表ID
@ -33,9 +67,5 @@ namespace Shentun.Peis.PhoneFollowUps
/// </summary>
public string FollowUpContent { get; set; }
/// <summary>
/// 回复内容
/// </summary>
public string ReplyContent { get; set; }
}
}

4
src/Shentun.Peis.Application.Contracts/PhoneFollowUps/CreatePhoneFollowUpDto.cs

@ -16,10 +16,6 @@ namespace Shentun.Peis.PhoneFollowUps
/// </summary>
public string FollowUpContent { get; set; }
/// <summary>
/// 回复内容
/// </summary>
public string ReplyContent { get; set; }
/// <summary>
/// 随访日期 yyyy-MM-dd

19
src/Shentun.Peis.Application.Contracts/SmsSends/AutoCreateSmsSendDto.cs

@ -7,24 +7,27 @@ namespace Shentun.Peis.SmsSends
public class AutoCreateSmsSendDto
{
/// <summary>
/// 0-corn表达式 1-按天 2-按周 3-按月 4-按年
/// 开始时间
/// </summary>
public char FollowUpMode { get; set; } = '0';
public string StartDate { get; set; }
/// <summary>
/// FollowUpMode为0时 为corn表达式 其他模式为具体数字
/// 间隔天数
/// </summary>
public string ModeValue { get; set; }
public int IntervalDays { get; set; } = 1;
/// <summary>
/// 短信内容,默认是患者姓名
/// 生成次数
/// </summary>
public string Content { get; set; }
public int GenerateCount { get; set; } = 1;
/// <summary>
/// 截止时间
/// 短信内容,默认是患者姓名
/// </summary>
public string EndDate { get; set; }
public string Content { get; set; }
/// <summary>
/// 随访主表ID

97
src/Shentun.Peis.Application/PhoneFollowUps/PhoneFollowUpAppService.cs

@ -143,7 +143,6 @@ namespace Shentun.Peis.PhoneFollowUps
}
/// <summary>
/// 获取所有危急值列表
/// </summary>
@ -363,17 +362,11 @@ namespace Shentun.Peis.PhoneFollowUps
[HttpPost("api/app/PhoneFollowUp/AutoCreate")]
public async Task AutoCreateAsync(AutoCreatePhoneFollowUpDto input)
{
if (string.IsNullOrWhiteSpace(input.ModeValue))
{
throw new UserFriendlyException("计划周期不能为空");
}
if (input.FollowUpMode == FollowUpModeFlag.Corn && string.IsNullOrWhiteSpace(input.EndDate))
if (string.IsNullOrWhiteSpace(input.StartDate))
{
throw new UserFriendlyException("采用corn表达式时需要截止日期");
throw new UserFriendlyException("开始时间不能为空");
}
var isPhoneFollowUp = await _phoneFollowUpRepository.CountAsync(c => c.FollowUpId == input.FollowUpId);
if (isPhoneFollowUp > 0)
{
@ -389,83 +382,27 @@ namespace Shentun.Peis.PhoneFollowUps
List<PhoneFollowUp> phoneFollowUpList = new List<PhoneFollowUp>();
if (input.FollowUpMode == FollowUpModeFlag.Corn)
{
//corn表达式
#region 解析Cron表达式
try
{
var schedule = CronExpression.Parse(input.ModeValue, CronFormat.IncludeSeconds);
var occurrences = schedule.GetOccurrences(DateTime.UtcNow, Convert.ToDateTime(input.EndDate).ToUniversalTime()); //获取截止时间前所有的计划时间
foreach (var occurrence in occurrences)
{
var phoneFollowUpEntity = new PhoneFollowUp(GuidGenerator.Create())
{
FollowUpContent = input.FollowUpContent,
FollowUpId = input.FollowUpId,
ReplyContent = input.ReplyContent,
PlanFollowDate = occurrence,
IsComplete = 'N'
};
phoneFollowUpList.Add(phoneFollowUpEntity);
}
}
catch (Exception ex)
{
throw new UserFriendlyException("Corn表达式不正确");
}
#endregion
}
else
for (int i = 0; i < input.GenerateCount; i++)
{
//其他模式
int planCount = 0;
try
{
planCount = Convert.ToInt32(input.ModeValue);
}
catch (Exception ex)
{
throw new UserFriendlyException("Corn表达式不正确");
}
DateTime planFollowDate = Convert.ToDateTime(input.StartDate);
planFollowDate = planFollowDate.AddDays(i * input.IntervalDays);
for (int i = 0; i < planCount; i++)
var phoneFollowUpEntity = new PhoneFollowUp(GuidGenerator.Create())
{
DateTime planFollowDate = DateTime.Now;
if (input.FollowUpMode == FollowUpModeFlag.Day)
{
planFollowDate = planFollowDate.AddDays(i);
}
else if (input.FollowUpMode == FollowUpModeFlag.Week)
{
planFollowDate = planFollowDate.AddDays(7 * i);
}
else if (input.FollowUpMode == FollowUpModeFlag.Month)
{
planFollowDate = planFollowDate.AddMonths(i);
}
else if (input.FollowUpMode == FollowUpModeFlag.Year)
{
planFollowDate = planFollowDate.AddYears(i);
}
var phoneFollowUpEntity = new PhoneFollowUp(GuidGenerator.Create())
{
FollowUpContent = input.FollowUpContent,
FollowUpId = input.FollowUpId,
ReplyContent = input.ReplyContent,
PlanFollowDate = planFollowDate,
IsComplete = 'N'
};
phoneFollowUpList.Add(phoneFollowUpEntity);
}
FollowUpContent = input.FollowUpContent,
FollowUpId = input.FollowUpId,
PlanFollowDate = planFollowDate,
IsComplete = 'N'
};
phoneFollowUpList.Add(phoneFollowUpEntity);
}
if (phoneFollowUpList.Any())
{
await _phoneFollowUpRepository.InsertManyAsync(phoneFollowUpList);
@ -474,8 +411,8 @@ namespace Shentun.Peis.PhoneFollowUps
await _followUpRepository.UpdateAsync(followUpEnt);
}
}
}
/// <summary>
/// 新增电话随访记录
/// </summary>
@ -500,7 +437,6 @@ namespace Shentun.Peis.PhoneFollowUps
{
FollowUpContent = input.FollowUpContent,
FollowUpId = input.FollowUpId,
ReplyContent = input.ReplyContent,
PlanFollowDate = Convert.ToDateTime(input.PlanFollowDate),
IsComplete = 'N'
};
@ -556,5 +492,6 @@ namespace Shentun.Peis.PhoneFollowUps
await _phoneFollowUpRepository.DeleteAsync(input.PhoneFollowUpId);
}
}
}

103
src/Shentun.Peis.Application/SmsSends/SmsSendAppService.cs

@ -138,17 +138,11 @@ namespace Shentun.Peis.SmsSends
[HttpPost("api/app/SmsSend/AutoCreate")]
public async Task AutoCreateAsync(AutoCreateSmsSendDto input)
{
if (string.IsNullOrWhiteSpace(input.ModeValue))
if (string.IsNullOrWhiteSpace(input.StartDate))
{
throw new UserFriendlyException("计划周期不能为空");
throw new UserFriendlyException("开始时间不能为空");
}
if (input.FollowUpMode == FollowUpModeFlag.Corn && string.IsNullOrWhiteSpace(input.EndDate))
{
throw new UserFriendlyException("采用corn表达式时需要截止日期");
}
var isSmsSend = await _smsSendRepository.CountAsync(c => c.FollowUpId == input.FollowUpId);
if (isSmsSend > 0)
{
@ -182,90 +176,31 @@ namespace Shentun.Peis.SmsSends
throw new UserFriendlyException("随访数据不存在");
}
if (input.FollowUpMode == FollowUpModeFlag.Corn)
{
//corn表达式
#region 解析Cron表达式
try
{
var schedule = CronExpression.Parse(input.ModeValue, CronFormat.IncludeSeconds);
var occurrences = schedule.GetOccurrences(DateTime.UtcNow, Convert.ToDateTime(input.EndDate).ToUniversalTime()); //获取截止时间前所有的计划时间
foreach (var occurrence in occurrences)
{
var smsSendEntity = new SmsSend(GuidGenerator.Create())
{
FollowUpId = input.FollowUpId,
Content = string.IsNullOrWhiteSpace(input.Content) ? patientRegisterEnt.patientName : input.Content,
MobileTelephone = patientRegisterEnt.mobileTelephone,
PatientName = patientRegisterEnt.patientName,
PatientId = patientRegisterEnt.patientId,
PlanSendDate = occurrence,
SmsTypeId = "01",
IsComplete = 'Y'
};
smsSendList.Add(smsSendEntity);
}
}
catch (Exception ex)
{
throw new UserFriendlyException("Corn表达式不正确");
}
#endregion
}
else
for (int i = 0; i < input.GenerateCount; i++)
{
//其他模式
int planCount = 0;
try
{
planCount = Convert.ToInt32(input.ModeValue);
}
catch (Exception ex)
{
throw new UserFriendlyException("Corn表达式不正确");
}
DateTime planFollowDate = Convert.ToDateTime(input.StartDate);
for (int i = 0; i < planCount; i++)
{
DateTime planFollowDate = DateTime.Now;
if (input.FollowUpMode == FollowUpModeFlag.Day)
{
planFollowDate = planFollowDate.AddDays(i);
}
else if (input.FollowUpMode == FollowUpModeFlag.Week)
{
planFollowDate = planFollowDate.AddDays(7 * i);
}
else if (input.FollowUpMode == FollowUpModeFlag.Month)
{
planFollowDate = planFollowDate.AddMonths(i);
}
else if (input.FollowUpMode == FollowUpModeFlag.Year)
{
planFollowDate = planFollowDate.AddYears(i);
}
planFollowDate = planFollowDate.AddDays(i * input.IntervalDays);
var smsSendEntity = new SmsSend(GuidGenerator.Create())
{
FollowUpId = input.FollowUpId,
Content = string.IsNullOrWhiteSpace(input.Content) ? patientRegisterEnt.patientName : input.Content,
MobileTelephone = patientRegisterEnt.mobileTelephone,
PatientName = patientRegisterEnt.patientName,
PatientId = patientRegisterEnt.patientId,
PlanSendDate = planFollowDate,
SmsTypeId = "01",
IsComplete = 'Y'
};
smsSendList.Add(smsSendEntity);
}
var smsSendEntity = new SmsSend(GuidGenerator.Create())
{
FollowUpId = input.FollowUpId,
Content = string.IsNullOrWhiteSpace(input.Content) ? patientRegisterEnt.patientName : input.Content,
MobileTelephone = patientRegisterEnt.mobileTelephone,
PatientName = patientRegisterEnt.patientName,
PatientId = patientRegisterEnt.patientId,
PlanSendDate = planFollowDate,
SmsTypeId = "01",
IsComplete = 'Y'
};
smsSendList.Add(smsSendEntity);
}
if (smsSendList.Any())
{
await _smsSendRepository.InsertManyAsync(smsSendList);

Loading…
Cancel
Save