feat(miniprogram): 添加健康记录和诊断记录查看页面
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- 新建 service: health-record.ts(listHealthRecords + listDiagnoses)
- 新建页面: health-records/index(体检记录列表,分页+下拉刷新)
- 新建页面: diagnoses/index(诊断记录列表,类型/状态标签)
- 路由注册到 pkg-profile 分包
- "我的"页菜单添加健康记录、诊断记录入口
This commit is contained in:
iven
2026-04-30 22:49:44 +08:00
parent f05ca00c75
commit 813843e8cc
7 changed files with 443 additions and 13 deletions

View File

@@ -0,0 +1,110 @@
@import '../../../styles/variables.scss';
@mixin tag($bg, $color) {
display: inline-block;
padding: 4px 12px;
border-radius: 8px;
font-size: 20px;
font-weight: 500;
background: $bg;
color: $color;
}
.diagnoses-page {
min-height: 100vh;
background: $bg;
padding: 32px 24px;
padding-bottom: 40px;
}
.page-title {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: 30px;
font-weight: bold;
color: $tx;
margin-bottom: 20px;
display: block;
padding-left: 4px;
}
.diagnosis-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.diagnosis-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: $shadow-sm;
}
.diagnosis-card__header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.diagnosis-card__name {
font-size: 28px;
font-weight: bold;
color: $tx;
flex: 1;
margin-right: 12px;
}
.diagnosis-card__status {
@include tag($bd-l, $tx3);
&.active {
@include tag($acc-l, $acc);
}
&.resolved {
@include tag($suc-l, $suc);
}
&.chronic {
@include tag($wrn-l, $wrn);
}
}
.diagnosis-card__meta {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 8px;
}
.diagnosis-card__type {
@include tag($pri-l, $pri-d);
&.secondary {
@include tag($bd-l, $tx2);
}
&.comorbid {
@include tag($wrn-l, $wrn);
}
}
.diagnosis-card__code {
font-size: 22px;
color: $tx3;
font-variant-numeric: tabular-nums;
}
.diagnosis-card__date {
font-size: 22px;
color: $tx2;
display: block;
}
.diagnosis-card__notes {
font-size: 22px;
color: $tx2;
display: block;
margin-top: 8px;
}

View File

@@ -0,0 +1,101 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listDiagnoses, Diagnosis } from '../../../services/health-record';
import EmptyState from '../../../components/EmptyState';
import Loading from '../../../components/Loading';
import './index.scss';
const TYPE_MAP: Record<string, { label: string; cls: string }> = {
primary: { label: '主要', cls: 'primary' },
secondary: { label: '次要', cls: 'secondary' },
comorbid: { label: '合并症', cls: 'comorbid' },
};
const STATUS_MAP: Record<string, { label: string; cls: string }> = {
active: { label: '活动', cls: 'active' },
resolved: { label: '已解决', cls: 'resolved' },
chronic: { label: '慢性', cls: 'chronic' },
};
export default function Diagnoses() {
const [records, setRecords] = useState<Diagnosis[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const fetchData = useCallback(async (p: number, append = false) => {
const patientId = Taro.getStorageSync('current_patient_id') || '';
if (!patientId) {
setRecords([]);
return;
}
setLoading(true);
try {
const res = await listDiagnoses(patientId, { page: p, page_size: 20 });
const list = res.data || [];
setRecords(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total);
setPage(p);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchData(1);
});
usePullDownRefresh(() => {
fetchData(1).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && records.length < total) {
fetchData(page + 1, true);
}
});
return (
<View className='diagnoses-page'>
<Text className='page-title'></Text>
<View className='diagnosis-list'>
{records.map((d) => {
const typeInfo = TYPE_MAP[d.diagnosis_type] || { label: d.diagnosis_type, cls: '' };
const statusInfo = STATUS_MAP[d.status] || { label: d.status, cls: '' };
return (
<View className='diagnosis-card' key={d.id}>
<View className='diagnosis-card__header'>
<Text className='diagnosis-card__name'>{d.diagnosis_name}</Text>
<Text className={`diagnosis-card__status ${statusInfo.cls}`}>
{statusInfo.label}
</Text>
</View>
<View className='diagnosis-card__meta'>
<Text className={`diagnosis-card__type ${typeInfo.cls}`}>
{typeInfo.label}
</Text>
<Text className='diagnosis-card__code'>{d.icd_code}</Text>
</View>
<Text className='diagnosis-card__date'>{d.diagnosed_date}</Text>
{d.notes && (
<Text className='diagnosis-card__notes'>{d.notes}</Text>
)}
</View>
);
})}
</View>
{records.length === 0 && !loading && (
<EmptyState text={Taro.getStorageSync('current_patient_id') ? '暂无诊断记录' : '请先在就诊人管理中选择就诊人'} />
)}
{loading && <Loading />}
</View>
);
}

View File

@@ -0,0 +1,71 @@
@import '../../../styles/variables.scss';
.health-records-page {
min-height: 100vh;
background: $bg;
padding: 32px 24px;
padding-bottom: 40px;
}
.page-title {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: 30px;
font-weight: bold;
color: $tx;
margin-bottom: 20px;
display: block;
padding-left: 4px;
}
.record-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.record-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: $shadow-sm;
}
.record-card__header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.record-card__type {
font-size: 28px;
font-weight: bold;
color: $tx;
}
.record-card__date {
font-size: 24px;
color: $tx2;
font-variant-numeric: tabular-nums;
}
.record-card__assessment {
font-size: 24px;
color: $tx;
display: block;
margin-bottom: 4px;
}
.record-card__source {
font-size: 22px;
color: $tx3;
display: block;
margin-bottom: 4px;
}
.record-card__notes {
font-size: 22px;
color: $tx2;
display: block;
margin-top: 8px;
}

