NIH | National Cancer Institute | NCI Wiki  

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

REST calls are not platform specific.  They can be integrated into a wide variety of platforms. 

  • Browser
  • Java
  • Scala
  • Python
  • JavaScript
  • Unix Command line
  • Any platform able to handle REST calls and XML or JSON formatted responses

...

Code Block
languagepython
titlePython REST Client
collapsetrue
__author__ = 'sbauer'
from restful_lib import Connection

conn = Connection("http://informatics.mayo.edu/cts2/rest")
reply = conn.request_get("/valuesets")
if reply['headers']['status'] == '200':
    print reply['body']


conn = Connection("http://informatics.mayo.edu/cts2/rest")
reply = conn.request_get("/valuesets?format=json",headers={'Accept':'application/json;q=1.0'})
if reply['headers']['status'] == '200':
    print reply['body']
    print eval(reply['body'])

conn = Connection("http://informatics.mayo.edu/cts2/rest")
print conn.request_get("/valuesets?matchvalue='Sequence'")['body']'] == '200':
    print reply['body']
    print eval(reply['body'])

conn = Connection("http://informatics.mayo.edu/cts2/rest")
print conn.request_get("/valuesets?matchvalue='Sequence'")['body']

JavaScript (JQuery and Bootstrap.js)

Code Block
languagejavascript
linenumberstrue
var CodeSystemListConfig = {
    serviceUrl: "http://<base url>/codesystemversions?format=json"
};

function init() {

    $(document).ready(
        function() {
            var url = CodeSystemListConfig.serviceUrl;
            $.getJSON(url + "&callback=?", function (data) {

                for (var i in data.codeSystemVersionCatalogEntryDirectory.entryList) {
                    var entry = data.codeSystemVersionCatalogEntryDirectory.entryList[i];
                    var key = entry.formalName;
                    var designation = entry.documentURI;
                    var uri = entry.href;
                    $("ul").append("<li><a href=\"" + uri +"\">" + key + "</a></li>");
                }
            });
        });
}
Code Block
languagehtml/xml
titleHTML
linenumberstrue
<!DOCTYPE html>
<html>
<head>
    <title>Code System</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <script src="cts2/js/codeSystem.js"></script>
    <script src="cts2/js/jquery-1.10.2.js"></script>
</head>
<body>
<h1>Code Systems</h1>
<script>init()</script>
<ul class="nav nav-pills nav-stacked">
    <li class="active"><a href="#">Home</a></li>
</ul>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>

 

Unix Command Line

returns XML that can be piped to a file

...

Code Block
collapsetrue
<IteratableResolvedValueSet xmlns="http://schema.omg.org/spec/CTS2/1.0/ValueSetDefinition" xmlns:core="http://schema.omg.org/spec/CTS2/1.0/Core"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.omg.org/spec/CTS2/1.0/ValueSetDefinition http://www.omg.org/spec/cts2/201206/valuesetdefinition/ValueSetDefinition.xsd" complete="PARTIAL" numEntries="50" next="http://<base url>/valueset/NICHD Newborn Screening Terminology/definition/4125c982/resolution/1?page=1&maxtoreturn=50">
<core:heading>
<core:resourceRoot>
valueset/NICHD Newborn Screening Terminology/definition/4125c982/resolution/1
</core:resourceRoot>


<core:resourceURI>
http://<base url>/valueset/NICHD Newborn Screening Terminology/definition/4125c982/resolution/1
</core:resourceURI>


<core:accessDate>2013-09-13T16:54:52.357-05:00</core:accessDate>

</core:heading>


<resolutionInfo>
<resolutionOf>
<core:valueSetDefinition uri="http://ncit:C89506" href="http://<base url>/valueset/NICHD Newborn Screening Terminology/definition/4125c982">4125c982</core:valueSetDefinition>
<core:valueSet>NICHD Newborn Screening Terminology</core:valueSet>

</resolutionOf>



</resolutionInfo>


<entry uri="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C16847" href="http://<base url>/codesystem/NCI_Thesaurus/version/10.07e/entity/NCI_Thesaurus:C16847">
<core:namespace>NCI_Thesaurus</core:namespace>
<core:name>C16847</core:name>
<core:designation>Technique</core:designation>

</entry>


<entry uri="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C34816" href="http://<base url>/codesystem/NCI_Thesaurus/version/10.07e/entity/NCI_Thesaurus:C34816">
<core:namespace>NCI_Thesaurus</core:namespace>
<core:name>C34816</core:name>
<core:designation>Congenital Metabolic Disorder</core:designation>

</entry>


<entry uri="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C81178" href="http://<base url>/codesystem/NCI_Thesaurus/version/10.07e/entity/NCI_Thesaurus:C81178">
<core:namespace>NCI_Thesaurus</core:namespace>
<core:name>C81178</core:name>
<core:designation>Newborn Screening</core:designation>

</entry>


<entry uri="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C50644" href="http://<base url>/codesystem/NCI_Thesaurus/version/10.07e/entity/NCI_Thesaurus:C50644">
<core:namespace>NCI_Thesaurus</core:namespace>
<core:name>C50644</core:name>
<core:designation>Lung Overinflation</core:designation>

</entry>


<entry uri="http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C13235" href="http://<base url>/codesystem/NCI_Thesaurus/version/10.07e/entity/NCI_Thesaurus:C13235">
<core:namespace>NCI_Thesaurus</core:namespace>
<core:name>C13235</core:name>
<core:designation>Fetus</core:designation>

</entry>