Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring and fixes to support correct canonical json representation #201

Merged
merged 1 commit into from
Mar 31, 2020

Conversation

chevalleyc
Copy link
Contributor

Changes

This is to fix several issues when returning canonical json in AQL:

Events

{
  "q": "select o/data[at0001]
	from EHR e
	contains COMPOSITION c
	contains OBSERVATION o[openEHR-EHR-OBSERVATION.minimal.v1]
" 
}

Was:

    "rows": [
        [
            {
                "name": {
                    "value": "Event Series"
                },
                "events": {
                    "events": [
                        {
                            "name": {
                                "value": "Cualquier evento"
                            },
                            "time": {
                                "value": "2019-01-28T21:22:19.562Z",
                                "_type": "DV_DATE_TIME"
                            },

The expression

                "events": {
                    "events": [

is replaced with

                 "events": [

Similar issue when an AQL query return an array

{
  "q": "select o/data[at0001]/events[at0002]
	from EHR e
	contains COMPOSITION c
	contains OBSERVATION o[openEHR-EHR-OBSERVATION.minimal.v1]
" 
}

Was

    "rows": [
        [
            {
                "items": [
                    {
                        "name": {
                            "value": "Cualquier evento"
                        },
                        "time": {
                            "value": "2019-01-28T21:22:19.562Z",
                            "_type": "DV_DATE_TIME"
                        },
                        "_type": "POINT_EVENT",
                        "data": {
                            "archetype_node_id": "at0003",
                            "_type": "ITEM_TREE",
                            "items": [
                                {
                                    "name": {
                                        "value": "text"
                                    },
                                    "value": {
                                        "value": "modified value",
                                        "_type": "DV_TEXT"
                                    },
                                    "_type": "ELEMENT",
                                    "archetype_node_id": "at0004"
                                }
                            ]
                        }
                    }
                ]
            }
        ],

Now:

   "rows": [
        [
           
                    {
                        "name": {
                            "value": "Cualquier evento"
                        },
                        "time": {
                            "value": "2019-01-28T21:22:19.562Z",
                            "_type": "DV_DATE_TIME"
                        },
                        "_type": "POINT_EVENT",
                        "data": {
                            "archetype_node_id": "at0003",
                            "_type": "ITEM_TREE",
                            "items": [
                                {
                                    "name": {
                                        "value": "text"
                                    },
                                    "value": {
                                        "value": "modified value",
                                        "_type": "DV_TEXT"
                                    },
                                    "_type": "ELEMENT",
                                    "archetype_node_id": "at0004"
                                }
                            ]
                        }
                    }
        ],

Several jUnit tests illustrate this translation:

DBEncodeTest::unmarshal_from_js_composition_observation_events()
DBEncodeTest::unmarshal_from_js_composition_observation_events_data()
DBEncodeTest:unmarshal_from_js_events_data_as_array()
DBEncodeTest:unmarshal_from_js_history()

Related issue

Closes: https://github.com/ehrbase/project_management/issues/185

Additional information and checks

  • Pull request linked in changelog

@jakesmolka
Copy link
Contributor

Please add a line to the changelog :)

@chevalleyc chevalleyc merged commit 1a8040f into develop Mar 31, 2020
@wlad wlad deleted the feature/185_wrong_canonical_encoding branch September 7, 2020 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants