IHE / ITI.MHD

The Mobile access to Health Documents (MHD) Profile defines one standardized interface to health documents for use by mobile devices so that deployment of mobile applications is more consistent and reusable. The transactions defined here leverage the document content- and format-.agnostic metadata
https://profiles.ihe.net/ITI/MHD/index.html
Creative Commons Attribution 4.0 International
9 stars 6 forks source link

Invariant iti-mhd-repl is incomplete #213

Closed JohnMoehrke closed 5 months ago

JohnMoehrke commented 11 months ago

I had to fixup the invariant with a newer IG publisher, but during the fixing of it to make the publisher happy, I came to the realization that the logic was not matching the fhirpath expression. And it was not complete.

today:

Invariant:   iti-mhd-repl
Description: "a DocumetReference replacements needs to relate to a superseded DocumentReference"
Expression:  "code='replaces' implies target.exists()"
Severity:    #error

Yet the invariant should actually be checking deeper. It really says that if the .code is replaces that the .target must point at a DocumentReference that is superceded

relatesTo.target.resolve().status=superseded

but if we had this, we really should be checking that all the others are pointing at current DocumentReference.

relatesTo.target.resolve().status=current

Then, I find out that it is generally not recommended to include resolve() in an invariant.

see zulip chat https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/help.20with.20code.20is

JohnMoehrke commented 11 months ago

is this invariant only intended to be used in an ITI-65 Transaction Bundle?

lukeaduncan commented 11 months ago

is this invariant only intended to be used in an ITI-65 Transaction Bundle?

Based on https://build.fhir.org/ig/IHE/ITI.MHD/ITI-65.html#23654123-replace-transform-signs-and-append-associations I'd agree with what you're suggesting here. It looks like the invariant should be on the bundle. I'm not sure of how you'd do the fhirpath to find the correct entry, but it seems the invariant should be related to the 2 DocumentReference entries in the Bundle instead of on DocumentReference directly.

lukeaduncan commented 11 months ago

I found something so perhaps like this? I haven't done any validation on this, but maybe it's close. I'm not sure we can really rely on the id though.

entry.resource.where(is(DocumentReference) and status = 'superseded').id = entry.resource.where(is(DocumentReference) and relatesTo.code = 'replaces').relatesTo.target.reference.replace('DocumentReference/','')

JohnMoehrke commented 11 months ago

lloyd did give me the right code.. but then said that we should NOT do that.

lukeaduncan commented 9 months ago

Discussed in committee and will resolve by removing the invariant as stated today as it is redundant.

oliveregger commented 9 months ago

@lukeaduncan why is it redundant?

JohnMoehrke commented 9 months ago

Because the fhir core already requires them to be populated