fix(lex): valuation columns ordered with per-table empties dropped; CMS summary once; one cite per line; comments events open their summary (S1-P12)
Some checks failed
CI / lint (push) Successful in 1m31s
CI / notebooks-smoke (push) Successful in 3m10s
Deploy / changes (push) Successful in 17s
CI / test (push) Failing after 7m25s
Deploy / report (push) Has been cancelled
Deploy / notebooks (push) Has been cancelled
Deploy / zotero (push) Has been cancelled
Deploy / docs (push) Has been cancelled
Deploy / api (push) Has been cancelled
Deploy / bcda (push) Has been cancelled
Deploy / llm (push) Has been cancelled
Deploy / mc (push) Has been cancelled
Infra CI / docs (push) Has been cancelled
Infra CI / api (push) Has been cancelled
Infra CI / bcda (push) Has been cancelled
Infra CI / llm (push) Has been cancelled
Infra CI / mc (push) Has been cancelled
Infra CI / notebooks (push) Has started running
Infra CI / zotero (push) Has been cancelled
Some checks failed
CI / lint (push) Successful in 1m31s
CI / notebooks-smoke (push) Successful in 3m10s
Deploy / changes (push) Successful in 17s
CI / test (push) Failing after 7m25s
Deploy / report (push) Has been cancelled
Deploy / notebooks (push) Has been cancelled
Deploy / zotero (push) Has been cancelled
Deploy / docs (push) Has been cancelled
Deploy / api (push) Has been cancelled
Deploy / bcda (push) Has been cancelled
Deploy / llm (push) Has been cancelled
Deploy / mc (push) Has been cancelled
Infra CI / docs (push) Has been cancelled
Infra CI / api (push) Has been cancelled
Infra CI / bcda (push) Has been cancelled
Infra CI / llm (push) Has been cancelled
Infra CI / mc (push) Has been cancelled
Infra CI / notebooks (push) Has started running
Infra CI / zotero (push) Has been cancelled
This commit is contained in:
@@ -75,20 +75,37 @@ function groupChip(cite, refs) {
|
||||
return `<span class="cite group${cite.kind === "cpt_book" ? " book" : ""}" role="button" tabindex="0" data-refs="${esc(refs.join(" "))}" title="${refs.length} facts cite this source">${text} ×${refs.length}</span>`;
|
||||
}
|
||||
|
||||
/** Text with [F#] tags turned into the facts' cites. Consecutive tags that
|
||||
/** Text with [F#] tags turned into the facts' cites. Each distinct source
|
||||
* appears once per line, at its first position (a later repeat is dropped;
|
||||
* its fact still joins that chip's drawer list). Consecutive tags that
|
||||
* cite the same source collapse into one chip with a count (S1-P11); a
|
||||
* repeat of one tag counts once. An unknown tag, or a fact with no cite,
|
||||
* stays as text and ends a run. */
|
||||
export function tagged(text, facts) {
|
||||
if (!text) return "";
|
||||
const lookup = (id) => (facts && Object.prototype.hasOwnProperty.call(facts, id) ? facts[id] : null);
|
||||
return esc(text).replace(/(?:\[F\d+\])+/g, (run) => {
|
||||
const src = esc(text);
|
||||
// every fact id per source across the line: a source's first chip counts
|
||||
// and lists them all, so the drawer still reaches each fact
|
||||
const all = new Map();
|
||||
for (const [, id] of src.matchAll(/\[(F\d+)\]/g)) {
|
||||
const f = lookup(id);
|
||||
if (!f || !f.cite) continue;
|
||||
const k = citeKey(f.cite);
|
||||
if (!all.has(k)) all.set(k, []);
|
||||
if (!all.get(k).includes(id)) all.get(k).push(id);
|
||||
}
|
||||
const seen = new Set();
|
||||
return src.replace(/(?:\[F\d+\])+/g, (run) => {
|
||||
const out = [];
|
||||
let cur = null;
|
||||
let chips = 0;
|
||||
const flush = () => {
|
||||
// a space between chips, so a long run of distinct cites can wrap
|
||||
if (cur) out.push((chips++ ? " " : "") + citeHtml(cur.cite, { ref: cur.ids[0], refs: cur.ids }));
|
||||
if (cur && !seen.has(citeKey(cur.cite))) {
|
||||
seen.add(citeKey(cur.cite));
|
||||
// a space between chips, so a long run of distinct cites can wrap
|
||||
out.push((chips++ ? " " : "") + citeHtml(cur.cite, { ref: cur.ids[0], refs: all.get(citeKey(cur.cite)) }));
|
||||
}
|
||||
cur = null;
|
||||
};
|
||||
for (const [, id] of run.matchAll(/\[(F\d+)\]/g)) {
|
||||
|
||||
@@ -35,8 +35,13 @@ const list = (ids, facts) => (ids || []).map((id) => facts[id]).filter(Boolean).
|
||||
|
||||
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>`;
|
||||
const open = (e.fact_ids || [])[0] || (e.cms_summary_fact_ids || [])[0] || "";
|
||||
// a line that is CMS's own summary text is shown once, under its label
|
||||
const flat = (t) => String(t || "").replace(/\s*\[F\d+\]/g, "").replace(/\s+/g, " ").trim();
|
||||
const line = flat(e.what_changed);
|
||||
const dup = !telehealth && (e.cms_summary_fact_ids || []).some((id) => facts[id] && flat(facts[id].text) && line.includes(flat(facts[id].text)));
|
||||
let h = `<div class="tl-item" data-kind="${esc(filterKey(e.kind))}" data-open="${esc(open)}">`;
|
||||
h += `<div class="top"><span class="type ${kindClass(e.kind)}">${esc(kindLabel(e.kind))}</span>${dup ? "" : `<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>`;
|
||||
@@ -70,12 +75,13 @@ export function render(data, state) {
|
||||
<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);
|
||||
const years = Array.from(new Set(events.map((e) => e.year))).sort((a, b) => (a ?? 1e9) - (b ?? 1e9));
|
||||
const yr = (y) => (y == null ? "Undated" : "CY" + esc(y));
|
||||
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 class="tl-year"><h4>${yr(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) {
|
||||
|
||||
@@ -44,14 +44,22 @@ function cell(r, key, kind) {
|
||||
}
|
||||
|
||||
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>`;
|
||||
const any = (key) => rows.some(({ r }) => filled(r[key]));
|
||||
const opt = columns.filter(any);
|
||||
const showFinal = any("final_work_rvu");
|
||||
const showDecision = any("decision");
|
||||
let h = `<div class="tbl-wrap"><table class="tbl"><thead><tr><th>Code</th><th class="r">RUC rec.</th><th class="r pcol">CMS proposed <span class="pill prop">proposed</span></th>`;
|
||||
if (showFinal) h += `<th class="r">CMS final</th>`;
|
||||
if (showDecision) h += `<th>Decision</th>`;
|
||||
h += opt.map((c) => `<th${OPTIONAL[c][1] === "text" || OPTIONAL[c][1] === "why" ? "" : ' class="r"'}>${esc(OPTIONAL[c][0])}</th>`).join("");
|
||||
h += `<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>`;
|
||||
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><td class="r num pcol">${esc(n2(r.proposed_work_rvu))}</td>`;
|
||||
if (showFinal) h += `<td class="r num">${esc(n2(r.final_work_rvu))}</td>`;
|
||||
if (showDecision) h += `<td class="small">${esc(r.decision || "—")}</td>`;
|
||||
h += opt.map((c) => cell(r, c, OPTIONAL[c][1])).join("");
|
||||
h += `<td class="nowrap">${citeHtml(sourceCite(r))}</td></tr>`;
|
||||
}
|
||||
return h + `</tbody></table></div>`;
|
||||
}
|
||||
@@ -59,13 +67,14 @@ function groupTable(rows, columns, deleted) {
|
||||
/** 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 internal = (k) => k === "p_id" || k.endsWith("_p_id");
|
||||
const dl = Object.entries(r)
|
||||
.filter(([k, v]) => !skip.has(k) && filled(v))
|
||||
.filter(([k, v]) => !skip.has(k) && !internal(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>
|
||||
<h3>${esc(r.code)} · ${r.rule_year == null ? "undated" : "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>`;
|
||||
}
|
||||
@@ -125,13 +134,14 @@ export function render(data) {
|
||||
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));
|
||||
const yr = (y) => (y == null ? "Undated" : "CY" + esc(y));
|
||||
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)}`;
|
||||
h += `<h3>${yr(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 (yf.length) h += `<div class="sec"><span class="eyebrow">Round and practice-expense facts${y == null ? "" : ", " + yr(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;
|
||||
|
||||
@@ -176,21 +176,30 @@ test("tagged collapses a run of identical cites into one counted chip (S1-P11)",
|
||||
ok(!h.includes("<a ") && !h.includes("[F"));
|
||||
});
|
||||
|
||||
test("tagged keeps distinct cites in order and a different cite ends a run", () => {
|
||||
test("one source appears once per line, at its first position; the chip lists every fact (S1-P12)", () => {
|
||||
const fs = { F1: mk("F1", "A"), F2: mk("F2", "A"), F3: mk("F3", "B"), F4: mk("F4", "A"), F5: mk("F5", "A") };
|
||||
const h = tagged("x [F1][F2][F3][F4][F5].", fs);
|
||||
eq(count(h, "<a "), 1);
|
||||
eq(count(h, "group"), 2);
|
||||
ok(h.indexOf("A ×2") < h.indexOf(">B<") && h.indexOf(">B<") < h.lastIndexOf("A ×2"));
|
||||
eq(count(h, "A ×2"), 2);
|
||||
eq(count(h, "<a "), 1, "B is the only plain link");
|
||||
eq(count(h, "group"), 1);
|
||||
eq(count(h, "A ×4"), 1);
|
||||
ok(h.includes('data-refs="F1 F2 F4 F5"') && h.indexOf("A ×4") < h.indexOf(">B<"));
|
||||
});
|
||||
|
||||
test("a source repeated later in the line is dropped, its fact kept in the first chip", () => {
|
||||
const fs = { F1: mk("F1", "A"), F2: mk("F2", "B"), F3: mk("F3", "A") };
|
||||
const h = tagged("one [F1] two [F2] three [F3].", fs);
|
||||
eq(count(h, 'data-refs="F1 F3"'), 1);
|
||||
eq(count(h, ">B<"), 1);
|
||||
ok(h.includes("A ×2") && h.endsWith("three ."));
|
||||
});
|
||||
|
||||
test("an uncited tag in a run stays text and ends the run", () => {
|
||||
const fs = { F1: mk("F1", "A"), F2: { id: "F2", kind: "event", text: "n" }, F3: mk("F3", "A") };
|
||||
const h = tagged("[F1][F2][F3]", fs);
|
||||
ok(h.includes("[F2]"));
|
||||
eq(count(h, "group"), 0);
|
||||
eq(count(h, "<a "), 2);
|
||||
eq(count(h, "<a "), 0);
|
||||
eq(count(h, 'data-refs="F1 F3"'), 1);
|
||||
eq(count(h, "A ×2"), 1);
|
||||
});
|
||||
|
||||
test("groupHtml lists the collapsed facts, each opening its own evidence", () => {
|
||||
|
||||
@@ -115,3 +115,46 @@ test("valuation: round evidence lists every non-empty field with its cite", () =
|
||||
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"));
|
||||
});
|
||||
|
||||
// ---- S1-P12 fix round ----
|
||||
const heads = (html) => [...html.matchAll(/<table[\s\S]*?<\/thead>/g)].map((m) => [...m[0].matchAll(/<th[^>]*>([\s\S]*?)<\/th>/g)].map((x) => x[1].replace(/<[^>]+>/g, "").trim()));
|
||||
|
||||
test("valuation: order Code, RUC, proposed, final, Decision, optional, Source; empty columns dropped per table", () => {
|
||||
const base = { ...V.rounds[0], ruc_percentile: "", survey_total_min: null, requested_work_rvu: null, rationale_quote: "", pe_note: "" };
|
||||
const rounds = [
|
||||
{ ...base, code: "99341", rule_year: 2008, rule_kind: "final", item_key: "A", ruc_work_rvu: 1, proposed_work_rvu: 1, final_work_rvu: 1.2, decision: "refine", requested_work_rvu: 2.85 },
|
||||
{ ...base, code: "99341", rule_year: 2023, rule_kind: "proposed", item_key: "B", ruc_work_rvu: 1, proposed_work_rvu: 1, final_work_rvu: null, decision: "", ruc_percentile: "25th", pe_note: "supplies" },
|
||||
];
|
||||
const v = valuation.render({ header: H, valuation: { ...V, rounds, columns: ["ruc_percentile", "requested_work_rvu", "pe_note"], facts: {} } }, st("/valuation?family=X"));
|
||||
const [a, b] = heads(v);
|
||||
eq(a.join("|"), "Code|RUC rec.|CMS proposed proposed|CMS final|Decision|Requested|Source");
|
||||
eq(b.join("|"), "Code|RUC rec.|CMS proposed proposed|Survey pct.|PE note|Source");
|
||||
ok(!a.includes("Survey pct.") && !b.includes("Requested"));
|
||||
});
|
||||
|
||||
test("valuation: evidence shows cites, not internal ids; a null year does not break the page", () => {
|
||||
const e = valuation.roundEvidence({ ...V.rounds[0], p_id: 5, final_p_id: 7, rationale_p_id: 0, ruc_p_id: 0, final_work_rvu: 1.5 });
|
||||
ok(!/p id/.test(e) && e.includes("final work rvu"));
|
||||
const rounds = [{ ...V.rounds[0], rule_year: null }, { ...V.rounds[1], rule_year: 2008 }];
|
||||
const v = valuation.render({ header: H, valuation: { ...V, rounds, facts: {} } }, st("/valuation?family=X"));
|
||||
ok(v.indexOf("CY2008") < v.indexOf("Undated"));
|
||||
const T2 = { ...T, events: [{ year: null, kind: "origin", codes: [], what_changed: "u", fact_ids: [], stance_fact_ids: [], cms_summary_fact_ids: [] }, { year: 2020, kind: "origin", codes: [], what_changed: "d", fact_ids: [], stance_fact_ids: [], cms_summary_fact_ids: [] }], unplaced: [] };
|
||||
const t = timeline.render({ header: H, timeline: T2 }, st("/timeline?family=X"));
|
||||
ok(t.indexOf("CY2020") < t.indexOf("Undated"));
|
||||
});
|
||||
|
||||
test("timeline: a comments line that is CMS's summary text shows once, under its label; click and drawer work without fact_ids", () => {
|
||||
const F = { ...T.facts.F6, id: "F12", text: "In the CY2005 final rule, CMS summarized: \"x\"." };
|
||||
const T5 = { ...T, facts: { F12: F }, unplaced: [], events: [{ year: 2005, kind: "comments", codes: [], what_changed: "In the CY2005 final rule, CMS summarized: \"x\". [F12][F12]", fact_ids: [], stance_fact_ids: [], cms_summary_fact_ids: ["F12"] }] };
|
||||
const t = timeline.render({ header: H, timeline: T5 }, st("/timeline?family=X"));
|
||||
eq(count(t, "CMS summarized"), 1);
|
||||
ok(t.includes("CMS's summary") && t.includes('data-open="F12"') && t.includes('data-fact="F12"'));
|
||||
eq(count(t, 'class="cite'), 1, "one chip for the one source");
|
||||
});
|
||||
|
||||
test("timeline: a repeated tag in a line gives one chip", () => {
|
||||
const T6 = { ...T, unplaced: [], events: [{ year: 2005, kind: "appeared", codes: [], what_changed: "a [F3] b [F4] c [F3] d [F3]", fact_ids: ["F3"], stance_fact_ids: [], cms_summary_fact_ids: [] }] };
|
||||
const t = timeline.render({ header: H, timeline: T6 }, st("/timeline?family=X"));
|
||||
const line = t.slice(t.indexOf('class="sum"'), t.indexOf("<details"));
|
||||
eq(count(line, "CY2023 PFS final PETM225D ¶1672"), 1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user