Coder Social home page Coder Social logo

medication_api's Introduction

Medication Management API

Database architecture

We have two models currently: Patient and Medication. Patient contains a name and age field. Medication only contains a name field and is a many-to-many relationship with the Patient model. We will use the sqlite db that comes pre-packaged with Python for now.

Endpoints

The api exposes a few endpoints for both models.

  1. GET /patients/ returns a JSON list of all patients' name and database id.
  2. POST /patients/ creates a new patient in the database and returns its id. This endpoint requires a JSON body with the patient name parameter: { patient_name: agastya }
  3. GET /medications/ returns a JSON list of all medications' name and database id.
  4. POST /medications/ creates a new medication in the database and returns its id. This endpoint requires a JSON body with the medication name parameter: { medication_name: advil }
  5. POST /patient/{id}/add/ associates a given medication with the patient, given the patient's database id. It returns all medications associated with the given patient after the association is complete. This endpoint requires a JSON body with the medication name parameter, and returns a 400 response if either the medication or patient are not found. { medication_name: advil }
  6. POST /patient/{id}/remove/ removes a given medication for the patient, given the patient's database id. It returns all medications associated with the given patient after the removal is complete. This endpoint requires a JSON body with the medication name parameter, and returns a 400 response if either the medication or patient are not found. { medication_name: advil }

Running Locally

I have set up a Makefile to run the API locally. To run, simply:

  1. clone the directory locally: git clone https://github.com/amondal2/medication_api.git
  2. run make run in the root directory
  3. the shell will print which localhost:port combination it's running on (usually localhost:8000). access this with the above endpoints to test the api.

medication_api's People

Contributors

amondal2 avatar

Watchers

James Cloos avatar  avatar

medication_api's Issues

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.