feat(lex): Timeline and Valuation views (S1)
This commit is contained in:
@@ -287,6 +287,12 @@ button.dis { font-family: var(--font-body); font-size: 14px; padding: 3px 10px;
|
||||
.tl-item .top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
|
||||
.tl-item .ttl { font-weight: 600; }
|
||||
.tl-item .sum { font-size: 14px; color: var(--secondary-foreground); }
|
||||
.tl-item .tl-blk { border-top: 1px dashed var(--border); padding-top: 6px; display: grid; gap: 4px; }
|
||||
.tl-item details > summary { cursor: pointer; color: var(--muted-foreground); }
|
||||
.tl-item[hidden], .tl-year[hidden] { display: none; }
|
||||
.tl-item .cite { white-space: normal; overflow-wrap: anywhere; }
|
||||
.tl-item .facts { font-size: 14px; }
|
||||
.tbl td.why { min-width: 14rem; max-width: 26rem; }
|
||||
.type { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 1px 5px; border: 1px solid var(--border); color: var(--secondary-foreground); background: var(--secondary); white-space: nowrap; }
|
||||
.type.origin { border-color: var(--s-alt); }
|
||||
.type.valuation { border-color: var(--s-final); }
|
||||
|
||||
@@ -1,10 +1,108 @@
|
||||
// lex · Timeline view. A stub until S1 Task 7 fills it in.
|
||||
// lex · Timeline view: the family's dated changes, by year, each with its
|
||||
// facts, our classification and CMS's own summary kept apart.
|
||||
//
|
||||
// A view module exports needs (the API slices it reads), render(data, state)
|
||||
// returning markup, and optionally mount(root, data, state, nav).
|
||||
// Telehealth events show only their cited text (the stored neutral wording).
|
||||
|
||||
import { esc } from "./fmt.js";
|
||||
import { factHtml, tagged } from "./cite.js";
|
||||
|
||||
export const needs = ["header", "timeline"];
|
||||
|
||||
export function render() {
|
||||
return `<p class="muted">This view is being built.</p>`;
|
||||
const KIND = {
|
||||
deleted: "Deleted",
|
||||
cpt_panel: "CPT panel",
|
||||
telehealth_list: "Telehealth list",
|
||||
appeared: "Appeared",
|
||||
disappeared: "Disappeared",
|
||||
descriptor_change: "Descriptor change",
|
||||
revalued: "Revalued",
|
||||
valuation: "Valuation",
|
||||
comments: "Comments",
|
||||
formation: "Formation",
|
||||
origin: "Origin",
|
||||
cpt_edition: "CPT edition",
|
||||
};
|
||||
|
||||
// the .type chip's colour class (template.html): valuation, origin, cms, link
|
||||
const TYPE_CLASS = { valuation: "valuation", revalued: "valuation", origin: "origin", formation: "origin", comments: "cms" };
|
||||
|
||||
const kindLabel = (k) => (k.startsWith("link:") ? "Linked code: " + k.slice(5) : KIND[k] || k.replace(/_/g, " "));
|
||||
const kindClass = (k) => (k.startsWith("link:") ? "link" : TYPE_CLASS[k] || "");
|
||||
const filterKey = (k) => (k.startsWith("link:") ? "link" : k);
|
||||
const filterLabel = (k) => (k === "link" ? "Linked codes" : kindLabel(k));
|
||||
|
||||
const list = (ids, facts) => (ids || []).map((id) => facts[id]).filter(Boolean).map((f) => factHtml(f)).join("");
|
||||
|
||||
function eventHtml(e, facts) {
|
||||
const telehealth = e.kind === "telehealth_list";
|
||||
let h = `<div class="tl-item" data-kind="${esc(filterKey(e.kind))}" data-open="${esc((e.fact_ids || [])[0] || "")}">`;
|
||||
h += `<div class="top"><span class="type ${kindClass(e.kind)}">${esc(kindLabel(e.kind))}</span><span class="sum">${tagged(e.what_changed, facts)}</span></div>`;
|
||||
if ((e.codes || []).length) h += `<div class="codes">${e.codes.map((c) => `<span class="code">${esc(c)}</span>`).join("")}</div>`;
|
||||
const sources = list(e.fact_ids, facts);
|
||||
if (sources) h += `<details><summary class="small">Sources and facts (${(e.fact_ids || []).filter((id) => facts[id]).length})</summary><ul class="facts">${sources}</ul></details>`;
|
||||
if (!telehealth) {
|
||||
const ours = list(e.stance_fact_ids, facts);
|
||||
if (ours) h += `<div class="tl-blk"><span class="eyebrow">Our classification</span><ul class="facts">${ours}</ul></div>`;
|
||||
const cms = list(e.cms_summary_fact_ids, facts);
|
||||
if (cms) h += `<div class="tl-blk"><div><span class="eyebrow">CMS's summary</span> <span class="pill cms">cms</span></div><ul class="facts">${cms}</ul></div>`;
|
||||
}
|
||||
return h + "</div>";
|
||||
}
|
||||
|
||||
export function render(data, state) {
|
||||
const T = data.timeline;
|
||||
const facts = T.facts || {};
|
||||
const code = (state && state.code) || "";
|
||||
const all = T.events || [];
|
||||
const events = all.filter((e) => !code || (e.codes || []).includes(code));
|
||||
const unplaced = (T.unplaced || []).map((id) => facts[id]).filter((f) => f && (!code || (f.codes || []).includes(code)));
|
||||
|
||||
const counts = new Map();
|
||||
for (const e of events) counts.set(filterKey(e.kind), (counts.get(filterKey(e.kind)) || 0) + 1);
|
||||
const codes = Array.from(new Set(all.flatMap((e) => e.codes || []))).sort();
|
||||
if (code && !codes.includes(code)) codes.push(code);
|
||||
|
||||
let h = `<div class="col-h"><h2>Timeline</h2></div>
|
||||
<p class="lede">Dated changes to the family: what appeared, was deleted or revalued, and CMS's own summaries of comments. Open an entry's sources to read the fact behind it.</p>`;
|
||||
h += `<div class="filters" id="tl-f">
|
||||
<button class="fbtn" type="button" data-k="all" aria-pressed="true">All <span class="muted">${events.length}</span></button>
|
||||
${Array.from(counts, ([k, n]) => `<button class="fbtn" type="button" data-k="${esc(k)}" aria-pressed="false">${esc(filterLabel(k))} <span class="muted">${n}</span></button>`).join("")}
|
||||
<label class="eyebrow" for="tl-code" style="margin-left:8px">Code</label>
|
||||
<select class="fsel" id="tl-code"><option value="">All codes</option>${codes.map((c) => `<option value="${esc(c)}"${c === code ? " selected" : ""}>${esc(c)}</option>`).join("")}</select></div>`;
|
||||
|
||||
const years = Array.from(new Set(events.map((e) => e.year))).sort((a, b) => a - b);
|
||||
h += `<div id="tl-list">`;
|
||||
if (!years.length) h += `<p class="muted">No timeline entries${code ? " for " + esc(code) : ""}.</p>`;
|
||||
for (const y of years) {
|
||||
const its = events.filter((e) => e.year === y);
|
||||
h += `<div class="tl-year"><h4>CY${esc(y)}<small>${its.length} ${its.length === 1 ? "entry" : "entries"}</small></h4><div class="tl-items">${its.map((e) => eventHtml(e, facts)).join("")}</div></div>`;
|
||||
}
|
||||
h += `</div>`;
|
||||
if (unplaced.length) {
|
||||
h += `<div class="sec-head"><span class="section-eyebrow">Not placed on the timeline</span></div>
|
||||
<p class="small muted">Facts the timeline did not attach to a dated entry. They are listed here so none is lost.</p>
|
||||
<ul class="facts">${unplaced.map((f) => factHtml(f)).join("")}</ul>`;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
export function mount(root, data, state, nav) {
|
||||
const bar = root.querySelector("#tl-f");
|
||||
const sel = root.querySelector("#tl-code");
|
||||
if (bar) {
|
||||
bar.addEventListener("click", (e) => {
|
||||
const b = e.target.closest("[data-k]");
|
||||
if (!b) return;
|
||||
for (const x of bar.querySelectorAll("[data-k]")) x.setAttribute("aria-pressed", String(x === b));
|
||||
// the kind filter is UI only: it hides rows, it does not touch the URL
|
||||
for (const it of root.querySelectorAll(".tl-item")) it.hidden = b.dataset.k !== "all" && it.dataset.kind !== b.dataset.k;
|
||||
for (const y of root.querySelectorAll(".tl-year")) y.hidden = !y.querySelector(".tl-item:not([hidden])");
|
||||
});
|
||||
}
|
||||
if (sel) sel.addEventListener("change", () => nav.go({ code: sel.value }, { push: false }));
|
||||
root.addEventListener("click", (e) => {
|
||||
if (e.target.closest("a, button, summary, details, [data-fact], [data-ref], [data-refs]")) return;
|
||||
const it = e.target.closest(".tl-item");
|
||||
if (it && it.dataset.open) nav.openFact(it.dataset.open);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,160 @@
|
||||
// lex · Valuation view. A stub until S1 Task 7 fills it in.
|
||||
// lex · Valuation view: RUC recommendation against CMS's proposed and final
|
||||
// work RVUs, one table per rule, then the dot plot across the rounds.
|
||||
//
|
||||
// A view module exports needs (the API slices it reads), render(data, state)
|
||||
// returning markup, and optionally mount(root, data, state, nav).
|
||||
// Proposed values sit in their own hatched columns with a "proposed" pill and
|
||||
// are never blended with final ones. Columns that are empty across every row
|
||||
// are left out (the slice's `columns`).
|
||||
|
||||
import { esc, int, n2 } from "./fmt.js";
|
||||
import { citeHtml, factHtml } from "./cite.js";
|
||||
|
||||
export const needs = ["header", "valuation"];
|
||||
|
||||
export function render() {
|
||||
return `<p class="muted">This view is being built.</p>`;
|
||||
const OPTIONAL = {
|
||||
ruc_percentile: ["Survey pct.", "text"],
|
||||
survey_intra_min: ["Survey intra (min)", "int"],
|
||||
survey_total_min: ["Survey total (min)", "int"],
|
||||
comparators: ["Comparators", "text"],
|
||||
surveying_societies: ["Surveying societies", "text"],
|
||||
requested_work_rvu: ["Requested", "rvu"],
|
||||
rationale_quote: ["CMS rationale", "why"],
|
||||
pe_note: ["PE note", "why"],
|
||||
};
|
||||
|
||||
const asArr = (c) => (Array.isArray(c) ? c : c ? [c] : []);
|
||||
const filled = (v) => v !== null && v !== undefined && v !== "" && !(Array.isArray(v) && v.length === 0);
|
||||
const byId = (a, b) => parseInt(String(a.id).slice(1), 10) - parseInt(String(b.id).slice(1), 10);
|
||||
|
||||
// The row's source: its rationale, else the cite behind its final value.
|
||||
function sourceCite(r) {
|
||||
if (r.rationale) return r.rationale;
|
||||
const c = r.cites || {};
|
||||
for (const k of ["final_work_rvu", "decision", "proposed_work_rvu", "ruc_work_rvu", ...Object.keys(c)]) {
|
||||
const [first] = asArr(c[k]);
|
||||
if (first) return first;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function cell(r, key, kind) {
|
||||
const v = r[key];
|
||||
if (kind === "int") return `<td class="r num">${v == null ? "—" : esc(int(v))}</td>`;
|
||||
if (kind === "rvu") return `<td class="r num">${esc(n2(v))}</td>`;
|
||||
return `<td class="small${kind === "why" ? " why" : ""}">${filled(v) ? esc(v) : "—"}</td>`;
|
||||
}
|
||||
|
||||
function groupTable(rows, columns, deleted) {
|
||||
let h = `<div class="tbl-wrap"><table class="tbl"><thead><tr><th>Code</th><th class="r">RUC rec.</th>`;
|
||||
h += columns.map((c) => `<th${OPTIONAL[c][1] === "text" || OPTIONAL[c][1] === "why" ? "" : ' class="r"'}>${esc(OPTIONAL[c][0])}</th>`).join("");
|
||||
h += `<th class="r pcol">CMS proposed <span class="pill prop">proposed</span></th><th class="r">CMS final</th><th>Decision</th><th>Source</th></tr></thead><tbody>`;
|
||||
for (const { r, i } of rows) {
|
||||
const del = deleted.has(r.code);
|
||||
h += `<tr data-round="${i}" tabindex="0"><td class="mono"><span class="code${del ? " del" : ""}">${esc(r.code)}</span></td><td class="r num">${esc(n2(r.ruc_work_rvu))}</td>`;
|
||||
h += columns.map((c) => cell(r, c, OPTIONAL[c][1])).join("");
|
||||
h += `<td class="r num pcol">${esc(n2(r.proposed_work_rvu))}</td><td class="r num">${esc(n2(r.final_work_rvu))}</td><td class="small">${esc(r.decision || "—")}</td><td class="nowrap">${citeHtml(sourceCite(r))}</td></tr>`;
|
||||
}
|
||||
return h + `</tbody></table></div>`;
|
||||
}
|
||||
|
||||
/** One row's evidence for the drawer: every non-empty field, each with its cite. */
|
||||
export function roundEvidence(r) {
|
||||
const skip = new Set(["family", "cites", "rationale"]);
|
||||
const dl = Object.entries(r)
|
||||
.filter(([k, v]) => !skip.has(k) && filled(v))
|
||||
.map(([k, v]) => `<dt>${esc(k.replace(/_/g, " "))}</dt><dd>${esc(v)}${asArr((r.cites || {})[k]).map((c) => " " + citeHtml(c)).join("")}</dd>`)
|
||||
.join("");
|
||||
const rat = r.rationale ? `<div class="ev-src"><div>${citeHtml(r.rationale)}</div><div class="src-t">Rationale</div></div>` : "";
|
||||
return `<div class="ev" data-evidence="round"><div class="d-head"><span class="eyebrow">Evidence · valuation round</span><button class="close" type="button" data-close>Close</button></div>
|
||||
<h3>${esc(r.code)} · CY${esc(r.rule_year)} ${esc(r.rule_kind)} rule</h3>
|
||||
<div class="ev-flags"><span class="pill prop">proposed</span> <span class="pill final">final</span></div>
|
||||
<dl class="ev-dl">${dl}</dl>${rat}</div>`;
|
||||
}
|
||||
|
||||
/** Work RVUs by code: an open ring for each RUC recommendation, a circle for
|
||||
* each CMS final value, one position per round year (older rounds paler). */
|
||||
export function dotPlot(rounds, deleted = new Set()) {
|
||||
const codes = Array.from(new Set(rounds.map((r) => r.code))).sort();
|
||||
const years = Array.from(new Set(rounds.map((r) => r.rule_year))).sort((a, b) => a - b);
|
||||
const vals = rounds.flatMap((r) => [r.ruc_work_rvu, r.final_work_rvu]).filter((v) => v != null).map(Number);
|
||||
const xmax = Math.max(1, Math.ceil(Math.max(0, ...vals)));
|
||||
const W = 660, rowH = 24, top = 46, left = 70, right = 24, H = top + codes.length * rowH + 30;
|
||||
const X = (v) => left + (v / xmax) * (W - left - right);
|
||||
const step = xmax > 8 ? 2 : 1;
|
||||
const fade = (y) => (years.length > 1 ? (0.45 + (0.55 * years.indexOf(y)) / (years.length - 1)).toFixed(2) : "1");
|
||||
let s = `<svg class="chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Work RVUs by code: the RUC recommendation and CMS's final value in each captured round">`;
|
||||
for (let v = 0; v <= xmax; v += step) s += `<line class="grid" x1="${X(v)}" x2="${X(v)}" y1="${top - 8}" y2="${H - 26}"/><text x="${X(v)}" y="${H - 10}" text-anchor="middle">${v.toFixed(1)}</text>`;
|
||||
s += `<text x="${W - right}" y="18" text-anchor="end">work RVU</text>`;
|
||||
s += `<g transform="translate(${left},14)"><circle cx="6" cy="0" r="4.5" fill="var(--card)" stroke="var(--s-ruc)" stroke-width="2"/><text x="16" y="4">RUC recommendation</text>
|
||||
<circle cx="176" cy="0" r="5" fill="var(--s-final)"/><text x="186" y="4">CMS final${years.length > 1 ? " (older rounds paler)" : ""}</text></g>`;
|
||||
codes.forEach((c, i) => {
|
||||
const y = top + i * rowH + rowH / 2;
|
||||
s += `<text x="${left - 10}" y="${y + 4}" text-anchor="end"${deleted.has(c) ? ' text-decoration="line-through"' : ""}>${esc(c)}</text>`;
|
||||
s += `<line class="grid" x1="${left}" x2="${W - right}" y1="${y}" y2="${y}" stroke-dasharray="2 4"/>`;
|
||||
for (const yr of years) {
|
||||
const rs = rounds.filter((r) => r.code === c && r.rule_year === yr);
|
||||
const ruc = rs.map((r) => r.ruc_work_rvu).find((v) => v != null);
|
||||
const fins = Array.from(new Set(rs.filter((r) => r.rule_kind === "final" && r.final_work_rvu != null).map((r) => Number(r.final_work_rvu))));
|
||||
if (ruc != null) {
|
||||
for (const f of fins) if (f !== Number(ruc)) s += `<line x1="${X(ruc)}" x2="${X(f)}" y1="${y}" y2="${y}" stroke="var(--s-ruc)" stroke-width="2" stroke-dasharray="3 3" opacity="${fade(yr)}"/>`;
|
||||
s += `<circle cx="${X(ruc)}" cy="${y}" r="4.5" fill="var(--card)" stroke="var(--s-ruc)" stroke-width="2" data-tip="${esc(c)} · CY${esc(yr)} RUC recommendation ${n2(ruc)}"/>`;
|
||||
}
|
||||
for (const f of fins) s += `<circle cx="${X(f)}" cy="${y}" r="3.5" fill="var(--s-final)" stroke="var(--card)" stroke-width="2" opacity="${fade(yr)}" data-tip="${esc(c)} · CY${esc(yr)} final ${n2(f)}"/>`;
|
||||
}
|
||||
});
|
||||
return s + `</svg>`;
|
||||
}
|
||||
|
||||
export function render(data) {
|
||||
const V = data.valuation;
|
||||
const rounds = V.rounds || [];
|
||||
const facts = Object.values(V.facts || {}).sort(byId);
|
||||
const deleted = new Set(((data.header && data.header.code_groups) || {}).deleted || []);
|
||||
const columns = (V.columns || []).filter((c) => OPTIONAL[c]);
|
||||
let h = `<div class="col-h"><h2>Valuation</h2></div>
|
||||
<p class="lede">The RUC's recommendation against CMS's proposed and final work RVUs, per code per rule. Proposed values are hatched and kept in their own column; they are never blended with final ones.</p>
|
||||
<div class="legend" style="margin-bottom:12px"><span><span class="pill prop">proposed</span> from the proposed rule</span><span><span class="pill final">final</span> from the final rule</span></div>`;
|
||||
if (!rounds.length) h += `<p class="muted">No valuation rounds captured for this family.</p>`;
|
||||
|
||||
const keyOf = (r) => [r.rule_year, r.rule_kind, r.item_key];
|
||||
const groups = [];
|
||||
rounds.forEach((r, i) => {
|
||||
let g = groups.find((x) => x.key.join("|") === keyOf(r).join("|"));
|
||||
if (!g) groups.push((g = { key: keyOf(r), rows: [] }));
|
||||
g.rows.push({ r, i });
|
||||
});
|
||||
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
||||
groups.sort((a, b) => cmp(a.key[0], b.key[0]) || cmp(String(a.key[1]), String(b.key[1])) || cmp(String(a.key[2]), String(b.key[2])));
|
||||
const years = Array.from(new Set([...groups.map((g) => g.key[0]), ...facts.map((f) => f.year)])).sort((a, b) => (a ?? 1e9) - (b ?? 1e9));
|
||||
for (const y of years) {
|
||||
for (const g of groups.filter((x) => x.key[0] === y)) {
|
||||
g.rows.sort((a, b) => String(a.r.code).localeCompare(String(b.r.code)));
|
||||
h += `<h3>CY${esc(y)} · ${esc(g.key[1])} rule <small class="mono muted">${esc(g.key[2])}</small></h3>${groupTable(g.rows, columns, deleted)}`;
|
||||
}
|
||||
const yf = facts.filter((f) => f.year === y);
|
||||
if (yf.length) h += `<div class="sec"><span class="eyebrow">Round and practice-expense facts${y == null ? "" : ", CY" + esc(y)}</span><ul class="facts">${yf.map((f) => factHtml(f)).join("")}</ul></div>`;
|
||||
}
|
||||
if (rounds.length) h += `<h3>Work RVUs across the rounds</h3><div class="chart-box">${dotPlot(rounds, deleted)}</div>`;
|
||||
return h;
|
||||
}
|
||||
|
||||
export function mount(root, data, state, nav) {
|
||||
const rounds = data.valuation.rounds || [];
|
||||
const open = (tr) => {
|
||||
for (const x of root.querySelectorAll("tr.sel")) x.classList.remove("sel");
|
||||
tr.classList.add("sel");
|
||||
nav.openEvidence(roundEvidence(rounds[+tr.dataset.round]));
|
||||
};
|
||||
root.addEventListener("click", (e) => {
|
||||
if (e.target.closest("a, button")) return;
|
||||
const tr = e.target.closest("tr[data-round]");
|
||||
if (tr) open(tr);
|
||||
});
|
||||
root.addEventListener("keydown", (e) => {
|
||||
if (e.key !== "Enter" && e.key !== " ") return;
|
||||
const tr = e.target.closest && e.target.closest("tr[data-round]");
|
||||
if (tr && e.target === tr) {
|
||||
e.preventDefault();
|
||||
open(tr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
117
tests/lex/views-history.test.mjs
Normal file
117
tests/lex/views-history.test.mjs
Normal file
@@ -0,0 +1,117 @@
|
||||
// lex · Timeline and Valuation views.
|
||||
import { test } from "node:test";
|
||||
import { equal as eq, ok } from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
import { parseLocation } from "../../infra/gitea/custom/public/assets/dossier/state.js";
|
||||
import * as timeline from "../../infra/gitea/custom/public/assets/dossier/view-timeline.js";
|
||||
import * as valuation from "../../infra/gitea/custom/public/assets/dossier/view-valuation.js";
|
||||
|
||||
const fx = (name) => JSON.parse(readFileSync(new URL(`./fixtures/${name}.json`, import.meta.url), "utf8"));
|
||||
const H = fx("header");
|
||||
const T = fx("timeline");
|
||||
const V = fx("valuation");
|
||||
const st = (url) => parseLocation(new URL(url, "https://lex.test"));
|
||||
const count = (s, sub) => s.split(sub).length - 1;
|
||||
|
||||
test("timeline: every fact, years ascending, blocks apart, unplaced list", () => {
|
||||
const t = timeline.render({ header: H, timeline: T }, st("/timeline?family=HOME-VISITS"));
|
||||
for (const id of Object.keys(T.facts)) ok(t.includes(`data-fact="${id}"`), id);
|
||||
ok(t.indexOf("Our classification") < t.indexOf("CMS's summary") && t.includes("Not placed on the timeline"));
|
||||
ok(t.includes("CY2023") && t.includes(">Deleted<") && t.includes("Linked code: G0318"));
|
||||
ok(t.includes("<details"));
|
||||
// the accuracy line travels with the classification fact
|
||||
ok(t.includes("it finds 80% of hand-coded positions"));
|
||||
// the CMS summary carries the cms pill; classification does not mix with it
|
||||
ok(/pill cms[^>]*>cms</.test(t));
|
||||
eq(timeline.needs.join(), "header,timeline");
|
||||
});
|
||||
|
||||
test("timeline: a code keeps only its events", () => {
|
||||
const t = timeline.render({ header: H, timeline: T }, st("/timeline?family=HOME-VISITS#code=99341"));
|
||||
ok(!t.includes("99343 was deleted"));
|
||||
ok(t.includes("Invented valuation line"));
|
||||
ok(/<option value="99341" selected>/.test(t));
|
||||
const all = timeline.render({ header: H, timeline: T }, st("/timeline?family=HOME-VISITS"));
|
||||
ok(all.includes("99343 was deleted") && !/selected>/.test(all));
|
||||
});
|
||||
|
||||
test("timeline: kind labels, the raw-kind fallback, a repeated citation counts once", () => {
|
||||
const ev = (kind, extra = {}) => ({ year: 2024, kind, codes: ["99341"], what_changed: "x [F3][F3]", fact_ids: [], stance_fact_ids: [], cms_summary_fact_ids: [], ...extra });
|
||||
const T2 = { ...T, events: [ev("some_new_kind"), ev("telehealth_list"), ev("cpt_edition")], unplaced: [] };
|
||||
const t = timeline.render({ header: H, timeline: T2 }, st("/timeline?family=HOME-VISITS"));
|
||||
ok(t.includes(">some new kind<") && t.includes(">Telehealth list<") && t.includes(">CPT edition<"));
|
||||
eq(count(t, "×"), 0, "one tag repeated twice is one plain chip");
|
||||
});
|
||||
|
||||
test("timeline: a run of identical cites collapses into a counted chip", () => {
|
||||
const facts = {};
|
||||
for (let i = 1; i <= 3; i++) facts["F" + i] = { ...T.facts.F3, id: "F" + i };
|
||||
const T3 = { ...T, facts, unplaced: [], events: [{ year: 2024, kind: "appeared", codes: [], what_changed: "Seen [F1][F2][F3].", fact_ids: ["F1"], stance_fact_ids: [], cms_summary_fact_ids: [] }] };
|
||||
const t = timeline.render({ header: H, timeline: T3 }, st("/timeline?family=X"));
|
||||
ok(t.includes("×3") && t.includes('data-refs="F1 F2 F3"'));
|
||||
});
|
||||
|
||||
test("timeline: injected strings are escaped", () => {
|
||||
const T4 = { ...T, events: [{ year: 2024, kind: "<b>x", codes: ["<i>"], what_changed: "<script>alert(1)</script>", fact_ids: [], stance_fact_ids: [], cms_summary_fact_ids: [] }], unplaced: [] };
|
||||
const t = timeline.render({ header: H, timeline: T4 }, st("/timeline?family=X"));
|
||||
ok(!t.includes("<script>") && !t.includes("<b>x") && !t.includes("<i>"));
|
||||
ok(t.includes("<script>"));
|
||||
});
|
||||
|
||||
test("timeline: empty", () => {
|
||||
const t = timeline.render({ header: H, timeline: { ...T, events: [], unplaced: [], facts: {} } }, st("/timeline?family=X"));
|
||||
ok(t.includes("No timeline entries"));
|
||||
});
|
||||
|
||||
test("valuation: optional columns only, proposed column hatched, facts, plot", () => {
|
||||
const v = valuation.render({ header: H, valuation: V }, st("/valuation?family=HOME-VISITS"));
|
||||
ok(v.includes("Survey pct") && v.includes("Requested") && !v.includes("Survey intra") && !v.includes("Comparators"));
|
||||
ok(v.includes('class="r num pcol"') && v.includes('data-fact="F4"') && v.includes('data-fact="F5"') && v.includes("<svg"));
|
||||
ok(v.includes("CMS rationale") && !v.includes("PE note") && !v.includes("Surveying societies"));
|
||||
eq(count(v, ">Decision<"), 2, "one Decision column in each of the two groups");
|
||||
ok(v.indexOf("CY2008") < v.indexOf("CY2023"));
|
||||
ok(v.includes("proposed</span>"));
|
||||
ok(v.includes("We are finalizing the RUC-recommended values."));
|
||||
eq(valuation.needs.join(), "header,valuation");
|
||||
});
|
||||
|
||||
test("valuation: a row carries its round index and a source cite", () => {
|
||||
const cite = { kind: "fr_para", label: "CY2023 PFS final X ¶1", url: "https://example.test/x", item_key: "X", p_id: 1, page: 0, locator: "X ¶1" };
|
||||
const rounds = V.rounds.map((r, i) => (i === 0 ? { ...r, rationale: cite } : r));
|
||||
const v = valuation.render({ header: H, valuation: { ...V, rounds } }, st("/valuation?family=HOME-VISITS"));
|
||||
ok(/data-round="0"/.test(v) && /data-round="1"/.test(v));
|
||||
ok(v.includes('href="https://example.test/x"'));
|
||||
});
|
||||
|
||||
test("valuation: the dot plot has a ring for RUC, a circle per final value, tips, tokens", () => {
|
||||
const rounds = [
|
||||
{ ...V.rounds[0], code: "99341", rule_year: 2008, ruc_work_rvu: 1.0, final_work_rvu: 1.2 },
|
||||
{ ...V.rounds[0], code: "99341", rule_year: 2023, ruc_work_rvu: 1.5, final_work_rvu: 1.5 },
|
||||
{ ...V.rounds[1], code: "99343", rule_year: 2023, ruc_work_rvu: 2.0, final_work_rvu: null, rule_kind: "proposed" },
|
||||
];
|
||||
const v = valuation.render({ header: H, valuation: { ...V, rounds, facts: {} } }, st("/valuation?family=HOME-VISITS"));
|
||||
eq(count(v, 'data-tip="'), 5);
|
||||
eq(count(v, "RUC recommendation 1.00") + count(v, "RUC recommendation 1.50") + count(v, "RUC recommendation 2.00"), 3);
|
||||
ok(v.includes("CY2008 final 1.20") && v.includes("CY2023 final 1.50"));
|
||||
ok(v.includes("var(--s-final)") && v.includes("var(--s-ruc)") && !/(?:fill|stroke)="#/.test(v));
|
||||
eq(count(v, "<svg"), 1);
|
||||
});
|
||||
|
||||
test("valuation: no rounds", () => {
|
||||
ok(valuation.render({ header: H, valuation: { ...V, rounds: [], facts: {} } }, st("/valuation?family=X")).includes("No valuation rounds captured"));
|
||||
});
|
||||
|
||||
test("valuation: escapes injected strings", () => {
|
||||
const rounds = [{ ...V.rounds[0], code: "<b>1", rationale_quote: "<script>x</script>" }];
|
||||
const v = valuation.render({ header: H, valuation: { ...V, rounds, facts: {} } }, st("/valuation?family=X"));
|
||||
ok(!v.includes("<script>") && !v.includes("<b>1"));
|
||||
});
|
||||
|
||||
test("valuation: round evidence lists every non-empty field with its cite", () => {
|
||||
const cite = { kind: "fr_para", label: "CY2023 PFS final X ¶1", url: "https://example.test/x", item_key: "X", p_id: 1, page: 0, locator: "X ¶1" };
|
||||
const row = { ...V.rounds[0], final_work_rvu: 1.5, cites: { final_work_rvu: cite } };
|
||||
const e = valuation.roundEvidence(row);
|
||||
ok(e.includes("final work rvu") && e.includes("1.5") && e.includes('href="https://example.test/x"'));
|
||||
ok(e.includes("25th") && !e.includes("survey intra min") && e.includes("data-close"));
|
||||
});
|
||||
Reference in New Issue
Block a user