Search in sources :

Example 1 with InactivationProperties

use of com.b2international.snowowl.snomed.core.domain.InactivationProperties 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 2 with InactivationProperties

use of com.b2international.snowowl.snomed.core.domain.InactivationProperties 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)

Example 3 with InactivationProperties

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

the class SnomedDescriptionApiTest method updateIndicatorAfterInactivation.

@Test
public void updateIndicatorAfterInactivation() {
    String descriptionToInactivate = createNewDescription(branchPath);
    assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.DUPLICATE, Collections.emptyList()));
    assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.OUTDATED, Collections.emptyList()));
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 4 with InactivationProperties

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

the class SnomedDescriptionApiTest method updateInactivationIndicatorOnActiveReleasedDescription.

@Test
public void updateInactivationIndicatorOnActiveReleasedDescription() throws Exception {
    String descriptionToInactivate = createNewDescription(branchPath);
    assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.PENDING_MOVE, Collections.emptyList()));
    // release component
    createCodeSystemAndVersion(branchPath, "SNOMEDCT-RELDESC-INACTIVATIONINDICATOR", "v1", LocalDate.parse("2018-07-01"));
    SnomedDescription description = assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.CONCEPT_NON_CURRENT, Collections.emptyList())).extract().as(SnomedDescription.class);
    List<SnomedReferenceSetMember> inactivationIndicators = description.getMembers().stream().filter(member -> Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR.equals(member.getRefsetId())).collect(Collectors.toList());
    final SnomedReferenceSetMember inactivationIndicator = Iterables.getOnlyElement(inactivationIndicators);
    assertEquals(Concepts.CONCEPT_NON_CURRENT, inactivationIndicator.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
    assertNull(inactivationIndicator.getEffectiveTime());
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) CoreMatchers(org.hamcrest.CoreMatchers) RestExtensions.assertCreated(com.b2international.snowowl.test.commons.rest.RestExtensions.assertCreated) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) Json(com.b2international.commons.json.Json) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SnomedRestFixtures(com.b2international.snowowl.snomed.core.rest.SnomedRestFixtures) SnomedComponentType(com.b2international.snowowl.snomed.core.rest.SnomedComponentType) IdentifierStatus(com.b2international.snowowl.snomed.cis.domain.IdentifierStatus) ApplicationContext.getServiceForClass(com.b2international.snowowl.core.ApplicationContext.getServiceForClass) Map(java.util.Map) RevisionIndex(com.b2international.index.revision.RevisionIndex) RepositoryRequest(com.b2international.snowowl.core.request.RepositoryRequest) ISnomedIdentifierService(com.b2international.snowowl.snomed.cis.ISnomedIdentifierService) ConflictException(com.b2international.commons.exceptions.ConflictException) BulkRequestBuilder(com.b2international.snowowl.core.events.bulk.BulkRequestBuilder) RepositoryManager(com.b2international.snowowl.core.RepositoryManager) ContentType(io.restassured.http.ContentType) TimestampProvider(com.b2international.index.revision.TimestampProvider) InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) LocalDate(java.time.LocalDate) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) SnomedComponentRestRequests(com.b2international.snowowl.snomed.core.rest.SnomedComponentRestRequests) CodeSystemVersionRestRequests.getNextAvailableEffectiveDate(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.getNextAvailableEffectiveDate) Acceptability(com.b2international.snowowl.snomed.core.domain.Acceptability) Iterables(com.google.common.collect.Iterables) CodeSystemVersionRestRequests.createVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.createVersion) SnomedRefSetRestRequests.updateRefSetComponent(com.b2international.snowowl.snomed.core.rest.SnomedRefSetRestRequests.updateRefSetComponent) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) ModuleIdProvider(com.b2international.snowowl.snomed.datastore.request.ModuleRequest.ModuleIdProvider) AssociationTarget(com.b2international.snowowl.snomed.core.domain.AssociationTarget) TermFilter(com.b2international.snowowl.core.request.TermFilter) Environment(com.b2international.snowowl.core.setup.Environment) SnomedRequests(com.b2international.snowowl.snomed.datastore.request.SnomedRequests) CodeSystemVersionRestRequests.createCodeSystemAndVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.createCodeSystemAndVersion) BulkRequest(com.b2international.snowowl.core.events.bulk.BulkRequest) RestExtensions.givenAuthenticatedRequest(com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest) SctId(com.b2international.snowowl.snomed.cis.domain.SctId) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) BranchPathUtils(com.b2international.snowowl.core.branch.BranchPathUtils) SnomedApiTestConstants(com.b2international.snowowl.snomed.core.rest.SnomedApiTestConstants) SnomedRefSetRestRequests.bulkUpdateMembers(com.b2international.snowowl.snomed.core.rest.SnomedRefSetRestRequests.bulkUpdateMembers) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) SnomedTerminologyComponentConstants(com.b2international.snowowl.snomed.common.SnomedTerminologyComponentConstants) TextConstants(com.b2international.index.compat.TextConstants) CodeSystemRestRequests.createCodeSystem(com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem) TimeUnit(java.util.concurrent.TimeUnit) Assert.assertNull(org.junit.Assert.assertNull) TransactionContext(com.b2international.snowowl.core.domain.TransactionContext) SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) DateTimeFormatter(java.time.format.DateTimeFormatter) SnomedRf2Headers(com.b2international.snowowl.snomed.common.SnomedRf2Headers) Collections(java.util.Collections) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Assert.assertEquals(org.junit.Assert.assertEquals) ApplicationContext(com.b2international.snowowl.core.ApplicationContext) ComponentCategory(com.b2international.snowowl.core.terminology.ComponentCategory) SnomedRefSetType(com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType) InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 5 with InactivationProperties

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

the class SnomedDescriptionApiTest method inactivateWithIndicator.

@Test
public void inactivateWithIndicator() {
    String descriptionId = createNewDescription(branchPath);
    assertInactivation(branchPath, descriptionId, new InactivationProperties(Concepts.DUPLICATE, Collections.emptyList()));
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Aggregations

InactivationProperties (com.b2international.snowowl.snomed.core.domain.InactivationProperties)7 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)7 Test (org.junit.Test)7 AssociationTarget (com.b2international.snowowl.snomed.core.domain.AssociationTarget)4 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)2 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)2 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)2 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)2 ConflictException (com.b2international.commons.exceptions.ConflictException)1 Json (com.b2international.commons.json.Json)1 TextConstants (com.b2international.index.compat.TextConstants)1 RevisionIndex (com.b2international.index.revision.RevisionIndex)1 TimestampProvider (com.b2international.index.revision.TimestampProvider)1 ApplicationContext (com.b2international.snowowl.core.ApplicationContext)1 ApplicationContext.getServiceForClass (com.b2international.snowowl.core.ApplicationContext.getServiceForClass)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 BranchPathUtils (com.b2international.snowowl.core.branch.BranchPathUtils)1 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)1 BulkRequest (com.b2international.snowowl.core.events.bulk.BulkRequest)1 BulkRequestBuilder (com.b2international.snowowl.core.events.bulk.BulkRequestBuilder)1