Fix CapabilityStatement conformance for resources#5617
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5617 +/- ##
==========================================
+ Coverage 76.90% 76.93% +0.02%
==========================================
Files 997 997
Lines 36616 36622 +6
Branches 5529 5533 +4
==========================================
+ Hits 28160 28175 +15
+ Misses 7104 7095 -9
Partials 1352 1352 🚀 New features to boost your workflow:
|
| { | ||
| // Remove resource entries with no interactions to ensure FHIR conformance. | ||
| // In STU3, CapabilityStatement.rest.resource.interaction has min cardinality 1, | ||
| // so resources without interactions (e.g. Parameters) must be excluded. |
There was a problem hiding this comment.
@EXPEkesheth this could technically be called a breaking change. I think it is a correct change, and it should be non-impactful as anything removed in this filter would have no request types. What are your thoughts?
| // Remove resource entries with no interactions to ensure FHIR conformance. | ||
| // In STU3, CapabilityStatement.rest.resource.interaction has min cardinality 1, | ||
| // so resources without interactions (e.g. Parameters) must be excluded. | ||
| foreach (var restComponent in _statement.Rest) |
There was a problem hiding this comment.
@v-rachitsh I know this is an external PR, but could you add an if statement here so this only runs if the _modelInfoProvider.Version is Stu3? This isn't an issue in other FHIR versions.
There was a problem hiding this comment.
@LTA-Thinking Wrapped up in if statement as you have suggested
Summary
Fixes #5394. External PR #5473
In STU3,
CapabilityStatement.rest.resource.interactionhas a minimum cardinality of 1 (spec). Resources likeParametersthat are explicitly excluded from interaction population (line 303-307) were still appearing in the resource list with an empty interaction array, causing FHIR-conformant parsers (e.g., Firely SDK 6.x with strict validation) to reject the CapabilityStatement.Changes
CapabilityStatementBuilder.Build(), added a cleanup step that removes resource entries with no interactions before serializationWhy this approach
Rather than modifying how
Parametersis handled specifically, this cleanup catches any resource that ends up with zero interactions — making it robust against future edge cases. The comment explains the STU3 cardinality requirement for maintainability.Related issues
AB#191808
Testing
Describe how this change was tested.
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)