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

API: Procedures

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

Procedure

A Procedure is the root document that the protocol builder creates. In a sense, it is the protocol itself. It contains information about the document and is made up of a series of pages.

Path

/api/procedures

Permissions

Only the user that owns the procedure may access or modify it.

Fields

Field Name Type Required? Default Value Read Only? Description
id int Yes Yes The unique id for this procedure.
title string Yes No The name for this procedure
author string No owner.first_name + ' ' + owner.last_name No The creator of this procedure
owner User Yes No The user that owns this procedure. This is inferred from the authorization token.
uuid uuid Yes Yes A unique identifier for this procedure. This value is auto-generated
created datetime Yes Yes The time that this object was created. This value is auto-generated
last_modified datetime Yes Yes The last time that this object was updated. This value is auto-generated.
pages list<Page> No [] No The pages that are contained within this procedure. This is auto-updated when a page is created that belongs to this procedure.

Creating

To create a procedure POST to /api/procedures.

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/procedures
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
  "title":"Untitled Procedure"
}

Example Response

{
  "id":7,
  "title":"Untitled Procedure",
  "author":"John Smith",
  "uuid":"bed18172-1723-4072-85b8-798616097667",
  "owner":6,
  "pages":[],
  "last_modified":"2016-03-05T18:44:51.230744Z",
  "created":"2016-03-05T18:44:51.230806Z"
}

Updating

To update a procedure PUT to /api/procedures/{id}, where id is the id of the procedure. 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: Procedure does not exist

Example Request

PUT /api/procedures/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
  "title":"My Procedure"
}

Example Response

{
  "id":7,
  "title":"My Procedure",
  "author":"John Smith",
  "uuid":"bed18172-1723-4072-85b8-798616097667",
  "owner":6,
  "pages":[],
  "last_modified":"2016-03-05T18:48:37.515686Z",
  "created":"2016-03-05T18:44:51.230806Z"
}

Deleting

To delete a procedure send a DELETE request to /api/procedures/{id} where the id is the id of the procedure to be deleted.

Status Codes

203: Object successfully deleted

401: Invalid Request Token

404: Procedure does not exist

Example Request

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

Example Response

No response body

Getting All

To get all procedures that you own GET to /api/procedures. If the only_return_id flag is provided and set to true as follows: ?only_return_id=true, then the response object's pages array will only contain page ids, and not the full serialized object.

Optional Flags

Flag Type Description
only_return_id boolean If set to true, array of pages returned on response will only contain page ids

Status Codes

200: Success

401: Invalid Request Token

Example Request

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

Example Response

[
  {
    "id":5,
    "title":"Untitled Procedure",
    "author":"No author specified",
    "uuid":"6841a13e-275d-4b17-a6f3-b0c2e8512d49",
    "owner":6,
    "pages":[
      {
        "id":12,
        "display_index":0,
        "last_modified":"2016-03-05T00:42:38.880071Z",
        "created":"2016-03-05T00:41:54.141476Z",
        "procedure":5
      },
      {
        "id":13,
        "display_index":1,
        "last_modified":"2016-03-05T00:42:53.808247Z",
        "created":"2016-03-05T00:42:53.808288Z",
        "procedure":5
      },
      {
        "id":14,
        "display_index":2,
        "last_modified":"2016-03-05T00:42:54.518141Z",
        "created":"2016-03-05T00:42:54.518178Z",
        "procedure":5
      }
    ],
    "last_modified":"2016-03-05T00:43:02.622411Z",
    "created":"2016-03-04T18:18:21.549666Z"
  },
  {
    "id":6,
    "title":"Untitled Procedure",
    "author":"a",
    "uuid":"3d66f932-9c43-4cb1-8c2d-3fb6eb23aa56",
    "owner":6,
    "pages":[

    ],
    "last_modified":"2016-03-05T18:44:20.723130Z",
    "created":"2016-03-05T18:37:58.466792Z"
  },
  {
    "id":7,
    "title":"My Procedure",
    "author":"John Smith",
    "uuid":"bed18172-1723-4072-85b8-798616097667",
    "owner":6,
    "pages":[

    ],
    "last_modified":"2016-03-05T18:48:37.515686Z",
    "created":"2016-03-05T18:44:51.230806Z"
  }
]

Get one

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

Status Codes

200: Success

401: Invalid Request Token

404: Procedure does not exist

Example Request

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

Example Response

{
    "id":7,
    "title":"My Procedure",
    "author":"John Smith",
    "uuid":"bed18172-1723-4072-85b8-798616097667",
    "owner":6,
    "pages":[],
    "last_modified":"2016-03-05T18:48:37.515686Z",
    "created":"2016-03-05T18:44:51.230806Z"
  }

Generating

To generate the XML protocol that a procedure represents, send a GET request to /api/procedures/{id}/generate, where id is the procedure id.

Status Codes

200: Success

400: Error in generation. See message for details.

401: Invalid Request Token

404: Procedure does not exist

Example Request

GET /api/procedures/7/generate
Host: sanaprotocolbuilder.me
Authorization: Token <token>

Example Response

<Procedure title="Radiology Examination" author="UP Manilla National Telehealth Center", uuid="bed18172-1723-4072-85b8-798616097667" version="2016-03-05T18:48:37.515686Z">
	<Page>
		<Element type="ENTRY" id="1" concept="CHIEF COMPLAINT" question="Chief Complaint:" answer=""/>
	</Page>
	<Page>
		<Element type="ENTRY" id="2" concept="HISTORY" question="Short History of Present Illness:" answer=""/>
	</Page>
	<Page>
		<Element type="ENTRY" id="3" concept="PHYSICAL FINDINGS" question="Physical Findings:" answer=""/>
	</Page>
	<Page>
		<Element type="ENTRY" id="4" concept="INITIAL DIAGNOSIS" question="Diagnosis:" answer=""/>
	</Page>
</Procedure>