RadLex API

From MircWiki
Revision as of 13:58, 14 June 2007 by Rboden (Talk | contribs) (Reverted edits by TfpO1l (Talk); changed back to last version by Johnpaulett)

Jump to: navigation, search

Warning: This documentation is currently being updated to reflect version 2 of the servlet.

The RadLex API acts as a webservice, which allows developers to query the RadLex terminology and retrieve an XML response. For more information about the RadLexID's, see RadLex Term Browser#RadLex URI's. The servlets treat HTTP GET's and POST's the same, so while the examples use GET requests, you are free to use HTTP POST request (POST's are merely redirected to GET's by the servlet).

As a convention for this API, elements preceded by a dollar sign ($) are variable content.

1 API Methods

1.1 getTermByID

URL: http://radlex.org/getTermByID


  • radlexID - the RadLex ID to obtain in the form "^RID([0-9] )$"

Return: #<term> structure.

Notes: Obtains all information pertaining to the radlexID in the terminology.

1.2 getTree

URL: http://radlex.org/getTree


  • relationType - the type of relation the tree should show.
  • (baseID) - optional. The RadLex ID to start the tree at. Default: RID0
  • (radlexID) - optional. The RadLex ID to enumerate the tree to.

Return: #<links> structure.

Notes: Returns a tree structure that represents the terms and their relationships. It returns all links starting with the baseID as the root term related via the relationType. If no radlexID is present only a single layer of children below the baseID term will be returned. If radlexID is present, all nodes that will create the structure from the baseID term to the radlexID term are given—this is "filled" out with the children of the nodes above the radlexID level. That is, if baseID = A and radlexID = a1, and A has children a, b, c, d, and a has children a1, a2, a3. The links of all of A’s children will be given, followed by all of a’s children. If no baseID is given, the root term for the terminology ("RID0") is used.

1.3 getChildren

URL: http://radlex.org/getChildren


  • radlexID - the RadLex term for which you which to find its children
  • (relationType) - optional. The relation that the children must have with the radlexID term. Default: all relationships

Return: #<children> structure. All the children of the radlexID, based upon the relationType (if defined)

Notes: Serves as an extension of the getTree method, by allowing the program to see one level farther down the tree. Calls to the #getTermByID method, automatically include any child information.

1.4 search

URL: http://radlex.org/search


  • query - string to search for in the database

Return: See notes below. <terms> structure.

Notes: Performs a search on the database for the query' term or phrase.

  • If the query matches "^RID([0-9] )$", a search for that radlexID is performed, which should yield 0 or 1 results. If 1 result is found, the search exits and returns that one value.
  • If the query has fewer than 4 characters, the database is queried via several LIKE statements. The 4 character minimum is a result of MySQL's Fulltext Search default limit. The query will return all, if any, matches and exit the search.
  • If the search has not already been exited, a MySQL Fulltext Search will be initiated on the database. This is the preferred method, as it uses MySQL's native natural language search (MySQL Documentation).

1.5 getRelationTypes

URL: http://radlex.org/getRelationTypes

Parameters: none

Return: #<relationTypes> structure.

Notes: Returns all the types of relationships that are currently used or supported in the terminology.

1.6 getTotalNumberOfTerms

URL: http://radlex.org/getTotalNumberOfTerms

Parameters: none

Return: A number, not enclosed in any xml, of the number of RadLex terms in the database.

Notes: Returns the number of terms that are in the terminology.

2 Return Structures

2.1 Notes

2.1.1 Boolean values

Boolean values are represented as 0 (=false) or 1 (=true)

2.2 <term>

<term id="$radlexID">
   <acr id="$acrTermID">$acrTermName</acr>
   <snomed id="$snomedTermID">$snomedTermName</snomed>
   <umls id="$umlsTermID">$umlsTermName</umls>
      <parent id="$parentsRadlexID" relationType="$relationWithParent" preferred="$0_or_1">$parentName</parent>
      <child id="$childRadlexID" relationType="$relationWithChild" preferred="$0_or_1" childIsParent="$0_or_1">$childName</child>

See #<children> for information on childIsParent

2.3 <terms>

   <term id="$termsID" preferredid="$preferredID">$termName</term>
  • preferredid represents the term that is considered the 'main' term by RadLex. Cases where the id and preferredid differ are usually when the term is a synonym. Since a synonym is not considered a 'main' term by RadLex, the <terms> structure points the user in the direction of the term that is the 'main' term.

2.4 <children>

<children parent="$parentRID">
   <child id="$radlexID" relationType="$relationType" preferred="$0_or_1" childIsParent="$0_or_1">
  • childIsParent - indicates if the term is itself a parent. If childIsParent=1, there are children of the $radlexID given this $relationType

2.5 <links>

   <link parent="$parentID" id="$radlexID" relationType="$relationType" preferred="$0_or_1" childIsParent="$0_or_1">$termName</link>

See #<children> for information on childIsParent

2.6 <relationTypes>


2.7 <error>

For a more detailed discussion of error messages, see below.

   <error id="$errorid">$errormessage</error>

3 Errors

When there has been an error processing an API request, the server will respond with a generic error message, explaining the problem. For the #<error> return format

error id meaning
1 RadLex ID is not valid
2 Radlex ID could not be found
3 Relationship type is not valid
4 Database connection error
5 Insufficient http get parameters.
6 No search results matching query

4 Current Relation Types

  • preferred - indicates that the parent-child relationship is preferred. The preferred status usually highlights that one of the other relations is preferred. There are cases where another relation has not yet been defined (but eventually should be).
  • isa
  • partof
  • branchof
  • segmentof
  • tributaryof
  • continuouswith
  • containedin
  • memberof
  • synonymof

5 Examples

5.1 getTermByID Example

I want to get all the details about Thorax. So, I construct a GET request using RID1243, for Thorax:


And the server responds with:

<term id="RID1243">
   <comment>child of anatomic location</comment>
   <acr id=""/>
   <snomed id=""/>
   <umls id=""/>
      <parent id="RID3" relationType="" preferred="1">anatomic location</parent>
      <child id="RID1245" relationType="continuouswith" preferred="1" childIsParent="1">airway</child>
      <child id="RID1524" relationType="continuouswith" preferred="1" childIsParent="1">diaphragm</child>
      <child id="RID1530" relationType="continuouswith" preferred="1" childIsParent="1">diaphragmatic sulcus</child>
      <child id="RID1301" relationType="continuouswith" preferred="1" childIsParent="1">lung</child>
      <child id="RID1384" relationType="continuouswith" preferred="1" childIsParent="1">mediastinum</child>
      <child id="RID1362" relationType="continuouswith" preferred="1" childIsParent="1">pleura</child>
      <child id="RID1463" relationType="continuouswith" preferred="1" childIsParent="1">thoracic lymph node</child>
      <child id="RID1244" relationType="synonymof" preferred="0" childIsParent="0">chest</child>

5.2 getTree Example

I want to find all the terms between the root of the terminology (RID0) and anatomic location, so I construct a GET request using getTree: