use of org.hl7.fhir.dstu2.model.Element in project kindling by HL7.
the class CDAGenerator method processDataTypes.
private void processDataTypes(String filename) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException, FHIRFormatError, DefinitionException {
System.out.println("Process Data Types");
Document dtMif = XMLUtil.parseFileToDom(filename);
List<Element> dts = new ArrayList<Element>();
XMLUtil.getNamedChildren(dtMif.getDocumentElement(), "mif:datatype", dts);
for (Element dt : dts) {
String n = dt.getAttribute("name");
types.put(n, dt);
if (n.equals("IVL")) {
processDataType(dt, n + "_TS", "TS");
processDataType(dt, n + "_PQ", "PQ");
processDataType(dt, n + "_INT", "INT");
} else if (n.equals("PIVL")) {
processDataType(dt, n + "_TS", null);
} else if (n.equals("EIVL")) {
processDataType(dt, n + "_TS", null);
} else if (n.equals("RTO")) {
processDataType(dt, n + "_PQ_PQ", "PQ");
} else if (!"Binding".equals(dt.getAttribute("datatypeKind")))
processDataType(dt, n, null);
}
buildSXPR();
buildInfrastructureRoot();
for (StructureDefinition sd : structures) {
// if (!sd.getAbstract())
generateSnapShot(sd);
}
System.out.println(" ... done");
}
use of org.hl7.fhir.dstu2.model.Element in project kindling by HL7.
the class CKMImporter method downloadArchetype.
private void downloadArchetype(String id) throws Exception {
String destFn = Utilities.path(dest, id + ".xml");
if (new File(destFn).exists())
System.out.println(id + " already fetched");
else {
System.out.println("Fetch " + id);
Document sxml = loadXml(ckm + "/services/ArchetypeFinderBean/getArchetypeInXML?archetypeId=" + id);
Element e = XMLUtil.getFirstChild(sxml.getDocumentElement());
String src = Utilities.path("c:\\temp", id + ".xml");
TextFile.stringToFile(e.getTextContent(), src);
}
}
use of org.hl7.fhir.dstu2.model.Element in project kindling by HL7.
the class BuildWorkerContext method queryForTerm.
private SnomedServerResponse queryForTerm(String code) throws Exception {
if (!triedServer || serverOk) {
triedServer = true;
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://tx.fhir.org/snomed/tool/" + SNOMED_EDITION + "/" + URLEncoder.encode(code, "UTF-8").replace("+", "%20"));
// HttpGet httpget = new HttpGet("http://local.fhir.org:960/r4/snomed/tool/"+SNOMED_EDITION+"/"+URLEncoder.encode(code, "UTF-8").replace("+", "%20")); // don't like the url encoded this way
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
InputStream instream = entity.getContent();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document xdoc = builder.parse(instream);
// we always get back a version, and a type. What we do depends on the type
String t = xdoc.getDocumentElement().getAttribute("type");
serverOk = true;
if (t.equals("error"))
throw new Exception(xdoc.getDocumentElement().getAttribute("message"));
if (t.equals("description"))
throw new Exception("The Snomed code (\"" + code + "\") is a description id not a concept id which is not valid");
if (t.equals("concept")) {
Concept c = new Concept();
c.display = xdoc.getDocumentElement().getAttribute("display");
Element child = XMLUtil.getFirstChild(xdoc.getDocumentElement());
while (child != null) {
c.displays.add(child.getAttribute("value"));
child = XMLUtil.getNextSibling(child);
}
snomedCodes.put(code, c);
return null;
}
if (t.equals("expression")) {
SnomedServerResponse resp = new SnomedServerResponse();
resp.correctExpression = xdoc.getDocumentElement().getAttribute("expressionMinimal");
resp.display = xdoc.getDocumentElement().getAttribute("display");
if (!snomedCodes.containsKey(resp.correctExpression)) {
Concept c = new Concept();
c.display = resp.display;
snomedCodes.put(resp.correctExpression, c);
}
return resp;
}
throw new Exception("Unrecognised response from server");
} finally {
instream.close();
}
} else
return null;
}
use of org.hl7.fhir.dstu2.model.Element in project kindling by HL7.
the class BuildWorkerContext method loadLoinc.
public void loadLoinc(String filename) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document xdoc = builder.parse(new CSFileInputStream(filename));
Element code = XMLUtil.getFirstChild(xdoc.getDocumentElement());
while (code != null) {
Concept c = new Concept();
c.display = code.getAttribute("long");
c.shortN = code.getAttribute("short");
if (!code.getAttribute("long").equalsIgnoreCase(code.getAttribute("short")))
c.displays.add(code.getAttribute("short"));
loincCodes.put(code.getAttribute("id"), c);
code = XMLUtil.getNextSibling(code);
}
}
use of org.hl7.fhir.dstu2.model.Element in project kindling by HL7.
the class Navigation method parse.
public void parse(String file) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document xdoc = builder.parse(new CSFileInputStream(file));
Element root = xdoc.getDocumentElement();
if (root.getNodeName().equals("Navigation"))
parseNavigation(root);
else
throw new Exception("Unexpected node " + root.getNodeName());
}
Aggregations