Skip to content

freedomofchoice1991/medical_device_recommender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Medical Device Recommender

Python FastAPI HTML CSS JavaScript jQuery Last Commit PRs Welcome openFDA API

This project is a FastAPI-based medical device recommender that suggests alternative medical devices based on their FDA classification.

Features

✅ Search for a medical device by Product Code

✅ Find strong matches (same classification code)

✅ Find potential alternatives (same medical specialty)

✅ View grouped classification data

Export results to CSV or PDF

Web-based frontend using HTML, CSS, and jQuery

API testing with Pytest

Continuous Deployment using GitHub Actions


1️⃣ Installation & Setup

Step 1: Clone the Repository

   git clone https://github.com/YOUR_USERNAME/medical-device-recommender.git
   cd medical-device-recommender

Step 2: Set Up a Virtual Environment

   python3 -m venv venv
   source venv/bin/activate  # macOS/Linux
   venv\Scripts\activate  # Windows

Step 3: Install Dependencies

   pip install -r requirements.txt

Step 4: Run the FastAPI Server

   uvicorn app.main:app --reload

✅ The API will now be running at: http://127.0.0.1:8000

✅ API Docs available at: http://127.0.0.1:8000/docs


2️⃣ Fetching FDA Data & Storing in SQLite

Run the following script to fetch medical device classifications and store them in SQLite:

   python app/database.py

This will:

  • Create the SQLite database (medical_devices.db)
  • Fetch classification data from the FDA API
  • Store it in the database

3️⃣ Running Tests with Pytest

This project includes unit tests using pytest. Run tests with:

   pytest tests/
   # or for verbose version
   python -m pytest -v 

Tests include:

  • Checking if the API is reachable
  • Verifying device recommendations
  • Handling edge cases (invalid product codes)

4️⃣ Using the Web Interface

Launch the Web UI

  1. Open your browser
  2. Go to: http://127.0.0.1:8000/static/index.html
  3. Enter a Product Code (e.g., KNY)
  4. Click "Search" to see recommendations
  5. Click "Load Grouped Data" to view classification groups
  6. Export results as CSV or PDF

5️⃣ CI/CD Pipeline with GitHub Actions

This project includes a CI/CD pipeline using GitHub Actions.

Pipeline Steps:

  1. Runs Tests on every push to main
  2. Deploys to the server after successful tests

Setting Up GitHub Secrets

Go to GitHub RepositorySettingsSecrets and VariablesActionsNew Repository Secret

Add the following secrets:

  • SSH_PRIVATE_KEY → Your private SSH key for deployment
  • SERVER_IP → Your server’s IP address
  • SERVER_USER → Your server’s username

Trigger Deployment

Push your code to GitHub:

   git add .
   git commit -m "New feature added"
   git push origin main

This will:

  1. Run tests automatically
  2. Deploy the app if tests pass

6️⃣ Deploying the FastAPI App to a Server

Step 1: SSH into Your Server

   ssh user@your-server-ip

Step 2: Clone the Repository on the Server

   git clone https://github.com/YOUR_USERNAME/medical-device-recommender.git
   cd medical-device-recommender

Step 3: Set Up Virtual Environment

   python3 -m venv venv
   source venv/bin/activate
   pip install -r requirements.txt

Step 4: Run the FastAPI Server

    uvicorn app.main:app --host 0.0.0.0 --port 8000 &

✅ Your API is now live on your server!


7️⃣ Running FastAPI in the Background (Optional)

If you want the API to run even after you close SSH, use pm2:

   pip install pm2
   pm2 start "uvicorn app.main:app --host 0.0.0.0 --port 8000" --name fastapi
   pm2 save

✅ Now, your API auto-restarts if the server reboots!


🌟 Summary

✅ Clone Repo → Install Dependencies → Run FastAPI 🚀

✅ Fetch Data → Use Web UI → Export Reports 📊

✅ Run Tests → Deploy Automatically with GitHub Actions 🔄

✅ Deploy to Server → Keep Running in Background 💡


💡 Contribution & Support

  • Found a bug? Open an issue on GitHub!
  • Want to contribute? Fork & submit a PR

📌 Made with ❤️ using FastAPI & openFDA API

About

A system for suggesting alternative medical devices based on FDA classification api.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors