Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SO-4280: Enforce new rules to determine definition status of a concept #663

Open
wants to merge 2 commits into
base: 7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public String execute(TransactionContext context) {

private SnomedConceptDocument convertConcept(final TransactionContext context) {
final String newDefinitionStatusId;
final Set<String> newAxiomExpressions = getOwlAxiomExpressions();
final Set<String> newAxiomExpressions = getOwlAxiomExpressions(context);

if (!newAxiomExpressions.isEmpty()) {
newDefinitionStatusId = SnomedOWLAxiomHelper.getDefinitionStatusFromExpressions(newAxiomExpressions);
Expand All @@ -140,12 +140,17 @@ private SnomedConceptDocument convertConcept(final TransactionContext context) {
}
}

private Set<String> getOwlAxiomExpressions() {
private Set<String> getOwlAxiomExpressions(final TransactionContext context) {
return Optional.ofNullable(members()).map(Collection::stream).orElseGet(Stream::empty)
.filter(req -> req.hasProperty(SnomedRf2Headers.FIELD_OWL_EXPRESSION))
.filter(req -> {
String owlExpression = req.getProperty(SnomedRf2Headers.FIELD_OWL_EXPRESSION);
SnomedOWLExpressionConverterResult result = context.service(SnomedOWLExpressionConverter.class)
.toSnomedOWLRelationships(req.getReferencedComponentId(), owlExpression);
return result.getGciAxiomRelationships() == null || result.getGciAxiomRelationships().isEmpty();
})
.map(req -> req.getProperty(SnomedRf2Headers.FIELD_OWL_EXPRESSION))
.collect(Collectors.toSet());

}

private void convertDescriptions(TransactionContext context, final String conceptId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private boolean updateDefinitionStatus(final TransactionContext context, final S
.map(Collection::stream)
.orElseGet(Stream::empty)
.filter(member -> SnomedRefSetType.OWL_AXIOM == member.type() || Concepts.REFSET_OWL_AXIOM.equals(member.getReferenceSetId()))
.filter(member -> member.getGciOWLRelationships() == null || member.getGciOWLRelationships().isEmpty()) // Filter out GCI axioms
.map(member -> (String) member.getProperties().get(SnomedRf2Headers.FIELD_OWL_EXPRESSION))
.collect(Collectors.toSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public final class SnomedOWLAxiomHelper {

private static final String SUBCLASSOF = "subclassof";
private static final String EQUIVALENTCLASSES = "equivalentclasses";

public static String getDefinitionStatusFromExpressions(Set<String> owlExpressions) {
if (owlExpressions.isEmpty()) {
Expand All @@ -35,7 +35,7 @@ public static String getDefinitionStatusFromExpressions(Set<String> owlExpressio

return owlExpressions.stream()
.filter(expression -> !Strings.isNullOrEmpty(expression))
Copy link
Member

@apeteri apeteri Sep 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filter GCI axioms here (in class SnomedOWLAxiomHelper), not in the create or update requests. They don't have a say in the concept's suggested definition status, but should be going through when creating or updating a SNOMED CT concept, just as before.

Or did they cause some other problem?

.filter(expression -> expression.toLowerCase(Locale.ENGLISH).contains(SUBCLASSOF))
.filter(expression -> !expression.toLowerCase(Locale.ENGLISH).contains(EQUIVALENTCLASSES))
.findFirst()
.map(equivalentClassesAxiom -> Concepts.PRIMITIVE)
.orElse(Concepts.FULLY_DEFINED);
Expand Down