use of org.hl7.fhir.convertors.txClient.TerminologyClientR5 in project kindling by HL7.
the class PageProcessor method setDefinitions.
public void setDefinitions(Definitions definitions) throws Exception {
this.definitions = definitions;
breadCrumbManager.setDefinitions(definitions);
TerminologyClient client;
try {
client = new TerminologyClientR5(tsServer);
client.setTimeout(60000);
} catch (Exception e) {
System.out.println("Warning @ PageProcessor client initialize: " + e.getLocalizedMessage());
client = null;
}
workerContext = new BuildWorkerContext(definitions, client, definitions.getCodeSystems(), definitions.getValuesets(), conceptMaps, profiles, guides, folders.rootDir);
workerContext.setDefinitions(definitions);
workerContext.setLogger(this);
workerContext.setAllowLoadingDuplicates(true);
log("Load UTG Terminology", LogMessageType.Process);
NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology");
workerContext.loadFromPackage(utg, new R4ToR5Loader(BuildWorkerContext.defaultTypesToLoad(), new UTGLoader(utg.version())));
log("Load Terminology Cache from " + Utilities.path(folders.rootDir, "vscache"), LogMessageType.Process);
workerContext.initTS(Utilities.path(folders.rootDir, "vscache"));
log(" .. loaded", LogMessageType.Process);
vsValidator = new ValueSetValidator(workerContext, definitions.getVsFixups(), definitions.getStyleExemptions());
breadCrumbManager.setContext(workerContext);
}
use of org.hl7.fhir.convertors.txClient.TerminologyClientR5 in project org.hl7.fhir.core by hapifhir.
the class TestingUtilities method context.
public static IWorkerContext context(String version) {
if ("4.5.0".equals(version)) {
// temporary work around
version = "4.4.0";
}
String v = VersionUtilities.getMajMin(version);
if (fcontexts == null) {
fcontexts = new HashMap<>();
}
if (!fcontexts.containsKey(v)) {
FilesystemPackageCacheManager pcm;
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
IWorkerContext fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters());
// ((SimpleWorkerContext) fcontext).connectToTSServer(new TerminologyClientR5("http://tx.fhir.org/r4"), null);
fcontexts.put(v, fcontext);
} catch (Exception e) {
e.printStackTrace();
throw new Error(e);
}
}
return fcontexts.get(v);
}
use of org.hl7.fhir.convertors.txClient.TerminologyClientR5 in project kindling by HL7.
the class BuildWorkerContext method lookupLoinc.
private String lookupLoinc(String code) throws Exception {
if (true) {
// (!triedServer || serverOk) {
try {
triedServer = true;
// for this, we use the FHIR client
if (txClient == null) {
txClient = new TerminologyClientR5(tsServer);
this.txLog = new HTMLClientLogger(null);
}
Map<String, String> params = new HashMap<String, String>();
params.put("code", code);
params.put("system", "http://loinc.org");
Parameters result = txClient.lookupCode(params);
for (ParametersParameterComponent p : result.getParameter()) {
if (p.getName().equals("display"))
return ((StringType) p.getValue()).asStringValue();
}
throw new Exception("Did not find LOINC code in return values");
} catch (EFhirClientException e) {
serverOk = true;
throw e;
} catch (Exception e) {
serverOk = false;
throw e;
}
} else
throw new Exception("Server is not available");
}
Aggregations