Design/Api_v0.3

Drugle API v 0.3

This is the specification document of the Drugle v0.3 API.
A new API version is already available (Drugle API v1.0), new implementations should use the new version instead of this one.

Operations

This section describes the complete set of services in Drugle API. Each operation is specified as a REST resource and its URI is relative to a root URI that we denote by <drugle-root>. E.g.: <drugle-root> = http://drugledemo.seibostudios.se

OperationDescription
SearchProcess the search and returns a search id to access the results.
ResultsThe results of the query specified in the <query-id> parameter represented as HTML.
Aspect contentThe aspect content of a specific document.
TermsThe list of terms starting with the prefix <term-prefix> specified in the parameters.
DocumentThe document <document-id> in <fmt> representation.

Process the search and returns a search id to access the results.

HTTP Method

POST

Uri

<drugle-root>/search?pattern=<query_text>&language=<language>&aspect=<aspect>&profile=<profile>

  • pattern: <string>
    the text to search for
  • language: [all | de | en | es | fr | sv]
    specifies the documents language:
    • all: any language
    • de: German
    • en: English
    • es: Spanish
    • fr: French
    • sv: Swedish
  • aspect: [ all | 1 | 2 | 3 | 4.1 | 4.2 | 4.3 | 4.5 | 4.8 ]
    specifies the documents aspect to search for:
    • all: any aspect
    • 1: Medicinal product name
    • 2: Quantitative composition
    • 3: Pharmaceutical form
    • 4.1: Therapeutic indications
    • 4.2: Posology
    • 4.3: Contraindications
    • 4.5: Interactions
    • 4.8: Undesirable effects
  • profile: [ profile-normal | profile-doctor]
    user profile used to order the results

Body

None

Response body

<search-id>

  • search-id: INTEGER
    The search id used to access the results.

Errors

None

Example

In this example, the XMLHttpRequest open function is called in the search() function to execute the search query in the server. The handler() is called to manage the request and once the response arrives, it shows a successful message.

client = getClient();

function getClient() {

  var httpCli = false; 
  if (window.XMLHttpRequest) {
    httpCli = new XMLHttpRequest();
  } else
    if (window.ActiveXObject) {
      try {
        httpCli = new ActiveXObject("Msxml2.XMLHTTP");
      }  catch (e) {
        try {
          httpCli = new ActiveXObject("Microsoft.XMLHTTP");
        }  catch (e) { }
      }
    }
  return httpCli;

}

function handler() {
    if (client.readyState == 4) 
    {
        if (client.status == 200)
        {
            var text = client.responseText;
            alert(text);
        }
    }
}

function test() {

  var text = "aspirin"; 
  var language = "en"; 
  var aspect = "1"; 
  var profile = "profile-normal";

  url = "/drugle-root/search?pattern=" + text + "&language=" + language + "&aspect=" + aspect + "&profile=" + profile;
  client.open ('POST', url, true); 
  client.onreadystatechange = handler;
  client.send (text);

}

Results

Description

Returns an HTML with the results of the query specified in the <query_id> parameter.

HTTP Method

GET

Uri

<drugle-root>/results?id=<search_id>&page=<page>

  • search_id: <integer>
    the search number that identifies the previous created search
  • page: <integer>
    the page number to retrieve

Body

None

Response body

HTML document containing the query results

Errors

None

Example

In this example we replace the handler() function of the search operation to retrieve the results after the search was successfully created:

function handler() 
{
    if (client.readyState == 4) 
    {
        if (client.status == 200)
        {
            id_result = client.responseText;
            document.location="/drugle-root/results?id=" + id_result + "&page=1";
        }
    }
}

Aspect content

Description

Returns the aspect content of a specific document.

HTTP Method

GET

Uri

<drugle-root>/resources/txt/<source>/spc/<language>/<document-id>/<aspect>/row<row>/<pattern>

  • source: STRING
    the document's source name
  • language: [de | en | es | fr | sv]
    specifies the document language:
  • document_id: STRING
    the document id
  • aspect: [ 1 | 2 | 3 | 4.1 | 4.2 | 4.3 | 4.5 | 4.8 ]
    specifies the document aspect to retrieve
  • row: INTEGER
    the result number of the page
  • pattern: STRING
    the search pattern, used to highlight terms in the response text

Body

None

Response body

HTML document containing the aspect content of the specified document

Errors

None

Example

In this example we replace the test() function of the search operation to retrieve a document aspect.

function test() {
  var source = "emea"; 
  var language = "en"; 
  var doc_id = "emea-combined-h273en.0.py";
  var aspect = "1"; 
  var row = 1;
  var pattern = "aspirin";

  url = "resources/txt/" + source + "/spc/" + language + "/" + doc_id + "/" + aspect + "/row" + row + "/" + pattern;
  client.open ('POST', url, true); 
  client.onreadystatechange = handler;
  client.send (text);
}

Terms

Description

Returns a list of terms starting with the prefix <term_prefix> specified in the parameters.

HTTP Method

GET

Uri

<drugle-root>/terms/<term_prefix>

  • term_prefix: STRING
    the prefix string of the terms to retrieve

Body

None

Response body

Returns a JSON document containing a list of string elements:

 ['term_1', 'term_2', ... 'term_n']

Errors

None

Example

In this example we replace the test() function of the search operation to retrieve a list of terms that matches with the sent prefix

function test() {
  var prefix = "asp";

  url = "/drugle-root/terms/" + prefix;
  client.open ('POST', url, true);
  client.onreadystatechange = handler;
  client.send (text);
}

Document

Description

The document <document-id> in <fmt> representation

HTTP Method

GET

Uri

<drugle-root>/resources/<type>/<source>/spc/txt/<document-id>

  • type: [ pdf | txt ]
    the file type
  • source: [emea, mhra, lmc, aem]
    the document's source name
  • document-id: STRING
    the id of the document file to download

Body

None

Response body

Returns a document with content type "application/pdf" or "text/plain".

Errors

None

Example

A text file link example: /drugle-root/resources/var/emea/spc/txt/emea-combined-h273en.txt
A pdf file link example: /drugle-root/resources/orig/emea/spc/en/H-406-PI-en.pdf