Missing type id property '_type' Error in Ehrbase

I am trying to post a composition to ehrbase server but I keep getting this error :


I am not able to detect what the problem is exactly

Hey @Yash! Can you post more details, like what composition (+ its template) you are posting, what version of EHRbase you are using and how you are running it?

Sure , all the files are at this link
Open EHR – Google Drive

I am using the docker image for running ehrbase

the Ehebase image I am running is : ehrbase/ehrbase:0.16.4

Hi,

the compositions are not following the canonical format. The instances should look similar to this (take note the differences regarding @xsi:type etc.):

"content": [

    {

      "_type": "OBSERVATION",

      "name": {

        "_type": "DV_TEXT",

        "value": "Murray-Score"

      },

      "archetype_details": {

        "_type": "ARCHETYPED",

        "archetype_id": {

          "_type": "ARCHETYPE_ID",

          "value": "openEHR-EHR-OBSERVATION.murray_score.v0"

        },

        "rm_version": "1.0.4"

      },

      "archetype_node_id": "openEHR-EHR-OBSERVATION.murray_score.v0",

      "language": {

        "_type": "CODE_PHRASE",

        "terminology_id": {

          "_type": "TERMINOLOGY_ID",

          "value": "ISO_639-1"

        },

        "code_string": "de"

      },

      "encoding": {

        "_type": "CODE_PHRASE",

        "terminology_id": {

          "_type": "TERMINOLOGY_ID",

          "value": "IANA_character-sets"

        },

        "code_string": "UTF-8"

      },

      "subject": {

        "_type": "PARTY_SELF"

      },

      "data": {

        "_type": "HISTORY",

        "name": {

          "_type": "DV_TEXT",

          "value": "Event Series"

        },

        "archetype_node_id": "at0001",

        "origin": {

          "_type": "DV_DATE_TIME",

          "value": "2021-08-05T06:24:01.182227+02:00"

        },

        "events": [

          {

            "_type": "POINT_EVENT",

            "name": {

              "_type": "DV_TEXT",

              "value": "Beliebiges Ereignis"

            },

            "archetype_node_id": "at0002",

            "time": {

              "_type": "DV_DATE_TIME",

              "value": "2021-08-05T06:24:01.182227+02:00"

            },

            "data": {

              "_type": "ITEM_TREE",

              "name": {

                "_type": "DV_TEXT",

                "value": "Tree"

              },

              "archetype_node_id": "at0003",

              "items": [

                {

                  "_type": "ELEMENT",

                  "name": {

                    "_type": "DV_TEXT",

                    "value": "Röntgenbefund der Lunge"

                  },

                  "archetype_node_id": "at0004",

                  "value": {

                    "_type": "DV_ORDINAL",

                    "value": 4,

                    "symbol": {

                      "_type": "DV_CODED_TEXT",

                      "value": "4 Quadranten",

                      "defining_code": {

                        "_type": "CODE_PHRASE",

                        "terminology_id": {

                          "_type": "TERMINOLOGY_ID",

                          "value": "local"

                        },

                        "code_string": "at0011"

                      }

                    }

                  }

                },

                {

                  "_type": "ELEMENT",

                  "name": {

                    "_type": "DV_TEXT",

                    "value": "Oxygenierungsindex (PaO₂/FiO₂)"

                  },

                  "archetype_node_id": "at0012",

                  "value": {

                    "_type": "DV_ORDINAL",

                    "value": 3,

                    "symbol": {

                      "_type": "DV_CODED_TEXT",

                      "value": "100-174 mmHg",

                      "defining_code": {

                        "_type": "CODE_PHRASE",

                        "terminology_id": {

                          "_type": "TERMINOLOGY_ID",

                          "value": "local"

                        },

                        "code_string": "at0017"

                      }

                    }

                  }

                },

I agree with Birger, the JSON is not canonical. That looks like the format generated from GitHub - ppazos/openEHR-OPT: Java/Groovy Support of openEHR Operational Templates, Refernce Model, Dat that is accepted by EHRServer but not by EHRBASE, which is generating an XML COMPOSITION then doing a simple transformation to JSON.

If you are using the openEHR-OPT to generate that format, you might want to take a look at the latest master which has also canonical JSON generation.

Thank You for your responses , I understand that my composition does not follow the standard so how do I convert my template to a composition file that is accepted by the ehrbase server.
Also what are flat forms and how can i use them ?

For the standard form, there is JSON Schema available that describes the format at specifications-ITS-JSON/components/RM/RM-1.1.0 at master · nedap/specifications-ITS-JSON · GitHub</t . Note that this is a fork of the openehr-one, because the openehr-based repo currently is not in a fully usable state.

Flat form is a list of paths with their values, that can be converted to a structured object, such as you constructed. It can be easier to work with for people who work with custom UIs, but do not feel the need to construct full RM-compositions. There are several flat form variants out there. If you use java, there is the FlatJsonGenerator in Archie that can generate it, in several instances. I don’t know which format is supported by EHRBase, they should have documentation available on that.

To get some examples, you can install visual studio code, read an archetype, install the extension when prompted, convert to ADL 2, then right click → source actions → generate example (json) or generate example (flat json). The node ids in the data will be different because of the differences in ADL 1.4 and ADL 2, but it should give an example of both the flat format and the full format. Note that this extension does not yet work with OPT 1.4 files, but it does work with 1.4 source archetypes. OPT 1.4 → OPT 2 conversion will be added soon.

1 Like

Hey @pieterbos! That’s really cool. I’m doing research on all the possible ways to create an openEHR composition for my next video.

I’d like to know if it’s possible to get an example composition (in canonical JSON/flat) for a template using any method using this VSCode extension after creating a template using the Archetype Designer.

Not yet! it is possible to generate examples from .adl files form archetype designer, both the ADL 2 and ADL 1.4 files from that should work, but not yet with opt 1.4 . Work to do that is in progress though.

That needs something to parse and convert OPT 1.4 files. The code to convert an OPT 1.4 to ADL 2/OPT 2 is now mostly done, and available at Opt 1.4 parser and converter by pieterbos · Pull Request #261 · openEHR/archie · GitHub . After I get a review from a co-worker and process it, we will release a new Archie version and it will be integrated it into the visual studio code extension. Then it will be possible, at least after a conversion to OPT 2. Again, node ids will be different, at being converted to id and the numbers will have one added to it, but the structure will be the same. Might even be possible to generate the example without a node id difference, I need to experiment with that a bit. so, that will take a bit more time.