RippleOSI / Ripple-openEHR

for openEHR archetypes, templates, AQL etc - for Ripple showcase stack
Apache License 2.0
6 stars 2 forks source link

EtherCIS- test Results- lab data values #8

Closed tony-shannon closed 6 years ago

tony-shannon commented 7 years ago

Test lab results arent showing up in the detail that am expecting See this related issue with screenshot https://github.com/RippleOSI/Ripple-Qewd/issues/38

robtweed commented 7 years ago

This is due to a known issue apparently. Ethercis is returning the lab test results as a string containing the JSON structure, rather than the JSON itself

tony-shannon commented 7 years ago

thanks Rob Is this being actioned & sorted at EtherCIS end? If so can we add link to related issue here please? Otherwise do we need to help in middleware for now? Tony

freshehr commented 7 years ago

The Marand fromat is

"resultSet": [
        {
            "conclusion": "Very rapidly deteriorating renal function",
            "uid": "61ea7918-512c-4e65-8ec4-55d30140e7d5::ripple_osi.ehrscape.c4h::1",
            "test_panel": {
                "@class": "CLUSTER",
                "name": {
                    "@class": "DV_TEXT",
                    "value": "Laboratory test panel"
                },
                "archetype_details": {
                    "@class": "ARCHETYPED",
                    "archetype_id": {
                        "@class": "ARCHETYPE_ID",
                        "value": "openEHR-EHR-CLUSTER.laboratory_test_panel.v0"
                    },
                    "rm_version": "1.0.1"
                },
                "archetype_node_id": "openEHR-EHR-CLUSTER.laboratory_test_panel.v0",
                "items": [
                    {
                        "@class": "CLUSTER",
                        "name": {
                            "@class": "DV_TEXT",
                            "value": "Laboratory result"
                        },
                        "archetype_node_id": "at0002",
                        "items": [
                            {
                                "@class": "ELEMENT",
                                "name": {
                                    "@class": "DV_CODED_TEXT",
                                    "value": "Urea",
                                    "defining_code": {
                                        "@class": "CODE_PHRASE",
                                        "terminology_id": {
                                            "@class": "TERMINOLOGY_ID",
                                            "value": "SNOMED-CT"
                                        },
                                        "code_string": "365755003"
                                    }
                                },
                                "archetype_node_id": "at0001",
                                "value": {
                                    "@class": "DV_QUANTITY",
                                    "normal_range": {
                                        "@class": "DV_INTERVAL",
                                        "lower": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 2.5,
                                            "units": "mmol/l"
                                        },
                                        "upper": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 6.6,
                                            "units": "mmol/l"
                                        },
                                        "lower_unbounded": false,
                                        "upper_unbounded": false
                                    },
                                    "magnitude": 7.8,
                                    "units": "mmol/l"
                                }
                            },
                            {
                                "@class": "ELEMENT",
                                "name": {
                                    "@class": "DV_TEXT",
                                    "value": "Comment"
                                },
                                "archetype_node_id": "at0003",
                                "value": {
                                    "@class": "DV_TEXT",
                                    "value": "may be technical artefact"
                                }
                            }
                        ]
                    },
                    {
                        "@class": "CLUSTER",
                        "name": {
                            "@class": "DV_TEXT",
                            "value": "Laboratory result #2"
                        },
                        "archetype_node_id": "at0002",
                        "items": [
                            {
                                "@class": "ELEMENT",
                                "name": {
                                    "@class": "DV_CODED_TEXT",
                                    "value": "Creatinine",
                                    "defining_code": {
                                        "@class": "CODE_PHRASE",
                                        "terminology_id": {
                                            "@class": "TERMINOLOGY_ID",
                                            "value": "SNOMED-CT"
                                        },
                                        "code_string": "70901006"
                                    }
                                },
                                "archetype_node_id": "at0001",
                                "value": {
                                    "@class": "DV_QUANTITY",
                                    "normal_range": {
                                        "@class": "DV_INTERVAL",
                                        "lower": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 80,
                                            "units": "mmol/l"
                                        },
                                        "upper": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 110,
                                            "units": "mmol/l"
                                        },
                                        "lower_unbounded": false,
                                        "upper_unbounded": false
                                    },
                                    "magnitude": 123,
                                    "units": "mmol/l"
                                }
                            }
                        ]
                    },
                    {
                        "@class": "CLUSTER",
                        "name": {
                            "@class": "DV_TEXT",
                            "value": "Laboratory result #3"
                        },
                        "archetype_node_id": "at0002",
                        "items": [
                            {
                                "@class": "ELEMENT",
                                "name": {
                                    "@class": "DV_CODED_TEXT",
                                    "value": "Sodium",
                                    "defining_code": {
                                        "@class": "CODE_PHRASE",
                                        "terminology_id": {
                                            "@class": "TERMINOLOGY_ID",
                                            "value": "SNOMED-CT"
                                        },
                                        "code_string": "365761000"
                                    }
                                },
                                "archetype_node_id": "at0001",
                                "value": {
                                    "@class": "DV_QUANTITY",
                                    "normal_range": {
                                        "@class": "DV_INTERVAL",
                                        "lower": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 133,
                                            "units": "mmol/l"
                                        },
                                        "upper": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 146,
                                            "units": "mmol/l"
                                        },
                                        "lower_unbounded": false,
                                        "upper_unbounded": false
                                    },
                                    "magnitude": 131,
                                    "units": "mmol/l"
                                }
                            }
                        ]
                    },
                    {
                        "@class": "CLUSTER",
                        "name": {
                            "@class": "DV_TEXT",
                            "value": "Laboratory result #4"
                        },
                        "archetype_node_id": "at0002",
                        "items": [
                            {
                                "@class": "ELEMENT",
                                "name": {
                                    "@class": "DV_CODED_TEXT",
                                    "value": "365760004",
                                    "defining_code": {
                                        "@class": "CODE_PHRASE",
                                        "terminology_id": {
                                            "@class": "TERMINOLOGY_ID",
                                            "value": "SNOMED-CT"
                                        },
                                        "code_string": "Potassium"
                                    }
                                },
                                "archetype_node_id": "at0001",
                                "value": {
                                    "@class": "DV_QUANTITY",
                                    "normal_range": {
                                        "@class": "DV_INTERVAL",
                                        "lower": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 3.5,
                                            "units": "mmol/l"
                                        },
                                        "upper": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 5.3,
                                            "units": "mmol/l"
                                        },
                                        "lower_unbounded": false,
                                        "upper_unbounded": false
                                    },
                                    "magnitude": 5.4,
                                    "units": "mmol/l"
                                }
                            }
                        ]
                    }
                ]
            },
            "author": "Dr Lab",
            "date_created": "2015-04-22T00:11:02.518+02:00",
            "sample_taken": "2015-04-22T00:11:02.518+02:00",
            "test_name": "Urea, electrolytes and creatinine measurement",
            "status": "Final"
        },

Christian is proposing this light-weight version, which I think should be ok but needs testing

"value": {
                                    "@class": "DV_QUANTITY",
                                    "normal_range": {
                                        "@class": "DV_INTERVAL",
                                        "lower": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 3.5,
                                            "units": "mmol/l"
                                        },
                                        "upper": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 5.3,
                                            "units": "mmol/l"
                                        },
                                        "lower_unbounded": false,
                                        "upper_unbounded": false
                                    },
                                    "magnitude": 5.4,
                                    "units": "mmol/l"
                                }
freshehr commented 7 years ago

There is also still a problem with some AQL formats not working on Ethercis. Christian is working on this. However this appears to work...

select   a/uid/value as uid,   a/composer/name as author,   a/context/start_time/value as date_created,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value/value as test_name,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0057]/value/value as conclusion,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0073]/value/value as status,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0075]/value/value as sample_taken,   a_a/data[at0001]/events[at0002]/data[at0003]/items[openEHR-EHR-CLUSTER.laboratory_test_panel.v0] as test_panel  from EHR e  contains COMPOSITION a[openEHR-EHR-COMPOSITION.report-result.v1]  contains OBSERVATION a_a[openEHR-EHR-OBSERVATION.laboratory_test.v0]  where a/name/value='Laboratory test report'

which should work for us.

freshehr commented 7 years ago

Heading

Lab Results

Version:

2.0.0 : 20-June-2017

TemplateID:

IDCR - Laboratory Test Report.v0

Summary AQL /query:

To populate the list of items when the heading is selected.

