How convert tag xml in PATH?

How to convert XML tags to a path corresponding to the template?

Example - <laboratory_result>

FOR

[Archetype ID]/magnitude/value

Java language

Are you trying to read an xml composition into a CDR , or construct a new Composition, based on a template?

For (2) My usual approach (if I have a Better CDR available) is to use the Ehrscape GET /template/example to generate a FLAT or STRUCTURED JSON composition object - , Post that to the CDR then retrieve the composition via GET/ composition as XML - that gives me an ‘example’ XML composition.

In the company where I am, they are keeping the information from open ehr in their own database,
what happens is that client applications send the path of open ehr

thus
[archetype] / magnitude / value

Fixed

I want this to become dynamic so that I don’t have to change the code, is there a library that transforms the TAG by a path corresponding to your template?

THanks Luiz,

I’m still not exactly sure of the challenge here.

Can you send an actual snippet of some source data and a clearer idea of the target data format you want to hit?

Maybe someone else has a clearer picture but I’m struggling to understand, I’m afraid.

Example composition
Exame_OPEN_EHR_sem_unidade_de_medida.xml (10.4 KB) XML

example format Json

{
“[openEHR-EHR-COMPOSITION.encounter.v1]/content[openEHR-EHR-SECTION.adhoc.v1]/items[openEHR-EHR-OBSERVATION.image_capture.v0]/data[at0001]/events[at0002]:0/data[at0003]/items[at0004]/value/alternate_text” : “1edb3663-e39a-485f-bbfb-858e81dee85d.JPG”
}

Transform TAG XML in a path [openEHR-EHR-COMPOSITION.encounter.v1]/content[openEHR-EHR-SECTION.adhoc.v1]/items[openEHR-EHR-OBSERVATION.story.v1]/data[at0001]/events[at0002]:0/time

An automated mapping from path to tag is possible, and is being standardised - but the team at Better (maybe @borut.fabjan, @matijap might elaborate) and other companies have built various forms of this. The output artefact of this may differ, but is being standardised (see here).

Going the other way (tag -> path) means having that artefact available at runtime so as to look up the tags or simplified paths to get the original full paths.

Thanks Thomas! :blush:
So this will have to be implemented, as there is still no library for this?

THanks Luiz,

I get it now!!

You should explore the EhrBase SDK as this is getting very close to what you need. Your input is canonical xml and the output looks like the Ethercis ‘FLAT JSON’ format.

The work that Ehrbase are doing to support the Better web template format and associated FLAT JSON formats is directly connected. @birger.haarbrandt

I will explore, Thank you very much for your attention !!

:heart:

@luiz_Minelli
The sdk provides general tools in from of abstract classes to implement mappings from and to Composition:

  org.ehrbase.serialisation.walker.FromCompositionWalker
  org.ehrbase.serialisation.walker.ToCompositionWalker

Those a used to implement for example the flat format:

org.ehrbase.serialisation.flatencoding.std.marshal.StdFromCompositionWalker
org.ehrbase.serialisation.flatencoding.std.umarshal.StdToCompositionWalker

So you could use those to implement what you want.

1 Like

To add to this: this transformation will not work out of the box at the moment but can be implemented with reasonable effort based on the SDK. This being said, we welcome PRs :wink:

EtherCIS Flat is on the roadmap but I’m sure we will not be able to tackle this one until Q3 2021.

1 Like

I will try to implement, thank you again for your attention !!

the Forum has helped me a lot!

<3