use of org.hl7.fhir.dstu2.formats.XmlParser in project kindling by HL7.
the class DSTU3ValidationConvertor method convert.
public void convert(String bundleSource, String bundleTarget) throws Exception {
System.out.println("Convert " + bundleSource);
try {
source = (Bundle) new XmlParser().parse(new FileInputStream(bundleSource));
org.hl7.fhir.dstu3.model.Bundle target = Bundle30_50.convertBundle(source);
new org.hl7.fhir.dstu3.formats.XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(bundleTarget), target);
} catch (Exception e) {
throw new Exception(e);
}
}
use of org.hl7.fhir.dstu2.formats.XmlParser in project kindling by HL7.
the class CDAGenerator method finish.
private void finish() throws FileNotFoundException, IOException {
StringBuilder b = new StringBuilder();
for (StructureDefinition sd : structures) {
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(target, sd.getId() + ".xml")), sd);
b.append(" <resource>\r\n" + " <purpose value=\"logical\"/>\r\n" + " <name value=\"" + sd.getName() + "\"/>\r\n" + " <sourceUri value=\"cda\\cda-logical-" + sd.getId() + ".xml\"/>\r\n" + " </resource>\r\n");
}
TextFile.stringToFile(b.toString(), Utilities.path(target, "ig-template.xml"));
// dumpPaths();
}
use of org.hl7.fhir.dstu2.formats.XmlParser in project kindling by HL7.
the class BindingsParser method loadValueSet.
private ValueSet loadValueSet(String ref, String committee) throws Exception {
String folder = new File(filename).getParent();
String srcName;
IParser p;
if (new File(Utilities.path(folder, ref + ".xml")).exists()) {
p = new XmlParser();
srcName = Utilities.path(folder, ref + ".xml");
} else if (new File(Utilities.path(folder, ref + ".json")).exists()) {
p = new JsonParser();
srcName = Utilities.path(folder, ref + ".json");
} else
throw new Exception("Unable to find source for " + ref + " in " + filename + " (" + Utilities.path(folder, ref + ".xml/json)"));
FileInputStream input = new FileInputStream(srcName);
try {
ValueSet result = ValueSetUtilities.makeShareable((ValueSet) p.parse(input));
result.setId(ref.substring(9));
if (!result.hasExperimental())
result.setExperimental(false);
// if (!result.hasUrl())
result.setUrl("http://hl7.org/fhir/ValueSet/" + ref.substring(9));
if (!result.hasVersion() || result.getUrl().startsWith("http://hl7.org/fhir"))
result.setVersion(version);
if (!Utilities.noString(committee)) {
if (!result.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
result.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType(committee));
} else {
String ec = ToolingExtensions.readStringExtension(result, ToolingExtensions.EXT_WORKGROUP);
if (!ec.equals(committee))
System.out.println("ValueSet " + result.getUrl() + " WG mismatch 1: is " + ec + ", want to set to " + committee);
}
}
result.setUserData("filename", "valueset-" + ref.substring(9));
result.setUserData("path", "valueset-" + ref.substring(9) + ".html");
new CodeSystemConvertor(codeSystems).convert(p, result, srcName, packageInfo);
return result;
} finally {
IOUtils.closeQuietly(input);
}
}
use of org.hl7.fhir.dstu2.formats.XmlParser in project kindling by HL7.
the class SourceParser method loadCommonSearchParameters.
private void loadCommonSearchParameters() throws FHIRFormatError, FileNotFoundException, IOException {
Bundle bnd = (Bundle) new XmlParser().parse(new CSFileInputStream(Utilities.path(srcDir, "searchparameter", "common-search-parameters.xml")));
for (BundleEntryComponent be : bnd.getEntry()) {
SearchParameter sp = (SearchParameter) be.getResource();
CommonSearchParameter csp = new CommonSearchParameter();
csp.setId(sp.getId());
csp.setCode(sp.getCode());
for (CodeType ct : sp.getBase()) {
csp.getResources().add(ct.asStringValue());
definitions.getCommonSearchParameters().put(ct.asStringValue() + "::" + sp.getCode(), csp);
}
}
}
use of org.hl7.fhir.dstu2.formats.XmlParser in project kindling by HL7.
the class SourceParser method loadCodeSystem.
private void loadCodeSystem(String n) throws FileNotFoundException, Exception {
XmlParser xml = new XmlParser();
CodeSystem cs = (CodeSystem) xml.parse(new CSFileInputStream(srcDir + ini.getStringProperty("codesystems", n).replace('\\', File.separatorChar)));
if (!cs.hasId())
cs.setId(FormatUtilities.makeId(n));
if (cs.getUrl().startsWith("http://hl7.org/fhir"))
cs.setVersion(version.toCode());
cs.setUserData("path", "codesystem-" + cs.getId() + ".html");
cs.setUserData("filename", "codesystem-" + cs.getId());
definitions.getCodeSystems().see(cs, page.packageInfo());
}
Aggregations