Right now we can query as long as the data is RM compliant, even if the archetype labels in the data are not actually registerd with the CDR (or actually don’t exist!). I’m grateful because, at least for us it solved the population query demographics issue mentioned else where but it would be better if it was backed by a template for reference purposes.
Here is the structure we embed in EHR_STATUS.other_details. It is actually based on a CKM archetype
```json
----
"otherDetails": {
"@class": "ITEM_TREE",
"name": {
"@class": "DV_TEXT",
"value": "Tree"
},
"archetype_node_id": "at0001",
"items": [
{
"@class": "CLUSTER",
"name": {
"@class": "DV_TEXT",
"value": "Anonymised person (PARENT)"
},
"archetype_details": {
"@class": "ARCHETYPED",
"archetype_id": {
"@class": "ARCHETYPE_ID",
"value": "openEHR-EHR-CLUSTER.person_anonymised_parent.v0"
},
"rm_version": "1.0.1"
},
"archetype_node_id": "openEHR-EHR-CLUSTER.person_anonymised_parent.v0",
"items": [
{
"@class": "ELEMENT",
"name": {
"@class": "DV_TEXT",
"value": "Administrative Gender"
},
"archetype_node_id": "at0001",
"value": {
"@class": "DV_CODED_TEXT",
"value": "Not known",
"defining_code": {
"@class": "CODE_PHRASE",
"terminology_id": {
"@class": "TERMINOLOGY_ID",
"value": "local"
},
"code_string": "at0012"
}
}
},
{
"@class": "ELEMENT",
"name": {
"@class": "DV_TEXT",
"value": "Birth Sex"
},
"archetype_node_id": "at0002",
"value": {
"@class": "DV_CODED_TEXT",
"value": "Female",
"defining_code": {
"@class": "CODE_PHRASE",
"terminology_id": {
"@class": "TERMINOLOGY_ID",
"value": "local"
},
"code_string": "at0010"
}
}
},
{
"@class": "ELEMENT",
"name": {
"@class": "DV_TEXT",
"value": "Vital Status"
},
"archetype_node_id": "at0003",
"value": {
"@class": "DV_CODED_TEXT",
"value": "Alive",
"defining_code": {
"@class": "CODE_PHRASE",
"terminology_id": {
"@class": "TERMINOLOGY_ID",
"value": "local"
},
"code_string": "at0004"
}
}
}
]
},
{
"@class": "CLUSTER",
"name": {
"@class": "DV_TEXT",
"value": "Identifiable Person (PARENT)"
},
"archetype_details": {
"@class": "ARCHETYPED",
"archetype_id": {
"@class": "ARCHETYPE_ID",
"value": "openEHR-EHR-CLUSTER.person_identifiable_parent.v0"
},
"rm_version": "1.0.1"
},
"archetype_node_id": "openEHR-EHR-CLUSTER.person_identifiable_parent.v0",
"items": [
{
"@class": "ELEMENT",
"name": {
"@class": "DV_TEXT",
"value": "Person Identifier"
},
"archetype_node_id": "at0001",
"value": {
"@class": "DV_IDENTIFIER",
"issuer": "GOSH",
"assigner": "GOSH",
"id": "4ff62524-64bb-421d-b664-eea72ef925ee",
"type": "GOSH MRN"
}
},
{
"@class": "ELEMENT",
"name": {
"@class": "DV_TEXT",
"value": "Person Identifier"
},
"archetype_node_id": "at0001",
"value": {
"@class": "DV_IDENTIFIER",
"issuer": "GOSH",
"assigner": "GOSH",
"id": "MRN 12342345",
"type": "GOSH ANNEX MRN"
}
},
{
"@class": "ELEMENT",
"name": {
"@class": "DV_TEXT",
"value": "Year of Birth"
},
"archetype_node_id": "at0008",
"value": {
"@class": "DV_DATE_TIME",
"value": "2013"
}
}
]
}
]
}
AQLs -code snippet for creating the select
if (ctx.vars.maxAge) {
aql = aql + ' and e/ehr_status/other_details/items[openEHR-EHR-CLUSTER.person_anonymised_parent.v1]/items[at0014]/value/value <= \'' + (currentYear - ctx.vars.minAge).toString() + '\'';