use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedConceptSearchApiTest method searchByNamespaceConceptId.
@Test
public void searchByNamespaceConceptId() 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(// Extension Namespace {1000001} (namespace concept)
Map.of("namespaceConceptId", List.of("370138007"))).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()));
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class SnomedConceptSearchApiTest method searchBySemanticTag.
@Test
public void searchBySemanticTag() throws Exception {
String conceptId = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
createNewDescription(branchPath, Json.object("conceptId", conceptId, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.FULLY_SPECIFIED_NAME, "term", "My awesome fsn (tag)", "languageCode", "en", "acceptability", UK_PREFERRED_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE, "commitComment", "New FSN"));
SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("semanticTag", "tag")).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 searchByBothSemanticTagAndTerm.
/**
* Related to https://github.com/b2ihealthcare/snow-owl/issues/738
*/
@Test
public void searchByBothSemanticTagAndTerm() throws Exception {
String conceptId = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
createNewDescription(branchPath, Json.object("conceptId", conceptId, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.FULLY_SPECIFIED_NAME, "term", "My awesome fsn (tag)", "languageCode", "en", "acceptability", UK_PREFERRED_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE, "commitComment", "New FSN"));
createNewDescription(branchPath, Json.object("conceptId", conceptId, "moduleId", Concepts.MODULE_SCT_CORE, "typeId", Concepts.FULLY_SPECIFIED_NAME, "term", "My another fsn (other)", "languageCode", "en", "acceptability", UK_PREFERRED_MAP, "caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE, "commitComment", "New FSN"));
SnomedConcepts hits = givenAuthenticatedRequest(getApiBaseUrl()).accept(JSON_UTF8).queryParams(Map.of("term", "another", "semanticTag", "tag")).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 EquivalentConceptSetConverter method toResource.
@Override
protected EquivalentConceptSet toResource(final EquivalentConceptSetDocument entry) {
final EquivalentConceptSet resource = new EquivalentConceptSet();
resource.setClassificationId(entry.getClassificationId());
resource.setUnsatisfiable(entry.isUnsatisfiable());
final List<SnomedConcept> items = newArrayList();
for (final LongIterator itr = entry.getConceptIds().iterator(); itr.hasNext(); ) /* empty */
{
items.add(new SnomedConcept(Long.toString(itr.next())));
}
final SnomedConcepts equivalentConcepts = new SnomedConcepts(items, null, items.size(), items.size());
resource.setEquivalentConcepts(equivalentConcepts);
return resource;
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcepts in project snow-owl by b2ihealthcare.
the class ConceptChangeConverter method expand.
@Override
public void expand(final List<ConceptChange> results) {
if (!expand().containsKey(ConceptChange.Expand.CONCEPT)) {
return;
}
/*
* Depending on the concept change search request, we might need to issue
* SNOMED CT searches against multiple branches; find out which ones we have.
*/
final Multimap<String, ConceptChange> itemsByBranch = getItemsByBranch(results);
// Check if we only need to load inferred concepts in their entirety
final Options expandOptions = expand().getOptions(ConceptChange.Expand.CONCEPT);
// pt() and fsn() are the only useful options here
final Options conceptExpandOptions = expandOptions.getOptions("expand");
conceptExpandOptions.keySet().retainAll(CONCEPT_EXPAND_OPTIONS);
for (final String branch : itemsByBranch.keySet()) {
final Collection<ConceptChange> itemsForCurrentBranch = itemsByBranch.get(branch);
final Set<String> conceptIds = itemsForCurrentBranch.stream().map(c -> c.getConcept().getOriginConceptId()).collect(Collectors.toSet());
final Request<BranchContext, SnomedConcepts> conceptSearchRequest = SnomedRequests.prepareSearchConcept().filterByIds(conceptIds).setLimit(conceptIds.size()).setExpand(conceptExpandOptions).setLocales(locales()).build();
final SnomedConcepts concepts = new BranchRequest<>(branch, new RevisionIndexReadRequest<>(conceptSearchRequest)).execute(context());
final Map<String, SnomedConcept> conceptsById = Maps.uniqueIndex(concepts, SnomedConcept::getId);
for (final ConceptChange item : itemsForCurrentBranch) {
final ReasonerConcept reasonerConcept = item.getConcept();
final String conceptId = reasonerConcept.getOriginConceptId();
final SnomedConcept expandedConcept = conceptsById.get(conceptId);
reasonerConcept.setDefinitionStatusId(expandedConcept.getDefinitionStatusId());
reasonerConcept.setPt(expandedConcept.getPt());
reasonerConcept.setFsn(expandedConcept.getFsn());
// reasonerConcept.setReleased(...) is already set
}
}
}
Aggregations