Extracting from medical records
Coded clinical data — diagnoses, medications, labs and vitals — where the coding system is the hard part and the handling obligations are real.
A clinical document is not free text with some numbers in it. Almost every field worth extracting is governed by a published coding system with a structure you can check: ICD-10-CM says which character carries laterality, the NDC has three segments and two incompatible digit lengths, LOINC identifies a lab result by six axes rather than by its printed name, and a prescriber’s NPI carries a check digit that tells you the transcription is arithmetically sound. The interesting work is not getting a model to emit JSON. It is knowing what the emitted value is supposed to look like, and what it means when it does not.
These pages are written for an organisation that already holds the records lawfully and needs the data out of them. Every example is synthetic. Where a handling obligation genuinely attaches — minimum necessary on the field list, redaction before a page reaches somebody else’s model, a business associate agreement covering the provider that sees it — it is named at the point it attaches, and nowhere else. None of this is clinical advice: the subject is parsing a document, not deciding what to do about its contents.
Extracting Diagnosis Codes From a Medical Record
How to tell a printed ICD-10-CM code from a diagnosis that exists only as a sentence, and why deriving the second one is a coding decision rather than an extraction problem.
10 min read
Extracting Medication Lists From a Medical Record
Why one chart contains several medication lists that disagree on purpose, and how RxNorm and the NDC's three segments give you something stable to normalise onto.
11 min read
Extracting Vital Signs From a Clinical Note
Vitals appear as a narrative sentence and as a flowsheet column in the same note, the units are usually implied rather than printed, and only one of the two unit errors is caught by a range check.
9 min read
Extracting Allergies and Adverse Reactions From a Medical Record
The only field in the chart where the valuable answer is usually a negative, and where an empty array and an explicit statement of none must never collapse into the same value.
10 min read
Extracting Reference Ranges and Flags From a Lab Report
A reference range belongs to the run that produced the result, not to the analyte, and a single misaligned row shifts every range down the column onto the wrong test.
10 min read
Extracting Analyte Results From a Multi-Page Lab Panel
A worked method for carrying the patient header, the specimen and the column definitions from page one onto every continuation page of a lab panel.
11 min read
Extracting Critical-Value Flags From a Lab Report
The flag is an assertion the performing laboratory made under its own critical-value policy, which is why it needs its own field and why you must transcribe it rather than recompute it.
9 min read
Extracting Drug Name, Dosage and Sig From a Prescription
The sig is a compositional grammar in abbreviated Latin, several of whose tokens are on published error-prone lists because humans misread them, and a lookup table beats a model that thinks it knows them.
11 min read
Extracting Refill Counts and Prescriber Details From a Prescription
The prescriber's NPI and DEA number both carry check digits, so these two fields can be validated arithmetically rather than merely extracted — and only one of them has a public registry.
10 min read
Extracting Findings and Impressions From a Radiology Report
Findings and Impression are different speech acts — observation versus conclusion — and merging them destroys the hedging and the incidental findings that the sections exist to keep apart.
10 min read
Extracting Measurements From a Radiology Report
Measurement text is a small grammar with an implied unit at the end, an axis convention that differs for lymph nodes, and a prior value in the same sentence that a naive parser grabs.
10 min read
Extracting Eligibility Criteria From a Clinical Trial Protocol
Criteria are numbered, cross-referencing and amended, so the extraction problem is atomicity plus stable identity — a criterion is a predicate with a comparator, a unit and a time window, not a sentence.
10 min read
Extracting Dosing Schedules From a Clinical Trial Protocol
The schedule of activities is a matrix of relative days inside repeating cycles with visit windows, and expanding it into a calendar has an off-by-one that no schema check will catch.
10 min read
Other topics
- LLM fundamentals & architecture
- Tokens, tokenization & context windows
- Prompt engineering
- Reasoning models & test-time compute
- Multimodal AI: vision, audio, video
- RAG & retrieval
- Embeddings & vector search
- AI agents & tool use
- Structured output & function calling
- Fine-tuning & post-training
- Local inference errors, string by string
- Running local models day to day
- Testing code that calls an LLM
- Snapshot and property testing for model output
- Regression suites for prompts
- Eval gates in CI
- Flaky tests against a model
- Determinism and the cost of testing
- Contract and streaming tests
- Testing tool calls and retrieval
- Inference, serving & latency
- Rolling out a prompt change
- Testing AI systems in practice
- Forecasting a time series
- Machine learning on tabular data
- Geospatial data and models
- Understanding audio that is not speech
- Understanding video
- Core computer vision tasks
- Machine learning on graphs
- Point clouds and 3D
- Evaluation, benchmarks & LLM-as-judge
- Sensor and IoT data
- Logs and event streams
- Models over biological sequences
- Machine learning on molecules
- Embedding and searching code
- Extracting invoices and purchase orders
- Receipts, statements and tax forms
- Insurance policies and contracts
- Deeds, court filings and patents
- Observability & LLMOps
- CVs, certificates and identity documents
- Shipping, customs and technical documents
- Meetings, email, chat and filled-in forms
- Building an extraction pipeline
- Business, property and inspection documents
- Contract clauses and insurance claims
- Regulated and compliance documents
- Consumer, travel and closing documents
- Mapping one chat API onto another
- SDK and framework migrations
- Hallucination & failure modes
- Re-embedding and model deprecation
- Cutting over between providers
- Parity gaps, shims and legacy endpoints
- Moving between model versions
- Migrating vector stores and caches
- Mapping capabilities and parameters
- Migrating pipelines and agents
- Contracts, runbooks and rollback
- Auditing a codebase before a cutover
- Compliance and fine-tune migration
- LLM cost engineering
- Routing, cost tracking and multi-tenancy
- What a migration does to your prompts
- AI security & prompt injection
- Privacy, compliance & data residency
- AI governance, policy & society
- Building reliable AI applications
- AI hardware, GPUs & compute
- Open-weight models & local inference
- AI for developers & coding agents
- AI in industry: vertical playbooks
- AGI, superintelligence, alignment & the long future
- Machine learning foundations
- NLP fundamentals & classical tasks
- Data engineering for AI
- Synthetic data & dataset curation
- AI product design & UX
- Search, ranking & recommendation
- Enterprise adoption & change management
- AI careers, skills & teams
- Reading AI research
- AI in science & discovery
- Robotics & embodied AI
- AI economics, markets & business models
- AI myths, hype & media literacy
- Context engineering
- Shipping AI features: patterns & anti-patterns
- Build it: end-to-end AI tutorials
- Python for AI: hands-on recipes
- TypeScript, React and the web
- Frameworks and SDKs
- Errors and troubleshooting
- AI facts, numbers and statistics
- The history of AI
- The maths behind AI
- Architectures beyond the transformer
- Reinforcement learning
- Diffusion and generative media
- Speech, audio and voice engineering
- Benchmarks, one at a time
- AI search visibility
- Infrastructure and operations
- Databases and storage for AI
- Knowledge graphs and structured knowledge
- Classical ML in production
- Regulation, jurisdiction by jurisdiction
- Prompt recipes and pattern library
- AI for people who do not write code
- Writing, media and creative work
- Edge and on-device AI
- Interpretability and model internals
- Field notes
- OpenAI model behaviour
- Claude model behaviour
- Gemini model behaviour
- Llama model behaviour
- Mistral model behaviour
- Qwen model behaviour
- DeepSeek model behaviour
- Cohere model behaviour
- Grok model behaviour
- Small model behaviour
- Hybrid model architectures
- Token cost by language and script
- Transliteration, romanization and script handling
- Locale-correct output
- Multilingual generation quality
- Multilingual pipelines
- The EU AI Act, article by article
- AI under the GDPR and EU data law
- US AI regulation, state and sector
- International AI governance and standards
- AI litigation and enforcement
- Running AI workloads on AWS
- Running AI workloads on Google Cloud
- Running AI workloads on Azure
- AI at the edge: Workers, Vercel and Netlify
- Serving models on Kubernetes
- Operating AI infrastructure
- Quantization formats and what they cost
- llama.cpp, flag by flag
- Ollama and the desktop local-model runtimes
- Local models on Apple Silicon
- Hardware for local inference
- Running speech and embedding models locally
- Model files, adapters and conversion
- VRAM arithmetic for local models