use of com.b2international.snowowl.core.domain.ConceptMapMapping in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method useDefaultPreferredDisplay.
@Test
public void useDefaultPreferredDisplay() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertEquals(1, conceptMaps.getTotal());
final ConceptMapMapping conceptMapMapping = conceptMaps.first().get();
assertEquals(ID, conceptMapMapping.getSourceTerm());
assertEquals(testName.getMethodName(), conceptMapMapping.getConceptMapTerm());
}
use of com.b2international.snowowl.core.domain.ConceptMapMapping in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method setPreferredDisplayToPT.
@Test
public void setPreferredDisplayToPT() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setLocales("en").setPreferredDisplay("PT").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertEquals(1, conceptMaps.getTotal());
final ConceptMapMapping conceptMapMapping = conceptMaps.first().get();
assertEquals(PT, conceptMapMapping.getSourceTerm());
assertEquals(testName.getMethodName(), conceptMapMapping.getConceptMapTerm());
}
use of com.b2international.snowowl.core.domain.ConceptMapMapping in project snow-owl by b2ihealthcare.
the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method setPreferredDisplayToFSN.
@Test
public void setPreferredDisplayToFSN() {
final String refSetId = createSimpleMapTypeRefSet();
createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setPreferredDisplay("FSN").setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
assertEquals(1, conceptMaps.getTotal());
final ConceptMapMapping conceptMapMapping = conceptMaps.first().get();
assertEquals(FSN, conceptMapMapping.getSourceTerm());
assertEquals(testName.getMethodName(), conceptMapMapping.getConceptMapTerm());
}
use of com.b2international.snowowl.core.domain.ConceptMapMapping in project snow-owl by b2ihealthcare.
the class SnomedConceptMapSearchRequestEvaluator method toCollectionResource.
private ConceptMapMappings toCollectionResource(SnomedReferenceSetMembers referenceSetMembers, ResourceURI uri, ServiceProvider context, Options search, SnomedDisplayTermType snomedDisplayTermType) {
final Set<String> refSetsToFetch = referenceSetMembers.stream().map(SnomedReferenceSetMember::getRefsetId).collect(Collectors.toSet());
final Map<String, SnomedConcept> refSetsById = SnomedRequests.prepareSearchConcept().all().filterByIds(refSetsToFetch).setLocales(search.getList(OptionKey.LOCALES, ExtendedLocale.class)).setExpand("pt(),referenceSet()").build(uri).execute(context.service(IEventBus.class)).getSync(1, TimeUnit.MINUTES).stream().collect(Collectors.toMap(SnomedConcept::getId, concept -> concept));
final Map<String, ComponentURI> targetComponentsByRefSetId = getTargetComponentsByRefSetId(context, refSetsById);
List<ConceptMapMapping> mappings = referenceSetMembers.stream().filter(m -> SnomedConcept.TYPE.equals(m.getReferencedComponent().getComponentType())).map(m -> {
return toMapping(m, uri, targetComponentsByRefSetId.get(m.getRefsetId()), snomedDisplayTermType, refSetsById);
}).collect(Collectors.toList());
if (!mappings.isEmpty()) {
final Map<String, Concept> conceptsById = Multimaps.index(mappings, mapping -> mapping.getTargetComponentURI().resourceUri()).asMap().entrySet().stream().filter(entry -> !TerminologyRegistry.UNSPECIFIED.equals(entry.getKey().getResourceId())).map(entry -> {
final Set<String> idsToFetch = entry.getValue().stream().map(map -> map.getTargetComponentURI().identifier()).collect(Collectors.toSet());
return CodeSystemRequests.prepareSearchConcepts().all().filterByCodeSystemUri(entry.getKey()).filterByIds(idsToFetch).buildAsync().execute(context.service(IEventBus.class)).getSync(5, TimeUnit.MINUTES).stream().collect(Collectors.toMap(Concept::getId, c -> c));
}).flatMap(map -> map.entrySet().stream()).collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue(), (concept1, concept2) -> concept1));
mappings = mappings.stream().map(mapping -> {
final String mapTargetId = mapping.getTargetComponentURI().identifier();
if (conceptsById.containsKey(mapTargetId) && !mapping.getTargetComponentURI().isUnspecified()) {
final Concept concept = conceptsById.get(mapTargetId);
return mapping.toBuilder().targetTerm(concept.getTerm()).targetIconId(concept.getIconId()).build();
} else {
return mapping;
}
}).collect(Collectors.toList());
}
return new ConceptMapMappings(mappings, referenceSetMembers.getSearchAfter(), referenceSetMembers.getLimit(), referenceSetMembers.getTotal());
}
Aggregations