Search in sources :

Example 11 with SnomedConcepts

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

the class SnomedSimpleTypeRefSetDSVExporter method writeValues.

private void writeValues(IProgressMonitor monitor, BufferedWriter writer) throws IOException {
    SearchResourceRequestIterator<SnomedConceptSearchRequestBuilder, SnomedConcepts> conceptIterator = getMemberConceptIterator(DATA_EXPAND);
    while (conceptIterator.hasNext()) {
        SnomedConcepts chunk = conceptIterator.next();
        writeValues(writer, chunk);
        monitor.worked(chunk.getItems().size());
    }
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConceptSearchRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedConceptSearchRequestBuilder)

Example 12 with SnomedConcepts

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

the class SnomedQueryMemberCreateDelegate method createWithNewRefSet.

private String createWithNewRefSet(SnomedReferenceSet refSet, TransactionContext context) {
    checkNonEmptyProperty(REFERENCED_COMPONENT);
    checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
    // create new simple type reference set
    final SnomedConcept referencedComponent = getProperty(REFERENCED_COMPONENT, SnomedConcept.class);
    final String referencedComponentId = new IdRequest<>(referencedComponent.toCreateRequest()).execute(context);
    // write the generated ID back to the request
    setReferencedComponentId(referencedComponentId);
    // add all matching members
    final SnomedConcepts queryResults = SnomedRequests.prepareSearchConcept().all().filterByEcl(getProperty(SnomedRf2Headers.FIELD_QUERY)).build().execute(context);
    for (SnomedConcept queryResult : queryResults) {
        SnomedComponents.newSimpleMember().withActive(isActive()).withReferencedComponent(queryResult.getId()).withModuleId(getModuleId()).withRefSet(referencedComponentId).addTo(context);
    }
    return createWithExistingRefSet(refSet, context);
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 13 with SnomedConcepts

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

the class SnomedClassificationApiTest method issue_SO_1830_testInferredEquivalentConceptParents.

@Test
public void issue_SO_1830_testInferredEquivalentConceptParents() throws Exception {
    String parentConceptId = createNewConcept(branchPath);
    String childConceptId = createNewConcept(branchPath, parentConceptId);
    String equivalentConceptId = createNewConcept(branchPath, parentConceptId);
    changeToDefining(branchPath, equivalentConceptId);
    String classificationId = getClassificationJobId(beginClassification(branchPath));
    waitForClassificationJob(branchPath, classificationId).statusCode(200).body("status", equalTo(ClassificationStatus.COMPLETED.name()));
    /* 
		 * Expecting that childConceptId will get two inferred IS A-s pointing to parentConceptId and equivalentConceptId, respectively, 
		 * while parentConceptId and equivalentConceptId each will get a single inferred IS A pointing to the root concept.
		 */
    RelationshipChanges changes = MAPPER.readValue(getRelationshipChanges(branchPath, classificationId).statusCode(200).extract().asInputStream(), RelationshipChanges.class);
    FluentIterable<RelationshipChange> changesIterable = FluentIterable.from(changes.getItems());
    assertEquals(4, changes.getTotal());
    assertTrue("All changes should be inferred.", changesIterable.allMatch(relationshipChange -> ChangeNature.NEW.equals(relationshipChange.getChangeNature())));
    assertInferredIsAExists(changesIterable, childConceptId, parentConceptId);
    assertInferredIsAExists(changesIterable, childConceptId, equivalentConceptId);
    assertInferredIsAExists(changesIterable, parentConceptId, Concepts.ROOT_CONCEPT);
    assertInferredIsAExists(changesIterable, equivalentConceptId, Concepts.ROOT_CONCEPT);
    EquivalentConceptSets equivalentConceptSets = MAPPER.readValue(getEquivalentConceptSets(branchPath, classificationId).statusCode(200).extract().asInputStream(), EquivalentConceptSets.class);
    assertEquals(1, equivalentConceptSets.getItems().size());
    SnomedConcepts equivalentConceptsInFirstSet = equivalentConceptSets.first().get().getEquivalentConcepts();
    FluentIterable<SnomedConcept> equivalentConceptsIterable = FluentIterable.from(equivalentConceptsInFirstSet);
    assertEquals(2, equivalentConceptsInFirstSet.getTotal());
    assertEquivalentConceptPresent(equivalentConceptsIterable, parentConceptId);
    assertEquivalentConceptPresent(equivalentConceptsIterable, equivalentConceptId);
}
Also used : CodeSystemVersionRestRequests.getNextAvailableEffectiveDate(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.getNextAvailableEffectiveDate) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) RestExtensions.assertCreated(com.b2international.snowowl.test.commons.rest.RestExtensions.assertCreated) CoreMatchers.anyOf(org.hamcrest.CoreMatchers.anyOf) Iterables(com.google.common.collect.Iterables) CodeSystemVersionRestRequests.createVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.createVersion) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) com.b2international.snowowl.snomed.reasoner.domain(com.b2international.snowowl.snomed.reasoner.domain) Multimap(com.google.common.collect.Multimap) SnomedRestFixtures(com.b2international.snowowl.snomed.core.rest.SnomedRestFixtures) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) SnomedComponentType(com.b2international.snowowl.snomed.core.rest.SnomedComponentType) Multimaps(com.google.common.collect.Multimaps) SnomedComponentRestRequests.getComponent(com.b2international.snowowl.snomed.core.rest.SnomedComponentRestRequests.getComponent) BigDecimal(java.math.BigDecimal) FluentIterable(com.google.common.collect.FluentIterable) Map(java.util.Map) SnomedComponentRestRequests.createComponent(com.b2international.snowowl.snomed.core.rest.SnomedComponentRestRequests.createComponent) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) Collection(java.util.Collection) SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) JsonSupport(com.b2international.snowowl.core.repository.JsonSupport) Test(org.junit.Test) CodeSystemRestRequests.createCodeSystem(com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem) SnomedClassificationRestRequests(com.b2international.snowowl.snomed.core.rest.SnomedClassificationRestRequests) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) SnomedRf2Headers(com.b2international.snowowl.snomed.common.SnomedRf2Headers) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Assert.assertEquals(org.junit.Assert.assertEquals) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) InputStream(java.io.InputStream) SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 14 with SnomedConcepts

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

the class SnomedConceptSearchApiTest method searchByMembership.

@Test
public void searchByMembership() throws Exception {
    String conceptId1 = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    String conceptId2 = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    String refSetId = createNewRefSet(branchPath, SnomedRefSetType.SIMPLE);
    String memberId1 = createNewRefSetMember(branchPath, conceptId1, refSetId);
    createNewRefSetMember(branchPath, conceptId2, refSetId);
    updateComponent(branchPath, SnomedComponentType.MEMBER, memberId1, Json.object("active", false, "commitComment", "Inactivated reference set member")).statusCode(204);
    SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("isActiveMemberOf", List.of(refSetId))).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 15 with SnomedConcepts

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

the class SnomedConceptSearchApiTest method searchByNamespace.

@Test
public void searchByNamespace() 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(Map.of("namespace", List.of("1000001"))).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)

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