use of org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class R2R3ConversionManager method setR2Definitions.
// set up ------------------------------------------------------------------
public void setR2Definitions(InputStream stream) throws IOException, FHIRException {
needPrepare = true;
R2ToR3Loader ldr = new R2ToR3Loader();
ldr.setPatchUrls(true).setKillPrimitives(true);
Map<String, InputStream> files = readInputStream(stream);
contextR2 = new SimpleWorkerContext();
contextR2.setAllowLoadingDuplicates(true);
contextR2.loadFromFile(files.get("profiles-types.xml"), "profiles-types.xml", ldr);
contextR2.loadFromFile(files.get("profiles-resources.xml"), "profiles-resources.xml", ldr);
contextR2.loadFromFile(files.get("valuesets.xml"), "valuesets.xml", ldr);
}
use of org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class TestingUtilities method getWorkerContext.
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception {
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage);
TerminologyCache.setCacheErrors(true);
return swc;
}
use of org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ToolsHelper method generateSnapshots.
private void generateSnapshots(String[] args) throws IOException, FHIRException {
if (args.length == 1) {
System.out.println("tools.jar snapshot-maker [source] -defn [definitions]");
System.out.println("");
System.out.println("Generates a snapshot from a differential. The nominated profile must have a single struture that has a differential");
System.out.println("");
System.out.println("source - the profile to generate the snapshot for. Maybe a file name, or a URL reference to a server running FHIR RESTful API");
System.out.println("definitions - filename for local copy of the validation.zip file");
}
String address = args[1];
String definitions = args[3];
SimpleWorkerContext context = SimpleWorkerContext.fromDefinitions(getDefinitions(definitions));
// } else {
throw new NotImplementedException("generating snapshots not done yet (address = " + address + ")");
// }
}
use of org.hl7.fhir.dstu2016may.utils.SimpleWorkerContext 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;
}
}
Aggregations