use of org.hl7.fhir.r5.terminologies.TerminologyClient in project org.hl7.fhir.core by hapifhir.
the class SimpleWorkerContextTests method testExpandValueSet4ArgsWithCache.
@Test
public void testExpandValueSet4ArgsWithCache() throws IOException {
ValueSet vs = new ValueSet();
vs.setUrl(DUMMY_URL);
Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(vs, true);
Mockito.doReturn(expectedExpansionResult).when(terminologyCache).getExpansion(cacheToken);
Parameters pIn = new Parameters();
ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(vs, true, true, true, pIn);
assertEquals(expectedExpansionResult, actualExpansionResult);
Mockito.verify(terminologyCache).getExpansion(cacheToken);
Mockito.verify(terminologyCache, times(0)).cacheExpansion(any(), any(), anyBoolean());
Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any(), any());
}
use of org.hl7.fhir.r5.terminologies.TerminologyClient in project org.hl7.fhir.core by hapifhir.
the class StandAloneValidatorFetcher method fetchCanonicalResource.
@Override
public CanonicalResource fetchCanonicalResource(IResourceValidator validator, String url) throws URISyntaxException {
String[] p = url.split("\\/");
String root = getRoot(p, url);
if (root != null) {
TerminologyClient c;
c = TerminologyClientFactory.makeClient(root, "fhir/validator", context.getVersion());
return c.read(p[p.length - 2], p[p.length - 1]);
} else {
throw new FHIRException("The URL '" + url + "' is not known to the FHIR validator, and has not been provided as part of the setup / parameters");
}
}
use of org.hl7.fhir.r5.terminologies.TerminologyClient in project org.hl7.fhir.core by hapifhir.
the class SimpleWorkerContext method connectToTSServer.
public String connectToTSServer(TerminologyClient client, String log) {
try {
txLog("Connect to " + client.getAddress());
txClient = client;
if (log != null && log.endsWith(".txt")) {
txLog = new TextClientLogger(log);
} else {
txLog = new HTMLClientLogger(log);
}
txClient.setLogger(txLog);
txClient.setUserAgent(userAgent);
final CapabilityStatement capabilitiesStatementQuick = txCache.hasCapabilityStatement() ? txCache.getCapabilityStatement() : txClient.getCapabilitiesStatementQuick();
txCache.cacheCapabilityStatement(capabilitiesStatementQuick);
final TerminologyCapabilities capabilityStatement = txCache.hasTerminologyCapabilities() ? txCache.getTerminologyCapabilities() : txClient.getTerminologyCapabilities();
txCache.cacheTerminologyCapabilities(capabilityStatement);
setTxCaps(capabilityStatement);
return capabilitiesStatementQuick.getSoftware().getVersion();
} catch (Exception e) {
throw new FHIRException(formatMessage(canNoTS ? I18nConstants.UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER_USE_PARAMETER_TX_NA_TUN_RUN_WITHOUT_USING_TERMINOLOGY_SERVICES_TO_VALIDATE_LOINC_SNOMED_ICDX_ETC_ERROR__ : I18nConstants.UNABLE_TO_CONNECT_TO_TERMINOLOGY_SERVER, e.getMessage()), e);
}
}
Aggregations