FHIR Chat · Different behavior of validator and FhirPath.js tool · fhirpath

Stream: fhirpath

Topic: Different behavior of validator and FhirPath.js tool


view this post on Zulip Kailash (Apr 16 2021 at 10:20):

I have implemented FhirPath expression "Consent.except.actor.distinct().subsetOf(Consent.actor)" for consent profile means consent.except.actor should be subset of consent.actor, this expression giving true output when testing with consent instance using fhirpath.js(https://github.com/HL7/fhirpath.js) build tool, but same instance is failing validation while validating using HL7 Java validatorwith with 1 error -
"Error @ Consent (line 1, col38) : Consent-1: 'consent.except.actor should be subset of consent.actor' failed".
I am not sure if distinct() and subsetOf() FhirPath functions are supported by java validator? Where I can find documentation of java validator to know what all FhirPath features are supported/not supported?

view this post on Zulip Grahame Grieve (Apr 20 2021 at 04:14):

The code is here: https://github.com/hapifhir/org.hl7.fhir.core/blob/master/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java. The tests are here: https://github.com/FHIR/fhir-test-cases/blob/master/r5/fhirpath/tests-fhir-r5.xml

And yes, R5 is what the validator uses internally

view this post on Zulip Kailash (Apr 20 2021 at 16:34):

Thank you for reply, just one doubt, I am using FHIR STU3 version, can I expect the validator to support all Fhirpath features that are supported for r5 ? I saw no different in FhirPath spec across FHIR versions.

view this post on Zulip Grahame Grieve (Apr 20 2021 at 20:42):

the validator uses R5 code internally, irrespective of the version it is validating

view this post on Zulip Kailash (Jun 02 2021 at 10:31):

Hello All, This is similar to my previous post on FHIRPath validation,
I have a constraint on consent resource(STU3) at root level and FHIRPath expresiion is:-
Expression: Consent.actor.supersetOf(Consent.except.actor.distinct())
Severity: error

Below is snippet from consent instance where actor list is not superset of exept.actor list as except.actor.reference is not part of actor list and should return a error -
{
"resourceType": "Consent",
"meta": {
"profile": [
"https://www.example.com/StructureDefinition/ConsentProfile"
]
},
"status": "active",
"patient": {
"reference": "Patient/55"
},
"actor": [
{
"role": {
"coding": [
{
"system": "http://hl7.org/fhir/v3/RoleClass",
"code": "PAT"
}
]
},
"reference": {
"reference": "Patient/12345"
}
}
],
"policyRule": "http://hl7.org/fhir/ConsentPolicy/opt-in",
"except": [
{
"type": "deny",
"actor": [
{
"role": {
"coding": [
{
"system": "http://hl7.org/fhir/v3/RoleClass",
"code": "PAT"
}
]
},
"reference": {
"reference": "Patient/9999"
}
}
]
}
]
}

I am expecting this instance to be failed while its getting pass with 0 error using cli validator 5.4.2
I am not sure if the issue is with Validator or something else? When testing the same instance and expression using javascript.js tool its giving expected result(false).

view this post on Zulip Lloyd McKenzie (Jun 02 2021 at 13:31):

@Grahame Grieve @Bryn Rhodes

view this post on Zulip Grahame Grieve (Jun 02 2021 at 18:14):

what are you actually trying to achieve? what is a super set in this context?

view this post on Zulip Kailash (Jun 03 2021 at 03:45):

want to validate that consent.actor[1..] is superset of consent.exept[0..].actor[0..*] or in other way consent.exept.actor is subset of consent.actor

view this post on Zulip Grahame Grieve (Jun 03 2021 at 04:11):

but what makes them a superset? they're not the same objects

view this post on Zulip Kailash (Jun 03 2021 at 05:18):

Yes, they are not same objects in the given instance but still validator passing the given FHIRPath expression and no error. I am expecting validation to be failed but its not.

view this post on Zulip Grahame Grieve (Jun 03 2021 at 22:05):

well, the problem might not be in the fhirpath itself. Please provide a zip and a set of parameters for the validator that reproduces the issue

view this post on Zulip Kailash (Jun 07 2021 at 10:58):

@Grahame Grieve , Thank you for response, I am attaching Profile having discussed FhirPath expression, Valid and Invalid instances and validation result for both instances against the profile. FHIRPathIssue.zip

view this post on Zulip David Simons (Jun 07 2021 at 11:20):

(working on this with @Kailash )

I think @Grahame Grieve 's point is that you are looking to compare Objects in different sets, for which superSet may be inappropriate?

one set is the consent.actor[] ; another set is the consent.except[].actor[]
but the superSet/Equals comparison should not be by Object reference, but by looking whether their attributes are equal.

what we want to ensure is that each individual entry in consent.except[].actor[] _equals_ an entry of consent.actor[]

view this post on Zulip David Simons (Jun 17 2021 at 14:57):

This is an example that must throw an error, based on the profile conformance claim being validated, given the actor mismatch:
Which FHIRPath expression to achieve this with, it our puzzle:

 <Consent xmlns="http://hl7.org/fhir">
    <id value="test-ConsentConsumer"/>
    <meta>
        <profile value="ConsentConsumer" />
    </meta>
    <status value="active"/>
    <category>
        <coding>
            <system value="http://loinc.org"/>
            <code value="59284-0"/>
        </coding>
    </category>
    <patient>
        <reference value="Patient/test-Patient"/>
    </patient>
    <actor>                                                          **Consent.actor[]**
        <role>
            <coding>
                <system value="http://hl7.org/fhir/v3/RoleClass"/>
                <code value="PAT"/>
            </coding>
        </role>
        <reference>
            <reference value="Patient/test-Patient"/>
        </reference>
    </actor>
    <action>
        <coding>
            <system value="http://hl7.org/fhir/consentaction"/>
            <code value="access"/>
        </coding>
    </action>
    <policyRule value="http://hl7.org/fhir/ConsentPolicy/opt-in"/>
    <except>
        <type value="deny"/>
        <actor>                                                        **Consent.except[].actor[]**
            <role>
                <coding>
                    <system value="http://hl7.org/fhir/v3/ParticipationType"/>
                    <code value="CST"/>
                </coding>
            </role>
            <reference>
                <reference value="Organization/test-Organization"/>
            </reference>
        </actor>
        <action>
            <coding>
                <system value="http://hl7.org/fhir/consentaction"/>
                <code value="access"/>
            </coding>
        </action>
        <securityLabel>
            <system value="http://hl7.org/fhir/v3/ActCode"/>
            <code value="NOPAT"/>
        </securityLabel>
    </except>
</Consent>

view this post on Zulip Bryn Rhodes (Jun 17 2021 at 17:27):

consent.except.actor.exclude(consent.actor).exists().not() should do it

view this post on Zulip David Simons (Jun 18 2021 at 12:04):

Bryn Rhodes said:

consent.except.actor.exclude(consent.actor).exists().not() should do it

Thank you - I was hopeful but unfortunately that also does not work as expected...

view this post on Zulip Grahame Grieve (Jun 18 2021 at 12:53):

because the consent actors are distinct objects from the consent.except.actor. You'll have to say how you're comparing them somehow

view this post on Zulip David Simons (Jun 18 2021 at 13:09):

Grahame Grieve said:

because the consent actors are distinct objects from the consent.except.actor. You'll have to say how you're comparing them somehow

thanks will need to figure that out - I think you are hinting at implementing more granular and individual element comparisons of their role and references, separately (in STU3 at least)

view this post on Zulip Bryn Rhodes (Jun 18 2021 at 15:57):

@Grahame Grieve , are you saying that the FHIRPath implementation uses reference comparison for equality between objects?

view this post on Zulip Grahame Grieve (Jun 18 2021 at 21:53):

well, I think in classic terms, it uses identity. I don't think we've said anything about that?

view this post on Zulip David Simons (Jun 21 2021 at 09:40):

I was assuming Equality/Equivalence

http://hl7.org/fhirpath/#equality
"For complex types, equality requires all child properties to be equal, recursively."

and I think we're running into: "Note that this implies that if the collections have a different number of items to compare, the result will be false."

https://www.hl7.org/fhir/fhirpath.html#changes
image.png


Last updated: Apr 12 2022 at 19:14 UTC