Search in sources :

Example 6 with TerminologyCapabilities

use of org.hl7.fhir.r5.model.TerminologyCapabilities in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeTerminologyCapabilitiesTerminologyCapabilitiesCodeSystemVersionComponent.

protected void composeTerminologyCapabilitiesTerminologyCapabilitiesCodeSystemVersionComponent(Complex parent, String parentType, String name, TerminologyCapabilities.TerminologyCapabilitiesCodeSystemVersionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "version", name, element, index);
    if (element.hasCodeElement())
        composeString(t, "TerminologyCapabilities", "code", element.getCodeElement(), -1);
    if (element.hasIsDefaultElement())
        composeBoolean(t, "TerminologyCapabilities", "isDefault", element.getIsDefaultElement(), -1);
    if (element.hasCompositionalElement())
        composeBoolean(t, "TerminologyCapabilities", "compositional", element.getCompositionalElement(), -1);
    for (int i = 0; i < element.getLanguage().size(); i++) composeCode(t, "TerminologyCapabilities", "language", element.getLanguage().get(i), i);
    for (int i = 0; i < element.getFilter().size(); i++) composeTerminologyCapabilitiesTerminologyCapabilitiesCodeSystemVersionFilterComponent(t, "TerminologyCapabilities", "filter", element.getFilter().get(i), i);
    for (int i = 0; i < element.getProperty().size(); i++) composeCode(t, "TerminologyCapabilities", "property", element.getProperty().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 7 with TerminologyCapabilities

use of org.hl7.fhir.r5.model.TerminologyCapabilities in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeTerminologyCapabilitiesTerminologyCapabilitiesCodeSystemComponent.

protected void composeTerminologyCapabilitiesTerminologyCapabilitiesCodeSystemComponent(Complex parent, String parentType, String name, TerminologyCapabilities.TerminologyCapabilitiesCodeSystemComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "codeSystem", name, element, index);
    if (element.hasUriElement())
        composeCanonical(t, "TerminologyCapabilities", "uri", element.getUriElement(), -1);
    for (int i = 0; i < element.getVersion().size(); i++) composeTerminologyCapabilitiesTerminologyCapabilitiesCodeSystemVersionComponent(t, "TerminologyCapabilities", "version", element.getVersion().get(i), i);
    if (element.hasSubsumptionElement())
        composeBoolean(t, "TerminologyCapabilities", "subsumption", element.getSubsumptionElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 8 with TerminologyCapabilities

use of org.hl7.fhir.r5.model.TerminologyCapabilities in project org.hl7.fhir.core by hapifhir.

the class TerminologyCacheTests method testCachePersistence.

@Test
public void testCachePersistence() throws IOException, URISyntaxException {
    Object lock = new Object();
    Path tempCacheDirectory = createTempCacheDirectory();
    ValueSet valueSet = new ValueSet();
    valueSet.setUrl("dummyValueSetURL");
    TerminologyCapabilities terminologyCapabilities = new TerminologyCapabilities();
    terminologyCapabilities.getExpansion().setParameter(Arrays.asList());
    CapabilityStatement.CapabilityStatementSoftwareComponent software = new CapabilityStatement.CapabilityStatementSoftwareComponent();
    software.setVersion("dummyVersion");
    CapabilityStatement capabilityStatement = new CapabilityStatement();
    capabilityStatement.setSoftware(software);
    Coding coding = new Coding();
    coding.setCode("dummyCode");
    CodeableConcept concept = new CodeableConcept();
    concept.addCoding(new Coding().setCode("dummyCode"));
    ValueSet ccvalueSet = new ValueSet();
    // Add dummy results to the cache
    TerminologyCache terminologyCacheA = new TerminologyCache(lock, tempCacheDirectory.toString());
    terminologyCacheA.cacheTerminologyCapabilities(terminologyCapabilities);
    terminologyCacheA.cacheCapabilityStatement(capabilityStatement);
    IWorkerContext.ValidationResult codingResultA = new IWorkerContext.ValidationResult(ValidationMessage.IssueSeverity.INFORMATION, "dummyInfo");
    TerminologyCache.CacheToken codingTokenA = terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, coding, valueSet);
    terminologyCacheA.cacheValidation(codingTokenA, codingResultA, true);
    IWorkerContext.ValidationResult codeableConceptResultA = new IWorkerContext.ValidationResult(ValidationMessage.IssueSeverity.INFORMATION, "dummyInfo");
    TerminologyCache.CacheToken codeableConceptTokenA = terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, concept, valueSet);
    terminologyCacheA.cacheValidation(codeableConceptTokenA, codeableConceptResultA, true);
    TerminologyCache.CacheToken expansionTokenA = terminologyCacheA.generateExpandToken(valueSet, true);
    ValueSetExpander.ValueSetExpansionOutcome expansionOutcomeA = new ValueSetExpander.ValueSetExpansionOutcome(valueSet);
    terminologyCacheA.cacheExpansion(expansionTokenA, expansionOutcomeA, true);
    // Check that the in-memory cache is returning what we put in
    {
        assertEquals(terminologyCapabilities, terminologyCacheA.getTerminologyCapabilities());
        assertEquals(capabilityStatement, terminologyCacheA.getCapabilityStatement());
        assertValidationResultEquals(codingResultA, terminologyCacheA.getValidation(codingTokenA));
        assertValidationResultEquals(codeableConceptResultA, terminologyCacheA.getValidation(codeableConceptTokenA));
        assertExpansionOutcomeEquals(expansionOutcomeA, terminologyCacheA.getExpansion(expansionTokenA));
    }
    // Create another cache using the same directory, and check that it gives the same results.
    {
        TerminologyCache terminologyCacheB = new TerminologyCache(lock, tempCacheDirectory.toString());
        assertCanonicalResourceEquals(terminologyCapabilities, terminologyCacheB.getTerminologyCapabilities());
        assertCanonicalResourceEquals(capabilityStatement, terminologyCacheB.getCapabilityStatement());
        assertValidationResultEquals(codingResultA, terminologyCacheB.getValidation(terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, coding, valueSet)));
        assertValidationResultEquals(codeableConceptResultA, terminologyCacheB.getValidation(terminologyCacheA.generateValidationToken(CacheTestUtils.validationOptions, concept, valueSet)));
        assertExpansionOutcomeEquals(expansionOutcomeA, terminologyCacheB.getExpansion(terminologyCacheA.generateExpandToken(valueSet, true)));
    }
    deleteTempCacheDirectory(tempCacheDirectory);
}
Also used : Path(java.nio.file.Path) ValueSetExpander(org.hl7.fhir.r5.terminologies.ValueSetExpander) Coding(org.hl7.fhir.r5.model.Coding) TerminologyCapabilities(org.hl7.fhir.r5.model.TerminologyCapabilities) CapabilityStatement(org.hl7.fhir.r5.model.CapabilityStatement) ValueSet(org.hl7.fhir.r5.model.ValueSet) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with TerminologyCapabilities

