- Install Node.js: https://nodejs.org/en/download/
- Install MongoDB: https://docs.mongodb.com/manual/installation/
- Install Git: https://git-scm.com/downloads
In order to send out notifications to iOS devices, the backend must be setup with a verified Apple Developer Account enrolled in the Apple Developer Program which has a 99 USD annual fee. To setup an account, simply navigate to https://developer.apple.com and create one. You should now be presented with the dashboard. Once you are there, please follow the steps outlined below:
-
First, navigate to
Membership
tab and take note of theTeam ID
field. We will use this value later on. -
Next, click on the
Certificates, IDs & Profiles
tab. Click on theKeys
tab and click on the blue plus icon. You should be presented with a screen similar to this one:
-
Enter a name for the key and enable the
Apple Push Notifications server (APNs)
option. Click continue and then click register. -
Now you should be presented with the option to download the key. Please take note of the
Key ID
which will be used later on. An example is shown below:
- Now click on the blue download button in the top right. Save the downloaded key to the root of the backend repository and change the name of the file to
MedManager_apns_key.p8
. It's very important that you change the name of the key file otherwise the backend will not be able to send out notifications.
In order to send out notifications on devices running Android, the backend must be connected to an authenticated Firebase account. To create a Firebase account, navigate to https://firebase.google.com and follow the instructions. Once in the firebase console, follow these steps:
-
Create a firebase project and navigate to the project overview page.
-
Go to the project settings page, and navigate to
Service Accounts
>Generate new private key
. This json file will allow the backend to send out notifications. Place it within the root directory of this project. -
Make sure to rename this json file to
med-manager-3-firebase-adminsdk.json
. If not changed, the backend will not be able to send out notifications for Android.
This backend uses the Twilio API to send out text messages to caregiver contacts. In order to send out notifications, a secure Twilio account must be made. Navigate to https://twilio.com and follow the steps to create an account and create a Twilio project. From there, a dashboard screen should show the ACCOUNT_SID
and AUTH TOKEN
fields, which will be used to set up the environment variables in the next section. Make sure to obtain a number through the project dashboard as well, as the phone number through which text messages are sent needs to be outlined in the environment variables.
Note: All prior steps need to be completed in order to fill out the environment variables.
In order to setup the backend environment properly, you must set the required environment variables through a .env
file at the root of the project. Please follow the steps outlined below:
- Create the file named
.env
at the root of the project. - Copy the contents of the
.env.example
file into the newly created.env
file. - Enter the
APPLE_TEAM_ID
andAPPLE_KEY_ID
values captured in the previous section on iOS notifications setup - Enter the
TWILIO_ACCOUNT_SID
,TWILIO_AUTH_TOKEN
, andTWILIO_PHONE_NUMBER
values captured in the previous section on caregiver alert setup.
To download the backend repository, execute the following command in a folder called medmanager
on your machine:
git clone https://github.com/medmanager/backend.git
To install the project's dependencies, execute the following command at the root of the backend repository:
npm install
After this command is done executing, a new folder named node_modules
should appear at the root of the directory.
A list of dependencies for the project can be found in the package.json
file in this repository.
After installing the dependencies, to run the server locally you need to execute the following command at the root of the backend repository:
npm run start
Now you can now access the API locally at http://localhost:4000/.
Note: You can change the servers port number (the default is port 4000
) in the .env
file by setting the variable like so:
PORT=1337
- If 'npm' command is not recognized:
- Have you installed nodejs correctly and added the path to your environment variables? Follow this link here for a brief tutorial on how to do so: https://www.tutorialspoint.com/nodejs/nodejs_environment_setup.htm
- 'npm install' command has failed
- Try running 'npm cache clean'
- Use -verbose to view more details about the installation issue
- Make sure your npm version is up to date ('npm version')
- If you get an error for not having installed 'git', make sure to do so. Instructions can be found here: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
- Try deleting the node_modules folder if it exists, restart your computer, and try again
- 'npm start' command has failed
- If the issue is a node_module concern, make sure you have ran 'npm install' recently
- Make sure you do not have another local server running on the same port specified in the .env file
- Try restarting your computer
- Try uninstalling and reinstalling node
- Users can now register a new account by providing their fist and last name, email, and a password.
- Users can now login to their existing account by providing their email and password. If the email or password is incorrect, an error message will be displayed.
- Users can now update their device operating system and token information via a new route.
- Users can now add a new medication to their account. The medication will be verified before the data is persisted.
- Users can now delete a medication from their account.
- Users can now update the details of a medication or reschedule it's dosages using new times or frequencies. The previous dosage data will be saved in order to track compliance over time. Of course, the information will be verified before persisting.
- Users can now stop taking a medication anytime they want. The data up until the point they stop taking the medication will be saved and continue to be used for tracking.
- Users can now resume taking a medication anytime they want. The dosages will be rescheduled and the user will now get reminders if they have enabled them in the settings.
- Dosage reminders are now scheduled for each medication's occurrence in the current weeks time frame. The user has the ability to disable reminders on a per-dosage basis or turn off notifications entirely.
- Dosage reminders are now persisted when the server restarts.
- New API route which retrieves medication information along with its dosages.
- New API route which retrieves information necessary to get all the medications for a single notification.
- Users can now access medication compliance data stored since they first added the medication.
- Users can now enable caregiver contact alerts from the settings which will be sent if the user does not take their medication within 6 hours of it's scheduled dosage time. The user can configure the name and phone number of the caregiver which will be alerted. By default, the caregiver contact will not be configured and thus, no alerts will be sent.
- Caregiver alerts are now scheduled 6 hours after the dosage reminder is delivered to the user. If the user has disabled caregiver alerts, then nothing will be scheduled.
- Users can now configure settings to disable all notifications or to hide medication names in dosage reminders. By default, the names are hidden from the medication dosage reminders.
- Users can now update the first name, last name, or email currently associated with their account.
- The server will no longer consider duplicate occurrences when scheduling occurrences for the current week.
- Weekly medications no longer contain incorrect occurrence times. Rescheduling a medication from daily to weekly is now possible!
- There is no way of resetting a users password.
- There is no way of updating the amount of medication remaining.
- No handling of the event when a medication has no amount remaining when taken.
- No way of dynamically setting the JWT secret used to generate authentication tokens.
- There is no fatal error recovery for creating and scheduling medication occurrences.