Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📑 Automated Intelligent Medical Intake Processing Pipeline

FastAPI AWS Bedrock uv

An enterprise-grade, document processing microservice built natively with FastAPI and AWS Bedrock Data Automation (BDA). This system automates the ingestion, validation, and structured entity extraction of unstructured Medical Intake Forms (PDFs) stored securely in Amazon S3, converting raw files into validated, schema-compliant JSON payloads.


🏥 Business Use Case & Domain Impact

In healthcare administration, manually reviewing and processing patient intake forms, insurance documents, and medical histories introduces severe operational bottlenecks and human error.

This microservice provides an end-to-end automated solution:

  1. Ingestion: Securely reference medical intake documents deposited in Amazon S3 buckets.
  2. AI-Powered Extraction: Leverages AWS Bedrock Data Automation using highly specific clinical data blueprints.
  3. Structured Outputs: Automatically parses unstructured form text into machine-readable JSON containing patient demographics, insurance identifiers, and historical clinical data, reducing administrative processing cycle times by up to 85%.

🏗️ Clean Architecture Diagram

This project strictly adheres to a 3-Tier Layered Clean Architecture pattern to ensure complete decoupling of network protocols, business workflows, and external infrastructure clients.

graph TD
    Client[HTTP POST /process] --> Route[routes/routed.py]
    Route -->|Validates Pydantic Request| Service[services/service.py]
    Service -->|Workflow Orchestration| ClientLayer[client/client.py]
    ClientLayer -->|boto3 Control Plane| AWS_BDA[AWS Bedrock Blueprints]
    ClientLayer -->|boto3 Runtime Plane| AWS_BDA_Runtime[AWS BDA Execution Engine]
    ClientLayer -->|boto3 Storage Plane| AWS_S3[(Amazon S3 Storage)]
Loading

🛠️ Key Technical Implementations

1. Modern Dependency Management with uv

Utilizes Astral's uv, a fast Python package installer and resolver, replacing standard pip workflows. This ensures deterministic, rapid workspace initialization and sub-second dependency tree compilations for deployment pipelines.

2. High-Performance FastAPI Routing & Pydantic Validation

Leverages FastAPI's asynchronous design and native Pydantic integration to enforce strict request-response data validation contracts. This guarantees that inbound S3 URIs are well-formed before hitting downstream infrastructure, while self-documenting the entire API via interactive OpenAPI/Swagger docs.

3. Idempotent Schema and Blueprint Provisions

The service layer implements conflict recovery when handling underlying cloud assets. If multi-tenant instances trigger concurrent execution requests, the system traps AWS ConflictException signatures and dynamically cascades to lookup fallbacks, guaranteeing zero workflow downtime.


🚀 Getting Started

Prerequisites

  • Python 3.10+
  • uv installed (curl -LsSf https://astral.sh/uv/install.sh | sh or brew install uv)
  • AWS Account with explicit permissions for bedrock-data-automation and s3 operations

Installation & Environment Setup

Clone the repository:

git clone https://github.com/dharaneedharan-v/BDA
cd BDA 

Create a virtual environment and install dependencies using uv:

# Creates .venv and installs requirements dynamically at lightning speed
uv venv
source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
uv pip install -r requirements.txt

Configure your environment variables (.env):

AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_DEFAULT_REGION=us-east-1

Running the Application

Spin up the development server:

uv run main.py

The interactive API documentation will be available at:

http://127.0.0.1:8000/docs

🧪 API Specification

Extract Intake Metadata

Endpoint

POST /api/v1/process

Content-Type

application/json

Request Body

{
  "s3_uri": "s3://your-healthcare-bucket/intakes/patient_intake_04.pdf"
}

Successful Response (200 OK)

{
  "status": "success",
  "data": "{\n  \"patient_name\": \"Jane Doe\",\n  \"date_of_birth\": \"1992-08-24\",\n  \"medical_history\": \"NKA, Hypertension managed with Lisinopril\",\n  \"insurance_provider\": \"Blue Cross Blue Shield\",\n  \"policy_number\": \"XEH98471023\"\n}"
}

FILE STRUCT :

BDA 
├─── src
│   ├─── client
│   │   └─── client_bda.py
│   ├─── migrations
│   │   ├─── factory
│   │   │   └─── factory.py
│   │   ├─── __init__.py
│   │   ├─── create_tables.py
│   │   └─── seeder.py
│   ├─── models
│   │   ├─── __init__.py
│   │   └─── models.py
│   ├─── repositories
│   │   ├─── schema
│   │   │   └─── schema.py
│   │   ├─── __init__.py
│   │   ├─── Database.py
│   │   └─── repository.py
│   ├─── routes
│   │   ├─── __init__.py
│   │   └─── routes.py
│   ├─── services
│   │   ├─── __init__.py
│   │   └─── service.py
│   ├─── utils
│   │   ├─── exceptions
│   │   │   ├─── custom_exception.py
│   │   │   ├─── error_code.py
│   │   │   ├─── error.py
│   │   │   └─── global_exception.py
│   │   ├─── logger
│   │   │   └─── log.py
│   │   ├─── __init__.py
│   │   └─── helpers.py
│   ├─── __init__.py
│   └─── settings.py
├─── .env.local
├─── .gitignore
├─── .python-version
├─── folder.py
├─── main.py
├─── pyproject.toml
├─── README.md
└─── requirements.txt


About

An enterprise-grade, asynchronous document processing microservice built with FastAPI and AWS Bedrock Data Automation (BDA). This system automates the ingestion, validation, and structured entity extraction of unstructured Medical Intake Forms (PDFs) stored in Amazon S3, converting raw files into validated, schema-compliant JSON payloads.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages