Search in sources :

Example 71 with SnomedConcept

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

the class SnomedSimpleTypeRefSetDSVExporter method computeHeader.

private void computeHeader(SnomedConcepts chunk) {
    for (SnomedConcept concept : chunk) {
        for (AbstractSnomedDsvExportItem exportItem : exportItems) {
            switch(exportItem.getType()) {
                case DESCRIPTION:
                    ComponentIdSnomedDsvExportItem descriptionItem = (ComponentIdSnomedDsvExportItem) exportItem;
                    String descriptionTypeId = descriptionItem.getComponentId();
                    Integer matchingDescriptions = concept.getDescriptions().stream().filter(d -> descriptionTypeId.equals(d.getTypeId())).collect(Collectors.reducing(0, description -> 1, Integer::sum));
                    descriptionCount.merge(descriptionTypeId, matchingDescriptions, Math::max);
                    break;
                case RELATIONSHIP:
                    ComponentIdSnomedDsvExportItem relationshipItem = (ComponentIdSnomedDsvExportItem) exportItem;
                    String relationshipTypeId = relationshipItem.getComponentId();
                    Map<Integer, Integer> matchingRelationships = concept.getRelationships().stream().filter(r -> relationshipTypeId.equals(r.getTypeId()) && (Concepts.INFERRED_RELATIONSHIP.equals(r.getCharacteristicTypeId()) || Concepts.ADDITIONAL_RELATIONSHIP.equals(r.getCharacteristicTypeId()))).collect(Collectors.groupingBy(SnomedRelationship::getRelationshipGroup, Collectors.reducing(0, relationship -> 1, Integer::sum)));
                    matchingRelationships.entrySet().stream().forEach(entry -> {
                        propertyCountByGroup.compute(entry.getKey(), (key, oldValue) -> {
                            Map<String, Integer> propertyCountForGroup = ofNullable(oldValue).orElseGet(HashMap::new);
                            propertyCountForGroup.merge(relationshipTypeId, entry.getValue(), Math::max);
                            return propertyCountForGroup;
                        });
                    });
                    break;
                case DATAYPE:
                    ComponentIdSnomedDsvExportItem dataTypeItem = (ComponentIdSnomedDsvExportItem) exportItem;
                    String dataTypeId = dataTypeItem.getComponentId();
                    Map<Integer, Integer> matchingMembers = concept.getMembers().stream().filter(m -> SnomedRefSetType.CONCRETE_DATA_TYPE.equals(m.type()) && m.isActive() && dataTypeId.equals(m.getProperties().get(SnomedRf2Headers.FIELD_TYPE_ID)) && (Concepts.INFERRED_RELATIONSHIP.equals(m.getProperties().get(SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID)) || Concepts.ADDITIONAL_RELATIONSHIP.equals(m.getProperties().get(SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID)))).collect(Collectors.groupingBy(m -> (Integer) m.getProperties().get(SnomedRf2Headers.FIELD_RELATIONSHIP_GROUP), Collectors.reducing(0, relationship -> 1, Integer::sum)));
                    matchingMembers.entrySet().stream().forEach(entry -> {
                        propertyCountByGroup.compute(entry.getKey(), (key, oldValue) -> {
                            Map<String, Integer> propertyCountForGroup = ofNullable(oldValue).orElseGet(HashMap::new);
                            propertyCountForGroup.merge(dataTypeId, entry.getValue(), Math::max);
                            return propertyCountForGroup;
                        });
                    });
                    break;
                default:
                    // Single-use fields don't need to be counted in advance
                    break;
            }
        }
    }
}
Also used : EffectiveTimes(com.b2international.snowowl.core.date.EffectiveTimes) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) java.util(java.util) SnomedConceptSearchRequestBuilder(com.b2international.snowowl.snomed.datastore.request.SnomedConceptSearchRequestBuilder) Concepts(com.b2international.snowowl.snomed.common.SnomedConstants.Concepts) ExtendedLocale(com.b2international.commons.http.ExtendedLocale) SnomedRequests(com.b2international.snowowl.snomed.datastore.request.SnomedRequests) ComponentIdSnomedDsvExportItem(com.b2international.snowowl.snomed.datastore.internal.rf2.ComponentIdSnomedDsvExportItem) SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) Path(java.nio.file.Path) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Charsets(com.google.common.base.Charsets) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) Files(java.nio.file.Files) ImmutableMap(com.google.common.collect.ImmutableMap) Optional.ofNullable(java.util.Optional.ofNullable) BufferedWriter(java.io.BufferedWriter) Dates(com.b2international.snowowl.core.date.Dates) SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) AbstractSnomedDsvExportItem(com.b2international.snowowl.snomed.datastore.internal.rf2.AbstractSnomedDsvExportItem) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedRefSetDSVExportModel(com.b2international.snowowl.snomed.datastore.internal.rf2.SnomedRefSetDSVExportModel) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) DatatypeSnomedDsvExportItem(com.b2international.snowowl.snomed.datastore.internal.rf2.DatatypeSnomedDsvExportItem) Ordering(com.google.common.collect.Ordering) Sort(com.b2international.snowowl.core.request.SearchResourceRequest.Sort) SearchResourceRequestIterator(com.b2international.snowowl.core.request.SearchResourceRequestIterator) SnomedRf2Headers(com.b2international.snowowl.snomed.common.SnomedRf2Headers) BranchContext(com.b2international.snowowl.core.domain.BranchContext) SnomedRefSetType(com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType) Joiner(com.google.common.base.Joiner) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) AbstractSnomedDsvExportItem(com.b2international.snowowl.snomed.datastore.internal.rf2.AbstractSnomedDsvExportItem) ComponentIdSnomedDsvExportItem(com.b2international.snowowl.snomed.datastore.internal.rf2.ComponentIdSnomedDsvExportItem)

