Search in sources :

Example 1 with ConceptMap

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

the class ConceptMapsTest method testWithMapsFromDirectoryJson.

@Test
public void testWithMapsFromDirectoryJson() {
    ConceptMaps maps = ConceptMaps.getEmpty(spark).withMapsFromDirectory("src/test/resources/json/conceptmaps");
    ConceptMap genderMap = maps.getConceptMap("urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1");
    Assert.assertNotNull(genderMap);
    Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl());
    Assert.assertEquals("0.0.1", genderMap.getVersion());
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 2 with ConceptMap

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

the class ConceptMapsTest method testWithDisjointMapsFromDirectory.

@Test
public void testWithDisjointMapsFromDirectory() {
    String database = "test_conceptmaps_disjoint";
    spark.sql("CREATE DATABASE " + database);
    ConceptMaps.getEmpty(spark).withMapsFromDirectory("src/test/resources/xml/conceptmaps").writeToDatabase(database);
    ConceptMaps maps = ConceptMaps.getFromDatabase(spark, database).withDisjointMapsFromDirectory("src/test/resources/xml/conceptmaps", database);
    ConceptMap genderMap = maps.getConceptMap("urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1");
    Assert.assertEquals(1, maps.getMaps().count());
    Assert.assertNotNull(genderMap);
    Assert.assertEquals("urn:cerner:poprec:fhir:conceptmap:demographics:gender", genderMap.getUrl());
    Assert.assertEquals("0.0.1", genderMap.getVersion());
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 3 with ConceptMap

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

the class ConceptMapsTest method testExpandMappings.

@Test
public void testExpandMappings() {
    ConceptMap conceptMap = ConceptMaps.getEmpty(spark).withConceptMaps(conceptMap("urn:cerner:conceptmap:map", "1")).getConceptMap("urn:cerner:conceptmap:map", "1");
    List<Mapping> mappings = ConceptMaps.expandMappings(conceptMap);
    Mapping expectedValue = new Mapping("urn:cerner:conceptmap:map", "1", "urn:source:valueset", "urn:target:valueset", "urn:source:system", "urn:source:code:a", "urn:target:system", "urn:target:code:1", Mapping.EQUIVALENT);
    Assert.assertEquals(1, mappings.size());
    Assert.assertEquals(expectedValue, mappings.get(0));
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 4 with ConceptMap

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

the class ConceptMapsTest method testAppendMappings.

@Test
public void testAppendMappings() throws FHIRException {
    ConceptMaps original = ConceptMaps.getEmpty(spark).withConceptMaps(conceptMap("urn:cerner:map:testmap", "1"), conceptMap("urn:cerner:map:othermap", "1"));
    ConceptMaps maps = original.withConceptMaps(conceptMap("urn:cerner:map:newmap", "1"));
    // The original should be unchanged.
    Assert.assertEquals(2, original.getMappings().count());
    Assert.assertEquals(3, maps.getMappings().count());
    ConceptMap firstMap = maps.getConceptMap("urn:cerner:map:testmap", "1");
    checkMap(firstMap, "urn:cerner:map:testmap", "1");
    ConceptMap secondMap = maps.getConceptMap("urn:cerner:map:othermap", "1");
    checkMap(secondMap, "urn:cerner:map:othermap", "1");
    ConceptMap newMap = maps.getConceptMap("urn:cerner:map:newmap", "1");
    checkMap(newMap, "urn:cerner:map:newmap", "1");
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 5 with ConceptMap

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

the class ConceptMapsTest method testCreateSimpleMappings.

@Test
public void testCreateSimpleMappings() throws FHIRException {
    ConceptMaps maps = ConceptMaps.getEmpty(spark).withConceptMaps(conceptMap("urn:cerner:map:testmap", "1"), conceptMap("urn:cerner:map:othermap", "1"));
    Dataset<Mapping> mappings = maps.getMappings();
    Assert.assertEquals(2, mappings.count());
    ConceptMap firstMap = maps.getConceptMap("urn:cerner:map:testmap", "1");
    checkMap(firstMap, "urn:cerner:map:testmap", "1");
    ConceptMap secondMap = maps.getConceptMap("urn:cerner:map:othermap", "1");
    checkMap(secondMap, "urn:cerner:map:othermap", "1");
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Aggregations

ConceptMap (org.hl7.fhir.dstu3.model.ConceptMap)14 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)3 ConceptMapGroupComponent (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent)3 UriType (org.hl7.fhir.dstu3.model.UriType)3 ArrayDeque (java.util.ArrayDeque)2 HashSet (java.util.HashSet)2 SourceElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)2 ConceptMaps (com.cerner.bunsen.codes.ConceptMaps)1 Mapping (com.cerner.bunsen.codes.Mapping)1 Serializable (java.io.Serializable)1 Timestamp (java.sql.Timestamp)1 Collections (java.util.Collections)1 Deque (java.util.Deque)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1