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);
}
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);
}
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);
}
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;
}
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();
}
Aggregations