Querying actions by their ism_transition/current_state

Hi all,

While testing EHRBASE and EHRSCAPE trying to get ACTIONs that have a specific ism_transition/current_state, the results are empty.

Context:

We have this action template: https://github.com/ehrbase/ehrbase/blob/develop/tests/robot/_resources/test_data_sets/valid_templates/minimal/minimal_action_2.opt

And generated a JSON instance based on that one, that has:

"ism_transition": {
    "current_state": {
                    "value": "planned",
                    "defining_code": {
                        "terminology_id": {
                            "value": "openehr"
                        },
                        "code_string": "526"
                    }
                }
            }

Full example: action2.instance.json (3.5 KB)

I commit several of those compositions to one EHR, everything works OK.

Now if I execute this AQL:

{"q":"select a_a from EHR e contains COMPOSITION a contains ACTION a_a[openEHR-EHR-ACTION.minimal_2.v1] where a_a/ism_transition/current_state/defining_code/code_string = '526'"}

The result has no rows.

Also on EHRSCAPE tried to get the full ACTIONs, this also has no rows.

{"q":"select a_a from EHR e contains COMPOSITION a contains ACTION a_a[openEHR-EHR-ACTION.minimal_2.v1]"}

I’m not sure why this doesn’t work or what should be the “correct” way of doing it. There should be something wrong in what I’m doing, because it’s strange to have the same behavior on two different implementaions.

On thing I noticed from the EHREXPLORER tool from Marand, is when I want to query the ism_transition, it doesn’t show the internal structure:

Any guidance on this area would be very useful, thanks!

Unless this is secret, I wonder if we should move it to the platform implementation category?

no secret, not sure why AQL category is private though, that was the category I assigned, not the SEC one.

There is an AQL category under specifications as well…

yes, that was the issue, thought AQL was a normal category but it’s private.

Hi Pablo,

I have certainly been able to do queries on Better CDR like this in the past. I’ll see if I can replicate.

Ian

1 Like

THis works for me…

{
    "meta": {
        "_type": "RESULTSET",
        "_created": "2020-07-30T17:01:50.373Z",
        "_executed_aql": "select\n    a/composer/name as author,\n    a/uid/value as uid,\n    a/context/start_time/value as date_created,\n    b_a/activities[at0001]/description[at0009]/items[at0121]/value/value as referral_type,\n    b_a/activities[at0001]/description[at0009]/items[at0062]/value/value as referral_reason,\n    b_a/activities[at0001]/description[at0009]/items[at0064]/value/value as clinical_summary,\n    b_a/protocol[at0008]/items[openEHR-EHR-CLUSTER.individual_person_uk.v1, 'Requestor']/items[openEHR-EHR-CLUSTER.person_name.v1]/items[at0001]/value/value as referralFrom,\n    b_a/protocol[at0008]/items[openEHR-EHR-CLUSTER.organisation.v1, 'Receiver']/items[at0001]/value/value as referralTo,\n    b_a/protocol[at0008]/items[at0011]/value/value as referral_ref,\n    b_c/description[at0001]/items[at0011]/value/value as Service_Service_name,\n    b_c/description[at0001]/items[at0028]/value/value as Outcome,\n    b_c/time/value as dateOfState,\n    b_c/ism_transition/current_state/value as state,\n    b_c/ism_transition/current_state/defining_code/code_string as stateCode,\n    b_c/ism_transition/careflow_step/value as careflow,\n    b_c/ism_transition/careflow_step/defining_code/code_string as careflowCode\n from EHR e [ehr_id/value = '3e674739-950c-4b8a-976b-5aef21c618c5']\ncontains COMPOSITION a[openEHR-EHR-COMPOSITION.request.v1]\ncontains\n  (INSTRUCTION b_a[openEHR-EHR-INSTRUCTION.request.v0]\n   and\n   ACTION b_c[openEHR-EHR-ACTION.service.v0])\nwhere b_c/ism_transition/current_state/defining_code/code_string = '526'\n"
    },
    "q": "select\n    a/composer/name as author,\n    a/uid/value as uid,\n    a/context/start_time/value as date_created,\n    b_a/activities[at0001]/description[at0009]/items[at0121]/value/value as referral_type,\n    b_a/activities[at0001]/description[at0009]/items[at0062]/value/value as referral_reason,\n    b_a/activities[at0001]/description[at0009]/items[at0064]/value/value as clinical_summary,\n    b_a/protocol[at0008]/items[openEHR-EHR-CLUSTER.individual_person_uk.v1, 'Requestor']/items[openEHR-EHR-CLUSTER.person_name.v1]/items[at0001]/value/value as referralFrom,\n    b_a/protocol[at0008]/items[openEHR-EHR-CLUSTER.organisation.v1, 'Receiver']/items[at0001]/value/value as referralTo,\n    b_a/protocol[at0008]/items[at0011]/value/value as referral_ref,\n    b_c/description[at0001]/items[at0011]/value/value as Service_Service_name,\n    b_c/description[at0001]/items[at0028]/value/value as Outcome,\n    b_c/time/value as dateOfState,\n    b_c/ism_transition/current_state/value as state,\n    b_c/ism_transition/current_state/defining_code/code_string as stateCode,\n    b_c/ism_transition/careflow_step/value as careflow,\n    b_c/ism_transition/careflow_step/defining_code/code_string as careflowCode\n from EHR e [ehr_id/value = '3e674739-950c-4b8a-976b-5aef21c618c5']\ncontains COMPOSITION a[openEHR-EHR-COMPOSITION.request.v1]\ncontains\n  (INSTRUCTION b_a[openEHR-EHR-INSTRUCTION.request.v0]\n   and\n   ACTION b_c[openEHR-EHR-ACTION.service.v0])\nwhere b_c/ism_transition/current_state/defining_code/code_string = '526'\n",
    "columns": [
        {
            "name": "author",
            "path": "/composer/name"
        },
        {
            "name": "uid",
            "path": "/uid/value"
        },
        {
            "name": "date_created",
            "path": "/context/start_time/value"
        },
        {
            "name": "referral_type",
            "path": "/activities[at0001]/description[at0009]/items[at0121]/value/value"
        },
        {
            "name": "referral_reason",
            "path": "/activities[at0001]/description[at0009]/items[at0062]/value/value"
        },
        {
            "name": "clinical_summary",
            "path": "/activities[at0001]/description[at0009]/items[at0064]/value/value"
        },
        {
            "name": "referralFrom",
            "path": "/protocol[at0008]/items[openEHR-EHR-CLUSTER.individual_person_uk.v1]/items[openEHR-EHR-CLUSTER.person_name.v1]/items[at0001]/value/value"
        },
        {
            "name": "referralTo",
            "path": "/protocol[at0008]/items[openEHR-EHR-CLUSTER.organisation.v1]/items[at0001]/value/value"
        },
        {
            "name": "referral_ref",
            "path": "/protocol[at0008]/items[at0011]/value/value"
        },
        {
            "name": "Service_Service_name",
            "path": "/description[at0001]/items[at0011]/value/value"
        },
        {
            "name": "Outcome",
            "path": "/description[at0001]/items[at0028]/value/value"
        },
        {
            "name": "dateOfState",
            "path": "/time/value"
        },
        {
            "name": "state",
            "path": "/ism_transition/current_state/value"
        },
        {
            "name": "stateCode",
            "path": "/ism_transition/current_state/defining_code/code_string"
        },
        {
            "name": "careflow",
            "path": "/ism_transition/careflow_step/value"
        },
        {
            "name": "careflowCode",
            "path": "/ism_transition/careflow_step/defining_code/code_string"
        }
    ],
    "rows": [
        [
            "Dr Tony Shannon",
            "1b4cb6d3-b836-4bd4-8ad9-1abfcbc7ea9a::a81f47c6-a757-4e34-b644-3ccc62b4a01c::1",
            "2015-09-17T00:11:02.518+02:00",
            "Orthopaedics",
            "Arthritis left hip",
            "Constant pain and restricted mobility",
            "Tony Shannon",
            "Ripplefields Orthopaedics service",
            "3f74c2e6-2ae0-4680-b8b2-c6daec8f9309",
            "Orthopaedics",
            null,
            "2020-07-30T16:59:02.097Z",
            "planned",
            "526",
            "Service request sent",
            "at0026"
        ],
        [
            "Dr Tony Shannon",
            "dd917942-9209-46fc-8d02-1739dc536f6f::a81f47c6-a757-4e34-b644-3ccc62b4a01c::1",
            "2014-12-08T00:11:02.518+02:00",
            "Dermatology clinic",
            "Exacerbation of eczema",
            "Eczema since childhood, normally well-controlled, but significantly worse over last 3 weeks",
            "Tony Shannon",
            "Ripple DGH",
            "3f74c2e6-2ae0-4680-b8b2-c6daec8f9309",
            "Dermatology clinic",
            null,
            "2020-07-30T16:59:07.381Z",
            "planned",
            "526",
            "Service request sent",
            "at0026"
        ],
        [
            "Dr Tony Shannon",
            "892f688a-9a94-4c70-9a2a-e86b4158d4ac::a81f47c6-a757-4e34-b644-3ccc62b4a01c::1",
            "2016-10-12T00:11:02.518+02:00",
            "Physiotherapy",
            "Recurrent back pain",
            null,
            "Tony Shannon",
            "Ripple Physiotherapy Clinic",
            "3f74c2e6-2ae0-4680-b8b2-c6daec8f9309",
            "Physiotherapy",
            null,
            "2020-07-30T16:59:10.117Z",
            "planned",
            "526",
            "Service request sent",
            "at0026"
        ]
    ]
}

and closer to your test aql

{
    "meta": {
        "_type": "RESULTSET",
        "_created": "2020-07-30T17:06:34.382Z",
        "_executed_aql": "select a_a from EHR e contains COMPOSITION a contains ACTION a_a[openEHR-EHR-ACTION.service.v0] where a_a/ism_transition/current_state/defining_code/code_string = '526'\n"
    },
    "q": "select a_a from EHR e contains COMPOSITION a contains ACTION a_a[openEHR-EHR-ACTION.service.v0] where a_a/ism_transition/current_state/defining_code/code_string = '526'\n",
    "columns": [
        {
            "name": "#0",
            "path": "/"
        }
    ],
    "rows": [
        [
            {
                "_type": "ACTION",
                "name": {
                    "_type": "DV_TEXT",
                    "value": "Service"
                },
                "archetype_details": {
                    "_type": "ARCHETYPED",
                    "archetype_id": {
                        "_type": "ARCHETYPE_ID",
                        "value": "openEHR-EHR-ACTION.service.v0"
                    },
                    "rm_version": "1.0.4"
                },
                "archetype_node_id": "openEHR-EHR-ACTION.service.v0",
                "language": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "ISO_639-1"
                    },
                    "code_string": "en"
                },
                "encoding": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "IANA_character-sets"
                    },
                    "code_string": "UTF-8"
                },
                "subject": {
                    "_type": "PARTY_SELF"
                },
                "protocol": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Tree"
                    },
                    "archetype_node_id": "at0015",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Receiver identifier"
                            },
                            "archetype_node_id": "at0018",
                            "value": {
                                "_type": "DV_TEXT",
                                "value": "3f74c2e6-2ae0-4680-b8b2-c6daec8f9309"
                            }
                        }
                    ]
                },
                "time": {
                    "_type": "DV_DATE_TIME",
                    "value": "2020-07-30T16:59:02.097Z"
                },
                "description": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Tree"
                    },
                    "archetype_node_id": "at0001",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Service name"
                            },
                            "archetype_node_id": "at0011",
                            "value": {
                                "_type": "DV_TEXT",
                                "value": "Orthopaedics"
                            }
                        }
                    ]
                },
                "ism_transition": {
                    "_type": "ISM_TRANSITION",
                    "current_state": {
                        "_type": "DV_CODED_TEXT",
                        "value": "planned",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "openehr"
                            },
                            "code_string": "526"
                        }
                    },
                    "careflow_step": {
                        "_type": "DV_CODED_TEXT",
                        "value": "Service request sent",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "local"
                            },
                            "code_string": "at0026"
                        }
                    }
                }
            }
        ],
        [
            {
                "_type": "ACTION",
                "name": {
                    "_type": "DV_TEXT",
                    "value": "Service"
                },
                "archetype_details": {
                    "_type": "ARCHETYPED",
                    "archetype_id": {
                        "_type": "ARCHETYPE_ID",
                        "value": "openEHR-EHR-ACTION.service.v0"
                    },
                    "rm_version": "1.0.4"
                },
                "archetype_node_id": "openEHR-EHR-ACTION.service.v0",
                "language": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "ISO_639-1"
                    },
                    "code_string": "en"
                },
                "encoding": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "IANA_character-sets"
                    },
                    "code_string": "UTF-8"
                },
                "subject": {
                    "_type": "PARTY_SELF"
                },
                "protocol": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Tree"
                    },
                    "archetype_node_id": "at0015",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Receiver identifier"
                            },
                            "archetype_node_id": "at0018",
                            "value": {
                                "_type": "DV_TEXT",
                                "value": "3f74c2e6-2ae0-4680-b8b2-c6daec8f9309"
                            }
                        }
                    ]
                },
                "time": {
                    "_type": "DV_DATE_TIME",
                    "value": "2020-07-30T16:59:07.381Z"
                },
                "description": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Tree"
                    },
                    "archetype_node_id": "at0001",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Service name"
                            },
                            "archetype_node_id": "at0011",
                            "value": {
                                "_type": "DV_TEXT",
                                "value": "Dermatology clinic"
                            }
                        }
                    ]
                },
                "ism_transition": {
                    "_type": "ISM_TRANSITION",
                    "current_state": {
                        "_type": "DV_CODED_TEXT",
                        "value": "planned",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "openehr"
                            },
                            "code_string": "526"
                        }
                    },
                    "careflow_step": {
                        "_type": "DV_CODED_TEXT",
                        "value": "Service request sent",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "local"
                            },
                            "code_string": "at0026"
                        }
                    }
                }
            }
        ],
        [
            {
                "_type": "ACTION",
                "name": {
                    "_type": "DV_TEXT",
                    "value": "Service"
                },
                "archetype_details": {
                    "_type": "ARCHETYPED",
                    "archetype_id": {
                        "_type": "ARCHETYPE_ID",
                        "value": "openEHR-EHR-ACTION.service.v0"
                    },
                    "rm_version": "1.0.4"
                },
                "archetype_node_id": "openEHR-EHR-ACTION.service.v0",
                "language": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "ISO_639-1"
                    },
                    "code_string": "en"
                },
                "encoding": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "IANA_character-sets"
                    },
                    "code_string": "UTF-8"
                },
                "subject": {
                    "_type": "PARTY_SELF"
                },
                "protocol": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Tree"
                    },
                    "archetype_node_id": "at0015",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Receiver identifier"
                            },
                            "archetype_node_id": "at0018",
                            "value": {
                                "_type": "DV_TEXT",
                                "value": "3f74c2e6-2ae0-4680-b8b2-c6daec8f9309"
                            }
                        }
                    ]
                },
                "time": {
                    "_type": "DV_DATE_TIME",
                    "value": "2020-07-30T16:59:10.117Z"
                },
                "description": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Tree"
                    },
                    "archetype_node_id": "at0001",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Service name"
                            },
                            "archetype_node_id": "at0011",
                            "value": {
                                "_type": "DV_TEXT",
                                "value": "Physiotherapy"
                            }
                        }
                    ]
                },
                "ism_transition": {
                    "_type": "ISM_TRANSITION",
                    "current_state": {
                        "_type": "DV_CODED_TEXT",
                        "value": "planned",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "openehr"
                            },
                            "code_string": "526"
                        }
                    },
                    "careflow_step": {
                        "_type": "DV_CODED_TEXT",
                        "value": "Service request sent",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "local"
                            },
                            "code_string": "at0026"
                        }
                    }
                }
            }
        ]
    ]
}

and using your test template and a generated composition on Better CDR

{
    "meta": {
        "_type": "RESULTSET",
        "_created": "2020-07-30T17:14:33.899Z",
        "_executed_aql": "select a_a from EHR e contains COMPOSITION a contains ACTION a_a[openEHR-EHR-ACTION.minimal_2.v1] where a_a/ism_transition/current_state/defining_code/code_string = '526'\n"
    },
    "q": "select a_a from EHR e contains COMPOSITION a contains ACTION a_a[openEHR-EHR-ACTION.minimal_2.v1] where a_a/ism_transition/current_state/defining_code/code_string = '526'\n",
    "columns": [
        {
            "name": "#0",
            "path": "/"
        }
    ],
    "rows": [
        [
            {
                "_type": "ACTION",
                "name": {
                    "_type": "DV_TEXT",
                    "value": "Minimal 2"
                },
                "uid": {
                    "_type": "HIER_OBJECT_ID",
                    "value": "af11ae61-e303-42a4-9cd5-5a40bc19fd66"
                },
                "archetype_details": {
                    "_type": "ARCHETYPED",
                    "archetype_id": {
                        "_type": "ARCHETYPE_ID",
                        "value": "openEHR-EHR-ACTION.minimal_2.v1"
                    },
                    "rm_version": "1.0.4"
                },
                "archetype_node_id": "openEHR-EHR-ACTION.minimal_2.v1",
                "language": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "ISO_639-1"
                    },
                    "code_string": "es"
                },
                "encoding": {
                    "_type": "CODE_PHRASE",
                    "terminology_id": {
                        "_type": "TERMINOLOGY_ID",
                        "value": "IANA_character-sets"
                    },
                    "code_string": "UTF-8"
                },
                "subject": {
                    "_type": "PARTY_SELF"
                },
                "other_participations": [
                    {
                        "_type": "PARTICIPATION",
                        "function": {
                            "_type": "DV_TEXT",
                            "value": "performer"
                        },
                        "performer": {
                            "_type": "PARTY_IDENTIFIED",
                            "name": "Nurse Bailey"
                        },
                        "mode": {
                            "_type": "DV_CODED_TEXT",
                            "value": "not specified",
                            "defining_code": {
                                "_type": "CODE_PHRASE",
                                "terminology_id": {
                                    "_type": "TERMINOLOGY_ID",
                                    "value": "openehr"
                                },
                                "code_string": "193"
                            }
                        }
                    },
                    {
                        "_type": "PARTICIPATION",
                        "function": {
                            "_type": "DV_TEXT",
                            "value": "requester"
                        },
                        "performer": {
                            "_type": "PARTY_IDENTIFIED",
                            "name": "Dr. Stiles"
                        },
                        "mode": {
                            "_type": "DV_CODED_TEXT",
                            "value": "not specified",
                            "defining_code": {
                                "_type": "CODE_PHRASE",
                                "terminology_id": {
                                    "_type": "TERMINOLOGY_ID",
                                    "value": "openehr"
                                },
                                "code_string": "193"
                            }
                        }
                    }
                ],
                "time": {
                    "_type": "DV_DATE_TIME",
                    "value": "2020-07-30T17:10:23.036Z"
                },
                "description": {
                    "_type": "ITEM_TREE",
                    "name": {
                        "_type": "DV_TEXT",
                        "value": "Arbol"
                    },
                    "archetype_node_id": "at0001",
                    "items": [
                        {
                            "_type": "ELEMENT",
                            "name": {
                                "_type": "DV_TEXT",
                                "value": "Proportion"
                            },
                            "archetype_node_id": "at0002",
                            "value": {
                                "_type": "DV_PROPORTION",
                                "numerator": 79.19,
                                "denominator": 15.9,
                                "type": 4
                            }
                        }
                    ]
                },
                "ism_transition": {
                    "_type": "ISM_TRANSITION",
                    "current_state": {
                        "_type": "DV_CODED_TEXT",
                        "value": "planned",
                        "defining_code": {
                            "_type": "CODE_PHRASE",
                            "terminology_id": {
                                "_type": "TERMINOLOGY_ID",
                                "value": "openehr"
                            },
                            "code_string": "526"
                        }
                    }
                }
            }
        ]
    ]
}

But does not work with ehrbase . Interestingly, if you remove the where clause the ism_transition is not returned in either a n ACTION retreive or a full composition GET (xml or json) -looks like the ism_trnsition is just not being commited correctly.

I detected that too, the ism_transition doesn’t seem to be saved in EHRBASE.

ism_transition attribute is not present in your OPT. Why?

That might be because it was built with TD, which did not have support for ism_transition constraints. But it should not matter, should it?

I’m not sure. :slight_smile:

I would assume that if there is no constraint in the .opt then the default RM ism_transition attributes/constraints should apply. i.e everything is allowed.

1 Like

It is valid to not having any constraints for a node, that means any ism_transition is accepted.