NIH | National Cancer Institute | NCI Wiki  

Error rendering macro 'rw-search'

null

Versions Compared

Key

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

...

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

conn = Connection("http://http://lexevscts2.nci.nih.gov/lexevscts2")
reply = conn.request_get("/valuesets")
if reply['headers']['status'] == '200':
    print reply['body']


conn = Connection("http://http://lexevscts2.nci.nih.gov/lexevscts2")
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://http://lexevscts2.nci.nih.gov/lexevscts2")
print conn.request_get("/valuesets?matchvalue='Sequence'")['body']

JavaScript (JQuery and Bootstrap.js)

Warning

This script example features JSON parsing.  The JSON structure in CTS2 1.0 was non-standard and will not be compatible with the standardized JSON in CTS2 1.1.  CTS2 XML is standard.  CTS2 associated with LexEVS 6.2 will contain the standard version of JSON for CTS 1.1.

 

  • Download JQuery 1.10.x
    Multiexcerpt include
    MultiExcerptNameExitDisclaimer
    nopaneltrue
    PageWithExcerptwikicontent:Exit Disclaimer to Include
    and Bootstrap 3.0.x
    Multiexcerpt include
    MultiExcerptNameExitDisclaimer
    nopaneltrue
    PageWithExcerptwikicontent:Exit Disclaimer to Include
  • Create a CTSRest directory for your files
  • Add directories bootstrap and cts2 to this root
  • Add subdirectories js and css to both directories you've just created
  • Add bootstrap.js to the bootstrap/js directory
  • Add bootstrap.min.css to the bootstrap/css directory
  • Add jquery-1.10.2.js to the cts2/js library
  • Create a codeSystem.js text file and add the following text (adjust the serviceUrl to point to a convenient CTS2 service)
Code Block
languagejavascript
titleJavaScript REST Client
collapsetrue
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>");
                }
            });
        });
}
  • when complete add codesystem.js to the cts2/js directory
  • Create a new html file containing the following html and add it to the root CTSRest folder

...

languagehtml/xml
titleHTML
collapsetrue

...

  • Open the new HTML file in a browser and you should see code systems displayed on a browser page.

Warning
titleTroubleshooting

If this page shows errors in your browser's debugging tools, you may have extraneous characters in your text file. Try removing all indentations, save and run again.

Unix Command Line

returns XML that can be piped to a file

...

Code Systems Bulk Download

Example

Map Bulk Download

Example

Parameters for Rest Call

URL:

...