Browse Source

调整高频时长不足10分钟,都不产生告警信息

undefined
H Vs 4 weeks ago
parent
commit
5f9a1fcbff
2 changed files with 75 additions and 9 deletions
  1. +50
    -7
      HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs
  2. +25
    -2
      HealthMonitor.WebApi/Worker.cs

+ 50
- 7
HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs View File

@@ -380,8 +380,9 @@ namespace HealthMonitor.Service.Resolver
var freqFirstPhr = phr.OrderByDescending(i => i.LastUpdate) var freqFirstPhr = phr.OrderByDescending(i => i.LastUpdate)
.Skip(1) //在高频第二条才能判断,所以要去除本条记录 .Skip(1) //在高频第二条才能判断,所以要去除本条记录
.First(); .First();
_logger.LogInformation($"首条高频附近的3条:{string.Join(',', phr.OrderByDescending(i => i.LastUpdate).Take(3).Select(i=>i.MessageId))}");
await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno, freqFirstPhr); await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno, freqFirstPhr);
_logger.LogInformation($"{heartRate.Serialno} 设置高频状态");
_logger.LogInformation($"{heartRate.Serialno} 设置高频状态,首条高频心率ID:{freqFirstPhr.MessageId}");
phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno);
HisGpsHeartRate freqFirstHR = new() HisGpsHeartRate freqFirstHR = new()
{ {
@@ -430,18 +431,23 @@ namespace HealthMonitor.Service.Resolver
// 高频不停,15分钟内只下发一条 // 高频不停,15分钟内只下发一条
if (string.IsNullOrEmpty(freqSaveAndPushFetalHeartRate)) if (string.IsNullOrEmpty(freqSaveAndPushFetalHeartRate))
{ {
//await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); //await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);


heartRate.HeartRate = (int)avgPhr; heartRate.HeartRate = (int)avgPhr;
//await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); //await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);

var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)heartRate.LastUpdate!, phrFreqstatus!.LastUpdate);
// 最后一条高频心率
var lastFreqHr = lastPhr.First();
var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)lastFreqHr.LastUpdate!, phrFreqstatus!.LastUpdate);
// 判断是否够highFreqSampleTimes,540s // 判断是否够highFreqSampleTimes,540s
if (ts < highFreqSampleTimes) if (ts < highFreqSampleTimes)
{ {
/// 不够10分钟最近12个数据的最小值生成胎心值 /// 不够10分钟最近12个数据的最小值生成胎心值
_logger.LogInformation($"{heartRate.Serialno} 不够10分钟最近12个数据的最小值生成胎心值");
heartRate.HeartRate = lastPhr.Select(i=>i.PregnancyHeartRate).Min(); heartRate.HeartRate = lastPhr.Select(i=>i.PregnancyHeartRate).Min();
heartRate.LastUpdate = lastFreqHr.LastUpdate;
} }
_logger.LogInformation($"{heartRate.Serialno} 高频15分钟不停止的高频心率处理");
await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR,highFreqSampleTimes ,upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR,highFreqSampleTimes ,upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);
// 删除高频状态的首条记录 // 删除高频状态的首条记录
@@ -492,13 +498,19 @@ namespace HealthMonitor.Service.Resolver


heartRate.HeartRate = (int)avgPhr; heartRate.HeartRate = (int)avgPhr;
//await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); //await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);
var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)heartRate.LastUpdate!, phrFreqstatus!.LastUpdate);
// 最后一条高频心率
var lastFreqHr = lastPhr.First();

var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)lastFreqHr.LastUpdate!, phrFreqstatus!.LastUpdate);
// 判断是否够highFreqSampleTimes,540s // 判断是否够highFreqSampleTimes,540s
if (ts < highFreqSampleTimes) if (ts < highFreqSampleTimes)
{ {
/// 不够10分钟最近12个数据的最小值生成胎心值 /// 不够10分钟最近12个数据的最小值生成胎心值
_logger.LogInformation($"{heartRate.Serialno} 不够10分钟最近12个数据的最小值生成胎心值");
heartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min(); heartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min();
heartRate.LastUpdate = lastFreqHr.LastUpdate;
} }
_logger.LogInformation($"{heartRate.Serialno} 高频结束后的highFreqSampleTimes=0的高频心率处理");
await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);


} }
@@ -527,7 +539,7 @@ namespace HealthMonitor.Service.Resolver
.Take(stopHighFreqSampleCount) // 计算最后12条 .Take(stopHighFreqSampleCount) // 计算最后12条
.Select(i => i.PregnancyHeartRate).Average(); .Select(i => i.PregnancyHeartRate).Average();


