Funções de chamada dos serviços CID-10

De Wiki REDDES

(Diferencias entre revisiones)
(Java)
Revisión actual (14:47 21 jun 2018) (editar) (deshacer)
(Página blanqueada)
 
Línea 1: Línea 1:
-
=== PHP ===
 
-
<pre>
 
-
<?php
 
-
 
-
$BASEURL = "http://bases.bireme.br/cgi-bin/mxlindG4.exe/cgi=@cid10/cid10";
 
-
 
-
 
-
function wordsSearch($words="") {
 
-
global $BASEURL;
 
-
$params = array('words' => trim($words));
 
-
return getContent($BASEURL, $params);
 
-
}
 
-
 
-
 
-
function boolSearch($bool_="", $index="") {
 
-
global $BASEURL;
 
-
$params = array('bool'=>trim($index)." ".trim($bool_));
 
-
return getContent($BASEURL, $params);
 
-
}
 
-
 
-
 
-
function tree_idSearch($tree_id="") {
 
-
global $BASEURL;
 
-
$params = array('tree_id'=>trim($tree_id));
 
-
return getContent($BASEURL, $params);
 
-
}
 
-
 
-
 
-
function getContent($url, $params) {
 
-
array_walk($params , create_function('&$v,$k', '$v = $k."=".$v ;'));
 
-
$parameters = str_replace (" ", "%20" , implode("&",$params));
 
-
$content = file_get_contents($url."?".$parameters);
 
-
return $content;
 
-
}
 
-
 
-
?>
 
-
</pre>
 
-
 
-
=== Python ===
 
-
 
-
<pre>
 
-
import urllib
 
-
 
-
BASEURL = "http://bases.bireme.br/cgi-bin/mxlindG4.exe/cgi=@cid10/cid10"
 
-
 
-
 
-
def wordsSearch(words=""):
 
-
params = {'words': words.strip()}
 
-
return getContent(BASEURL, params)
 
-
 
-
 
-
def boolSearch(bool_="", index=""):
 
-
params = {'bool' : index.strip() + " " + bool_.strip()}
 
-
return getContent(BASEURL, params)
 
-
 
-
 
-
def tree_idSearch(tree_id=""):
 
-
params = {'tree_id': tree_id.strip()}
 
-
return getContent(BASEURL, params)
 
-
 
-
 
-
def getContent(url, params):
 
-
parameters = urllib.urlencode(params)
 
-
handle = urllib.urlopen("%s?%s" %(url,parameters))
 
-
content = handle.read()
 
-
handle.close()
 
-
return content
 
-
 
-
</pre>
 
-
 
-
=== Java ===
 
-
 
-
<pre>
 
-
import java.io.*;
 
-
import java.net.*;
 
-
 
-
public class CID_10 {
 
-
public static final String BASEURL =
 
-
"http://bases.bireme.br/cgi-bin/mxlindG4.exe/cgi=@cid10/cid10";
 
-
 
-
public String wordsSearch(final String words) {
 
-
final String wrd = (words == null) ? "?words="
 
-
: "?words=" + words.trim();
 
-
return getContent(BASEURL + wrd);
 
-
}
 
-
 
-
public String boolSearch(final String bool,
 
-
final String index) {
 
-
 
-
final String idx = (index == null) ? "" : index.trim() + " ";
 
-
final String bl = (bool == null) ? "?bool="
 
-
: "?bool=" + idx + bool.trim();
 
-
 
-
return getContent(BASEURL + bl);
 
-
}
 
-
 
-
public String tree_idSearch(final String tree_id) {
 
-
 
-
final String id = (tree_id == null) ? "?tree_id="
 
-
: "?tree_id=" + tree_id.trim();
 
-
 
-
return getContent(BASEURL + id);
 
-
}
 
-
 
-
private String getContent(final String url) {
 
-
final StringBuilder ret = new StringBuilder();
 
-
URLConnection connection = null;
 
-
BufferedReader reader = null;
 
-
String line;
 
-
 
-
if (url != null) {
 
-
try {
 
-
connection = new URL(url.replace(" ", "%20")).openConnection();
 
-
connection.connect();
 
-
 
-
reader = new BufferedReader(
 
-
new InputStreamReader(connection.getInputStream(),
 
-
"ISO-8859-1"));
 
-
while (true) {
 
-
line = reader.readLine();
 
-
if (line == null) {
 
-
break;
 
-
}
 
-
ret.append(line + "\n");
 
-
}
 
-
} catch (Exception ex) {
 
-
ret.setLength(0);
 
-
} finally {
 
-
try {
 
-
if (reader != null) {
 
-
reader.close();
 
-
}
 
-
} catch (IOException ioe) {
 
-
 
-
}
 
-
}
 
-
}
 
-
return ret.toString();
 
-
}
 
-
}
 
-
</pre>
 
-
 
-
{| align="right" border="0" cellspacing="5"
 
-
| [[Serviços CID-10#Chamada dos Serviços CID-10 a partir de uma linguagem de programação|volta]]
 
-
|}
 

Revisión actual

Herramientas personales