Search in sources :

Example 6 with ConceptMapMappings

use of com.b2international.snowowl.core.domain.ConceptMapMappings 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());
}
Also used : ConceptMapMapping(com.b2international.snowowl.core.domain.ConceptMapMapping) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Example 7 with ConceptMapMappings

use of com.b2international.snowowl.core.domain.ConceptMapMappings 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());
}
Also used : ConceptMapMapping(com.b2international.snowowl.core.domain.ConceptMapMapping) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Example 8 with ConceptMapMappings

use of com.b2international.snowowl.core.domain.ConceptMapMappings 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());
}
Also used : CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) SnomedRefSetUtil(com.b2international.snowowl.snomed.datastore.SnomedRefSetUtil) ConceptMapMappingSearchRequestEvaluator(com.b2international.snowowl.core.request.ConceptMapMappingSearchRequestEvaluator) SnomedDisplayTermType(com.b2international.snowowl.snomed.core.SnomedDisplayTermType) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) Multimaps(com.google.common.collect.Multimaps) Strings(com.google.common.base.Strings) ExtendedLocale(com.b2international.commons.http.ExtendedLocale) Options(com.b2international.commons.options.Options) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Map(java.util.Map) ResourceURI(com.b2international.snowowl.core.ResourceURI) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) ConceptMapMapping(com.b2international.snowowl.core.domain.ConceptMapMapping) Collection(java.util.Collection) MappingCorrelation(com.b2international.snowowl.core.request.MappingCorrelation) Set(java.util.Set) ComponentURI(com.b2international.snowowl.core.uri.ComponentURI) Builder(com.b2international.snowowl.core.domain.ConceptMapMapping.Builder) IEventBus(com.b2international.snowowl.eventbus.IEventBus) Collectors(java.util.stream.Collectors) TerminologyRegistry(com.b2international.snowowl.core.terminology.TerminologyRegistry) TimeUnit(java.util.concurrent.TimeUnit) ResourceDocument(com.b2international.snowowl.core.internal.ResourceDocument) List(java.util.List) Concept(com.b2international.snowowl.core.domain.Concept) SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) ServiceProvider(com.b2international.snowowl.core.ServiceProvider) CodeSystemRequests(com.b2international.snowowl.core.codesystem.CodeSystemRequests) SnomedRf2Headers(com.b2international.snowowl.snomed.common.SnomedRf2Headers) SnomedReferenceSet(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSet) OptionsBuilder(com.b2international.commons.options.OptionsBuilder) SnomedRefSetType(com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Concept(com.b2international.snowowl.core.domain.Concept) ConceptMapMapping(com.b2international.snowowl.core.domain.ConceptMapMapping) ComponentURI(com.b2international.snowowl.core.uri.ComponentURI) ExtendedLocale(com.b2international.commons.http.ExtendedLocale) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings)

Example 9 with ConceptMapMappings

use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.

the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method filterByComponentUriAndId.

@Test
public void filterByComponentUriAndId() {
    final String refSetId = createSimpleMapTypeRefSet();
    final String filterId = "12345";
    final ComponentURI uri = ComponentURI.of(CODESYSTEM, SnomedConcept.TYPE, filterId);
    final ComponentURI sourceUri = ComponentURI.of(CODESYSTEM, SnomedConcept.TYPE, REFERENCED_COMPONENT);
    createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, filterId);
    createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, "Random map target");
    createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, uri.toString());
    final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByComponentIds(Set.of(uri.toString(), uri.identifier())).filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
    assertEquals(2, conceptMaps.getTotal());
    Set<ComponentURI> componentUris = getComponentUris(conceptMaps);
    assertThat(componentUris).containsOnly(sourceUri, uri, ComponentURI.unspecified(filterId));
}
Also used : ComponentURI(com.b2international.snowowl.core.uri.ComponentURI) ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Example 10 with ConceptMapMappings

use of com.b2international.snowowl.core.domain.ConceptMapMappings in project snow-owl by b2ihealthcare.

the class ConceptMapSearchMappingRequestSnomedMapTypeReferenceSetTest method filterByMapTarget.

@Test
public void filterByMapTarget() {
    final String refSetId = createSimpleMapTypeRefSet();
    createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_1);
    createSimpleMapTypeRefSetMember(refSetId, REFERENCED_COMPONENT, MAP_TARGET_2);
    final ConceptMapMappings conceptMaps = ConceptMapRequests.prepareSearchConceptMapMappings().all().filterByConceptMap(ComponentURI.of(CODESYSTEM, SnomedConcept.REFSET_TYPE, refSetId).toString()).filterByMapTarget(MAP_TARGET_1).setLocales("en").buildAsync().execute(Services.bus()).getSync(1, TimeUnit.MINUTES);
    assertTrue(!conceptMaps.isEmpty());
    conceptMaps.forEach(concepMap -> assertEquals(MAP_TARGET_1, concepMap.getTargetComponentURI().identifier()));
}
Also used : ConceptMapMappings(com.b2international.snowowl.core.domain.ConceptMapMappings) Test(org.junit.Test)

Aggregations

ConceptMapMappings (com.b2international.snowowl.core.domain.ConceptMapMappings)13 Test (org.junit.Test)11 ConceptMapMapping (com.b2international.snowowl.core.domain.ConceptMapMapping)4 ComponentURI (com.b2international.snowowl.core.uri.ComponentURI)3 Options (com.b2international.commons.options.Options)2 ResourceURI (com.b2international.snowowl.core.ResourceURI)2 ServiceProvider (com.b2international.snowowl.core.ServiceProvider)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)1 OptionsBuilder (com.b2international.commons.options.OptionsBuilder)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)1 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)1 Concept (com.b2international.snowowl.core.domain.Concept)1 Builder (com.b2international.snowowl.core.domain.ConceptMapMapping.Builder)1 ResourceDocument (com.b2international.snowowl.core.internal.ResourceDocument)1 ConceptMapMappingSearchRequestEvaluator (com.b2international.snowowl.core.request.ConceptMapMappingSearchRequestEvaluator)1 MappingCorrelation (com.b2international.snowowl.core.request.MappingCorrelation)1