Search in sources :

Example 6 with Mapping

use of com.cerner.bunsen.spark.codes.Mapping 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 : Mapping(com.cerner.bunsen.spark.codes.Mapping) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 7 with Mapping

use of com.cerner.bunsen.spark.codes.Mapping in project bunsen by cerner.

the class ConceptMapsTest method testLoadExpandedMappings.

@Test
public void testLoadExpandedMappings() throws FHIRException {
    ConceptMap map = conceptMap("urn:cerner:map:testmap", "1");
    // Explicitly create a mapping dataset to simulate an ETL load from an external source.
    Mapping mapping = new Mapping();
    mapping.setConceptMapUri(map.getUrl());
    mapping.setConceptMapVersion(map.getVersion());
    mapping.setSourceValueSet("urn:source:valueset");
    mapping.setTargetValue("urn:target:valueset");
    mapping.setSourceSystem("urn:source:system");
    mapping.setSourceValue("urn:source:code:a");
    mapping.setTargetSystem("urn:target:system");
    mapping.setTargetValue("urn:target:code:1");
    Dataset<Mapping> mappings = spark.createDataset(Arrays.asList(mapping), ConceptMaps.getMappingEncoder());
    ConceptMaps maps = ConceptMaps.getEmpty(spark).withExpandedMap(map, mappings);
    Dataset<Mapping> loadedMappings = maps.getMappings();
    Assert.assertEquals(1, loadedMappings.count());
    Mapping loadedMapping = loadedMappings.head();
    Assert.assertEquals(mapping, loadedMapping);
}
Also used : Mapping(com.cerner.bunsen.spark.codes.Mapping) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Aggregations

Mapping (com.cerner.bunsen.spark.codes.Mapping)7 ConceptMap (org.hl7.fhir.dstu3.model.ConceptMap)4 ConceptMapGroupComponent (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent)3 SourceElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)3 Test (org.junit.Test)3 FhirVersionEnum (ca.uhn.fhir.context.FhirVersionEnum)2 FhirContexts (com.cerner.bunsen.FhirContexts)2 SparkRowConverter (com.cerner.bunsen.spark.SparkRowConverter)2 UrlAndVersion (com.cerner.bunsen.spark.codes.UrlAndVersion)2 BroadcastableMappings (com.cerner.bunsen.spark.codes.broadcast.BroadcastableMappings)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 JavaRDD (org.apache.spark.api.java.JavaRDD)2 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)2 Function (org.apache.spark.api.java.function.Function)2 Broadcast (org.apache.spark.broadcast.Broadcast)2 Dataset (org.apache.spark.sql.Dataset)2