NIH | National Cancer Institute | NCI Wiki  

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
Code Block
languagehtml/xml
titleHTML
collapsetrue
<!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>
  • 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 Block
collapsetrue
{
    "IteratableResolvedValueSet": {
        "resolutionInfo": {
            "resolutionOf": {
                "valueSetDefinition": {
                    "content": "2856f3ed",
                    "uri": "http://evs.nci.nih.gov/valueset/C81223",
                    "href": "https://lexevscts2.nci.nih.gov/lexevscts2/valueset/CDISC ADaM Date Imputation Flag Terminology/definition/2856f3ed"
                },
                "valueSet": {
                    "content": "CDISC ADaM Date Imputation Flag Terminology"
                }
            },
            "resolvedUsingCodeSystem": [
                {
                    "version": {
                        "content": "NCI_Thesaurus-17.06d"
                    },
                    "codeSystem": {
                        "content": "NCI_Thesaurus",
                        "uri": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#"
                    }
                }
            ]
        },
        "entry": [
            {
                "uri": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C81210",
                "href": "https://lexevscts2.nci.nih.gov/lexevscts2/codesystem/NCI_Thesaurus/version/17.06d/entity/NCI_Thesaurus:C81210",
                "namespace": "NCI_Thesaurus",
                "name": "C81210",
                "designation": "Year Month Day Imputed"
            },
            {
                "uri": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C81211",
                "href": "https://lexevscts2.nci.nih.gov/lexevscts2/codesystem/NCI_Thesaurus/version/17.06d/entity/NCI_Thesaurus:C81211",
                "namespace": "NCI_Thesaurus",
                "name": "C81211",
                "designation": "Month Day Imputed"
            },
            {
                "uri": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C81212",
                "href": "https://lexevscts2.nci.nih.gov/lexevscts2/codesystem/NCI_Thesaurus/version/17.06d/entity/NCI_Thesaurus:C81212",
                "namespace": "NCI_Thesaurus",
                "name": "C81212",
                "designation": "Day Imputed"
            }
        ],
        "complete": "COMPLETE",
        "numEntries": 3,
        "heading": {
            "resourceRoot": "https://lexevscts2.nci.nih.gov/lexevscts2/",
            "resourceURI": "valueset/CDISC ADaM Date Imputation Flag Terminology/definition/2856f3ed/resolution/1",
            "parameter": [
                {
                    "arg": "format",
                    "val": "json"
                }
            ],
            "accessDate": "2017-08-07T11:38:21.389-04:00"
        }
    }

}

CTS2 Bulk Term Download Extension

LexEVS 6.1 features a bulk download REST interface that is an extension to the LexEVS CTS2 service. It provides users with the ability to download entire term sets from a given coding scheme or map to a text file

Code Systems Bulk Download

Example

Map Bulk Download

Example

Parameters for Rest Call

URL:

  • /lexevscts2/exporter/codingscheme or
  • /lexevscts2/exporter/map

Parameters:

codingschemes or map - (Optional) CodingSchemes or map to include (comma-separated). Default: all

fields - (Optional) Content fields to output. Default: [code, namespace, description, codingschemename, codingschemeuri, codingschemeversion]

separator -(Optional) One character field separator. Default: |

filename - (Optional) Output file name. Default: terminology-bulk-download.txt

Scrollbar
iconsfalse