Giter Site home page Giter Site logo

awful-doctor's Introduction

awful-doctor

It's very bad at it.

Setup

This project uses Django with SQLite and React with Redux.

Django

I used virtualenv to install Django, but you can use a system wide installation if you have one. I'm using Python 3, so if Python 2 is your default version, replace python with python3 and pip with pip3. Run pip install -r ./requirements.txt to install all the dependencies. You might have to use sudo if you're not using virtualenv.

You'll need to run python ./manage.py migrate to run Django's database migration stuff.

An importcsv command is included to grab the data from symptoms.csv and put them into the DB. It can be run from backend/ with python ./manage.py importcsv.

SECRET_KEY is kept the default since this isn't a production environment, but usually it wouldn't be committed.

I also included django-cors-headers instead of setting up nginx or something, so that the webpack dev server and django runserver could just talk directly to each other.

React

I used create-react-app to set up the environment because I didn't want to mess around with configuration for too long. Remember to yarn install (or npm i).

Running

For the backend, first activate virtualenv if you're using it. Then, cd backend; python ./manage.py runserver That will start the Django dev server on port 8000, leave it running.

For the frontend, you can do yarn run start (or npm run start) to start the webpack dev server on port 3000. If you want it built instead, it's yarn run build, which goes into the build directory. For a quick server, you can just do python -m http.server 8080 in build.

APIs

Most of the data is keyed by ID for easier access on the frontend, and to prevent the storing of duplicate data in redux, since any one symptoms or sicknesses can appear in any number of diagnoses.

api/symptoms

GET

{
    "symptom_ids": [
        1,
        2,
        3
    ],
    "symptoms": {
        "1": {
            "name": "sore throat",
            "id": 1
        },
        "2": {
            "name": "itchy rash",
            "id": 2
        },
        "3": {
            "name": "runny nose",
            "id": 3
        }
    }
}

api/diagnosis

GET

Params:

  • symptom: symptom ID
{
    "diagnoses": {
        "1": {
            "sickness_id": 1,
            "id": 1,
            "frequency": 5,
            "symptom_id": 1
        },
        ...
    },
    "sickness": {
        "1": {
            "name": "common cold",
            "id": 1
        },
        ...
    },
    // ID of the most likely diagnosis
    "most_likely": 1,
    // Sorted by frequency, then alphabetically
    "diagnosis_ids": [
        1,
        ...
    ]
}

POST

Body (JSON):

{
    "symptom": 2, // Symptom ID
    "diagnosis": 3, // Diagnosis ID
}

Returns the same data as the GET request

awful-doctor's People

Contributors

emmasimon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.