Browse Source

高频和非高频时间倒叙处理

datasub12_fetal_heart_rate_0
H Vs 3 months ago
parent
commit
98a7029cae
1 changed files with 52 additions and 2 deletions
  1. +52
    -2
      HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs

+ 52
- 2
HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs View File

@@ -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} 秒");

}

}

// 删除高频状态的首条记录


Loading…
Cancel
Save