_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,超过约定的 {highFreqSampleTimes} 秒,即将结束高频状态,高频心率平均值:{(int)avgPhr},将下发指令");
//_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,约定的 {highFreqSampleTimes} 秒,即将结束高频状态,高频心率平均值:{(int)avgPhr},将下发指令");
//计算高频 //计算高频
//await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); //await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);
heartRate.HeartRate = (int)avgPhr; heartRate.HeartRate = (int)avgPhr;
@@ -537,13 +549,20 @@ namespace HealthMonitor.Service.Resolver
var lastPhr = filterPhr var lastPhr = filterPhr
.OrderByDescending(i => i.LastUpdate) .OrderByDescending(i => i.LastUpdate)
.Take(stopHighFreqSampleCount); .Take(stopHighFreqSampleCount);
var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)heartRate.LastUpdate!, phrFreqstatus!.LastUpdate);

// 最后一条高频心率
var lastFreqHr = lastPhr.First();

var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)lastFreqHr.LastUpdate!, phrFreqstatus!.LastUpdate);
if (ts < highFreqSampleTimes) if (ts < highFreqSampleTimes)
{ {
/// 不够10分钟最近12个数据的最小值生成胎心值 /// 不够10分钟最近12个数据的最小值生成胎心值
_logger.LogInformation($"{heartRate.Serialno} 不够10分钟最近12个数据的最小值生成胎心值");
heartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min(); heartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min();
heartRate.LastUpdate = lastFreqHr.LastUpdate;
} }
_logger.LogInformation($"{heartRate.Serialno} 高频结束后的在highFreqSampleTimes>0 正常心率(通常情况)触发的高频心率处理");
await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);
} }
else else
@@ -607,12 +626,18 @@ namespace HealthMonitor.Service.Resolver
var lastPhr = freqCollection var lastPhr = freqCollection
.OrderByDescending(i => i.LastUpdate) .OrderByDescending(i => i.LastUpdate)
.Take(stopHighFreqSampleCount); .Take(stopHighFreqSampleCount);
var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)heartRate.LastUpdate!, phrFreqstatus!.LastUpdate);
// 最后一条高频心率
var lastFreqHr = lastPhr.First();

var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)lastFreqHr.LastUpdate!, phrFreqstatus!.LastUpdate);
if (ts < highFreqSampleTimes) if (ts < highFreqSampleTimes)
{ {
/// 不够10分钟最近12个数据的最小值生成胎心值 /// 不够10分钟最近12个数据的最小值生成胎心值
_logger.LogInformation($"{heartRate.Serialno} 不够10分钟最近12个数据的最小值生成胎心值");
heartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min(); heartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min();
heartRate.LastUpdate = lastFreqHr.LastUpdate;
} }
_logger.LogInformation($"{heartRate.Serialno} 高频结束后的时间倒序的正常心率触发的高频心率处理");
await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(heartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);


_logger.LogInformation($"{heartRate.Serialno} 高频数据个数{freqCollection.Count},触发高频开始时间{phrFreqstatus!.LastUpdate},时间倒叙"); _logger.LogInformation($"{heartRate.Serialno} 高频数据个数{freqCollection.Count},触发高频开始时间{phrFreqstatus!.LastUpdate},时间倒叙");
@@ -1236,6 +1261,23 @@ namespace HealthMonitor.Service.Resolver
} }
} }


/// <summary>
/// 高频胎心处理
/// 1. 高频15分钟不停止的高频心率处理
/// 2. 高频结束后的highFreqSampleTimes=0的高频心率处理
/// 3. 高频结束后的在highFreqSampleTimes>0 正常心率触发的高频心率处理(常态)
/// 4. 高频结束后的时间倒序的正常心率触发的高频心率处理
/// 5. 高频结束后计算胎心数据,防止结束后与常规心理的胎心处理过长,定时器时长highFreqSampleInterval触发的高频心率处理
/// </summary>
/// <param name="heartRate"></param>
/// <param name="commonPHR"></param>
/// <param name="highFreqSampleTimes"></param>
/// <param name="upperAlarmThreshold"></param>
/// <param name="lowerAlarmThreshold"></param>
/// <param name="sampleTime"></param>
/// <param name="statStartTime"></param>
/// <param name="statEndTime"></param>
/// <returns></returns>
private async Task SaveAndPushFetalHeartRateEndFreqHeartRateAsync(HisGpsHeartRate heartRate, PregnancyCommonHeartRateModel commonPHR, int highFreqSampleTimes, int upperAlarmThreshold, int lowerAlarmThreshold, string sampleTime, DateTime statStartTime, DateTime statEndTime) private async Task SaveAndPushFetalHeartRateEndFreqHeartRateAsync(HisGpsHeartRate heartRate, PregnancyCommonHeartRateModel commonPHR, int highFreqSampleTimes, int upperAlarmThreshold, int lowerAlarmThreshold, string sampleTime, DateTime statStartTime, DateTime statEndTime)
{ {
// 计算胎心=孕妇心率*系数 // 计算胎心=孕妇心率*系数
@@ -1499,6 +1541,7 @@ namespace HealthMonitor.Service.Resolver
} }
else else
{ {
// 不断修改时长,直到最后的一条高频胎心
await _serviceEtcd.PutValAsync(key, schedulePush, interval, false).ConfigureAwait(false); await _serviceEtcd.PutValAsync(key, schedulePush, interval, false).ConfigureAwait(false);
} }