select
a/uid/value as uid,
a/composer/name as author,
a/context/start_time/value as date_created,
    a_b/data[at0001]/origin/value as sample_time,
    a_b/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value/value as test_name,
    a_b/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value/defining_code/code_string as test_name_code,
    a_b/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value/defining_code/terminology_id/value as test_name_terminology,
    a_b/data[at0001]/events[at0002]/data[at0003]/items[at0073]/value/value as status,
    a_b/data[at0001]/events[at0002]/data[at0003]/items[at0057]/value/value as conclusion,
    a_a/items[at0002]/name/value as Laboratory_result_header,
    a_a/items[at0002]/items[at0001]/name/value as result_name,
    a_a/items[at0002]/items[at0001]/name/defining_code/code_string as result_name_code,
    a_a/items[at0002]/items[at0001]/name/defining_code/terminology_id/value as result_name_terminology,
    a_a/items[at0002]/items[at0001]/value/magnitude as result_magnitude,
    a_a/items[at0002]/items[at0001]/value/units as result_units,
    a_a/items[at0002]/items[at0001]/value/normal_range/lower/magnitude as normal_range_lower,
        a_a/items[at0002]/items[at0001]/value/normal_range/lower/units as normal_range_lower_units,
    a_a/items[at0002]/items[at0001]/value/normal_range/upper/magnitude as normal_range_upper,
        a_a/items[at0002]/items[at0001]/value/normal_range/upper/units as normal_range_upper_units,
    a_a/items[at0002]/items[at0001]/value/normal_range/lower_included as lower_included,
    a_a/items[at0002]/items[at0001]/value/normal_range/upper_included as upper_included,
    a_a/items[at0002]/items[at0001]/value/normal_range/lower_unbounded as lower_unbounded,
    a_a/items[at0002]/items[at0001]/value/normal_range/upper_unbounded as upper_unbounded
from EHR e[ehr_id/value='{{ehrId}}']
contains COMPOSITION a
contains
    OBSERVATION a_b[openEHR-EHR-OBSERVATION.laboratory_test.v0]
contains
    CLUSTER a_a[openEHR-EHR-CLUSTER.laboratory_test_panel.v0]

Alternative AQL using Resultset Objects

select   a/uid/value as uid,   
  a/composer/name as author,
  a/context/start_time/value as date_created,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value/value as test_name,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0057]/value/value as conclusion,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0073]/value/value as status,   a_a/data[at0001]/events[at0002]/data[at0003]/items[at0075]/value/value as sample_taken,   a_a/data[at0001]/events[at0002]/data[at0003]/items[openEHR-EHR-CLUSTER.laboratory_test_panel.v0] as test_panel  
  from EHR e[ehr_id/value='{{ehrId}}']
  contains COMPOSITION a[openEHR-EHR-COMPOSITION.report-result.v1]
  contains OBSERVATION a_a[openEHR-EHR-OBSERVATION.laboratory_test.v0]  
  where a/name/value='Laboratory test report'

Detail AQL /query:

To populate the detailed view / edit when a single record within the heading is selected.

As above

Sample Composition(FLAT JSON) for POST/PUT /composition:

To create or update a composition for a single item via the /composition Ehrscape API call.

{
 "ctx/composer_name": "Dr Lab",
 "ctx/health_care_facility|id": "999999-34567",
 "ctx/health_care_facility|name": "Super Labs Inc",
 "ctx/id_namespace": "NHS-UK",
 "ctx/id_scheme": "2.16.840.1.113883.2.1.4.3",
 "ctx/language": "en",
 "ctx/territory": "GB",
 "ctx/time": "2015-04-15T00:11:02.518+02:00",
 "ctx/history_origin": "2015-04-10T00:11:02.518+02:00",
 "laboratory_test_report/laboratory_test/test_name|value": "Urea, electrolytes and creatinine measurement",
 "laboratory_test_report/laboratory_test/test_name|code": "444164000",
 "laboratory_test_report/laboratory_test/test_name|terminology": "SNOMED-CT",
 "laboratory_test_report/laboratory_test/test_status|code": "at0038",
 "laboratory_test_report/laboratory_test/test_status|value": "Final",
 "laboratory_test_report/laboratory_test/test_status_timestamp": "2015-04-10T00:11:02.518+02:00",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_name|value": "Urea",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_name|code": "365755003",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_name|terminology": "SNOMED-CT",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value|magnitude": 3.6,
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_normal_range/lower|magnitude": "2.5",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_normal_range/lower|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_normal_range/upper|magnitude": "6.6",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/result_value/_normal_range/upper|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:0/comment": "this is free text",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_name|value": "Creatinine",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_name|code": "70901006",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_name|terminology": "SNOMED-CT",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value|magnitude": 97,
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_normal_range/lower|magnitude": "80",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_normal_range/lower|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_normal_range/upper|magnitude": "110",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:1/result_value/_normal_range/upper|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_name|value": "Sodium",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_name|code": "365761000",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_name|terminology": "SNOMED-CT",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value|magnitude": 122,
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_normal_range/lower|magnitude": "133",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_normal_range/lower|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_normal_range/upper|magnitude": "146",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:2/result_value/_normal_range/upper|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_name|value": "Potassium",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_name|code": "365760004",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_name|terminology": "SNOMED-CT",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value|magnitude": "6.1",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_normal_range/lower|magnitude": "3.5",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_normal_range/lower|unit": "mmol/l",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_normal_range/upper|magnitude": "5.3",
 "laboratory_test_report/laboratory_test/laboratory_test_panel/laboratory_result:3/result_value/_normal_range/upper|unit": "mmol/l"
}
freshehr commented 7 years ago

