VN COSTA ANALYTICS

project

SimpleCPT — Automated Clinical Coding

Automated ICD-10 coding suggestion system for Brazilian electronic health records, built with pre-trained Transformer networks and a rank-based learning framework.

Health AI / NLPResearchNLPDeep LearningClinical NLPICD-10

SimpleCPT turns unstructured clinical notes into ranked ICD-10 suggestions, using transformer models and ranking objectives to reduce manual coding friction in Brazilian healthcare.

Executive summary

Clinical coding with ranking models

SimpleCPT is a deep-learning system that suggests ICD-10 diagnostic codes from unstructured clinical text in Brazilian electronic health records (EHRs). Developed as a bachelor's thesis in partnership with Pickcells and a private hospital in Brazil, the project demonstrated meaningful potential to reduce manual coding workload and improve coding consistency — and directly led to a Junior Data Scientist role.

Problem

Why ICD-10 coding was hard

Manual ICD-10 coding is a bottleneck in Brazilian healthcare administration. Clinicians and medical coders must map free-text clinical notes to a standardized ontology of thousands of codes, a process that is:

  • Time-consuming: a single hospitalization record can require reviewing dozens of code candidates.
  • Error-prone: inconsistencies in code assignment affect billing, epidemiological reporting, and clinical audits.
  • Understaffed: Brazil faces a shortage of qualified medical coders, especially in smaller hospitals.

Existing rule-based or keyword-matching approaches lack the semantic flexibility to handle the variability of clinical Portuguese.

Approach

Three design choices that mattered

Language models

Fine-tuned multilingual and Portuguese-specific Transformer models captured the semantics of clinical text.

Ranking objective

A pairwise ranking loss scaled better than flat classification over 10,000+ ICD codes.

Real data

A private-hospital EHR dataset provided realistic, noisy clinical-Portuguese text for evaluation.

Architecture

Model flow

Clinical Note (text)
                      │
                      ▼
    Tokenizer (WordPiece / BPE)
                      │
                      ▼
    Transformer Encoder (fine-tuned BERT)
                      │
                      ▼
    Pooled Representation [CLS]
                      │
                      ▼
    Ranking Head (pairwise loss)
                      │
                      ▼
    Ranked ICD-10 Candidates → Top-K suggestions

The ranking head uses a margin-based pairwise loss: for each (note, positive_code, negative_code) triple, the model is trained to score the correct code higher. This makes the learning signal richer than standard cross-entropy over the full label space.

Key results

What the model achieved

Better ranking metrics

Statistically significant improvement over keyword-based baselines on Precision@K and NDCG@K.

Strong top-3 coverage

The top-3 suggestions covered the ground-truth code in the majority of test cases.

Clinical plausibility

The partner hospital team confirmed the suggestions were medically plausible even when not exact.

Limitations

Open questions and constraints

  • The dataset is proprietary and cannot be released publicly.
  • Performance degrades on rare codes, a known challenge for any classification or ranking system in this domain.
  • The system is a decision-support tool, not a replacement for human coders; regulatory and liability considerations keep a human in the loop.
  • Further work on Brazilian clinical NLP benchmarks and multilabel variants of the ranking objective remains open.

Impact

This project was the direct bridge between academic research and professional practice: the results convinced Pickcells to hire Vinícius as a Junior Data Scientist, where the NLP/LLM and clinical AI expertise developed here was immediately applied to new products (biosignal extraction from PDF lab reports, computer vision for cancer detection).

The full thesis is available upon request. Code and data are under institutional NDA.