Search in sources :

Example 11 with SnomedReferenceSetMembers

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

the class SnomedConceptMapSearchRequestEvaluator method evaluate.

@Override
public ConceptMapMappings evaluate(ResourceURI uri, ServiceProvider context, Options search) {
    final String preferredDisplay = search.get(OptionKey.DISPLAY, String.class);
    final SnomedDisplayTermType snomedDisplayTermType = SnomedDisplayTermType.getEnum(preferredDisplay);
    SnomedReferenceSetMembers referenceSetMembers = fetchRefsetMembers(uri, context, search, snomedDisplayTermType);
    return toCollectionResource(referenceSetMembers, uri, context, search, snomedDisplayTermType);
}
Also used : SnomedDisplayTermType(com.b2international.snowowl.snomed.core.SnomedDisplayTermType) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)

Example 12 with SnomedReferenceSetMembers

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

the class SnomedDescriptionApiTest method updateAcceptabilityWithDefaultModule.

@Test
public void updateAcceptabilityWithDefaultModule() throws Exception {
    // All preferred descriptions in the UK language reference set should be changed to acceptable on SNOMED CT Root
    changeToAcceptable(branchPath, Concepts.ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_UK);
    // Add new UK preferred term to SNOMED CT Root
    String descriptionId = createNewDescription(branchPath, Concepts.ROOT_CONCEPT, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    // All preferred descriptions in the US language reference set should be changed to acceptable on SNOMED CT Root
    changeToAcceptable(branchPath, Concepts.ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_US);
    // Change UK preferred synonym to US preferred, UK acceptable, with default module ID parameter
    Json requestBody = Json.object("acceptability", Json.object(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE, Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED), // SNOMED CT Spanish edition module
    "defaultModuleId", // SNOMED CT Spanish edition module
    "449081005", "commitComment", "Changed UK, added US acceptability to description");
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
    // Check language member count and module
    SnomedReferenceSetMembers members = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).body("members.items.refsetId", hasItems(Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.REFSET_LANGUAGE_TYPE_US)).extract().as(SnomedDescription.class).getMembers();
    assertEquals(2, members.getTotal());
    members.forEach(m -> assertEquals("Reference set member should be placed in the default module", "449081005", m.getModuleId()));
    getComponent(branchPath, SnomedComponentType.CONCEPT, Concepts.ROOT_CONCEPT, "pt()").statusCode(200).body("pt.id", equalTo(descriptionId));
}
Also used : SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 13 with SnomedReferenceSetMembers

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

the class SnomedDescriptionApiTest method updateAcceptabilityWithRemove.

@Test
public void updateAcceptabilityWithRemove() throws Exception {
    changeToAcceptable(branchPath, Concepts.ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_US);
    String descriptionId = createNewDescription(branchPath, Concepts.ROOT_CONCEPT, Concepts.SYNONYM, Map.<String, Acceptability>of(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE, Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED));
    Json requestBody = Json.object("acceptability", Json.object(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE), "commitComment", "Removed US preferred acceptability from description");
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
    SnomedReferenceSetMembers members = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class).getMembers();
    assertEquals(1, members.getTotal());
    SnomedReferenceSetMember member = Iterables.getOnlyElement(members);
    assertEquals(Concepts.REFSET_LANGUAGE_TYPE_UK, member.getRefsetId());
    assertEquals(Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_ACCEPTABLE, member.getProperties().get(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID));
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 14 with SnomedReferenceSetMembers

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

the class SnomedConceptApiTest method updateInactivationIndicatorOnActiveConceptWithAssociationTargets.

