Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect shall have a contained resource if a local reference is provided #2941

Open
mmsmits opened this issue Oct 22, 2024 — with Slack · 4 comments
Open

Incorrect shall have a contained resource if a local reference is provided #2941

mmsmits opened this issue Oct 22, 2024 — with Slack · 4 comments

Comments

Copy link
Member

mmsmits commented Oct 22, 2024

I have a situation which I don't fully understand with validation.

Example : https://simplifier.net/erezept-workflow/fsh-generated-resources-Parameters-ExampleCloseInputParametersRezeptur/~overview
Base profile: https://simplifier.net/erezept-workflow/gem_erp_pr_par_closeoperation_input

The legacy validator returns this:

Invariant : Instance failed constraint ref-1 "SHALL have a contained resource if a local reference is provided"
Rule: reference.exists() implies (reference.startsWith('#').not() or (reference.substring(1).trace('url') in %rootResource.contained.id.trace('ids')) or (reference='#' and %rootResource!=%resource))
Parameters.parameter[0].part[1].resource[0].ingredient[0].item[0] 

The new validator returns this similar error, but with different explanation:

[ERROR] Instance failed constraint ref-1 "SHALL have a contained resource if a local reference is provided" (at Parameters.parameter[0].part[0].resource[0].performer[0].actor[0], element Parameters(https://gematik.de/fhir/erp/StructureDefinition/GEM_ERP_PR_PAR_CloseOperation_Input).parameter.part.resource->MedicationDispense.performer.actor) 

ref-1 (https://hl7.org/fhir/references.html#Reference) states:

reference.exists() implies (reference.startsWith('#').not() or (reference.substring(1).trace('url') in %rootResource.contained.id.trace('ids')) or (reference='#' and %rootResource!=%resource)) 

Does calling %rootResource cause our Validator to jump to the Parameters Resource, and should it not go towards the Medication Resource?
Is this the part that is causing the issue?

reference.substring(1).trace('url') in %rootResource.contained.id.trace('ids')

What it does is it checks whether the ID of the referenced contained resource exists within the parent resource's contained resource IDs.
The Java Validator does not throw an error here.

Ghost-writer of @MatthijsvdWielen

@mmsmits mmsmits added the needs research label Oct 22, 2024 — with Slack
@MatthijsvdWielen
Copy link

Thank you @mmsmits for being my Ghost-writer. I was unable to verify if this was already fixed in v2.5.0 of the new validator.

@mmsmits
Copy link
Member Author

mmsmits commented Oct 22, 2024

Yes, that's ok, we'll check that. :)

@mmsmits
Copy link
Member Author

mmsmits commented Oct 24, 2024

This is a duplicate of #FirelyTeam/firely-validator-api#384

@mmsmits
Copy link
Member Author

mmsmits commented Oct 24, 2024

@Kasdejong, this error was introduced after your work on contained resources I believe.

Short story:
It occurs on reference, that only have an identifier set. The validator sees this as a local reference, and tries to find a contained resource, but the reference.reference is not set, so it returns null (I think). and throws this error. Probably easy to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants