Skip to content

MDS REST API

Eric Winkler edited this page Aug 4, 2015 · 11 revisions

MDS REST API

Authentication

The dispatch server will accept basic authentication for requests.

Response format

Responses must return a JSON object with status, code, and message fields and an optional errors in the case failure.

  • status - A string displaying SUCCESS or FAILURE
  • code - An int value similar to http response code but with additional options.
  • message - An array containing either a list of zero or more objects on success or list of one or more exception messages.

Successful Response

{ "status": "SUCCESS", "code": 200, "message": [] }
A successful response will normally return a code of 200

Failure Response

{ "status": "FAIL", "code": 400, "message": [] }
A failure response will have a code value greater than or equal to 400.

Request Methods

All resources will accept GET, POST, and PUT request methods. DELETE methods are not available. Objects should be updated as 'voided' instead. The only exception is the session resource which accepts POST and DELETE only.

UUID Uri param

The UUID value is optional in the url path for GET and PUT requests and not allowed for POST requests.

Note: POST calls allow for inclusion of the uuid field in the request body. This will override the value uuid value generated by the server.

URI Templates and Fields

Resource Uri Methods Fields
Session core/session/ POST
DELETE
username
password
Concept core/concept/{uuid} GET
POST
PUT
uuid
created
modified
voided
name
display_name
description
conceptclass
datatype
mimetype
constraint
Device core/device/{uuid} GET
POST
PUT
uuid
created
modified
name
Encounter core/encounter/{uuid} GET
POST
PUT
uuid
created
modified
voided
procedure
observer
device
subject
concept
Event core/event/{uuid} GET
POST
uuid
created
modified
voided
client
path
level
messages
duration
timestamp
message
Instruction core/instruction/{uuid} GET
POST
PUT
uuid
created
modified
voided
concept
predicate
algorithm
Location core/location/{uuid} GET
POST
PUT
uuid
created
modified
voided
name
Observation core/observation/{uuid} GET
POST
PUT
uuid
created
modified
voided
encounter
node
concept
value_text
value_complex
Observer core/observer/{uuid} GET
POST
PUT
uuid
created
modified
voided
user
Procedure core/procedure/{uuid} GET
POST
PUT
uuid
created
modified
voided
title
author
description
version
src
Subject core/subject/{uuid} GET
POST
PUT
uuid
created
modified
voided
given_name
family_name
dob
gender
image
location
system_id
Encounter Task tasks/encountertask/{uuid} GET
POST
PUT
uuid
created
modified
voided
assigned_to
status
due_on
started
completed
concept
voided
subject
procedure
encounter
Observation Task tasks/observationtask/{uuid} GET
POST
PUT
uuid
created
modified
voided
assigned_to
status
due_on
started
completed
concept
voided
subject
instruction
encounter

Related objects in POST and PUT Requests

POST and PUT requests for object fields where the field represents the related object will accept either the uuid string value or the object representation. Related field objects must be sent in POST requests prior to the object request.

POST data format

POST requests will accept the following as the request body

  • form-data
  • x-www-form-urlencoded
  • json

Testing

Requests can be sent to the server using any REST client, either as a browser plugin or from a command line.

Command Line - Curl

  • Example GET to localhost:
    curl --basic admin:Sanamobile1 -H "Accept: application/json" http://127.0.0.1:8000/core/concept/
  • Example POST to localhost:
    `curl -H "Accept: application/json" -H "Content-Type: application/json; charset=UTF-8" -X POST -d '{"username":"admin","password":"Sanamobile1"}' http://127.0.0.1:8000/core/session/

Browser Based Client

Most major browsers have a REST client plugin. For the Google Chrome browser, we recommend using the Postman REST Client, available in the Chrome web store. If using Postman, a sample collection may be downloaded here:

mds-current postman


The example collection will require setting up an environment with following parameters utilized in the request urls as {{scheme}}://{{host}}{{port}}/{{path_prefix}}

  • scheme http or https
  • host The ip address or hostname of the server
  • port Port value, normally empty but included ':' if not
  • path_prefix Normally should be mds/