Search in sources :

Example 11 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedCompareRestRequestTest method prepareNewChanges.

private Set<ComponentIdentifier> prepareNewChanges(String conceptId, IBranchPath branchPath) {
    final SnomedConcept concept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "descriptions(expand(members())),relationships()").extract().as(SnomedConcept.class);
    final Set<ComponentIdentifier> newIds = newHashSet();
    newIds.add(ComponentIdentifier.of(SnomedConcept.TYPE, concept.getId()));
    for (SnomedDescription description : concept.getDescriptions()) {
        newIds.add(ComponentIdentifier.of(SnomedDescription.TYPE, description.getId()));
        for (SnomedReferenceSetMember member : description.getMembers()) {
            newIds.add(ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, member.getId()));
        }
    }
    for (SnomedRelationship relationship : concept.getRelationships()) {
        newIds.add(ComponentIdentifier.of(SnomedRelationship.TYPE, relationship.getId()));
    }
    return newIds;
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) ComponentIdentifier(com.b2international.snowowl.core.ComponentIdentifier) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 12 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedDescriptionConverter method expandType.

private void expandType(List<SnomedDescription> results, final Set<String> descriptionIds) {
    if (expand().containsKey("type")) {
        final Options expandOptions = expand().get("type", Options.class);
        final Iterable<String> typeIds = FluentIterable.from(results).transform(SnomedDescription::getTypeId);
        context().service(SnomedConceptRequestCache.class).request(typeIds, expandOptions.getOptions("expand"), locales(), typesById -> {
            for (SnomedDescription description : results) {
                ((SnomedDescription) description).setType(typesById.get(description.getTypeId()));
            }
        });
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)

Example 13 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedDescriptionConverter method expandConcept.

private void expandConcept(List<SnomedDescription> results, final Set<String> descriptionIds) {
    if (expand().containsKey("concept")) {
        final Options expandOptions = expand().get("concept", Options.class);
        final Iterable<String> conceptIds = FluentIterable.from(results).transform(SnomedDescription::getConceptId);
        context().service(SnomedConceptRequestCache.class).request(conceptIds, expandOptions.getOptions("expand"), locales(), conceptsById -> {
            for (SnomedDescription description : results) {
                ((SnomedDescription) description).setConcept(conceptsById.get(description.getConceptId()));
            }
        });
    }
}
Also used : Options(com.b2international.commons.options.Options) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)

Example 14 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedDescriptionConverter method expandCaseSignificance.

private void expandCaseSignificance(List<SnomedDescription> results) {
    if (!expand().containsKey("caseSignificance")) {
        return;
    }
    final Iterable<String> caseSignificanceIds = results.stream().map(SnomedDescription::getCaseSignificanceId)::iterator;
    final Options caseSignificanceExpand = expand().get("caseSignificance", Options.class);
    context().service(SnomedConceptRequestCache.class).request(caseSignificanceIds, caseSignificanceExpand.getOptions("expand"), locales(), caseSignificancesById -> {
        for (SnomedDescription result : results) {
            result.setCaseSignificance(caseSignificancesById.get(result.getCaseSignificanceId()));
        }
    });
}
Also used : Options(com.b2international.commons.options.Options) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedConceptRequestCache(com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)

Example 15 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedReferenceSetMemberConverter method setReferencedComponent.

private void setReferencedComponent(SnomedReferenceSetMember member, String referencedComponentId, String referencedComponentType) {
    // XXX: partial field loading support
    if (referencedComponentType == null || referencedComponentId == null)
        return;
    final SnomedCoreComponent component;
    switch(referencedComponentType) {
        // TODO support query type refset refcomp expansion, currently it's a concept
        case SnomedConcept.REFSET_TYPE:
        case SnomedConcept.TYPE:
            component = new SnomedConcept();
            ((SnomedConcept) component).setId(referencedComponentId);
            break;
        case SnomedDescription.TYPE:
            component = new SnomedDescription();
            ((SnomedDescription) component).setId(referencedComponentId);
            break;
        case SnomedRelationship.TYPE:
            component = new SnomedRelationship();
            ((SnomedRelationship) component).setId(referencedComponentId);
            break;
        default:
            throw new UnsupportedOperationException("UnsupportedReferencedComponentType: " + referencedComponentType);
    }
    member.setReferencedComponent(component);
}
Also used : SnomedCoreComponent(com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Aggregations

SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)25 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)14 Test (org.junit.Test)8 Json (com.b2international.commons.json.Json)7 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)6 LocalDate (java.time.LocalDate)6 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)5 Options (com.b2international.commons.options.Options)4 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)4 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)4 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)4 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)3 BranchContext (com.b2international.snowowl.core.domain.BranchContext)3 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)3 InactivationProperties (com.b2international.snowowl.snomed.core.domain.InactivationProperties)3 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)3 SnomedConceptRequestCache (com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)3