import { redirect } from "next/navigation"; import { Activity, FileText, HeartPulse, ShieldAlert, Stethoscope } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Table } from "@/components/ui/table"; import { getCurrentAuthContext } from "@/modules/core/server/auth"; import { hasPermission } from "@/modules/core/server/permissions"; import { HealthAdminClient } from "@/modules/health/components/HealthAdminClient"; import { listHealthAdminData } from "@/modules/health/server/operations"; import type { HealthReviewSeverity, HealthReviewStatus } from "@/modules/health/types"; import { CHRONIC_CONDITION_STATUS_LABELS, HEALTH_REVIEW_SEVERITY_LABELS, HEALTH_REVIEW_STATUS_LABELS, VITAL_SOURCE_LABELS, } from "@/modules/health/types"; import { getWorkspaceHref } from "@/modules/shared/lib/workspace-routing"; type HealthPageData = { canManage: boolean; data: Awaited>; }; function formatDateTime(value: string | undefined): string { return value ? new Date(value).toLocaleString("zh-CN") : "-"; } function formatTenths(value: number | undefined, suffix = ""): string { return value === undefined ? "-" : `${(value / 10).toFixed(1)}${suffix}`; } function severityBadgeVariant(severity: HealthReviewSeverity): "secondary" | "warning" | "danger" { if (severity === "critical") { return "danger"; } return severity === "warning" ? "warning" : "secondary"; } function reviewStatusBadgeVariant(status: HealthReviewStatus): "success" | "secondary" | "warning" { if (status === "pending") { return "warning"; } return status === "resolved" ? "success" : "secondary"; } async function loadHealthPageData(): Promise { const context = await getCurrentAuthContext(); if (!context) { redirect("/login"); } if (!hasPermission(context.permissions, "health:read")) { redirect(getWorkspaceHref(context.organization?.slug, "/dashboard")); } const organizationId = context.organization?.id; if (!organizationId) { redirect(getWorkspaceHref(context.organization?.slug, "/dashboard")); } const data = await listHealthAdminData(organizationId); return { canManage: hasPermission(context.permissions, "health:manage"), data, }; } export async function renderHealthWorkspacePage(): Promise { const { data } = await loadHealthPageData(); const pendingReviews = data.reviews.filter((review) => review.status === "pending").slice(0, 8); const recentVitals = data.vitals.slice(0, 8); const activeConditions = data.chronicConditions.filter((condition) => condition.status === "active").slice(0, 8); return (

健康照护

健康概览、重点慢病、生命体征与异常复核队列

待复核健康异常 按最新异常记录展示护理复核队列。 老人 异常 级别 状态 创建时间 {pendingReviews.map((review) => ( {review.elderName}

{review.title}

{review.description}

{HEALTH_REVIEW_SEVERITY_LABELS[review.severity]} {HEALTH_REVIEW_STATUS_LABELS[review.status]} {formatDateTime(review.createdAt)}
))} {pendingReviews.length === 0 ? ( 暂无待复核健康异常 ) : null}
慢病重点关注 持续管理中的慢病记录。 {activeConditions.map((condition) => (

{condition.elderName}

{condition.name}

{CHRONIC_CONDITION_STATUS_LABELS[condition.status]}

{condition.followUpNotes || condition.treatmentNotes || "暂无随访备注"}

))} {activeConditions.length === 0 ?

暂无持续管理慢病记录

: null}
最近生命体征 展示最新录入或采集的生命体征记录。 老人 时间 来源 血压 心率 体温 血氧 备注 {recentVitals.map((vital) => ( {vital.elderName} {formatDateTime(vital.recordedAt)} {VITAL_SOURCE_LABELS[vital.source]} {vital.systolicBp && vital.diastolicBp ? `${vital.systolicBp}/${vital.diastolicBp}` : "-"} {vital.heartRate?.toString() ?? "-"} {formatTenths(vital.temperatureTenths, "°C")} {vital.spo2 === undefined ? "-" : `${vital.spo2}%`} {vital.notes || "-"} ))} {recentVitals.length === 0 ? ( 暂无生命体征记录 ) : null}
); } export async function renderHealthSettingsPage(): Promise { const { canManage, data } = await loadHealthPageData(); return (

健康数据管理

维护健康档案、生命体征、慢病记录与异常复核

); } function MetricCard({ icon, label, value }: { icon: React.ReactNode; label: string; value: number }): React.ReactElement { return ( {label} {icon} {value} ); }