Example 72 with SnomedConcept

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

the class Rf2OwlExpressionRefSetContentType method resolve.

@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
    component.setRefsetId(values[4]);
    if (Concepts.REFSET_OWL_AXIOM.equals(component.getRefsetId())) {
        component.setType(SnomedRefSetType.OWL_AXIOM);
    } else if (Concepts.REFSET_OWL_ONTOLOGY.equals(component.getRefsetId())) {
        component.setType(SnomedRefSetType.OWL_ONTOLOGY);
    } else {
        throw new UnsupportedOperationException("Unrecognized OWL Reference Set " + component.getRefsetId());
    }
    // XXX actual type is not relevant here
    component.setReferencedComponent(new SnomedConcept(values[5]));
    component.setProperties(ImmutableMap.of(FIELD_OWL_EXPRESSION, values[6]));
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 73 with SnomedConcept

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

the class Rf2SimpleRefSetContentType method resolve.

@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
    component.setType(SnomedRefSetType.SIMPLE);
    component.setRefsetId(values[4]);
    // XXX actual type is not relevant here
    component.setReferencedComponent(new SnomedConcept(values[5]));
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 74 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept 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);
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 75 with SnomedConcept

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

the class Rf2AttributeValueRefSetContentType method resolve.

@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
    component.setType(SnomedRefSetType.ATTRIBUTE_VALUE);
    component.setRefsetId(values[4]);
    // XXX actual type is not relevant here
    component.setReferencedComponent(new SnomedConcept(values[5]));
    component.setProperties(ImmutableMap.of(SnomedRf2Headers.FIELD_VALUE_ID, values[6]));
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Aggregations

SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)90 Test (org.junit.Test)42 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)17 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)15 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)15 LocalDate (java.time.LocalDate)15 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)12 SnomedConcepts (com.b2international.snowowl.snomed.core.domain.SnomedConcepts)12 Options (com.b2international.commons.options.Options)10 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)10 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)9 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)8 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)8 CodeSystemRestRequests.createCodeSystem (com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests.createCodeSystem)8 List (java.util.List)8 Map (java.util.Map)8 Collectors (java.util.stream.Collectors)8 Json (com.b2international.commons.json.Json)7 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)7 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)5