FHIR Chat · Parser and FHIR rules · hapi

Stream: hapi

Topic: Parser and FHIR rules


view this post on Zulip Patrick Werner (Feb 16 2022 at 13:20):

I just serialized a resource having a contained resource having the narrative (.text) populated. This is not allowed by the FHIR standard, and hapi strips it.

I totally understand, that hapi tries to prevent miss-use of FHIR, but i think a parser/encoder shouldn't enforce "business logic", or at least has a parameter/config to disable this guidance.

view this post on Zulip Brian Kaney (Feb 16 2022 at 13:48):

I actually didn't realize is was not allowed to prescribe the narrative.. I assume this is only if the status is generated?

view this post on Zulip Patrick Werner (Feb 16 2022 at 16:20):

you are right. It is only relevant during narrative rendering/generation. It was a rule back in STU1/2

view this post on Zulip Patrick Werner (Feb 16 2022 at 16:20):

This was already reported to hapi: https://github.com/hapifhir/hapi-fhir/issues/1466

view this post on Zulip Patrick Werner (Feb 16 2022 at 17:21):

I think we need to revert the changes made here: https://github.com/hapifhir/hapi-fhir/commit/287162af914231aa5d994813de9a4d1ea64f0196

view this post on Zulip Patrick Werner (Feb 16 2022 at 17:24):

Will create a PR (probably tomorrow)

view this post on Zulip Patrick Werner (Feb 16 2022 at 23:19):

fix is ready, will fix the broken tests tomorrow

view this post on Zulip Patrick Werner (Feb 17 2022 at 09:42):

https://github.com/hapifhir/hapi-fhir/pull/3402

view this post on Zulip Patrick Werner (Feb 17 2022 at 09:43):

@James Agnew who should i mark for a review on the PR?

view this post on Zulip James Agnew (Feb 17 2022 at 16:08):

I just did a quick scan, and I can't even find the rule forbidding narratives in contained resources in R4... Does it still exist?

view this post on Zulip Patrick Werner (Feb 17 2022 at 16:10):

Yes, the parsers are skipping encoding narratives. My PR removes the code and also changes the unit tests affected by the change.

view this post on Zulip Patrick Werner (Feb 17 2022 at 16:10):

Ah, you meant the spec :smiley:

view this post on Zulip James Agnew (Feb 17 2022 at 16:10):

heh yeah

If it's still a rule, I will say this kind of change makes me at least a bit nervous. I get your point about a parser shouldn't be enforcing business rules, but the counter argument is that if the library lets you do it people will assume it's ok and use it.. and then there may be safety issues since the consumers could miss the existence of that data.

view this post on Zulip James Agnew (Feb 17 2022 at 16:11):

We could make that configurable though in the ParserOptions

view this post on Zulip James Agnew (Feb 17 2022 at 16:11):

Or if it's not even a rule anymore we should definitely not enforce it

view this post on Zulip Patrick Werner (Feb 17 2022 at 16:12):

this was only a rule in STU1 iirc.. will double check on this

view this post on Zulip James Agnew (Feb 17 2022 at 16:13):

Looks like it's gone. I found it in DSTU1: https://www.hl7.org/fhir/DSTU1/narrative.html

Note that contained Resources SHALL NOT have a narrative of their own.

view this post on Zulip James Agnew (Feb 17 2022 at 16:13):

But it's not in R4 on that page

view this post on Zulip James Agnew (Feb 17 2022 at 16:14):

I've approved the PR - Please add a changelog though before you merge :)

view this post on Zulip Patrick Werner (Feb 17 2022 at 16:16):

thanks. I added a change yml file, do i have to provide the change at another location as well?

view this post on Zulip Patrick Werner (Feb 17 2022 at 17:22):

checked other PRs. I think i'm good: https://github.com/hapifhir/hapi-fhir/blob/9f2af9747fbd600c78acd0955554515cdf0394b9/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_0_0/1466-encode-narratives-of-encoded-resources.yaml

view this post on Zulip James Agnew (Feb 17 2022 at 18:22):

that's awesome, thanks!

view this post on Zulip Patrick Werner (Feb 17 2022 at 19:29):

Thanks for the quick review. :tada:


Last updated: Apr 12 2022 at 19:14 UTC