Pārlūkot izejas kodu

生理健康与胎动的关系

datasub12_fetal_heart_rate
H Vs pirms 3 mēnešiem
vecāks
revīzija
4880d4593d
4 mainītis faili ar 203 papildinājumiem un 3 dzēšanām
  1. +75
    -1
      HealthMonitor.Service/Cache/PersonCacheManager.cs
  2. +1
    -1
      HealthMonitor.Service/HealthMonitor.Service.csproj
  3. +1
    -1
      HealthMonitor.WebApi/HealthMonitor.WebApi.csproj
  4. +126
    -0
      HealthMonitor.WebApi/Worker.cs

+ 75
- 1
HealthMonitor.Service/Cache/PersonCacheManager.cs Parādīt failu

@@ -12,6 +12,7 @@ using System.Threading.Tasks;
using TelpoDataService.Util;
using TelpoDataService.Util.Clients;
using TelpoDataService.Util.Entities.GpsCard;
using TelpoDataService.Util.Entities.GpsLocationHistory;
using TelpoDataService.Util.Models;
using TelpoDataService.Util.QueryObjects;

@@ -23,8 +24,17 @@ namespace HealthMonitor.Service.Cache

//注意要改用 redis DB7 数据库 ,Prefix=TELPO
private const string CACHE_HASH_KEY_GPSDEVICEPERSON = "#GPSDEVICE_PERSON_HASH";
//注意要改用 redis DB7 数据库 ,Prefix=TELPO

#region db10
// 周期性体温
private const string CACHE_HASH_KEY_TEMP_PERIODICITY = "#HM_PERIODICITY_TEMP_HASH";

// 周期性步数
private const string CACHE_HASH_KEY_STEP_PERIODICITY = "#HM_PERIODICITY_STEP_HASH";

// 周期性血压
private const string CACHE_HASH_KEY_BLOODPRESS_PERIODICITY = "#HM_PERIODICITY_BLOODPRESS_HASH";
#endregion

private readonly GpsCardAccessorClient<GpsPerson> _personApiClient;
private readonly ILogger<PersonCacheManager> _logger;
@@ -165,5 +175,69 @@ namespace HealthMonitor.Service.Cache
return flag;

}


#region 生理健康(步数、周期性体温、周期性血压)
// 周期性体温
public async Task<HisGpsTemperature?> GetTemperaturePeriodicityAsync(string sn)
{
try
{
var res=await RedisHelper.HGetAsync(CACHE_HASH_KEY_TEMP_PERIODICITY, sn);
if (!string.IsNullOrEmpty(res))
{
return JsonConvert.DeserializeObject<HisGpsTemperature>(res)!;
}

}
catch (Exception ex)
{

_logger.LogError($"Redis发生异常:{ex.Message}, {ex.StackTrace}");
}
return null;

}

// 周期性步数
public async Task<HisGpsStep?> GetStepPeriodicityAsync(string sn )
{
try
{
var res = await RedisHelper.HGetAsync(CACHE_HASH_KEY_STEP_PERIODICITY, sn);
if (!string.IsNullOrEmpty(res))
{
return JsonConvert.DeserializeObject<HisGpsStep>(res)!;
}
}
catch (Exception ex)
{

_logger.LogError($"Redis发生异常:{ex.Message}, {ex.StackTrace}");
}
return null;
}

// 周期性血压
public async Task<HisGpsBloodPress?> GetBloodPressPeriodicityAsync(string sn)
{
try
{
var res = await RedisHelper.HGetAsync(CACHE_HASH_KEY_BLOODPRESS_PERIODICITY, sn);
if (!string.IsNullOrEmpty(res))
{
return JsonConvert.DeserializeObject<HisGpsBloodPress>(res)!;
}
}
catch (Exception ex)
{

_logger.LogError($"Redis发生异常:{ex.Message}, {ex.StackTrace}");
}
return null;
}

#endregion

}
}

+ 1
- 1
HealthMonitor.Service/HealthMonitor.Service.csproj Parādīt failu

@@ -16,7 +16,7 @@
<PackageReference Include="SqlSugarCore" Version="5.1.4.160" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="TDengine.Connector" Version="3.0.2" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.31-beta1" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.33-beta1" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
HealthMonitor.WebApi/HealthMonitor.WebApi.csproj Parādīt failu

@@ -11,7 +11,7 @@
<PackageReference Include="Serilog.Expressions" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.31-beta1" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.33-beta1" />
</ItemGroup>

<ItemGroup>


+ 126
- 0
HealthMonitor.WebApi/Worker.cs Parādīt failu

@@ -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} 已完成.");

// 获取胎心数据状态与胎动数据状态一致


Notiek ielāde…
Atcelt
Saglabāt