|
|
@@ -374,10 +374,60 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//不满足持续10分钟highFreqSampleTimes |
|
|
|
//不满足持续10分钟highFreqSampleTimes或出现时间倒叙 |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频持续时间不足{highFreqSampleTimes},只持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
|
|
|
|
|
// 高频结束后与周期性的心率时间倒叙 |
|
|
|
if ((firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds<0) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频结束出现时间倒叙,计算当条心率创建之前的高频心率"); |
|
|
|
#region 计算当条心率创建之前的高频心率 |
|
|
|
// 取得高频之后的所有数据 |
|
|
|
var phrFlashBack = daysPhr.Where(p => p.LastUpdate >= phrFreqstatus!.LastUpdate) |
|
|
|
.OrderByDescending(i => i.LastUpdate); |
|
|
|
// 取得高频数据 |
|
|
|
var freqCollection = new List<PregnancyHeartRateModel>(); |
|
|
|
PregnancyHeartRateModel? previousItem = null; |
|
|
|
|
|
|
|
foreach (var item in phrFlashBack) |
|
|
|
{ |
|
|
|
if (previousItem != null) |
|
|
|
{ |
|
|
|
var timeNextDiff = (previousItem!.LastUpdate - item.LastUpdate).TotalSeconds; |
|
|
|
if (timeNextDiff <= highFreqSampleInterval) |
|
|
|
{ |
|
|
|
freqCollection.Add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
previousItem = item; |
|
|
|
} |
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频数据个数{freqCollection.Count},触发高频开始时间{phrFreqstatus!.LastUpdate}"); |
|
|
|
if (freqCollection.Count>=stopHighFreqSampleCount) |
|
|
|
{ |
|
|
|
// 计算高频产生的胎心 |
|
|
|
var avgPhr = freqCollection |
|
|
|
.OrderByDescending(i => i.LastUpdate) |
|
|
|
.Take(stopHighFreqSampleCount) // 计算最后12条 |
|
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
|
|
await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), freqCollection.Last().LastUpdate, freqCollection.First().LastUpdate); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 时间倒叙触发计算高频心率的数据不足{stopHighFreqSampleCount}条,不进行胎心计算"); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频持续时间不足{highFreqSampleTimes},只持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 删除高频状态的首条记录 |
|
|
|