Search in sources :

Example 6 with SnomedConcept

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

the class TerminologyTreeTest method getProximalPrimitiveParentsOfDefiningConceptWithPrimitiveAncestor.

@Test
public void getProximalPrimitiveParentsOfDefiningConceptWithPrimitiveAncestor() throws Exception {
    final TerminologyTree tree = new TestTree().addNode(N1, true, null, newHashSet(N2)).addNode(N2, false, newHashSet(N1), newHashSet(N3)).addNode(N3, false, newHashSet(N2)).build();
    final SnomedConcept n1 = tree.getNode(N1);
    assertThat(tree.getProximalPrimitiveParents(N3)).containsOnly(n1);
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test)

Example 7 with SnomedConcept

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

the class SnomedMergeApiTest method rebaseMultipleChangesFromParent.

@Test
public void rebaseMultipleChangesFromParent() throws Exception {
    final String concept = createNewConcept(branchPath);
    final IBranchPath task = BranchPathUtils.createPath(branchPath, "task1");
    branching.createBranch(task).statusCode(201);
    String newParentDescription1 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    String newChildDescription1 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription1).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription1).statusCode(200);
    String newParentDescription2 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    String newChildDescription2 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription2).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription2).statusCode(200);
    String newParentDescription3 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    String newChildDescription3 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription3).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription3).statusCode(200);
    SnomedConcept finalConcept = getComponent(task, SnomedComponentType.CONCEPT, concept, "descriptions(),preferredDescriptions()").statusCode(200).extract().as(SnomedConcept.class);
    // 2 default + 6 newly added
    assertThat(finalConcept.getDescriptions()).hasSize(8);
    assertThat(finalConcept.getPreferredDescriptions()).hasSize(8);
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 8 with SnomedConcept

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

the class SnomedMergeApiTest method mergeThenRebaseOtherTask.

@Test
public void mergeThenRebaseOtherTask() throws Exception {
    final String conceptA = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    final IBranchPath b = BranchPathUtils.createPath(branchPath, "b");
    branching.createBranch(a).statusCode(201);
    branching.createBranch(b).statusCode(201);
    Map<?, ?> inactivationRequest = ImmutableMap.builder().put("active", false).put("inactivationProperties", new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_SAME_AS_ASSOCIATION, Concepts.FULLY_SPECIFIED_NAME)))).put("commitComment", "Inactivated concept").build();
    updateComponent(a, SnomedComponentType.CONCEPT, conceptA, inactivationRequest).statusCode(204);
    final String conceptB = createNewConcept(b);
    merge(a, branchPath, "Merge branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    SnomedConcept conceptAOnParent = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptA, "members(),relationships()").statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptAOnParent.getRelationships()).hasSize(1);
    assertThat(conceptAOnParent.getMembers()).hasSize(2);
    merge(branchPath, b, "Rebase branch B").body("status", equalTo(Merge.Status.COMPLETED.name()));
    SnomedConcept conceptAOnBranchB = getComponent(b, SnomedComponentType.CONCEPT, conceptA, "members(),relationships()").statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptAOnBranchB.getRelationships()).hasSize(1);
    assertThat(conceptAOnBranchB.getMembers()).hasSize(2);
    getComponent(b, SnomedComponentType.CONCEPT, conceptB, "relationships()").statusCode(200).extract().as(SnomedConcept.class);
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) AssociationTarget(com.b2international.snowowl.snomed.core.domain.AssociationTarget) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 9 with SnomedConcept

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

the class SnomedMergeConflictTest method rebaseResolvableIsaRelationshipConflictTwoDifferentDestinations.

@Test
public void rebaseResolvableIsaRelationshipConflictTwoDifferentDestinations() throws Exception {
    final String concept = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String relationshipOnParent = createNewRelationship(branchPath, concept, Concepts.IS_A, Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE);
    String relationshipOnChild = createNewRelationship(a, concept, Concepts.IS_A, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipOnChild).statusCode(200);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipOnParent).statusCode(200);
    SnomedConcept conceptOnChild = getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptOnChild.getStatedParentIdsAsString()).containsOnly(Concepts.ROOT_CONCEPT, Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
    assertThat(conceptOnChild.getParentIdsAsString()).containsOnly(IComponent.ROOT_ID);
    assertThat(conceptOnChild.getStatedAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT, Concepts.LINKAGE, Concepts.ATTRIBUTE, Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.TOPLEVEL_METADATA);
    assertThat(conceptOnChild.getAncestorIdsAsString()).isEmpty();
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 10 with SnomedConcept

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

the class SnomedComponentInactivationApiTest method reuseConceptAndDescriptionInactivationIndicators.

@Test
public void reuseConceptAndDescriptionInactivationIndicators() throws Exception {
    // create a concept
    String conceptId = createNewConcept(branchPath);
    SnomedConcept concept = getConcept(conceptId, "descriptions()");
    // add pending move to concept and descriptions
    Map<?, ?> pendingMoveUpdate = ImmutableMap.of("inactivationProperties", new InactivationProperties(Concepts.PENDING_MOVE, null), "commitComment", "Set to Pending Move");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, pendingMoveUpdate).statusCode(204);
    for (SnomedDescription description : concept.getDescriptions()) {
        updateComponent(branchPath, SnomedComponentType.DESCRIPTION, description.getId(), pendingMoveUpdate).statusCode(204);
    }
    // XXX intentionally using the members() expand here to check duplication
    SnomedConcept pendingMoveConcept = getConcept(conceptId, "members(),descriptions(expand(members()))");
    // verify and collect inactivation indicator members
    SnomedReferenceSetMember conceptInactivationIndicatorMember = getIndicatorMember(pendingMoveConcept, Concepts.REFSET_CONCEPT_INACTIVITY_INDICATOR);
    SnomedReferenceSetMember fsnInactivationIndicatorMember = null;
    SnomedReferenceSetMember ptInactivationIndicatorMember = null;
    for (SnomedDescription description : pendingMoveConcept.getDescriptions()) {
        if (Concepts.FULLY_SPECIFIED_NAME.equals(description.getTypeId())) {
            fsnInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else if (Concepts.SYNONYM.equals(description.getTypeId())) {
            ptInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else {
            throw new UnsupportedOperationException();
        }
    }
    Map<?, ?> inactivationConceptRequest = ImmutableMap.builder().put("active", false).put("inactivationProperties", new InactivationProperties(Concepts.DUPLICATE, null)).put("commitComment", "Inactivated concept").build();
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, inactivationConceptRequest).statusCode(204);
    // XXX intentionally using the members() expand here to check duplication/member issues
    SnomedConcept inactivatedConcept = getConcept(conceptId, "members(),descriptions(expand(members()))");
    SnomedReferenceSetMember afterInactivationConceptInactivationIndicatorMember = getIndicatorMember(inactivatedConcept, Concepts.REFSET_CONCEPT_INACTIVITY_INDICATOR);
    SnomedReferenceSetMember afterInactivationFsnInactivationIndicatorMember = null;
    SnomedReferenceSetMember afterInactivationPtInactivationIndicatorMember = null;
    for (SnomedDescription description : inactivatedConcept.getDescriptions()) {
        if (Concepts.FULLY_SPECIFIED_NAME.equals(description.getTypeId())) {
            afterInactivationFsnInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else if (Concepts.SYNONYM.equals(description.getTypeId())) {
            afterInactivationPtInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else {
            throw new UnsupportedOperationException();
        }
    }
    assertEquals(conceptInactivationIndicatorMember.getId(), afterInactivationConceptInactivationIndicatorMember.getId());
    assertEquals(null, afterInactivationConceptInactivationIndicatorMember.getEffectiveTime());
    assertEquals(false, afterInactivationConceptInactivationIndicatorMember.isReleased());
    assertEquals(Concepts.DUPLICATE, afterInactivationConceptInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
    assertEquals(fsnInactivationIndicatorMember.getId(), afterInactivationFsnInactivationIndicatorMember.getId());
    assertEquals(null, afterInactivationFsnInactivationIndicatorMember.getEffectiveTime());
    assertEquals(false, afterInactivationFsnInactivationIndicatorMember.isReleased());
    assertEquals(Concepts.CONCEPT_NON_CURRENT, afterInactivationFsnInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
    assertEquals(ptInactivationIndicatorMember.getId(), afterInactivationPtInactivationIndicatorMember.getId());
    assertEquals(null, afterInactivationPtInactivationIndicatorMember.getEffectiveTime());
    assertEquals(false, afterInactivationPtInactivationIndicatorMember.isReleased());
    assertEquals(Concepts.CONCEPT_NON_CURRENT, afterInactivationPtInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Aggregations

SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)90 Test (org.junit.Test)42 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)17 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)15 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)15 LocalDate (java.time.LocalDate)15 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)12 SnomedConcepts (com.b2international.snowowl.snomed.core.domain.SnomedConcepts)12 Options (com.b2international.commons.options.Options)10 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)10 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)9 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)8 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)8 CodeSystemRestRequests.createCodeSystem (com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem)8 List (java.util.List)8 Map (java.util.Map)8 Collectors (java.util.stream.Collectors)8 Json (com.b2international.commons.json.Json)7 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)7 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)5