Comprendre et références · Comprendre

L'état d'écran dans l'URL

Everything about where you are in a patient chart is in the query string, not in a React useState: the open tab (tab), the item being pointed at (item), each pane's filter (obs, trans, feed, order, archived), and the prescribe drawer (rx, rxFor).

Two consequences, and the second is the point.

A screen becomes citable. "Look at the transmissions on this chart" is a link, not an instruction. So is "prescribe for this problem".

Reading position survives. Writes go through the browser History API, never router.replace: the chart re-reads the whole FHIR warehouse on every server render, so opening a drawer must not trigger one. Open the prescribe drawer from the middle of the anamnesis and the tab, the scroll position and every expanded block are exactly where you left them when you close it.

Because state is in the URL rather than hidden in a component, Back closes the drawer instead of leaving the chart — and Forward reopens it, with its context intact.

Why the prescribe drawer in particular

Prescribing is a small slice of the work: Overhage & McCallie (2020) measured 33 % of EHR time in chart review against 17 % in order entry. The intent to prescribe therefore forms during reading — in front of a problem, in front of a lab result. An entry point that only exists in the Prescriptions tab makes the reader pay for it by losing their place.

So there is one drawer for the whole chart, mounted once, and triggers sit wherever the decision is taken:

  • the chart header, reachable from any tab;
  • the Prescriptions section, where it always was;
  • every treatable problem in the Synthèse tab — and that one says more than "open the form". It resolves against all four lists, so it works on a stay problem or on a hypothesis, not only on the persistent list.

Triggers disappear outside a stay rather than opening a drawer that would refuse to write.

Prescribing from a problem declares the indication

?rx=open&rxFor=<problem id> carries a stable chart id, so the drawer resolves the problem itself — a pasted link opens the same context, no server round-trip needed. The drawer shows what it is prescribing for, and passes it to the dosage picker, where focusIndication moves the matching indication group to the top and opens it.

Nothing is hidden: the other indications keep their order and stay one click away, because prescribing off the declared indication is legitimate — it should just cost a gesture. The ranking already put dossier-matching indications first (see dosage suggestions); this says which one.

The one rough edge

Closing the drawer with Escape or the overlay calls history.back() when the drawer was opened from this page, so the entry we pushed is undone rather than left as a duplicate of the screen. When the drawer came from a pasted URL there is nothing of ours to undo, so the parameter is simply replaced — Back then leaves the chart, which is the honest behaviour for a link that arrived already open.