feat(web): 危急值阈值 + 诊断记录 Web UI — Phase 2b-2/2b-3
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

危急值阈值:CRUD 列表页(指标/方向/阈值/级别/科室/年龄范围)
诊断记录:患者范围 CRUD 列表页(ICD编码/类型/状态/确诊日期)
This commit is contained in:
iven
2026-05-04 23:59:22 +08:00
parent b6838c1bc1
commit 0774dd75ad
6 changed files with 731 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
import client from '../client';
// --- Types ---
export interface CriticalValueThreshold {
id: string;
tenant_id: string;
indicator: string;
direction: string;
threshold_value: number;
level: string;
department?: string;
age_min?: number;
age_max?: number;
is_active: boolean;
created_at: string;
updated_at: string;
version: number;
}
export interface CreateThresholdReq {
indicator: string;
direction: string;
threshold_value: number;
level?: string;
department?: string;
age_min?: number;
age_max?: number;
}
export interface UpdateThresholdReq {
threshold_value: number;
level?: string;
department?: string;
age_min?: number;
age_max?: number;
version: number;
}
// --- Constants ---
export const INDICATOR_OPTIONS = [
{ label: '收缩压', value: 'systolic_bp' },
{ label: '舒张压', value: 'diastolic_bp' },
{ label: '心率', value: 'heart_rate' },
{ label: '血糖', value: 'blood_sugar' },
{ label: '空腹血糖', value: 'blood_sugar_fasting' },
{ label: '餐后血糖', value: 'blood_sugar_postprandial' },
{ label: '血氧', value: 'blood_oxygen' },
{ label: '体温', value: 'temperature' },
];
export const DIRECTION_OPTIONS = [
{ label: '偏高', value: 'high' },
{ label: '偏低', value: 'low' },
];
export const LEVEL_OPTIONS = [
{ label: '危急', value: 'critical' },
{ label: '警告', value: 'warning' },
];
export const LEVEL_COLOR: Record<string, string> = {
critical: 'red',
warning: 'orange',
};
export const INDICATOR_LABEL: Record<string, string> = Object.fromEntries(
INDICATOR_OPTIONS.map((o) => [o.value, o.label]),
);
export const DIRECTION_LABEL: Record<string, string> = Object.fromEntries(
DIRECTION_OPTIONS.map((o) => [o.value, o.label]),
);
export const LEVEL_LABEL: Record<string, string> = Object.fromEntries(
LEVEL_OPTIONS.map((o) => [o.value, o.label]),
);
// --- API ---
export const criticalValueThresholdApi = {
list: async () => {
const { data } = await client.get<{
success: boolean;
data: CriticalValueThreshold[];
}>('/health/critical-value-thresholds');
return data.data;
},
create: async (req: CreateThresholdReq) => {
const { data } = await client.post<{
success: boolean;
data: CriticalValueThreshold;
}>('/health/critical-value-thresholds', req);
return data.data;
},
update: async (id: string, req: UpdateThresholdReq) => {
const { data } = await client.put<{
success: boolean;
data: CriticalValueThreshold;
}>(`/health/critical-value-thresholds/${id}`, req);
return data.data;
},
delete: async (id: string) => {
await client.delete(`/health/critical-value-thresholds/${id}`);
},
};

View File

@@ -0,0 +1,108 @@
import client from '../client';
import type { PaginatedResponse } from '../types';
// --- Types ---
export interface Diagnosis {
id: string;
patient_id: string;
health_record_id?: string;
icd_code: string;
diagnosis_name: string;
diagnosis_type: string;
diagnosed_date: string;
status: string;
diagnosed_by?: string;
notes?: string;
created_at: string;
updated_at: string;
version: number;
}
export interface CreateDiagnosisReq {
icd_code: string;
diagnosis_name: string;
diagnosis_type?: string;
diagnosed_date: string;
status?: string;
health_record_id?: string;
diagnosed_by?: string;
notes?: string;
}
export interface UpdateDiagnosisReq {
icd_code?: string;
diagnosis_name?: string;
diagnosis_type?: string;
diagnosed_date?: string;
status?: string;
health_record_id?: string;
diagnosed_by?: string;
notes?: string;
}
// --- Constants ---
export const DIAGNOSIS_TYPE_OPTIONS = [
{ label: '主要诊断', value: 'primary' },
{ label: '次要诊断', value: 'secondary' },
{ label: '合并症', value: 'comorbid' },
];
export const DIAGNOSIS_STATUS_OPTIONS = [
{ label: '活跃', value: 'active' },
{ label: '已缓解', value: 'resolved' },
{ label: '慢性', value: 'chronic' },
];
export const DIAGNOSIS_TYPE_COLOR: Record<string, string> = {
primary: 'red',
secondary: 'blue',
comorbid: 'orange',
};
export const DIAGNOSIS_STATUS_COLOR: Record<string, string> = {
active: 'green',
resolved: 'default',
chronic: 'orange',
};
export const DIAGNOSIS_TYPE_LABEL: Record<string, string> = Object.fromEntries(
DIAGNOSIS_TYPE_OPTIONS.map((o) => [o.value, o.label]),
);
export const DIAGNOSIS_STATUS_LABEL: Record<string, string> = Object.fromEntries(
DIAGNOSIS_STATUS_OPTIONS.map((o) => [o.value, o.label]),
);
// --- API ---
export const diagnosisApi = {
list: async (patientId: string, params?: { page?: number; page_size?: number }) => {
const { data } = await client.get<{
success: boolean;
data: PaginatedResponse<Diagnosis>;
}>(`/health/patients/${patientId}/diagnoses`, { params });
return data.data;
},
create: async (patientId: string, req: CreateDiagnosisReq) => {
const { data } = await client.post<{
success: boolean;
data: Diagnosis;
}>(`/health/patients/${patientId}/diagnoses`, req);
return data.data;
},
update: async (diagnosisId: string, req: UpdateDiagnosisReq & { version: number }) => {
const { data } = await client.put<{
success: boolean;
data: Diagnosis;
}>(`/health/diagnoses/${diagnosisId}`, req);
return data.data;
},
delete: async (diagnosisId: string, version: number) => {
await client.delete(`/health/diagnoses/${diagnosisId}`, { data: { version } });
},
};