Search in sources :

Example 16 with SnomedConcepts

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

the class SnomedConceptSearchApiTest method searchByNamespaceConceptId.

@Test
public void searchByNamespaceConceptId() throws Exception {
    String conceptId = createNewConcept(branchPath, createConceptRequestBody(Concepts.ROOT_CONCEPT).with("namespaceId", "1000001").with("commitComment", "Create new concept"));
    SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(// Extension Namespace {1000001} (namespace concept)
    Map.of("namespaceConceptId", List.of("370138007"))).get("/{path}/concepts/", branchPath.getPath()).then().assertThat().statusCode(200).extract().as(SnomedConcepts.class);
    assertThat(hits.getTotal()).isEqualTo(1);
    assertThat(hits.getItems()).allMatch(c -> conceptId.equals(c.getId()));
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 17 with SnomedConcepts

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

the class SnomedConceptSearchApiTest method searchBySemanticTag.

@Test
public void searchBySemanticTag() throws Exception {
    String conceptId = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    createNewDescription(branchPath, Json.object("conceptId", conceptId, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.FULLY_SPECIFIED_NAME, "term", "My awesome fsn (tag)", "languageCode", "en", "acceptability", UK_PREFERRED_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE, "commitComment", "New FSN"));
    SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("semanticTag", "tag")).get("/{path}/concepts/", branchPath.getPath()).then().assertThat().statusCode(200).extract().as(SnomedConcepts.class);
    assertThat(hits.getTotal()).isEqualTo(1);
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 18 with SnomedConcepts

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

the class SnomedConceptSearchApiTest method searchByBothSemanticTagAndTerm.

/**
 * Related to https://github.com/b2ihealthcare/snow-owl/issues/738
 */
@Test
public void searchByBothSemanticTagAndTerm() throws Exception {
    String conceptId = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    createNewDescription(branchPath, Json.object("conceptId", conceptId, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.FULLY_SPECIFIED_NAME, "term", "My awesome fsn (tag)", "languageCode", "en", "acceptability", UK_PREFERRED_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE, "commitComment", "New FSN"));
    createNewDescription(branchPath, Json.object("conceptId", conceptId, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.FULLY_SPECIFIED_NAME, "term", "My another fsn (other)", "languageCode", "en", "acceptability", UK_PREFERRED_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE, "commitComment", "New FSN"));
    SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("term", "another", "semanticTag", "tag")).get("/{path}/concepts/", branchPath.getPath()).then().assertThat().statusCode(200).extract().as(SnomedConcepts.class);
    assertThat(hits.getTotal()).isEqualTo(1);
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 19 with SnomedConcepts

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

the class EquivalentConceptSetConverter method toResource.

@Override
protected EquivalentConceptSet toResource(final EquivalentConceptSetDocument entry) {
    final EquivalentConceptSet resource = new EquivalentConceptSet();
    resource.setClassificationId(entry.getClassificationId());
    resource.setUnsatisfiable(entry.isUnsatisfiable());
    final List<SnomedConcept> items = newArrayList();
    for (final LongIterator itr = entry.getConceptIds().iterator(); itr.hasNext(); ) /* empty */
    {
        items.add(new SnomedConcept(Long.toString(itr.next())));
    }
    final SnomedConcepts equivalentConcepts = new SnomedConcepts(items, null, items.size(), items.size());
    resource.setEquivalentConcepts(equivalentConcepts);
    return resource;
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) EquivalentConceptSet(com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSet) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) LongIterator(com.b2international.collections.longs.LongIterator)

Example 20 with SnomedConcepts

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

the class ConceptChangeConverter method expand.

