Skip to content

ube09/LabLens-Health-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LabLens Health Insights API

A suite of FastAPI microservices that turn raw blood/lab biomarker reports into AI-generated clinical insights, follow-up questions, recommendations, and test suggestions.

Overview

LabLens Health Insights API is a collection of independently deployable FastAPI services that analyze comprehensive lab reports (100+ biomarkers) and produce structured, patient-friendly clinical output. Each service accepts a lab report (plus optional patient intake profile and follow-up answers) and uses large language models — OpenAI GPT-4o with a Google Gemini fallback — to generate functional-medicine style analysis.

A rule-based and statistical Dynamic Pattern Detector augments the LLM prompts by surfacing biomarker correlations, clinically meaningful ratios (e.g. Triglyceride/HDL, Cholesterol/HDL, BUN/Creatinine, Neutrophil/Lymphocyte), and emerging multi-system patterns before the report is sent to the model.

Features

  • Follow-up Questions API — Generates 5–10 contextual follow-up questions from a lab report, then produces multiple-choice answer options for each question via a two-step LLM process.
  • Clinical Notes API — Produces comprehensive clinical notes split into Concerns & Conditions, Positive Findings, and a Summary, plus per-category summaries across nine health categories (longevity, metabolic, cardiovascular, hormonal, immune, nutritional, organ health, performance, preventive).
  • Recommendations API — Generates personalized diet (include/exclude), activity, and supplement recommendations grounded in the lab data and clinician notes.
  • Follow-up Tests API — Recommends additional lab tests for diagnostic clarification, monitoring, or confirmation of abnormalities.
  • Dynamic Pattern Detector — Statistical correlation, ratio analysis, novel/borderline pattern detection, and an adaptive ML layer (RandomForest / IsolationForest / DBSCAN) with online confidence scoring.
  • Resilient LLM layer — OpenAI primary with automatic Gemini fallback, rate limiting, and robust JSON parsing of model output.
  • Abnormality & borderline detection — Flags high/low markers and biomarkers within 5% of reference-range limits.

Tech Stack

  • Language: Python 3.9
  • API framework: FastAPI + Uvicorn
  • Validation: Pydantic v1
  • LLMs: OpenAI GPT-4o (openai), Google Gemini (REST via requests)
  • ML / analytics: scikit-learn, NumPy
  • Config: python-dotenv
  • Deployment: Render (multi-service render.yaml)

Setup / Run

1. Install dependencies

cd 3api
pip install -r requirements.txt

2. Configure environment

Create a 3api/.env file (see the included placeholders):

OPENAI_API_KEY=your_openai_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here

3. Run a service

Each API runs as its own Uvicorn app:

cd 3api
uvicorn follow_up_api:app        --reload --port 8001
uvicorn clinical_notes_api:app   --reload --port 8003
uvicorn recommendations_api:app  --reload --port 8004
uvicorn follow_up_tests_api:app  --reload --port 8005

Interactive API docs are available at http://localhost:<port>/docs for each service, and a /health endpoint reports LLM availability.

Deployment

render.yaml defines four Render web services (one per API), each built with build.sh and supplied OPENAI_API_KEY / GEMINI_API_KEY as environment variables.

Author

Usama Bin Ejaz — AI/ML Engineer | Data Scientist | Founder, UBE Labs

About

FastAPI microservices that turn 100+ biomarker lab reports into LLM-generated clinical insights and recommendations

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors