FirelyTeam / firely-validator-api

Firely's official FHIR validator API for validating HL7 FHIR resources against profiles.
Other
7 stars 2 forks source link

Enhance new validator w.r.t. circular references #286

Open LuudSlagter opened 6 months ago

LuudSlagter commented 6 months ago

In the new validator, circular references result in a validation warning of the form:

[WARNING] Detected a loop: instance data inside 'Bundle.entry[1].resource[0]' refers back to itself. (at Bundle.entry[1].resource[0])

It would be a nice enhancement to indicate the exact elements that together contain the circular reference, or at least indicate the element containing the reference in the resource that triggered the validation warning.

Example Suppose a Bundle contains a Condition and Encounter resource that reference each other via Condition.encounter and Encounter.diagnosis.condition. Then a validation warning of the form

[WARNING] Detected a loop: instance data inside 'Bundle.entry[1].resource[0]' refers back to itself. (at Bundle.entry[1].resource[0].encounter and Bundle.entry[2].resource[0].diagnosis[0].condition)

would be ideal, but a validation warning of the form

[WARNING] Detected a loop: instance data inside 'Bundle.entry[1].resource[0]' refers back to itself. (at Bundle.entry[1].resource[0].encounter)

would already be helpful to easily find the circular reference.

mmsmits commented 6 months ago

Transferred from SDK to Validator repo