A tiny Rails app that uploads a text-based medical PDF, extracts text, calls an LLM to auto-summarize key facts (diagnoses, medications, procedures, dates, providers), lets an analyst edit the results inline, and exports a CSV.
Stack
⚠️ Demo-only / HIPAA disclaimer This repository is not production-ready. It does not meet HIPAA compliance requirements. Do not upload real PHI. It sends text chunks to a third-party LLM API. Logs and error traces may include data. A production version would require a BAA with the LLM vendor, strict logging/retention controls, encryption at rest/transport, access controls, audit logging, and a security review.
Models
Document(id, title, status, text, redact:boolean)
Finding(id, document_id, category, label, value, date, confidence:float)
Categories returned by the LLM
diagnoses
, medications (name,dose)
, procedures (text,date)
, key_dates (label,date)
, providers (name,type)
DocumentsController
(new/create/show/analyze/export), FindingsController#update
Pdf::ExtractText
— text extraction via pdf-reader
Text::Chunker
— 3–5k char chunksLlm::MedicalFactsExtractor
— OpenAI Chat Completions → strict JSONFindings::Merge
— dedupe by normalized keysCsv::Exporter
— single CSV across categories# install Ruby gems and JS deps
bundle install
yarn install
# DB
bin/rails db:create db:migrate
# .env
cat > .env <<'ENVVARS'
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
ENVVARS
# build assets
yarn build && yarn build:css
# run dev (Rails + Tailwind + esbuild)
bin/dev