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-5535: MRCM evaluations #1068

Merged
merged 40 commits into from
Dec 7, 2022
Merged

Conversation

AAAlinaaa
Copy link
Contributor

@AAAlinaaa AAAlinaaa commented Oct 12, 2022

@AAAlinaaa AAAlinaaa self-assigned this Oct 12, 2022
@AAAlinaaa AAAlinaaa changed the title Issue/so 5535 mrcm applicable predicates SO-5535 MRCM evaluations Oct 12, 2022
@AAAlinaaa AAAlinaaa marked this pull request as ready for review October 15, 2022 12:50
@AAAlinaaa AAAlinaaa requested a review from cmark October 15, 2022 12:50
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2022

Codecov Report

Base: 64.23% // Head: 64.26% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (ab252c7) compared to base (830f966).
Patch coverage: 74.73% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##                8.x    #1068      +/-   ##
============================================
+ Coverage     64.23%   64.26%   +0.02%     
- Complexity    12467    12516      +49     
============================================
  Files          1734     1741       +7     
  Lines         58217    58451     +234     
  Branches       5372     5394      +22     
============================================
+ Hits          37396    37562     +166     
- Misses        18506    18567      +61     
- Partials       2315     2322       +7     
Impacted Files Coverage Δ
...ational/snowowl/snomed/common/SnomedConstants.java 100.00% <ø> (ø)
...nowowl/snomed/core/rest/SnomedMrcmRestService.java 4.76% <4.76%> (ø)
...ational/snowowl/snomed/core/MrcmAttributeType.java 50.00% <50.00%> (ø)
...nomed/datastore/request/SnomedMrcmTypeRequest.java 75.00% <75.00%> (ø)
...tastore/request/SnomedMrcmRangeRequestBuilder.java 80.00% <80.00%> (ø)
...omed/datastore/request/SnomedMrcmRangeRequest.java 92.30% <92.30%> (ø)
...atastore/request/SnomedMrcmTypeRequestBuilder.java 100.00% <100.00%> (ø)
...owowl/snomed/datastore/request/SnomedRequests.java 92.10% <100.00%> (+0.43%) ⬆️
...n/detail/SnomedValidationIssueDetailExtension.java 75.54% <100.00%> (ø)
...x/src/com/b2international/index/util/JsonDiff.java 75.29% <0.00%> (-2.36%) ⬇️
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -386,5 +397,97 @@ public static SnomedRepositoryCommitRequestBuilder prepareCommit() {
public static SnomedConceptSearchRequestBuilder prepareGetSynonyms() {
return prepareSearchConcept().all().filterByActive(true).filterByEcl("<<"+Concepts.SYNONYM);
}


public static Promise<Collection<String>> getApplicableTypes(final IEventBus bus, final String resourcePath,
Copy link
Member

Choose a reason for hiding this comment

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

Let's push this completely to the server side as one request to form a new Java API.

requestBuilder.filterByAncestor(SnomedConstants.Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE);
} else if (!needsDataAttributes && needsObjectAttributes) {
requestBuilder.filterByAncestor(SnomedConstants.Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
}
Copy link
Member

Choose a reason for hiding this comment

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

Add another else block with a meaningful comment for the missing case (both boolean parameters are false).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer applicable.

.execute(bus);
}).thenWith(members -> {
Set<String> typeIds = members.stream().map(m -> m.getReferencedComponentId()).collect(Collectors.toSet());
if ((needsDataAttributes && needsObjectAttributes) || typeIds.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

What happens if I specify both boolean parameters with the value false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to use an enum instead, so this wouldn't happen.

}

def searchRelationshipsInUnregulatedDomains = {
String regulatedDomainSpace = Joiner.on(" OR ")
Copy link
Member

Choose a reason for hiding this comment

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

If this is an ECL OR operator, then use Ecl.or helper instead.

String regulatedDomainSpace = Joiner.on(" OR ")
.join(FluentIterable.from(domainMembers.values())
.transform({ m -> m.getProperties().get(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT)})
.transform({ c -> "(${c})"}));
Copy link
Member

Choose a reason for hiding this comment

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

This becomes unnecessary if you use that Ecl.or helper I think.

.transform({ m -> m.getProperties().get(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT)})
.transform({ c -> "(${c})"}));

Set<String> unregulatedDomainSpace = getApplicableConcepts("* MINUS (${regulatedDomainSpace})");
Copy link
Member

Choose a reason for hiding this comment

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

Use Ecl.exclude helper.

//Find non-IsA relationships in domains where no MRCM rule is defined
ExpressionBuilder relationshipQueryBuilder = Expressions.builder()
.filter(SnomedRelationshipIndexEntry.Expressions.active())
.filter(SnomedRelationshipIndexEntry.Expressions.sourceIds(unregulatedDomainSpace))
Copy link
Member

Choose a reason for hiding this comment

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

Is regulated/unregulated the same as sanctioned/unsanctioned? If yes, please rename these variables to the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They might, I was trying to make a distinction between cases that break an explicit rule, vs cases that aren't covered by any rules. To me, an attribute that breaks an explicit rule is an unsanctioned attribute, attributes in domains that have no rules defined for them are unregulated.

This comment was marked as duplicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do offer both sanctioned and unsanctioned properties for selection.

.domainConstraint(String.format("<<%s", Concepts.CONCEPT_MODEL_ATTRIBUTE))
.build();

final SnomedRefSetMemberIndexEntry mrcmAttributeDomainMember1 = member(Concepts.FINDING_SITE, Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL)
.referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_DOMAIN)
.refsetId(Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL)
Copy link
Member

Choose a reason for hiding this comment

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

Do we have test cases for failing/passing OWL Axiom MRCM relationships?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we do.

@cmark cmark requested a review from apeteri November 13, 2022 14:55
@cmark cmark changed the title SO-5535 MRCM evaluations SO-5535: MRCM evaluations Nov 24, 2022
.setFields(ID, MRCM_RULE_REFSET_ID)
.build()
.execute(context)
.stream()
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use all() anymore unless you have a really good reason to do so. Also, using all + stream together is a no go. Please set the limit correctly.

Copy link
Member

Choose a reason for hiding this comment

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

This request queries a small set of module scope members, which should be kept in practice at a low member count (the current tally is 3, and the expected count is 3 × number of modules declaring MRCM rules). stream() is called on the returned collection resource and processes individual members, not batches.

//Find non-IsA relationships in domains where no MRCM rule is defined
ExpressionBuilder relationshipQueryBuilder = Expressions.builder()
.filter(SnomedRelationshipIndexEntry.Expressions.active())
.filter(SnomedRelationshipIndexEntry.Expressions.sourceIds(unregulatedDomainSpace))

This comment was marked as duplicate.

Copy link
Member

@apeteri apeteri left a comment

Choose a reason for hiding this comment

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

One small observation below. I think the rest of my requests were addressed, so LGTM otherwise!

Copy link
Member

@cmark cmark left a comment

Choose a reason for hiding this comment

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

🥓

@cmark cmark merged commit fea71e2 into 8.x Dec 7, 2022
@cmark cmark deleted the issue/SO-5535-MRCM_applicable_predicates branch December 7, 2022 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants