Search in sources :

Example 51 with SnomedConcept

use of com.b2international.snowowl.snomed.core.domain.SnomedConcept 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)

Example 52 with SnomedConcept

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

the class TerminologyTreeTest method getProximalPrimitiveParentsOfDefiningConceptWithTwoDistinctPrimitiveParents.

@Test
public void getProximalPrimitiveParentsOfDefiningConceptWithTwoDistinctPrimitiveParents() throws Exception {
    final TerminologyTree tree = new TestTree().addNode(N1, true, null, newHashSet(N3)).addNode(N2, true, null, newHashSet(N3)).addNode(N3, false, newHashSet(N1, N2)).build();
    final SnomedConcept n1 = tree.getNode(N1);
    final SnomedConcept n2 = tree.getNode(N2);
    assertThat(tree.getProximalPrimitiveParents(N3)).containsOnly(n1, n2);
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test)

Example 53 with SnomedConcept

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

the class TerminologyTreeTest method getProximalPrimitiveWithFixedAncestorSet.

@Test
public void getProximalPrimitiveWithFixedAncestorSet() throws Exception {
    final TerminologyTree tree = new TestTree().addNode(N1, true, null, newHashSet(N2, N4)).addNode(N2, true, newHashSet(N1), newHashSet(N3)).addNode(N3, true, newHashSet(N2), newHashSet(N4)).addNode(N4, false, newHashSet(N3, N1)).build();
    final SnomedConcept n3 = tree.getNode(N3);
    assertThat(tree.getProximalPrimitiveParents(N4)).containsOnly(n3);
    final SnomedConcept n1 = tree.getNode(N1);
    final SnomedConcept n2 = tree.getNode(N2);
    assertThat(tree.getProximalPrimitiveParentIds(newArrayList(n3, n1, n2))).containsOnly(N3);
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test)

Example 54 with SnomedConcept

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

the class SnomedConceptCreateRequest method isValidParentage.

private boolean isValidParentage(TransactionContext context, String requiredSuperType, Collection<String> parents) {
    // first check if the requiredSuperType is specified in the parents collection
    if (parents.contains(requiredSuperType)) {
        return true;
    }
    // if not, then check if any of the specified parents is subTypeOf the requiredSuperType
    final long superTypeIdLong = Long.parseLong(requiredSuperType);
    final SnomedConcepts parentConcepts = SnomedRequests.prepareSearchConcept().setLimit(parents.size()).filterByIds(parents).build().execute(context);
    for (SnomedConcept parentConcept : parentConcepts) {
        if (parentConcept.getParentIds() != null) {
            if (PrimitiveSets.newLongOpenHashSet(parentConcept.getParentIds()).contains(superTypeIdLong)) {
                return true;
            }
        }
        if (parentConcept.getAncestorIds() != null) {
            if (PrimitiveSets.newLongOpenHashSet(parentConcept.getAncestorIds()).contains(superTypeIdLong)) {
                return true;
            }
        }
    }
    return false;
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 55 with SnomedConcept

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

the class SnomedConceptMapSearchRequestEvaluator method toMapping.

private ConceptMapMapping toMapping(SnomedReferenceSetMember member, ResourceURI codeSystemURI, ComponentURI targetURI, final SnomedDisplayTermType snomedDisplayTermType, final Map<String, SnomedConcept> refSetsByIds) {
    final String iconId = member.getReferencedComponent().getIconId();
    final String componentType = member.getReferencedComponent().getComponentType();
    final SnomedConcept concept = (SnomedConcept) member.getReferencedComponent();
    final String term = snomedDisplayTermType.getLabel(concept);
    Builder mappingBuilder = ConceptMapMapping.builder();
    Map<String, Object> properties = member.getProperties();
    String mapTarget = (String) properties.get(SnomedRf2Headers.FIELD_MAP_TARGET);
    if (ComponentURI.isValid(mapTarget)) {
        mappingBuilder.targetComponentURI(ComponentURI.of(mapTarget));
    } else {
        mappingBuilder.targetComponentURI(ComponentURI.of(targetURI.resourceUri(), targetURI.componentType(), mapTarget));
    }
    if (properties.containsKey(SnomedRf2Headers.FIELD_MAP_PRIORITY)) {
        int mapPriority = (int) properties.get(SnomedRf2Headers.FIELD_MAP_PRIORITY);
        mappingBuilder.mapPriority(mapPriority);
    }
    if (properties.containsKey(SnomedRf2Headers.FIELD_MAP_GROUP)) {
        int mapGroup = (int) properties.get(SnomedRf2Headers.FIELD_MAP_GROUP);
        mappingBuilder.mapGroup(mapGroup);
    }
    mappingBuilder.mapAdvice((String) properties.get(SnomedRf2Headers.FIELD_MAP_ADVICE));
    mappingBuilder.mapRule((String) properties.get(SnomedRf2Headers.FIELD_MAP_RULE));
    final SnomedConcept referenceSet = refSetsByIds.get(member.getRefsetId());
    return mappingBuilder.uri(ComponentURI.of(codeSystemURI, SnomedReferenceSetMember.TYPE, member.getId()).toString()).conceptMapUri(ComponentURI.of(codeSystemURI, SnomedConcept.REFSET_TYPE, member.getRefsetId()).toString()).conceptMapTerm(referenceSet.getPt().getTerm()).conceptMapIconId(referenceSet.getIconId()).sourceComponentURI(ComponentURI.of(codeSystemURI, componentType, member.getReferencedComponentId())).sourceIconId(iconId).sourceTerm(term).targetTerm(mapTarget).active(member.isActive()).mappingCorrelation(getEquivalence(member)).build();
}
Also used : Builder(com.b2international.snowowl.core.domain.ConceptMapMapping.Builder) OptionsBuilder(com.b2international.commons.options.OptionsBuilder) 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