RadLex API

From MircWiki
Revision as of 01:15, 11 May 2007 by Johnpaulett (talk | contribs)
Jump to navigation Jump to 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

Parameters:

  • 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

Parameters:

  • 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

Parameters:

  • 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

Parameters:

  • 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">
   <name>$termName</name>
   <uri>$URItoTerm</uri>
   <definition>$termDefinition</definition>
   <comment>$termComment</comment>
   <source>$sourceOfTerm</source>
   <dateCreated>$dateTermCreated</dateCreated>
   <termStatus>$statusOfTerm</termStatus>
   <versionNumber>$termVersionNumber</versionNumber>
   <acr id="$acrTermID">$acrTermName</acr>
   <snomed id="$snomedTermID">$snomedTermName</snomed>
   <umls id="$umlsTermID">$umlsTermName</umls>
   <parents>
      <parent id="$parentsRadlexID" relationType="$relationWithParent" preferred="$0_or_1">$parentName</parent>
      ...
   </parents>
   <children>
      <child id="$childRadlexID" relationType="$relationWithChild" preferred="$0_or_1" childIsParent="$0_or_1">$childName</child>
      ...
   </children>
</term>

See #<children> for information on childIsParent

2.3 <terms>

<terms>
   <term id="$termsID" preferredid="$preferredID">$termName</term>
   ...
</terms>
  • 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">
      $termName
   </child>
   ...
</children>
  • childIsParent - indicates if the term is itself a parent. If childIsParent=1, there are children of the $radlexID given this $relationType

2.5 <links>

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

See #<children> for information on childIsParent

2.6 <relationTypes>

<relationTypes>
   <relationType>$nameOfType</relationType>
   ...
</relationTypes>

2.7 <error>

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

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


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:

http://radlex.org/getTermByID?radlexID=RID1243

And the server responds with:

<term id="RID1243">
   <name>thorax</name>
   <uri>http://radlex.org/RID1243</uri>
   <definition></definition>
   <comment>child of anatomic location</comment>
   <source/>
   <dateCreated/>
   <termStatus/>
   <versionNumber/>
   <acr id=""/>
   <snomed id=""/>
   <umls id=""/>
   <parents>
      <parent id="RID3" relationType="" preferred="1">anatomic location</parent>
   </parents>
   <children>
      <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>
   </children>
</term>


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:

http://radlex.org/getTree?relationType=preferred