Hi,
In a template with an archetype with multiple occurrence and more than one attribute with multiple occurrences, will I be able to query and get a specific instance for a given value of the attribute.
Consider the following example
Problem diagnosis : cardinality 0..*
- Problem diagnosis name : cardinality 0..1
- Body site : cardinality 0..*
- Cause : cardinality 0..*
Example:
Problem diagnosis[0]
Problem diagnosis name = "oral precancerous lesion"
Body site[0] = "inner lining of the cheeks"
Body site[1] = "floor of the mouth"
Body site[2] = "lips"
Cause[0] - "tobacco use"
Cause[1] - "drinking alcohol"
Problem diagnosis[1]
Problem diagnosis name = "lymphedema"
Body site[0] = "face"
Body site[1] = "neck"
Cause[0] - "surgical treatment"
Cause[1] - "lymph node removal"
AQL query to get the Problem diagnosis where Body site = “lips”
SELECT
e1/data[at0001]
FROM
ehr e
CONTAINS
composition c[openEHR-EHR-COMPOSITION.encounter.v1]
contains evaluation e1[openEHR-EHR-EVALUATION.problem_diagnosis.v1]
WHERE
e1/data[at0001]/items[at0012]/value/value ='lips'
c/archetype_details/template_id/value='test_problem_diagnosis'
This returns both the instances of problem diagnosis.
If I select both the attributes the response results in Cartesian product issue.
SELECT
e1/data[at0001]/items[at0002]/value/value as problem_diagnosis_name,
e1/data[at0001]/items[at0012]/value/value as body_site,
e1/data[at0001]/items[at0078]/value/value as cause
FROM
ehr e
CONTAINS
composition c[openEHR-EHR-COMPOSITION.encounter.v1]
contains evaluation e1[openEHR-EHR-EVALUATION.problem_diagnosis.v1]
WHERE
e1/data[at0001]/items[at0012]/value/value ='lips'
c/archetype_details/template_id/value='test_problem_diagnosis'
Response
[
"oral precancerous lesion",
"inner lining of the cheeks",
"tobacco use"
]
[
"oral precancerous lesion",
"floor of the mouth",
"tobacco use"
]
[
"oral precancerous lesion",
"lips",
"tobacco use"
]
[
"oral precancerous lesion",
"face",
"tobacco use"
]
[
"oral precancerous lesion",
"neck",
"tobacco use"
]
The last two rows is due to cartesian product issue.
Is the AQL query with select for the multiple occurrence of the attribute a valid query?
If not what is the expected query?
How do we avoid the Cartesian product issue.
Attached is the sample opt, example flat json, aql and its result.
Note, we are using EHRBase as the CDR.
test_problem_diagnosis.opt (95.2 KB)
aql_response_multiple_cardinality.json (5.8 KB)
flat_json_multiple_cardinality_issue.json (2.6 KB)