Search in sources :

Example 31 with SnomedConcept

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

the class SnomedImportApiTest method import27MRCMReferenceSetMembers.

@Test
public void import27MRCMReferenceSetMembers() throws Exception {
    SnomedConcept rootConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, Concepts.ROOT_CONCEPT, "members()").extract().as(SnomedConcept.class);
    assertTrue(StreamSupport.stream(rootConcept.getMembers().spliterator(), false).noneMatch(m -> {
        return m.getRefsetId().equals(Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL) || m.getRefsetId().equals(Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL) || m.getRefsetId().equals(Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL) || m.getRefsetId().equals(Concepts.REFSET_MRCM_MODULE_SCOPE);
    }));
    importArchive("SnomedCT_Release_INT_20170731_new_mrcm_members.zip");
    SnomedConcept newRootConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, Concepts.ROOT_CONCEPT, "members()").extract().as(SnomedConcept.class);
    Optional<SnomedReferenceSetMember> mrcmDomainMemberCandidate = StreamSupport.stream(newRootConcept.getMembers().spliterator(), false).filter(m -> m.getRefsetId().equals(Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL)).findFirst();
    assertTrue(mrcmDomainMemberCandidate.isPresent());
    SnomedReferenceSetMember mrcmDomainMember = mrcmDomainMemberCandidate.get();
    assertEquals("28ecaa32-8f0e-4ff8-b6b1-b642e40519d8", mrcmDomainMember.getId());
    assertEquals(Concepts.MODULE_SCT_MODEL_COMPONENT, mrcmDomainMember.getModuleId());
    assertEquals(Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL, mrcmDomainMember.getRefsetId());
    assertEquals(Concepts.ROOT_CONCEPT, mrcmDomainMember.getReferencedComponent().getId());
    Map<String, Object> domainMemberProps = mrcmDomainMember.getProperties();
    assertEquals("domainConstraint", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT));
    assertEquals("parentDomain", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_PARENT_DOMAIN));
    assertEquals("proximalPrimitiveConstraint", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_CONSTRAINT));
    assertEquals("proximalPrimitiveRefinement", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_REFINEMENT));
    assertEquals("domainTemplateForPrecoordination", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_PRECOORDINATION));
    assertEquals("domainTemplateForPostcoordination", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_POSTCOORDINATION));
    assertEquals("guideURL", domainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_GUIDEURL));
    Optional<SnomedReferenceSetMember> mrcmAttributeDomainMemberCandidate = StreamSupport.stream(newRootConcept.getMembers().spliterator(), false).filter(m -> m.getRefsetId().equals(Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL)).findFirst();
    assertTrue(mrcmAttributeDomainMemberCandidate.isPresent());
    SnomedReferenceSetMember mrcmAttributeDomainMember = mrcmAttributeDomainMemberCandidate.get();
    assertEquals("126bf3f1-4f34-439d-ba0a-a832824d072a", mrcmAttributeDomainMember.getId());
    assertEquals(Concepts.MODULE_SCT_MODEL_COMPONENT, mrcmAttributeDomainMember.getModuleId());
    assertEquals(Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL, mrcmAttributeDomainMember.getRefsetId());
    assertEquals(Concepts.ROOT_CONCEPT, mrcmAttributeDomainMember.getReferencedComponent().getId());
    Map<String, Object> attributeDomainMemberProps = mrcmAttributeDomainMember.getProperties();
    assertEquals(Concepts.ROOT_CONCEPT, attributeDomainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID));
    assertEquals(Boolean.TRUE, attributeDomainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_GROUPED));
    assertEquals("attributeCardinality", attributeDomainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY));
    assertEquals("attributeInGroupCardinality", attributeDomainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY));
    assertEquals(Concepts.ROOT_CONCEPT, attributeDomainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID));
    assertEquals(Concepts.ROOT_CONCEPT, attributeDomainMemberProps.get(SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID));
    Optional<SnomedReferenceSetMember> mrcmAttributeRangeMemberCandidate = StreamSupport.stream(newRootConcept.getMembers().spliterator(), false).filter(m -> m.getRefsetId().equals(Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL)).findFirst();
    assertTrue(mrcmAttributeRangeMemberCandidate.isPresent());
    SnomedReferenceSetMember mrcmAttributeRangeMember = mrcmAttributeRangeMemberCandidate.get();
    assertEquals("ae090cc3-2827-4e39-80c6-364435d30c17", mrcmAttributeRangeMember.getId());
    assertEquals(Concepts.MODULE_SCT_MODEL_COMPONENT, mrcmAttributeRangeMember.getModuleId());
    assertEquals(Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL, mrcmAttributeRangeMember.getRefsetId());
    assertEquals(Concepts.ROOT_CONCEPT, mrcmAttributeRangeMember.getReferencedComponent().getId());
    Map<String, Object> attributeRangeMemberProps = mrcmAttributeRangeMember.getProperties();
    assertEquals("rangeConstraint", attributeRangeMemberProps.get(SnomedRf2Headers.FIELD_MRCM_RANGE_CONSTRAINT));
    assertEquals("attributeRule", attributeRangeMemberProps.get(SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_RULE));
    assertEquals(Concepts.ROOT_CONCEPT, attributeRangeMemberProps.get(SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID));
    assertEquals(Concepts.ROOT_CONCEPT, attributeRangeMemberProps.get(SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID));
    Optional<SnomedReferenceSetMember> mrcmModuleScopeMemberCandidate = StreamSupport.stream(newRootConcept.getMembers().spliterator(), false).filter(m -> m.getRefsetId().equals(Concepts.REFSET_MRCM_MODULE_SCOPE)).findFirst();
    assertTrue(mrcmModuleScopeMemberCandidate.isPresent());
    SnomedReferenceSetMember mrmcModuleScopeMember = mrcmModuleScopeMemberCandidate.get();
    assertEquals("52d29f1b-f7a3-4a0f-828c-383c6259c3f5", mrmcModuleScopeMember.getId());
    assertEquals(Concepts.MODULE_SCT_MODEL_COMPONENT, mrmcModuleScopeMember.getModuleId());
    assertEquals(Concepts.REFSET_MRCM_MODULE_SCOPE, mrmcModuleScopeMember.getRefsetId());
    assertEquals(Concepts.ROOT_CONCEPT, mrmcModuleScopeMember.getReferencedComponent().getId());
    assertEquals(Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL, mrmcModuleScopeMember.getProperties().get(SnomedRf2Headers.FIELD_MRCM_RULE_REFSET_ID));
}
Also used : MethodSorters(org.junit.runners.MethodSorters) EffectiveTimes(com.b2international.snowowl.core.date.EffectiveTimes) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) RemoteJobState(com.b2international.snowowl.core.jobs.RemoteJobState) ValidatableResponse(io.restassured.response.ValidatableResponse) CodeSystemVersionRestRequests.createVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.createVersion) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) RestExtensions.lastPathSegment(com.b2international.snowowl.test.commons.rest.RestExtensions.lastPathSegment) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) SnomedComponentType(com.b2international.snowowl.snomed.core.rest.SnomedComponentType) SnomedComponentRestRequests.getComponent(com.b2international.snowowl.snomed.core.rest.SnomedComponentRestRequests.getComponent) Map(java.util.Map) RestExtensions.givenAuthenticatedRequest(com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest) StreamSupport(java.util.stream.StreamSupport) NotFoundException(com.b2international.commons.exceptions.NotFoundException) Rf2ReleaseType(com.b2international.snowowl.snomed.core.domain.Rf2ReleaseType) CodeSystemVersionRestRequests.assertGetVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.assertGetVersion) BranchPathUtils(com.b2international.snowowl.core.branch.BranchPathUtils) SnomedApiTestConstants(com.b2international.snowowl.snomed.core.rest.SnomedApiTestConstants) DateFormats(com.b2international.snowowl.core.date.DateFormats) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test) SnomedTerminologyComponentConstants(com.b2international.snowowl.snomed.common.SnomedTerminologyComponentConstants) SnomedImportRestRequests.doImport(com.b2international.snowowl.snomed.core.rest.SnomedImportRestRequests.doImport) CodeSystemRestRequests.createCodeSystem(com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem) TimeUnit(java.util.concurrent.TimeUnit) SnomedImportRestRequests.waitForImportJob(com.b2international.snowowl.snomed.core.rest.SnomedImportRestRequests.waitForImportJob) List(java.util.List) SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) IComponent(com.b2international.snowowl.core.domain.IComponent) Optional(java.util.Optional) CodeSystemRequests(com.b2international.snowowl.core.codesystem.CodeSystemRequests) SnomedRf2Headers(com.b2international.snowowl.snomed.common.SnomedRf2Headers) Assert(org.junit.Assert) FixMethodOrder(org.junit.FixMethodOrder) Collections(java.util.Collections) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 32 with SnomedConcept

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

