LHNCBC / formbuilder-lhcforms

Build LHC-Forms and FHIR Questionnaires
Other
28 stars 22 forks source link

Problem with complex extension, the inner extension is lost from the model #72

Closed ghaliouss closed 9 months ago

ghaliouss commented 10 months ago

Hello, We have a problem when importing a questionnaire that contains complex extension. The data is lost and the inner extension is deleted from the model when we try to preview after clicking the button 'Edit question'

Here the test questionnaire used to reproduce the issue:

issue with complex extension.json

Step to reproduce the issue:

  1. Import questionnaire from local file:

image

  1. Click to the button 'Edit questions'

image

  1. Click to the button 'Preview' and verify the json (the R4 version)

the inner extension is lost in the model, we should have an extension like this: "extension": [ { "url": "https://test.fr/ig/fhir/StructureDefinition/new-extension", "extension": [ { "url": "id", "valueInteger": 1 } ] } ] image

Can you fix this issue please ?

Thanks in advance.

Rosnyni commented 10 months ago

Hello,

I'm working with @ghaliouss.

Just to add that It makes hard for us to add in the formbuilder the launch context extension (for population and data extraction) and some home-made quite complex extensions.

Sincerely

plynchnlm commented 10 months ago

Sorry about that! We are starting work on this problem right away. Fixing it seems to be more complicated than I would have expected, due to the Form Builder's reliance on a FHIR schema file, and for some reason the nested extension is an unknown field. As a general principle, I think the Form Builder should not be dropping anything it doesn't know about. But, there might be a faster fix that allows one level of extension nesting which would solve the immediate problem.

Rosnyni commented 9 months ago

I think the Form Builder should not be dropping anything it doesn't know about.

I think I agree with you.

But, there might be a faster fix that allows one level of extension nesting which would solve the immediate problem.

I can't remember any extension with more than two level. I'm not sure it is possible ?

plynchnlm commented 9 months ago

But, there might be a faster fix that allows one level of extension nesting which would solve the immediate problem.

I can't remember any extension with more than two level. I'm not sure it is possible ?

I had the same question. It is turns out that it is rare, but it does happen. https://chat.fhir.org/#narrow/stream/179166-implementers/topic/extensions.20with.20grandchildren.3F

Rosnyni commented 9 months ago

I take a look at http://hl7.org/fhir/R4/extensibility.html#exchange

And it appears that :

If a system modifies a resource it SHOULD remove any extensions that it does not understand from the modified element and its descendants, because it cannot know whether the modifications it has made might invalidate the value of the unknown extension

So the formbuilder should drop anything it doesn't know about.

akanduru commented 9 months ago

Dropping the extension here is due to the bug, regardless of whether the extension is valid or not. The bug is fixed in 9.2.8.

At the moment, form builder is imposing structural validity to the questionnaire based on fhir.schema.json. We are not really checking for semantic validation errors.

@Rosnyni, I am closing the issue, since the core problem is addressed. Feel free to re-open it if you have more to add.

Rosnyni commented 9 months ago

Thank you