Using the alternative AQL in the above document should work on both CDRs.

tony-shannon commented 7 years ago

ok many thanks @freshehr Suggest we check this in action before closing this issue @robtweed can you please amend so we can retest, this is linked to https://github.com/RippleOSI/Ripple-Qewd/issues/38

robtweed commented 7 years ago

Lab results seems to be now working on the dev machine - could someone check and confirm before I copy it to the demo machine?

tony-shannon commented 7 years ago

@freshehr Just tested this, there seems to be a change in the data returned.. 2 issues

1 the screenshot here shows the first row includes "Comment" as text. image

2 yet the test result AQL doesnt seem to have a comment field, according to Rob?

thanks

freshehr commented 7 years ago

It might just be that we have not included comments in the sample data. I'll check

Ian On Thu, 29 Jun 2017 at 17:50, Tony Shannon notifications@github.com wrote:

@freshehr https://github.com/freshehr Just tested this, there seems to be a change in the data returned.. 2 issues

1 the screenshot here shows the first row includes "Comment" as text. [image: image] https://user-images.githubusercontent.com/939996/27699783-4c48e18c-5cf3-11e7-8b99-6fe379cacb8e.png

2 yet the test result AQL doesnt seem to have a comment field, according to Rob?

thanks

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/RippleOSI/Ripple-openEHR/issues/8#issuecomment-312026397, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQ4RdFsR75qcVoh26HEZzzP0JRes83iks5sI9XkgaJpZM4N_1Ys .

-- Ian McNicoll

freshehr commented 7 years ago

@ethercis - this seems to be a problem with Ethercis query resultset.

The original composition is

{
    "composition": {
        "laboratory_test_report/_uid": "7b370b47-fee4-4224-9c28-aea620ebba77::vm01.ethercis.org::1",
        "laboratory_test_report/language|code": "en",
        "laboratory_test_report/language|terminology": "ISO_639-1",
        "laboratory_test_report/territory|code": "GB",
        "laboratory_test_report/territory|terminology": "ISO_3166-1",
        "laboratory_test_report/context/_health_care_facility|id": "999999-34567",
        "laboratory_test_report/context/_health_care_facility|id_scheme": "2.16.840.1.113883.2.1.4.3",
        "laboratory_test_report/context/_health_care_facility|id_namespace": "NHS-UK",
        "laboratory_test_report/context/_health_care_facility|name": "Super Labs Inc",
        "laboratory_test_report/context/start_time": "2017-03-29T00:17:48.518+02:00",
        "laboratory_test_report/context/setting|code": "238",
        "laboratory_test_report/context/setting|value": "other care",
        "laboratory_test_report/context/setting|terminology": "openehr",
        "laboratory_test_report/laboratory_test:0/test_name|code": "26958001",
        "laboratory_test_report/laboratory_test:0/test_name|value": "hepatic function panel",
        "laboratory_test_report/laboratory_test:0/test_name|terminology": "SNOMED-CT",
        "laboratory_test_report/laboratory_test:0/test_status|code": "at0038",
        "laboratory_test_report/laboratory_test:0/test_status|value": "Final",
        "laboratory_test_report/laboratory_test:0/test_status|terminology": "local",
        "laboratory_test_report/laboratory_test:0/test_status_timestamp": "2017-03-29T00:13:13.518+02:00",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_name|value": "total protein measurement",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value|magnitude": 97,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/lower|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/lower|magnitude": 60,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/upper|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/upper|magnitude": 80,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/comment": "singificantly raised level",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:1/result_value|magnitude": 29,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:1/result_value|unit": "�mol/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:1/result_value/_normal_range/lower|unit": "�mol/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:1/result_value/_normal_range/lower|magnitude": 1,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:1/result_value/_normal_range/upper|unit": "�mol/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:1/result_value/_normal_range/upper|magnitude": 20,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:2/result_value|magnitude": 66,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:2/result_value|unit": "U/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:2/result_value/_normal_range/lower|unit": "U/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:2/result_value/_normal_range/lower|magnitude": 5,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:2/result_value/_normal_range/upper|unit": "U/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:2/result_value/_normal_range/upper|magnitude": 45,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:3/result_value|magnitude": 135,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:3/result_value|unit": "U/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:3/result_value/_normal_range/lower|unit": "U/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:3/result_value/_normal_range/lower|magnitude": 30,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:3/result_value/_normal_range/upper|unit": "U/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:3/result_value/_normal_range/upper|magnitude": 130,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:4/result_value|magnitude": 67,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:4/result_value|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:4/result_value/_normal_range/lower|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:4/result_value/_normal_range/lower|magnitude": 35,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:4/result_value/_normal_range/upper|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:4/result_value/_normal_range/upper|magnitude": 50,
        "laboratory_test_report/laboratory_test:0/conclusion": "result outside normal range - indicates advancced liver disease",
        "laboratory_test_report/laboratory_test:0/time": "2017-03-28T00:19:56.518+02:00",
        "laboratory_test_report/laboratory_test:0/language|code": "en",
        "laboratory_test_report/laboratory_test:0/language|terminology": "ISO_639-1",
        "laboratory_test_report/laboratory_test:0/encoding|code": "UTF-8",
        "laboratory_test_report/laboratory_test:0/encoding|terminology": "IANA_character-sets",
        "laboratory_test_report/composer|name": "Dr Lab"
    },
    "meta": {
        "href": "rest/v1/composition?uid=7b370b47-fee4-4224-9c28-aea620ebba77::vm01.ethercis.org::1"
    },
    "format": "FLAT",
    "templateId": "IDCR - Laboratory Test Report.v0"
}

but the AQL result returns ..

  "resultSet": [
        {
            "conclusion": "result outside normal range - indicates advancced liver disease",
            "uid": "7b370b47-fee4-4224-9c28-aea620ebba77::vm01.ethercis.org::1",
            "test_panel": {
                "name": {
                    "value": "Laboratory test panel"
                },
                "items": [
                    {
                        "name": {
                            "value": "Laboratory result"
                        },
                        "items": [
                            {
                                "name": {
                                    "value": "Comment"
                                },
                                "value": {
                                    "value": "singificantly raised level"
                                },
                                "@class": "DV_TEXT",
                                "archetype_node_id": "at0003"
                            }
                        ],
                        "archetype_node_id": "at0002"
                    },
                    {
                        "name": {
                            "value": "Laboratory result #2"
                        },
                        "items": [
                            {
                                "name": {
                                    "value": "albumin measurement, serum",
                                    "defining_code": {
                                        "codeString": "104485008",
                                        "terminologyId": {
                                            "name": "SNOMED-CT",
                                            "value": "SNOMED-CT"
                                        }
                                    }
                                },
                                "value": {
                                    "units": "g/l",
                                    "accuracy": 0,
                                    "magnitude": 67,
                                    "precision": 0,
                                    "normalRange": {
                                        "interval": {
                                            "lower": {
                                                "units": "g/l",
                                                "accuracy": 0,
                                                "magnitude": 35,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "upper": {
                                                "units": "g/l",
                                                "accuracy": 0,
                                                "magnitude": 50,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "lowerIncluded": true,
                                            "upperIncluded": true
                                        }
                                    },
                                    "accuracyPercent": false,
                                    "measurementService": {}
                                },
                                "@class": "DV_QUANTITY",
                                "archetype_node_id": "at0001"
                            }
                        ],
                        "archetype_node_id": "at0002"
                    },
                    {
                        "name": {
                            "value": "Laboratory result #3"
                        },
                        "items": [
                            {
                                "name": {
                                    "value": "alkaline phosphatase measurement",
                                    "defining_code": {
                                        "codeString": "88810008",
                                        "terminologyId": {
                                            "name": "SNOMED-CT",
                                            "value": "SNOMED-CT"
                                        }
                                    }
                                },
                                "value": {
                                    "units": "U/l",
                                    "accuracy": 0,
                                    "magnitude": 135,
                                    "precision": 0,
                                    "normalRange": {
                                        "interval": {
                                            "lower": {
                                                "units": "U/l",
                                                "accuracy": 0,
                                                "magnitude": 30,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "upper": {
                                                "units": "U/l",
                                                "accuracy": 0,
                                                "magnitude": 130,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "lowerIncluded": true,
                                            "upperIncluded": true
                                        }
                                    },
                                    "accuracyPercent": false,
                                    "measurementService": {}
                                },
                                "@class": "DV_QUANTITY",
                                "archetype_node_id": "at0001"
                            }
                        ],
                        "archetype_node_id": "at0002"
                    },
                    {
                        "name": {
                            "value": "Laboratory result #4"
                        },
                        "items": [
                            {
                                "name": {
                                    "value": "alanine aminotransferase measurement",
                                    "defining_code": {
                                        "codeString": "34608000",
                                        "terminologyId": {
                                            "name": "SNOMED-CT",
                                            "value": "SNOMED-CT"
                                        }
                                    }
                                },
                                "value": {
                                    "units": "U/l",
                                    "accuracy": 0,
                                    "magnitude": 66,
                                    "precision": 0,
                                    "normalRange": {
                                        "interval": {
                                            "lower": {
                                                "units": "U/l",
                                                "accuracy": 0,
                                                "magnitude": 5,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "upper": {
                                                "units": "U/l",
                                                "accuracy": 0,
                                                "magnitude": 45,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "lowerIncluded": true,
                                            "upperIncluded": true
                                        }
                                    },
                                    "accuracyPercent": false,
                                    "measurementService": {}
                                },
                                "@class": "DV_QUANTITY",
                                "archetype_node_id": "at0001"
                            }
                        ],
                        "archetype_node_id": "at0002"
                    },
                    {
                        "name": {
                            "value": "Laboratory result #5"
                        },
                        "items": [
                            {
                                "name": {
                                    "value": "bilirubin, total measurement",
                                    "defining_code": {
                                        "codeString": "359986008",
                                        "terminologyId": {
                                            "name": "SNOMED-CT",
                                            "value": "SNOMED-CT"
                                        }
                                    }
                                },
                                "value": {
                                    "units": "\ufffdmol/l",
                                    "accuracy": 0,
                                    "magnitude": 29,
                                    "precision": 0,
                                    "normalRange": {
                                        "interval": {
                                            "lower": {
                                                "units": "\ufffdmol/l",
                                                "accuracy": 0,
                                                "magnitude": 1,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "upper": {
                                                "units": "\ufffdmol/l",
                                                "accuracy": 0,
                                                "magnitude": 20,
                                                "precision": 0,
                                                "accuracyPercent": false,
                                                "measurementService": {}
                                            },
                                            "lowerIncluded": true,
                                            "upperIncluded": true
                                        }
                                    },
                                    "accuracyPercent": false,
                                    "measurementService": {}
                                },
                                "@class": "DV_QUANTITY",
                                "archetype_node_id": "at0001"
                            }
                        ],
                        "archetype_node_id": "at0002"
                    }
                ]
            },
            "author": "Dr Lab",
            "date_created": "2017-03-28T23:17:48+02:00",
            "sample_taken": "2017-03-29T00:13:13.518+02:00",
            "test_name": "hepatic function panel",
            "status": "Final"
        },
freshehr commented 7 years ago

Looking further into it - the 'comment' data is valid - there is a comment associated with the labe result but I think the nesting is wrong, and the first lab result is missing.

"laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_name|value": "total protein measurement",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value|magnitude": 97,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/lower|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/lower|magnitude": 60,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/upper|unit": "g/l",
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/upper|magnitude": 80,
        "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/comment": "significantly raised level",

or in RAW JSON

               "items": [
                                            {
                                                "@class": "CLUSTER",
                                                "name": {
                                                    "@class": "DV_TEXT",
                                                    "value": "Laboratory result"
                                                },
                                                "archetype_node_id": "at0002",
                                                "items": [
                                                    {
                                                        "@class": "ELEMENT",
                                                        "name": {
                                                            "@class": "DV_TEXT",
                                                            "value": "Comment"
                                                        },
                                                        "archetype_node_id": "at0003",
                                                        "value": {
                                                            "@class": "DV_TEXT",
                                                            "value": "singificantly raised level"
                                                        }
                                                    },
                                                    {
                                                        "@class": "ELEMENT",
                                                        "name": {
                                                            "@class": "DV_TEXT",
                                                            "value": "total protein measurement"
                                                        },
                                                        "archetype_node_id": "at0001",
                                                        "value": {
                                                            "@class": "DV_QUANTITY",
                                                            "magnitude": 97,
                                                            "units": "g/l"
                                                        }
                                                    }
                                                ]
                                            },
tony-shannon commented 7 years ago

thanks @freshehr

Assume we're we waiting for further fix ? Dont see comment in that JSON

Tony

On 30 June 2017 at 09:34, Ian McNicoll notifications@github.com wrote:

Looking further into it - the 'comment' data is valid - there is a comment associated with the labe result but I think the nesting is wrong, and the first lab result is missing.

"laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_name|value": "total protein measurement", "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value|magnitude": 97, "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value|unit": "g/l", "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/lower|unit": "g/l", "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/lower|magnitude": 60, "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/upper|unit": "g/l", "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/result_value/_normal_range/upper|magnitude": 80, "laboratory_test_report/laboratory_test:0/laboratory_test_panel:0/laboratory_result:0/comment": "significantly raised level",

or in RAW JSON

           "items": [
                                        {
                                            "@class": "CLUSTER",
                                            "name": {
                                                "@class": "DV_TEXT",
                                                "value": "Laboratory result"
                                            },
                                            "archetype_node_id": "at0002",
                                            "items": [
                                                {
                                                    "@class": "ELEMENT",
                                                    "name": {
                                                        "@class": "DV_TEXT",
                                                        "value": "Comment"
                                                    },
                                                    "archetype_node_id": "at0003",
                                                    "value": {
                                                        "@class": "DV_TEXT",
                                                        "value": "singificantly raised level"
                                                    }
                                                },
                                                {
                                                    "@class": "ELEMENT",
                                                    "name": {
                                                        "@class": "DV_TEXT",
                                                        "value": "total protein measurement"
                                                    },
                                                    "archetype_node_id": "at0001",
                                                    "value": {
                                                        "@class": "DV_QUANTITY",
                                                        "magnitude": 97,
                                                        "units": "g/l"
                                                    }
                                                }
                                            ]
                                        },

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/RippleOSI/Ripple-openEHR/issues/8#issuecomment-312209408, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5X3GLCJchVygBh-CCTnAYV_v7GqNUHks5sJLMFgaJpZM4N_1Ys .

robtweed commented 7 years ago

The problem is that a comment is appearing as the first object in the test panel array of objects, eg

[{ "name": { "value": "Laboratory result" }, "items": [{ "name": { "value": "Comment" }, "value": { "value": "singificantly raised level" }, "@class": "DV_TEXT", "archetype_node_id": "at0003" }], "archetype_node_id": "at0002" },

{ "name": { "value": "Laboratory result #2" }, "items": [{ "name": { "value": "albumin measurement, serum", "defining_code": { "codeString": "104485008", "terminologyId": { "name": "SNOMED-CT", "value": "SNOMED-CT" } } }, "value": { "units": "g/l", "accuracy": 0, "magnitude": 67, "precision": 0, "normalRange": { "interval": { "lower": { "units": "g/l", "accuracy": 0, "magnitude": 35, "precision": 0, "accuracyPercent": false, "measurementService": {} }, "upper": { "units": "g/l", "accuracy": 0, "magnitude": 50, "precision": 0, "accuracyPercent": false, "measurementService": {} }, "lowerIncluded": true, "upperIncluded": true } }, "accuracyPercent": false, "measurementService": {} }, "@class": "DV_QUANTITY", "archetype_node_id": "at0001" }], "archetype_node_id": "at0002" },...etc ]

So the comment appears to relate to the group of tests within the test panel array. Previously we had a comment for each test within the test panel array.

tony-shannon commented 7 years ago

We could make a change at the UI level if the comment was consistently a single comment and not a series of comments Can we check how consistent that is /what API change would be needed to serve a single comment to the UI?

On 30 June 2017 at 15:28, robtweed notifications@github.com wrote:

The problem is that a comment is appearing as the first object in the test panel array of objects, eg

[{ "name": { "value": "Laboratory result" }, "items": [{ "name": { "value": "Comment" }, "value": { "value": "singificantly raised level" }, "@Class https://github.com/class": "DV_TEXT",

"archetype_node_id": "at0003" }], "archetype_node_id": "at0002" },

{ "name": { "value": "Laboratory result #2 https://github.com/RippleOSI/Ripple-openEHR/issues/2" }, "items": [{ "name": { "value": "albumin measurement, serum", "defining_code": { "codeString": "104485008", "terminologyId": { "name": "SNOMED-CT", "value": "SNOMED-CT" } } }, "value": { "units": "g/l", "accuracy": 0, "magnitude": 67, "precision": 0, "normalRange": { "interval": { "lower": { "units": "g/l", "accuracy": 0, "magnitude": 35, "precision": 0, "accuracyPercent": false, "measurementService": {} }, "upper": { "units": "g/l", "accuracy": 0, "magnitude": 50, "precision": 0, "accuracyPercent": false, "measurementService": {} }, "lowerIncluded": true, "upperIncluded": true } }, "accuracyPercent": false, "measurementService": {} }, "@Class https://github.com/class": "DV_QUANTITY", "archetype_node_id": "at0001" }], "archetype_node_id": "at0002" },...etc ]

So the comment appears to relate to the group of tests within the test panel array. Previously we had a comment for each test within the test panel array.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/RippleOSI/Ripple-openEHR/issues/8#issuecomment-312282211, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5X3L3OEOo-0Sfb5fBKXbpNbcSc1ac2ks5sJQYmgaJpZM4N_1Ys .

robtweed commented 7 years ago

Well, if there's a single comment for the entire set of tests in the test panel, it would make more sense for the data returned from OpenEHR to have the comment separated out and not as one of the test panel objects (it always appears to be the first, though I'm not sure if that is definitely always the case). As it currently stands, it's tricky and messy for the middle tier mapping logic to treat one of the test panel array elements as a special case

tony-shannon commented 7 years ago

thanks Rob

@freshehr Ian can you suggest an improvement to AQL re comment please?

thanks T

freshehr commented 7 years ago

Hi all. The problem here is not the AQL. I am pretty sure that the issue is that the 'raw' openEHR json coming back from Ethercis is not quite correct. @

The comment that is messing Rob up is actually associated with an individual result, not with the whole panel (though there can be a separate element for that, which we do use at times). The problem is that there is a chunk of json essentially missing. I did try to explain that in the other thread.

This

[{
"name": {
"value": "Laboratory result"
},
"items": [{
"name": {
"value": "Comment"
},
"value": {
"value": "singificantly raised level"
},
"@Class": "DV_TEXT",
"archetype_node_id": "at0003"
}],
"archetype_node_id": "at0002"
},

should be

"items": [
        {
                                "name": {
                                    "@class": "DV_CODED_TEXT",
                                    "value": "Total HDL",
                                    "defining_code": {
                                        "@class": "CODE_PHRASE",
                                        "terminology_id": {
                                            "@class": "TERMINOLOGY_ID",
                                            "value": "SNOMED-CT"
                                        },
                                        "code_string": "71006"
                                    }
                                },
                                "archetype_node_id": "at0001",
                                "value": {
                                    "@class": "DV_QUANTITY",
                                    "normal_range": {
                                        "@class": "DV_INTERVAL",
                                        "lower": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 80,
                                            "units": "mmol/l"
                                        },
                                        "upper": {
                                            "@class": "DV_QUANTITY",
                                            "magnitude": 110,
                                            "units": "mmol/l"
                                        },
                                        "lower_unbounded": false,
                                        "upper_unbounded": false
                                    },
                                    "magnitude": 123,
                                    "units": "mmol/l",                                        
                                }
                            },
                            {
                              "archetype_node_id": "at0003",
                              "name": {
                                "value": "Comment"
                                },
                              "value": {
                                "value": "singificantly raised level"
                              }
                            }
                        ]

I will raise this again with Christian. There are a couple of other node name formatting issues that need tweaked as a well.

freshehr commented 6 years ago

Still not working I'm afraid

GET /rest/v1/query?aql=select a/uid/value as uid, a/composer/name as author, a/context/start_time/value as date_created, a_b as lab_test from EHR e[ehr_id/value='4a704b79-72ec-4bf7-bf7b-b90c6225495a'] contains COMPOSITION a contains OBSERVATION a_b[openEHR-EHR-OBSERVATION.laboratory_test.v0] HTTP/1.1
Host: 178.62.71.220:8080
Authorization: Basic Z3Vlc3Q6Z3Vlc3Q=
Ehr-Session: sessionId:127.0.0.1-guest-1508074924248-655738533-4562

Response:

HTTP ERROR: 500

Problem accessing /rest/v1/query. Reason:

    #1.0.0 Invocation exception to method:query:java.lang.IllegalArgumentException: Could not encode raw json for template Id:IDCR - Laboratory Test Report.v0
tony-shannon commented 6 years ago

thanks Ian @freshehr Can you recommend next steps/actions on this & by whom? thanks T

freshehr commented 6 years ago

It should be ok now - I tested it with the wrong query (which did not work) but the one that is being used currently in Ripple should work with both Ethercis and ThinkEhr. Just test the UI and see how we get on ...

tony-shannon commented 6 years ago

this looks to be working better now, with comments showing up properly

image

So I'm going to close this issue for now Tony