-
Notifications
You must be signed in to change notification settings - Fork 2
Web API
Server data will always be sent down in JSON format in the following protocol:
{
"status": "success",
"data": {
//return data will appear here
},
"message": null //optional success message
}
{
"status": "error",
"data": null,
"message": "Error message" //Custom error message
}
ND specifies that the action will have a NULL data payload back from the server
IMG specifies that the server will return a RAW image, not JSON data
Basic server tests. Destination: api/test/action
Get request test, server will always send back success
Send:
- foo: test paramater, can be anything
Server will indicate success if foo parameter is set. Receive:
- fooback: server will echo foo back
Send:
- uiud: device token (64 characters)
- message: desired message
Server will always indicate success. Receive:
- "Server response": node.js server response
Users are fundamentally divided into groups caretakers and patients. Caretaker actions are located at api/caretaker/action
Send:
- username: user username, must be above 5 characters in length
- password: user password, must be above 8 characters in length
Send:
- username: user username
- password: user password
Recieve:
- authcode: authentication code
After recieving the authentication code, all future API requests MUST have the authentication code attached as a GET parameter.
Example: /API/user/info?authcode=XxxxXxxxX
Verifies authcode is valid or invalid, returns success/failure.
Returns user info
Recieve:
- username: username of user
- more to come
Register device token for user.
Send:
- uiud: 64 character device token
Caretaker and patient interaction. This is done through the following endpoint: /api/caretaker/action
Fetches a list of patients for the given caretaker.
Recieve:
[
{
pid: 5 //patient id,
name: "John Doe" //name of patient
active: 1 //whether or not the patient has been successfully linked (0/1)
},
{
//....
}
]
Caretaker creates a new patient.
Send:
- name: full name of patient
- usability: usability level of patient
Receive:
- lcode: linking code needed to link with patient
- pid: patient id of newly created patient
Retrieves patient info for an individual patient.
Recieve:
- name: name of patient
- usability: usability level
- medstatus: boolean (1/0) indicating if they are up to date with their medication
Caretaker resends the lcode for patient {pid}. This is useful if the patient gets a new phone.
Receive:
- lcode: linking code
A caretaker is able to "share" a patient, with another caretaker. This allows multiple caretakers to be connected to one patient.
Send:
- username: username of person-to-share
Handles creating medication for the patient. Endpoint: api/caretaker/patients/{pid}/actions
Get all medication information in a JSON array.
Receive:
[
{
medid: 5, //medication id
name: "Lipitor", //name of medication
dosage: 2, //medication dosage
remain: 20, //amount left
info: "Take with your meal" //additional instructions for taking medication
},
{
//....
}
]
Create new medication for given patient
Send:
- name: name of medication
- dosage: dosage amount
- remain: amount of medication left
- picture: picture of medication
- info: additional info in taking medication
Receive:
- medid: medication id
Get picture for given medication. Returns a 404 not found on error.
Receive:
Raw picture of medication in .jpg format.
Edit medication specified by medid. Only sent parameters you want to modify.
Send:
- name: name of medication
- dosage: dosage amount
- remain: amount of medication left
- picture: picture of medication
- info: additional info in taking medication
Create schedules for when to take medication for a patient. Endpoint: api/caretaker/patients/{pid}/actions
List of schedules returned in JSON array.
Receive:
[
{
schid: 5, //schedule id
hours: 4, //hour of medication (military time)
minutes: 20 //minute of medication
},
{
//....
}
]
Create a new schedule
Send:
- hours: hour of medication (military time)
- minutes: minute of medication
- medication: attached medication, send comma separated medids. Example data:
1,5,18,20.
Get medication info for a given schedule. Returns a JSON array.
Recieve:
[
{
medid: 5, //medicine id
taken: 2016-04-20 04:20:69 //Last time medication was taken
},
{
//....
}
]
Alters a given schedule. Allows you to change attached medication.
Send:
- medication: attached altered medication, send comma separated medids. Example data:
1,5,18,20.
Deletes a given schedule.
Patient actions. Located at /api/patient/action
Gets patient info, same as caretaker endpoint.
Links to the caretaker from the patient device.
Send:
- lcode: linking code
Receive:
- authcode: like in the case of the caretaker, the authcode should be attached to all further requests as a GET parameter
Register device token for user.
Send:
- uiud: 64 character device token
Medication information for the patient. Same as caretaker medication fetch (check above).
Fetches picture of medication, also same as caretaker
Schedule information, also the same as caretaker schedule fetch.
More detailed schedule information, same as caretakers.
Marks a given medication {medid} for schedule {schid} as taken and sets the last taken time.
Send:
- medid: medication id