← All projects
Project — 07 / 09OCR / ML · 2025

Medical Data Extraction

A Python OCR pipeline that reads medical PDFs and pulls out structured data automatically.

PythonPyMuPDFOpenCVpytesseractBeautifulSoup4
Illustrative cover image for the Medical Data Extraction case study

01The problem

Medical documents arrived as PDFs and scans, and staff were typing the details in by hand — slow and error-prone.

02How it works

01

Load documents

PyMuPDF extracts text and page images from PDFs.

02

Clean images

OpenCV pre-processes scanned pages to improve readability.

03

OCR

pytesseract reads text from the cleaned images.

04

Parse

Text — and HTML sources via BeautifulSoup4 — is mapped into structured fields.

05

Output

Structured records are ready for storage, replacing manual typing.

03What I built

  • Extracted text and page images from PDFs with PyMuPDF.
  • Cleaned and pre-processed scanned pages with OpenCV to improve OCR quality.
  • Ran OCR with pytesseract and parsed HTML sources with BeautifulSoup4.
  • Mapped the extracted text into structured fields ready for storage.

04Key features

Digital & scanned PDFs

Handles both text PDFs and image scans.

Image pre-processing

OpenCV clean-up before OCR.

HTML parsing

BeautifulSoup4 for web sources.

Structured output

Clean fields instead of raw text.

05Challenges & solutions

ChallengeScanned pages give poor OCR results.
SolutionPre-processed images with OpenCV before OCR, reaching 95% extraction accuracy.
ChallengeData arrives from mixed sources — PDFs and HTML.
SolutionCombined PyMuPDF and BeautifulSoup4 in one pipeline.

06Impact

95%Extraction accuracy
80%Less manual data-entry time