Difference between revisions of "RadLex API"

From MircWiki
Jump to navigation Jump to search
(Replacing page with '[http://radlexwiki.rsna.org/index.php?title=RadLex_API RadLex Wiki]')
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''Warning:  This documentation is currently being updated to reflect version 2 of the servlet.'''
+
[http://radlexwiki.rsna.org/index.php?title=RadLex_API RadLex Wiki]
 
 
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.
 
 
 
__TOC__
 
== Methods ==
 
=== getTermByID ===
 
'''URL:''' [http://radlex.org/getTermByID 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.
 
 
 
 
 
=== getTree ===
 
'''URL:''' [http://radlex.org/getTree 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.
 
 
 
 
 
=== getChildren ===
 
'''URL:''' [http://radlex.org/getChildren 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.
 
 
 
 
 
=== search ===
 
'''URL:''' [http://radlex.org/search 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 ([http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html MySQL Documentation]).
 
 
 
 
 
=== getRelationTypes ===
 
'''URL:''' [http://radlex.org/getRelationTypes 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.
 
 
 
 
 
=== getTotalNumberOfTerms ===
 
'''URL:''' [http://radlex.org/getTotalNumberOfTerms 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.
 
 
 
 
 
== Return Structures ==
 
Boolean values are represented as 0 (=false) or 1 (=true)
 
 
 
=== <term> ===
 
<pre><nowiki>
 
<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>
 
</nowiki></pre>
 
See [[#<children>]] for information on ''childIsParent''
 
 
 
=== <terms> ===
 
<pre><nowiki>
 
<terms>
 
  <term id="$termsID" preferredid="$preferredID">$termName</term>
 
  ...
 
</terms>
 
</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> ===
 
<pre><nowiki>
 
<children parent="$parentRID">
 
  <child id="$radlexID" relationType="$relationType" preferred="$0_or_1" childIsParent="$0_or_1">
 
      $termName
 
  </child>
 
  ...
 
</children>
 
</nowiki></pre>
 
* ''childIsParent'' - indicates if the term is itself a parent.  If childIsParent=1, there are children of the $radlexID given this $relationType
 
 
 
=== <links> ===
 
<pre><nowiki>
 
<links>
 
  <link parent="$parentID" id="$radlexID" relationType="$relationType" preferred="$0_or_1" childIsParent="$0_or_1">$termName</link>
 
</links>
 
</nowiki></pre>
 
See [[#<children>]] for information on ''childIsParent''
 
 
 
=== <relationTypes> ===
 
<pre><nowiki>
 
<relationTypes>
 
  <relationType>$nameOfType</relationType>
 
  ...
 
</relationTypes>
 
</nowiki></pre>
 
 
 
=== <error> ===
 
For a more detailed discussion of [[#Errors | error messages]], see below.
 
<pre><nowiki>
 
<program>
 
  <error id="$errorid">$errormessage</error>
 
</program>
 
</nowiki></pre>
 
 
 
 
 
== 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
 
|}
 
 
 
== 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
 
 
 
== Examples ==
 
=== getTermByID Example ===
 
I want to get all the details about [http://radlex.org/RID1243 Thorax].  So, I construct a GET request using RID1243, for [http://radlex.org/RID1243 Thorax]:
 
 
 
<pre><nowiki>
 
http://radlex.org/getTermByID?radlexID=RID1243
 
</nowiki></pre>
 
 
 
And the server responds with:
 
<pre><nowiki>
 
<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>
 
</nowiki></pre>
 
 
 
 
 
=== getTree Example ===
 
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>
 
http://radlex.org/getTree?relationType=preferred&radlexID=RID3
 
</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]]
 

Latest revision as of 16:11, 28 June 2007