Search in sources :

Example 1 with SnomedReferenceSetMembers

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

the class SnomedRefSetMemberApiTest method searchOWLAxiomRefsetMemberBySourceTypeDestination.

@Test
public void searchOWLAxiomRefsetMemberBySourceTypeDestination() {
    String conceptId = createNewConcept(branchPath);
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, conceptId).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, "SubClassOf(:" + conceptId + " :" + Concepts.NAMESPACE_ROOT + ")").with("commitComment", "Created new OWL Axiom reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMembers results = givenAuthenticatedRequest(SnomedApiTestConstants.SCT_API).queryParam("referencedComponentId", conceptId).queryParam("owlExpression.typeId", Concepts.IS_A).queryParam("owlExpression.destinationId", Concepts.NAMESPACE_ROOT).get("/{path}/members", branchPath.getPath()).then().extract().as(SnomedReferenceSetMembers.class);
    assertEquals(1, results.getItems().size());
    SnomedReferenceSetMember member = results.getItems().stream().findFirst().get();
    assertEquals(memberId, member.getId());
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 2 with SnomedReferenceSetMembers

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

the class SnomedConceptInactivationApiTest method toggleDefinitionStatusAtStatusChange.

@Test
public void toggleDefinitionStatusAtStatusChange() {
    String conceptId = createNewConcept(branchPath);
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, conceptId).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, "EquivalentClasses(:" + conceptId + " :" + Concepts.NAMESPACE_ROOT + ")").with("commitComment", "Created new equivalent class OWL Axiom reference set member");
    assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMembers members = SnomedComponentRestRequests.searchComponent(branchPath, SnomedComponentType.MEMBER, Map.of("referencedComponentId", conceptId)).extract().as(SnomedReferenceSetMembers.class);
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, Json.object("members", members, "commitComment", "Update concept members")).statusCode(204);
    SnomedConcept concept = assertGetConcept(conceptId).statusCode(200).extract().as(SnomedConcept.class);
    assertTrue(concept.isActive());
    // Active concept is defined after adding equivalent class axioms to it
    assertTrue(!concept.isPrimitive());
    inactivateConcept(branchPath, conceptId);
    concept = assertGetConcept(conceptId).statusCode(200).extract().as(SnomedConcept.class);
    assertTrue(!concept.isActive());
    // Inactive concept becomes primitive
    assertTrue(concept.isPrimitive());
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, Json.object("active", true, "commitComment", "Reactivate concept")).statusCode(204);
    concept = assertGetConcept(conceptId).statusCode(200).extract().as(SnomedConcept.class);
    assertTrue(concept.isActive());
    // Reactivated concept with no active members stays primitive
    assertTrue(concept.isPrimitive());
}
Also used : SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 3 with SnomedReferenceSetMembers

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

the class SnomedModuleDependencyRefsetTest method updateExistingModuleDependencyMembers.

@Test
public void updateExistingModuleDependencyMembers() {
    Json conceptRequestBody = createConceptRequestBody(// it must belong to the core module
    Concepts.MODULE_ROOT, // it must belong to the core module
    Concepts.MODULE_SCT_CORE, SnomedApiTestConstants.UK_PREFERRED_MAP).with("commitComment", "Created concept with INT core module");
    String conceptId = createConcept(SnomedContentRule.SNOMEDCT, conceptRequestBody);
    assertThat(getConcept(SnomedContentRule.SNOMEDCT, conceptId).getEffectiveTime()).isNull();
    // version branch
    final LocalDate versionEffectiveTime = getNextAvailableEffectiveDate(SnomedContentRule.SNOMEDCT_ID);
    final String versionId = "updateExistingModuleDependencyMembers";
    createVersion(SnomedContentRule.SNOMEDCT_ID, versionId, versionEffectiveTime).statusCode(201);
    assertGetVersion(SnomedContentRule.SNOMEDCT_ID, versionId).statusCode(200);
    assertThat(getConcept(SnomedContentRule.SNOMEDCT, conceptId).getEffectiveTime()).isEqualTo(versionEffectiveTime);
    SnomedReferenceSetMembers coreModuleDependencyMembersAfterVersioning = SnomedRequests.prepareSearchMember().all().filterByActive(true).filterByModule(// filter for members where the module id is the SCT core module
    Concepts.MODULE_SCT_CORE).filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).build(SnomedContentRule.SNOMEDCT).execute(getBus()).getSync();
    for (SnomedReferenceSetMember member : coreModuleDependencyMembersAfterVersioning) {
        assertEquals(versionEffectiveTime, member.getEffectiveTime());
    }
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) LocalDate(java.time.LocalDate) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 4 with SnomedReferenceSetMembers

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

the class SnomedModuleDependencyRefsetTest method updateRelevantModDepMembersForExtensionVersions.

