In the previous post, we introduced the Context-Aware EMR Enhancer Plugin: type a diagnosis, and the EMR reshapes itself, generating disease-specific fields mapped to FHIR R4, SNOMED CT and LOINC. For a snake-bite or DKA case, that works well.
But real patients rarely arrive as a single diagnosis.
A patient admitted with DKA may also have CKD and an infected foot ulcer. A disease-specific template fits one of those problems and ignores the other two. Worse, some of the most useful structure in a chart is not a disease at all. HbA1c monitoring, a sliding-scale insulin protocol, or a vitals chart attach to any patient, whatever the diagnosis.
This post covers the next step: the Care Trajectory–Oriented Context-Aware EMR.
The Core Concept: Start Blank, Compose as the Patient Evolves
The idea is a clean slate. A clinician opens a new case and sees one thing: a case narrative, a plain-text, FHIR-interoperable box. No forced template, no mandatory fields.
From there, the clinician adds elements or element sets as the care unfolds:
- Vitals
- A basic EMR template (history, examination, plan)
- HbA1c monitoring with a sliding-scale insulin protocol
- A disease context such as snake envenomation or DKA
Disease-specific templates break when a patient has three problems at once. Element sets compose; templates don't.
One Concept: The Element Set
To keep the design simple, everything becomes an element set, with a kind field that says what it is:
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Our existing schema contract already fits this. We only add kind, id, version, and optional requires / suggests links. The earlier disease flow simply becomes: generate an element set from a diagnosis.
The case model
A case is now:
- a narrative (the root), plus
- a list of applied element sets, stored as
case.applied = [{ setId, addedAt }], with entered data incase.values.
Because composition is additive, the FHIR bundle builder keeps working unchanged in spirit: it iterates over all applied sets instead of one.
Separating Disease Context from Care Context
This is the key design insight. A disease context answers "what is wrong?" A care context answers "how are we managing and watching this patient?"
HbA1c monitoring with sliding-scale insulin is a care pathway. It belongs to the patient's journey, not to a diagnosis, so it can be attached to a DKA patient, a post-operative patient, or a steroid-induced hyperglycaemia patient alike. This is what makes the phrase "context can be expanded" a real property of the system rather than a slogan.
Pathway Templates: Bundles of Element Sets
Adding element sets one by one gives flexibility, but for common situations clinicians want a head start. That is what pathway templates are for.
A pathway template is a named, ordered bundle of element sets that can be applied in one click. For example, a "DKA admission pathway" might bundle:
- Vitals
- Basic EMR template
- DKA disease context
- Glucose monitoring with sliding-scale insulin
- HbA1c monitoring
Other pathways could cover a post-operative diabetic patient, an ICU admission, or a snake-bite protocol.
How pathways fit the model
- A pathway is just another registry entry with
kind: "pathway", containing a list of membersetIds (plus optionalrequires/suggestslinks). - Applying a pathway adds each member to
case.appliedindividually, so the case stays a flat, additive composition. Nothing about the FHIR builder or analytics changes. - The application can record which pathway a set came from (for example
fromPathway), so the clinician can see the origin and so analytics can measure pathway usage. - A pathway is a starting point, not a lock-in. After applying it, the clinician can remove sets they don't need or add others, and the narrative box stays the root throughout.
Who defines pathways
Pathways reflect institutional practice, so they are clinician- or institution-defined data, versioned and editable, not generated by an LLM. A clinician can also build a pathway from a case they have already composed ("save this combination as a pathway"). Pathways then become the most-used chips in the sidebar, alongside individual sets, so a whole admission workup is one click away.
Pathway templates are also the clearest example of why the clean slate matters: the starting point is empty, but the shortcuts to a complete structure are always one click away.
Care Needs Time: Repeating Fields and Trajectories
A form captures a snapshot. Care is a trajectory.
HbA1c is measured repeatedly. Sliding-scale insulin is a series of glucose readings, each with a dose given against a band. So the schema gains one important feature: fields can be marked repeat: true, turning a single value into a mini-table of timestamp + value entries.
On top of that sits a trajectory view: repeated values plotted over time as lightweight inline SVG charts, with no heavy charting library. This is the change that turns the tool from a form builder into a care-trajectory tool.
Handling Protocols Safely: The Sliding Scale
Sliding-scale insulin is a protocol, and protocols affect patient safety. Our rules:
- The scale (glucose band → units) is editable data defined by the clinician or institution, not something an LLM invents.
- It is labelled "protocol-defined, clinician-verified."
- Dosing logic stays user-entered. The LLM never suggests doses.
- The "not for clinical use, synthetic data" banner stays prominent.
LLMs are useful for generating context (which fields matter for a condition). They should not be the source of dosing numbers.
One-Click Access: Usage-Ranked Suggestions
Clinicians repeat themselves. The sidebar therefore shows the most-used element sets as one-click chips, with a search box for the rest.
This is personalisation without machine learning: a simple counter in localStorage increments whenever a set is applied, and the top 5 to 8 appear as suggestions. A later extension can rank by diagnosis ("sets most used with this diagnosis"), which is where context-aware and most-used meet.
Narrative to FHIR
The narrative box starts simple: plain text saved into the FHIR bundle as a Composition text section (or DocumentReference). An optional LLM button, "suggest element sets from this narrative", reads the free text and proposes relevant sets, a natural step toward true context-awareness while keeping the clinician in control of what gets applied.
Future Scope, Built In as Data
A contexts registry sits at the top of the UI as a dropdown. Today it offers:
- Disease
- Care pathway
Alongside them are disabled placeholders for future contexts:
- Specialty (e.g. cardiology, nephrology)
- Setting (ICU, OPD, ward)
- Population (paediatric, geriatric, obstetric)
Because contexts are registry data rather than hard-coded logic, adding a new axis later is cheap, and the expansion story is visible in the interface today.
Codes: Verify Before You Bind
Care elements such as HbA1c, glucose, blood pressure and heart rate have well-known LOINC codes. We keep the same rule as before: a code enters the verified table only after it has been looked up and confirmed, never copied from model output.
Why This Matters
Static EMRs force the patient into the form. Disease-specific EMRs improved on that, but still assume one problem at a time. A trajectory-oriented, composable EMR follows the patient instead: blank at the start, enriched as the clinical picture develops, and structured and interoperable throughout.
Project repository: VibeRounds-Clinical-Analytics-App
Live demo: https://viberounds-clinical-analytics-app.onrender.com/ (contact me for access: avi33tbtt@gmail.com)
Disclaimer: this is a prototype using synthetic data and is not for clinical use.
No comments:
Post a Comment