use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade06DonatedDescription.
@Test
public void upgrade06DonatedDescription() throws Exception {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
String extensionModuleId = createModule(extension);
String descriptionTerm = "Donated synonym of root concept";
Json extensionDescriptionRequest = Json.object("conceptId", Concepts.ROOT_CONCEPT, "namespaceId", Concepts.B2I_NAMESPACE, "moduleId", extensionModuleId, "typeId", Concepts.SYNONYM, "term", descriptionTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.US_ACCEPTABLE_MAP, "caseSignificanceId", Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE, "commitComment", "Created new extension synonym");
String extensionDescriptionId = createDescription(extension.getResourceURI(), extensionDescriptionRequest);
// create new extension version
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
// simulate donation to SI with same ID but with slightly different properties
Json donatedDescriptionRequest = Json.assign(extensionDescriptionRequest, Json.object("id", extensionDescriptionId, "moduleId", Concepts.MODULE_SCT_CORE, "languageCode", "en", "acceptability", SnomedApiTestConstants.UK_ACCEPTABLE_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_SENSITIVE, "commitComment", "Created new donated synonym"));
String donatedDescriptionId = createDescription(SnomedContentRule.SNOMEDCT, donatedDescriptionRequest);
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
assertEquals(extensionDescriptionId, donatedDescriptionId);
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, effectiveTime.toString()));
SnomedDescription donatedDescriptionOnUpgrade = getDescription(upgradeCodeSystem.getResourceURI(), donatedDescriptionId);
assertEquals(Concepts.MODULE_SCT_CORE, donatedDescriptionOnUpgrade.getModuleId());
assertEquals(Concepts.ENTIRE_TERM_CASE_SENSITIVE, donatedDescriptionOnUpgrade.getCaseSignificanceId());
// acceptability should come from both INT
assertThat(donatedDescriptionOnUpgrade.getAcceptabilityMap().containsKey(Concepts.REFSET_LANGUAGE_TYPE_UK));
assertEquals(Acceptability.ACCEPTABLE, donatedDescriptionOnUpgrade.getAcceptabilityMap().get(Concepts.REFSET_LANGUAGE_TYPE_UK));
// and EXT should keep its acceptability values
assertThat(donatedDescriptionOnUpgrade.getAcceptabilityMap().containsKey(Concepts.REFSET_LANGUAGE_TYPE_US));
assertEquals(Acceptability.ACCEPTABLE, donatedDescriptionOnUpgrade.getAcceptabilityMap().get(Concepts.REFSET_LANGUAGE_TYPE_US));
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade14CompleteUpgrade.
@Test
public void upgrade14CompleteUpgrade() throws Exception {
// 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);
ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveTime.toString());
// create new extension version with one new concept, module in this case
String moduleId = createModule(extension);
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), upgradeVersion);
assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
getComponent(upgradeCodeSystem.getResourceURI(), SnomedComponentType.CONCEPT, moduleId).statusCode(200);
Boolean success = CodeSystemRequests.prepareComplete(upgradeCodeSystem.getId()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
assertTrue(success);
// after upgrade completion, the upgrade Code System is no longer available
CodeSystemRestRequests.assertGetCodeSystem(upgradeCodeSystem.getId()).statusCode(404);
// the extension should use the upgrade's branch
CodeSystem afterUpgrade = CodeSystemRestRequests.getCodeSystem(upgradeCodeSystem.getUpgradeOf().getResourceId());
assertThat(afterUpgrade.getBranchPath()).isEqualTo(upgradeCodeSystem.getBranchPath());
assertThat(afterUpgrade.getExtensionOf()).isEqualByComparingTo(upgradeCodeSystem.getExtensionOf());
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade16UpgradeFromCodeSystemVersion.
@Test
public void upgrade16UpgradeFromCodeSystemVersion() {
// 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());
// version extension
LocalDate effectiveDate2 = LocalDate.now();
createVersion(extension.getId(), effectiveDate2).statusCode(201);
ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, 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 SnomedExtensionUpgradeTest method upgrade27MultipleUpgradesAroundSameConcept.
@Test
public void upgrade27MultipleUpgradesAroundSameConcept() throws Exception {
String intConceptId = "413858005";
// prepare extension on latest int version
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
String inferredIntRelationship = createRelationship(SNOMEDCT_URI, createRelationshipRequestBody("409852006", Concepts.IS_A, Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.INFERRED_RELATIONSHIP));
// version INT
LocalDate newSIVersion = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, newSIVersion).statusCode(201);
// create upgrade to the new SI version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), SNOMEDCT_URI.withPath(newSIVersion.toString()));
SnomedConcept conceptOnUpgradeBranch = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId);
assertThat(conceptOnUpgradeBranch.getParentIdsAsString()).containsOnly("409852006");
assertThat(conceptOnUpgradeBranch.getAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, "41146007", "81325006", "106237007", Concepts.ROOT_CONCEPT, "246061005", "409822003", "410607006", Concepts.CONCEPT_MODEL_ATTRIBUTE, "900000000000441003");
Boolean success = CodeSystemRequests.prepareComplete(upgradeCodeSystem.getId()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
assertTrue(success);
String secondInferredIntRelationship = createRelationship(SNOMEDCT_URI, createRelationshipRequestBody("409852006", Concepts.IS_A, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE, Concepts.INFERRED_RELATIONSHIP));
// version INT again for new upgrade
LocalDate secondSIVersion = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, secondSIVersion).statusCode(201);
// upgrade again
upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), SNOMEDCT_URI.withPath(secondSIVersion.toString()));
conceptOnUpgradeBranch = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId);
assertThat(conceptOnUpgradeBranch.getParentIdsAsString()).containsOnly("409852006");
assertThat(conceptOnUpgradeBranch.getAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, "41146007", "81325006", "106237007", Concepts.ROOT_CONCEPT, "246061005", "409822003", "410607006", Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE, "900000000000441003");
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade21ExpandUpgradeInfo.
@Test
public void upgrade21ExpandUpgradeInfo() throws Exception {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
// new SI concept
createConcept(SnomedContentRule.SNOMEDCT, createConceptRequestBody(Concepts.ROOT_CONCEPT, Concepts.MODULE_SCT_CORE));
// create a new INT version
LocalDate effectiveDate = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveDate).statusCode(201);
ResourceURI upgradeVersion = CodeSystem.uri(SNOMEDCT, effectiveDate.toString());
// new SE concept
String extensionModuleId = createModule(extension);
createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
// version extension
LocalDate effectiveDate2 = LocalDate.now();
createVersion(extension.getId(), effectiveDate2).statusCode(201);
ResourceURI extensionVersion = CodeSystem.uri(extension.getId(), effectiveDate2.toString());
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
// new SE concept
createConcept(extension.getResourceURI(), createConceptRequestBody(Concepts.ROOT_CONCEPT, extensionModuleId));
// version extension
LocalDate effectiveDate3 = getNextAvailableEffectiveDate(extension.getId());
createVersion(extension.getId(), effectiveDate3).statusCode(201);
ResourceURI extensionVersion2 = CodeSystem.uri(extension.getId(), effectiveDate3.toString());
CodeSystems expandedCodeSystems = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
assertEquals(upgradeVersion, upgradeCodeSystem.getExtensionOf());
assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).doesNotContainSequence(extensionVersion);
assertThat(expandedCodeSystems.first().get().getUpgradeInfo().getAvailableVersions()).contains(extensionVersion2);
}
Aggregations