PJCT01

Health Risk API (PJCT01) A FastAPI-powered health risk assessment API that accepts patient vitals and lifestyle data, then returns a computed health risk analysis. Built with Python, SQLAlchemy, Pydantic, and PostgreSQL (Neon). Deployed on Render. Live Docs: https://pjct01.onrender.com/docs — Table of Contents Overview Tech Stack Setup & Installation Environment Variables API Endpoints — Overview PJCT01 exposes a single intelligent endpoint that accepts a patient’s medical profile — age, sex, BMI inputs, vitals, smoking habits, and existing conditions — and returns a structured health risk response. Designed as a backend service to be consumed by health-facing frontends or other APIs. — Tech Stack Layer Technology Framework FastAPI ORM SQLAlchemy Validation Pydantic Database PostgreSQL (Neon) Runtime Python 3.11+ Deployment Render — Setup & Installation

  1. Clone the repository
    git clone https://github.com/techbyFEMI/pjct01.git
    cd pjct01
    
  2. Create and activate a virtual environment
    python -m venv venv
    source venv/bin/activate        # Linux/macOS
    venv\Scripts\activate           # Windows
    
  3. Install dependencies
    pip install -r requirements.txt
    
  4. Configure environment variables Create a .env file in the root directory (see Environment Variables below).
  5. Run the development server
    uvicorn app:app --reload
    

    The API will be available at http://localhost:8000. Interactive docs at http://localhost:8000/docs. — Environment Variables Create a .env file in the project root:

    postgreSQL=postgresql+asyncpg://user:password@host/dbname
    

    The database URL variable is named postgreSQL — keep this exact casing in your deployment config.

    API Endpoints POST /medicinfoept Accepts a patient’s health profile and returns a risk assessment. Request Body — application/json

    {
      "age": 28,
      "sex": "male",
      "weight": 75.0,
      "height": 1.78,
      "smokeRate": "never",
      "bloodPressure": 120.0,
      "heartRate": 72.0,
      "bodyTemperature": 36.6,
      "existingConditions": ["asthma"]
    }
    

    Field Reference Field Type Required Notes age integer ✓ Max 120 sex male / female ✓ Enum weight float ✓ In kilograms height float ✓ In metres smokeRate string (enum) ✓ frequently, moderate, or never bloodPressure float ✓ Systolic, in mmHg heartRate float ✓ In BPM bodyTemperature float ✓ In °C existingConditions array of strings ✓ Pass empty array [] if none Response — 200 OK

    {
      "risk_level": "...",
      "details": "..."
    }
    

    Error Response — 422 Unprocessable Entity Returned when required fields are missing or fail validation.

    {
      "detail": [
     {
       "loc": ["body", "age"],
       "msg": "field required",
       "type": "value_error.missing"
     }
      ]
    }
    

    Notes Render free-tier instances spin down after inactivity — the first request may take 30–60 seconds to cold-start. All fields in the request body are required; there are no optional fields. existingConditions accepts any string values (e.g. "diabetes", "hypertension", "asthma"). Pass an empty array [] if the patient has none.