动态血压报告
This commit is contained in:
parent
953a118df0
commit
9853a60f06
2405
public/abpm-report-template.html
Normal file
2405
public/abpm-report-template.html
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,8 @@ import {
|
||||
MapChart,
|
||||
PictorialBarChart,
|
||||
PieChart,
|
||||
RadarChart
|
||||
RadarChart,
|
||||
ScatterChart
|
||||
} from 'echarts/charts'
|
||||
|
||||
import {
|
||||
@ -43,7 +44,8 @@ echarts.use([
|
||||
PictorialBarChart,
|
||||
RadarChart,
|
||||
GaugeChart,
|
||||
FunnelChart
|
||||
FunnelChart,
|
||||
ScatterChart
|
||||
])
|
||||
|
||||
export default echarts
|
||||
|
||||
@ -157,7 +157,6 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="suggestion" label="建议" align="center" />
|
||||
<el-table-column label="操作" width="100" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
@ -193,7 +192,7 @@
|
||||
<div class="result-action-buttons">
|
||||
<el-button type="primary" @click="handleSave">保存</el-button>
|
||||
<el-button @click="handleClose">关闭</el-button>
|
||||
<el-button type="success">报告浏览</el-button>
|
||||
<el-button type="success" @click="handleReportPreview">报告浏览</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-card>
|
||||
@ -407,12 +406,7 @@ const processData = (rawList: any[], existingAnalysisResult?: string) => {
|
||||
diastolic: Number(item.diastolicpressure) || 0,
|
||||
heartRate: Number(item.heartrate) || 0,
|
||||
avgBP: Math.round((Number(item.systolicpressure) + 2 * Number(item.diastolicpressure)) / 3), // 平均血压公式
|
||||
status: getBPStatus(Number(item.systolicpressure) || 0, Number(item.diastolicpressure) || 0),
|
||||
suggestion: getSuggestionByValues(
|
||||
Number(item.systolicpressure) || 0,
|
||||
Number(item.diastolicpressure) || 0,
|
||||
Number(item.heartrate) || 0
|
||||
)
|
||||
status: getBPStatus(Number(item.systolicpressure) || 0, Number(item.diastolicpressure) || 0)
|
||||
}))
|
||||
|
||||
// 3. 更新患者统计数据(从排序后的数据计算)
|
||||
@ -475,50 +469,6 @@ const getBPStatus = (systolic: number, diastolic: number) => {
|
||||
return '重度高血压'
|
||||
}
|
||||
|
||||
// 根据血压和心率值生成建议
|
||||
const getSuggestionByValues = (systolic: number, diastolic: number, heartRate: number) => {
|
||||
// 心率异常的建议
|
||||
if (heartRate < 60) {
|
||||
if (systolic >= 140 || diastolic >= 90) {
|
||||
return '心率偏慢且血压偏高,建议立即就医检查'
|
||||
}
|
||||
return '心率偏慢,建议增加运动量,如有不适请就医'
|
||||
}
|
||||
|
||||
if (heartRate > 100) {
|
||||
if (systolic >= 180 || diastolic >= 110) {
|
||||
return '心率过快且血压严重偏高,建议立即急诊就医'
|
||||
}
|
||||
if (systolic >= 140 || diastolic >= 90) {
|
||||
return '心率过快且血压偏高,建议尽快就医调整用药'
|
||||
}
|
||||
return '心率过快,建议减少刺激性饮品,放松心情'
|
||||
}
|
||||
|
||||
// 血压分级建议
|
||||
if (systolic >= 180 || diastolic >= 110) {
|
||||
return '重度高血压,建议立即就医,密切监测血压'
|
||||
}
|
||||
|
||||
if (systolic >= 160 || diastolic >= 100) {
|
||||
return '中度高血压,建议就医调整降压方案'
|
||||
}
|
||||
|
||||
if (systolic >= 140 || diastolic >= 90) {
|
||||
return '轻度高血压,建议低盐饮食,适量运动,定期监测'
|
||||
}
|
||||
|
||||
if (systolic >= 130 || diastolic >= 85) {
|
||||
return '血压偏高,建议调整生活方式,减少盐分摄入'
|
||||
}
|
||||
|
||||
if (systolic < 90 || diastolic < 60) {
|
||||
return '血压偏低,建议适量增加盐分,避免久站'
|
||||
}
|
||||
|
||||
return '血压正常,建议保持良好生活习惯'
|
||||
}
|
||||
|
||||
// 更新患者统计数据
|
||||
const updatePatientStatistics = (rawList: any[]) => {
|
||||
if (!rawList || rawList.length === 0) return
|
||||
@ -1099,6 +1049,115 @@ const clearAllData = () => {
|
||||
analysisResult.value = '暂无数据,无法生成分析报告'
|
||||
}
|
||||
|
||||
// 处理报告预览
|
||||
const handleReportPreview = () => {
|
||||
// 构造要传递的数据
|
||||
const reportData = {
|
||||
patientData: patientData,
|
||||
chartDataTable: chartDataTable.value,
|
||||
analysisResult: analysisResult.value
|
||||
}
|
||||
|
||||
console.log('准备打开报告,完整数据结构:', JSON.stringify(reportData, null, 2))
|
||||
console.log('患者数据:', patientData)
|
||||
console.log('图表数据条数:', chartDataTable.value.length)
|
||||
console.log('分析结果长度:', analysisResult.value.length)
|
||||
|
||||
// 打开新窗口并全屏展示 abpm-report-template.html (注意路径不包含public)
|
||||
const reportUrl = '/abpm-report-template.html'
|
||||
const reportWindow = window.open(reportUrl, '_blank')
|
||||
|
||||
if (reportWindow) {
|
||||
// 全屏展示
|
||||
reportWindow.moveTo(0, 0)
|
||||
reportWindow.resizeTo(screen.availWidth, screen.availHeight)
|
||||
|
||||
let dataTransferred = false
|
||||
|
||||
// 监听来自报告窗口的消息
|
||||
const messageHandler = (event) => {
|
||||
console.log('收到消息:', event.data, '来源匹配:', event.source === reportWindow)
|
||||
|
||||
if (
|
||||
event.source === reportWindow &&
|
||||
event.data?.type === 'ABPM_TEMPLATE_LOADED' &&
|
||||
!dataTransferred
|
||||
) {
|
||||
console.log('收到报告模板加载完成消息,开始传递数据')
|
||||
console.log('要传递的数据:', reportData)
|
||||
dataTransferred = true
|
||||
|
||||
// 延迟传递数据,确保页面完全准备好
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// 创建深拷贝,避免引用问题
|
||||
const dataToSend = JSON.parse(JSON.stringify(reportData))
|
||||
|
||||
console.log('准备发送的数据结构:')
|
||||
console.log('- 患者数据:', dataToSend.patientData)
|
||||
console.log('- 图表数据条数:', dataToSend.chartDataTable?.length || 0)
|
||||
console.log('- 分析结果长度:', dataToSend.analysisResult?.length || 0)
|
||||
|
||||
reportWindow.postMessage(
|
||||
{
|
||||
type: 'INIT_ABPM_REPORT',
|
||||
data: dataToSend
|
||||
},
|
||||
'*'
|
||||
)
|
||||
console.log('数据已传递到报告窗口')
|
||||
} catch (error) {
|
||||
console.error('传递数据到报告窗口失败:', error)
|
||||
ElMessage.error('初始化报告数据失败,请重试')
|
||||
}
|
||||
}, 100)
|
||||
|
||||
// 移除事件监听器
|
||||
window.removeEventListener('message', messageHandler)
|
||||
}
|
||||
}
|
||||
|
||||
// 添加消息监听器
|
||||
window.addEventListener('message', messageHandler)
|
||||
|
||||
// 备用方案:如果3秒内没有收到加载完成消息,直接尝试传递数据
|
||||
setTimeout(() => {
|
||||
if (!dataTransferred) {
|
||||
console.log('使用备用方案传递数据')
|
||||
dataTransferred = true
|
||||
try {
|
||||
// 创建深拷贝,避免引用问题
|
||||
const dataToSend = JSON.parse(JSON.stringify(reportData))
|
||||
|
||||
reportWindow.postMessage(
|
||||
{
|
||||
type: 'INIT_ABPM_REPORT',
|
||||
data: dataToSend
|
||||
},
|
||||
'*'
|
||||
)
|
||||
console.log('备用方案:数据已传递到报告窗口')
|
||||
} catch (error) {
|
||||
console.error('备用方案传递数据失败:', error)
|
||||
ElMessage.error('初始化报告数据失败,请重试')
|
||||
}
|
||||
window.removeEventListener('message', messageHandler)
|
||||
}
|
||||
}, 3000)
|
||||
|
||||
// 监听窗口关闭,清理事件监听器
|
||||
const checkClosed = setInterval(() => {
|
||||
if (reportWindow.closed) {
|
||||
clearInterval(checkClosed)
|
||||
window.removeEventListener('message', messageHandler)
|
||||
console.log('报告窗口已关闭')
|
||||
}
|
||||
}, 1000)
|
||||
} else {
|
||||
ElMessage.error('无法打开报告预览窗口,请检查浏览器弹窗设置')
|
||||
}
|
||||
}
|
||||
|
||||
// 删除数据方法
|
||||
const handleDelete = async (index: number) => {
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user