the class SnomedImportApiTest method import30ImportExistingConceptAsPublished.

@Test
public void import30ImportExistingConceptAsPublished() throws Exception {
    getComponent(branchPath, SnomedComponentType.CONCEPT, "100005").statusCode(404);
    importArchive("SnomedCT_Release_INT_20210502_concept_wo_eff_time.zip");
    SnomedConcept conceptBefore = getComponent(branchPath, SnomedComponentType.CONCEPT, "100005").statusCode(200).extract().as(SnomedConcept.class);
    importArchive("SnomedCT_Release_INT_20210502_concept_w_eff_time.zip");
    SnomedConcept conceptAfter = getComponent(branchPath, SnomedComponentType.CONCEPT, "100005").statusCode(200).extract().as(SnomedConcept.class);
    assertEquals(EffectiveTimes.toDate(EffectiveTimes.UNSET_EFFECTIVE_TIME), conceptBefore.getEffectiveTime());
    assertFalse(conceptBefore.isReleased());
    assertEquals(EffectiveTimes.parse("2021-05-02"), conceptAfter.getEffectiveTime());
    assertTrue(conceptAfter.isReleased());
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 33 with SnomedConcept

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

the class SnomedComponentEffectiveTimeRestoreTest method restoreInternationalEffectiveTimeOnExtensionUpgrade.

@Test
public void restoreInternationalEffectiveTimeOnExtensionUpgrade() throws Exception {
    // create extension on the base SI VERSION
    CodeSystem extension = createExtension(baseInternationalCodeSystem, branchPath.lastSegment());
    // start the extension upgrade process
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeInternationalCodeSystem);
    // get the first concept from the Base SI version
    SnomedConcept concept = searchConcepts(upgradeInternationalCodeSystem, Map.of("module", Concepts.MODULE_SCT_CORE, "effectiveTime", "20200131"), 1).stream().findFirst().get();
    LocalDate lastReleasedEffectiveTime = concept.getEffectiveTime();
    String conceptId = concept.getId();
    // create a change on the concept, like change the definition status
    updateConcept(upgradeCodeSystem.getResourceURI(), concept.getId(), Map.of("moduleId", Concepts.MODULE_SCT_MODEL_COMPONENT));
    concept = getConcept(upgradeCodeSystem.getResourceURI(), conceptId);
    assertEquals(null, concept.getEffectiveTime());
    // revert the change, so it reverts the effective time to the EXT_VER effective time
    updateConcept(upgradeCodeSystem.getResourceURI(), conceptId, Map.of("moduleId", Concepts.MODULE_SCT_CORE));
    concept = getConcept(upgradeCodeSystem.getResourceURI(), conceptId);
    assertEquals(lastReleasedEffectiveTime, concept.getEffectiveTime());
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) CodeSystemRestRequests.createCodeSystem(com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 34 with SnomedConcept

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

the class SnomedComponentEffectiveTimeRestoreTest method restoreExtensionEffectiveTimeOnExtensionVersionUpgrade.

@Test
public void restoreExtensionEffectiveTimeOnExtensionVersionUpgrade() throws Exception {
    final String codeSystemId = branchPath.lastSegment();
    // create extension on the base SI VERSION
    final CodeSystem extension = createExtension(baseInternationalCodeSystem, codeSystemId);
    // create the module concept to represent the extension
    String moduleId = createModule(extension);
    // create an extension version, concept receives effective time
    LocalDate effectiveTime = getNextAvailableEffectiveDate(codeSystemId);
    createVersion(codeSystemId, effectiveTime).statusCode(201);
    ResourceURI upgradeExtVersion = CodeSystem.uri(codeSystemId, effectiveTime.toString());
    SnomedConcept concept = getConcept(extension.getResourceURI(), moduleId);
    assertEquals(effectiveTime, concept.getEffectiveTime());
    // Update extension concept
    updateConcept(extension.getResourceURI(), concept.getId(), Map.of("moduleId", Concepts.MODULE_SCT_MODEL_COMPONENT));
    // Create second version
    LocalDate effectiveDate2 = getNextAvailableEffectiveDate(codeSystemId);
    createVersion(codeSystemId, effectiveDate2).statusCode(201);
    // start the extension upgrade process
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(upgradeExtVersion, upgradeInternationalCodeSystem);
    // create a change on the concept, like change the definition status
    updateConcept(upgradeCodeSystem.getResourceURI(), concept.getId(), Map.of("definitionStatusId", Concepts.FULLY_DEFINED));
    concept = getConcept(upgradeCodeSystem.getResourceURI(), moduleId);
    assertEquals(null, concept.getEffectiveTime());
    // revert the change, so it reverts the effective time to the 'effectiveDate' effective time
    updateConcept(upgradeCodeSystem.getResourceURI(), moduleId, Map.of("definitionStatusId", Concepts.PRIMITIVE));
    concept = getConcept(upgradeCodeSystem.getResourceURI(), moduleId);
    assertEquals(effectiveTime, concept.getEffectiveTime());
}
Also used : ResourceURI(com.b2international.snowowl.core.ResourceURI) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) CodeSystemRestRequests.createCodeSystem(com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 35 with SnomedConcept

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

the class SnomedComponentEffectiveTimeRestoreTest method restoreExtensionEffectiveTimeOnExtensionUpgrade.

@Test
public void restoreExtensionEffectiveTimeOnExtensionUpgrade() throws Exception {
    // create extension on the base SI VERSION
    final CodeSystem extension = createExtension(baseInternationalCodeSystem, branchPath.lastSegment());
    // create the module concept to represent the extension
    String moduleId = createModule(extension);
    // create an extension version, concept receives effective time
    createVersion(extension.getId(), EXT_VERSION, LocalDate.parse("2019-10-31")).statusCode(201);
    SnomedConcept concept = getConcept(extension.getResourceURI(), moduleId);
    assertEquals(EffectiveTimes.parse(EXT_VERSION), concept.getEffectiveTime());
    // start the extension upgrade process
    CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeInternationalCodeSystem);
    // create a change on the concept, like change the definition status
    updateConcept(upgradeCodeSystem.getResourceURI(), concept.getId(), Map.of("definitionStatusId", Concepts.FULLY_DEFINED));
    concept = getConcept(upgradeCodeSystem.getResourceURI(), moduleId);
    assertEquals(null, concept.getEffectiveTime());
    // revert the change, so it reverts the effective time to the EXT_VER effective time
    updateConcept(upgradeCodeSystem.getResourceURI(), moduleId, Map.of("definitionStatusId", Concepts.PRIMITIVE));
    concept = getConcept(upgradeCodeSystem.getResourceURI(), moduleId);
    assertEquals(EffectiveTimes.parse(EXT_VERSION), concept.getEffectiveTime());
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) CodeSystem(com.b2international.snowowl.core.codesystem.CodeSystem) CodeSystemRestRequests.createCodeSystem(com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem) Test(org.junit.Test)

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