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

...

Info

Generally returned summary lists are returned as Directories and single elements are returned as messages such as "EntryMsg"

Info

The following examples show how to have the output formatted to JSON with the "format=json" parameter.  When the format is not specified, it will default to XML.

DescriptionRESTModel Element Class
Code System Versions<base url>codesystemversions?format=jsonCodeSystemVersionCatalogEntryDirectory
Code System Read
<base url>/codesystem/NCI_Thesaurus/version/17.06d
CodeSystemVersionCatalogEntryMsg
Code System Version Query<base url>/codesystemversions?matchvalue=nci_thesaurus&filtercomponent=resourceName&format=jsonCodeSystemVersionCatalogEntryDirectory
Value Sets<base url>resolvedvaluesets?format=jsonResolvedValueSetDirectory
Value Set Definition Read<base url>/cts2/valueset/CDISC ADaM Terminology/definition/5f51c37b?format=jsonValueSetDefinitionMsg
Value Set Query
<base url>/resolvedvaluesets?matchvalue=imputation&filtercomponent=resourceName&format=json
ResolvedValueSetDirectory
Value Set Entries<base url>/valueset/valueset/CDISC Questionnaire Terminology/definition/aa5e7b3f/resolution/1?format=json
IteratableResolvedValueSet
Entities
<base url>/codesystem/NCI_Thesaurus/version/17.06d/entities?format=json
EntityDirectory
Entity Read<base url>/codesystem/NCI_Thesaurus/version/17.06d/entity/C3399?format=jsonEntityDescriptionMsg
Entity Query
<base url>/codesystem/NCI_Thesaurus/version/17.06d/entities?matchvalue=swelling&format=json
EntityDirectory
Association parents<base url>/codesystem/NCI_Thesaurus/version/17.06d/entity/C3399?format=json

EntityDescriptionMsg
with an instance entity with method calls:

entity.getEntityDescription().getNamedEntity().getParent()

returning an instance of URIAndEntityName[]

Association children
<base url>/codesystem/NCI_Thesaurus/version/17.06d/entity/C3399/children?format=json
EntityDirectory
Association subjectOf
<base url>/codesystem/npo/version/TestForMultiNamespace/entity/GO:NPO_1607/subjectof?format=json
AssociationDirectory
Association targetOf
<base url>/codesystem/NCI_Thesaurus/version/17.06d/entity/C3399/targetof?format=json
AssociationDirectory
Maps
<base url>/mapversions?format=json
MapVersionDirectory
Map Version Query<base url>/mapversions?matchvalue=ncit&filtercomponent=resourceSynopsis&format=jsonMapVersionDirectory
Map Version Read
<base url>/map/MA_to_NCIt_Mapping/version/MA_to_NCIt_Mapping-1.0?format=json
MapVersionMsg
Map Entities
<base url>/map/MA_to_NCIt_Mapping/version/MA_to_NCIt_Mapping-1.0/entries?format=json
 MapEntryDirectory 
Map Restriction To, From, or Both Role
<base url>/mapversions?codesystem=ICD10CM&codesystemsmaprole=MAP_TO_ROLE&format=json
MapVersionDirectory

...

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