use of org.hl7.fhir.r4b.model.ConceptMap in project pathling by aehrc.
the class ConceptMapBuilder method build.
@Nonnull
public ConceptMap build() {
final Map<Pair<VersionedSystem, VersionedSystem>, List<ConceptMapEntry>> mappingsBySystem = entries.stream().collect(Collectors.groupingBy(ConceptMapBuilder::getVersionedSystems));
final ConceptMap result = new ConceptMap();
result.setStatus(PublicationStatus.ACTIVE);
mappingsBySystem.forEach((srcAndTarget, systemMappings) -> {
final ConceptMapGroupComponent group = result.addGroup();
group.setSource(srcAndTarget.getLeft().getSystem());
group.setSourceVersion(srcAndTarget.getLeft().getVersion());
group.setTarget(srcAndTarget.getRight().getSystem());
group.setTargetVersion(srcAndTarget.getRight().getVersion());
systemMappings.forEach(m -> {
final SourceElementComponent sourceElement = group.addElement();
sourceElement.setCode(m.getSource().getCode());
final TargetElementComponent targetElement = sourceElement.addTarget();
targetElement.setCode(m.getTarget().getCode());
targetElement.setEquivalence(m.getEquivalence());
});
});
return result;
}
use of org.hl7.fhir.r4b.model.ConceptMap in project MtbImporter by nr23730.
the class FhirResolver method resolveOncoTree.
/**
* Converts an ICD-O-3 classification into an OncoTree coding.
* @param topography ICD-O-3 topography code (first part)
* @param morphology ICD-O-3 morpholoy code (second part)
* @return FHIR coding for the corresponding OncoTree-Code.
*/
public static Coding resolveOncoTree(String topography, String morphology) {
Parameters params = new Parameters();
params.addParameter("system", new UriType(Settings.getFhir().getTerminology().getIcdO3Url()));
params.addParameter("target", new UriType(Settings.getFhir().getTerminology().getOncoTreeUrl()));
params.addParameter("conceptMap", new UriType(Settings.getFhir().getTerminology().getIcdO3ToOncoTreeConceptMapUrl()));
params.addParameter("code", topography.split(" ")[0] + " " + morphology.split(" ")[0]);
try {
Parameters result = terminologyClient.operation().onInstance("ConceptMap/" + Settings.getFhir().getTerminology().getIcdO3ToOncoTreeConceptMapId()).named("translate").withParameters(params).execute();
for (ParametersParameterComponent p : result.getParameter()) {
if (!p.getName().equals("match")) {
continue;
}
Coding coding = null;
String str = null;
for (ParametersParameterComponent c : p.getPart()) {
if (c.getValue() instanceof Coding) {
coding = (Coding) c.getValue();
}
if (c.getValue() instanceof StringType && c.getName().equals("source")) {
str = ((StringType) c.getValue()).getValue();
}
}
if (str != null && str.equals(Settings.getFhir().getTerminology().getIcdO3ToOncoTreeConceptMapUrl())) {
return coding;
}
}
} catch (FhirClientConnectionException e) {
Logger.error("Could not connect to FHIR Terminology Server", e);
}
return new Coding();
}
use of org.hl7.fhir.r4b.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());
}
use of org.hl7.fhir.r4b.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());
}
use of org.hl7.fhir.r4b.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));
}
Aggregations