@Override
public void expand(final List<ConceptChange> results) {
    if (!expand().containsKey(ConceptChange.Expand.CONCEPT)) {
        return;
    }
    /*
		 * Depending on the concept change search request, we might need to issue
		 * SNOMED CT searches against multiple branches; find out which ones we have.
		 */
    final Multimap<String, ConceptChange> itemsByBranch = getItemsByBranch(results);
    // Check if we only need to load inferred concepts in their entirety
    final Options expandOptions = expand().getOptions(ConceptChange.Expand.CONCEPT);
    // pt() and fsn() are the only useful options here
    final Options conceptExpandOptions = expandOptions.getOptions("expand");
    conceptExpandOptions.keySet().retainAll(CONCEPT_EXPAND_OPTIONS);
    for (final String branch : itemsByBranch.keySet()) {
        final Collection<ConceptChange> itemsForCurrentBranch = itemsByBranch.get(branch);
        final Set<String> conceptIds = itemsForCurrentBranch.stream().map(c -> c.getConcept().getOriginConceptId()).collect(Collectors.toSet());
        final Request<BranchContext, SnomedConcepts> conceptSearchRequest = SnomedRequests.prepareSearchConcept().filterByIds(conceptIds).setLimit(conceptIds.size()).setExpand(conceptExpandOptions).setLocales(locales()).build();
        final SnomedConcepts concepts = new BranchRequest<>(branch, new RevisionIndexReadRequest<>(conceptSearchRequest)).execute(context());
        final Map<String, SnomedConcept> conceptsById = Maps.uniqueIndex(concepts, SnomedConcept::getId);
        for (final ConceptChange item : itemsForCurrentBranch) {
            final ReasonerConcept reasonerConcept = item.getConcept();
            final String conceptId = reasonerConcept.getOriginConceptId();
            final SnomedConcept expandedConcept = conceptsById.get(conceptId);
            reasonerConcept.setDefinitionStatusId(expandedConcept.getDefinitionStatusId());
            reasonerConcept.setPt(expandedConcept.getPt());
            reasonerConcept.setFsn(expandedConcept.getFsn());
        // reasonerConcept.setReleased(...) is already set
        }
    }
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) BranchRequest(com.b2international.snowowl.core.request.BranchRequest) RepositoryContext(com.b2international.snowowl.core.domain.RepositoryContext) ImmutableSet(com.google.common.collect.ImmutableSet) ClassificationRequests(com.b2international.snowowl.snomed.reasoner.request.ClassificationRequests) Collection(java.util.Collection) Request(com.b2international.snowowl.core.events.Request) SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) com.b2international.snowowl.snomed.reasoner.domain(com.b2international.snowowl.snomed.reasoner.domain) Set(java.util.Set) Multimap(com.google.common.collect.Multimap) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) RevisionIndexReadRequest(com.b2international.snowowl.core.request.RevisionIndexReadRequest) Multimaps(com.google.common.collect.Multimaps) List(java.util.List) ExtendedLocale(com.b2international.commons.http.ExtendedLocale) SnomedRequests(com.b2international.snowowl.snomed.datastore.request.SnomedRequests) Options(com.b2international.commons.options.Options) Map(java.util.Map) ConceptChangeDocument(com.b2international.snowowl.snomed.reasoner.index.ConceptChangeDocument) BranchContext(com.b2international.snowowl.core.domain.BranchContext) BaseResourceConverter(com.b2international.snowowl.core.request.BaseResourceConverter) Options(com.b2international.commons.options.Options) RevisionIndexReadRequest(com.b2international.snowowl.core.request.RevisionIndexReadRequest) SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) BranchContext(com.b2international.snowowl.core.domain.BranchContext)

Aggregations

SnomedConcepts (com.b2international.snowowl.snomed.core.domain.SnomedConcepts)20 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)12 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)7 Options (com.b2international.commons.options.Options)6 Test (org.junit.Test)6 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)5 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)5 BranchContext (com.b2international.snowowl.core.domain.BranchContext)4 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)4 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)4 SnomedConceptSearchRequestBuilder (com.b2international.snowowl.snomed.datastore.request.SnomedConceptSearchRequestBuilder)4 Collection (java.util.Collection)4 List (java.util.List)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)3 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)3 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)3 com.b2international.snowowl.snomed.reasoner.domain (com.b2international.snowowl.snomed.reasoner.domain)3 Multimap (com.google.common.collect.Multimap)3