use of com.b2international.snowowl.core.codesystem.CodeSystem 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.core.codesystem.CodeSystem 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.core.codesystem.CodeSystem 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());
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade09DonatedConceptAndDescriptions.
@Test
public void upgrade09DonatedConceptAndDescriptions() {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
String extensionModuleId = createModule(extension);
String extensionFsnTerm = "FSN of concept";
String extensionPtTerm = "PT of concept";
String extensionSynonymTerm = "Synonym of extension concept";
Json fsnRequestBody = Json.object("typeId", Concepts.FULLY_SPECIFIED_NAME, "term", extensionFsnTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
Json ptRequestBody = Json.object("typeId", Concepts.SYNONYM, "term", extensionPtTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
Json synonymRequestBody = Json.object("typeId", Concepts.SYNONYM, "term", extensionSynonymTerm, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_ACCEPTABLE_MAP);
Json statedIsa = Json.object("typeId", Concepts.IS_A, "destinationId", Concepts.ROOT_CONCEPT, "characteristicTypeId", Concepts.STATED_RELATIONSHIP);
Json inferredIsa = Json.object("typeId", Concepts.IS_A, "destinationId", Concepts.ROOT_CONCEPT, "characteristicTypeId", Concepts.INFERRED_RELATIONSHIP);
Json extensionConceptRequestBody = Json.object("namespaceId", Concepts.B2I_NAMESPACE, "moduleId", extensionModuleId, "descriptions", Json.array(fsnRequestBody, ptRequestBody, synonymRequestBody), "relationships", Json.array(statedIsa, inferredIsa));
String extensionConceptId = createConcept(extension.getResourceURI(), extensionConceptRequestBody);
// create new extension version
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
SnomedConcept extensionConcept = getConcept(extension.getResourceURI(), extensionConceptId, "descriptions()", "relationships()");
String extensionFsnId = getFirstMatchingDescription(extensionConcept, extensionFsnTerm).getId();
String extensionPtId = getFirstMatchingDescription(extensionConcept, extensionPtTerm).getId();
String extensionSynonymId = getFirstMatchingDescription(extensionConcept, extensionSynonymTerm).getId();
String extensionStatedIsaId = getFirstRelationshipId(extensionConcept, Concepts.STATED_RELATIONSHIP);
String extensionInferredIsaId = getFirstRelationshipId(extensionConcept, Concepts.INFERRED_RELATIONSHIP);
// simulate donation via concept create and versioning
// create INT concept with same ID and with same description and relationship IDs
String intConceptId = createConcept(SnomedContentRule.SNOMEDCT, Json.object("id", extensionConceptId, "moduleId", Concepts.MODULE_SCT_CORE, "descriptions", Json.array(fsnRequestBody.with("id", extensionFsnId), ptRequestBody.with("id", extensionPtId)), "relationships", Json.array(statedIsa, inferredIsa)));
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 donatedConceptInExtension = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId, "descriptions()", "relationships()");
// validate components of donated concept on extension branch
// same ID, different module
assertNotEquals(donatedConceptInExtension.getModuleId(), extensionConcept.getModuleId());
SnomedDescription donatedFsn = getFirstMatchingDescription(donatedConceptInExtension, extensionFsnTerm);
assertEquals(extensionFsnId, donatedFsn.getId());
assertEquals(Concepts.MODULE_SCT_CORE, donatedFsn.getModuleId());
SnomedDescription donatedPt = getFirstMatchingDescription(donatedConceptInExtension, extensionPtTerm);
assertEquals(extensionPtId, donatedPt.getId());
assertEquals(Concepts.MODULE_SCT_CORE, donatedPt.getModuleId());
Set<String> descriptionIds = donatedConceptInExtension.getDescriptions().getItems().stream().map(SnomedDescription::getId).collect(Collectors.toSet());
assertThat(descriptionIds).hasSize(3).contains(extensionSynonymId);
Set<String> relationshipIds = donatedConceptInExtension.getRelationships().getItems().stream().map(SnomedRelationship::getId).collect(Collectors.toSet());
assertThat(relationshipIds).hasSize(4).contains(extensionStatedIsaId, extensionInferredIsaId);
}
use of com.b2international.snowowl.core.codesystem.CodeSystem in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade22UpgradeSychronizeHead.
@Test
public void upgrade22UpgradeSychronizeHead() 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());
// 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());
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extensionVersion, upgradeVersion);
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);
IBranchPath extensionBranch = BranchPathUtils.createPath(extension.getBranchPath());
IBranchPath upgradeBranch = BranchPathUtils.createPath(upgradeCodeSystem.getBranchPath());
merge(extensionBranch, upgradeBranch, "Merged new concept from child branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
Boolean result = CodeSystemRequests.prepareUpgradeSynchronization(upgradeCodeSystem.getResourceURI(), extension.getResourceURI()).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
assertTrue(result);
CodeSystems expandedCodeSystemsAfterMerge = CodeSystemRestRequests.search(upgradeCodeSystem.getId(), CodeSystem.Expand.UPGRADE_INFO + "()");
assertThat(expandedCodeSystemsAfterMerge.first().get().getUpgradeInfo().getAvailableVersions()).isEmpty();
}
Aggregations