Files
nj/apps/web/src/api/health/familyProxy.ts
iven 8111471e93
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled
feat: 添加管理端前端 (HMS 基座 React 管理面板)
- 从 HMS 基座复制 apps/web/ (React + Ant Design + Vite + TypeScript)
- 管理端自动代理 API 到 localhost:3000 (vite.config.ts)
- 更新 scripts/dev.sh 支持三端启动: backend/admin/app
- 登录验证通过, 用户管理/角色权限/审计日志等页面正常
- 添加 .gitignore 排除 node_modules/dist
2026-06-02 10:03:13 +08:00

110 lines
2.8 KiB
TypeScript

import client from '../client';
// --- Types ---
export interface FamilyMember {
id: string;
patient_id: string;
name: string;
relationship: string;
phone?: string;
birth_date?: string;
notes?: string;
user_id?: string;
consent_status: string;
access_level: string;
consented_at?: string;
created_at: string;
updated_at: string;
version: number;
}
export interface FamilyPatientSummary {
family_member_id: string;
patient_id: string;
patient_name: string;
relationship: string;
consent_status: string;
access_level: string;
consented_at?: string;
}
export interface FamilyHealthSummary {
patient_id: string;
patient_name: string;
latest_vital_signs?: Record<string, unknown>;
active_care_plan?: Record<string, unknown>;
recent_alerts_count: number;
next_appointment?: Record<string, unknown>;
}
export interface GrantAccessReq {
access_level: string;
}
// --- Constants ---
export const CONSENT_STATUS_OPTIONS = [
{ label: '已同意', value: 'granted' },
{ label: '待确认', value: 'pending' },
{ label: '已撤销', value: 'revoked' },
{ label: '已过期', value: 'expired' },
];
export const ACCESS_LEVEL_OPTIONS = [
{ label: '完全访问', value: 'full' },
{ label: '只读', value: 'read_only' },
{ label: '摘要', value: 'summary' },
];
export const CONSENT_STATUS_COLOR: Record<string, string> = {
granted: 'green',
pending: 'orange',
revoked: 'red',
expired: 'default',
};
export const ACCESS_LEVEL_LABEL: Record<string, string> = Object.fromEntries(
ACCESS_LEVEL_OPTIONS.map((o) => [o.value, o.label]),
);
export const CONSENT_STATUS_LABEL: Record<string, string> = Object.fromEntries(
CONSENT_STATUS_OPTIONS.map((o) => [o.value, o.label]),
);
// --- API ---
export const familyProxyApi = {
grantAccess: async (patientId: string, familyMemberId: string, req: GrantAccessReq, version: number) => {
const { data } = await client.post<{
success: boolean;
data: FamilyMember;
}>(`/health/patients/${patientId}/family-members/${familyMemberId}/grant-access`, { ...req, version });
return data.data;
},
revokeAccess: async (patientId: string, familyMemberId: string, version: number) => {
const { data } = await client.put<{
success: boolean;
data: FamilyMember;
}>(`/health/patients/${patientId}/family-members/${familyMemberId}/revoke-access`, { version });
return data.data;
},
listMyPatients: async () => {
const { data } = await client.get<{
success: boolean;
data: FamilyPatientSummary[];
}>('/health/family/patients');
return data.data;
},
getHealthSummary: async (patientId: string) => {
const { data } = await client.get<{
success: boolean;
data: FamilyHealthSummary;
}>(`/health/family/patients/${patientId}/health-summary`);
return data.data;
},
};