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));
}
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());
}
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());
}
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());
}
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());
}
Aggregations