KatInterview

Automated Diagnosis Coding Engine for Long Clinical Notes

Machine LearningModel answer
HardModel answerMachine Learningnlpextreme-multi-labelml-system-design

Last updated

Design a service that reads long clinical notes, suggests ICD-10 codes with calibrated confidence and cited evidence, and learns from medical coder corrections over time.

Scenario

A health-tech company turns doctor-patient conversations into structured encounter notes. It now wants a service that reads each finished note and proposes diagnosis codes from the ICD-10-CM catalog, so that human medical coders can review suggestions instead of coding from scratch. Suggestions feed billing and risk-adjustment workflows.

What the system must do

  • Accept an unstructured clinical note and return a ranked list of ICD-10-CM codes, each with a calibrated confidence score.
  • For every suggested code, point to the exact text spans in the note that justify it.
  • Expose an API or UI where coders can accept, reject, or manually add codes.
  • Fold coder feedback back into the models over time without degrading what the models already do well.

Constraints and assumptions

  • Label space: roughly 70,000 billable codes. More than 80% of them appear fewer than 10 times in historical training data, and some never appear.
  • Input length: notes commonly run several thousand tokens and can reach tens of thousands, far beyond a 512-token encoder window.
  • Latency: suggestions for a standard note should return within about 2 seconds.
  • Compliance and safety: the system must meet HIPAA requirements, and it must limit hallucinated codes and over-coding (suggesting codes the documentation does not support).

What to cover in your answer

  1. How you process long documents (tokenization, chunking, pooling, long-context architectures).
  2. How you handle the extreme multi-label problem: flat classification versus retrieval against code descriptions versus hierarchical routing.
  3. How you deal with rare and zero-shot codes.
  4. Which evaluation metrics you use across frequent, mid-frequency, and rare codes, and how you measure audit risk.
  5. How the coder feedback loop works: capturing corrections, handling label noise, active learning, and safe model updates.

State your assumptions about traffic and scale, and discuss trade-offs.

Hints

Hint 1

Start with numbers: label count, note length, daily volume, peak QPS, and a latency budget per pipeline stage. Decide early whether precision or recall matters more for billing-sensitive codes.

Hint 2

No single model handles both the head and the tail. Think of a two-stage design: several candidate generators (a classifier for frequent codes, embedding retrieval over code descriptions, hierarchy-based routing) unioned for high recall, followed by a precision-oriented reranker and rule checks.

Hint 3

Make evidence a hard requirement: negated, family-history, or historical mentions should not produce a code. Add a grounding gate that drops any suggestion without a supporting present-tense span.

Hint 4

Evaluate per frequency bucket, not only globally. Micro-F1 is dominated by frequent codes, so also report macro-F1, recall of the candidate stage, and precision on high-risk codes.