@Test
public void updateRelevantModDepMembersForExtensionVersions() {
    final String shortName = "SNOMEDCT-MODULEDEPENDENCY";
    createCodeSystem(branchPath, shortName).statusCode(201);
    Set<String> INT_MODULE_IDS = Set.of(Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.MODULE_SCT_CORE, ICD_10_MAPPING_MODULE);
    Map<Pair<String, String>, LocalDate> moduleToReferencedComponentAndEffectiveDateMap = Maps.newHashMap();
    SnomedReferenceSetMembers intModuleDependencyMembers = SnomedRequests.prepareSearchMember().all().filterByActive(true).filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).filterByModules(INT_MODULE_IDS).filterByReferencedComponent(INT_MODULE_IDS).build(branchPath.getPath()).execute(getBus()).getSync();
    intModuleDependencyMembers.forEach(member -> {
        Pair<String, String> pair = Tuples.pair(member.getModuleId(), member.getReferencedComponent().getId());
        moduleToReferencedComponentAndEffectiveDateMap.put(pair, member.getEffectiveTime());
    });
    // create Norwegian module
    Json norwegianModuleRequestBody = createConceptRequestBody(Concepts.MODULE_ROOT, NORWEGIAN_MODULE_CONCEPT_ID, SnomedApiTestConstants.UK_PREFERRED_MAP).with("id", NORWEGIAN_MODULE_CONCEPT_ID).with("commitComment", "Created norwegian module concept");
    createComponent(branchPath, SnomedComponentType.CONCEPT, norwegianModuleRequestBody).statusCode(201);
    // create both inferred and stated relationships
    Json inferredRelationshipRequestBody = SnomedRestFixtures.createRelationshipRequestBody(NORWEGIAN_MODULE_CONCEPT_ID, Concepts.IS_A, Concepts.MODULE_ROOT, NORWEGIAN_MODULE_CONCEPT_ID, Concepts.INFERRED_RELATIONSHIP, 0).with("commitComment", "Created inferred is_a from the norwegian module concept to SCT_MODULE_CORE");
    Json statedRelationshipRequestBody = SnomedRestFixtures.createRelationshipRequestBody(NORWEGIAN_MODULE_CONCEPT_ID, Concepts.IS_A, Concepts.MODULE_ROOT, NORWEGIAN_MODULE_CONCEPT_ID, Concepts.STATED_RELATIONSHIP, 0).with("commitComment", "Created state is_a from the norwegian module concept to SCT_MODULE_CORE");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, inferredRelationshipRequestBody).statusCode(201);
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, statedRelationshipRequestBody).statusCode(201);
    // check for the newly created module concept to have effective set to null
    SnomedRequests.prepareSearchConcept().filterById(NORWEGIAN_MODULE_CONCEPT_ID).build(branchPath.getPath()).execute(getBus()).getSync().forEach(c -> assertEquals("Effective time must still be null", null, c.getEffectiveTime()));
    // version branch
    final LocalDate effectiveTime = getNextAvailableEffectiveDate(shortName);
    final String versionId = "testForModuleDependencyMembers";
    createVersion(shortName, versionId, effectiveTime).statusCode(201);
    assertGetVersion(shortName, versionId).statusCode(200);
    // check for the newly created module concept after versioning to have effectiveTime set to the correct date
    SnomedConcept norwegianModule = SnomedRequests.prepareGetConcept(NORWEGIAN_MODULE_CONCEPT_ID).build(branchPath.getPath()).execute(getBus()).getSync();
    assertEquals("Effective time should have been set to the date of versioning", effectiveTime, norwegianModule.getEffectiveTime());
    SnomedReferenceSetMembers moduleDependencyMembersAfterVersioning = SnomedRequests.prepareSearchMember().all().filterByActive(true).filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).build(branchPath.getPath()).execute(getBus()).getSync();
    moduleDependencyMembersAfterVersioning.forEach(member -> {
        final Pair<String, String> pair = Tuples.pair(member.getModuleId(), member.getReferencedComponent().getId());
        final LocalDate originalMemberEffectiveTime = moduleToReferencedComponentAndEffectiveDateMap.get(pair);
        if (originalMemberEffectiveTime != null) {
            assertEquals(String.format("Effective dates on unaffected existing module dependency members shouldn't be updated after versioning. ModuleID: %s", member.getReferencedComponentId()), originalMemberEffectiveTime, member.getEffectiveTime());
        } else {
            assertEquals("The new members effective time should match the versionDate", effectiveTime, member.getEffectiveTime());
        }
    });
}
Also used : SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) LocalDate(java.time.LocalDate) Pair(org.eclipse.xtext.util.Pair) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 5 with SnomedReferenceSetMembers

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

the class SnomedDescriptionApiTest method updateAcceptabilityWithMemberReactivation.

@Test
public void updateAcceptabilityWithMemberReactivation() throws Exception {
    changeToAcceptable(branchPath, Concepts.ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_UK);
    String descriptionId = createNewDescription(branchPath, Concepts.ROOT_CONCEPT, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    SnomedReferenceSetMembers members = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class).getMembers();
    // Inactivate the reference set member
    members.forEach(m -> {
        Json requestBody = Json.object("active", false, "commitComment", "Inactivate language reference set member");
        updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, m.getId(), requestBody, false).statusCode(204);
    });
    Json requestBody = Json.object("acceptability", Json.object(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED, Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED), "commitComment", "Reactivated UK, added US acceptability to description");
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
    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 active", Boolean.TRUE, m.isActive()));
}
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)

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