How to find a list of forms that are available through the API
Syntax
- https://assessmentcenter.net/ac_api/2014-01/Forms/ - returns a list of all forms (i.e. OID and Name).
- https://assessmentcenter.net/ac_api/2014-01/Forms/{.xml or .json} - returns a list of all forms in the specified format.
(i.e. https://assessmentcenter.net/ac_api/2014-01/Forms/.json) - https://assessmentcenter.net/ac_api/2014-01/Forms/{OID} - returns the specified form as an html page
- https://assessmentcenter.net/ac_api/2014-01/Forms/{OID}.xml - returns the specified form in xml format
- https://assessmentcenter.net/ac_api/2014-01/Forms/{OID}.json - returns the specified form in json format
Remarks
If the FormOID does not match an available form, then the list of all forms is returned. If Requests parameter "Properties" is used (i.e. ?Properties=true), then metadata for the forms is displayed. The following metadata attributes are displayed, when available:- Engine - Administration class used to by Participants endpoint
- Event - Scoring component
- Method - Scoring component method (i.e. after each item or after the end of the form)
- Category - (see Category on http://www.healthmeasures.net/search-view-measures)
- Domain - (see Domain http://www.healthmeasures.net/search-view-measures)
- Population - (see Age http://www.healthmeasures.net/search-view-measures)
- Assessment_Type - (see Measure Type http://www.healthmeasures.net/search-view-measures)
- Measurement_System - (see Measurement System http://www.healthmeasures.net/search-view-measures)
- Locale - (see Language http://www.healthmeasures.net/search-view-measures)
Sample code for https://assessmentcenter.net/ac_api/2014-01/Forms
<script langauge="javascript" src="jquery-1.7.1.min.js"></script> <script language="javascript" src="crypto.js"></script> <script type='text/javascript' version='1.3'> var Server = https://assessmentcenter.net/ac_api; var FormOID = "D2FA612D-C290-4B88-957D-1C27F48EE58C"; // Sample form -- replace with your FormOID function listForms() { $.ajax({ url: Server + "/2014-01/Forms/.json", cache: false, type: "POST", data: "", dataType: "json", beforeSend: function(xhr) { var bytes = Crypto.charenc.Binary.stringToBytes(document.getElementById("txtRegistration").value + ":" + document.getElementById("txtToken").value); var base64 = Crypto.util.bytesToBase64(bytes); xhr.setRequestHeader("Authorization", "Basic " + base64); }, success: function(data) { var container = document.getElementById("Content"); var forms = data.Form; for (var i=0; i < forms.length; i++) { var myform = document.createElement("div"); myform.innerHTML = forms[i].OID + " : " + forms[i].Name + ""; container.appendChild(myform); } }, error: function(jqXHR, textStatus, errorThrown) { document.write(jqXHR.responseText + ':' + textStatus + ':' + errorThrown); } }) } function formDetails(FormOID) { $.ajax({ url: Server + "Forms/" + FormOID + ".json", cache: false, type: "POST", data: "", dataType: "json", beforeSend: function(xhr) { var bytes = Crypto.charenc.Binary.stringToBytes(document.getElementById("txtRegistration").value + ":" + document.getElementById("txtToken").value); var base64 = Crypto.util.bytesToBase64(bytes); xhr.setRequestHeader("Authorization", "Basic " + base64); }, success: function(data) { var container = document.getElementById("Content"); for (var k = container.childNodes.length - 1 ; k > -1; k--) { container.removeChild(container.childNodes[k]) } for (var i = 0; i < data.Items.length; i++) { var _div = document.createElement("div"); _div.appendChild(document.createTextNode(data.Items[i].ID + ":")); for (var j = 0; j < data.Items[i].Elements.length; j++) { if (typeof(data.Items[i].Elements[j].Map) == "undefined") { var _p = document.createElement("p"); _p.innerHTML = data.Items[i].Elements[j].Description; _div.appendChild(_p); } else { var _p = document.createElement("p"); for (var n = 0; n < data.Items[i].Elements[j].Map.length; n++) { _p.innerHTML += "(" + data.Items[i].Elements[j].Map[n].Value + "):"+ data.Items[i].Elements[j].Map[n].Description + " " ; } _div.appendChild(_p); } } container.appendChild(_div); } }, error: function(jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText + ':' + textStatus + ':' + errorThrown); } }) }
Based on twillio example to call RESTful services. (http://www.twilio.com/docs/api/rest)
using System; using System.Collections; using System.Configuration; using System.IO; using System.Net; using System.Web; using System.Text; using System.Text.RegularExpressions; public class TestHarness { static void Main(string[] args) { string REGISTRATIONID ="31839849-ECE0-4F5E-BEAE-3D655ED65E31"; // Sample registration -- replace with your RegistrationOID string TOKEN ="F3738486-5A7D-41EF-8044-DCBAF800E2D4"; // Sample token -- replace with your TokenOID string API_URL = "https://assessmentcenter.net/ac_api/2014-01/Forms/.json"; string authstring = Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", REGISTRATIONID, TOKEN))); ServicePointManager.Expect100Continue = false; Byte[] postbytes = Encoding.ASCII.GetBytes(string.Empty); WebClient client = new WebClient(); client.Headers.Add("Authorization", String.Format("Basic {0}", authstring)); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); byte[] resp = client.UploadData(API_URL, "post", postbytes); Console.WriteLine(Encoding.ASCII.GetString(resp)); } }
Request:https://assessmentcenter.net/ac_api/2014-01/Forms/.json
Response:
Response:
{ "Form": [ { "OID": "C4ADCFAB-6B75-498E-9E94-AFD3BA211DC4", "Name": "PROMIS Bank v1.0 - Pain Behavior" }, { "OID": "29654543-C99B-4CE9-884B-3D401B4AD857", "Name": "PROMIS Bank v2.0 - Emotional Support" }, ... { "OID": "96FE494D-F176-4EFB-A473-2AB406610626", "Name": "PROMIS Bank v1.0 - Depression" } ] }
// Requesting one form to be returned as an "Items" array Request:https://assessmentcenter.net/ac_api/2014-01/Forms/C4ADCFAB-6B75-498E-9E94-AFD3BA211DC4.json
Response:
{ "DateFinished": "", "Items": [ { "FormItemOID": "77C86585-CAFF-43C3-80B0-1023496FAED2", "ID": "PAINBE2", "Order": "1", "Elements": [ { "ElementOID": "8AB8BA58-3BB0-40B6-B656-C24F1169069B", "Description": "In the past 7 days", "ElementOrder": "1" }, { "ElementOID": "3AD1A30F-4E80-4DFE-8099-B3294F2BF4E0", "Description": "When I was in pain I became irritable", "ElementOrder": "2" }, { "ElementOID": "C54EF195-0904-4A9A-9789-510D2F2894A5", "Description": "ContainerForC54EF195-0904-4A9A-9789-510D2F2894A5", "ElementOrder": "3", "Map": [ { "ElementOID": "3D86FC4B-516C-42AF-A5EA-028339A0B123", "Description": "Had no pain", "FormItemOID": "77C86585-CAFF-43C3-80B0-1023496FAED2", "ItemResponseOID": "B153BE2F-4CEB-4C86-9CB4-20534298DF48", "Value": "1", "Position": "1" }, { "ElementOID": "C279A7CB-A5C4-4211-B615-0B1090AE91C8", "Description": "Never", "FormItemOID": "77C86585-CAFF-43C3-80B0-1023496FAED2", "ItemResponseOID": "F4CE265C-EC1A-4AC1-A3A4-D25143D283C5", "Value": "2", "Position": "2" }, ... { "ElementOID": "D1288A7D-DFB4-4D89-B2BE-3C6CE2776F2C", "Description": "Always", "FormItemOID": "77C86585-CAFF-43C3-80B0-1023496FAED2", "ItemResponseOID": "080AC0B0-7054-49D4-A4EC-6541D783B5BB", "Value": "6", "Position": "6" } ] } ] }, ... { "FormItemOID": "39DD369B-9236-49D2-96F2-BD96806F0D96", "ID": "PAINBE51", "Order": "39", "Elements": [ { "ElementOID": "8AB8BA58-3BB0-40B6-B656-C24F1169069B", "Description": "In the past 7 days", "ElementOrder": "1" }, { "ElementOID": "E9BFAA13-B51E-4382-9A7E-AEA5AA8C9FFE", "Description": "When I was in pain I avoided physical contact with others", "ElementOrder": "2" }, { "ElementOID": "C54EF195-0904-4A9A-9789-510D2F2894A5", "Description": "ContainerForC54EF195-0904-4A9A-9789-510D2F2894A5", "ElementOrder": "3", "Map": [ { "ElementOID": "3D86FC4B-516C-42AF-A5EA-028339A0B123", "Description": "Had no pain", "FormItemOID": "39DD369B-9236-49D2-96F2-BD96806F0D96", "ItemResponseOID": "7CE2E456-84D4-4AAC-AF19-76814560DC1F", "Value": "1", "Position": "1" }, ... { "ElementOID": "D1288A7D-DFB4-4D89-B2BE-3C6CE2776F2C", "Description": "Always", "FormItemOID": "39DD369B-9236-49D2-96F2-BD96806F0D96", "ItemResponseOID": "3C3730F8-E980-4097-8CDB-A869FDCF4C6D", "Value": "6", "Position": "6" } ] } ] } ] }
// Requesting all forms available to be returned as "Form" nodes
Request:https://assessmentcenter.net/ac_api/2014-01/Forms/.xml
Response:
Request:https://assessmentcenter.net/ac_api/2014-01/Forms/.xml
Response:
<?xml version="1.0" encoding="utf-8"?> <forms> <form OID="C4ADCFAB-6B75-498E-9E94-AFD3BA211DC4" name="PROMIS Bank v1.0 - Pain Behavior" /> <form OID="29654543-C99B-4CE9-884B-3D401B4AD857" name="PROMIS Bank v2.0 - Emotional Support" /> <form OID="9DA933EC-4E3B-4409-8785-9D692010B7A2" name="PROMIS Ped Bank v1.0 - Peer Rel" /> <form OID="037D7B69-FCB2-482E-A1CE-9A4D017D24AD" name="Neuro-QOL Ped Bank v1.0 - Anxiety" /> </forms>