Files
akmon/pages/ec/types.uts
2026-01-20 08:04:15 +08:00

684 lines
18 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 养老管理系统类型定义 - 简化版本(直接映射数据库字段)
// filepath: h:\blews\akmon\pages\ec\types.uts
// 老人基本信息
export type Elder = {
id: string
user_id: string | null
facility_id: string | null
care_unit_id: string | null
elder_code: string | null
name: string
id_card: string | null
gender: string | null
birthday: string | null
avatar?: string | null // 头像字段,表单用
birth_date?: string | null // 兼容表单字段
phone?: string | null // 联系电话,表单用
address?: string | null // 联系地址,表单用
health_status?: string | null // 健康状态,表单用
medical_history?: string | null // 疾病史,表单用
allergies?: string | null // 过敏史,表单用
special_needs?: string | null // 特殊需求,表单用
emergency_contact_name?: string | null // 紧急联系人姓名
emergency_contact_relationship?: string | null // 紧急联系人关系
emergency_contact_phone?: string | null // 紧急联系人电话
nationality: string | null
religion: string | null
marital_status: string | null
education: string | null
occupation: string | null
admission_date: string | null
care_level: string | null
room_number: string | null
bed_number: string | null
payment_method: string | null
monthly_fee: number | null
deposit: number | null
status: string | null
created_at: string | null
updated_at: string | null
}
// 护理员
export type Caregiver = {
id: string
user_id: string
facility_id: string | null
name: string
phone: string | null
position: string | null
certification: string | null
work_shift: string | null
max_capacity: number | null
status: string | null
created_at: string | null
updated_at: string | null
}
// 护理记录
export type CareRecord = {
id: string
task_id: string | null
elder_id: string
elder_name?: string | null // 用于连接查询时的老人姓名
caregiver_id: string
caregiver_name?: string | null // 用于连接查询时的护理员姓名
start_time: string | null
end_time: string | null
actual_duration: number | null
care_content: string | null
description?: string | null // 用于显示护理内容的简化描述
record_type?: string | null // 用于分类显示的记录类型
elder_condition: string | null
issues_notes: string | null
photo_urls: string[] | null
status: string
rating: number | null
supervisor_notes: string | null
created_at: string
updated_at: string
}
// 健康提醒
export type HealthAlert = {
id: string
elder_id: string
elder_name?: string | null // 用于连接查询时的老人姓名
alert_type: string
severity: string
title: string
description: string | null
vital_sign_id: string | null
threshold_value: number | null
actual_value: number | null
status: string
acknowledged_by: string | null
acknowledged_at: string | null
resolved_at: string | null
notes: string | null
created_at: string
updated_at: string
}
// 护理任务
export type CareTask = {
id: string
elder_id: string
elder_name?: string | null // 用于连接查询时的老人姓名
care_plan_id: string | null
task_name: string
task_type: string | null
description: string | null
scheduled_time: string | null
assigned_to: string | null
caregiver_name?: string | null // 用于连接查询时的护理员姓名
priority: string
estimated_duration: number | null
status: string
due_date: string | null
created_by: string | null
created_at: string
updated_at: string
}
// 生命体征
export type VitalSign = {
id: string
elder_id: string
device_id: string | null
vital_type: string
systolic_pressure: number | null
diastolic_pressure: number | null
heart_rate: number | null
temperature: number | null
oxygen_saturation: number | null
glucose_level: number | null
measured_at: string
measured_by: string | null
notes: string | null
is_abnormal: boolean
created_at: string
}
// 用药管理
export type Medication = {
id: string
elder_id: string
medical_record_id: string | null
medication_name: string
dosage: string | null
frequency: string | null
route: string | null
start_date: string | null
end_date: string | null
prescribed_by: string | null
instructions: string | null
side_effects: string | null
status: string
created_at: string
updated_at: string
}
// 活动记录
export type Activity = {
id: string
facility_id: string
activity_name: string
activity_type: string | null
description: string | null
location: string | null
start_time: string | null
end_time: string | null
max_participants: number | null
instructor: string | null
requirements: string | null
materials_needed: string | null
status: string
created_by: string | null
created_at: string
updated_at: string
}
// 访客记录
export type Visit = {
id: string
elder_id: string
visitor_name: string
visitor_relationship: string | null
visitor_id_card: string | null
visitor_phone: string | null
visit_date: string | null
start_time: string | null
end_time: string | null
purpose: string | null
notes: string | null
status: string
approved_by: string | null
created_at: string
updated_at: string
}
// 账单记录
export type Bill = {
id: string
elder_id: string
bill_type: string
amount: number
description: string | null
due_date: string | null
paid_date: string | null
status: string
payment_method: string | null
notes: string | null
created_at: string
updated_at: string
}
// 机构信息
export type Facility = {
id: string
name: string
region_id: string | null
type: string | null
license_number: string | null
contact_phone: string | null
address: string | null
capacity: number | null
current_occupancy: number | null
created_at: string
updated_at: string
}
// 工作排班
export type WorkSchedule = {
id: string
caregiver_id: string
facility_id: string | null
date: string
shift: string | null
start_time: string | null
end_time: string | null
assigned_elders: string[] | null
status: string
notes: string | null
created_at: string
updated_at: string
}
// 设备信息
export type Equipment = {
id: string
name: string
equipment_id: string
type: string
type_name: string
model: string | null
location_id: string | null
location_name: string | null
status: string
description: string | null
last_maintenance: string | null
next_maintenance: string | null
created_at: string
updated_at: string
}
// 维护记录
export type MaintenanceRecord = {
id: string
equipment_id: string
type: string
description: string
performed_by: string
performed_at: string
next_maintenance_date: string | null
created_at: string
}
// 事件报告
export type Incident = {
id: string
elder_id: string
facility_id: string | null
incident_type: string
severity: string
title: string
description: string | null
location: string | null
incident_time: string
reported_by: string | null
witnesses: string[] | null
actions_taken: string | null
follow_up_required: boolean
status: string
resolved_at: string | null
created_at: string
updated_at: string
}
// 医生信息
export type Doctor = {
id: string
user_id: string
facility_id: string | null
name: string
specialization: string | null
license_number: string | null
phone: string | null
email: string | null
status: string
created_at: string
updated_at: string
}
// 护士信息
export type Nurse = {
id: string
user_id: string
facility_id: string | null
name: string
certification: string | null
department: string | null
phone: string | null
email: string | null
status: string
created_at: string
updated_at: string
}
// 统计数据类型
export type DashboardStats = {
total_elders: number
total_caregivers: number
on_duty_caregivers: number
occupancy_rate: number
available_beds: number
urgent_alerts: number
elders_trend: number
}
// 健康统计数据类型
export type HealthStats = {
total_equipment: number
online_equipment: number
maintenance_needed: number
faulty_equipment: number
total_records_today: number
abnormal_readings: number
pending_reviews: number
critical_alerts: number
today_visitors: number
current_visitors: number
scheduled_visits: number
pending_approvals: number
}
// 数据分析相关类型
export type AnalyticsMetric = {
key: string
label: string
value: string
icon: string
trend: string
change: string
}
export type ActivityStat = {
type: string
label: string
count: number
percentage: number
color: string
}
export type CareQualityItem = {
name: string
value: number
}
export type CareQualityMetric = {
category: string
score: number
items: Array<CareQualityItem>
}
export type Alert = {
id: string
title: string
message: string
level: string
created_at: string
handled: boolean
}
export type DoctorInfo = {
id: string
name: string
phone: string
department: string
specialization: string
title: string
}
// 老人统计数据
export type ElderStats = {
total: number
new_this_month: number
self_care: number
assisted_care: number
full_care: number
}
// 事件报告相关类型
export type IncidentReport = {
id: string
title: string
elder_id: string
elder_name?: string
reporter_id: string
reporter_name?: string
incident_type: 'medical' | 'safety' | 'behavioral' | 'equipment' | 'other'
priority: 'normal' | 'high' | 'urgent' | 'critical'
status: 'pending' | 'in_progress' | 'resolved' | 'closed'
description: string
action_taken?: string
incident_time: string
created_at: string
updated_at: string
}
export type IncidentStats = {
urgent_incidents: number
pending_reports: number
resolved_today: number
total_incidents: number
}
// 任务统计类型
export type TaskStats = {
pending: number
in_progress: number
completed: number
overdue: number
total: number
}
// 护工相关类型
export type CaregiverInfo = {
id: string
name: string
employee_id: string
phone?: string
email?: string
avatar?: string
hire_date?: string
care_level?: 'junior' | 'intermediate' | 'senior' | 'supervisor'
status?: 'active' | 'on_leave' | 'inactive'
assigned_elders?: number
rating?: number
specialties?: string
certifications?: string
created_at?: string
updated_at?: string
}
export type CaregiverStats = {
total_caregivers: number
active_caregivers: number
on_leave: number
workload_avg: number
}
// 工具函数
export function formatDateTime(dateTime: string | null): string {
if (dateTime === null || dateTime === '') return ''
const date = new Date(dateTime)
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hour = date.getHours().toString().padStart(2, '0')
const minute = date.getMinutes().toString().padStart(2, '0')
return `${year}-${month}-${day} ${hour}:${minute}`
}
export function formatDate(date: string | null): string {
if (date === null || date === '') return ''
const d = new Date(date)
const year = d.getFullYear()
const month = (d.getMonth() + 1).toString().padStart(2, '0')
const day = d.getDate().toString().padStart(2, '0')
return `${year}-${month}-${day}`
}
export function formatTime(time: string | null): string {
if (time === null || time === '') return ''
const date = new Date(time)
const hour = date.getHours().toString().padStart(2, '0')
const minute = date.getMinutes().toString().padStart(2, '0')
return `${hour}:${minute}`
}
export function getAge(birthday: string | null): number {
if (birthday === null || birthday === '') return 0
const birth = new Date(birthday)
const today = new Date()
let age = today.getFullYear() - birth.getFullYear()
const monthDiff = today.getMonth() - birth.getMonth()
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
age--
}
return age
}
export function getCareLevelText(level: string | null): string {
if (level === null) return '未设置'
const levelMap = new Map<string, string>([
['self_care', '自理'],
['assisted', '半护理'],
['full_care', '全护理'],
['dementia', '失智护理']
])
return levelMap.get(level) ?? level
}
export function getHealthStatusText(status: string | null): string {
if (status === null) return '未知'
const statusMap = new Map<string, string>([
['excellent', '优秀'],
['good', '良好'],
['fair', '一般'],
['poor', '较差'],
['critical', '严重']
])
return statusMap.get(status) ?? status
}
export function getSeverityText(severity: string): string {
const severityMap = new Map<string, string>([
['low', '低'],
['medium', '中'],
['high', '高'],
['critical', '紧急'] ])
return severityMap.get(severity) ?? severity
}
export function getTaskStatusText(status: string): string {
const statusMap = new Map<string, string>([
['pending', '待处理'],
['in_progress', '进行中'],
['completed', '已完成'],
['cancelled', '已取消'],
['overdue', '已超期']
])
return statusMap.get(status) ?? status
}
export function getTaskPriorityText(priority: string): string {
const priorityMap = new Map<string, string>([
['low', '低'],
['normal', '普通'],
['high', '高'],
['urgent', '紧急']
])
return priorityMap.get(priority) ?? priority
}
export function getRecordTypeText(type: string | null): string {
if (type === null) return '其他'
const typeMap = new Map<string, string>([
['medication', '用药'],
['hygiene', '清洁'],
['mobility', '康复'],
['nutrition', '饮食'],
['social', '社交'],
['medical', '医疗']
])
return typeMap.get(type) ?? type
}
export function getAlertIcon(severity: string): string {
const iconMap = new Map<string, string>([
['critical', '🚨'],
['high', '⚠️'],
['medium', ''],
['low', '💡']
])
return iconMap.get(severity) ?? ''
}
export function getPriorityIcon(priority: string): string {
const iconMap = new Map<string, string>([
['urgent', '🚨'],
['high', '⚠️'],
['normal', '📋'],
['low', '💭']
])
return iconMap.get(priority) ?? '📋'
}
export function getTaskPriorityClass(priority: string): string {
const classMap = new Map<string, string>([
['urgent', 'priority-urgent'],
['high', 'priority-high'],
['normal', 'priority-normal'],
['low', 'priority-low']
])
return classMap.get(priority) ?? 'priority-normal'
}
export function getSeverityClass(severity: string): string {
const classMap = new Map<string, string>([
['critical', 'severity-critical'],
['high', 'severity-high'],
['medium', 'severity-medium'],
['low', 'severity-low']
])
return classMap.get(severity) ?? 'severity-medium'
}
export function getStatusClass(status: string): string {
const classMap = new Map<string, string>([
['active', 'status-active'],
['inactive', 'status-inactive'],
['pending', 'status-pending'],
['completed', 'status-completed'],
['cancelled', 'status-cancelled'],
['in_progress', 'status-progress']
])
return classMap.get(status) ?? 'status-unknown'
}
// 通用状态文本转换
export function getStatusText(status: string | null): string {
if (!status) return '未知'
const map = new Map<string, string>([
['normal', '正常'],
['warning', '预警'],
['danger', '异常'],
['stable', '稳定'],
['critical', '危急'],
['pending', '待处理'],
['completed', '已完成'],
['in_progress', '进行中'],
['cancelled', '已取消'],
['active', '活跃'],
['inactive', '未激活']
])
return map.get(status) ?? status
}
// 活动状态文本转换
export function getActivityStatusText(status: string | null): string {
if (!status) return '未知'
const map = new Map<string, string>([
['pending', '待开始'],
['in_progress', '进行中'],
['completed', '已完成'],
['cancelled', '已取消']
])
return map.get(status) ?? status
}
// 补充 getHealthStatusClass 工具函数,返回健康状态对应的 class
export function getHealthStatusClass(status: string): string {
switch (status) {
case 'excellent': return 'health-excellent'
case 'good': return 'health-good'
case 'fair': return 'health-fair'
case 'poor': return 'health-poor'
default: return ''
}
}
// 获取优先级文本
export const getPriorityText = (priority: string): string => {
switch (priority) {
case 'urgent': return '紧急'
case 'high': return '高'
case 'normal': return '普通'
case 'low': return '低'
default: return priority
}
}