# AQL with Demographics **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2015-01-15 09:28 UTC **Views:** 4 **Replies:** 3 **URL:** https://discourse.openehr.org/t/aql-with-demographics/15342 --- ## Post #1 by @Alessandro_Torrisi Hello, did any off you thought about how a query should look like suppose I want such like this : "Give me all **female** patients living in **Paris** and with **no allergies** and a **the last labresult of type Kreatine is < 20 but within a year**" The hardest part is to combine the demographic information with the medical information. Should you be able to do it with AQL? --- ## Post #2 by @thomas.beale An earlier private response to Alessandro before he posted: It might be interesting to find out what other implementers are doing. - thomas --- ## Post #3 by @Karsten_Hilbert > >the first question is: is the patient sex and location stored in the EHR > >in the system? If so, it's just standard EHR\-based query\. > > > >I'm assuming that the location / address is not however\. So a normal query > >can be written to do everything except the 'living in Alkmaar' bit\. That's exactly the boundary between systems "built for" medical care vs "built for" epidemiology\. Both may have requirements that are contrary to each other, such as this: > >That last item will need a traversal of the reference > >PARTY\_PROXY\.external\_ref <http://www.openehr.org/local/releases/1.0.1/uml/Browsable/_9_5_1_76d0249_1140169202660_257304_813Report.html>, > >if you have it set\. But you might not have it set \- we don't in most of > >our systems, due to privacy / security\. Karsten --- ## Post #4 by @system Hi Alessandro Very good question\. I know that some implementers store 'basic query demographics' in a single persistent composition with an archetype representing dob, sex, gender etc, to get around this although it to some extent weakens the ehr / Demographics split\. One approach I would like to see pursued is that we develop a standardised approach using similar archetypes in a 'demographics composition' but allowing the backend system to choose whether the data was sourced from the EHR that composition, or retrieved virtually from a seaprate Demographics engine as Thomas was suggesting\. That would let us standardise the AQL statements but allow implementers to meet the needs of different groups as Karsten was suggesting\. Patient registries is an example of where it is more compelling to hold some demographics data in situ\. I have done a little work on this for the EU PARENT project\. This is the anonymised patient details archetype http://www.openehr.org/ckm/#showArchetype_1013.1.1745 and seen in use at http://www.openehr.org/ckm/#showTemplate_1013.26.16 For review purposes, in this template, the anonymised archetype is carried in the same composition \- this would not be the case in a run time example\. So in this case a standard AQL could be used to retrieve "Give me all female patients living in Paris and with no allergies and a the last labresult of type Kreatine is < 20 but within a year" but how the age, sex, location data is actually resolved is implementation dependent\. Ian Dr Ian McNicoll mobile \+44 \(0\)775 209 7859 office \+44 \(0\)1536 414994 skype: ianmcnicoll email: ian@freshehr\.com twitter: @ianmcnicoll Director, freshEHR Clinical Informatics Director, openEHR Foundation Director, HANDIHealth CIC Hon\. Senior Research Associate, CHIME, UCL --- **Canonical:** https://discourse.openehr.org/t/aql-with-demographics/15342 **Original content:** https://discourse.openehr.org/t/aql-with-demographics/15342