use of org.hl7.fhir.r5.model.TerminologyCapabilities in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeTerminologyCapabilitiesTerminologyCapabilitiesImplementationComponent.

protected void composeTerminologyCapabilitiesTerminologyCapabilitiesImplementationComponent(Complex parent, String parentType, String name, TerminologyCapabilities.TerminologyCapabilitiesImplementationComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "implementation", name, element, index);
    if (element.hasDescriptionElement())
        composeString(t, "TerminologyCapabilities", "description", element.getDescriptionElement(), -1);
    if (element.hasUrlElement())
        composeUrl(t, "TerminologyCapabilities", "url", element.getUrlElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 10 with TerminologyCapabilities

use of org.hl7.fhir.r5.model.TerminologyCapabilities in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeTerminologyCapabilitiesTerminologyCapabilitiesTranslationComponent.

protected void composeTerminologyCapabilitiesTerminologyCapabilitiesTranslationComponent(Complex parent, String parentType, String name, TerminologyCapabilities.TerminologyCapabilitiesTranslationComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "translation", name, element, index);
    if (element.hasNeedsMapElement())
        composeBoolean(t, "TerminologyCapabilities", "needsMap", element.getNeedsMapElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)11 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 TerminologyCapabilities (org.hl7.fhir.r5.model.TerminologyCapabilities)2 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 JsonObject (com.google.gson.JsonObject)1 Path (java.nio.file.Path)1 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)1 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)1 JsonParser (org.hl7.fhir.r5.formats.JsonParser)1 CapabilityStatement (org.hl7.fhir.r5.model.CapabilityStatement)1 CodeableConcept (org.hl7.fhir.r5.model.CodeableConcept)1 Coding (org.hl7.fhir.r5.model.Coding)1 ValueSet (org.hl7.fhir.r5.model.ValueSet)1 ValueSetExpander (org.hl7.fhir.r5.terminologies.ValueSetExpander)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1