From 1e8269c7225c61c6dfa1b75f0d1c84e1454b4da2 Mon Sep 17 00:00:00 2001 From: H Vs Date: Fri, 23 Aug 2024 14:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=83=8E=E5=BF=83=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=80=BC=E8=B0=83=E6=95=B4=E4=B8=BA220?= =?UTF-8?q?=EF=BC=8C=E8=B6=85=E8=BF=87=E9=83=BD=E6=8C=89=E8=AF=A5=E5=80=BC?= =?UTF-8?q?220=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resolver/PregnancyHeartRateResolver.cs | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs b/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs index c41dee2..a2c4584 100644 --- a/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs +++ b/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs @@ -236,7 +236,6 @@ namespace HealthMonitor.Service.Resolver // 高频心率启动(在高频第二条才能判断) if (timeDiffInSeconds <= highFreqSampleInterval) { - var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); if (phrFreqstatus == null) { @@ -250,6 +249,7 @@ namespace HealthMonitor.Service.Resolver await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno, freqFirstPhr); _logger.LogInformation($"{heartRate.Serialno} 设置高频状态"); phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); + // 通过续租 延时计算高频心率的胎心 } /// phr PregnancyHeartRate 连续连续正常次数个值都是正常(大于等于triggerHighFreqLow,少于等于triggerHighFreqHig), @@ -642,7 +642,8 @@ namespace HealthMonitor.Service.Resolver #endregion var fetalHeartRate = SafeType.SafeInt(phrValue * coefficient); - + // 胎心的最大值调整为220,超过都按该值220输出 + fetalHeartRate = fetalHeartRate>= 220 ? 220 : fetalHeartRate; var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0); var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); @@ -795,6 +796,7 @@ namespace HealthMonitor.Service.Resolver /// 去除高频数据 /// /// + /// /// private static List GetNonFreqPregnancyHeartRate(List phr,int highFreqSampleInterval) { @@ -825,5 +827,39 @@ namespace HealthMonitor.Service.Resolver } + /// + /// 获取高频数据 + /// + /// + /// + /// + private static List GetFreqPregnancyHeartRate(List phr, int highFreqSampleInterval) + { + phr = phr.OrderByDescending(i => i.LastUpdate).ToList(); + var freqCollection = new List(); + PregnancyHeartRateModel? previousItem = null; + + foreach (var item in phr) + { + if (previousItem != null) + { + var timeNextDiff = (previousItem.LastUpdate - item.LastUpdate).TotalSeconds; + if (timeNextDiff <= highFreqSampleInterval) + { + freqCollection.Add(previousItem); + } + } + previousItem = item; + } + + // 检查最后一条是否高频 + if (previousItem != null && (phr.Last().LastUpdate - previousItem.LastUpdate).TotalSeconds <= highFreqSampleInterval) + { + freqCollection.Add(previousItem); + } + + return freqCollection; + } + } }