Search in sources :

Example 11 with ValueSet

use of org.hl7.fhir.r5.model.ValueSet in project bunsen by cerner.

the class ValueSetsTest method testWriteToNewTables.

@Test
public void testWriteToNewTables() {
    String database = "test_valuesets_write";
    spark.sql("CREATE DATABASE " + database);
    ValueSets valueSets = ValueSets.getEmpty(spark).withValueSetsFromDirectory("src/test/resources/xml/valuesets");
    valueSets.writeToDatabase(database);
    ValueSets reloadedValueSets = ValueSets.getFromDatabase(spark, database);
    ValueSet marriedValueSet = reloadedValueSets.getValueSet("urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1");
    Assert.assertNotNull(marriedValueSet);
    Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl());
    Assert.assertEquals("0.0.1", marriedValueSet.getVersion());
    Assert.assertEquals(1, marriedValueSet.getCompose().getInclude().size());
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Example 12 with ValueSet

use of org.hl7.fhir.r5.model.ValueSet in project bunsen by cerner.

the class ValueSetsTest method valueSet.

private static ValueSet valueSet(String valueSetUrl, String valueSetVersion, String... codes) {
    ValueSet valueSet = new ValueSet();
    valueSet.setUrl(valueSetUrl);
    valueSet.setVersion(valueSetVersion);
    valueSet.setExperimental(true);
    ConceptSetComponent inclusion = valueSet.getCompose().addInclude();
    inclusion.setSystem("urn:cerner:system").setVersion("1");
    for (String code : codes) {
        inclusion.addConcept().setCode(code);
    }
    return valueSet;
}
Also used : ConceptSetComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent) ValueSet(org.hl7.fhir.dstu3.model.ValueSet)

Example 13 with ValueSet

use of org.hl7.fhir.r5.model.ValueSet in project bunsen by cerner.

the class ValueSetsTest method testWithDisjointValueSetsFromDirectory.

@Test
public void testWithDisjointValueSetsFromDirectory() {
    String database = "test_valuesets_disjoint";
    spark.sql("CREATE DATABASE " + database);
    ValueSets.getEmpty(spark).withValueSetsFromDirectory("src/test/resources/xml/valuesets").writeToDatabase(database);
    ValueSets valueSets = ValueSets.getFromDatabase(spark, database).withDisjointValueSetsFromDirectory("src/test/resources/xml/valuesets", database);
    ValueSet marriedValueSet = valueSets.getValueSet("urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1");
    Assert.assertEquals(1, valueSets.getValueSets().count());
    Assert.assertNotNull(marriedValueSet);
    Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl());
    Assert.assertEquals("0.0.1", marriedValueSet.getVersion());
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Example 14 with ValueSet

use of org.hl7.fhir.r5.model.ValueSet in project bunsen by cerner.

the class ValueSetsTest method testWithValueSetsFromDirectoryXml.

@Test
public void testWithValueSetsFromDirectoryXml() {
    ValueSets valueSets = ValueSets.getEmpty(spark).withValueSetsFromDirectory("src/test/resources/xml/valuesets");
    ValueSet marriedValueSet = valueSets.getValueSet("urn:cerner:bunsen:valueset:married_maritalstatus", "0.0.1");
    Assert.assertNotNull(marriedValueSet);
    Assert.assertEquals("urn:cerner:bunsen:valueset:married_maritalstatus", marriedValueSet.getUrl());
    Assert.assertEquals("0.0.1", marriedValueSet.getVersion());
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Example 15 with ValueSet

use of org.hl7.fhir.r5.model.ValueSet in project bunsen by cerner.

the class ValueSetsTest method testExpandValues.

@Test
public void testExpandValues() {
    ValueSet valueSet = ValueSets.getEmpty(spark).withValueSets(valueSet("urn:cerner:valueset:valueset", "1")).getValueSet("urn:cerner:valueset:valueset", "1");
    List<Value> values = ValueSets.expandValues(valueSet);
    Value expectedValue = new Value("urn:cerner:valueset:valueset", "1", "urn:cerner:system", "1", "a");
    Assert.assertEquals(1, values.size());
    Assert.assertEquals(expectedValue, values.get(0));
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Aggregations

ValueSet (org.hl7.fhir.r5.model.ValueSet)159 ValueSet (org.hl7.fhir.r4.model.ValueSet)116 Test (org.junit.jupiter.api.Test)115 ArrayList (java.util.ArrayList)101 FHIRException (org.hl7.fhir.exceptions.FHIRException)100 IOException (java.io.IOException)97 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)59 ValueSet (org.hl7.fhir.r4b.model.ValueSet)59 FileNotFoundException (java.io.FileNotFoundException)58 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)56 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)46 HashMap (java.util.HashMap)45 Test (org.junit.Test)45 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)43 File (java.io.File)36 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)29 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)29 FileInputStream (java.io.FileInputStream)27