Decades of stacking poorly optimized administrative mandates onto aging, rigid database architectures have created an environment where physicians spend more time feeding the machine than treating human beings. At the heart of this crisis is the legacy Electronic Health Record (EHR) system, and its most exhausting symptom, dropdown fatigue.
Legacy EHRs were originally built as billing and compliance software, not clinical tools. Because their core database structures date back to the late 20th century, adding new regulatory or insurance requirements means adding more fields, checkboxes, and nested menus.
Final_Final_v2)
Problems: Almost no concepts integrated solved by Software Engineering (SWE) in the EHR
system itself, even though it is coded by those same developers. Can't we model a clincial workflow
similar to SWE concepts?As of early 2025, real-world implementation of LLMs in clinical settings remains limited, though documented applications include outpatient communication, mental health support, inbox message drafting, and clinical data extraction, with documented improvements in operational efficiency, user satisfaction, and reduced workload. LLMs are increasingly applied across various domains such as disease screening, diagnostic assistance, and health management, playing a key role in advancing intelligent healthcare.
Foundation models are deliberately constrained on medical knowledge via RLHF to avoid liability and medical malpractice. This creates a strange inversion: the model can't reliably generate medical reasoning, so instead it extracts patterns from internet text in its weights (which may be dubious, incomplete, or contradictory), or acts as a fuzzy pattern-matching tool given RAG context rather than a knowledge representation system.
Having LLMs performing medical diagnosis and triage is a logical error of itself. The policy engine in the backend, consisting of decision trees, EHR systems, Bayesian networks, and other algorithms, are already compliant through years of auditing and testing. The LLM should be the observer of inputs, and the decision should be made by those classical AI systems itself.
We are using probabilistic machines to populate deterministic containers (EHR structured fields).
It feels generative because of the writing involved. The fact that it looks generative is because a human clinician synthesizes these in prose, but that prose is serving a deterministic function. SOAP is functionally a data collection task. A series of observations, which is fed to a function, that then generates an output: the assessment and plan.
This is the crux of the "Medical Debt" problem. By storing clinical intelligence as unstructured "blobs" (the finalized SOAP note), the healthcare industry has effectively turned its most valuable data into read-only text files that are invisible to computation. One that relies on copy and paste to generate a new document, and to "erase" for changes. If it is stored like a generative document, no wonder why the industry believes the task seems like a generative problem that LLMs theoretically can solve.
The medical industry is currently caught in a "generative-first" loop, treating clinical documentation as a creative task that requires complex LLMs to interpret unstructured "blobs" of prose. This approach is fundamentally flawed because it prioritizes the appearance of intelligence over the utility of the data. By relying on probabilistic models to handle clinical shorthand and terminology, healthcare systems are introducing unnecessary latency, liability, and semantic noise, effectively transforming valuable clinical observations into "read-only" text files that are invisible to downstream computation.
The Fine-Tuning, RAG, and LangChain Trap: One spend millions to get a model to output a code with 98% accuracy. It still fails 2% of the time. One now needs a human to audit every single output to catch that 2%. One needs to red-team, develop complex documentation, and design complex LangChain workflows to prove to an auditor that it works most of the time.
LLMs are used convert shorthand, descriptions, acronymns, "slang", to specific code and normalization. That is a massive misallocation of compute and risk. The industry is throwing a LLMs at a problem that is fundamentally a one-to-many mapping problem. A doctor's vocabulary is not infinite. A physician's shorthand for "shortness of breath", whether it is "SOB," "dyspnea," "air hunger," "the usual air problem", or "can't catch breath", is a closed set of variables. A human is likely not going to have ten different ways to describe a symptom, but small, closed set of phrases. Instead, of an LLM "guessing" on the specific hospital code, the LLM should extract the symptom literally, with a local dictionary to resolve the term. When a doctor uses a pre-defined shorthand mapped to a specific code, they are making a deliberate, verifiable declaration.
A specific hospital already knows:
By using an LLM to do the "thinking" for the normalization, we are creating a layer of hidden assumptions. If the LLM misinterprets the "slang," it propagates an incorrect code into the EHR without the clinician ever realizing the translation was wrong.
When the local agent inputs the text literally, a deterministic script identifies the shorthand, references the personal/hospital dictionary, and writes a normalized object to the database.
The Rendering (The "Reverse Dictionary"): When another clinician opens the record, they don't read a "blob" written by the first doctor. Instead, the UI renders that structured state according to the viewer's preference, converting the normalized term using a reverse dictionary lookup.
Once one isolates the "Term" (the CDSL declaration), the subsequent arguments within it become a positional or keyword-based schema rather than a prose-parsing challenge. An inner delimiter such as a semicolon within the pipes is only needed because the "slang" is inherently high-entropy that needs to be normalized first. Once isolated, the rest becomes predicatable. The attributes (severity, duration, trajectory, frequency, context)are all low-information-density and do not conflict with each other
Semantic Predictability: Because 4/10 (integer/integer), 2h (quantity/unit), and ex (categorical shorthand) are structurally distinct, the parser can disambiguate them even if the order changes. A standard regex-based or lexer-based parser (like those used in compiler design) would handle this with near-zero latency.
By implementing the CDSL/Parser, one is effectively pre-indexing the medical record. Even if one never builds the rest of the Medical Registry, or a fancy "IDE for Medicine," CDSL will have solved the biggest problem in healthcare AI: the data is no longer invisible to computation, even if it still remains in a blob.
As a hypothetical prototype, the event ledger mimics Git with some differences.
| Operation | Description |
|---|---|
add |
Add a new event (state), such as an observation. |
update |
Update an existing (parent) event, or combine/update several parent events into one. The
payload,
with a new state_id will be the updated resulting payload, not a diff. The
parent
state_id from one or more events will be supressed.
|
remove |
"Removes" an event, by suppressing a given state_id. |
branch |
Create a new branch from a given state without affecting the main trees. Good for hypothesis and "what if" testing without having to target the main branch (assessment and planning). |
archive |
Mark the branch as archived/failed/closed. The event node starting where
archived cannot be merged.
|
merge |
Merges data from other branches. Unlike SWE/Git merge conflict resolution, it is additive (adding new data), and there is no "editing"/"updating". For example, one can merge from several automated device branches, or merge a final hypothesis branch into the main timeline. |
In code, branches are often alternative realities (e.g., trying a new feature that might get discarded). In medicine, branches are parallel realities happening to the same human body simultaneously.
In a distributed or branched EHR system, conflicts don't usually happen because two doctors edited the exact same sentence. They happen because two clinicians made clinically incompatible decisions in parallel.
x = 5. Developer
B changes Line
10 to x = 10. The system flags a conflict and asks the human to choose one.The "common node" you mentioned is the patient's baseline state. The branches are the specialized care pathways that must eventually reconcile back into a single, cohesive treatment plan.
Assessment and Planning (the "A&P" of a SOAP note) is where the logic gets incredibly complicated. In current, centralized EHRs, one avoids branching by forcing strict serialization. Only one person can truly edit the active order profile at a time, or changes are committed instantly to a single source of truth. If a specialist orders something harmful, the system relies on real-time asynchronous alerts.
If one moves to a asynchronous "branch and merge" workflow, the Assessment and Planning phase would require a Clinical Code Review:
A human (usually the attending physician or hospitalist) has to act as the Maintainer, reviewing the pull request of both specialists to ensure the combined logic doesn't harm the patient.
In software, a bad merge breaks a server. In medicine, a bad merge from conflicting assessments and plans breaks a person.
Medical "unit tests" cannot be "wait and see." They have to be predictive and preventative. When merging two clinical branches, the automated testing suite has to run several layers of validation:
| Test Type | Software Equivalent | Clinical Application |
|---|---|---|
| Syntax Check | Compiling the code | Ensuring dosages, routes (IV vs. Oral), and frequencies are valid (running external algorithms and checks). |
| Integration Testing | Checking if Modules A & B play nice | Running Contraindication Engines (Drug-Drug, Drug-Disease, and Drug-Allergy interactions). |
| Regression Testing | Ensuring old features didn't break | Checking if new orders conflict with the patient's chronic problem list or past adverse reactions. |
Even if the automated clinical "unit tests" pass (i.e., no known drug interactions), medicine has variables code doesn't: biology.
If a bad merge happens, the "runtime errors" are physiological changes (e.g., a sudden drop
in
kidney
function). Therefore, a medical merge tool would actually need to auto-generate Monitoring
Orders, essentially creating dynamic assertions like:
assert patient.potassium < 5.0.
A document renderer should process the immutable ledger backward because the present holds the ability to interpret, mask, or validate the past. By walking backward, the engine only evaluates what is structurally relevant right now, allowing it to short-circuit the moment it finds the most recent materialized truth.
When a clinician requests a SOAP document render, the engine targets the Tip Node of
the active
branch. It initializes an empty Render Workspace W and a
Suppression
Blacklist
S.
As the walker steps backward through parent states, it uses the operations as deterministic compiler instructions:
[Root: Baseline] ---> [add: Symptom X] ---> [update: Symptom X (v2)] ---> [remove (Tombstone)]
^
| BACKWARD WALK
| (Evaluates latest first)
|
[FINAL RENDER] <--- [Workspace Filter Layer]
update (Instant Masking)Because update operation contains the fully materialized state rather than
a patch delta,
the backward walk treats it as an absolute data boundary:
[A: add (null parents)] ---> [U1: update (parent: A)] ---> [U2: update (parent: U1)]
: : |
:.........................:............................|
| |
|<============= RECUSIVELY BLACKLISTS ALL =============|
[ledger-node-03]
|
|---> Reads parent: ["ledger-node-02"] -> Adds to Blacklist
|
|---> Reads grandparent: ["ledger-node-01"] -> Adds to Blacklist
|
|---> Reads great-grandparent: null -> STOP!
W.
mutation_parent_ids to the Suppression Blacklist
B. It must continuously read the parents' mutation_parent_ids th all
the way
back, but it stops automatically the exact moment it hits an
add node.
remove (The Tombstone Guard)remove node tells the walker that a conceptual entity has been
deleted.state_id into the Blacklist B.merge (Lineage Forking & Rejection
Isolation)When the walk hits a merge node, it reads the explicit ledger state to navigate parallel
paths:
merge_resolution.rejected_state_ids
and throws them
into the Blacklist B. Whole segments of parallel history are instantly muted.accepted_state_ids concurrently. If Branch Alpha has automated vitals arrays
(add) and
Branch Beta has a clinical entry (add), the walker seamlessly glues their lineages
back together at
their common ancestor node.
The compilation engine evaluates each ledger node type on its reverse path to the root parent:
| Encountered Node Type | Impact on Render Workspace W |
Impact on Blacklist B |
Walker Routing Action |
|---|---|---|---|
update |
If fields are empty, write full payload; lock fields. | Append mutation_parent_ids to blacklist, recursively target parent
mutation_ids.
|
Continue tracking down parent chain. |
remove |
Ignore payload entirely. | Append targeted state_id to blacklist. |
Continue tracking down parent chain. |
add |
Append payload metrics to timelines/ranges if not masked. | Maintain state. | Continue tracking down parent chain. |
merge |
Maintain state. | Append rejected_state_ids to blacklist. |
Fork walker into parallel ancestor tracks. |
archive |
Blocked at Commit Layer | Maintain state. | Stop path search; this branch cannot be traversed or merged. For other branches, it was never connected. |
| Any Blacklisted ID | Ignore entirely. | Maintain state. | Skip node execution and step to its parent. |
The CDSL doesn't just store the bare string terminology; it stores a tokenized object that links to a unique canonical code based on dictionary. Possible use cases exist even if the rest of the Medical Registry is not built (such as the Event Version Control).
Clinical Freedom and Separation of ConcernsFor example, a skin and an eye doctor can type into the same document with the same acronym, "PT", yet it resolves to two different canonical codes because of their personal dictionaries. Similarly, CDSL does not care about the language either; a Japanese, German, French, and American doctor can all write to the same exact document without any friction.
Localization: The "Rendered View" as a Translation LayerSince the final SOAP output is just a rendered view of CDSL, a document with CDSL syntax can be rendered in any language, such as Chinese or Arabic even if the original document was multilingual or in a different language.
Predictive CDSL Autocomplete: Hierarchical Bayesian Networks for Contextual LikelihoodIf a clinician inputs | SOB; 4/10; 2h | and misses
the "trajectory," a Bayesian network doesn't have to "think." It
looks at historical observations for that patient or condition. If 95% of "SOB"
entries with
"4/10 severity" and "2h
duration" are "progressive," the algorithm suggests "progressive"
as the most likely value.
Instead of an alert saying "You forgot to document X," the system merely suggests
the
most likely value for X in a faint, muted font (e.g.,
| SOB; 4/10; 2h; [progressive?] |).
A simple decision tree can act as a gatekeeper for missing data, such as smoking without packs per year.
As the registry collects even a few hundred commits, the autocompletion engine gets smarter. It learns that this specific clinician almost always means "stable" when they omit a trajectory, and that specific clinic almost always means "oral" for that specific medication.
With billions of records of structured CDSL transitions, a Bayesian model wouldn't just be "guessing"; it would be mapping the specific "Clinical DNA" of that encounter, along with years of historical data.
Cmd +
Enter or Alt + Pipe) while the cursor is inside a highlighted segment to
instantly "wrap" the
text into the |...|
delimiters.Whether the data is generated by an LLM interpreting a voice dictation, a firmware update from a continuous glucose monitor (CGM), or a manual entry by a nurse, the backend policy engine treats them all as atomic mutations to the patient's state.
Because the infrastructure mandates the schema, it doesn't care if the
vitals_measurement
came
from a smart thermometer or a
manual keyboard entry. The validation layer (e.g., checking if the heart rate is physiologically
possible) runs the same
function regardless of the input method.
The "Authoring" Flattening: The LLM stops trying to be the "author" of medical truth and becomes just one of many clients submitting JSON payloads to the registry. The authority remains with the Policy Engine that evaluates the state change.
"Breaking changes" in a rigid clinical schema should be rare, but they are inevitable as medical science evolves. Because of the "Universal Minimal" strategy, the transactional shape (the add, update, remove operations) never changes. Only the payload inside the observation object changes, and that can be tracked and versioned.
None of the described schemas dictate that a doctor or hospital has to replace existing workflows or legacy systems. For example, if the clinician prefers to write prose, the LLM just extracts that prose into structured data objects. The data objects are for machines to read, not for humans to read.
Instead of forcing a full migration, one treats the legacy blob as a read-only archive and the Medical Registry as the write-ahead log for all future interactions, with backward compatibility until it is phased out.
One may argue for the current hype for LLMs and AI agents is that everyone is running, legacy, 50-year old systems no one wants to touch. So the patchwork is to use an LLM to do the doctor's work faster without fixing the underlying system. However, these arguments for the reasons why this Medical Registry should be implemented.
Because the JSON shape is fixed, one can use coding libraries, or LLMs to generate hundreds of thousands of test cases. The schema bounds the output space strictly.
The coding model's job is not to make medical decisions, but just to translate the JSON shape to the legacy backend, and to augment test data.
This "Medical Registry" framework effectively transforms the medical record from a stagnant document repository into a versioned, transactional database. By treating the patient record as a series of cryptographically committed transactions, we unlock capabilities that are impossible in the current "blob-based" environment.
assessment?"
A well-designed translation layer provided by the SWEs can make once tedious clerical work into a frictionless experience.
Instead of relying on a nurse, doctor, or LLM to remember that a "yearly exam" requires a BP check (X), a BMI calculation (Y), and a vaccine review (Z), the Policy Engine runs a deterministic check against the ledger state whenever a session is committed.
personal_dictionary file. This
file contains mappings for his/her personal shorthand (e.g., preferred "slang" for chronic
conditions).
hospital_registry_map
that ties
all official clinical
terms to FHIR/SNOMED codes.
The schema is the protocol, not an LLM artifact. Other input sources may include:
Developing nations often struggle with proprietary, siloed EHR systems that are difficult to interoperate and expensive to maintain. By implementing a standardized registry (where the data format is the "law," not the software), they could force vendors to compete on UI/UX performance rather than data captivity. Any software would simply be a "skin" over the shared registry, allowing the nation to switch or upgrade tools without the nightmare of data migration.
Decentralized Intelligence, Centralized Integrity: In regions with a critical scarcity of physicians, the ability for the backend to run deterministic compliance checks is a force multiplier. If the government hosts the "Registry" and the Policy Engine, a nurse or even a community health worker can interact with an AI that is mathematically constrained to safe, locally-compliant pathways. They don't need the model to be a "genius"; they just need it to correctly populate the schema.
With CDSL and normalized data, one can train classical AI systems such that it becomes more effective than using LLMs and RAG. This may lead to the resurgence of MYCIN, DXplain, better Bayesian networks, and other algorithms.
Currently, EHR vendors hold power because they own the "schema" of the clinical record in forms of lossy blobs. If a hospital wants to switch vendors, they face a massive data migration problem, often losing the semantic nuance of the data in the process.
urn:global-standards:medical: protocol) is
standardized,
the EHR becomes
nothing more than a UI/UX skin over the state registry.Several parts of the document mimics Git in behavior. The idea of an event-driven git-like system for medicine, extends far beyond just LLMs. Git's core insight (2005) was: treat code as an immutable, versioned, branching ledger of atomic changes. That solved problems that seemed intractable in centralized version control:
In the current system, if a physician wants to test a hypothesis (e.g., "What if we switch this
patient's medication to
Drug X?"), they have to rely on their memory or a separate mental workspace. In a "Event
Version
Control"
world, one performs a
git checkout -b hypothesis-trial.
observation mutations (git add).
git merge the branch if the trial is successful, or close/archive the
branch
if it fails (no deletion here for traceability and auditability).git checkout main) record remains pristine
and
audit-compliant throughout.Current SOAP notes are a singluar, monolithic "commit" that contain too much information to be
parsed
cleanly. By
using the Medical Registry
schema, every entry is an atomic mutation_batch.
reason
field in the JSON schema).git checkout the patient's record to a
specific timestamp in the past to see exactly what clinical information was available at that
moment, a critical
capability for legal defense and error analysis.
In software, branching saves developer time, replay helps with debugging, and history helps with code review. Had medicine adopted even parts of the Medical Registry, or anything related to Git 15 years ago; if the medical record had been built as a Git-like distributed state machine rather than a CMS (Content Management System) for "blobs," the entire trajectory of patient safety and clinical innovation would be unrecognizable today.
| Era | Software Engineering (Git/IDE) | Hypothetical Medical Registry |
|---|---|---|
| 2005–2008 | Git created; GitHub launched. | Medical Registry Protocol Released: Open-source schema for patient state defined. |
| 2009–2012 | IDEs adopt Git; language plugins grow. | First "Clinical IDE" Emerges: Specialized interfaces (e.g., for Cardiology) that read/write to the registry. |
| 2013–2016 | The "App Store" boom (Mobile/IDE). | Registry App Store: Launch of specialized "Clinical Extensions" for billing, triage, or pediatrics. |
| 2017–Present | CI/CD, AI Integration, Copilot. | Fully Automated Policy Gate: AI agents and sensor-driven data "committing" to the patient state. |
The SOAP note was a brilliant 1960s solution to a 19th-century problem. How to force organization onto chaotic, long-form narrative paper records such that:
However, it was to solve limitations at that time, where powerful computer system did not exist yet, and writing paper is faster. For the Medical Registry Protocol to work, one needs a computer system that can parse text, store them in a database, have version control, and be able to render the structured data such that it automatically render documents such as SOAP.
A team of SWEs could have theoretically built the Medical Registry's event-driven format (not the backend yet). The FDA could've mandated it at that time, and therefore, developed a singluar protocol first for data structure format and storage.
/obs SOB 4/10
Other technology existed at the time, including OCR, which could've could scan a handwritten note from a Smart Card or SOAP document, identify keywords, and map them to the registry schema. Rather than baking the limitations of paper into the software, the registry could have rerendered the document in the preferred format with the dictionary.
By establishing a simple grammar for the clinician (e.g.,
| [TERM]; [ATTRIBUTES] |), offload the
"thinking" from the UI and move it to a high-speed, background Parser, while allowing the
clincian
to keep its preferred terms.
Given normalized structured data, millions of normalized training examples, these systems would've lasted a lot longer:
Given the amounts of structured data now ranging in the billions, a fully autonomous CDSS system would have emerged that is entirely auditable as a white-box, requiring minimal human input except when the system is unconfident. At this point, speech-to-text is not reliable, so a human doctor must be able to write or type the text into the system.
ASR allows patient speech to be reliably converted to text, which is translated by a statistical machine translator if needed. Then, it is passed to a CRF to surface the relevant tokens for the CDSS, if it is confident. A human does not even need to be in the loop at this point except for exceptions, or the system itself can ask clarification questions.
Because the Registry treats every medical and developmental observation as an immutable, hash-linked transaction, the "dataset" for a child is a rich time-series of markers. One can imagine the ethical concerns if the anonymized data was public to those that do not need it.
The moment one moves from treating a child to simulating their life path, one enters dangerous ethical territory.
In our "dangerous fork", a reality where the Registry is not just a storage system, but a continuously feeds an executing and autonomous simulation engine used for questionable purposes. When the cost of compute is low enough and the data is granular enough, the system stops reacting to the patient and starts proactively branching their life. In a system with unlimited compute, one can "optimize" for "lower risk" or "lower cost".