How to get a theta/T-Score for custom measures through the API
Syntax
- https://promis.consultlia.com//2013-01/Scores/{FormOID}.xml - returns the specified form in xml format
- https://promis.consultlia.com//2013-01/Scores/{FormOID}.json - returns the specified form in json format
Remarks
FormOID is the key returned from a call to the https://promis.consultlia.com//2014-01/Forms/.{json|xml} API.
POST Item data as Key Value pairs: Key= Item ID (i.e. Form.Items[i].ID) and Value = Map Descriptions (i.e. Form.Items[i].Elements[j].Map[k].Description) to the endpoint for all items that are to be scored.
POST responses are case-sensitive.
T-Score = Theta * 10 + 50.0
Standard Error = StdError * 10
ItemCount contains the number of items processed
ItemErrors contains the [itemid:response] for items not processed
API Home Try it!Sample code for https://promis.consultlia.com//2013-01/Scores
<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://promis.consultlia.com/;
var FormOID = "9BA1259E-11ED-42CB-B686-0EB81175236E"; // PROMIS Global Physical Health Items
function calculateScore(FormOID) {
$.ajax({
url: Server + "/2013-01/Scores/" + FormOID + ".json",
cache: false,
type: "POST",
data: "Global07r=7&Global03=Good&Global06=Not at all&Global08r=Very severe",
dataType: "json",
beforeSend: function(xhr) {
var reg = document.getElementById("txtRegistration").value;
var token = document.getElementById("txtToken").value;
var bytes = Crypto.charenc.Binary.stringToBytes(reg + ":" + token);
var base64 = Crypto.util.bytesToBase64(bytes);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data) {
//Response from Scores endpoint: data = "{"Form":[{"Theta":"-2.34906908578432","StdError":"0.537179330208796"}]}";
var container = document.getElementById("Content");
var _div = document.createElement("div");
_div.appendChild(document.createTextNode(" Theta (" + data.Form[0].Theta + ") Error (" + data.Form[0].StdError + ")"));
container.appendChild(_div);
},
error: function(jqXHR, textStatus, errorThrown) {
alert('displayScore:' + 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 FormOID = "9BA1259E-11ED-42CB-B686-0EB81175236E"; // Sample Form -- PROMIS Global Physical Health Items
string API_URL = "https://promis.consultlia.com//2013-01/Scores/" + FormOID + ".xml";
string authstring = Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", REGISTRATIONID, TOKEN)));
ServicePointManager.Expect100Continue = false;
Byte[] postbytes = Encoding.ASCII.GetBytes("Global07r=7&Global03=Good&Global06=Not at all&Global08r=Very severe");
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));
}
}
// Requesting the score for the PROMIS Global Physical Health Items
Request:https://promis.consultlia.com//2013-01/Scores/9BA1259E-11ED-42CB-B686-0EB81175236E.json
Response:
Request:https://promis.consultlia.com//2013-01/Scores/9BA1259E-11ED-42CB-B686-0EB81175236E.json
Response:
{"Form":[{"Theta":"-2.34906908578432","StdError":"0.537179330208796", "ItemCount":"4","ItemErrors":""}]}
Based on the following data sent to the endpoint:
Global07r=7
Global03=Good
Global06=Not at all
Global08r=Very severe
// Requesting the score for the PROMIS Global Physical Health Items
Request:https://promis.consultlia.com//2013-01/Scores/9BA1259E-11ED-42CB-B686-0EB81175236E.xml
Response:
Request:https://promis.consultlia.com//2013-01/Scores/9BA1259E-11ED-42CB-B686-0EB81175236E.xml
Response:
<Form>
<ScoredItem Theta="-2.34906908578432" StdError="0.537179330208796" ItemCount="4" ItemErrors="/>
</Form>
Based on the following data sent to the endpoint:
Global07r=7
Global03=Good
Global06=Not at all
Global08r=Very severe