|
|
@@ -151,7 +151,9 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
// 如果需要,将时间差转换为秒 |
|
|
|
var timeDiffInSeconds = timeDiff.TotalSeconds; |
|
|
|
|
|
|
|
|
|
|
|
// 高频统计结束时间 |
|
|
|
var FreqStatsEnd = DateTime.Now; |
|
|
|
// 高频心率启动 |
|
|
|
if (timeDiffInSeconds <= highFreqSampleInterval) |
|
|
|
{ |
|
|
@@ -179,8 +181,10 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
// 计算一般心率得到胎心系数 |
|
|
|
//await SaveAndPushFreqFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
// 高频数据不建模 |
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
|
|
|
|
FreqStatsEnd = (DateTime)heartRate.LastUpdate!; |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd- phrFreqstatus!.LastUpdate).TotalSeconds} 秒,连续 {stopHighFreqSampleCount} 次采样心率正常,将下发指令"); |
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
} |
|
|
@@ -204,7 +208,10 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//await SaveAndPushFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, avgPhr); |
|
|
|
//await SaveAndPushFreqFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
// 高频数据不建模 |
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
FreqStatsEnd = firstTwoPhr[1]; |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,highFreqSampleTimes={highFreqSampleTimes}秒,即将结束高频状态,将下发指令"); |
|
|
|
|
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@@ -224,15 +231,16 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//await SaveAndPushFreqFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
//await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
// 高频数据不建模 |
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString()); |
|
|
|
FreqStatsEnd = firstTwoPhr[1]; |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,超过规定的 {highFreqSampleTimes} 秒,即将结束高频状态,将下发指令"); |
|
|
|
|
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
// 删除高频状态的首条记录 |
|
|
|
await _deviceCacheMgr.DelPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
|
|
|
|
|
/// 设置高频状态 |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 结束高频心率状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval}"); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 结束高频心率状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval},高频状态持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
|
} |
|
|
|
// 正常心率 |
|
|
|
else |
|
|
@@ -242,23 +250,23 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
// 获取当前时间 |
|
|
|
DateTime nowInterval = (DateTime)heartRate.LastUpdate!; |
|
|
|
|
|
|
|
// 计算last_update到上一刻钟的分钟数 |
|
|
|
// 计算last_update到上一间隔的分钟数 |
|
|
|
int minutesToSubtract = nowInterval.Minute % intervalFHR; |
|
|
|
|
|
|
|
// 计算上一刻钟的时间 |
|
|
|
// 计算上一间隔的时间 |
|
|
|
DateTime previousInterval = nowInterval.AddMinutes(-minutesToSubtract).AddSeconds(-nowInterval.Second).AddMilliseconds(-nowInterval.Millisecond); |
|
|
|
|
|
|
|
// 使用 last_update 上一刻 |
|
|
|
var sampleTimeFHR = DateTimeUtil.ConvertToTimeStamp(previousInterval).ToString(); |
|
|
|
|
|
|
|
// 计算last_update到下一刻钟的分钟数 |
|
|
|
// 计算last_update到下一间隔的分钟数 |
|
|
|
int minutesToAdd = intervalFHR - (nowInterval.Minute % intervalFHR); |
|
|
|
if (minutesToAdd == intervalFHR) |
|
|
|
{ |
|
|
|
minutesToAdd = 0; // 如果已经是刻钟,则不需要增加分钟 |
|
|
|
minutesToAdd = 0; // 如果已经是间隔,则不需要增加分钟 |
|
|
|
} |
|
|
|
|
|
|
|
// 计算下一刻钟的时间 |
|
|
|
// 计算下一间隔的时间 |
|
|
|
DateTime nextInterval = nowInterval.AddMinutes(minutesToAdd) |
|
|
|
.AddSeconds(-nowInterval.Second) |
|
|
|
.AddMilliseconds(-nowInterval.Millisecond); |
|
|
@@ -289,7 +297,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
fetalHeartRateIsAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0); |
|
|
|
fetalHeartRateIsAbnormal = 0;// 不是高频数据,按正常值 |
|
|
|
HisGpsFetalHeartRate gpsFetalHeartRate = new() |
|
|
|
/* HisGpsFetalHeartRate gpsFetalHeartRate = new() |
|
|
|
{ |
|
|
|
FetalHeartRateId = Guid.NewGuid().ToString("D"), |
|
|
|
PersonId = commonPHR!.PersonId, |
|
|
@@ -334,6 +342,11 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
}; |
|
|
|
await _serviceMqProcess.ProcessIMEIEventMessageAsync(fhrMsgId, topic, fhrMsg).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR!, upperAlarmThreshold, lowerAlarmThreshold, phrValue, sampleTimeFHR,false); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -510,17 +523,17 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//await SetIntervalTriggerAsync(fetalKey, heartRate.Serialno, 60 * 15); |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 定时计算胎心数据触发器下一刻钟后 |
|
|
|
#region 定时计算胎心数据触发器下一间隔后 |
|
|
|
//// 获取当前时间 |
|
|
|
//DateTime nowInterval = DateTime.Now; |
|
|
|
|
|
|
|
//// 计算下一个15分钟的刻钟 |
|
|
|
//// 计算下一个15分钟的间隔 |
|
|
|
//int minutesToAdd = 15 - (nowInterval.Minute % 15); |
|
|
|
//if (minutesToAdd == 15) |
|
|
|
//{ |
|
|
|
// minutesToAdd = 0; // 如果已经是刻钟,则不需要增加分钟 |
|
|
|
// minutesToAdd = 0; // 如果已经是间隔,则不需要增加分钟 |
|
|
|
//} |
|
|
|
//// 计算下一刻钟的时间 |
|
|
|
//// 计算下一间隔的时间 |
|
|
|
//DateTime nextInterval = nowInterval.AddMinutes(minutesToAdd) |
|
|
|
// .AddSeconds(-nowInterval.Second) |
|
|
|
// .AddMilliseconds(-nowInterval.Millisecond); |
|
|
@@ -722,12 +735,23 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
private async Task SaveAndPushFreqFetalHeartRateAsync(HisGpsHeartRate heartRate, PregnancyCommonHeartRateModel commonPHR, int upperAlarmThreshold, int lowerAlarmThreshold, double avgPhr,string sampleTime) |
|
|
|
/// <summary> |
|
|
|
/// |
|
|
|
/// </summary> |
|
|
|
/// <param name="heartRate"></param> |
|
|
|
/// <param name="commonPHR"></param> |
|
|
|
/// <param name="upperAlarmThreshold"></param> |
|
|
|
/// <param name="lowerAlarmThreshold"></param> |
|
|
|
/// <param name="phr"></param> |
|
|
|
/// <param name="sampleTime">使用高频心率的首条last_update</param> |
|
|
|
/// <param name="isFreq"></param> |
|
|
|
/// <returns></returns> |
|
|
|
private async Task SaveAndPushFreqFetalHeartRateAsync(HisGpsHeartRate heartRate, PregnancyCommonHeartRateModel commonPHR, int upperAlarmThreshold, int lowerAlarmThreshold, double phr,string sampleTime,bool isFreq = true) |
|
|
|
{ |
|
|
|
// 计算胎心=孕妇心率*系数 |
|
|
|
var fetalHeartRate = SafeType.SafeInt(avgPhr * commonPHR?.StatModeAvgFprCoefficient!); |
|
|
|
var fetalHeartRate = SafeType.SafeInt(phr * commonPHR?.StatModeAvgFprCoefficient!); |
|
|
|
var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0); |
|
|
|
|
|
|
|
if (!isFreq) isAbnormal = 0; |
|
|
|
// 保存到 数据服务 MySQL 数据库 |
|
|
|
HisGpsFetalHeartRate gpsFetalHeartRate = new() |
|
|
|
{ |
|
|
|