-
Notifications
You must be signed in to change notification settings - Fork 344
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
Support Is-a filter in local ValueSet expansion #2733
Support Is-a filter in local ValueSet expansion #2733
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marten - this is well done, but I thought I added some thoughts to improve your code.
src/Hl7.Fhir.Shims.Base/Specification/Terminology/CodeSystemFilterProcessor.cs
Outdated
Show resolved
Hide resolved
src/Hl7.Fhir.Shims.Base/Specification/Terminology/CodeSystemFilterProcessor.cs
Show resolved
Hide resolved
src/Hl7.Fhir.Shims.Base/Specification/Terminology/CodeSystemFilterProcessor.cs
Outdated
Show resolved
Hide resolved
//find all properties that are parents. | ||
var parents = concept.Property | ||
.Where(p => p.Code == SUBSUMEDBYCODE && p.Value is Code && ((Code)p.Value).Value is not null) | ||
.Select(p => ((Code)p.Value).Value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do most of the code in this function with the LINQ GroupBy
function, which returns an ILookup, just what you need here, and probably more efficient.
} | ||
} | ||
|
||
if (concept.Concept is not null && concept.Concept.Any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple places in the code where we need the whole list of the code + its children. Maybe you can make a function "Flatten" that returns an enumerable (with our without the parent itself, I don't know whats best). Then you can write both the filtering and the grouping stuff in this function using that Flatten.
I pushed a commit showing what I meant with some changes to the code filter extensions. Don't pull them if you want to try it our yourself first ;-) |
src/Hl7.Fhir.Shims.Base/Specification/Terminology/CodeSystemFilterProcessor.cs
Outdated
Show resolved
Hide resolved
var codeSystem = await settings.ValueSetSource.AsAsync().FindCodeSystemAsync(codeSystemUri).ConfigureAwait(false) | ||
?? throw new CodeSystemUnknownException($"Cannot find codesystem '{codeSystemUri}', so the defined filter(s) cannot be applied."); | ||
|
||
if (codeSystem.Content.GetLiteral() != "complete") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (codeSystem.Content.GetLiteral() != "complete") | |
if (codeSystem.Content != CodeSystemContentMode.Complete) |
fixes #2727 #2728