View File

@@ -0,0 +1,90 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listHealthRecords, HealthRecord } from '../../../services/health-record';
import EmptyState from '../../../components/EmptyState';
import Loading from '../../../components/Loading';
import './index.scss';
const TYPE_MAP: Record<string, string> = {
checkup: '体检',
follow_up: '复查',
referral: '转诊',
};
export default function HealthRecords() {
const [records, setRecords] = useState<HealthRecord[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const fetchData = useCallback(async (p: number, append = false) => {
const patientId = Taro.getStorageSync('current_patient_id') || '';
if (!patientId) {
setRecords([]);
return;
}
setLoading(true);
try {
const res = await listHealthRecords(patientId, { page: p, page_size: 20 });
const list = res.data || [];
setRecords(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total);
setPage(p);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchData(1);
});
usePullDownRefresh(() => {
fetchData(1).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && records.length < total) {
fetchData(page + 1, true);
}
});
return (
<View className='health-records-page'>
<Text className='page-title'></Text>
<View className='record-list'>
{records.map((r) => (
<View className='record-card' key={r.id}>
<View className='record-card__header'>
<Text className='record-card__type'>
{TYPE_MAP[r.record_type] || r.record_type}
</Text>
<Text className='record-card__date'>{r.record_date}</Text>
</View>
{r.overall_assessment && (
<Text className='record-card__assessment'>{r.overall_assessment}</Text>
)}
{r.source && (
<Text className='record-card__source'>{r.source}</Text>
)}
{r.notes && (
<Text className='record-card__notes'>{r.notes}</Text>
)}
</View>
))}
</View>
{records.length === 0 && !loading && (
<EmptyState text={Taro.getStorageSync('current_patient_id') ? '暂无健康记录' : '请先在就诊人管理中选择就诊人'} />
)}
{loading && <Loading />}
</View>
);
}

View File

@@ -6,10 +6,13 @@ import { usePointsStore } from '../../stores/points';
import './index.scss';
const MENU_ITEMS = [
{ label: '积分商城', char: '商', path: '/pages/mall/index' },
{ label: '我的订单', char: '单', path: '/pages/pkg-mall/orders/index' },
{ label: '积分明细', char: '明', path: '/pages/pkg-mall/detail/index' },
{ label: '就诊人管理', char: '人', path: '/pages/pkg-profile/family/index' },
{ label: '我的报告', char: '报', path: '/pages/pkg-profile/reports/index' },
{ label: '健康记录', char: '健', path: '/pages/pkg-profile/health-records/index' },
{ label: '诊断记录', char: '诊', path: '/pages/pkg-profile/diagnoses/index' },
{ label: '我的随访', char: '随', path: '/pages/pkg-profile/followups/index' },
{ label: '用药提醒', char: '药', path: '/pages/pkg-profile/medication/index' },
{ label: '透析记录', char: '透', path: '/pages/pkg-profile/dialysis-records/index' },
@@ -53,18 +56,18 @@ export default function Profile() {
<Text className='profile-name'>{user?.display_name || '未登录'}</Text>
<Text className='profile-phone'>{user?.phone || ''}</Text>
{/* 积分余额 */}
<View
className='profile-stats'
onClick={() => Taro.navigateTo({ url: '/pages/pkg-mall/detail/index' })}
>
<View className='stat-item'>
<Text className='stat-value'>{(pointsAccount?.balance ?? 0).toLocaleString()}</Text>
{/* 积分 + 连续打卡横排 */}
<View className='profile-stats'>
<View
className='stat-card'
onClick={() => Taro.navigateTo({ url: '/pages/pkg-mall/detail/index' })}
>
<Text className='stat-value stat-value-pri'>{(pointsAccount?.balance ?? 0).toLocaleString()}</Text>
<Text className='stat-label'></Text>
</View>
<View className='stat-divider' />
<View className='stat-item'>
<Text className='stat-value'>{checkinInfo?.consecutive_days ?? 0}</Text>
<View className='stat-card'>
<Text className='stat-value stat-value-acc'>{checkinInfo?.consecutive_days ?? 0}</Text>
<Text className='stat-label'>()</Text>
</View>
</View>