This commit is contained in:
2026-05-05 15:02:04 +08:00
parent 0da27ed745
commit 19bfeef98f
19 changed files with 1771 additions and 272 deletions
@@ -0,0 +1,369 @@
<template>
<div class="card case-card">
<div class="card-title">
患者病例
<span class="case-sub">{{ caseTypeLabel }} · 诊断日期 {{ diag?.diagnosis_date || apt?.appointment_date || '—' }}</span>
</div>
<!-- 基本信息 -->
<div class="grid-block">
<div class="grid-title">基本信息</div>
<div class="kv-grid four">
<KVItem label="诊单ID" :value="diag?.patient_id" />
<KVItem label="姓名" :value="diag?.patient_name" />
<KVItem label="身份证号" :value="diag?.id_card" />
<KVItem label="手机号" :value="maskPhone(diag?.phone || apt?.patient_phone)" />
<KVItem label="性别" :value="textOf('gender')" />
<KVItem label="年龄" :value="diag?.age != null ? diag.age + '岁' : ''" />
<KVItem label="婚姻状态" :value="textOf('marital_status')" />
<KVItem label="地区" :value="diag?.region" />
</div>
</div>
<!-- 生命体征 -->
<div class="grid-block">
<div class="grid-title">生命体征</div>
<div class="kv-grid four">
<KVItem label="身高" :value="diag?.height ? diag.height + ' cm' : ''" />
<KVItem label="体重" :value="diag?.weight ? diag.weight + ' kg' : ''" />
<MetricKVItem
label="高压"
:value="diag?.systolic_pressure"
unit=" mmHg"
:high="isHighSystolicPressure(diag?.systolic_pressure)"
/>
<MetricKVItem
label="低压"
:value="diag?.diastolic_pressure"
unit=" mmHg"
:high="isHighDiastolicPressure(diag?.diastolic_pressure)"
/>
<KVItem label="诊断类型" :value="textOf('diagnosis_type')" />
<MetricKVItem
label="空腹血糖"
:value="diag?.fasting_blood_sugar"
unit=" mmol/L"
:high="isHighFastingBloodSugar(diag?.fasting_blood_sugar, diag?.age)"
/>
<KVItem label="在用药物" :value="diag?.current_medications" multiline />
</div>
</div>
<!-- 主诉 -->
<div class="grid-block">
<div class="grid-title">主诉</div>
<div class="kv-grid four">
<KVItem label="当地医院诊断日期" :value="diag?.diagnosis_date" />
<KVItem
label="发现糖尿病病史"
:value="formatDiabetesDiscoveryDisplay
? formatDiabetesDiscoveryDisplay(diag?.diabetes_discovery_year)
: diag?.diabetes_discovery_year"
/>
<KVItem label="当地就诊医院" :value="diag?.local_hospital_name" />
<KVItem label="当地医院诊断结果" :value="joinArray(diag?.local_hospital_diagnosis)" />
</div>
</div>
<!-- 现病史后端已翻译 *_text -->
<div class="grid-block">
<div class="grid-title">现病史</div>
<div class="kv-grid three">
<KVItem label="口腔感觉" :value="textOf('appetite')" />
<KVItem label="每日饮水量" :value="textOf('water_intake')" />
<KVItem label="近月体重变化" :value="textOf('weight_change')" />
<KVItem label="脂肪肝程度" :value="textOf('fatty_liver_degree')" />
<KVItem label="饮食情况" :value="textOf('diet_condition')" span="2" />
<KVItem label="肢体感觉" :value="textOf('body_feeling')" />
<KVItem label="睡眠情况" :value="textOf('sleep_condition')" />
<KVItem label="眼睛情况" :value="textOf('eye_condition')" />
<KVItem label="头部感觉" :value="textOf('head_feeling')" />
<KVItem label="出汗情况" :value="textOf('sweat_condition')" />
<KVItem label="皮肤情况" :value="textOf('skin_condition')" />
<KVItem label="小便情况" :value="textOf('urine_condition')" />
<KVItem label="大便情况" :value="textOf('stool_condition')" />
<KVItem label="腰肾情况" :value="textOf('kidney_condition')" />
<KVItem label="其他补充" :value="diag?.symptoms" span="3" multiline />
</div>
</div>
<!-- 既往史 -->
<div class="grid-block">
<div class="grid-title">既往史</div>
<div class="kv-grid three">
<KVItem label="既往病史" :value="textOf('past_history')" span="3" />
</div>
</div>
<!-- 其他病史 -->
<div class="grid-block">
<div class="grid-title">其他病史</div>
<div class="kv-grid three">
<KVItem label="外伤史" :value="textOf('trauma_history')" />
<KVItem label="手术史" :value="textOf('surgery_history')" />
<KVItem label="过敏史" :value="textOf('allergy_history')" />
<KVItem label="家族病史" :value="textOf('family_history')" />
<KVItem label="妊娠哺乳史" :value="textOf('pregnancy_history')" />
</div>
</div>
<!-- 病史补充 -->
<div class="grid-block" v-if="diag?.remark">
<div class="grid-title">病史补充</div>
<div class="kv-grid one">
<KVItem label="" :value="diag.remark" multiline />
</div>
</div>
<!-- 处方意见 -->
<div class="grid-block">
<div class="grid-title">处方意见</div>
<div class="rx-note">
{{ apt?.has_prescription ? '已开方。' : '当前未开方。' }}
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, h } from 'vue'
import {
isHighSystolicPressure,
isHighDiastolicPressure,
isHighFastingBloodSugar
} from '@/utils/blood-thresholds'
import { maskPhone, joinArray, makeTextOf } from '@/utils/diag-display'
import { formatDiabetesDiscoveryDisplay } from '@/utils/diabetes-discovery-display'
interface Props {
apt?: Record<string, any> | null
diag?: Record<string, any> | null
}
const props = withDefaults(defineProps<Props>(), {
apt: () => ({}),
diag: () => ({})
})
const caseTypeLabel = computed(() => {
const d: any = props.diag || {}
return d.consultation_type === 'follow_up' ? '复诊' : '初诊'
})
const textOf = makeTextOf(() => props.diag || {})
// ========== 本地函数式子组件 ==========
/**
* 局部渲染组件:左侧 label + 右侧 value,支持 span / 换行(与抽离前 reception 内联实现一致)
*/
const KVItem = (kvProps: { label: string; value: any; span?: string | number; multiline?: boolean }) => {
const val = kvProps.value
const empty =
val === undefined || val === null || val === '' || (Array.isArray(val) && val.length === 0)
return h(
'div',
{
class: ['kv-item', kvProps.multiline ? 'multiline' : '', empty ? 'empty' : ''],
style: kvProps.span ? `grid-column: span ${kvProps.span}` : ''
},
[
h('span', { class: 'kv-label' }, kvProps.label),
h('span', { class: 'kv-value' }, empty ? '—' : String(val))
]
)
}
/**
* 数值型 KV:偏高时红色 + ↑ 箭头(与抽离前 reception 内联实现一致)
*/
const MetricKVItem = (mkvProps: {
label: string
value: any
unit?: string
span?: string | number
high?: boolean
}) => {
const empty = mkvProps.value === undefined || mkvProps.value === null || mkvProps.value === ''
return h(
'div',
{
class: ['kv-item', 'metric-kv-item', empty ? 'empty' : ''],
style: mkvProps.span ? `grid-column: span ${mkvProps.span}` : ''
},
[
h('span', { class: 'kv-label' }, mkvProps.label),
h(
'span',
{ class: ['kv-value', 'metric-kv-value', mkvProps.high ? 'high' : ''] },
empty
? '—'
: [
`${mkvProps.value}${mkvProps.unit || ''}`,
mkvProps.high ? h('span', { class: 'metric-up' }, '↑') : null
]
)
]
)
}
</script>
<style lang="scss" scoped>
.card {
background: var(--rx-surface);
border: 1px solid var(--rx-line);
border-radius: 14px;
padding: 18px;
display: flex;
flex-direction: column;
gap: 14px;
box-shadow: var(--rx-shadow-sm);
transition: box-shadow 0.2s ease;
&:hover {
box-shadow: var(--rx-shadow);
}
}
.card-title {
font-size: 15px;
font-weight: 700;
color: var(--rx-ink);
display: flex;
align-items: center;
gap: 10px;
padding-left: 10px;
position: relative;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 3px;
height: 16px;
border-radius: 2px;
background: linear-gradient(180deg, #4f8cff 0%, #2563eb 100%);
}
}
.case-sub {
font-size: 12px;
font-weight: 400;
color: var(--rx-soft);
font-family: var(--rx-font-data);
}
.grid-block {
display: flex;
flex-direction: column;
gap: 10px;
padding-top: 12px;
border-top: 1px dashed var(--rx-line);
&:first-of-type {
border-top: none;
padding-top: 0;
}
}
.grid-title {
font-size: 13px;
font-weight: 600;
color: var(--rx-accent-strong);
letter-spacing: 0.02em;
display: flex;
align-items: center;
gap: 6px;
&::before {
content: '';
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--rx-accent);
}
}
.kv-grid {
display: grid;
gap: 8px 16px;
&.one {
grid-template-columns: 1fr;
}
&.two {
grid-template-columns: repeat(2, 1fr);
}
&.three {
grid-template-columns: repeat(3, 1fr);
}
&.four {
grid-template-columns: repeat(4, 1fr);
}
}
:deep(.kv-item) {
display: flex;
gap: 6px;
font-size: 12.5px;
line-height: 1.55;
min-width: 0;
&.multiline {
flex-direction: column;
gap: 2px;
}
.kv-label {
color: var(--rx-soft);
flex-shrink: 0;
min-width: 58px;
}
.kv-value {
color: var(--rx-ink);
word-break: break-word;
flex: 1;
font-weight: 500;
}
&.empty .kv-value {
color: #c0c4cc;
font-weight: 400;
}
&.multiline .kv-value {
white-space: pre-wrap;
font-weight: 400;
}
}
:deep(.metric-kv-item .metric-kv-value) {
display: inline-flex;
align-items: center;
gap: 4px;
&.high {
color: #dc2626;
font-weight: 700;
}
}
:deep(.metric-up) {
font-size: 14px;
line-height: 1;
color: #dc2626;
}
.rx-note {
font-size: 13px;
color: var(--rx-muted);
line-height: 1.6;
padding: 12px 14px;
background: linear-gradient(135deg, #fafbfd 0%, #f5f7fb 100%);
border-radius: 8px;
border-left: 3px solid var(--rx-accent);
}
</style>
@@ -0,0 +1,124 @@
<template>
<div class="card patient-card">
<div class="card-title">患者信息</div>
<div class="patient-hero">
<div class="patient-name">{{ apt?.patient_name || '—' }}</div>
<div class="patient-meta">
<div>
{{ maskPhone(apt?.patient_phone) }} · {{ formatGender(diag?.gender) }} ·
{{ diag?.age != null ? diag.age + '岁' : '—' }}
</div>
<div>
{{ diag?.height ? diag.height + 'cm' : '—' }} /
{{ diag?.weight ? diag.weight + 'kg' : '—' }} · {{ diag?.region || '—' }}
</div>
<div>
预约{{ apt?.appointment_date }} {{ apt?.appointment_time }} ·
{{ formatPeriod(apt?.period) }}
</div>
<div>医生{{ apt?.doctor_name || '—' }} 医助{{ apt?.assistant_name || '—' }}</div>
<div>
状态{{ apt?.status_desc || '—' }} ·
{{ apt?.has_prescription ? '已开方' : '未开方' }}
</div>
<div v-if="apt?.remark">备注{{ apt.remark }}</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { maskPhone, formatGender, formatPeriod } from '@/utils/diag-display'
interface Props {
apt?: Record<string, any> | null
diag?: Record<string, any> | null
}
withDefaults(defineProps<Props>(), {
apt: () => ({}),
diag: () => ({})
})
</script>
<style lang="scss" scoped>
.card {
background: var(--rx-surface);
border: 1px solid var(--rx-line);
border-radius: 14px;
padding: 18px;
display: flex;
flex-direction: column;
gap: 14px;
box-shadow: var(--rx-shadow-sm);
transition: box-shadow 0.2s ease;
&:hover {
box-shadow: var(--rx-shadow);
}
}
.card-title {
font-size: 15px;
font-weight: 700;
color: var(--rx-ink);
display: flex;
align-items: center;
gap: 10px;
padding-left: 10px;
position: relative;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 3px;
height: 16px;
border-radius: 2px;
background: linear-gradient(180deg, #4f8cff 0%, #2563eb 100%);
}
}
.patient-hero {
background: linear-gradient(135deg, #f5f8ff 0%, #eef3ff 100%);
border: 1px solid #dde7ff;
border-radius: 12px;
padding: 16px 18px;
display: flex;
flex-direction: column;
gap: 6px;
position: relative;
overflow: hidden;
&::after {
content: '';
position: absolute;
right: -20px;
top: -20px;
width: 100px;
height: 100px;
border-radius: 50%;
background: radial-gradient(circle, rgba(79, 140, 255, 0.08) 0%, transparent 70%);
}
}
.patient-name {
font-size: 22px;
font-weight: 700;
color: var(--rx-ink);
letter-spacing: -0.01em;
}
.patient-meta {
color: var(--rx-muted);
font-size: 13px;
line-height: 1.7;
display: flex;
flex-direction: column;
gap: 2px;
position: relative;
z-index: 1;
}
</style>
@@ -0,0 +1,387 @@
<template>
<div class="tracking-matrix">
<div class="toolbar">
<el-radio-group v-model="windowDays" @change="onWindowChange">
<el-radio-button :value="7">最近 7 </el-radio-button>
<el-radio-button :value="30">最近 30 </el-radio-button>
</el-radio-group>
<span class="hint">同一天血糖三段挤一格超阈值红字年龄分段&lt;50空7/餐950空8/餐10</span>
</div>
<el-empty
v-if="visibleDates.length === 0"
description="近期无任何打卡记录"
:image-size="80"
/>
<el-table
v-else
:data="rows"
border
stripe
class="matrix-table"
empty-text="暂无数据"
row-key="date"
max-height="640"
>
<el-table-column prop="dateLabel" label="日期" width="120" fixed="left" />
<el-table-column label="血糖 (mmol/L)" min-width="180">
<template #default="{ row }">
<div v-if="row.bloodAny" class="cell-blood">
<span :class="{ 'cell-high': row.fastingHigh }">
<span class="value">{{ row.fasting ?? '—' }}</span>
<span v-if="row.fastingHigh" class="cell-up"></span>
</span>
<span :class="{ 'cell-high': row.postprandialHigh }">
<span class="value">{{ row.postprandial ?? '—' }}</span>
<span v-if="row.postprandialHigh" class="cell-up"></span>
</span>
<span :class="{ 'cell-high': row.otherHigh }">
其他
<span class="value">{{ row.other ?? '—' }}</span>
<span v-if="row.otherHigh" class="cell-up"></span>
</span>
</div>
<span v-else class="cell-empty"></span>
</template>
</el-table-column>
<el-table-column label="血压 (mmHg)" width="120" align="center">
<template #default="{ row }">
<span v-if="row.bp" :class="{ 'cell-high': row.bpHigh }">
{{ row.bp }}
<span v-if="row.bpHigh" class="cell-up"></span>
</span>
<span v-else class="cell-empty"></span>
</template>
</el-table-column>
<el-table-column label="西药" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
<span v-if="row.westernMedicine">{{ row.westernMedicine }}</span>
<span v-else class="cell-empty"></span>
</template>
</el-table-column>
<el-table-column label="胰岛素" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
<span v-if="row.insulin">{{ row.insulin }}</span>
<span v-else class="cell-empty"></span>
</template>
</el-table-column>
<el-table-column label="饮食打卡" width="110" align="center">
<template #default="{ row }">
<el-tooltip
v-if="row.diet"
placement="top"
:disabled="!row.diet"
effect="light"
>
<template #content>
<div class="diet-tip">
<div>{{ row.diet.breakfast || '—' }}</div>
<div>{{ row.diet.lunch || '—' }}</div>
<div>{{ row.diet.dinner || '—' }}</div>
</div>
</template>
<span class="cell-checked">已打卡</span>
</el-tooltip>
<span v-else class="cell-empty"></span>
</template>
</el-table-column>
<el-table-column label="运动打卡" min-width="160" align="center">
<template #default="{ row }">
<el-tooltip v-if="row.exercise" placement="top" effect="light">
<template #content>
<div class="exercise-tip">
<div>强度{{ row.exercise.intensityText || '—' }}</div>
<div>时长{{ row.exercise.duration ? row.exercise.duration + ' min' : '—' }}</div>
<div v-if="row.exercise.remark">备注{{ row.exercise.remark }}</div>
</div>
</template>
<span class="cell-checked">
已打卡
<span v-if="row.exercise.duration" class="meta">· {{ row.exercise.duration }}min</span>
<span v-if="row.exercise.intensityText" class="meta">· {{ row.exercise.intensityText }}</span>
</span>
</el-tooltip>
<span v-else class="cell-empty"></span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import {
isHighFastingBloodSugar,
isHighPostprandialBloodSugar,
isHighOtherBloodSugar,
isHighBloodPressure,
formatBp
} from '@/utils/blood-thresholds'
interface BloodRecord {
record_date?: string
record_date_ts?: number
fasting_blood_sugar?: any
postprandial_blood_sugar?: any
other_blood_sugar?: any
systolic_pressure?: any
diastolic_pressure?: any
western_medicine?: string
insulin?: string
[key: string]: any
}
interface DietRecord {
record_date?: string
record_date_ts?: number
breakfast?: string
lunch?: string
dinner?: string
[key: string]: any
}
interface ExerciseRecord {
record_date?: string
record_date_ts?: number
duration?: number
intensity?: number
intensity_text?: string
remark?: string
[key: string]: any
}
interface Props {
diagnosisId?: number
patientId?: number | null
age?: number | null
bloodRecords: BloodRecord[]
dietRecords: DietRecord[]
exerciseRecords: ExerciseRecord[]
}
const props = withDefaults(defineProps<Props>(), {
diagnosisId: 0,
patientId: null,
age: null,
bloodRecords: () => [],
dietRecords: () => [],
exerciseRecords: () => []
})
const windowDays = ref<7 | 30>(30)
const onWindowChange = () => {
// 触发 computed 重算;预留扩展点:未来可在此处通知父组件重拉
}
/**
* 把同一天可能多条的血糖记录聚合:每段取第一条非空值(与 BloodRecordLogic 趋势图一致)
*/
const bloodByDate = computed(() => {
const map = new Map<string, BloodRecord>()
for (const r of props.bloodRecords || []) {
const d = String(r.record_date || '')
if (!d) continue
if (!map.has(d)) {
map.set(d, {
record_date: d,
record_date_ts: r.record_date_ts
})
}
const acc = map.get(d)!
const fields: Array<keyof BloodRecord> = [
'fasting_blood_sugar',
'postprandial_blood_sugar',
'other_blood_sugar',
'systolic_pressure',
'diastolic_pressure',
'western_medicine',
'insulin'
]
for (const f of fields) {
if ((acc[f] === undefined || acc[f] === null || acc[f] === '') && r[f] !== undefined && r[f] !== null && r[f] !== '') {
;(acc as any)[f] = r[f]
}
}
}
return map
})
const dietByDate = computed(() => {
const map = new Map<string, DietRecord>()
for (const r of props.dietRecords || []) {
const d = String(r.record_date || '')
if (!d) continue
if (!map.has(d)) map.set(d, r)
}
return map
})
const exerciseByDate = computed(() => {
const map = new Map<string, ExerciseRecord>()
for (const r of props.exerciseRecords || []) {
const d = String(r.record_date || '')
if (!d) continue
if (!map.has(d)) map.set(d, r)
}
return map
})
/**
* 取三类记录的日期并集,按 desc 排序并去重,限制最大 windowDays 条
*/
const visibleDates = computed<string[]>(() => {
const set = new Set<string>()
for (const r of props.bloodRecords || []) if (r.record_date) set.add(String(r.record_date))
for (const r of props.dietRecords || []) if (r.record_date) set.add(String(r.record_date))
for (const r of props.exerciseRecords || []) if (r.record_date) set.add(String(r.record_date))
const list = Array.from(set).filter((d) => d.length === 10)
list.sort((a, b) => (a < b ? 1 : a > b ? -1 : 0))
return list.slice(0, windowDays.value)
})
const weekText = (d: string) => {
const ts = Date.parse(d + 'T00:00:00')
if (!Number.isFinite(ts)) return ''
const w = new Date(ts).getDay()
return ['日', '一', '二', '三', '四', '五', '六'][w]
}
const rows = computed(() =>
visibleDates.value.map((date) => {
const blood = bloodByDate.value.get(date)
const diet = dietByDate.value.get(date)
const exercise = exerciseByDate.value.get(date)
const fasting = blood?.fasting_blood_sugar ?? null
const postprandial = blood?.postprandial_blood_sugar ?? null
const other = blood?.other_blood_sugar ?? null
const sys = blood?.systolic_pressure ?? null
const dia = blood?.diastolic_pressure ?? null
const bloodAny =
fasting !== null && fasting !== '' ||
postprandial !== null && postprandial !== '' ||
other !== null && other !== ''
const bp = sys || dia ? formatBp({ systolic_pressure: sys, diastolic_pressure: dia }) : ''
return {
date,
dateLabel: `${date.slice(5)}(周${weekText(date)}`,
// 血糖
bloodAny,
fasting: fasting ?? '—',
postprandial: postprandial ?? '—',
other: other ?? '—',
fastingHigh: isHighFastingBloodSugar(fasting, props.age),
postprandialHigh: isHighPostprandialBloodSugar(postprandial, props.age),
otherHigh: isHighOtherBloodSugar(other, props.age),
// 血压
bp,
bpHigh: isHighBloodPressure({ systolic_pressure: sys, diastolic_pressure: dia }),
// 用药
westernMedicine: blood?.western_medicine || '',
insulin: blood?.insulin || '',
// 饮食
diet: diet
? {
breakfast: diet.breakfast || '',
lunch: diet.lunch || '',
dinner: diet.dinner || ''
}
: null,
// 运动
exercise: exercise
? {
duration: exercise.duration || 0,
intensityText: exercise.intensity_text || '',
remark: exercise.remark || ''
}
: null
}
})
)
</script>
<style lang="scss" scoped>
.tracking-matrix {
.toolbar {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
flex-wrap: wrap;
.hint {
font-size: 12px;
color: var(--el-text-color-secondary);
}
}
.matrix-table {
width: 100%;
}
.cell-blood {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 12.5px;
line-height: 1.55;
> span {
display: inline-flex;
align-items: center;
gap: 4px;
.value {
font-variant-numeric: tabular-nums;
font-weight: 600;
}
}
}
.cell-high {
color: #dc2626;
font-weight: 700;
}
.cell-up {
font-size: 13px;
color: #dc2626;
}
.cell-empty {
color: var(--el-text-color-placeholder);
}
.cell-checked {
color: #2563eb;
font-weight: 500;
.meta {
color: var(--el-text-color-secondary);
font-weight: 400;
margin-left: 2px;
}
}
}
.diet-tip,
.exercise-tip {
font-size: 12.5px;
line-height: 1.55;
> div {
margin-bottom: 2px;
&:last-child {
margin-bottom: 0;
}
}
}
</style>