AndWellness-JSON
From CSL Wiki
| Revision as of 18:09, 4 November 2009 Selsky (Talk | contribs) ← Previous diff |
Revision as of 18:11, 4 November 2009 Selsky (Talk | contribs) Next diff → |
||
| Line 57: | Line 57: | ||
| Each JSON message has a type and a subtype. The reason we have introduced typing into the message protocol is due to the nature of having only one upload URL (API entry point). If we had separate URLs for say, mobility uploads and prompt responses, we could remove one level of typing from these messages. It would be nice for AndWellness to have multiple URLs as described, but for the PDV, separate URLs would be a difficult task due to the PDV's generic nature of being able to interface with many third-party applications and datatypes. | Each JSON message has a type and a subtype. The reason we have introduced typing into the message protocol is due to the nature of having only one upload URL (API entry point). If we had separate URLs for say, mobility uploads and prompt responses, we could remove one level of typing from these messages. It would be nice for AndWellness to have multiple URLs as described, but for the PDV, separate URLs would be a difficult task due to the PDV's generic nature of being able to interface with many third-party applications and datatypes. | ||
| - | === Mobility Types and Subtypes === | + | === Mobility Types and Sub-types === |
| The mobility <code>type</code> allows us to specify details for messages related to the phone user's mobility state. | The mobility <code>type</code> allows us to specify details for messages related to the phone user's mobility state. | ||
| Line 68: | Line 68: | ||
| * type: '''mobility''' | * type: '''mobility''' | ||
| - | ** subtype: '''mode_features''' | + | ** sub-type: '''mode_features''' |
| *** '''features''' An object specifying classification features. Required. | *** '''features''' An object specifying classification features. Required. | ||
| **** '''speed''' A float. Required. | **** '''speed''' A float. Required. | ||
| Line 75: | Line 75: | ||
| **** '''fft''': An array of ten floats. Required. | **** '''fft''': An array of ten floats. Required. | ||
| - | Example <code>(type=mobility, subtype=mode_only</code>): | + | Example <code>(type=mobility, sub-type=mode_only</code>): |
| [{ | [{ | ||
| Line 89: | Line 89: | ||
| }] | }] | ||
| - | Example (<code>type=mobility, subtype=mode_features</code>): | + | Example (<code>type=mobility, sub-type=mode_features</code>): |
| [{ | [{ | ||
| Line 140: | Line 140: | ||
| *** response: any JSON object (the format of the response depends on the subtype) | *** response: any JSON object (the format of the response depends on the subtype) | ||
| - | Example (<code>type=prompt, subtype=stress</code>) | + | Example (<code>type=prompt, sub-type=stress</code>) |
| [{ | [{ | ||
| Line 154: | Line 154: | ||
| }] | }] | ||
| - | Example (<code>type=prompt, subtype=mood</code>) | + | Example (<code>type=prompt, sub-type=mood</code>) |
| [{ | [{ | ||
| Line 168: | Line 168: | ||
| }] | }] | ||
| - | Example (<code>type=prompt, subtype=energy</code>) | + | Example (<code>type=prompt, sub-type=energy</code>) |
| [{ | [{ | ||
| Line 182: | Line 182: | ||
| }] | }] | ||
| - | Example (<code>type=prompt, subtype=glucose_level</code>) | + | Example (<code>type=prompt, sub-type=glucose_level</code>) |
| [{ | [{ | ||
| Line 196: | Line 196: | ||
| }] | }] | ||
| - | Example (<code>type=prompt, subtype=blood_pressure</code>) | + | Example (<code>type=prompt, sub-type=blood_pressure</code>) |
| [{ | [{ | ||
Revision as of 18:11, 4 November 2009
Contents |
HTTP Between Phone and Server
This page defines the data format (schema) used between a phone and the server application. The client-server protocol uses JSON over HTTP. It is expected that the schema will change over time. The upload URL will be something like http://pilot.andwellness.cens.ucla.edu/upload?json={...}. TBC.
All client-server communication must use UTF-8 character encoding.
JSON
Naming Conventions
- All keys use lowercase.
- All multi-word keys use dashes as a word separator.
- All multi-word values use underscores as a word separator.
Upload Format
- phone-version: A float representing the phone application version. Required. Usage TBD.
- protocol-version: A float representing the JSON protocol version the current message adheres to. Required. Usage TBD.
- data: An array of objects. At least one packet is required and 500 is the maximum.
{
"phone-version":0.1,
"protocol-version":0.1,
"data":[first packet],[second packet], ... ,[nth packet]
}
Data Packet
The data packet is a JSON Object with a set of standard and function-specific data elements.
- user-name: A string used for identification. Required.
- date: A string in the ISO 8601 format to the detail of seconds “YYYY-MM-DD hh:mm:ss”. Required.
- time: An int specifying the number of milliseconds since the epoch.
- type: A lowercase string specifying the data type. Required.
- sub-type: A lowercase string specifying the data subtype (specialization). Required.
- latitude: A float representing latitude. Required.
- longitude: A float representing latitude. Required.
- time-zone: A string representing a standard time zone. Required.
- Feature specific data.
Example:
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"type",
"sub-type":"subtype",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
...
}]
Message Types and Subtypes
Each JSON message has a type and a subtype. The reason we have introduced typing into the message protocol is due to the nature of having only one upload URL (API entry point). If we had separate URLs for say, mobility uploads and prompt responses, we could remove one level of typing from these messages. It would be nice for AndWellness to have multiple URLs as described, but for the PDV, separate URLs would be a difficult task due to the PDV's generic nature of being able to interface with many third-party applications and datatypes.
Mobility Types and Sub-types
The mobility type allows us to specify details for messages related to the phone user's mobility state.
The mobility subtypes are: mode_only and mode_features. Each subtype specifies a data packet as described below.
- type: mobility
- subtype: mode_only
- mode: A lowercase string specifying an mobility mode. The allowed values are:
still, walk, run, bike, drive. Required.
- mode: A lowercase string specifying an mobility mode. The allowed values are:
- subtype: mode_only
- type: mobility
- sub-type: mode_features
- features An object specifying classification features. Required.
- speed A float. Required.
- variance: A float. Required.
- average: A float. Required.
- fft: An array of ten floats. Required.
- features An object specifying classification features. Required.
- sub-type: mode_features
Example (type=mobility, sub-type=mode_only):
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"mobility",
"sub-type":"mode_only",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"mode":"still"
}]
Example (type=mobility, sub-type=mode_features):
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"mobility",
"sub-type":"mode_features",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"features":{
"speed":0.0,
"variance":0.0,
"average":0.0,
"fft":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
}
}]
Prompt Types and Subtypes
The prompt type allows us to specify details for messages related to the phone user's EMA responses. Each prompt type message must contain a subtype. For the initial rollout of the application, the server will be accepting responses for five different prompts: stress, mood, energy, glucose level, and blood pressure. Stress, mood, energy, and glucose level have range-bound values while blood pressure has values for systolic and diastolic pressure.
| Prompt | Response Limits |
| Stress | 1 <= n <= 5 |
| Mood | 1 <= n <= 5 |
| Energy | 1 <= n <= 5 |
| Glucose Level | 1 <= n <= 11 |
| Blood Pressure | Two integer values: systolic and diastolic pressure. Min and max for each TBD. |
Message hierarchy:
- type: prompt
- subtype: a lowercase string that is one of: stress, mood, energy, bloodpressure
- response: any JSON object (the format of the response depends on the subtype)
- subtype: a lowercase string that is one of: stress, mood, energy, bloodpressure
Example (type=prompt, sub-type=stress)
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"prompt",
"sub-type":"stress",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"response":1
}]
Example (type=prompt, sub-type=mood)
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"prompt",
"sub-type":"mood",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"response":1
}]
Example (type=prompt, sub-type=energy)
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"prompt",
"sub-type":"energy",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"response":1
}]
Example (type=prompt, sub-type=glucose_level)
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"prompt",
"sub-type":"glucose_level",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"response":1
}]
Example (type=prompt, sub-type=blood_pressure)
[{
"user-name":"bob@example.com",
"date":"2009-11-03 10:18:33",
"time":1257272467077,
"type":"prompt",
"sub-type":"blood_pressure",
"latitude":38.8977,
"longitude",-77.0366,
"time-zone":"EST",
"response":{
"systolic":70,
"diastolic":100
}
}]
Prompts/EMAs we are considering for future iterations of the application are: diet, exercise, sexual interactions, drug use, and various biomarkers. It would be good to separate the EMAs by proposal. TBD.
