|
|
@@ -231,7 +231,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
var FreqStatsEnd = DateTime.Now; |
|
|
|
|
|
|
|
|
|
|
|
// 高频心率启动 |
|
|
|
// 高频心率启动(在高频第二条才能判断) |
|
|
|
if (timeDiffInSeconds <= highFreqSampleInterval) |
|
|
|
{ |
|
|
|
|
|
|
@@ -243,7 +243,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
// 设置高频状态 |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} phr.Count {phr.Count}"); |
|
|
|
var freqFirstPhr = phr.OrderByDescending(i => i.LastUpdate) |
|
|
|
.Skip(1) |
|
|
|
.Skip(1) //在高频第二条才能判断,所以要去除本条记录 |
|
|
|
.First(); |
|
|
|
await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno, freqFirstPhr); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 设置高频状态"); |
|
|
@@ -364,10 +364,10 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//.Where(i => i.PregnancyHeartRate < triggerHighFreqLow || i.PregnancyHeartRate > triggerHighFreqHigh) |
|
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
|
|
|
|
|
|
// 高频数据不建模 |
|
|
|
|
|
|
|
FreqStatsEnd = firstTwoPhr[1]; |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,超过约定的 {highFreqSampleTimes} 秒,即将结束高频状态,将下发指令"); |
|
|
|
|
|
|
|
//计算高频 |
|
|
|
await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); |
|
|
|
|
|
|
|
} |
|
|
@@ -381,8 +381,8 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
// 高频结束后与周期性的心率时间倒叙 |
|
|
|
if ((firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds<0) |
|
|
|
// 高频结束后与常规的心率时间倒叙 |
|
|
|
if ((firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds < 0) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频结束出现时间倒叙,计算当条心率创建之前的高频心率"); |
|
|
|
#region 计算当条心率创建之前的高频心率 |
|
|
@@ -408,7 +408,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//} |
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频数据个数{freqCollection.Count},触发高频开始时间{phrFreqstatus!.LastUpdate}"); |
|
|
|
if (freqCollection.Count>=stopHighFreqSampleCount) |
|
|
|
if (freqCollection.Count >= stopHighFreqSampleCount) |
|
|
|
{ |
|
|
|
// 计算高频产生的胎心 |
|
|
|
var avgPhr = freqCollection |
|
|
@@ -439,22 +439,24 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 超时结束高频心率状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval},高频状态持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
|
|
|
|
|
// 计算本次常规心率的胎心数据 |
|
|
|
// 计算本次常规心率的胎心数据(高频结束后,实时处理) |
|
|
|
await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR); |
|
|
|
//// 使用延后计算 |
|
|
|
//var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
|
//var fhrScheduleTTL = 60; |
|
|
|
//await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate); |
|
|
|
} |
|
|
|
// 常规心率 |
|
|
|
// 常规心率(本次心率可能是高频心率的首条,所以要使用延后计算胎心率) |
|
|
|
else |
|
|
|
{ |
|
|
|
// 计算本次常规心率的胎心数据 |
|
|
|
await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR); |
|
|
|
// 使用延后计算 |
|
|
|
//var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
|
//var fhrScheduleTTL = 60; |
|
|
|
//await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate); |
|
|
|
//await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR); |
|
|
|
// 本次心率可能是高频心率的首条,所以要使用本次常规心率延后计算胎心率 |
|
|
|
var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
|
var fhrScheduleTTL = 30; |
|
|
|
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 延时50秒,判断当前数据是否为高频首条"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|