-
Notifications
You must be signed in to change notification settings - Fork 7
API: Elements
A element represents a piece of content on a page. This includes the question to ask, a default answer, and how the question is supposed to be answered.
/api/elements
Only the user that owns the procedure that this element is contained in can access it.
| Field Name | Type | Required? | Default Value | Read Only? | Description |
|---|---|---|---|---|---|
id |
int |
Yes | Yes | The unique id for this element. | |
page |
Page |
Yes | Yes | The page that this element is on. | |
display_index |
int |
Yes | No | Represents where the element is located from 1..n within the page. | |
element_type |
string |
Yes | No | The type of element. Must be one of: ENTRY, SELECT, MULTI_SELECT, RADIO, DATE, PICTURE, PLUGIN, ENTRY_PLUGIN. | |
choices |
list<string> |
For SELECT, MULTI_SELECT, and RADIO element_type
|
No | The options available to answer the question. | |
concept |
Concept |
Yes | No | The concept that this element is backed by. | |
question |
string |
Yes | No | The question that this element asks. | |
answer |
list<string> |
Yes | No | The default answer to the question. Can be multiple values for the MULTI_SELECT type. | |
required |
boolean |
No | false |
No | Whether this question must be answered. |
image |
string |
No | No | The image for this element. | |
audio |
string |
No | No | The audio for this element. | |
action |
string |
For PLUGIN and ENTRY_PLUGIN element_type
|
No | The action for this element | |
mime_type |
string |
No | For PLUGIN and ENTRY_PLUGIN element_type
|
No | The mime_type of this element. |
last_modified |
datetime |
Yes | Yes | The last time that this object was updated. This value is auto-generated. | |
created |
datetime |
Yes | Yes | The time that this object was created. This value is auto-generated. |
To create a page POST to /api/elements.
201: Object Created Successfully
400: Bad value in the request body. Check the response for errors
401: Invalid Request Token
POST /api/elements
Host: sanaprotocolbuilder.me
Authorization: Token <token>{
"display_index":0,
"concept":2,
"page":67,
"element_type":"ENTRY",
"question":"Observed color of surgical site drainage.",
"answer":[
""
]
}{
"id":60,
"display_index":0,
"concept":2,
"question":"Observed color of surgical site drainage.",
"answer":[
""
],
"page":67,
"required":false,
"element_type":"ENTRY",
"last_modified":"2016-03-14T06:58:17.233446Z",
"created":"2016-03-14T06:58:17.233519Z"
}To update an element PUT to /api/elements/{id}, where id is the id of the element. You only need to send the fields that are to be updated in the body of the request. Sending up other fields that are not modified, will not do anything.
200: Object Updated Successfully
400: Bad value in the request body. Check the response for errors
401: Invalid Request Token
404: Does not exist
PUT /api/element/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>{
"answer":[
"Red"
]
}{
"id":60,
"display_index":0,
"concept":2,
"question":"Observed color of surgical site drainage.",
"answer":[
"Red"
],
"page":67,
"required":false,
"element_type":"ENTRY",
"last_modified":"2016-03-14T07:00:26.352719Z",
"created":"2016-03-14T06:58:17.233519Z"
}To delete an element send a DELETE request to /api/elements/{id} where the id is the id of the element to be deleted.
203: Object successfully deleted
401: Invalid Request Token
404: Does not exist
DELETE /api/elements/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>No response body
To get all elements that you own GET to /api/elements.
200: Success
401: Invalid Request Token
GET /api/elements
Host: sanaprotocolbuilder.me
Authorization: Token <token>[
{
"id":60,
"display_index":0,
"concept":2,
"question":"Observed color of surgical site drainage.",
"answer":[
"Red"
],
"page":67,
"required":false,
"element_type":"ENTRY",
"last_modified":"2016-03-14T07:00:26.352719Z",
"created":"2016-03-14T06:58:17.233519Z"
},
{
"id":61,
"display_index":0,
"concept":2,
"question":"Take a picture",
"answer":[
],
"page":67,
"required":false,
"element_type":"PICTURE",
"last_modified":"2016-03-14T07:00:26.352719Z",
"created":"2016-03-14T06:58:17.233519Z"
}
]To get a specific element that you own GET to /api/elements/{id}, Where id is the element's id.
200: Success
401: Invalid Request Token
404: Does not exist
GET /api/elements/60
Host: sanaprotocolbuilder.me
Authorization: Token <token>{
"id":60,
"display_index":0,
"concept":2,
"question":"Observed color of surgical site drainage.",
"answer":[
"Red"
],
"page":67,
"required":false,
"element_type":"ENTRY",
"last_modified":"2016-03-14T07:00:26.352719Z",
"created":"2016-03-14T06:58:17.233519Z"
}