use of org.hl7.fhir.r4.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class Transformer method process.
public boolean process() {
try {
System.out.println(" .. load definitions from " + definitions);
IWorkerContext context = SimpleWorkerContext.fromPack(definitions);
scu = new StructureMapUtilities(context, new HashMap<String, StructureMap>(), null);
for (String folder : folders) {
System.out.println(" .. load additional definitions from " + folder);
((SimpleWorkerContext) context).loadFromFolder(folder);
loadMaps(folder);
}
System.out.println(" .. load source from " + source);
Element e = Manager.parse(context, new FileInputStream(source), FhirFormat.XML);
Bundle bundle = new Bundle();
StructureMap map = scu.getLibrary().get(mapUri);
if (map == null)
throw new Error("Unable to find map " + mapUri + " (Known Maps = " + Utilities.listCanonicalUrls(scu.getLibrary().keySet()) + ")");
scu.transform(null, e, map, bundle);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(output), bundle);
return true;
} catch (Exception e) {
e.printStackTrace();
message = e.getMessage();
return false;
}
}
use of org.hl7.fhir.r4.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ResourceUtilities method representDataElementCollection.
public static String representDataElementCollection(IWorkerContext context, Bundle bundle, boolean profileLink, String linkBase) {
StringBuilder b = new StringBuilder();
DataElement common = showDECHeader(b, bundle);
b.append("<table class=\"grid\">\r\n");
List<String> cols = chooseColumns(bundle, common, b, profileLink);
for (BundleEntryComponent e : bundle.getEntry()) {
DataElement de = (DataElement) e.getResource();
renderDE(de, cols, b, profileLink, linkBase);
}
b.append("</table>\r\n");
return b.toString();
}
Aggregations