|
|
@@ -53,6 +53,8 @@ namespace HealthMonitor.WebApi |
|
|
|
private readonly GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> _hisFetalHeartApiClient; |
|
|
|
private readonly GpsLocationHistoryAccessorClient<HisGpsFetalMovement> _hisFetalMovementApiClient; |
|
|
|
|
|
|
|
private readonly GpsLocationHistoryAccessorClient<HisGpsPsychResult> _hisPsychResultApiClient; |
|
|
|
|
|
|
|
private readonly MqProcessLogic _serviceMqProcess; |
|
|
|
|
|
|
|
private CancellationTokenSource _tokenSource = default!; |
|
|
@@ -63,6 +65,7 @@ namespace HealthMonitor.WebApi |
|
|
|
TDengineDataSubcribe tdEngineDataSubcribe, TDengineService serviceDengine, |
|
|
|
GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> hisFetalHeartApiClient, |
|
|
|
GpsLocationHistoryAccessorClient<HisGpsFetalMovement> hisFetalMovementApiClient, |
|
|
|
GpsLocationHistoryAccessorClient<HisGpsPsychResult> hisGpsPsychResultApiClient, |
|
|
|
FetalMovementNormalValueRangeCacheManager fetalMovementNormalValueRangeCacheMgr, MqProcessLogic serviceMqProcess, |
|
|
|
HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr) |
|
|
|
{ |
|
|
@@ -80,8 +83,10 @@ namespace HealthMonitor.WebApi |
|
|
|
_deviceCacheMgr = deviceCacheMgr; |
|
|
|
_hisFetalHeartApiClient = hisFetalHeartApiClient; |
|
|
|
_hisFetalMovementApiClient = hisFetalMovementApiClient; |
|
|
|
_hisPsychResultApiClient = hisGpsPsychResultApiClient; |
|
|
|
_serviceMqProcess = serviceMqProcess; |
|
|
|
_mgrFetalMovementNormalValueRangeCache = fetalMovementNormalValueRangeCacheMgr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override Task StartAsync(CancellationToken cancellationToken) |
|
|
@@ -521,6 +526,127 @@ namespace HealthMonitor.WebApi |
|
|
|
var fetalMovement = (int)Math.Round(fetalMovementValue, 0, MidpointRounding.AwayFromZero); |
|
|
|
// _logger.LogInformation($"{imeiDel} segmentCountFMIndex: {i} -- fetalMovementSampleTime:{fetalMovementSampleTime}|{midNight.AddHours(2 * i).ToString("yyyy-MM-dd HH:mm:ss")} -- statStartTime: {statStartTime} -- statEndTime: {statEndTime}-- isFetalMovementExisted: {isFetalMovementExisted} "); |
|
|
|
|
|
|
|
#region 生理健康与胎动的关系 |
|
|
|
/// (步数)运动步数超过1500步则加1; |
|
|
|
/// (体温)低烧则胎动减1,高烧胎动减2;低烧是37.3~38.5,38.6以上是高烧。 |
|
|
|
/// (血压)血压收缩压大于160则加1。 |
|
|
|
/// (心理)心理压力高加2,压力中加1; |
|
|
|
|
|
|
|
var fetalMovementStepVar = 0; |
|
|
|
var fetalMovementTempVar = 0; |
|
|
|
var fetalMovementBpVar = 0; |
|
|
|
var fetalMovementPpVar = 0; |
|
|
|
// 步数 |
|
|
|
if (true) |
|
|
|
{ |
|
|
|
var step = await _personCacheMgr.GetStepPeriodicityAsync(imeiDel); |
|
|
|
if (DateTime.Now.Hour - ((DateTime)step?.LastUpdate!).Hour <= 2) |
|
|
|
{ |
|
|
|
if (step.Steps > 1500) fetalMovementStepVar = 1; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogWarning($"{imeiDel} 周期步数 时间无效"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 体温 |
|
|
|
if (true) |
|
|
|
{ |
|
|
|
var temp = await _personCacheMgr.GetTemperaturePeriodicityAsync(imeiDel); |
|
|
|
if (DateTime.Now.Hour - ((DateTime)temp?.LastUpdate!).Hour <= 2) |
|
|
|
{ |
|
|
|
// 中烧 |
|
|
|
if (temp.Temperature>=37.3M&& temp.Temperature<= 38.5M) |
|
|
|
{ |
|
|
|
fetalMovementTempVar = -1; |
|
|
|
} |
|
|
|
// 高烧 |
|
|
|
if (temp.Temperature >= 38.6M) |
|
|
|
{ |
|
|
|
fetalMovementTempVar = -2; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogWarning($"{imeiDel} 周期体温 时间无效"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 血压 |
|
|
|
if (true) |
|
|
|
{ |
|
|
|
var bp = await _personCacheMgr.GetBloodPressPeriodicityAsync(imeiDel); |
|
|
|
if (DateTime.Now.Hour - ((DateTime)bp?.LastUpdate!).Hour <= 2) |
|
|
|
{ |
|
|
|
if (bp.SystolicValue>160) |
|
|
|
{ |
|
|
|
fetalMovementBpVar = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogWarning($"{imeiDel} 周期血压 时间无效"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 心理 |
|
|
|
if (true) |
|
|
|
{ |
|
|
|
//-1 不处理, |
|
|
|
//0 正常, |
|
|
|
//1 轻度, |
|
|
|
//2 中度; |
|
|
|
//3 重度; |
|
|
|
GeneralParam psychResultParam = new() |
|
|
|
{ |
|
|
|
Filters = new List<QueryFilterCondition> |
|
|
|
{ |
|
|
|
new () |
|
|
|
{ |
|
|
|
Key=nameof(HisGpsPsychResult.Serialno), |
|
|
|
Value=imeiDel, |
|
|
|
ValueType=QueryValueTypeEnum.String, |
|
|
|
Operator=QueryOperatorEnum.Equal |
|
|
|
}, |
|
|
|
//new () |
|
|
|
//{ |
|
|
|
// Key=nameof(HisGpsFetalHeartRate.SampleTime), |
|
|
|
// Value=sampleTime, |
|
|
|
// ValueType=QueryValueTypeEnum.String, |
|
|
|
// Operator=QueryOperatorEnum.GreaterEqual |
|
|
|
//}, |
|
|
|
}, |
|
|
|
OrderBys = new List<OrderByCondition> |
|
|
|
{ |
|
|
|
new (){ |
|
|
|
IsDesc=true, |
|
|
|
Key=nameof(HisGpsPsychResult.Serialno) |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
var psych = await _hisPsychResultApiClient.GetFirstAsync(psychResultParam, imeiDel[^2..], null, new RequestHeader { RequestId = Guid.NewGuid().ToString("D") }); |
|
|
|
|
|
|
|
if (psych?.StressScore == 2) |
|
|
|
{ |
|
|
|
fetalMovementPpVar = 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (psych?.StressScore == 3) |
|
|
|
{ |
|
|
|
fetalMovementPpVar = 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_logger.LogInformation($"{imeiDel} 原始胎动值:{fetalMovementValue}, 步数变动值:{fetalMovementStepVar},体温变动值:{fetalMovementTempVar},血压变动值:{fetalMovementBpVar},心理压力变动值{fetalMovementPpVar}"); |
|
|
|
fetalMovementValue = fetalMovementValue + fetalMovementStepVar + fetalMovementTempVar + fetalMovementBpVar + fetalMovementPpVar; |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 胎心与胎动的关系 |
|
|
|
// 胎心值过缓时,则胎动数量减1;胎心值过速时,则胎动也加1。 |
|
|
|
// 此值允许在上限值上继续增加,在下限值上继续减少,最小值为0。 |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
_logger.LogInformation($"{imeiDel} 孕周:{pregnancyWeeks},胎动数据采样时间:{fetalMovementSampleTime}|{fmNowSubtract.ToString("yyyy-MM-dd HH:mm:ss")}, 采样周期:{statStartTime}-{statEndTime}, 原始胎动值:{fetalMovementMapValue}, 佩戴时间 :{duringMins}|{phrRange.Last()}-{phrRange.First()}, 胎动计算值:{fetalMovementValue}, 胎动最终值:{fetalMovement} 已完成."); |
|
|
|
|
|
|
|
// 获取胎心数据状态与胎动数据状态一致 |
|
|
|