Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions src/components/clinical-dashboard/differentials-home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -872,20 +872,12 @@ function SourceStatusBanner({
}

/**
* The two cards read different lists on purpose. Highest urgency is a safety net
* over the whole result set, so a result-type or urgency lens must not hide an
* emergent differential from it. Check next describes the list the clinician is
* actually reading, so it follows the lens.
* Both cards read the filtered result set, so the rail always describes the list
* the clinician is actually looking at rather than a wider one they cannot see.
* A lens that hides every emergent differential therefore empties the urgency
* card too — the applied-filter chips above the results say why it is gone.
*/
function InterpretationRail({
best,
results,
filteredResults,
}: {
best: DifferentialResult;
results: DifferentialResult[];
filteredResults: DifferentialResult[];
}) {
function InterpretationRail({ best, results }: { best: DifferentialResult; results: DifferentialResult[] }) {
return (
<aside className="hidden min-w-0 gap-3 lg:grid" aria-label="Differential interpretation">
<h2 className="flex items-center gap-2 text-sm font-extrabold uppercase tracking-kicker text-[color:var(--text-muted)]">
Expand All @@ -894,7 +886,7 @@ function InterpretationRail({
</h2>
{best.kind === "presentation" ? <LikelyPresentationCard lead={best} /> : null}
<UrgencyCard results={results} />
<NextStepsCard results={filteredResults} />
<NextStepsCard results={results} />
</aside>
);
}
Expand Down Expand Up @@ -1434,7 +1426,7 @@ function SearchResultsView({
)}
</section>

<InterpretationRail best={best} results={results} filteredResults={relevanceResults} />
<InterpretationRail best={best} results={relevanceResults} />
</div>
</div>
)}
Expand Down
19 changes: 12 additions & 7 deletions tests/differentials-interpretation-rail.dom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { getDifferentialRecord, getPresentationWorkflow } from "@/lib/differenti
* rail that must stay readable at a glance.
* 2. "Check next" aggregates the investigations the ranked differentials name,
* most-shared first, and never invents one of its own.
* 3. Both cards read the filtered result set, so the rail never describes a
* wider list than the one on screen.
*/

const catalogState = vi.hoisted(() => ({
Expand Down Expand Up @@ -141,27 +143,30 @@ describe("differentials interpretation rail", () => {
expect(within(card).getByText("ECG / QT assessment")).toBeVisible();
});

it("follows the urgency lens for check next while highest urgency keeps its safety-net rows", async () => {
it("makes both rail cards follow the urgency lens", async () => {
renderWith(["lithium-adverse-effects-toxicity", "acute-dystonia"]);

const card = await screen.findByTestId("differentials-shared-next-steps");
expect(within(card).getByText("Thyroid function tests")).toBeVisible();
expect(within(card).getByText("ECG / QT assessment")).toBeVisible();
expect(screen.getByTestId("differentials-highest-urgency")).toBeVisible();

// Narrowing to High leaves only the urgent differential, so the rail must
// describe that list alone: the emergent row goes, and so does the
// investigation only the emergent differential named.
await act(async () => {
screen.getByTestId("differential-filter-trigger-phone").click();
});
await act(async () => {
screen.getByRole("radio", { name: "Emergent (1)" }).click();
screen.getByRole("radio", { name: "High (1)" }).click();
});
await act(async () => {
screen.getByTestId("differential-filter-panel-done").click();
});

// Thyroid function tests belonged to the filtered-out urgent differential.
expect(within(card).queryByText("Thyroid function tests")).not.toBeInTheDocument();
expect(within(card).getByText("ECG / QT assessment")).toBeVisible();
// The emergent safety net is not a lens result and stays put.
expect(screen.getByTestId("differentials-highest-urgency")).toBeVisible();
expect(screen.queryByTestId("differentials-highest-urgency")).not.toBeInTheDocument();
expect(within(card).getByText("Thyroid function tests")).toBeVisible();
expect(within(card).queryByText("ECG / QT assessment")).not.toBeInTheDocument();
});

it("hides the check-next card when no ranked differential names an investigation", async () => {
Expand Down
Loading