use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade05DonatedConcept.
@Test
public void upgrade05DonatedConcept() {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
String extensionModuleId = createModule(extension);
String extensionConceptId = createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId).with("namespaceId", Concepts.B2I_NAMESPACE));
// put additional relationships and acceptable synonym on the concept
String additionalSynonymId = createDescription(extension.getResourceURI(), createDescriptionRequestBody(extensionConceptId).with("moduleId", extensionModuleId).with("namespaceId", Concepts.B2I_NAMESPACE).with("term", "Additional Synonym"));
String additionalRelationshipId = createRelationship(extension.getResourceURI(), createRelationshipRequestBody(extensionConceptId, Concepts.FINDING_SITE, Concepts.ROOT_CONCEPT).with("moduleId", extensionModuleId).with(SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID, Concepts.ADDITIONAL_RELATIONSHIP).with("namespaceId", Concepts.B2I_NAMESPACE));
SnomedConcept extensionConcept = getConcept(extension.getResourceURI(), extensionConceptId, "descriptions()", "relationships()", "fsn()", "pt()");
// create new extension version
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
// simulate donation to SI and new version import
String donatedConceptId = createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE).with("id", extensionConceptId));
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, effectiveTime.toString()));
SnomedConcept donatedConceptAfterUpgrade = getConcept(upgradeCodeSystem.getResourceURI(), donatedConceptId, "descriptions()", "relationships()", "fsn()", "pt()");
// validate components of donated concept on extension branch
assertEquals(extensionConcept.getId(), donatedConceptAfterUpgrade.getId());
assertNotEquals(extensionConcept.getModuleId(), donatedConceptAfterUpgrade.getModuleId());
// additional not donated extension content should remain on the concept
assertTrue(donatedConceptAfterUpgrade.getDescriptions().stream().filter(desc -> additionalSynonymId.equals(desc.getId())).findFirst().isPresent());
assertTrue(donatedConceptAfterUpgrade.getRelationships().stream().filter(rel -> additionalRelationshipId.equals(rel.getId())).findFirst().isPresent());
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade13SemanticallySameChangesAppliedTwiceBeforeUpgradeAndAfterUpgrade.
@Test
public void upgrade13SemanticallySameChangesAppliedTwiceBeforeUpgradeAndAfterUpgrade() throws Exception {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
// create new extension version with one new concept and one member on INT concept
String moduleId = createModule(extension);
SnomedConcept concept = searchConcepts(baseInternationalCodeSystem, Map.of("module", Concepts.MODULE_SCT_CORE, "expand", "descriptions()"), 1).stream().findFirst().get();
String descriptionId = concept.getDescriptions().stream().findFirst().get().getId();
// create new inactivation indicator for one of the description, pending move
createMember(extension.getResourceURI(), Map.of("moduleId", moduleId, "refsetId", Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, "referencedComponentId", descriptionId, "valueId", Concepts.PENDING_MOVE));
// version extension
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
// add another member on INT representing a change in INT and allow extension to upgrade
createMember(SnomedContentRule.SNOMEDCT, Map.of("moduleId", Concepts.MODULE_SCT_CORE, "refsetId", Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, "referencedComponentId", descriptionId, "valueId", Concepts.PENDING_MOVE));
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
// start the upgrade
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeVersion);
// add another extension member to the same int concept with same meaning to the original extension branch
createMember(extension.getResourceURI(), Map.of("moduleId", moduleId, "refsetId", Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR, "referencedComponentId", descriptionId, "valueId", Concepts.AMBIGUOUS));
// synchronize upgrade
final String mergeLocation = createMerge(extension.getBranchPath(), upgradeCodeSystem.getBranchPath(), "Sync Upgrade CodeSystem", false).statusCode(202).extract().header("Location");
waitForMergeJob(lastPathSegment(mergeLocation));
// each component should have a single revision after successful sync
getConcept(upgradeCodeSystem.getResourceURI(), concept.getId());
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade01Nochanges.
@Test
public void upgrade01Nochanges() {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
// create a new INT version without any changes
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
// start upgrade
final ResourceURI newExtensionOf = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), newExtensionOf);
assertEquals(newExtensionOf, upgradeCodeSystem.getExtensionOf());
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade03NewInternationalConceptOnly.
@Test
public void upgrade03NewInternationalConceptOnly() {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
// new SI concept
String newConceptId = createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
// create a new INT version
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeVersion);
assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, newConceptId).statusCode(200);
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExportApiTest method exportRf2WithoutConfiguration.
@Test
public void exportRf2WithoutConfiguration() throws Exception {
String codeSystemId = "SNOMEDCT-default-rf2-export-config";
createCodeSystem(branchPath, codeSystemId).statusCode(201);
CodeSystem codeSystem = CodeSystemRestRequests.getCodeSystem(codeSystemId);
final File exportArchive = doExport(codeSystemId, codeSystem.getSettings());
final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put("der2_sssssssRefset_MRCMDomainSnapshot_INT", true).put("sct2_Relationship_Snapshot_INT", true).put("sct2_Description_Snapshot-en_INT", true).put("der2_sRefset_SimpleMapSnapshot_INT", true).build();
assertArchiveContainsFiles(exportArchive, files);
}
Aggregations