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

Support Is-a filter in local ValueSet expansion #2733

Merged
merged 21 commits into from
Mar 19, 2024

Conversation

mmsmits
Copy link
Member

@mmsmits mmsmits commented Mar 12, 2024

fixes #2727 #2728

Copy link
Member

@ewoutkramer ewoutkramer left a 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.STU3/Model/ValueSetExpansionExtensions.cs Outdated Show resolved Hide resolved
src/Hl7.Fhir.STU3/Model/ValueSetExpansionExtensions.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);
Copy link
Member

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())
Copy link
Member

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.

@ewoutkramer
Copy link
Member

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 ;-)

@ewoutkramer ewoutkramer reopened this Mar 13, 2024
@mmsmits mmsmits enabled auto-merge March 15, 2024 16:10
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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (codeSystem.Content.GetLiteral() != "complete")
if (codeSystem.Content != CodeSystemContentMode.Complete)

@mmsmits mmsmits merged commit ea70fe7 into develop Mar 19, 2024
16 checks passed
@mmsmits mmsmits deleted the 2727-support-is-a-filter-in-local-valueset-expansion branch March 19, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants