Open fongsean opened 1 month ago
Happy to deploy the test app if it helps. Also, it's a React app.
Hi Sean, thanks for reporting this. I didn't expect the QR would be modified. A deep clone should be used at least. In fact the Questionnaire resource is deep cloned when it is loaded to the LHC-Forms widget. I will have it fixed next week.
Hi,
I've been playing around with LHC-Forms to test compatibility with the CSIRO Renderer (and do debugging). It's set up to be like Brian's https://dev.fhirpath-lab.com/Questionnaire/tester.
I've noticed that the
mergeFHIRDataIntoLForms()
function mutates the FHIR QuestionnaireResponse passed into the function. This is how i'm using it:The issue I'm facing is - when I switch between the two renderers without explicitly updating the QR state, any non-first answers of repeating items are removed from the initial FHIR QuestionnaireResponse, which causes those answers to be removed in another renderer.
Attached are two videos performing the following steps:
The first video uses the CSIRO renderer as the main renderer, while the second uses LHC-Forms. In the second video, it still happens even after the CSIRO renderer is removed.
This issue was first brought to me by @brianpos.
https://github.com/user-attachments/assets/24d59b08-d694-4972-aa78-2fe294cf0886
https://github.com/user-attachments/assets/6a6160ca-406d-4226-96ef-8c1df2c3c572
Potential fix:
Performing a deep clone of the FHIR QuestionnaireResponse before executing the function's logic should fix it.
Here's how I workaround it in my app:
Open to any discussion on better/more efficient ways to address it.