Sfoglia il codice sorgente

计算平时胎心延迟60s,并判断是否为高频首条

datasub12_fetal_heart_rate_0
H Vs 3 mesi fa
parent
commit
d1e66c9073
2 ha cambiato i file con 63 aggiunte e 26 eliminazioni
  1. +13
    -11
      HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs
  2. +50
    -15
      HealthMonitor.WebApi/Worker.cs

+ 13
- 11
HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs Vedi File

@@ -198,7 +198,7 @@ namespace HealthMonitor.Service.Resolver
TimeSpan timeUntilNextRun = nextRunTime - fmScheduleNow;
var ttl = (long)timeUntilNextRun.TotalSeconds;

await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl);
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl,heartRate);
}
#endregion

@@ -247,13 +247,13 @@ namespace HealthMonitor.Service.Resolver
/// 取连续正常次数正常值的平均值,推送到api/v1/open/OpenIot/SetFetalHeartRateConfig
#region 检查是否连续12个心率值都是正常的
// 获取最近连续正常次数个心率记录
_logger.LogInformation($"{heartRate.Serialno} 设置 stopHighFreqSampleCount {stopHighFreqSampleCount}");
//_logger.LogInformation($"{heartRate.Serialno} 设置 stopHighFreqSampleCount {stopHighFreqSampleCount}");

var lastPhr = phr.OrderByDescending(i => i.LastUpdate).Take(stopHighFreqSampleCount).ToList();

_logger.LogInformation($"{heartRate.Serialno} 设置 lastPhr {lastPhr.Count}");
_logger.LogInformation($"{heartRate.Serialno} 设置 triggerHighFreqLow {triggerHighFreqLow}");
_logger.LogInformation($"{heartRate.Serialno} 设置 triggerHighFreqHigh {triggerHighFreqHigh}");
//_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))
{
@@ -381,8 +381,8 @@ namespace HealthMonitor.Service.Resolver
//await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR);
// 使用延后计算
var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}";
var fhrScheduleTTL = 10;
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL);
var fhrScheduleTTL = 60;
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate);
}
// 平常心率
else
@@ -391,8 +391,8 @@ namespace HealthMonitor.Service.Resolver
//await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR);
// 使用延后计算
var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}";
var fhrScheduleTTL = 10;
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL);
var fhrScheduleTTL = 60;
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate);
}
}

@@ -586,7 +586,7 @@ namespace HealthMonitor.Service.Resolver
}
}

private async Task SetIntervalTriggerAsync(string key,string imei, long interval)
private async Task SetIntervalTriggerAsync(string key,string imei, long interval,HisGpsHeartRate heartRate)
{
// var key = $"health_monitor/schedule_push/{type}/imei/{imei}";
var schedulePush = await _serviceEtcd.GetValAsync(key).ConfigureAwait(false);
@@ -599,7 +599,9 @@ namespace HealthMonitor.Service.Resolver
imei,
create_time = now.ToString("yyyy-MM-dd HH:mm:ss"),
ttl = interval,
next_run_time = timeNextRun.ToString("yyyy-MM-dd HH:mm:ss")
next_run_time = timeNextRun.ToString("yyyy-MM-dd HH:mm:ss"),
trigger= heartRate,

};
var result = JsonConvert.SerializeObject(data);
await _serviceEtcd.PutValAsync(key, result, interval, false).ConfigureAwait(false);


+ 50
- 15
HealthMonitor.WebApi/Worker.cs Vedi File

@@ -352,23 +352,58 @@ namespace HealthMonitor.WebApi
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(imeiDel);

// 最后一条孕妇心率
var phr= await _serviceTDengine.GetLastAsync<PregnancyHeartRateModel>(imeiDel);
var lastPhr= await _serviceTDengine.GetLastAsync<PregnancyHeartRateModel>(imeiDel);
var triggerValue= (JObject)JsonConvert.SerializeObject(e.Kv.Value.ToStringUtf8());
var trigger = triggerValue["trigger"]?.ToString();
if (!string.IsNullOrEmpty(trigger))
{
var triggerHeartRate= JsonConvert.DeserializeObject<HisGpsHeartRate>(trigger);
var isNormalHeartRate = triggerHeartRate?.MessageId == lastPhr.MessageId;
// 判断最后一条孕妇心率与解析器的触发心率是否一致
if (isNormalHeartRate)
{
HisGpsHeartRate heartRate = new()
{
CreateTime = lastPhr.CreateTime,
DeviceKey = lastPhr.DeviceKey,
HeartRate = lastPhr.PregnancyHeartRate,
HeartRateId = lastPhr.PregnancyHeartRateId,
IsDisplay = lastPhr.IsDisplay ? 1 : 0,
MessageId = lastPhr.MessageId,
LastUpdate = lastPhr.LastUpdate,
Method = lastPhr.Method,
PersonId = lastPhr.PersonId,
Serialno = lastPhr.SerialNumber
};
var intervalFHR = 15;
await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR);
}
// 不一致,触发心率是高频心率的首条
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)
{
await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(imeiDel, freqFirstPhr);
_logger.LogInformation($"{imeiDel} 设置高频状态,修正触发的孕妇心率记录");
}
else
{
_logger.LogWarning($"{imeiDel} 不在高频状态状态,但触发孕妇心率与最后一条孕妇心率不一致");
}

HisGpsHeartRate heartRate = new()
}

}
else
{
CreateTime = phr.CreateTime,
DeviceKey = phr.DeviceKey,
HeartRate = phr.PregnancyHeartRate,
HeartRateId = phr.PregnancyHeartRateId,
IsDisplay = phr.IsDisplay ? 1 : 0,
MessageId = phr.MessageId,
LastUpdate = phr.LastUpdate,
Method = phr.Method,
PersonId = phr.PersonId,
Serialno = phr.SerialNumber
};
var intervalFHR = 15;
await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR);
_logger.LogWarning("trigger is not set");
}


}
}



Loading…
Annulla
Salva