firely-net-sdk
firely-net-sdk copied to clipboard
Allow validator to validate only against Core Specification
Is your feature request related to a problem? Please describe.
The Validate-Extension (Hl7.Fhir.Model on Base) on Resource doesn't give a proper validation message. Only an exception is thrown on the first invalid field. If there are more invalidities you won't know.
The Validator (from Hl7.Fhir.Validation in Hl7.Fhir.Specification.R4 package) has no settings to only validate against the core specifications. Profiles are checked always. It would be helpful to have a setting not to follow profiles or do a validation ONLY against the core specification.
The Validator has the better Outcome-Messaging, but it is also not very helpful that it gives errors, when extension urls cannot be resolved, which is already adressed in [#2105 ]
Describe the solution you'd like Possibilty to use the Validator against core specifications ONLY
Describe alternatives you've considered
Better and full outcome messaging of "validate"-extension-method on Resource
The current attribute validator indeed at the first error - as far as I know this is the behaviour of the underlying .NET attribute validation that I cannot change.
However, we have a new set of parsers for FHIR data that integrate these validation rules while it is parsing and it will continue parsing & returns a collection of all errors found.
You can read more about that here: https://docs.fire.ly/projects/Firely-NET-SDK/parsing/system-text-json-deserialization.html
Thank you for your answer. I created Fhir-Resources as ElementNode. And then wanted to validate its structure in context of fhir core specifications. Is there a more elegant way than serializing and deserializing?
Ah, I see, there are actually multiple things going on in this issue.
At first I was a bit confused, since you said "Better and full outcome messaging of "validate"-extension-method on Resource", I was assuming you are working with POCOs. If you are only using ElementNode, then there is no need to use POCO attribute based validations - only full profile validation is available, and that (as you described) reports all errors in the OperationOutcome.
But I now understand this is not about POCO's and the major thing requested in this issue is:
Possibilty to use the Validator against core specifications ONLY
Correct?
Yes, unfortunateIy I was not able to use the validator to ONLY validate for the core specification on my ElementNode object, though it has much better Outcome messaging.
So my (not very optimal) workaround was to call ElementNode.ToPoco() and to take that resulting Base-Resource and call the .Validate-Extension on it, what only validates the attributes on the POCO classes (and throws an exception on first hit)