FHIR Chat · Need help with invariant on extensions · conformance

Stream: conformance

Topic: Need help with invariant on extensions


view this post on Zulip Simone Heckmann (May 08 2017 at 16:01):

I created this profile: https://simplifier.net/BasisprofilDE/address-de-basis
It has two extensions on Adress.line: one for the house number and one for the street name
I added a constraint to each which is supposed to test whether the extensions are populated and make sure, that Address.line is also filled.
The point is to prevent implementers from only using the extensions without populating the Adress.line element.

However, this doesn't seem to work:

            <constraint>
                <key value="add-1" />
                <severity value="error" />
                <human value="Wenn die Extension Hausnummer verwendet wird, muss auch die Adress-Zeile gefüllt werden" />
                <expression value="line.extension:Hausnummer.empty() or line.exists()" />
            </constraint>

When I try to validate the example on Simplifier, I get this error:
Evaluation of FhirPath for constraint 'add-1' failed: Compilation failed: Parsing failure: unexpected ':'; expected end of input (Line 1, Column 15); recently consumed: .extension

Location: Organization.address[0]

Apparently my expression is wrong...

view this post on Zulip Marten Smits (May 08 2017 at 16:43):

I think it should be :

line.extension(http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName).empty() or line.exists()

view this post on Zulip Grahame Grieve (May 08 2017 at 17:16):

line.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName').empty() or line.exists()

view this post on Zulip Simone Heckmann (May 09 2017 at 08:25):

Thank you! That helped!
I think the FHIRPath documentation could need an example for this...
I had trouble finding hints at http://hl7.org/fhirpath/ about how to deal with extensions like this.

view this post on Zulip Marten Smits (May 09 2017 at 08:34):

I agree, that documentation page needs some love. Happy to help with that!

view this post on Zulip Grahame Grieve (May 09 2017 at 08:41):

you can create tasks for FHIRPath in gForge

view this post on Zulip Simone Heckmann (May 09 2017 at 08:50):

GF#13350

view this post on Zulip Simone Heckmann (May 09 2017 at 08:50):

BTW: Gforge still lists only "fluentpath" in the HTML Page(s) box

view this post on Zulip Grahame Grieve (May 09 2017 at 09:22):

@Lloyd McKenzie please rename fluentpath to fhirpath

view this post on Zulip Lloyd McKenzie (May 09 2017 at 12:15):

Done

view this post on Zulip Simone Heckmann (Jun 28 2017 at 21:47):

About this:

line.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName').empty() or line.exists()

does line.exists() return true if it's value is empty but it has extensions?
The invariant doesn't seem to work (at least not on simplifier, currently)

view this post on Zulip Grahame Grieve (Jun 29 2017 at 06:20):

yes. Looks like it needs .hasValue()

view this post on Zulip Grahame Grieve (Jun 29 2017 at 06:20):

not .exists()

view this post on Zulip Stefan Lang (Jun 29 2017 at 07:57):

Sounds obvious, when you don't stumble upon such things around midnight :joy:
I also just confirmed it's not a Simplifier issue; same behaviour for the official validator.

view this post on Zulip Simone Heckmann (Jun 29 2017 at 08:48):

Can anyone explain, why this example

<Patient>
    <meta>
        <profile value="http://fhir.de/StructureDefinition/patient-de-basis" />
    </meta>
    <identifier>
        <system value="http://fhir.de/NamingSystem/gkv/kvid-10" />
        <value value="G995030567" />
    </identifier>
    <name>
        <family value="Mustermann" />
        <given value="Max" />
    </name>
    <address>
        <line>
            <extension url="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName">
                <valueString value="Testwegs" />
            </extension>
        </line>
    </address>
</Patient>

https://simplifier.net/LHITCSandbox/Patient-example345/~xml
successfully validates against this Patient profile
https://simplifier.net/BasisprofilDE/patient-de-basis
which references this Address profile
https://simplifier.net/BasisprofilDE/address-de-basis
which has this constraint on the streetname-extension:
line.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName').empty() or line.hasValue())

What we're trying to accomplish here is to enforce that the address.line value is populated, whenever one of the line-extensions is populated

view this post on Zulip Simone Heckmann (Jun 29 2017 at 19:41):

Ok, I did two things:
a) I moved the invariants from the extensions to the Address. I assume the FHIR-Path expressions are always relative to the node to which they are assigned? In that case of course the expression couldn't be evaluated, as the extensions themselves don't have a line attribute
b) opened and saved the patient profile in forge and re- commited it to simplifier
I didn't realize, the address profile is embedded in the snapshot of the patient profile!
I thought that was a reference that's evaluated at runtime during validation. But apparently not.

Anyway: it's working now!

view this post on Zulip Ewout Kramer (Jun 30 2017 at 11:19):

"I didn't realize, the address profile is embedded in the snapshot of the patient profile!"

Yes, if a differential adds a constraint on an element that is a datatype (in this case of type Address), the node will be expanded into the profile, to be able to express that constraint. All non-changed properties of the datatype will then also be copied into the snapshot....

view this post on Zulip Simone Heckmann (Jun 30 2017 at 11:56):

Makes sense. It's a bit tricky on Simplifier though, to maintain consistency among the profiles, as we have to maually recreate all dependent snapshots with Forge and reupload them, when changing the profile of a datatype.

view this post on Zulip Ewout Kramer (Jun 30 2017 at 13:59):

Would a console-type app help that you could run over all profiles?

view this post on Zulip Ewout Kramer (Jun 30 2017 at 14:00):

This is of course the classic case where a dependency changes, and we need to update all the snapshots. I don't think this should be done automatically - the author of the referring SD might want to decide for him/herself when to do this....

view this post on Zulip Simone Heckmann (Jul 01 2017 at 07:34):

I think the best thing would be to have a button at the profile page in simplifier to rebuild the snapshot and one on the project page to rebuild all snapshots (once simplifier is able to create snapshots...)
Until then a console app that goes through the contents of a folder and recreates all the snapshots would be a nice workaround.

view this post on Zulip Stefan Lang (Jul 01 2017 at 17:05):

Doesn't the official IG publisher do that?

view this post on Zulip Grahame Grieve (Jul 03 2017 at 04:17):

yes the IG Publisher regenerates all the snapshots. But you might not be using that

view this post on Zulip Martijn Harthoorn (Jul 05 2017 at 07:57):

@Simone Heckmann "a button at the profile page" -- we are working on that right now.


Last updated: Apr 12 2022 at 19:14 UTC