Search in sources :

Example 6 with ValueSet

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

the class ValueSetsTest method testWithValueSetsFromDirectoryJson.

@Test
public void testWithValueSetsFromDirectoryJson() {
    ValueSets valueSets = ValueSets.getEmpty(spark).withValueSetsFromDirectory("src/test/resources/json/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 7 with ValueSet

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

the class ValueSetsTest method testAppendValueSets.

@Test
public void testAppendValueSets() {
    ValueSets original = ValueSets.getEmpty(spark).withValueSets(valueSet("urn:cerner:valueset:valueset1", "1"), valueSet("urn:cerner:valueset:valueset2", "1"));
    ValueSets valueSets = original.withValueSets(valueSet("urn:cerner:valueset:valueset3", "1"));
    Assert.assertEquals(2, original.getValues().count());
    Assert.assertEquals(3, valueSets.getValues().count());
    ValueSet firstValueSet = valueSets.getValueSet("urn:cerner:valueset:valueset1", "1");
    checkValueSet(firstValueSet, "urn:cerner:valueset:valueset1", "1");
    ValueSet secondValueSet = valueSets.getValueSet("urn:cerner:valueset:valueset2", "1");
    checkValueSet(secondValueSet, "urn:cerner:valueset:valueset2", "1");
    ValueSet newValueSet = valueSets.getValueSet("urn:cerner:valueset:valueset3", "1");
    checkValueSet(newValueSet, "urn:cerner:valueset:valueset3", "1");
}
Also used : ValueSet(org.hl7.fhir.dstu3.model.ValueSet) Test(org.junit.Test)

Example 8 with ValueSet

use of org.hl7.fhir.dstu3.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 9 with ValueSet

use of org.hl7.fhir.dstu3.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 10 with ValueSet

use of org.hl7.fhir.dstu3.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)

Aggregations

ValueSet (org.hl7.fhir.dstu3.model.ValueSet)13 Test (org.junit.Test)7 ConceptSetComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent)4 ValueSetComposeComponent (org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent)3 ConceptReferenceComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)2 FhirContext (ca.uhn.fhir.context.FhirContext)1 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 IParser (ca.uhn.fhir.parser.IParser)1 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1