use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method createDescriptionCaseInsensitive.
@Test
public void createDescriptionCaseInsensitive() {
Json requestBody = createDescriptionRequestBody(Concepts.ROOT_CONCEPT, Concepts.SYNONYM, Concepts.MODULE_SCT_CORE, SnomedApiTestConstants.UK_ACCEPTABLE_MAP, Concepts.ENTIRE_TERM_CASE_INSENSITIVE).with("commitComment", "Created new description with case insensitive significance");
String descriptionId = assertCreated(createComponent(branchPath, SnomedComponentType.DESCRIPTION, requestBody));
getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ENTIRE_TERM_CASE_INSENSITIVE));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method shouldUpdateReleasedDescriptionTerm.
@Test
public void shouldUpdateReleasedDescriptionTerm() throws Exception {
final String descriptionId = createNewDescription(branchPath);
final String newTerm = "updatedUnreleasedDescriptionTerm";
final Json update = Json.object(SnomedRf2Headers.FIELD_TERM, newTerm, "commitComment", "Update unreleased description term");
// release component
createCodeSystemAndVersion(branchPath, "SNOMEDCT-RELDESC-TERM", "v1", LocalDate.parse("2017-03-01"));
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, update).statusCode(204);
getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body(SnomedRf2Headers.FIELD_TERM, equalTo(newTerm));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method updateUnreleasedDescriptionTerm.
@Test
public void updateUnreleasedDescriptionTerm() throws Exception {
String descriptionId = createNewDescription(branchPath);
Json update = Json.object(SnomedRf2Headers.FIELD_TERM, "updatedUnreleasedDescriptionTerm", "commitComment", "Update unreleased description term");
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, update).statusCode(204);
getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body(SnomedRf2Headers.FIELD_TERM, equalTo("updatedUnreleasedDescriptionTerm"));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade11DonatedConceptAndDescriptionsAndRelationshipsWithCrossReference.
@Test
public void upgrade11DonatedConceptAndDescriptionsAndRelationshipsWithCrossReference() {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
String extensionModuleId = createModule(extension);
String extensionFsnTerm1 = "FSN of concept";
String extensionPtTerm1 = "PT of concept";
String extensionSynonymTerm1 = "Synonym of extension concept";
Json fsnRequestBody1 = Json.object("typeId", Concepts.FULLY_SPECIFIED_NAME, "term", extensionFsnTerm1, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
Json ptRequestBody1 = Json.object("typeId", Concepts.SYNONYM, "term", extensionPtTerm1, "languageCode", DEFAULT_LANGUAGE_CODE, "acceptability", SnomedApiTestConstants.UK_PREFERRED_MAP);
Json synonymRequestBody1 = Json.object("typeId", Concepts.SYNONYM, "term", extensionSynonymTerm1, "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(fsnRequestBody1, ptRequestBody1, synonymRequestBody1), "relationships", Json.array(statedIsa, inferredIsa));
String extensionConceptId1 = createConcept(extension.getResourceURI(), extensionConceptRequestBody);
// create another extension concept which references the previous one
String extensionFsnTerm2 = "FSN of concept 2";
String extensionPtTerm2 = "PT of concept 2";
String extensionSynonymTerm2 = "Synonym of extension concept 2";
Json referenceToExtensionConcept1 = Json.object("typeId", Concepts.PART_OF, "destinationId", extensionConceptId1, "characteristicTypeId", Concepts.ADDITIONAL_RELATIONSHIP);
String extensionConceptId2 = createConcept(extension.getResourceURI(), extensionConceptRequestBody.with(Json.object("descriptions", Json.array(fsnRequestBody1.with("term", extensionFsnTerm2), ptRequestBody1.with("term", extensionPtTerm2), synonymRequestBody1.with("term", extensionSynonymTerm2)), "relationships", Json.array(statedIsa, inferredIsa, referenceToExtensionConcept1))));
// create new extension version
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
SnomedConcept extensionConcept1 = getConcept(extension.getResourceURI(), extensionConceptId1, "descriptions()", "relationships()");
String extensionFsnId1 = getFirstMatchingDescription(extensionConcept1, extensionFsnTerm1).getId();
String extensionPtId1 = getFirstMatchingDescription(extensionConcept1, extensionPtTerm1).getId();
String extensionSynonymId1 = getFirstMatchingDescription(extensionConcept1, extensionSynonymTerm1).getId();
String extensionStatedIsaId1 = getFirstRelationshipId(extensionConcept1, Concepts.STATED_RELATIONSHIP);
String extensionInferredIsaId1 = getFirstRelationshipId(extensionConcept1, Concepts.INFERRED_RELATIONSHIP);
SnomedConcept extensionConcept2 = getConcept(extension.getResourceURI(), extensionConceptId2, "descriptions()", "relationships()");
String extensionFsnId2 = getFirstMatchingDescription(extensionConcept2, extensionFsnTerm2).getId();
String extensionPtId2 = getFirstMatchingDescription(extensionConcept2, extensionPtTerm2).getId();
String extensionSynonymId2 = getFirstMatchingDescription(extensionConcept2, extensionSynonymTerm2).getId();
String extensionStatedIsaId2 = getFirstRelationshipId(extensionConcept2, Concepts.STATED_RELATIONSHIP);
String extensionInferredIsaId2 = getFirstRelationshipId(extensionConcept2, Concepts.INFERRED_RELATIONSHIP);
String referenceToExtensionConcept1RelationshipId = getFirstRelationshipId(extensionConcept2, Concepts.ADDITIONAL_RELATIONSHIP);
// simulate donation via concept create and versioning
// donate both concepts without the PART OF relationship reference between them
String intConceptId1 = createConcept(SnomedContentRule.SNOMEDCT, Json.object("id", extensionConceptId1, "moduleId", Concepts.MODULE_SCT_CORE, "descriptions", Json.array(fsnRequestBody1.with("id", extensionFsnId1), ptRequestBody1.with("id", extensionPtId1)), "relationships", Json.array(statedIsa.with("id", extensionStatedIsaId1), inferredIsa.with("id", extensionInferredIsaId1))));
String intConceptId2 = createConcept(SnomedContentRule.SNOMEDCT, Json.object("id", extensionConceptId2, "moduleId", Concepts.MODULE_SCT_CORE, "descriptions", Json.array(fsnRequestBody1.with("id", extensionFsnId2), ptRequestBody1.with("id", extensionPtId2)), "relationships", Json.array(statedIsa.with("id", extensionStatedIsaId2), inferredIsa.with("id", extensionInferredIsaId2))));
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 donatedConceptInExtension1 = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId1, "descriptions()", "relationships()");
SnomedConcept donatedConceptInExtension2 = getConcept(upgradeCodeSystem.getResourceURI(), intConceptId2, "descriptions()", "relationships()");
// validate components of donated concepts on extension branch
// same IDs, different modules
assertEquals(donatedConceptInExtension1.getId(), extensionConcept1.getId());
assertNotEquals(donatedConceptInExtension1.getModuleId(), extensionConcept1.getModuleId());
assertThat(donatedConceptInExtension1.getDescriptions()).extracting(SnomedDescription::getId).containsOnly(extensionFsnId1, extensionPtId1, extensionSynonymId1);
assertThat(donatedConceptInExtension1.getRelationships()).extracting(SnomedRelationship::getId).containsOnly(extensionStatedIsaId1, extensionInferredIsaId1);
// check if the other donated extension concept still has the reference relationship
assertEquals(donatedConceptInExtension2.getId(), extensionConcept2.getId());
assertNotEquals(donatedConceptInExtension2.getModuleId(), extensionConcept2.getModuleId());
assertThat(donatedConceptInExtension2.getDescriptions()).extracting(SnomedDescription::getId).containsOnly(extensionFsnId2, extensionPtId2, extensionSynonymId2);
assertThat(donatedConceptInExtension2.getRelationships()).extracting(SnomedRelationship::getId).containsOnly(extensionStatedIsaId2, extensionInferredIsaId2, referenceToExtensionConcept1RelationshipId);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedExtensionUpgradeTest method upgrade07DonatedRelationship.
@Test
public void upgrade07DonatedRelationship() throws Exception {
// create extension on the latest SI VERSION
CodeSystem extension = createExtension(latestInternationalVersion, branchPath.lastSegment());
String extensionModuleId = createModule(extension);
Json extensionRelationshipRequest = Json.object("namespaceId", Concepts.B2I_NAMESPACE, "moduleId", extensionModuleId, "sourceId", Concepts.ROOT_CONCEPT, "typeId", Concepts.PART_OF, "destinationId", Concepts.NAMESPACE_ROOT, "characteristicTypeId", Concepts.ADDITIONAL_RELATIONSHIP, "relationshipGroup", 0, "commitComment", "Created new extension relationship");
String extensionRelationshipId = createRelationship(extension.getResourceURI(), extensionRelationshipRequest);
// create new extension version
createVersion(extension.getId(), "v1", LocalDate.now()).statusCode(201);
// simulate donation of relationship to INT with slightly different props but same ID
Json donatedRelationshipRequest = Json.assign(extensionRelationshipRequest, Json.object("id", extensionRelationshipId, "moduleId", Concepts.MODULE_SCT_CORE, "characteristicTypeId", Concepts.INFERRED_RELATIONSHIP, "relationshipGroup", 1, "commitComment", "Created new donated INT relationship"));
String donatedRelationshipId = createRelationship(SnomedContentRule.SNOMEDCT, donatedRelationshipRequest);
LocalDate effectiveTime = getNextAvailableEffectiveDate(SNOMEDCT);
createVersion(SNOMEDCT, effectiveTime).statusCode(201);
assertEquals(extensionRelationshipId, donatedRelationshipId);
// start upgrade to the new available upgrade version
CodeSystem upgradeCodeSystem = createExtensionUpgrade(extension.getResourceURI(), CodeSystem.uri(SNOMEDCT, effectiveTime.toString()));
SnomedRelationship donatedRelationshipOnUpgrade = getRelationship(upgradeCodeSystem.getResourceURI(), donatedRelationshipId);
assertEquals(Concepts.MODULE_SCT_CORE, donatedRelationshipOnUpgrade.getModuleId());
assertEquals(Concepts.INFERRED_RELATIONSHIP, donatedRelationshipOnUpgrade.getCharacteristicTypeId());
assertEquals(1, donatedRelationshipOnUpgrade.getRelationshipGroup().intValue());
}
Aggregations