use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project bunsen by cerner.
the class ConceptMaps method expandMappingsIterator.
private static Iterator<Mapping> expandMappingsIterator(ConceptMap map) {
List<Mapping> mappings = new ArrayList<>();
for (ConceptMapGroupComponent group : map.getGroup()) {
for (SourceElementComponent element : group.getElement()) {
for (TargetElementComponent target : element.getTarget()) {
Mapping mapping = new Mapping();
mapping.setConceptMapUri(map.getUrl());
mapping.setConceptMapVersion(map.getVersion());
try {
String sourceValue = map.getSource() instanceof UriType ? map.getSourceUriType().getValue() : map.getSourceReference().getReference();
mapping.setSourceValueSet(sourceValue);
String targetValue = map.getTarget() instanceof UriType ? map.getTargetUriType().getValue() : map.getTargetReference().getReference();
mapping.setTargetValueSet(targetValue);
} catch (FHIRException fhirException) {
// an exception.
throw new RuntimeException(fhirException);
}
mapping.setSourceSystem(group.getSource());
mapping.setSourceValue(element.getCode());
mapping.setTargetSystem(group.getTarget());
mapping.setTargetValue(target.getCode());
if (target.getEquivalence() != null) {
mapping.setEquivalence(target.getEquivalence().toCode());
}
mappings.add(mapping);
}
}
}
return mappings.iterator();
}
use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project bunsen by cerner.
the class BroadcastableMappingsTest method setUp.
/**
* Sets up Spark and concept maps for testing.
*/
@BeforeClass
public static void setUp() {
spark = SparkSession.builder().master("local[2]").appName("BroadcastableMappingsTest").getOrCreate();
ConceptMap conceptMap = new ConceptMap();
conceptMap.setUrl("uri:test:concept:map").setVersion("0").setSource(new UriType("uri:test:source:valueset")).setTarget(new UriType("uri:test:target:valueset"));
ConceptMapGroupComponent group = conceptMap.addGroup().setSource("uri:test:source:system").setTarget("uri:test:target:system");
group.addElement().setCode("abc").addTarget().setCode("123");
group.addElement().setCode("def").addTarget().setCode("456");
ConceptMap delegatingMap = new ConceptMap();
delegatingMap.setUrl("uri:test:concept:delegating").setVersion("0").setSource(new UriType("uri:test:source:valueset")).setTarget(new UriType("uri:test:target:valueset"));
delegatingMap.addGroup().setSource("uri:test:source:system").setTarget("uri:test:target:system").setUnmapped(new ConceptMapGroupUnmappedComponent().setMode(ConceptMapGroupUnmappedMode.OTHERMAP).setUrl("uri:test:concept:map"));
broadcast = BroadcastableMappings.broadcast(spark, ImmutableList.of(conceptMap, delegatingMap));
}
use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project kindling by HL7.
the class PageProcessor method parseConceptMapMapping.
private ConceptMap parseConceptMapMapping(ElementDefn logical, ElementDefinition resource, String src) throws FHIRException {
if (!src.startsWith("{map:"))
return null;
ConceptMap map = new ConceptMap();
map.setId(logical.getPath() + "2" + resource.getPath());
map.setUrl("http://hl7.org/fhir/ConceptMap/" + map.getId());
map.setVersion(version.toCode());
ConceptMapGroupComponent grp = map.addGroup();
String[] statements = src.substring(0, src.length() - 1).substring(5).split("\\;");
if (statements.length == 0)
throw new FHIRException("Unable to parse map details '" + src + "'");
for (String s : statements) {
String[] p = s.split("\\=");
if (p.length < 2)
throw new FHIRException("Unable to parse map details '" + src + "'");
if (":default".equals(p[0].trim())) {
grp.getUnmapped().setMode(ConceptMapGroupUnmappedMode.FIXED);
grp.getUnmapped().setCode(p[1].trim());
} else {
grp.addElement().setCode(p[0].trim()).addTarget().setRelationship(ConceptMapRelationship.EQUIVALENT).setCode(p[1].trim());
}
}
return map;
}
use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project kindling by HL7.
the class ResourceNameConceptMapGenerator method elementForCode.
private static SourceElementComponent elementForCode(ConceptMapGroupComponent grp, String s) {
for (SourceElementComponent t : grp.getElement()) if (t.getCode().equals(s))
return t;
SourceElementComponent t = grp.addElement();
t.setCode(s);
return t;
}
use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project org.hl7.fhir.core by hapifhir.
the class ConceptMap10_50 method getGroup.
public static ConceptMapGroupComponent getGroup(ConceptMap map, String srcs, String tgts) {
for (ConceptMapGroupComponent grp : map.getGroup()) {
if (grp.getSource().equals(srcs) && grp.getTarget().equals(tgts))
return grp;
}
ConceptMapGroupComponent grp = map.addGroup();
grp.setSource(srcs);
grp.setTarget(tgts);
return grp;
}
Aggregations