{"id":51650218,"url":"https://github.com/cocoindex-io/patient-intake-extraction","last_synced_at":"2026-07-14T03:01:47.651Z","repository":{"id":283747513,"uuid":"952297044","full_name":"cocoindex-io/patient-intake-extraction","owner":"cocoindex-io","description":"Patient Intake Form Extraction using llm ","archived":false,"fork":false,"pushed_at":"2026-06-11T05:59:35.000Z","size":665,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-21T06:24:51.660Z","etag":null,"topics":["data-indexing","etl","healthcare","llm","machine-learning","ocr","rag"],"latest_commit_sha":null,"homepage":"https://cocoindex.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cocoindex-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-21T03:47:21.000Z","updated_at":"2026-06-11T05:59:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"41c4dd16-6148-4fcc-87b6-c528644f77ac","html_url":"https://github.com/cocoindex-io/patient-intake-extraction","commit_stats":null,"previous_names":["cocoindex-io/patient-intake-extraction"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cocoindex-io/patient-intake-extraction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoindex-io%2Fpatient-intake-extraction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoindex-io%2Fpatient-intake-extraction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoindex-io%2Fpatient-intake-extraction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoindex-io%2Fpatient-intake-extraction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cocoindex-io","download_url":"https://codeload.github.com/cocoindex-io/patient-intake-extraction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cocoindex-io%2Fpatient-intake-extraction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35443979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-14T02:00:06.603Z","response_time":114,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-indexing","etl","healthcare","llm","machine-learning","ocr","rag"],"created_at":"2026-07-14T03:01:46.734Z","updated_at":"2026-07-14T03:01:47.637Z","avatar_url":"https://github.com/cocoindex-io.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Structured Data From Patient Intake Forms](https://github.com/user-attachments/assets/1f6afb69-d26d-4a08-8774-13982d6aec1e)\n\n# 🥥 Patient Intake Extraction with CocoIndex\n\nExtract structured data from patient intake forms (PDF) using [CocoIndex](https://cocoindex.io) v1 and [DSPy](https://github.com/stanfordnlp/dspy) with a Gemini vision model. Each form is rendered to images, passed to the LLM, and written out as a validated JSON record — incrementally, so re-runs only reprocess forms that actually changed.\n\n❤️ Please give [CocoIndex on GitHub](https://github.com/cocoindex-io/cocoindex) a star ⭐ to support us. A warm coconut hug 🥥🤗. [![GitHub](https://img.shields.io/github/stars/cocoindex-io/cocoindex?color=5B5BD6)](https://github.com/cocoindex-io/cocoindex)\n\n## What it does\n\n```\ndata/patient_forms/*.pdf  ──▶  pages → images  ──▶  DSPy + Gemini  ──▶  output_patients/*.json\n```\n\n- **Pydantic models** (`models.py`) define the target schema — type-safe, validated `Patient` records.\n- **DSPy module** (`main.py`) extracts directly from page images via `ChainOfThought` with vision — no intermediate text/markdown step.\n- **CocoIndex v1 app** (`main.py`) processes each form as an independent component and writes JSON, recomputing only what changed.\n\n## Prerequisites\n\n- **Python 3.11+**\n- A **Gemini API key** — no Postgres, no Docker.\n\n## Run\n\n**1. Install dependencies** (sample PDFs are already in `data/patient_forms/`):\n\n```bash\npip install -e .\n```\n\n**2. Set your API key** — copy the template and add your Gemini key:\n\n```bash\ncp .env.example .env\n# then edit .env and set GEMINI_API_KEY=your_api_key_here\n```\n\nThe template also sets `COCOINDEX_DB=./cocoindex.db` (the local engine state path), which is required.\n\n**3. Extract:**\n\n```bash\ncocoindex update main.py\n```\n\nThis reads each PDF in `data/patient_forms/`, extracts the patient record, and writes JSON to `output_patients/`:\n\n```bash\nls output_patients/\n# Patient_Intake_Form_David_Artificial.json\n# Patient_Intake_Form_Emily_Artificial.json\n# Patient_Intake_Form_Joe_Artificial.json\n# Patient_Intake_From_Jane_Artificial.json\n```\n\n## Incremental processing\n\nRe-running never redoes work that's already done — `process_patient_form` is memoized by file content:\n\n```bash\ncocoindex update main.py        # ⚡ unchanged forms are skipped\n```\n\nAdd, replace, or remove a PDF and re-run — only the affected form is reprocessed, and a removed PDF's JSON is cleaned up automatically.\n\n## How it works\n\nThe pipeline lives in [`main.py`](./main.py):\n\n- `extract_patient` — a `@coco.fn` that renders each PDF page to an image (pymupdf) and runs a DSPy `ChainOfThought` vision module to return a validated `Patient` ([`models.py`](./models.py)).\n- `process_patient_form` — a memoized `@coco.fn` that reads a file, extracts, and declares the JSON output.\n- `app_main` — walks `data/patient_forms/` and mounts one component per PDF.\n\nEach form is processed independently and memoized by content, so re-runs only touch what changed.\n\n---\n\nThe sample forms under `data/` are purely artificial and for testing only.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcocoindex-io%2Fpatient-intake-extraction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcocoindex-io%2Fpatient-intake-extraction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcocoindex-io%2Fpatient-intake-extraction/lists"}