Search in sources :

Example 11 with TerminologyClient

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());
}
Also used : Parameters(org.hl7.fhir.r5.model.Parameters) ValueSet(org.hl7.fhir.r5.model.ValueSet) ValueSetExpander(org.hl7.fhir.r5.terminologies.ValueSetExpander) Test(org.junit.jupiter.api.Test)

Example 12 with TerminologyClient

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");
    }
}
Also used : TerminologyClient(org.hl7.fhir.r5.terminologies.TerminologyClient) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 13 with TerminologyClient

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);
    }
}
Also used : FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) DataFormatException(ca.uhn.fhir.parser.DataFormatException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Aggregations

Test (org.junit.jupiter.api.Test)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)5 ValueSetExpander (org.hl7.fhir.r5.terminologies.ValueSetExpander)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 SimpleCoding (au.csiro.pathling.fhirpath.encoding.SimpleCoding)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 Parameters (org.hl7.fhir.r5.model.Parameters)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 DataFormatException (ca.uhn.fhir.parser.DataFormatException)2 UriParam (ca.uhn.fhir.rest.param.UriParam)2 CodeSystem (org.hl7.fhir.r4.model.CodeSystem)2 IParser (ca.uhn.fhir.parser.IParser)1 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)1 CqlDataProvider (com.ibm.cohort.cql.data.CqlDataProvider)1 R4LibraryDependencyGatherer (com.ibm.cohort.cql.hapi.R4LibraryDependencyGatherer)1 R4QualityMeasureResolverFactory (com.ibm.cohort.cql.hapi.resolver.R4QualityMeasureResolverFactory)1 R4QualityMeasureResolvers (com.ibm.cohort.cql.hapi.resolver.R4QualityMeasureResolvers)1 CqlTerminologyProvider (com.ibm.cohort.cql.terminology.CqlTerminologyProvider)1