Difference between revisions of "RadLex API"

From MircWiki
Jump to navigation Jump to search
Line 97: Line 97:
 
=== <term> ===
 
=== <term> ===
 
<pre><nowiki>
 
<pre><nowiki>
<term id="RID1243">
+
<term id="$radlexID">
   <name>thorax</name>
+
   <name>$termName</name>
   <uri>http://radlex.org/RID1243</uri>
+
   <uri>$URItoTerm</uri>
   <definition></definition>
+
   <definition>$termDefinition</definition>
   <comment>child of anatomic location</comment>
+
   <comment>$termComment</comment>
   <source/>
+
   <source>$sourceOfTerm</source>
   <dateCreated/>
+
   <dateCreated>$dateTermCreated</dateCreated>
   <termStatus/>
+
   <termStatus>$statusOfTerm</termStatus>
   <versionNumber/>
+
   <versionNumber>$termVersionNumber</versionNumber>
   <acr id=""/>
+
   <acr id="$acrTermID">$acrTermName</acr>
   <snomed id=""/>
+
   <snomed id="$snomedTermID">$snomedTermName</snomed>
   <umls id=""/>
+
   <umls id="$umlsTermID">$umlsTermName</umls>
 
   <parents>
 
   <parents>
       <parent id="RID3" relationType="" preferred="1">anatomic location</parent>
+
       <parent id="$parentsRadlexID" relationType="$relationWithParent" preferred="$0_or_1">$parentName</parent>
 
       ...
 
       ...
 
   </parents>
 
   </parents>
 
   <children>
 
   <children>
       <child id="RID1245" relationType="continuouswith" preferred="1" childIsParent="1">airway</child>
+
       <child id="$childRadlexID" relationType="$relationWithChild" preferred="$0_or_1" childIsParent="$0_or_1">$childName</child>
 
       ...
 
       ...
 
   </children>
 
   </children>
 
</term>
 
</term>
 
</nowiki></pre>
 
</nowiki></pre>
 +
See [[#<children>]] for information on ''childIsParent''
  
 
=== <terms> ===
 
=== <terms> ===
 
<pre><nowiki>
 
<pre><nowiki>
 +
<terms>
 +
  <term id="$termsID" preferredid="$preferredID">$termName</term>
 +
  ...
 +
</terms>
 
</nowiki></pre>
 
</nowiki></pre>
 +
* ''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.
  
 
=== <children> ===
 
=== <children> ===
Line 133: Line 139:
 
</children>
 
</children>
 
</nowiki></pre>
 
</nowiki></pre>
childIsParent - indicates if the term is itself a parent.  If childIsParent=1, there are children of the $radlexID given this $relationType
+
* ''childIsParent'' - indicates if the term is itself a parent.  If childIsParent=1, there are children of the $radlexID given this $relationType
  
 
=== <links> ===
 
=== <links> ===
Line 230: Line 236:
 
</term>
 
</term>
 
</nowiki></pre>
 
</nowiki></pre>
 +
  
 
=== getChildren Example ===
 
=== getChildren Example ===
Line 245: Line 252:
 
</children>
 
</children>
 
</nowiki></pre>
 
</nowiki></pre>
 +
 +
 +
=== search Example ===
 +
I want to search the database for "tibia", so I use the [[#search]] method:
 +
<pre><nowiki>
 +
http://radlex.org/search?query=tibia
 +
</nowiki></pre>
 +
 +
The server sends back all the RadLex terms with "tibia"
 +
<pre><nowiki>
 +
<terms>
 +
  <term id="RID2842" preferredid="RID2842">articular cartilage of fibular facet of tibia</term>
 +
  <term id="RID2885" preferredid="RID2885">tibia</term>
 +
  <term id="RID2898" preferredid="RID2898">fibular facet of proximal tibia</term>
 +
  <term id="RID2899" preferredid="RID2899">posterior intercondyloid fossa of proximal tibia</term>
 +
  <term id="RID2900" preferredid="RID2900">shaft of tibia</term>
 +
  <term id="RID2901" preferredid="RID2900">diaphysis of tibia</term>
 +
</terms>
 +
</nowiki></pre>
 +
We can see that [http://radlex.org/RID2901 diaphysis of tibia] is a synonym of [http://radlex.org/RID2900 shaft of tibia], since the preferred term is [http://radlex.org/RID2900 shaft of tibia].
 +
 +
 
[[Category:RadLex]]
 
[[Category:RadLex]]

Revision as of 00:47, 26 February 2007

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 GETs and POSTs the same, so while the examples use GET reqeusts and pass the parameters via the on

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

1 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

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

2.1 <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.2 <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.3 <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.4 <links>


2.5 <relationTypes>

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

2.6 <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 getChildren Example

I want to get all the preferred children of Blood Vessel. So, I construct a GET request using the radlexID of Blood Vessel, "RID4", and I specify to only show the preferred children:

http://radlex.org/getChildren?radlexID=RID4&relationtype=preferred 

The server responds with:

<children parent="RID4">
   <child id="RID478" relationType="" preferred="1" childIsParent="1">artery</child>
   <child id="RID1008" relationType="" preferred="1" childIsParent="1">vein</child>
</children>


5.3 search Example

I want to search the database for "tibia", so I use the #search method:

http://radlex.org/search?query=tibia

The server sends back all the RadLex terms with "tibia"

<terms>
   <term id="RID2842" preferredid="RID2842">articular cartilage of fibular facet of tibia</term>
   <term id="RID2885" preferredid="RID2885">tibia</term>
   <term id="RID2898" preferredid="RID2898">fibular facet of proximal tibia</term>
   <term id="RID2899" preferredid="RID2899">posterior intercondyloid fossa of proximal tibia</term>
   <term id="RID2900" preferredid="RID2900">shaft of tibia</term>
   <term id="RID2901" preferredid="RID2900">diaphysis of tibia</term>
</terms>

We can see that diaphysis of tibia is a synonym of shaft of tibia, since the preferred term is shaft of tibia.