Skip to content

Commit

Permalink
[CDR-1173] aggregate function on dv ordered (#14)
Browse files Browse the repository at this point in the history
* CDR-1225 Add supported Min/Max/Count for DV_ORDERED

* CDR-1225 Add not implemented test for Sum/Avg on DV_ORDERED

* CDR-1225 Extend count tests for aggregations on DV_ORDERED

* CDR-1225 adjust Robot test suites, test data files for CDR-1173

* CDR-1225 add missing tests, covering ticket CDR-1173

---------

Co-authored-by: vladislavploaia <[email protected]>
  • Loading branch information
alexlehn and vladislavploaia authored Feb 7, 2024
1 parent 9641fdf commit 6e9b078
Show file tree
Hide file tree
Showing 45 changed files with 638 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
*** Settings ***
Documentation CHECK AGGREGATE FUNCTIONS AVG NOT IMPLEMENTED ON DV_ORDERED IN AQL
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md#avg-on-dv-ordered
Resource ../../../_resources/keywords/aql_keywords.robot

Library DataDriver
... file=${PROJECT_ROOT}/tests/robot/_resources/test_data_sets/aql/fields_and_results/aggregate_functions/combinations/avg_on_dv_ordered.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
SELECT AVG(${path}) FROM OBSERVATION o [openEHR-EHR-OBSERVATION.conformance_observation.v0]
[Template] Execute Query
${path} ${expected_file}


*** Keywords ***
Precondition
Upload OPT For AQL conformance_ehrbase.de.v0.opt
Create EHR For AQL
Commit Composition For AQL conformance_ehrbase.de.v0_max_v3.json

Execute Query
[Arguments] ${path} ${expected_file}
${query} Set Variable SELECT AVG(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
Set AQL And Execute Ad Hoc Query ${query}

${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/aggregate_functions/${expected_file}
${exclude_paths} Create List root['meta']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}

Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
*** Settings ***
Documentation CHECK AGGREGATE FUNCTIONS MAX ON DV_ORDERED IN AQL
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md#max-on-dv-ordered
... - *Precondition:* 1. Create OPT; 2. Create EHR; 3. Create Composition.
... - *Postcondition:* Delete EHR using ADMIN endpoint. This is deleting compositions linked to EHR.
Resource ../../../_resources/keywords/aql_keywords.robot

Library DataDriver
... file=${PROJECT_ROOT}/tests/robot/_resources/test_data_sets/aql/fields_and_results/aggregate_functions/combinations/max_on_dv_ordered.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
SELECT MAX(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
[Template] Execute Query
${path} ${expected_file}


*** Keywords ***
Precondition
Upload OPT For AQL conformance_ehrbase.de.v0.opt
Create EHR For AQL
Commit Composition For AQL conformance_ehrbase.de.v0_max_v3.json

Execute Query
[Arguments] ${path} ${expected_file}
${query} Set Variable SELECT MAX(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
Set AQL And Execute Ad Hoc Query ${query}

${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/aggregate_functions/${expected_file}
${exclude_paths} Create List root['meta']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}

Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
*** Settings ***
Documentation CHECK AGGREGATE FUNCTIONS MAX ON DV_TEXT AND DV_CODED_TEXT ON DV_ORDERED IN AQL
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md
Resource ../../../_resources/keywords/aql_keywords.robot

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Variables ***
${query_max_1} SELECT MAX(o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value), o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
${query_max_2} SELECT MAX(o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value), o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]


*** Test Cases ***
${query_max_1}
Set Test Variable ${query} ${query_max_1}
Execute Query expected_max_dv_text_dv_coded_text_at4.json

${query_max_2}
Set Test Variable ${query} ${query_max_2}
Execute Query expected_max_dv_text_dv_coded_text_at5.json


*** Keywords ***
Precondition
Upload OPT For AQL conformance_ehrbase.de.v0.opt
Create EHR For AQL
Commit Composition For AQL conformance_ehrbase.de.v0_max_v3.json

Execute Query
[Arguments] ${expected_file}
Set AQL And Execute Ad Hoc Query ${query}

${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/aggregate_functions/${expected_file}
${exclude_paths} Create List root['meta']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}

Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
*** Settings ***
Documentation CHECK AGGREGATE FUNCTIONS MIN ON DV_ORDERED IN AQL
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md#min-on-dv_ordered
... - *Precondition:* 1. Create OPT; 2. Create EHR; 3. Create Composition.
... - *Postcondition:* Delete EHR using ADMIN endpoint. This is deleting compositions linked to EHR.
Resource ../../../_resources/keywords/aql_keywords.robot

Library DataDriver
... file=${PROJECT_ROOT}/tests/robot/_resources/test_data_sets/aql/fields_and_results/aggregate_functions/combinations/min_on_dv_ordered.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
SELECT MIN(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
[Template] Execute Query
${path} ${expected_file}


*** Keywords ***
Precondition
Upload OPT For AQL conformance_ehrbase.de.v0.opt
Create EHR For AQL
Commit Composition For AQL conformance_ehrbase.de.v0_max_v3.json

Execute Query
[Arguments] ${path} ${expected_file}
${query} Set Variable SELECT MIN(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
Set AQL And Execute Ad Hoc Query ${query}

${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/aggregate_functions/${expected_file}
${exclude_paths} Create List root['meta']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}

Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
*** Settings ***
Documentation CHECK AGGREGATE FUNCTIONS AVG NOT IMPLEMENTED ON DV_ORDERED IN AQL
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md#sum-on-dv-ordered
Resource ../../../_resources/keywords/aql_keywords.robot

Library DataDriver
... file=${PROJECT_ROOT}/tests/robot/_resources/test_data_sets/aql/fields_and_results/aggregate_functions/combinations/sum_on_dv_ordered.csv
... dialect=excel

Suite Setup Precondition
Suite Teardown Admin Delete EHR For AQL


*** Test Cases ***
SELECT SUM(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
[Template] Execute Query
${path} ${expected_file}


*** Keywords ***
Precondition
Upload OPT For AQL conformance_ehrbase.de.v0.opt
Create EHR For AQL
Commit Composition For AQL conformance_ehrbase.de.v0_max_v3.json

Execute Query
[Arguments] ${path} ${expected_file}
${query} Set Variable SELECT SUM(${path}) FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]
Set AQL And Execute Ad Hoc Query ${query}

${expected_result} Set Variable ${EXPECTED_JSON_DATA_SETS}/aggregate_functions/${expected_file}
${exclude_paths} Create List root['meta']
${diff} compare json-string with json-file
... ${resp_body_actual} ${expected_result}
... exclude_paths=${exclude_paths}
... ignore_order=${TRUE}
... ignore_string_case=${TRUE}

Should Be Empty ${diff} msg=DIFF DETECTED!
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*** Settings ***
Documentation CHECK AGGREGATE FUNCTIONS IN AQL
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md#min
... - Covers: https://github.com/ehrbase/AQL_Test_CASES/blob/main/AGGREGATE_FUNCTIONS.md#max
... - *Precondition:* 1. Create OPT; 2. Create EHR; 3. Create Composition.
... - *Postcondition:* Delete EHR using ADMIN endpoint. This is deleting compositions linked to EHR.
Resource ../../../_resources/keywords/aql_keywords.robot
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
${path},${expected_file}
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value",expected_avg_on_dv_ordered_at8_quantity.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0009]/value",expected_avg_on_dv_ordered_at9_proportion.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0010]/value",expected_avg_on_dv_ordered_at10_count.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0011]/value",expected_avg_on_dv_ordered_at11_datetime.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0012]/value",expected_avg_on_dv_ordered_at12_time.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0013]/value",expected_avg_on_dv_ordered_at13_date.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0014]/value",expected_avg_on_dv_ordered_at14_ordinal.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0018]/value",expected_avg_on_dv_ordered_at18_duration.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
${path},${nr_of_results},${expected_value}
"*",1,1
"o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value",1,3
"o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/value",1,3
"o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value",1,3
"o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value/value",1,3
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value",1,2
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value/units",1,2
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value/magnitude",1,2
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/null_flavour/value",1,1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
${path},${expected_file}
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value",expected_max_on_dv_ordered_at8_quantity.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0009]/value",expected_max_on_dv_ordered_at9_proportion.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0010]/value",expected_max_on_dv_ordered_at10_count.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0011]/value",expected_max_on_dv_ordered_at11_datetime.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0012]/value",expected_max_on_dv_ordered_at12_time.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0013]/value",expected_max_on_dv_ordered_at13_date.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0014]/value",expected_max_on_dv_ordered_at14_ordinal.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0018]/value",expected_max_on_dv_ordered_at18_duration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
${path},${expected_file}
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value",expected_min_on_dv_ordered_at8_quantity.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0009]/value",expected_min_on_dv_ordered_at9_proportion.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0010]/value",expected_min_on_dv_ordered_at10_count.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0011]/value",expected_min_on_dv_ordered_at11_datetime.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0012]/value",expected_min_on_dv_ordered_at12_time.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0013]/value",expected_min_on_dv_ordered_at13_date.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0014]/value",expected_min_on_dv_ordered_at14_ordinal.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0018]/value",expected_min_on_dv_ordered_at18_duration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
${path},${expected_file}
"o/data[at0001]/events[at0002]/data[at0003]/items[at0008]/value",expected_sum_on_dv_ordered_at8_quantity.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0009]/value",expected_sum_on_dv_ordered_at9_proportion.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0010]/value",expected_sum_on_dv_ordered_at10_count.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0011]/value",expected_sum_on_dv_ordered_at11_datetime.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0012]/value",expected_sum_on_dv_ordered_at12_time.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0013]/value",expected_sum_on_dv_ordered_at13_date.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0014]/value",expected_sum_on_dv_ordered_at14_ordinal.json
"o/data[at0001]/events[at0002]/data[at0003]/items[at0018]/value",expected_sum_on_dv_ordered_at18_duration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"meta": {
"_type": "RESULTSET",
"_schema_version": "1.0.4",
"_created": "2024-02-07T14:27:03.3849392+02:00",
"_executed_aql": "SELECT MAX(o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value), o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]",
"resultsize": 3
},
"q": "SELECT MAX(o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value), o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]",
"columns": [
{
"name": "#0"
},
{
"path": "o/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value",
"name": "#1"
}
],
"rows": [
[
null,
{
"_type": "DV_TEXT",
"value": "Lorem ipsum2"
}
],
[
null,
{
"_type": "DV_TEXT",
"value": "Lorem ipsum",
"mappings": [
{
"_type": "TERM_MAPPING",
"match": "=",
"target": {
"_type": "CODE_PHRASE",
"terminology_id": {
"_type": "TERMINOLOGY_ID",
"value": "SNOMED-CT"
},
"code_string": "21794005"
}
},
{
"_type": "TERM_MAPPING",
"match": ">",
"target": {
"_type": "CODE_PHRASE",
"terminology_id": {
"_type": "TERMINOLOGY_ID",
"value": "SNOMED-CT"
},
"code_string": "21794000"
}
}
]
}
],
[
null,
{
"_type": "DV_TEXT",
"value": "Lorem ipsum3"
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"meta": {
"_type": "RESULTSET",
"_schema_version": "1.0.4",
"_created": "2024-02-07T14:27:07.9863062+02:00",
"_executed_aql": "SELECT MAX(o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value), o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]",
"resultsize": 1
},
"q": "SELECT MAX(o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value), o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value FROM OBSERVATION o[openEHR-EHR-OBSERVATION.conformance_observation.v0]",
"columns": [
{
"name": "#0"
},
{
"path": "o/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value",
"name": "#1"
}
],
"rows": [
[
null,
{
"_type": "DV_CODED_TEXT",
"value": "term1",
"defining_code": {
"_type": "CODE_PHRASE",
"terminology_id": {
"_type": "TERMINOLOGY_ID",
"value": "local"
},
"code_string": "at0006"
}
}
]
]
}
Loading

0 comments on commit 6e9b078

Please sign in to comment.