diff --git a/.env b/.env index 105b61f..68d2b2c 100644 --- a/.env +++ b/.env @@ -20,6 +20,6 @@ VITE_APP_DOCALERT_ENABLE=false VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc # 默认账户密码 -VITE_APP_DEFAULT_LOGIN_TENANT = 艾康菲 +VITE_APP_DEFAULT_LOGIN_TENANT = 芋道源码 VITE_APP_DEFAULT_LOGIN_USERNAME = admin VITE_APP_DEFAULT_LOGIN_PASSWORD = admin123 diff --git a/public/abpm-report-template.html b/public/abpm-report-template.html index 1fa8994..81a33da 100644 --- a/public/abpm-report-template.html +++ b/public/abpm-report-template.html @@ -960,6 +960,7 @@ let patientData = {}; let chartDataTable = []; let analysisResult = ''; + let thresholds = {}; // 存储动态阈值配置 // 数据验证函数 function validateData(data) { @@ -1029,6 +1030,7 @@ patientData = data.patientData || {}; chartDataTable = data.chartDataTable || []; analysisResult = data.analysisResult || ''; + thresholds = data.thresholds || {}; // 接收阈值配置 showDebugInfo('患者姓名: ' + (patientData.name || '空')); showDebugInfo('图表数据条数: ' + chartDataTable.length); @@ -1301,11 +1303,11 @@ // 根据时段类型设置阈值 let systolicThreshold, diastolicThreshold; if (periodType === 'day') { - systolicThreshold = 135; - diastolicThreshold = 85; + systolicThreshold = 140; + diastolicThreshold = 90; } else if (periodType === 'night') { systolicThreshold = 120; - diastolicThreshold = 70; + diastolicThreshold = 80; } else { // all systolicThreshold = 140; diastolicThreshold = 90; @@ -2115,44 +2117,70 @@ // 渲染饼图 function renderPieCharts() { - // 收缩压饼图 - 按照C#代码的参考值 - renderPieChart('pie-systolic-day', getDaytimeData(), 'systolic', 140); // 白天: 90-140 - renderPieChart('pie-systolic-night', getNighttimeData(), 'systolic', 120); // 夜间: 80-120 - renderPieChart('pie-systolic-all', chartDataTable, 'systolic', 140); // 全天: 综合白天和夜间 + // 获取动态阈值,如果没有则使用默认值 + const daytimeSystolicThreshold = thresholds.bp_daytime_systolic || 140; + const nighttimeSystolicThreshold = thresholds.bp_nighttime_systolic || 120; + const daytimeDiastolicThreshold = thresholds.bp_daytime_diastolic || 90; + const nighttimeDiastolicThreshold = thresholds.bp_nighttime_diastolic || 80; - // 舒张压饼图 - 按照C#代码的参考值 - renderPieChart('pie-diastolic-day', getDaytimeData(), 'diastolic', 90); // 白天: 65-90 - renderPieChart('pie-diastolic-night', getNighttimeData(), 'diastolic', 80); // 夜间: 55-80 - renderPieChart('pie-diastolic-all', chartDataTable, 'diastolic', 90); // 全天: 综合白天和夜间 + // 心率动态阈值 + const daytimeHrMinThreshold = thresholds.hr_daytime_min || 50; + const daytimeHrMaxThreshold = thresholds.hr_daytime_max || 90; + const nighttimeHrMinThreshold = thresholds.hr_nighttime_min || 50; + const nighttimeHrMaxThreshold = thresholds.hr_nighttime_max || 90; - // 心率饼图 - 按照C#代码的参考值 - renderPieChart('pie-hr-day', getDaytimeData(), 'heartRate', null); // 白天: 50-90 - renderPieChart('pie-hr-night', getNighttimeData(), 'heartRate', null); // 夜间: 50-90 - renderPieChart('pie-hr-all', chartDataTable, 'heartRate', null); // 全天: 50-90 + // 收缩压饼图 - 使用动态阈值 + renderPieChart('pie-systolic-day', getDaytimeData(), 'systolic', daytimeSystolicThreshold, 'day'); + renderPieChart('pie-systolic-night', getNighttimeData(), 'systolic', nighttimeSystolicThreshold, 'night'); + renderPieChart('pie-systolic-all', chartDataTable, 'systolic', null, 'all'); // 全天数据需要综合判断 + + // 舒张压饼图 - 使用动态阈值 + renderPieChart('pie-diastolic-day', getDaytimeData(), 'diastolic', daytimeDiastolicThreshold, 'day'); + renderPieChart('pie-diastolic-night', getNighttimeData(), 'diastolic', nighttimeDiastolicThreshold, 'night'); + renderPieChart('pie-diastolic-all', chartDataTable, 'diastolic', null, 'all'); // 全天数据需要综合判断 + + // 心率饼图 - 使用动态阈值 + renderPieChart('pie-hr-day', getDaytimeData(), 'heartRate', {min: daytimeHrMinThreshold, max: daytimeHrMaxThreshold}, 'day'); + renderPieChart('pie-hr-night', getNighttimeData(), 'heartRate', {min: nighttimeHrMinThreshold, max: nighttimeHrMaxThreshold}, 'night'); + renderPieChart('pie-hr-all', chartDataTable, 'heartRate', null, 'all'); // 全天数据需要综合判断 // 填充饼图统计信息 fillPieChartStats(); } // 渲染单个饼图 - function renderPieChart(elementId, data, field, threshold) { + function renderPieChart(elementId, data, field, threshold, period) { const chart = echarts.init(document.getElementById(elementId)); let normalCount, abnormalCount; if (field === 'heartRate') { - // 按照C#代码的参考值:50-90 bpm - normalCount = data.filter(item => item[field] >= 50 && item[field] < 90).length; + // 心率:使用动态阈值 + if (threshold && typeof threshold === 'object') { + // 使用传入的动态阈值对象 + normalCount = data.filter(item => item[field] >= threshold.min && item[field] <= threshold.max).length; + } else if (period === 'all') { + // 全天数据需要根据时间判断使用哪个阈值 + normalCount = data.filter(item => { + const isDay = isDaytimeData(item); + const minHr = isDay ? (thresholds.hr_daytime_min || 50) : (thresholds.hr_nighttime_min || 50); + const maxHr = isDay ? (thresholds.hr_daytime_max || 90) : (thresholds.hr_nighttime_max || 90); + return item[field] >= minHr && item[field] <= maxHr; + }).length; + } else { + // 默认固定范围50-90 bpm + normalCount = data.filter(item => item[field] >= 50 && item[field] <= 90).length; + } abnormalCount = data.length - normalCount; } else { - // 血压的判断逻辑需要根据白天/夜间分别处理 + // 血压的判断逻辑使用动态阈值 if (field === 'systolic') { - // 收缩压:白天90-140,夜间80-120 - const isDaytime = data === getDaytimeData(); - const isNighttime = data === getNighttimeData(); + // 收缩压:使用动态阈值 + const daytimeThreshold = thresholds.bp_daytime_systolic || 140; + const nighttimeThreshold = thresholds.bp_nighttime_systolic || 120; - if (isDaytime) { + if (period === 'day') { normalCount = data.filter(item => item[field] >= 90 && item[field] < 140).length; - } else if (isNighttime) { + } else if (period === 'night') { normalCount = data.filter(item => item[field] >= 80 && item[field] < 120).length; } else { // 全天数据,需要综合判断 @@ -2166,13 +2194,13 @@ }).length; } } else if (field === 'diastolic') { - // 舒张压:白天65-90,夜间55-80 - const isDaytime = data === getDaytimeData(); - const isNighttime = data === getNighttimeData(); + // 舒张压:使用动态阈值 + const daytimeThreshold = thresholds.bp_daytime_diastolic || 90; + const nighttimeThreshold = thresholds.bp_nighttime_diastolic || 80; - if (isDaytime) { + if (period === 'day') { normalCount = data.filter(item => item[field] >= 65 && item[field] < 90).length; - } else if (isNighttime) { + } else if (period === 'night') { normalCount = data.filter(item => item[field] >= 55 && item[field] < 80).length; } else { // 全天数据,需要综合判断 diff --git a/src/views/analysis/ABPM/analysis.vue b/src/views/analysis/ABPM/analysis.vue index 966ef2d..3ec60eb 100644 --- a/src/views/analysis/ABPM/analysis.vue +++ b/src/views/analysis/ABPM/analysis.vue @@ -284,16 +284,24 @@ const defaultThresholds = { bp_moderate_diastolic: 110, // 整天血压正常值 - bp_all_day_systolic: 130, - bp_all_day_diastolic: 80, + bp_all_day_systolic: 140, + bp_all_day_diastolic: 90, // 白天血压正常值 - bp_daytime_systolic: 135, - bp_daytime_diastolic: 85, + bp_daytime_systolic: 140, + bp_daytime_diastolic: 90, // 夜间血压正常值 bp_nighttime_systolic: 120, - bp_nighttime_diastolic: 70, + bp_nighttime_diastolic: 80, + + // 心率正常范围 + hr_min: 50, + hr_max: 90, + hr_daytime_min: 50, + hr_daytime_max: 90, + hr_nighttime_min: 50, + hr_nighttime_max: 90, // 血压负荷正常范围 bp_load_min: 5, @@ -306,10 +314,10 @@ const defaultThresholds = { // 血压负荷阈值 bp_load_total_systolic: 140, bp_load_total_diastolic: 90, - bp_load_daytime_systolic: 135, - bp_load_daytime_diastolic: 85, + bp_load_daytime_systolic: 140, + bp_load_daytime_diastolic: 90, bp_load_nighttime_systolic: 120, - bp_load_nighttime_diastolic: 70 + bp_load_nighttime_diastolic: 80 } // 加载阈值配置 @@ -369,6 +377,14 @@ const loadThresholds = async (orgid: number) => { bp_nighttime_diastolic: thresholdMap['夜间_舒张压']?.maxValue || defaultThresholds.bp_nighttime_diastolic, + // 心率正常范围 - 使用动态阈值 + hr_min: thresholdMap['全天_心率']?.minValue || defaultThresholds.hr_min, + hr_max: thresholdMap['全天_心率']?.maxValue || defaultThresholds.hr_max, + hr_daytime_min: thresholdMap['白天_心率']?.minValue || defaultThresholds.hr_daytime_min, + hr_daytime_max: thresholdMap['白天_心率']?.maxValue || defaultThresholds.hr_daytime_max, + hr_nighttime_min: thresholdMap['夜间_心率']?.minValue || defaultThresholds.hr_nighttime_min, + hr_nighttime_max: thresholdMap['夜间_心率']?.maxValue || defaultThresholds.hr_nighttime_max, + // 血压负荷正常范围 - 保持默认值 bp_load_min: defaultThresholds.bp_load_min, bp_load_max: defaultThresholds.bp_load_max, @@ -1390,19 +1406,33 @@ const calculatePieChartStats = () => { if (type === 'systolic') { value = item.systolic - // 白天: 90-140, 夜间: 80-120 + // 使用动态阈值:白天和夜间收缩压 const isDayTime = isDaytime(item.time) - isNormal = isDayTime ? value >= 90 && value <= 140 : value >= 80 && value <= 120 + const minThreshold = isDayTime ? 90 : 80 + const maxThreshold = isDayTime + ? thresholds.value.bp_daytime_systolic + : thresholds.value.bp_nighttime_systolic + isNormal = value >= minThreshold && value <= maxThreshold } else if (type === 'diastolic') { value = item.diastolic - // 白天: 65-90, 夜间: 55-80 + // 使用动态阈值:白天和夜间舒张压 const isDayTime = isDaytime(item.time) - isNormal = isDayTime ? value >= 65 && value <= 90 : value >= 55 && value <= 80 + const minThreshold = isDayTime ? 65 : 55 + const maxThreshold = isDayTime + ? thresholds.value.bp_daytime_diastolic + : thresholds.value.bp_nighttime_diastolic + isNormal = value >= minThreshold && value <= maxThreshold } else { - // heartRate + // heartRate - 使用动态阈值:白天和夜间心率 value = item.heartRate - // 心率: 50-90 - isNormal = value >= 50 && value <= 90 + const isDayTime = isDaytime(item.time) + const minThreshold = isDayTime + ? thresholds.value.hr_daytime_min + : thresholds.value.hr_nighttime_min + const maxThreshold = isDayTime + ? thresholds.value.hr_daytime_max + : thresholds.value.hr_nighttime_max + isNormal = value >= minThreshold && value <= maxThreshold } if (isNormal) { @@ -1444,7 +1474,8 @@ const handleReportPreview = () => { patientData: patientData, chartDataTable: chartDataTable.value, analysisResult: analysisResult.value, - pieChartStats: pieChartStats + pieChartStats: pieChartStats, + thresholds: thresholds.value // 传递动态阈值配置 } // 打开新窗口并全屏展示 abpm-report-template.html (注意路径不包含public)