Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

API: Elements

Joshua Kalpin edited this page Mar 14, 2016 · 3 revisions

Element

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.

Path

/api/elements

Permissions

Only the user that owns the procedure that this element is contained in can access it.

Fields

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.

Creating

To create a page POST to /api/elements.

Status Codes

201: Object Created Successfully

400: Bad value in the request body. Check the response for errors

401: Invalid Request Token

Example Request

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":[  
    ""
  ]
}

Example Response

{  
  "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"
}

Updating

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.

Status Codes

200: Object Updated Successfully

400: Bad value in the request body. Check the response for errors

401: Invalid Request Token

404: Does not exist

Example Request

PUT /api/element/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
  "answer":[
    "Red"
  ]
}

Example Response

{  
  "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"
}

Deleting

To delete an element send a DELETE request to /api/elements/{id} where the id is the id of the element to be deleted.

Status Codes

203: Object successfully deleted

401: Invalid Request Token

404: Does not exist

Example Request

DELETE /api/elements/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

No response body

Getting All

To get all elements that you own GET to /api/elements.

Status Codes

200: Success

401: Invalid Request Token

Example Request

GET /api/elements
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

[  
  {  
    "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"
  }
]

Get one

To get a specific element that you own GET to /api/elements/{id}, Where id is the element's id.

Status Codes

200: Success

401: Invalid Request Token

404: Does not exist

Example Request

GET /api/elements/60
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

{  
  "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"
}