use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedDescriptionConverter method toResource.
@Override
protected SnomedDescription toResource(final SnomedDescriptionIndexEntry input) {
final SnomedDescription result = new SnomedDescription();
result.setAcceptabilityMap(input.getAcceptabilityMap());
result.setActive(input.isActive());
result.setCaseSignificanceId(input.getCaseSignificanceId());
result.setConceptId(input.getConceptId());
result.setEffectiveTime(toEffectiveTime(input.getEffectiveTime()));
result.setId(input.getId());
result.setLanguageCode(input.getLanguageCode());
result.setModuleId(input.getModuleId());
result.setIconId(input.getIconId());
result.setReleased(input.isReleased());
result.setTerm(input.getTerm());
result.setSemanticTag(input.getSemanticTag());
result.setTypeId(input.getTypeId());
result.setType(new SnomedConcept(input.getTypeId()));
result.setScore(input.getScore());
if (input.getMemberOf() != null) {
result.setMemberOf(ImmutableSortedSet.copyOf(input.getMemberOf()));
}
if (input.getActiveMemberOf() != null) {
result.setActiveMemberOf(ImmutableSortedSet.copyOf(input.getActiveMemberOf()));
}
return result;
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept 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.SnomedConcept in project snow-owl by b2ihealthcare.
the class SnomedFhirCodeSystemLookupConverter method expandProperties.
@Override
public List<Property> expandProperties(ServiceProvider context, CodeSystem codeSystem, Concept concept, LookupRequest lookupRequest) {
SnomedConcept snomedConcept = concept.getInternalConceptAs();
List<Property> properties = new ArrayList<>();
// add basic SNOMED properties
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.INACTIVE)) {
properties.add(CoreSnomedConceptProperties.INACTIVE.propertyOf(!snomedConcept.isActive()));
}
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.MODULE_ID)) {
properties.add(CoreSnomedConceptProperties.MODULE_ID.propertyOf(snomedConcept.getModuleId()));
}
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.SUFFICIENTLY_DEFINED)) {
properties.add(CoreSnomedConceptProperties.SUFFICIENTLY_DEFINED.propertyOf(!snomedConcept.isPrimitive()));
}
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.EFFECTIVE_TIME)) {
properties.add(CoreSnomedConceptProperties.EFFECTIVE_TIME.propertyOf(EffectiveTimes.format(snomedConcept.getEffectiveTime(), DateFormats.SHORT)));
}
// Optionally requested properties
boolean requestedChild = lookupRequest.containsProperty(CommonConceptProperties.CHILD.getCode());
boolean requestedParent = lookupRequest.containsProperty(CommonConceptProperties.PARENT.getCode());
if (requestedChild && snomedConcept.getDescendants() != null) {
for (SnomedConcept child : snomedConcept.getDescendants()) {
properties.add(CommonConceptProperties.CHILD.propertyOf(child.getId(), SnomedDisplayTermType.PT.getLabel(child)));
}
}
if (requestedParent && snomedConcept.getAncestors() != null) {
for (SnomedConcept parent : snomedConcept.getAncestors()) {
properties.add(CommonConceptProperties.PARENT.propertyOf(parent.getId(), SnomedDisplayTermType.PT.getLabel(parent)));
}
}
// Relationship Properties
Set<String> relationshipTypeIds = lookupRequest.getPropertyCodes().stream().map(p -> {
if (p.startsWith(SnomedTerminologyComponentConstants.SNOMED_URI_BASE)) {
// URI prefixed properties
return p.substring(p.lastIndexOf('/') + 1, p.length());
} else {
// use as is, so users won't need to define full URI for each SNOMED CT property, ID is enough
return p;
}
}).filter(// only SNOMED CT Concept IDs
SnomedIdentifiers::isConceptIdentifier).collect(Collectors.toSet());
if (!relationshipTypeIds.isEmpty()) {
SnomedRequests.prepareSearchRelationship().all().filterByActive(true).filterByCharacteristicType(Concepts.INFERRED_RELATIONSHIP).filterBySource(concept.getId()).filterByTypes(relationshipTypeIds).build(codeSystem.getResourceURI()).getRequest().execute(context).forEach(r -> {
Property.Builder propertyBuilder = Property.builder().code(r.getTypeId());
if (r.hasValue()) {
RelationshipValue value = r.getValueAsObject();
value.map(i -> propertyBuilder.valueInteger(i), d -> propertyBuilder.valueDecimal(d.doubleValue()), s -> propertyBuilder.valueString(s));
} else {
propertyBuilder.valueCode(r.getDestinationId());
}
properties.add(propertyBuilder.build());
});
}
if (properties.isEmpty()) {
return null;
} else {
return properties;
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept 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
}
}
}
use of com.b2international.snowowl.snomed.core.domain.SnomedConcept in project snow-owl by b2ihealthcare.
the class Rf2MRCMAttributeDomainRefSetContentType method resolve.
@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
component.setType(SnomedRefSetType.MRCM_ATTRIBUTE_DOMAIN);
component.setRefsetId(values[4]);
// XXX actual type is not relevant here
component.setReferencedComponent(new SnomedConcept(values[5]));
component.setProperties(ImmutableMap.<String, Object>builder().put(FIELD_MRCM_DOMAIN_ID, values[6]).put(FIELD_MRCM_GROUPED, BooleanUtils.valueOf(values[7])).put(FIELD_MRCM_ATTRIBUTE_CARDINALITY, values[8]).put(FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, values[9]).put(FIELD_MRCM_RULE_STRENGTH_ID, values[10]).put(FIELD_MRCM_CONTENT_TYPE_ID, values[11]).build());
}
Aggregations