Browse Source

调整时序计算

datasub12_fetal_heart_rate_0
H Vs 3 months ago
parent
commit
250e6fc56e
2 changed files with 17 additions and 11 deletions
  1. +13
    -8
      HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs
  2. +4
    -3
      HealthMonitor.WebApi/Worker.cs

+ 13
- 8
HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs View File

@@ -173,7 +173,11 @@ namespace HealthMonitor.Service.Resolver



var phr = await _serviceTDengine.GetBySerialNoAsync<PregnancyHeartRateModel>(heartRate.Serialno, 7);
var daysPhr = await _serviceTDengine.GetBySerialNoAsync<PregnancyHeartRateModel>(heartRate.Serialno, 7);
var phr = daysPhr
.Where(p => p.LastUpdate >= heartRate.LastUpdate)
.ToList();

if (phr.Count >= 30)
{
#region 定时计算胎动数据触发器两小时间隔开始
@@ -245,17 +249,17 @@ namespace HealthMonitor.Service.Resolver
}
/// phr PregnancyHeartRate 连续连续正常次数个值都是正常(大于等于triggerHighFreqLow,少于等于triggerHighFreqHig),
/// 取连续正常次数正常值的平均值,推送到api/v1/open/OpenIot/SetFetalHeartRateConfig
#region 检查是否连续12个心率值都是正常的
#region 检查高频状态是否连续12个心率值都是正常的
// 获取最近连续正常次数个心率记录
//_logger.LogInformation($"{heartRate.Serialno} 设置 stopHighFreqSampleCount {stopHighFreqSampleCount}");

var lastPhr = phr.OrderByDescending(i => i.LastUpdate).Take(stopHighFreqSampleCount).ToList();
//var lastPhr = phr.OrderByDescending(i => i.LastUpdate).Take(stopHighFreqSampleCount).ToList();
var lastPhr = phr.Where(i=>i.LastUpdate>= phrFreqstatus!.LastUpdate).Take(stopHighFreqSampleCount).ToList();

//_logger.LogInformation($"{heartRate.Serialno} 设置 lastPhr {lastPhr.Count}");
//_logger.LogInformation($"{heartRate.Serialno} 设置 triggerHighFreqLow {triggerHighFreqLow}");
//_logger.LogInformation($"{heartRate.Serialno} 设置 triggerHighFreqHigh {triggerHighFreqHigh}");
// 检查是否连续12个值都是正常的
if (lastPhr.All(i => i.PregnancyHeartRate >= triggerHighFreqLow && i.PregnancyHeartRate <= triggerHighFreqHigh))
if (lastPhr.Count >= stopHighFreqSampleCount &&
lastPhr.All(i => i.PregnancyHeartRate >= triggerHighFreqLow && i.PregnancyHeartRate <= triggerHighFreqHigh)
)
{
var avgPhr = lastPhr.Select(i => i.PregnancyHeartRate).Average();
// 计算一般心率得到胎心系数
@@ -512,7 +516,8 @@ namespace HealthMonitor.Service.Resolver
var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0);
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno);
if (phrFreqstatus == null) isAbnormal = 0;
var statsusDesc = (phrFreqstatus == null) ? "平常" : "高频";
_logger.LogInformation($"{heartRate.Serialno} 在 {statsusDesc} 状态,生成胎心值:{fetalHeartRate},统计周期:{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}----{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
//if (!isFreq)
//{
// statStartTime = heartRate.LastUpdate;


+ 4
- 3
HealthMonitor.WebApi/Worker.cs View File

@@ -312,12 +312,12 @@ namespace HealthMonitor.WebApi
else
{
var phr = await _serviceTDengine.GetBySerialNoAsync<PregnancyHeartRateModel>(imeiDel, 7);
var freqFirstPhr = phr.Where(p => p.MessageId == triggerHeartRate?.MessageId).First();
// 修改缓存中高频状态触发心率
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(imeiDel);
if (phrFreqstatus != null)
{
#region 修改首条高频心率
var freqFirstPhr = phr.Where(p => p.MessageId == triggerHeartRate?.MessageId).First();
await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(imeiDel, freqFirstPhr);
_logger.LogInformation($"{imeiDel} 设置高频状态,修正触发的孕妇心率记录");
#endregion
@@ -1002,7 +1002,7 @@ namespace HealthMonitor.WebApi
var phrValue = filteredPhr.Count == 1
? filteredPhr.First().PregnancyHeartRate
: filteredPhr.Average(i => i.PregnancyHeartRate);
//await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR!, upperAlarmThreshold, lowerAlarmThreshold, phrValue, sampleTimeFHR);
await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR!, upperAlarmThreshold, lowerAlarmThreshold, phrValue, sampleTimeFHR, normalPhrStatStartTime, normalPhrStatEndTime);
}
@@ -1033,7 +1033,8 @@ namespace HealthMonitor.WebApi
var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0);
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno);
if (phrFreqstatus == null) isAbnormal = 0;

var statsusDesc = (phrFreqstatus == null) ? "平常" : "高频";
_logger.LogInformation($"{heartRate.Serialno} 在 {statsusDesc} 状态,生成胎心值:{fetalHeartRate},统计周期:{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}----{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
//if (!isFreq)
//{
// statStartTime = heartRate.LastUpdate;


Loading…
Cancel
Save