use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedSimpleTypeRefSetDSVExporter method writeValues.
private void writeValues(IProgressMonitor monitor, BufferedWriter writer) throws IOException {
SearchResourceRequestIterator<SnomedConceptSearchRequestBuilder, SnomedConcepts> conceptIterator = getMemberConceptIterator(DATA_EXPAND);
while (conceptIterator.hasNext()) {
SnomedConcepts chunk = conceptIterator.next();
writeValues(writer, chunk);
monitor.worked(chunk.getItems().size());
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedQueryMemberCreateDelegate method createWithNewRefSet.
private String createWithNewRefSet(SnomedReferenceSet refSet, TransactionContext context) {
checkNonEmptyProperty(REFERENCED_COMPONENT);
checkComponentExists(refSet, context, SnomedRf2Headers.FIELD_MODULE_ID, getModuleId());
// create new simple type reference set
final SnomedConcept referencedComponent = getProperty(REFERENCED_COMPONENT, SnomedConcept.class);
final String referencedComponentId = new IdRequest<>(referencedComponent.toCreateRequest()).execute(context);
// write the generated ID back to the request
setReferencedComponentId(referencedComponentId);
// add all matching members
final SnomedConcepts queryResults = SnomedRequests.prepareSearchConcept().all().filterByEcl(getProperty(SnomedRf2Headers.FIELD_QUERY)).build().execute(context);
for (SnomedConcept queryResult : queryResults) {
SnomedComponents.newSimpleMember().withActive(isActive()).withReferencedComponent(queryResult.getId()).withModuleId(getModuleId()).withRefSet(referencedComponentId).addTo(context);
}
return createWithExistingRefSet(refSet, context);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedClassificationApiTest method issue_SO_1830_testInferredEquivalentConceptParents.
@Test
public void issue_SO_1830_testInferredEquivalentConceptParents() throws Exception {
String parentConceptId = createNewConcept(branchPath);
String childConceptId = createNewConcept(branchPath, parentConceptId);
String equivalentConceptId = createNewConcept(branchPath, parentConceptId);
changeToDefining(branchPath, equivalentConceptId);
String classificationId = getClassificationJobId(beginClassification(branchPath));
waitForClassificationJob(branchPath, classificationId).statusCode(200).body("status", equalTo(ClassificationStatus.COMPLETED.name()));
/*
* Expecting that childConceptId will get two inferred IS A-s pointing to parentConceptId and equivalentConceptId, respectively,
* while parentConceptId and equivalentConceptId each will get a single inferred IS A pointing to the root concept.
*/
RelationshipChanges changes = MAPPER.readValue(getRelationshipChanges(branchPath, classificationId).statusCode(200).extract().asInputStream(), RelationshipChanges.class);
FluentIterable<RelationshipChange> changesIterable = FluentIterable.from(changes.getItems());
assertEquals(4, changes.getTotal());
assertTrue("All changes should be inferred.", changesIterable.allMatch(relationshipChange -> ChangeNature.NEW.equals(relationshipChange.getChangeNature())));
assertInferredIsAExists(changesIterable, childConceptId, parentConceptId);
assertInferredIsAExists(changesIterable, childConceptId, equivalentConceptId);
assertInferredIsAExists(changesIterable, parentConceptId, Concepts.ROOT_CONCEPT);
assertInferredIsAExists(changesIterable, equivalentConceptId, Concepts.ROOT_CONCEPT);
EquivalentConceptSets equivalentConceptSets = MAPPER.readValue(getEquivalentConceptSets(branchPath, classificationId).statusCode(200).extract().asInputStream(), EquivalentConceptSets.class);
assertEquals(1, equivalentConceptSets.getItems().size());
SnomedConcepts equivalentConceptsInFirstSet = equivalentConceptSets.first().get().getEquivalentConcepts();
FluentIterable<SnomedConcept> equivalentConceptsIterable = FluentIterable.from(equivalentConceptsInFirstSet);
assertEquals(2, equivalentConceptsInFirstSet.getTotal());
assertEquivalentConceptPresent(equivalentConceptsIterable, parentConceptId);
assertEquivalentConceptPresent(equivalentConceptsIterable, equivalentConceptId);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedConceptSearchApiTest method searchByMembership.
@Test
public void searchByMembership() throws Exception {
String conceptId1 = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
String conceptId2 = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
String refSetId = createNewRefSet(branchPath, SnomedRefSetType.SIMPLE);
String memberId1 = createNewRefSetMember(branchPath, conceptId1, refSetId);
createNewRefSetMember(branchPath, conceptId2, refSetId);
updateComponent(branchPath, SnomedComponentType.MEMBER, memberId1, Json.object("active", false, "commitComment", "Inactivated reference set member")).statusCode(204);
SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("isActiveMemberOf", List.of(refSetId))).get("/{path}/concepts/", branchPath.getPath()).then().assertThat().statusCode(200).extract().as(SnomedConcepts.class);
assertThat(hits.getTotal()).isEqualTo(1);
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedConceptSearchApiTest method searchByNamespace.
@Test
public void searchByNamespace() throws Exception {
String conceptId = createNewConcept(branchPath, createConceptRequestBody(Concepts.ROOT_CONCEPT).with("namespaceId", "1000001").with("commitComment", "Create new concept"));
SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("namespace", List.of("1000001"))).get("/{path}/concepts/", branchPath.getPath()).then().assertThat().statusCode(200).extract().as(SnomedConcepts.class);
assertThat(hits.getTotal()).isEqualTo(1);
assertThat(hits.getItems()).allMatch(c -> conceptId.equals(c.getId()));
}
Aggregations