use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT 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.r4.model.Bundle.BundleType.DOCUMENT 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());
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project kindling by HL7.
the class SourceParser method divideContainedResources.
private Map<String, Document> divideContainedResources(String rootId, Document doc) throws Exception {
Map<String, Document> res = new HashMap<String, Document>();
List<Element> list = new ArrayList<Element>();
XMLUtil.getNamedChildren(doc.getDocumentElement(), "contained", list);
for (Element e : list) {
Element r = XMLUtil.getFirstChild(e);
String id = XMLUtil.getNamedChildValue(r, "id");
if (Utilities.noString(id))
throw new Exception("Contained Resource has no id");
String nid = rootId + "-" + id;
if (!nid.matches(FormatUtilities.ID_REGEX))
throw new Exception("Contained Resource combination is illegal");
replaceReferences(doc.getDocumentElement(), id, r.getNodeName() + "/" + nid);
XMLUtil.setNamedChildValue(r, "id", nid);
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document ndoc = docBuilder.newDocument();
Node newNode = ndoc.importNode(r, true);
ndoc.appendChild(newNode);
res.put(id, ndoc);
doc.getDocumentElement().removeChild(e);
}
return res;
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project kindling by HL7.
the class SourceParser method loadIgs.
private void loadIgs() throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document xdoc = builder.parse(new CSFileInputStream(srcDir + "igs.xml"));
Element root = xdoc.getDocumentElement();
if (root.getNodeName().equals("igs")) {
Element ig = XMLUtil.getFirstChild(root);
while (ig != null) {
if (ig.getNodeName().equals("ig") && (!ig.hasAttribute("local") || isOkLocally(ig.getAttribute("code"))) && !isRuledOutLocally(ig.getAttribute("code"))) {
ImplementationGuideDefn igg = new ImplementationGuideDefn(ig.getAttribute("committee"), ig.getAttribute("code"), ig.getAttribute("name"), ig.getAttribute("brief"), ig.getAttribute("source").replace('\\', File.separatorChar), "1".equals(ig.getAttribute("review")), ig.getAttribute("ballot"), ig.getAttribute("fmm"), ig.getAttribute("section"), "yes".equals(ig.getAttribute("core")), page.getValidationErrors());
definitions.getIgs().put(igg.getCode(), igg);
definitions.getSortedIgs().add(igg);
}
ig = XMLUtil.getNextSibling(ig);
}
}
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project kindling by HL7.
the class SourceParser method parseXml.
private Document parseXml(InputStream in, String name) throws FHIRException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(in);
} catch (Exception e) {
throw new FHIRException("Error processing " + name + ": " + e.getMessage(), e);
}
}
Aggregations