Skip to content

MyMeds-Turing/my_meds_be

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Meds API and Database

heroku postgreSQL

ruby rails rspec contributors

Background and Description

This repository implements a GraphQL API and PostgreSQL database providing a micro-service for the MyMeds FE web application. SMS and Email notifications are implemented using Twilio's suite of micro-services.

Disclaimer

This project is designed for usage with a specific front-end React application. If using it for your own project, please provide credit to: John Hennerich (jhennerich), Zel Imbriaco (zel-imbriaco), Maximillian Wagner (MWagner3), and Katy Harrod (mcharrod).

Table of Contents

Schema

plot

Gems Utilized


Usage Instructions

To install the My Meds Database for your own personal usage, please do the following:

  1. Fork this repository.
  2. Clone your forked repository to your desired back-end hardware.
  3. In the terminal, navigate to the my_meds_be folder and run bundle install.
  4. While still in the terminal, run rails db:{drop,create,migrate,seed} to populate your database with seed data.`
  5. Make any changes to the database as necessary, and deploy to your database-hosting service of choice.

GraphQL

Our GraphQL endpoints fall into two categories: queries and mutations.

Queries

  1. fetchUser(id: ID) Finds a specific user in the database
  • Example Query
{
  fetchUser(id: 1) {
    id
    firstName
    lastName
    fullName
    email
    sms
    notify
    createdAt
    updatedAt
  }
}
  • Example Response
{
  "data": {
    "fetchUser": {
      "id": "1",
      "firstName": "John",
      "lastName": "L",
      "fullName": "John L",
      "email": "[email protected]",
      "sms": "5551234567",
      "notify": 0,
      "createdAt": "2022-07-13T23:17:33Z",
      "updatedAt": "2022-07-13T23:17:33Z"
    }
  }
}
  1. fetchUsers list all users in the database
  • Example Query
{
      fetchUsers {
        id
        firstName
        lastName
        fullName
        email
        sms
        notify
        createdAt
        updatedAt
      }
}
  • Example Response
{
"data": {
  "fetchUsers": [
    {
      "id": "1",
      "firstName": "John",
      "lastName": "L",
      "fullName": "John L",
      "email": "[email protected]",
      "sms": "5551234567",
      "notify": 0,
      "createdAt": "2022-07-13T23:17:33Z",
      "updatedAt": "2022-07-13T23:17:33Z"
    },
    {
      "id": "2",
      "firstName": "Paul",
      "lastName": "M",
      "fullName": "Paul M",
      "email": "[email protected]",
      "sms": "5551234567",
      "notify": 0,
      "createdAt": "2022-07-13T23:17:33Z",
      "updatedAt": "2022-07-13T23:17:33Z"
    }
  ]
}
}
  1. fetchRxs list all prescriptions in the database
  • Example Query
{
  fetchRxs {
    id
    medName
    timeOfLastDose
    timeOfNextDose
    totalDoses
    dosesRemaining
    maxDailyDoses
    dose
    userInstructions
    additionalInstructions
    timeBetweenDose
    icon
    userId
    createdAt
    updatedAt
  }
}
  • Example Response
{
  "data": {
    "fetchRxs": [
      {
        "id": "1",
        "medName": "Tylenol",
        "timeOfLastDose": "2022-07-13T23:17:33Z",
        "timeOfNextDose": "2022-07-14T23:17:33Z",
        "totalDoses": 500,
        "dosesRemaining": 500,
        "maxDailyDoses": 6,
        "dose": "200 mg",
        "userInstructions": "take pill, take with food",
        "additionalInstructions": "take 2 call me in the morning",
        "timeBetweenDose": 240,
        "icon": "path_to_icon",
        "userId": 1,
        "createdAt": "2022-07-13T23:17:33Z",
        "updatedAt": "2022-07-13T23:17:33Z"
      },
      {
        "id": "2",
        "medName": "Tylenol",
        "timeOfLastDose": "2022-07-13T23:17:33Z",
        "timeOfNextDose": "2022-07-17T23:17:33Z",
        "totalDoses": 500,
        "dosesRemaining": 500,
        "maxDailyDoses": 6,
        "dose": "200 mg",
        "userInstructions": "take pill, take with food",
        "additionalInstructions": "take 2 call me in the morning",
        "timeBetweenDose": 240,
        "icon": "path_to_icon",
        "userId": 2,
        "createdAt": "2022-07-13T23:17:33Z",
        "updatedAt": "2022-07-13T23:17:33Z"
      },
      {
        "id": "3",
        "medName": "OxyContin",
        "timeOfLastDose": "2022-07-13T23:17:33Z",
        "timeOfNextDose": "2022-07-15T23:17:33Z",
        "totalDoses": 25,
        "dosesRemaining": 25,
        "maxDailyDoses": 4,
        "dose": "5mg",
        "userInstructions": "take pill, take with food",
        "additionalInstructions": "take 2 call me in the morning",
        "timeBetweenDose": 240,
        "icon": "path_to_icon",
        "userId": 1,
        "createdAt": "2022-07-13T23:17:33Z",
        "updatedAt": "2022-07-13T23:17:33Z"
      }
    ]
  }
}
  1. fetchUserRxs(id: ID) list all prescriptions in the database by user id
  • Example Query
{
  fetchUserRxs(id: 1) {
    id
    medName
    timeOfLastDose
    timeOfNextDose
    totalDoses
    dosesRemaining
    maxDailyDoses
    dose
    userInstructions
    additionalInstructions
    timeBetweenDose
    icon
    userId
    createdAt
    updatedAt
  }
}
  • Example Response
{
  "data": {
    "fetchUserRxs": [
      {
        "id": "1",
        "medName": "Tylenol",
        "timeOfLastDose": "2022-07-13T23:17:33Z",
        "timeOfNextDose": "2022-07-14T23:17:33Z",
        "totalDoses": 500,
        "dosesRemaining": 500,
        "maxDailyDoses": 6,
        "dose": "200 mg",
        "userInstructions": "take pill, take with food",
        "additionalInstructions": "take 2 call me in the morning",
        "timeBetweenDose": 240,
        "icon": "path_to_icon",
        "userId": 1,
        "createdAt": "2022-07-13T23:17:33Z",
        "updatedAt": "2022-07-13T23:17:33Z"
      },
      {
        "id": "3",
        "medName": "OxyContin",
        "timeOfLastDose": "2022-07-13T23:17:33Z",
        "timeOfNextDose": "2022-07-15T23:17:33Z",
        "totalDoses": 25,
        "dosesRemaining": 25,
        "maxDailyDoses": 4,
        "dose": "5mg",
        "userInstructions": "take pill, take with food",
        "additionalInstructions": "take 2 call me in the morning",
        "timeBetweenDose": 240,
        "icon": "path_to_icon",
        "userId": 1,
        "createdAt": "2022-07-13T23:17:33Z",
        "updatedAt": "2022-07-13T23:17:33Z"
      },
      {
        "id": "4",
        "medName": "Motrin",
        "timeOfLastDose": "2022-07-13T23:17:33Z",
        "timeOfNextDose": "2022-07-14T15:17:33Z",
        "totalDoses": 250,
        "dosesRemaining": 250,
        "maxDailyDoses": 4,
        "dose": "200mg",
        "userInstructions": "take pill, take with food",
        "additionalInstructions": "take 2 call me in the morning",
        "timeBetweenDose": 240,
        "icon": "path_to_icon",
        "userId": 1,
        "createdAt": "2022-07-13T23:17:33Z",
        "updatedAt": "2022-07-13T23:17:33Z"
      }
    ]
  }
}

Mutations

  1. deleteRx(id: ID) Deletes a prescription from the database
  • Example Mutation
{
  deleteRx(input: {id: 1}  ) {
          id
        }
      }
  • Example Response
{
  "data": {
    "deleteRx": {
      "id": "1"
    }
  }
}
  1. addRx creates an entry in the prescription table
  • Available input fields
mutation {
     addRx(input: { params: {
        medName: "Asprin",
        totalDoses: 100,
        maxDailyDoses: 12,
        dose: "25 mg",
        userInstructions: "takepill, take with food",
        additionalInstructions: "take 2 a day",
        timeBetweenDose: 15,
        icon: "path_to_icon",
        userId: 1   
    }}){
    rx {
        id
        medName
    }
    }
    }
  • Example Response
{
    "data": {
        "addRx": {
            "rx": {
                "id": "9",
                "medName": "Asprin"
            }
        }
    }
}
  1. updateRx updates an entry in the prescription table
  • Available input fields
mutation {
     rx: updateRx(
        input: {
         id: 11
         medName: "Adult Asprin",
        timeOfLastDose: "2022-07-15T04:03:27Z",
        timeOfNextDose: "2022-07-15T04:03:27Z"
        totalDoses: 100,
        dosesRemaining: 100,
        maxDailyDoses: 12,
        dose: "25 mg",
        userInstructions: "takepill, take with food",
        additionalInstructions: "take 2 a day",
        timeBetweenDose: 15,
        icon: "path_to_icon",
        userId: 1   
     }
     ){           
        id
        medName
        dosesRemaining
        }
     }
  • Example Response
{
   "data": {
       "addRx": {
           "rx": {
               "id": "9",
               "medName": "Asprin"
           }
       }
   }
}
  1. takeMed Reduces remaining doses by one.
  • Example Query
mutation {
        takeMed(input: {id: 3}  ) {
          id
          medName
          timeOfLastDose
          timeOfNextDose
          dosesRemaining
          userId
        }

      }
  • Example Response
{
  "data": {
    "takeMed": {
      "id": "3",
      "medName": "Tylenol",
      "timeOfLastDose": "2022-07-19T20:35:25Z",
      "timeOfNextDose": "2022-07-20T00:35:25Z",
      "dosesRemaining": 490,
      "userId": 3
    }
  }
}
  1. addUser creates a user
  • Example Query
mutation {
        addUser(input: { params: {
          firstName: "John",
          lastName: "Lennon",
          email: "[email protected]",
          password: "passwd",
          passwordConfirmation: "passwd",
          sms: "5551234567",
          notify: 2
          }} ) {
    user{ id
    email
    notify
    }
    }
    }
  • Example Response
{
  "data": {
    "addUser": {
      "user": {
        "id": "6",
        "email": "[email protected]",
        "notify": 0
      }
    }
  }
}

Future Iteration Goals

  • SMS and email reminders when it is time for users to take their medication.
  • SMS and email reminders when users are running low on stock of a specific medication and need to get a refill from their doctor.

Contributors

John Hennerich GitHub | LinkedIn
Max Wagner GitHub | LinkedIn
Zel Imbriaco GitHub | LinkedIn
Katy Harrod GitHub | LinkedIn

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages