Difference between revisions of "RadLex API"

From MircWiki
Jump to navigation Jump to search
(midstream of major revision for API v2)
Line 1: Line 1:
'''Warning:  This documentation is currently being updated to reflect version 2 of the servlet. Changes should be be official'''
+
'''Warning:  This documentation is currently being updated to reflect version 2 of the servlet.'''
  
[http://radlex.org RadLex Term Browser]
+
The RadLex API acts as a webservice, which allows developers to query the RadLex terminology and retrieve an XML response.
  
<h1>XML API</h1>
+
__TOC__
 +
== Methods ==
 +
=== search ===
 +
URL: [http://radlex.org/search http://radlex.org/search]
  
<table border="1">
+
Parameters:
  <tr>
+
* ''query'' - string to search for in the database
    <th>File</th>
 
    <th>get* Parameters</th>
 
    <th>Currently Implemented</th>
 
    <th>Details</th>
 
    <th>Return Format</th>
 
  </tr>
 
  <tr>
 
    <td valign="top">getTermById</td>
 
    <td valign="top">radlexID</td>
 
    <td valign="top">Yes</td>
 
    <td valign="top">Return a single term with its ID = radlexID</td>
 
    <td valign="top">&lt;term&gt;</td>
 
  </tr>
 
  <tr>
 
    <td valign="top">getChildren</td>
 
    <td valign="top">
 
<nowiki>
 
radlexID<br>
 
        [relationType]
 
</nowiki>
 
</td>
 
    <td valign="top">Yes</td>
 
    <td valign="top">Returns all terms that have that radlexID as a parent and are related to the parent via the relationType. If no e relationtype is present, all children of that radlexID will be returned.</td>
 
    <td valign="top">&lt;children&gt;</td>
 
  </tr>
 
  <tr>
 
    <td valign="top">getTree</td>
 
    <td valign="top">
 
<nowiki>
 
baseID<br>
 
relationType<br>
 
[radlexID]
 
</nowiki>
 
</td>
 
    <td valign="top">Yes</td>
 
    <td valign="top">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&mdash;this is &ldquo;filled&rdquo; out with all the children of the nodes. 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&rsquo;s children will be given, followed by all of a&rsquo;s children. <br>
 
        The baseID is also linked to its parent&mdash;the true root term for the ontology will be have an id=&ldquo;ROOT&rdquo;.</td>
 
    <td valign="top">&lt;links&gt;</td>
 
  </tr>
 
  <tr>
 
    <td valign="top">search</td>
 
    <td valign="top">
 
<nowiki>
 
query<br>
 
        [returnType]
 
</nowiki>
 
</td>
 
    <td valign="top">Yes</td>
 
    <td valign="top">Performs a search based upon the query parameter. returnType can equal &ldquo;reduced&rdquo; or &ldquo;full&rdquo;. If &ldquo;reduced&rdquo;, only matching radlexID&rsquo;s and term name&rsquo;s will be returned. If &ldquo;full&rdquo;, the full term structure will be returned for each match</td>
 
    <td valign="top">&lt;terms&gt; (Reduced) </td>
 
  </tr>
 
  <tr>
 
    <td valign="top">getRelationTypes</td>
 
    <td valign="top">&nbsp; </td>
 
    <td valign="top">Yes</td>
 
    <td valign="top">Returns a list of all the currently supported relationTypes. (See Relation Types below)</td>
 
    <td valign="top">&lt;relationTypes&gt;</td>
 
  </tr>
 
</table>
 
*HTTP post is redirected to get<br>
 
  
<h1>Relation Types</h1>
+
Return:
<ul>
+
See notes below.  <terms> structure.
<li>preferred</li>
 
<li>isa</li>
 
<li>partof</li>
 
<li>branchof</li>
 
<li>segmentof</li>
 
<li>tributaryof</li>
 
<li>continuouswith</li>
 
<li>containedin</li>
 
<li>memberof</li>
 
    <li>synonymof</li>
 
</ul>
 
<br>
 
  
<h1>Error Codes</h1>
+
Notes:
<table border="1">
+
Performs a search on the database for the ''query''' term or phrase. 
  <tr>
+
*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.
    <th>id</th>
+
*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.
    <th>meaning</th>
+
*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]).
  </tr>
 
  <tr>
 
    <td>1</td>
 
    <td>Radlex ID is not valid</td>
 
  </tr>
 
  <tr>
 
    <td>2</td>
 
    <td>Radlex ID could not be found</td>
 
  </tr>
 
  <tr>
 
    <td>3</td>
 
    <td>Relationship type is not valid</td>
 
  </tr>
 
  <tr>
 
    <td>4</td>
 
    <td>Database connection error</td>
 
  </tr>
 
  <tr>
 
    <td>5</td>
 
    <td>Insufficient http get parameters.</td>
 
  </tr>
 
  <tr>
 
    <td>6</td>
 
    <td>No search results matching query</td>
 
  </tr>
 
</table>
 
<br>
 
  
<h1>XML Documents Structure </h1>
 
<h2>&lt;error&gt; Format</h2>
 
<code>
 
&lt;program&gt;<br>
 
&nbsp;&nbsp;&lt;error id=&quot;2&quot;&gt;Radlex ID could not be found&lt;/error&gt;<br>
 
&lt;/program&gt;
 
</code>
 
  
<br>
 
<h2>&lt;term&gt; Format</h2>
 
<code>
 
&lt;term id=&quot;RID2&quot;&gt;<br>
 
&nbsp;&nbsp;&lt;name&gt;Thorax&lt;/name&gt;<br>
 
&nbsp;&nbsp;&lt;definition&gt;A definition&lt;/definition&gt;<br>
 
&nbsp;&nbsp;&lt;comment&gt;A comment&lt;/comment&gt;<br>
 
&nbsp;&nbsp;&lt;source&gt;Chest Committee&lt;/source&gt;<br>
 
&nbsp;&nbsp;&lt;dateCreated&gt;&lt;/dateCreated&gt;<br>
 
&nbsp;&nbsp;&lt;termStatus&gt;&lt;/termStatus&gt;<br>
 
&nbsp;&nbsp;&lt;versionNumber&gt;Chest Committee&lt;/versionNumber&gt;<br>
 
&nbsp;&nbsp;&lt;acr id=&quot;A44445&quot;&gt;Chest&lt;/acr&gt;<br>
 
&nbsp;&nbsp;&lt;snomed id=&quot;SN44545&quot;&gt;Chest&lt;/snomed&gt;<br>
 
&nbsp;&nbsp;&lt;umls id=&quot;CUI4545848&quot;&gt;Thorax&lt;/umls&gt;<br>
 
&nbsp;&nbsp;&lt;parents&gt;<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&lt;parent id=&quot;RID1&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Anatomical Terms&lt;/parent&gt;<br>
 
&nbsp;&nbsp;&lt;/parents&gt;<br>
 
&nbsp;&nbsp;&lt;children&gt;<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&lt;child id=&quot;RID3&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Lungs&lt;/child&gt;<br>
 
&nbsp;&nbsp;&lt;/children&gt;<br>
 
&lt;/term&gt;<br>
 
</code>
 
<br>
 
<h2>&lt;terms&gt; Reduced Format</h2>
 
<code>
 
&lt;terms&gt; <br>
 
&nbsp;&nbsp;&lt;term id=&quot;RID2&quot;&gt;<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&lt;name&gt;Thorax&lt;/name&gt;<br>
 
&nbsp;&nbsp;&lt;/term&gt;<br>
 
&nbsp;&nbsp;&hellip;<br>
 
&lt;/terms&gt;<br>
 
</code>
 
<br>
 
<h2>&lt;terms&gt; Full Format</h2>
 
<code>
 
&lt;terms&gt;<br>
 
&nbsp;&nbsp;&lt;term id=&quot;RID2&quot;&gt;<br>
 
&nbsp;&nbsp;&lt;name&gt;Thorax&lt;/name&gt;<br>
 
&nbsp;&nbsp;&lt;definition&gt;A definition&lt;/definition&gt;<br>
 
&nbsp;&nbsp;&lt;comment&gt;A comment&lt;/comment&gt;<br>
 
&nbsp;&nbsp;&lt;source&gt;Chest Committee&lt;/source&gt;<br>
 
&nbsp;&nbsp;&lt;acr id=&quot;A44445&quot;&gt;Chest&lt;/acr&gt;<br>
 
&nbsp;&nbsp;&lt;snomed id=&quot;SN44545&quot;&gt;SNChest&lt;/snomed&gt;<br>
 
&nbsp;&nbsp;&lt;umls id=&quot;CUI4545848&quot;&gt;Thorax&lt;/umls&gt;<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&lt;parents&gt;&lt;parent id=&quot;RID1&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Anatomical Terms&lt;/parent&gt;<br>
 
&nbsp;&nbsp;&lt;/parents&gt;<br>
 
&nbsp;&nbsp;&lt;children&gt;<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;&lt;child id=&quot;RID3&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Lungs&lt;/child&gt;<br>
 
&nbsp;&nbsp;&lt;/children&gt;<br>
 
&nbsp;&nbsp;&lt;/term&gt;<br>
 
&nbsp;&nbsp;&hellip;<br>
 
&lt;/terms&gt;<br>
 
</code>
 
<br>
 
<h2>&lt;links&gt; Format</h2>
 
<code>
 
&lt;links&gt;<br>
 
&nbsp;&nbsp;&lt;link parent=&quot;RID0&quot; id=&quot;RID1&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Anatomical Terms&lt;/link&gt;<br>
 
&nbsp;&nbsp;&lt;link parent=&quot;RID1&quot; id=&quot;RID5&quot; relationType=&quot;isa&quot; preferred=&quot;1&quot;&gt;Legs&lt;/link&gt;<br>
 
&nbsp;&nbsp;&lt;link parent=&quot;RID1&quot; id=&quot;RID4&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Abdomen&lt;/link&gt;<br>
 
&nbsp;&nbsp;&lt;link parent=&quot;RID1&quot; id=&quot;RID2&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Thorax&lt;/link&gt;<br>
 
&nbsp;&nbsp;&hellip;<br>
 
&lt;/links&gt;<br>
 
</code>
 
<br>
 
<h2>&lt;children&gt; Format</h2>
 
<code>
 
&lt;children parent=&quot;RID2&quot;&gt;<br>
 
&nbsp;&nbsp;&lt;child id=&quot;RID3&quot; relationType=&quot;partof&quot; preferred=&quot;1&quot;&gt;Lungs&lt;/child&gt;<br>
 
&nbsp;&nbsp;&hellip;<br>
 
&lt;/children&gt;<br>
 
<br>
 
 
</code>
 
<h2>&lt;relationTypes&gt; Format</h2>
 
<code>
 
&lt;relationTypes&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;preferred&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;isa&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;partof&lt;/relationType&gt;<br>
 
&nbsp;&nbsp;&lt;relationType&gt;tributaryof&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;branchof&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;segmentof&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;continuouswith&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;containedin&lt;/relationType&gt; <br>
 
&nbsp;&nbsp;&lt;relationType&gt;memberof&lt;/relationType&gt;<br>
 
&lt;/relationTypes&gt;
 
</code>
 
  
<h1>API Description</h1>
+
=== getTermByID ===
<h2>search</h2>
+
URL: [http://radlex.org/getTermByID http://radlex.org/getTermByID ]
'''URI:''' [http://radlex.org/search http://radlex.org/search] <br />
+
 
'''Parameters:''' ''query'' - a string of the term, ID, or phrase to search for <br />
+
Parameters:  
<br />
+
* ''radlexID'' - the RadLex ID to obtain in the form "^RID([0-9]+)$"
Utilizes 3 types of search: <br />
+
 
<ol>
+
Return:
<li>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. </li>
+
[[#<term>]] structure. 
<li>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. </li>
+
 
<li>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]). </li>
+
Notes:
</ol>
+
Obtains all information pertaining to the ''radlexID'' in the terminology.
 +
 
 +
== Return Structures ==
 +
As a convention for this API, elements preceeded by a dollar sign ($) are variable content.
 +
=== <term> ===
 +
=== <terms> ===
 +
=== <children> ===
 +
=== <relationTypes> ===
 +
=== <error> ===
 +
For a more detailed discussion of [[#Errors | error messages]], see below.
 +
<pre><nowiki>
 +
<program>
 +
  <error id="$errorid">$errormessage</error>
 +
</program>
 +
</nowiki></pre>
 +
 
 +
== Errors ==
 +
 
 +
== Examples ==
 +
 
  
 
[[Category:RadLex]]
 
[[Category:RadLex]]

Revision as of 22:39, 25 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.

1 Methods

1.1 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.2 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.

2 Return Structures

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

2.1 <term>

2.2 <terms>

2.3 <children>

2.4 <relationTypes>

2.5 <error>

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

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

3 Errors

4 Examples