try {
InputStream in = JavaToXML.getPropertiesFile("config.properties");
props.load(in);
in.close();
} catch (IOException ex) {
throw new SiteException("Unable to access configuration file", ex);
}
String stringUrl = props.getProperty("urlMirth");
String s = JavaToXML.objectToXml(patientId);
log.info("Message to send : \n" + s);
URL url;
try {
url = new URL(stringUrl);
} catch (MalformedURLException ex) {
throw new SiteException("Mailformed URL from property `urlMirth`", ex);
}
URLConnection conn;
try {
conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write("query=" + s);
wr.flush();
wr.close();
} catch (IOException ex) {
throw new SiteException("External CDA Query client unavailable", ex);
}
CdaQueryResult cdaQueryResult = new CdaQueryResult();
try {
return cdaQueryResult.parseDocument(conn.getInputStream());
} catch (IOException ex) {
throw new SiteException("Unable to parse CdaQuery result", ex);
}
}