@Test
public void updateInactivationIndicatorOnActiveConceptWithAssociationTargets() throws Exception {
    String conceptId = createNewConcept(branchPath);
    Map<?, ?> requestBody = createRefSetMemberRequestBody(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, conceptId).with(SnomedRf2Headers.FIELD_TARGET_COMPONENT_ID, Concepts.ROOT_CONCEPT).with("commitComment", "Created new reference set member");
    final String associationMemberId = lastPathSegment(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(201).extract().header("Location"));
    // ensure that the concept does not have any indicator set before the update
    SnomedReferenceSetMembers currentMembers = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "inactivationProperties(),members()").statusCode(200).body("inactivationProperties.inactivationIndicatorId", nullValue()).body("inactivationProperties.associationTargets.referenceSetId", equalTo(List.of(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION))).body("inactivationProperties.associationTargets.targetComponentId", equalTo(List.of(Concepts.ROOT_CONCEPT))).extract().jsonPath().getObject("members", SnomedReferenceSetMembers.class);
    Map<?, ?> updateReq = Json.object("inactivationProperties", new InactivationProperties(Concepts.PENDING_MOVE, List.of(new AssociationTarget(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, Concepts.ROOT_CONCEPT))), // XXX also pass the current members to the update, without the fix this would cause duplicate association members
    "members", currentMembers, "commitComment", "Add a pending move indicator to an active concept");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, updateReq).statusCode(204);
    List<String> memberIds = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "inactivationProperties(),members()").statusCode(200).body("inactivationProperties.inactivationIndicatorId", equalTo(Concepts.PENDING_MOVE)).body("inactivationProperties.associationTargets.referenceSetId", equalTo(List.of(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION))).body("inactivationProperties.associationTargets.targetComponentId", equalTo(List.of(Concepts.ROOT_CONCEPT))).extract().path("members.items.id");
    assertThat(memberIds.remove(associationMemberId)).isTrue();
    assertThat(memberIds.remove(associationMemberId)).isFalse();
    // the remaining member is the inactivation indicator
    assertThat(memberIds).hasSize(1);
}
Also used : SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Test(org.junit.Test)

Example 15 with SnomedReferenceSetMembers

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

the class SnomedConceptApiTest method updateAssociationTargetWithDefaultModule.

@Test
public void updateAssociationTargetWithDefaultModule() throws Exception {
    String conceptToInactivate = createNewConcept(branchPath);
    String firstAssociationTarget = createNewConcept(branchPath);
    String secondAssociationTarget = createNewConcept(branchPath);
    // Inactivate the duplicate concept and point to the other one
    assertInactivation(branchPath, conceptToInactivate, new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_POSSIBLY_EQUIVALENT_TO_ASSOCIATION, firstAssociationTarget))));
    // Update the inactivation reason and association target properties, specifying the module
    final ValidatableResponse response = assertInactivation(branchPath, conceptToInactivate, new InactivationProperties(Concepts.AMBIGUOUS, List.of(new AssociationTarget(Concepts.REFSET_REPLACED_BY_ASSOCIATION, secondAssociationTarget))), // defaultModuleId
    "449081005");
    // Check that the default module is honored
    final SnomedReferenceSetMembers refSetMembers = response.extract().body().jsonPath().getObject("members", SnomedReferenceSetMembers.class);
    refSetMembers.forEach(m -> assertEquals("Reference set member should be placed in the default module", "449081005", m.getModuleId()));
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Test(org.junit.Test)

Aggregations

SnomedReferenceSetMembers (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)20 Test (org.junit.Test)14 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)10 Json (com.b2international.commons.json.Json)9 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)9 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)5 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)5 Options (com.b2international.commons.options.Options)4 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)4 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)3 ComponentURI (com.b2international.snowowl.core.uri.ComponentURI)3 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)3 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)3 OptionsBuilder (com.b2international.commons.options.OptionsBuilder)2 ResourceURI (com.b2international.snowowl.core.ResourceURI)2 CodeSystemRequests (com.b2international.snowowl.core.codesystem.CodeSystemRequests)2 BranchContext (com.b2international.snowowl.core.domain.BranchContext)2 SnomedDisplayTermType (com.b2international.snowowl.snomed.core.SnomedDisplayTermType)2 SnomedCoreComponent (com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent)2 SnomedRefSetUtil (com.b2international.snowowl.snomed.datastore.SnomedRefSetUtil)2