Difference between revisions of "RadLex API"

From MircWiki
Jump to navigation Jump to search
m
Line 11: Line 11:
  
 
'''Parameters:'''  
 
'''Parameters:'''  
* ''radlexID'' - the RadLex ID to obtain in the form "^RID([0-9]+)$"
+
* ''radlexID'' - the RadLex ID to obtain in the form "^RID([0-9] )$"
  
 
'''Return:'''
 
'''Return:'''
Line 61: Line 61:
 
'''Notes:'''
 
'''Notes:'''
 
Performs a search on the database for the ''query''' term or phrase.   
 
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 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 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 ([http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html MySQL Documentation]).  
 
*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 ([http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html MySQL Documentation]).  
Line 249: Line 249:
 
I want to find all the terms between the root of the terminology (RID0) and [http://radlex.org/RID3 anatomic location], so I construct a GET request using getTree:
 
I want to find all the terms between the root of the terminology (RID0) and [http://radlex.org/RID3 anatomic location], so I construct a GET request using getTree:
 
<pre><nowiki>
 
<pre><nowiki>
http://radlex.org/getTree?relationType=preferred&radlexID=RID3
+
http://radlex.org/getTree?relationType=preferred
</nowiki></pre>
 
 
 
The server returns:
 
<pre><nowiki>
 
<links>
 
<link parent="RID0" id="RID2" relationType="" preferred="1" childIsParent="0">RadLex synonym</link>
 
<link parent="RID0" id="RID1" relationType="" preferred="1" childIsParent="1">RadLex term</link>
 
<link parent="RID1" id="RID8" relationType="" preferred="1" childIsParent="1">treatment</link>
 
<link parent="RID1" id="RID7" relationType="" preferred="1" childIsParent="0">image acquisition, processing, and display</link>
 
<link parent="RID1" id="RID6" relationType="" preferred="1" childIsParent="1">modifier</link>
 
<link parent="RID1" id="RID5" relationType="" preferred="1" childIsParent="1">finding</link>
 
<link parent="RID1" id="RID3" relationType="" preferred="1" childIsParent="1">anatomic location</link>
 
<link parent="RID1" id="RID29" relationType="" preferred="1" childIsParent="1">uncertainty</link>
 
<link parent="RID1" id="RID16" relationType="" preferred="1" childIsParent="1">teaching attribute</link>
 
<link parent="RID1" id="RID15" relationType="" preferred="1" childIsParent="1">relationship</link>
 
<link parent="RID1" id="RID10" relationType="" preferred="1" childIsParent="1">image quality</link>
 
</links>
 
</nowiki></pre>
 
 
 
If I wanted to set the base to be something other than RID0, I could have used the ''baseID'' parameter
 
<pre><nowiki>
 
http://radlex.org/getTree?relationType=preferred&radlexID=RID7435&baseID=RID3
 
</nowiki></pre>
 
 
 
 
 
=== getChildren Example ===
 
I want to get all the preferred children of [http://radlex.org/RID4 Blood Vessel]. So, I construct a GET request using the radlexID of [http://radlex.org/RID4 Blood Vessel], "RID4", and I specify to only show the preferred children:
 
 
 
<pre><nowiki>
 
http://radlex.org/getChildren?radlexID=RID4&relationtype=preferred
 
</nowiki></pre>
 
 
 
The server responds with:
 
<pre><nowiki>
 
<children parent="RID4">
 
  <child id="RID478" relationType="" preferred="1" childIsParent="1">artery</child>
 
  <child id="RID1008" relationType="" preferred="1" childIsParent="1">vein</child>
 
</children>
 
</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]]
 

Revision as of 21:20, 10 April 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 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:

<nowiki>
http://radlex.org/getTree?relationType=preferred