use of org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent 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();
}
Aggregations