Error in EHRbase when using feeder_audit within DV_TEXT element

Our application provides the user with the option to format some freetext fields, currently the formatting is done with RTF. @ian.mcnicoll 's feedback was that DV_TEXT/value should be as human-readable and accessible as possible, and since raw RTF is very much not human-readable, to store the raw, unformatted text in /value and the original formatted RTF text using feeder_audit/original_content.

We tried this out now, using a basic composition where a feeder_audit object is added to a DV_TEXT ELEMENT. The composition is attached here: feeder_audit_composition.json (9.6 KB). The relevant feeder_audit object is in lines 265-276.

This composition is valid for the Better Sandbox, POSTing and GETing works as expected. However, EHRbase behaves differently. POSTing works (204 Response), but GETing the posted composition yields this rather cryptic 400 error:
{"error": "Bad Request", "message": "parent already has child f (DbJsonPath{path=c0.d.e0.d.i1.f.})"}

Trying to fetch the composition via AQL yields a 500 error:
SELECT n FROM EHR e CONTAINS COMPOSITION n WHERE e/ehr_id/value = '40e18a64-f0ed-4d17-b26c-f3e142264246' AND n/uid/value = '7599e97d-0a83-426b-843a-76e46d926d24'

Error executing AQL query: [500 Internal Server Error] during [POST] to [https://sandbox.ehrbase.org/ehrbase/rest/openehr/v1/query/aql] [QueryExecuteClient#executeAdHocQuery(AdhocQueryExecute)]: [{"error":"Internal Server Error","message":"An internal error has occurred. Please contact your administrator."}]

We attempted this on a local EHRbase CDR as well as the EHRbase Sandbox, with identical results, so we are reasonably sure that this is a bug rather than a mistake on our side.
We tried to submit an empty feeder_audit/original_content to see if the problem was the RTF string itself, but the composition was only GETable with a complete removal of the feeder_audit object.

Please note that the feeder_audit object has to be within an ELEMENT object (same level as value). A top-level feeder_audit object works fine, but is insufficient for our use case.

My questions to the community would be:

  1. Did we make a mistake, or can you replicate this error?
  2. Can you make sense of the error messages? Do you know this issue, and have suggestions how to fix it?
  3. Do you have other suggestions how to store formatted text together with easily readable raw text?

Hi @HHeiser,

thanks for raising this issue, this points to an error while trying to save the data in Postgres. Might be a missed regression after introducing the new AQL engine. Maybe @vidi42 can also take a look.

1 Like

Thanks for answering!
I can also open an issue on the ehrbase github if it helps?

@HHeiser yes, please open a GitHub issue and we will follow-up on it there. And please include the OPT as well.

1 Like

Done: Error when using feeder_audit within DV_TEXT element · Issue #1501 · ehrbase/ehrbase · GitHub

1 Like