Skip to content

Risspecct/Medify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

92 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βš•οΈ Medify – AI-Powered Prescription Analyzer

Python 3.11 Framework AI Models License: MIT

An intelligent healthcare assistant that extracts, analyzes, verifies, and summarizes medical prescriptions using AI, machine learning, and cloud services.


πŸš€ Features

πŸ” Prescription Analysis & NER

Extracts text from prescription images using Google Cloud Vision API and identifies key medical entities like medications, dosages, and symptoms using a HuggingFace Biomedical NER model.


πŸ§ͺ AI-Powered Drug Interaction Analysis

  • AI-powered backend using Google Gemini (Generative AI).
  • Detects potential drug–drug interactions with structured risk levels (πŸ”΄ High, 🟑 Moderate, 🟒 Low). Screenshot 2025-08-30 132157

βœ… Prescription Verification

Cross-references prescription details against a curated medical dataset to verify:

  • Symptom Appropriateness: Checks if the medication is a valid treatment for the indicated symptom.
  • Age Safety: Ensures the patient's age is within the recommended range for the drug.
  • Dosage Safety: Validates the prescribed dosage (in mg/kg) against safe limits.

πŸ“Š Personalized Dosage Guidelines

Fetches standardized dosage ranges, intervals, and critical safety notes for a given medication, personalized to the patient’s age.


🌿 Alternatives & Home Remedies

Suggests alternative medications and provides relevant home remedies for common conditions, sourced from an internal knowledge base.


πŸ€– AI-Powered Summary

  • Generates a final patient-friendly report consolidating:

    • Verification results
    • Dosage guidelines
    • Alternative remedies
  • Uses Google Gemini summarization for clear, simple medical summaries.

Screenshot 2025-08-30 132625

πŸ—οΈ Tech Stack

  • Frontend: Streamlit

  • Backend: FastAPI

  • AI Models: HuggingFace Transformers (d4data/biomedical-ner-all), Google Gemini (Generative AI)

  • OCR: Google Cloud Vision API

  • Dataset: dosage.csv + curated alternative medicines dataset

  • Other Libraries:

    • pandas for data processing
    • requests for API calls
    • dotenv for environment management

πŸ“‚ Project Structure

medify/
β”œβ”€β”€ README.md
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ render.yaml
β”œβ”€β”€ .env.example
β”‚
<<<<<<< Updated upstream
β”œβ”€β”€ backend/                # FastAPI backend
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ main.py             # Entry point for backend
β”‚   β”œβ”€β”€ data_processors/    # Data preprocessing utilities
β”‚   β”‚   β”œβ”€β”€ dosage.py
β”‚   β”‚   └── prescription.py
β”‚   β”œβ”€β”€ routers/            # API routes
β”‚   β”‚   β”œβ”€β”€ ai_router.py
β”‚   β”‚   └── drug_info.py
β”‚   └── watson_ai/          # IBM Watson AI integration
β”‚       β”œβ”€β”€ ai_config.py
β”‚       β”œβ”€β”€ interactions.py
β”‚       └── summarizer.py
=======
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py               # FastAPI entrypoint
β”‚   β”œβ”€β”€ routers/              # API endpoints
β”‚   β”œβ”€β”€ data_processors/      # Dosage & prescription validation
β”‚   β”œβ”€β”€ watson_ai/            # Gemini AI integration (Gemini client lives here)
>>>>>>> Stashed changes
β”‚
β”œβ”€β”€ datasets/               # Project datasets
β”‚   β”œβ”€β”€ alt_dataset.py
β”‚   β”œβ”€β”€ dosage.csv
β”‚   └── ner_dataset.py
β”‚
└── frontend/               # Streamlit/Frontend app
    β”œβ”€β”€ Dockerfile
    β”œβ”€β”€ requirements.txt
    β”œβ”€β”€ app.py              # Entry point for frontend
    └── features/           # Core frontend features
        β”œβ”€β”€ ai_services.py
        β”œβ”€β”€ alternative.py
        β”œβ”€β”€ ner.py
        β”œβ”€β”€ ocr.py
        └── verification_client.py

βš™οΈ Setup and Installation

1. Clone the Repository

git clone https://github.com/Risspecct/Medify.git
cd medify

2. Configure Environment Variables

Copy the example environment file and fill in your API keys and configuration details.

cp .env.example .env

Update the .env file with your credentials:

# For backend/main.py
WATSON_API_KEY="your_watson_api_key"
WATSON_PROJECT_ID="your_watson_project_id"
WATSON_URL="your_watson_region_url"
DOSAGE_FILE_PATH="datasets/dosage.csv"

# For frontend/app.py
FAST_API_URL="http://127.0.0.1:8000"
GCP_SERVICE_ACCOUNT_JSON='{...your_gcp_json...}'

3. Run with Docker Compose (Recommended)

This is the easiest way to start both the frontend and backend services.

docker-compose up --build

4. Manual Local Installation (Without Docker)

Click to view manual setup instructions

a. Create a Virtual Environment

python -m venv venv

# On macOS/Linux:
source venv/bin/activate

# On Windows:
venv\Scripts\activate

b. Install Dependencies

Install dependencies for both the frontend and backend:

pip install -r frontend/requirements.txt
pip install -r backend/requirements.txt

4️⃣ Configure Environment

Copy .env.example β†’ .env and set:

GENAI_API_KEY=your_genai_api_key
GEMINI_MODEL_ID=models/gemini-1.5
FAST_API_URL=http://127.0.0.1:8000
DOSAGE_FILE_PATH=datasets/dosage.csv

5️⃣ Run Backend

cd backend
uvicorn main:app --reload

d. Run the Frontend Application

streamlit run frontend/app.py

πŸ“– Usage Flow

  1. Upload Prescription: Start by uploading an image, taking a photo, or pasting text from a prescription.
  2. Extract Entities: OCR + NER to identify medications, symptoms, and dosages.
  3. Check Drug Interactions: AI-powered interaction risk check.
  4. Verify Prescription: Validate symptoms, age safety, and dosage.
  5. Fetch Guidelines: Get standardized dosage info.
  6. Find Alternatives: Explore alternatives & home remedies.
  7. Generate Summary: AI-generated, patient-friendly report.

⚠️ Disclaimer

This tool is for educational and research purposes only. It is not a substitute for professional medical advice. Always consult a qualified doctor before making any healthcare decisions.

About

A smart prescription analysis tool that uses Google Vision and HuggingFace NER to extract medical data. It verifies prescriptions against a custom dataset for dosage and age safety, checks for drug interactions with IBM Watson, and generates patient-friendly summaries. Built with a Streamlit frontend and FastAPI backend.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors