Search in sources :

Example 1 with ConceptMap

use of org.hl7.fhir.dstu2.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.dstu2.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.dstu2.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.dstu2.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.dstu2.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)34 Test (org.junit.Test)31 ArrayList (java.util.ArrayList)29 HashMap (java.util.HashMap)27 FHIRException (org.hl7.fhir.exceptions.FHIRException)26 ConceptMap (org.hl7.fhir.r4.model.ConceptMap)23 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)23 ConceptMap (org.hl7.fhir.r5.model.ConceptMap)22 ConceptMapGroupComponent (org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent)17 ConceptMapGroupComponent (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent)15 HashSet (java.util.HashSet)13 ConceptMapGroupComponent (org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)12 FileOutputStream (java.io.FileOutputStream)11 ValueSet (org.hl7.fhir.r5.model.ValueSet)11 SourceElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)10 Test (org.junit.jupiter.api.Test)10 ConceptMap (org.hl7.fhir.dstu2016may.model.ConceptMap)9 Coding (org.hl7.fhir.r4.model.Coding)9 SourceElementComponent (org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent)9