+ 25
- 2
HealthMonitor.WebApi/Worker.cs View File

@@ -352,12 +352,18 @@ namespace HealthMonitor.WebApi


// 判断是否够highFreqSampleTimes,540s // 判断是否够highFreqSampleTimes,540s
var lastPhr = phrInFreqstatus; var lastPhr = phrInFreqstatus;
var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)triggerHeartRate.LastUpdate!, phrFreqstatus!.LastUpdate);
// 最后一条高频心率
var lastFreqHr = phrInFreqstatus.First();
var ts = DateTimeUtil.GetTimeDifferenceInSeconds((DateTime)lastFreqHr.LastUpdate!, phrFreqstatus!.LastUpdate);
if (ts < highFreqSampleTimes) if (ts < highFreqSampleTimes)
{ {
/// 不够10分钟最近12个数据的最小值生成胎心值 /// 不够10分钟最近12个数据的最小值生成胎心值
_logger.LogInformation($"{triggerHeartRate.Serialno} 不够10分钟最近12个数据的最小值生成胎心值");
triggerHeartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min(); triggerHeartRate.HeartRate = lastPhr.Select(i => i.PregnancyHeartRate).Min();
triggerHeartRate.LastUpdate = lastFreqHr.LastUpdate;
} }
_logger.LogInformation($"{triggerHeartRate.Serialno} 高频结束后计算胎心数据,防止结束后与常规心理的胎心处理过长,定时器时长highFreqSampleInterval触发的高频心率处理");

await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(triggerHeartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); await SaveAndPushFetalHeartRateEndFreqHeartRateAsync(triggerHeartRate, commonPHR, highFreqSampleTimes, upperAlarmThreshold, lowerAlarmThreshold, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd);
} }
else else
@@ -2082,7 +2088,24 @@ namespace HealthMonitor.WebApi


} }
} }

/// <summary>
/// 高频胎心处理
/// 1. 高频15分钟不停止的高频心率处理
/// 2. 高频结束后的highFreqSampleTimes=0的高频心率处理
/// 3. 高频结束后的在highFreqSampleTimes>0 正常心率触发的高频心率处理(常态)
/// 4. 高频结束后的时间倒序的正常心率触发的高频心率处理
/// * 5. 高频结束后计算胎心数据,防止结束后与常规心理的胎心处理过长,定时器时长highFreqSampleInterval触发的高频心率处理
/// </summary>
/// <param name="heartRate"></param>
/// <param name="commonPHR"></param>
/// <param name="highFreqSampleTimes"></param>
/// <param name="upperAlarmThreshold"></param>
/// <param name="lowerAlarmThreshold"></param>
/// <param name="sampleTime"></param>
/// <param name="statStartTime"></param>
/// <param name="statEndTime"></param>
/// <returns></returns>
private async Task SaveAndPushFetalHeartRateEndFreqHeartRateAsync(HisGpsHeartRate heartRate, PregnancyCommonHeartRateModel commonPHR, int highFreqSampleTimes, int upperAlarmThreshold, int lowerAlarmThreshold, string sampleTime, DateTime statStartTime, DateTime statEndTime) private async Task SaveAndPushFetalHeartRateEndFreqHeartRateAsync(HisGpsHeartRate heartRate, PregnancyCommonHeartRateModel commonPHR, int highFreqSampleTimes, int upperAlarmThreshold, int lowerAlarmThreshold, string sampleTime, DateTime statStartTime, DateTime statEndTime)
{ {
// 计算胎心=孕妇心率*系数 // 计算胎心=孕妇心率*系数


Loading…
Cancel
Save