Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Georg Fette
CDW_QueryMapper
Commits
aa83d00c
Commit
aa83d00c
authored
Nov 26, 2019
by
Georg Fette
Browse files
- fixed mismodeling in CONTENT_ITEM
parent
44498182
Changes
10
Hide whitespace changes
Inline
Side-by-side
QueryMapper/src/main/java/de/uniwue/query/OperatorType.java
View file @
aa83d00c
...
...
@@ -35,14 +35,14 @@ public class OperatorType {
BEFORE
,
DURATION_IN
;
// list
public
static
OperatorType
FILTER
,
COLLECT
,
FIRST
,
LAST
,
SORT
,
FIRST_N
,
EXISTS
,
DEMOTE
,
public
static
OperatorType
FILTER
,
COLLECT
,
SORT
,
FIRST_N
,
EXISTS
,
DEMOTE
,
CONTAINS_TYPE
/* , SELECT_INDEX */
;
// interval
public
static
OperatorType
END
,
START
;
// aggregation
public
static
OperatorType
COUNT
,
AVG
,
MIN
,
MAX
,
MEDIAN
,
SUM
,
STDDEV
,
VARIANCE
;
public
static
OperatorType
COUNT
,
AVG
,
MIN
,
MAX
,
MEDIAN
,
SUM
,
STDDEV
,
VARIANCE
,
FIRST
,
LAST
;
// arithmetics
public
static
OperatorType
POWER
,
ROUND
,
ABS
,
EXP
,
LOG
,
LN
,
TRUNCATE
,
FLOOR
,
CEILING
,
ADD
,
...
...
@@ -213,10 +213,6 @@ public class OperatorType {
COLLECT
=
new
OperatorType
(
"COLLECT"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
,
aModel
.
ANY
},
new
InterfaceFlags
[]
{
InterfaceFlags
.
ListOp
,
InterfaceFlags
.
ReturnSecondParamTypeAsList
});
FIRST
=
new
OperatorType
(
"FIRST"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
},
new
InterfaceFlags
[]
{
InterfaceFlags
.
ListOp
,
InterfaceFlags
.
ReturnFirstParamTypeNonList
});
LAST
=
new
OperatorType
(
"LAST"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
},
new
InterfaceFlags
[]
{
InterfaceFlags
.
ListOp
,
InterfaceFlags
.
ReturnFirstParamTypeNonList
});
SORT
=
new
OperatorType
(
"SORT"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
,
aModel
.
ANY
},
new
InterfaceFlags
[]
{
InterfaceFlags
.
ListOp
,
InterfaceFlags
.
ReturnFirstParamType
});
FIRST_N
=
new
OperatorType
(
"FIRST_N"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
,
aModel
.
INTEGER
},
...
...
@@ -254,6 +250,12 @@ public class OperatorType {
new
InterfaceFlags
[]
{
InterfaceFlags
.
IsAggregateOp
});
VARIANCE
=
new
OperatorType
(
"VARIANCE"
,
new
Concept
[]
{
aModel
.
LIST_OF_NUMBER
},
aModel
.
NUMBER
,
new
InterfaceFlags
[]
{
InterfaceFlags
.
IsAggregateOp
});
FIRST
=
new
OperatorType
(
"FIRST"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
},
new
InterfaceFlags
[]
{
InterfaceFlags
.
ListOp
,
InterfaceFlags
.
ReturnFirstParamTypeNonList
,
InterfaceFlags
.
IsAggregateOp
});
LAST
=
new
OperatorType
(
"LAST"
,
new
Concept
[]
{
aModel
.
LIST_OF_ANY
},
new
InterfaceFlags
[]
{
InterfaceFlags
.
ListOp
,
InterfaceFlags
.
ReturnFirstParamTypeNonList
,
InterfaceFlags
.
IsAggregateOp
});
// arithmetics
POWER
=
new
OperatorType
(
"POWER"
,
new
Concept
[]
{
aModel
.
NUMBER
,
aModel
.
NUMBER
},
...
...
QueryMapper/src/main/java/de/uniwue/query/QueryOperator.java
View file @
aa83d00c
...
...
@@ -146,6 +146,17 @@ public class QueryOperator extends Expression {
return
result
;
}
public
List
<
QueryOperator
>
getAncestorsWithType
(
OperatorType
aType
)
{
List
<
QueryOperator
>
result
=
new
ArrayList
<
QueryOperator
>();
if
(
parent
!=
null
)
{
result
.
addAll
(
parent
.
getAncestorsWithType
(
aType
));
if
(
parent
.
type
==
aType
)
{
result
.
add
(
parent
);
}
}
return
result
;
}
public
Model
getModel
()
{
return
model
;
}
...
...
QueryMapper/src/main/java/de/uniwue/query/cypher/Graph_2_Cypher_Mapper.java
View file @
aa83d00c
...
...
@@ -174,37 +174,31 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private
String
writeInfixOperator
(
QueryOperator
anOp
)
{
String
opString
=
opMap
.
getOpString
(
anOp
.
type
);
if
(
anOp
.
type
==
OperatorType
.
AND
)
{
opString
=
" "
+
opString
+
"\n\t"
;
}
else
{
opString
=
" "
+
opString
+
" "
;
}
List
<
String
>
expStrings
=
new
ArrayList
<
String
>();
String
result
=
""
;
boolean
first
=
true
;
for
(
Expression
anExp
:
anOp
.
getParameters
())
{
if
(
first
)
{
first
=
false
;
}
else
{
if
(
anOp
.
type
==
OperatorType
.
AND
)
{
result
+=
" "
+
opString
+
"\n\t"
;
}
else
{
result
+=
" "
+
opString
+
" "
;
}
}
String
expString
=
writeExpression
(
anExp
);
result
+=
expString
;
if
(!
expString
.
isEmpty
())
{
expStrings
.
add
(
expString
);
}
}
result
=
StringUtilsUniWue
.
concat
(
expStrings
,
opString
);
return
result
;
}
private
String
writePrefixOperator
(
QueryOperator
anOp
)
{
String
opString
=
opMap
.
getOpString
(
anOp
.
type
);
String
result
=
opString
+
"("
;
boolean
first
=
true
;
List
<
String
>
expStrings
=
new
ArrayList
<
String
>();
for
(
Expression
anExp
:
anOp
.
getParameters
())
{
if
(
first
)
{
first
=
false
;
}
else
{
result
+=
", "
;
}
result
+=
writeExpression
(
anExp
);
String
expString
=
writeExpression
(
anExp
);
expStrings
.
add
(
expString
);
}
result
+=
")"
;
String
result
=
opString
+
"("
+
StringUtilsUniWue
.
concat
(
expStrings
,
", "
)
+
")"
;
return
result
;
}
...
...
@@ -236,6 +230,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
result
=
writeExpression
(
anOp
.
getParameters
().
get
(
1
));
}
else
{
result
=
""
;
// anOp.getAncestorsWithType(OperatorType.NOT).size() == 0)
}
}
else
if
(
state
==
CypherPart
.
WITH
)
{
result
=
writeExpression
(
anOp
.
getParameters
().
get
(
0
));
...
...
QueryMapper/src/main/java/de/uniwue/query/openEHR/AQL_2_Graph_Mapper.java
View file @
aa83d00c
...
...
@@ -55,6 +55,10 @@ import de.uniwue.query.openEHR.parser.AqlParser.TopExprContext;
import
de.uniwue.query.openEHR.parser.AqlParser.ValueListItemsContext
;
import
de.uniwue.query.openEHR.parser.AqlParser.WhereContext
;
/*
* This is a deprecated version of the AQL_2_Graph_Mapper. It only exists for all old tests to still work.
* The newer version of this class is in the openEHR2 package
* */
public
class
AQL_2_Graph_Mapper
extends
System_2_Graph_Mapper
{
private
String
currentExternalAlias
;
...
...
QueryMapper/src/main/java/de/uniwue/query/openEHR2/AQL_2_Graph_Mapper.java
View file @
aa83d00c
...
...
@@ -476,9 +476,11 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
QueryOperator
filter
=
insertOp
(
OperatorType
.
FILTER
);
String
newAliasName
=
getNewAliasName
();
fieldOp
.
alias
=
newAliasName
;
QueryOperator
is
=
addOp
(
OperatorType
.
IS
);
addAliasRef
(
is
,
newAliasName
);
currentOp
.
addParameter
(
singleNodePredicateComparableName
);
QueryOperator
equals
=
addOp
(
OperatorType
.
EQUALS
);
QueryOperator
archetypeIDField
=
addOp
(
OperatorType
.
FIELD
);
addAliasRef
(
archetypeIDField
,
newAliasName
);
archetypeIDField
.
addParameter
(
"archetype_node_id"
);
equals
.
addParameter
(
singleNodePredicateComparableName
);
lastPathElem
=
filter
;
}
else
{
fieldOp
=
insertOp
(
OperatorType
.
INDEXED_FIELD
);
...
...
QueryMapper/src/main/resources/models/openEHR/StructureDefs_openEHR_RM/InformationModel/CONTENT_ITEM.xml
View file @
aa83d00c
<StructureDefinition>
<url
value=
"http://hl7.org/fhir/StructureDefinition/CONTENT_ITEM"
/>
<baseDefinition
value=
"http://hl7.org/fhir/StructureDefinition/
DomainResource
"
/>
<baseDefinition
value=
"http://hl7.org/fhir/StructureDefinition/
LOCATABLE
"
/>
<id
value=
"CONTENT_ITEM"
/>
<name
value=
"CONTENT_ITEM"
/>
<type
value=
"CONTENT_ITEM"
/>
...
...
@@ -11,5 +11,53 @@
<min
value=
"0"
/>
<max
value=
"*"
/>
</element>
<element
id=
"CONTENT_ITEM.name"
>
<path
value=
"CONTENT_ITEM.name"
/>
<min
value=
"1"
/>
<max
value=
"1"
/>
<type>
<code
value=
"DV_TEXT"
/>
</type>
</element>
<element
id=
"CONTENT_ITEM.archetype_node_id"
>
<path
value=
"CONTENT_ITEM.archetype_node_id"
/>
<min
value=
"1"
/>
<max
value=
"1"
/>
<type>
<code
value=
"string"
/>
</type>
</element>
<element
id=
"CONTENT_ITEM.uid"
>
<path
value=
"CONTENT_ITEM.uid"
/>
<min
value=
"1"
/>
<max
value=
"1"
/>
<type>
<code
value=
"UID_BASED_ID"
/>
</type>
</element>
<element
id=
"CONTENT_ITEM.links"
>
<path
value=
"CONTENT_ITEM.links"
/>
<min
value=
"0"
/>
<max
value=
"*"
/>
<type>
<code
value=
"LINK"
/>
</type>
</element>
<element
id=
"CONTENT_ITEM.archetype_details"
>
<path
value=
"CONTENT_ITEM.archetype_details"
/>
<min
value=
"0"
/>
<max
value=
"1"
/>
<type>
<code
value=
"ARCHETYPED"
/>
</type>
</element>
<element
id=
"CONTENT_ITEM.feeder_audit"
>
<path
value=
"CONTENT_ITEM.feeder_audit"
/>
<min
value=
"0"
/>
<max
value=
"1"
/>
<type>
<code
value=
"FEEDER_AUDIT"
/>
</type>
</element>
</snapshot>
</StructureDefinition>
QueryMapper/src/main/resources/models/openEHR/openEHR_model.json
View file @
aa83d00c
...
...
@@ -1834,8 +1834,32 @@
"parent" : "LOCATABLE"
}, {
"name" : "CONTENT_ITEM",
"fields" : [ ],
"parent" : "DomainResource"
"fields" : [ {
"name" : "name",
"possibleTypes" : [ "DV_TEXT" ],
"isArray" : false
}, {
"name" : "archetype_node_id",
"possibleTypes" : [ "string" ],
"isArray" : false
}, {
"name" : "uid",
"possibleTypes" : [ "UID_BASED_ID" ],
"isArray" : false
}, {
"name" : "links",
"possibleTypes" : [ "LINK" ],
"isArray" : true
}, {
"name" : "archetype_details",
"possibleTypes" : [ "ARCHETYPED" ],
"isArray" : false
}, {
"name" : "feeder_audit",
"possibleTypes" : [ "FEEDER_AUDIT" ],
"isArray" : false
} ],
"parent" : "LOCATABLE"
}, {
"name" : "EHR",
"fields" : [ {
QueryMapper/src/test/java/de/uniwue/query/Test_AQL_2_Cypher.java
View file @
aa83d00c
...
...
@@ -19,15 +19,15 @@ public class Test_AQL_2_Cypher {
public
static
void
main
(
String
[]
args
)
throws
IOException
,
QueryParseException
{
Test_AQL_2_Cypher
test
=
new
Test_AQL_2_Cypher
();
//
test.debugTest();
test
.
testAQL_2_Cypher
();
test
.
debugTest
();
//
test.testAQL_2_Cypher();
}
public
void
debugTest
()
throws
QueryParseException
,
IOException
{
initialize
();
QueryManager
queryManager
=
new
QueryManager
();
for
(
MultiQuery
aMultiQuery
:
queryManager
.
queries
)
{
if
(
aMultiQuery
.
name
.
equals
(
"query_AQL_2_Cypher_not
2
"
))
{
if
(
aMultiQuery
.
name
.
equals
(
"query_AQL_2_Cypher_not
_exists1
"
))
{
processQuery
(
aMultiQuery
);
}
}
...
...
QueryMapper/src/test/resources/queries/notYetWorkingAQL_2_Cypher/query_AQL_2_Cypher_not_exists1.txt
View file @
aa83d00c
...
...
@@ -26,8 +26,11 @@ QUERY(
ALIAS_REF('a'),
'content'
) as C,
IS(
ALIAS_REF('C'),
EQUALS(
FIELD(
ALIAS_REF('C'),
'archetype_node_id'
),
'openEHR-EHR-ADMIN_ENTRY.discharge_summary.v0'
)
)))
...
...
@@ -44,10 +47,10 @@ the cypher query is not ready yet.
MATCH
(A:EHR)-[*]->(B:COMPOSITION), (B)-[*]->(C:ADMIN_ENTRY)
OPTIONAL MATCH
(B)-[*]->(
C
:ADMIN_ENTRY)
(B)-[*]->(
D
:ADMIN_ENTRY)
WHERE
B.archetype_node_id = 'openEHR-EHR-COMPOSITION.encounter.v1' AND
C.archetype_node_id = 'openEHR-EHR-ADMIN_ENTRY.admission.v0' AND
NOT
EXISTS(
)
NOT
(C.archetype_node_id = 'openEHR-EHR-ADMIN_ENTRY.discharge_summary.v0'
)
RETURN
A
QueryMapper/src/test/resources/queries/
notYetW
orkingAQL_2_Cypher/query_AQL_2_Cypher_not2.txt
→
QueryMapper/src/test/resources/queries/
w
orking
_
AQL_2_Cypher/query_AQL_2_Cypher_not2.txt
View file @
aa83d00c
...
...
@@ -53,7 +53,6 @@ QUERY(
MATCH
(A:EHR), (A)-[:ehr_status]->(B:EHR_STATUS), (A)-[:ehr_id]->(C:HIER_OBJECT_ID), (A)-[*]->(D:COMPOSITION), (B)-[:subject]->(E:PARTY_SELF), (E)-[:external_ref]->(F:PARTY_REF), (D)-[*]->(G:ADMIN_ENTRY)
WHERE
AND
NOT(F.namespace = 'CEC') AND
D.archetype_node_id = 'openEHR-EHR-COMPOSITION.encounter.v1' AND
G.archetype_node_id = 'openEHR-EHR-ADMIN_ENTRY.admission.v0'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment