Commit 22d8ccbc by luoqi

fix(plan-detail): 治疗历史的"治疗计划"仅在晚于最近一次实际治疗时显示

旧版按 plannedFor 取最新 planned treatment 置顶,不管它是否已被后续治疗超越。
韩滨:拆线47(计划 2026-02-06)早于最新实际治疗(2026-03-16)→ 实为过期/已执行
的旧计划,却仍标"治疗计划"。改为:仅当计划日期 > 最近一次实际治疗日才显示。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
parent d7a251a3
...@@ -1296,13 +1296,6 @@ function treatmentLabel(f: AdaptedFact): string { ...@@ -1296,13 +1296,6 @@ function treatmentLabel(f: AdaptedFact): string {
} }
function TreatmentHistoryCard({ facts }: { facts: AdaptedFact[] }) { function TreatmentHistoryCard({ facts }: { facts: AdaptedFact[] }) {
const latestPlan = useMemo(() => {
const planned = facts
.filter((f) => f.type === 'treatment_record' && f.kind === 'planned')
.sort((a, b) => (b.plannedFor ?? '').localeCompare(a.plannedFor ?? ''));
return planned[0] ?? null;
}, [facts]);
const history = useMemo( const history = useMemo(
() => () =>
facts facts
...@@ -1311,6 +1304,18 @@ function TreatmentHistoryCard({ facts }: { facts: AdaptedFact[] }) { ...@@ -1311,6 +1304,18 @@ function TreatmentHistoryCard({ facts }: { facts: AdaptedFact[] }) {
[facts], [facts],
); );
const latestPlan = useMemo(() => {
const top = facts
.filter((f) => f.type === 'treatment_record' && f.kind === 'planned')
.sort((a, b) => (b.plannedFor ?? '').localeCompare(a.plannedFor ?? ''))[0];
if (!top) return null;
// 只显示"最近一次实际治疗之后"的计划:计划日期 ≤ 最新治疗日 = 已被后续治疗超越/执行,不显示
const latestActualDay = history[0]?.occurredAt?.slice(0, 10) ?? '';
const planDay = top.plannedFor?.slice(0, 10) ?? '';
if (latestActualDay && planDay && planDay <= latestActualDay) return null;
return top;
}, [facts, history]);
return ( return (
<SidebarCard title="治疗历史" meta={history.length > 0 ? `${history.length} 项` : undefined}> <SidebarCard title="治疗历史" meta={history.length > 0 ? `${history.length} 项` : undefined}>
{/* 治疗计划(最新一条)— 置顶,与历史同一行格式,"治疗计划"标在最右 */} {/* 治疗计划(最新一条)— 置顶,与历史同一行格式,"治疗计划"标在最右 */}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment