Sadum1's picture
Upload folder using huggingface_hub
6624dea verified
Raw History Blame Contribute Delete
3.11 kB
import type { Protocol, RobSummaryItem, SearchResultItem } from "../types";
import { useRobReference } from "./useRobReference";
import "./review-fixes.css";
interface RobHeatMapProps {
protocol: Protocol;
summary: RobSummaryItem[];
papersById: Map<string, SearchResultItem>;
}
/** Studies × OHAT questions, colour-coded, with each study's tier. */
export function RobHeatMap({ summary, papersById }: RobHeatMapProps) {
const { reference } = useRobReference();
if (!reference) return null;
const finals = summary.filter((i) => i.final);
const open = summary.length - finals.length;
const symbol = (v: string) => reference.ratings.find((r) => r.value === v)?.symbol ?? v;
return (
<div className="rob-heatmap">
{finals.length === 0 ? (
<p className="form-hint">No final risk-of-bias assessments yet.</p>
) : (
<div className="rob-heatmap-scroll">
<table>
<thead>
<tr>
<th>Study</th>
<th>Outcome</th>
{reference.questions.map((q) => (
<th key={q.number} title={q.text}>
Q{q.number}
</th>
))}
<th>Tier</th>
</tr>
</thead>
<tbody>
{finals.map((item) => {
const paper = papersById.get(item.paper_id);
const answers = new Map(item.final!.answers.map((a) => [a.question, a.rating]));
return (
<tr key={`${item.paper_id}-${item.outcome}`}>
<td className="rob-study">{paper ? `${paper.authors.split(",")[0]}${paper.year ? ` (${paper.year})` : ""}` : item.paper_id}</td>
<td>{item.outcome}</td>
{reference.questions.map((q) => {
const rating = answers.get(q.number);
const key = item.key_questions.includes(q.number);
return (
<td
key={q.number}
className={`rob-cell ${rating ? `rob-${rating}` : "rob-na"}${key ? " rob-key" : ""}`}
title={rating ? `${q.label}: ${symbol(rating)}${key ? " (key)" : ""}` : "Not applicable to this design"}
>
{rating ? symbol(rating) : "—"}
</td>
);
})}
<td className={`rob-tier rob-tier-${item.tier ?? "none"}`}>{item.tier ? `Tier ${item.tier}` : "—"}</td>
</tr>
);
})}
</tbody>
</table>
</div>
)}
<p className="form-hint">
++ definitely low · + probably low · − probably high · NR not reported (probably high) · −− definitely high ·
bordered cells are key questions · — = question doesn't apply to the design.
{open > 0 && ` ${open} assessment${open === 1 ? "" : "s"} still awaiting a second reviewer or resolution.`}
</p>
</div>
);
}