Commit 0fb00c92 authored by Georg Fette's avatar Georg Fette
Browse files

- fixed returning of object graphs

- aql now removed some primitve type nodes values from its concept
structure
parent 720c7789
......@@ -6,7 +6,7 @@ public abstract class Expression {
// an identifier with which the expression can be identified inside the returned results
public String outputName;
public String alias;
public QueryOperator parent;
......@@ -20,12 +20,11 @@ public abstract class Expression {
}
public boolean isConcept() {
boolean result;
if (isOperator()) {
QueryOperator thisAsOp = asOperator();
if ((thisAsOp.type == OperatorType.ITERATE) || (thisAsOp.type == OperatorType.FIELD)
|| (thisAsOp.type == OperatorType.FIELD_WITH_TYPE)
|| (thisAsOp.type == OperatorType.ALIAS_REF)) {
|| (thisAsOp.type == OperatorType.INDEXED_FIELD) || (thisAsOp.type == OperatorType.FIELD_WITH_TYPE)
|| (thisAsOp.type == OperatorType.ALIAS_REF) || (thisAsOp.type == OperatorType.CONTAINS_TYPE)) {
return true;
}
}
......@@ -45,7 +44,7 @@ public abstract class Expression {
}
public abstract Expression clone();
public abstract Concept getDataType();
}
......@@ -366,14 +366,14 @@ public class QueryOperator extends Expression {
public List<QueryOperator> getChildConceptsRecursive() {
List<QueryOperator> result = new ArrayList<QueryOperator>();
for (QueryOperator aChildConc : getChildConcepts()) {
List<QueryOperator> childConcepts = getChildConcepts();
for (QueryOperator aChildConc : childConcepts) {
result.add(aChildConc);
result.addAll(aChildConc.getChildConceptsRecursive());
}
return result;
}
public List<QueryOperator> getChildConcepts() {
if (type == OperatorType.ALIAS_REF) {
return resolveAlias().getChildConcepts();
......@@ -384,8 +384,9 @@ public class QueryOperator extends Expression {
allAliasRefs.add(this);
for (QueryOperator anAliasRef : allAliasRefs) {
QueryOperator aliasParent = anAliasRef.parent;
if ((aliasParent.type == OperatorType.FIELD) || (aliasParent.type == OperatorType.INDEXED_FIELD)) {
String fieldName = aliasParent.getParameters().get(1).asPrimitive().value;
if ((aliasParent.type == OperatorType.FIELD) || (aliasParent.type == OperatorType.INDEXED_FIELD)
|| (aliasParent.type == OperatorType.CONTAINS_TYPE)) {
// String fieldName = aliasParent.getParameters().get(1).asPrimitive().value;
// if (!existingFields.contains(fieldName)) {
// there can be a multiple access on the same field without an alias,
// e.g. "A.value.a == A.value.b" means implicitly that the two "A.value" are the same
......@@ -403,25 +404,6 @@ public class QueryOperator extends Expression {
return result;
}
public List<QueryOperator> getContainsTypeChildConcepts() {
if (type == OperatorType.ALIAS_REF) {
return resolveAlias().getChildConcepts();
}
List<QueryOperator> result = new ArrayList<QueryOperator>();
List<QueryOperator> allAliasRefs = getRoot().getAliasRefsWithAlias(alias);
for (QueryOperator anAliasRef : allAliasRefs) {
QueryOperator aliasParent = anAliasRef.parent;
if (aliasParent.type == OperatorType.CONTAINS_TYPE) {
String fieldName = aliasParent.getParameters().get(1).asPrimitive().value;
result.add(aliasParent);
}
}
if ((parent.type == OperatorType.FILTER) && (parent.alias != null)) {
result.addAll(parent.getChildConcepts());
}
return result;
}
public QueryOperator getFirstRootConcept() {
List<QueryOperator> rootConcepts = getRootConcepts();
if (rootConcepts.size() > 0) {
......
......@@ -9,6 +9,7 @@ import java.util.List;
import java.util.Set;
import de.uniwue.misc.util.StringUtilsUniWue;
import de.uniwue.model.Concept;
import de.uniwue.model.Model;
import de.uniwue.query.Expression;
import de.uniwue.query.Graph_2_System_Mapper;
......@@ -116,6 +117,8 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
String pathSourceString = writeExpression(pathSource);
String pathEndString = writeExpression(pathEnd);
result = pathSourceString + "." + pathEndString;
} else if (anOp.type == OperatorType.INDEXED_FIELD) {
result = "";
} else if (infixOps.contains(anOp.type)) {
result = writeInfixOperator(anOp);
} else if (prefixOps.contains(anOp.type)) {
......@@ -140,8 +143,8 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
output = aConc.outputName;
}
output = StringUtilsUniWue.cleanStringFromSpecialCharacters(output);
result += "_paths as " + output + "p, extract(r in relationships(" + alias + "_paths) | type(r)) as " + output
+ "_relationships, extract(n in nodes(" + alias + "_paths) | labels(n)) as " + output + "_nodetypes";
result = "last(nodes(" + result + "_paths)) as " + output + "_rm_object, extract(r in relationships(" + alias
+ "_paths) | type(r)) as " + output + "_relationships";
}
} else if (aConc.type == OperatorType.INDEXED_FIELD) {
// the INDEXED_FIELDS are already handled in the Match via aliases
......@@ -151,6 +154,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
} else {
QueryOperator asConcept = aConc.getParameters().get(0).asConcept();
String pathPart = writeExpression(asConcept);
Concept dataType = aConc.getDataType();
result = pathPart + "." + aConc.getIteratorSelector();
}
return result;
......@@ -327,6 +331,9 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
}
private boolean isRelation(QueryOperator aConc, QueryOperator aPossibleRel) {
if (aPossibleRel.type == OperatorType.CONTAINS_TYPE) {
return false;
}
String propertyType = getPropertyType(aConc, aPossibleRel);
if (propertyType == null) {
throw new RuntimeException("unknown property of concept '" + aConc.getIteratorSelector() + "'");
......@@ -374,11 +381,11 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
String relString = write_FIELD_Relation(aConc, aRel);
resultRelations.add(relString);
}
if (aRel.type == OperatorType.CONTAINS_TYPE) {
String relString = write_CONTAINS_TYPE_Relation(aConc, aRel);
resultRelations.add(relString);
}
}
List<String> resultContainsTypeRelations = writeContainsTypeRelations(aConc);
resultRelations.addAll(resultContainsTypeRelations);
List<QueryOperator> containsTypeChildConcepts = aConc.getContainsTypeChildConcepts();
childConcepts.addAll(containsTypeChildConcepts);
for (QueryOperator aChild : childConcepts) {
List<String> resultSubRelations = writeRelations(aChild);
resultRelations.addAll(resultSubRelations);
......@@ -386,17 +393,6 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
return resultRelations;
}
private List<String> writeContainsTypeRelations(QueryOperator aConc) {
List<String> resultRelations = new ArrayList<String>();
String alias = aliases.get(aConc);
List<QueryOperator> childConcepts = aConc.getContainsTypeChildConcepts();
for (QueryOperator aRel : childConcepts) {
String relString = write_CONTAINS_TYPE_Relation(aConc, aRel);
resultRelations.add(relString);
}
return resultRelations;
}
private String write_CONTAINS_TYPE_Relation(QueryOperator aConc, QueryOperator aRel) {
String sourceAlias = aliases.get(aConc);
String targetType = aRel.getParameters().get(1).asPrimitive().value;
......@@ -544,10 +540,12 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private String writeCalls() {
List<String> resultStrings = new ArrayList<String>();
for (QueryOperator aConc : query.getConcepts()) {
List<QueryOperator> concepts = query.getConcepts();
for (QueryOperator aConc : concepts) {
if (aConc.hasToBeReturned() && retrieveAllChildNodesInResult) {
String alias = aliases.get(aConc);
resultStrings.add("CALL apoc.path.spanningTree(" + alias + ", {}) yield path as " + alias + "_paths\n");
resultStrings.add("CALL apoc.path.spanningTree(" + alias + ", {relationshipFilter:'>'}) yield path as " + alias
+ "_paths");
}
}
String result = StringUtilsUniWue.concat(resultStrings, "\n").trim();
......
package de.uniwue.query.openEHR2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -15,6 +16,7 @@ import org.antlr.v4.runtime.tree.TerminalNode;
import com.google.common.collect.Lists;
import de.uniwue.model.Concept;
import de.uniwue.model.Model;
import de.uniwue.query.Expression;
import de.uniwue.query.OperatorType;
......@@ -110,9 +112,23 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
query.removeUnnecessaryANDs();
repairDemotions(query);
removeUnnecessaryFilters();
removeDataValueWrapper();
return query;
}
private Set<String> primitiveTypes = new HashSet<String>(Arrays.asList(new String[] { "DV_BOOLEAN", "DV_COUNT",
"DV_DATE_TIME", "DV_DATE", "DV_EHR_URI", "DV_IDENTIFIER", "DV_TEXT", "DV_TIME", "DV_URI" }));
private void removeDataValueWrapper() {
for (QueryOperator anOp : query.getOpsRecursiveWithType(OperatorType.FIELD)) {
Concept dataType = anOp.getParentConcept().getDataType();
if (primitiveTypes.contains(dataType.name)) {
anOp.replaceParameter(anOp.getParameters().get(0),
anOp.getParameters().get(0).asOperator().getParameters().get(0));
}
}
}
private void removeUnnecessaryFilters() {
for (QueryOperator aFilter : query.getOpsRecursiveWithType(OperatorType.FILTER)) {
if (aFilter.getParameters().size() == 1) {
......
......@@ -27,7 +27,7 @@ public class Test_AQL_2_Cypher {
initialize();
QueryManager queryManager = new QueryManager();
for (MultiQuery aMultiQuery : queryManager.queries) {
if (aMultiQuery.name.equals("query_AQL_2_Cypher_anamnese")) {
if (aMultiQuery.name.equals("query_AQL_2_Cypher_2Attrs_ReturnAttrs")) {
processQuery(aMultiQuery);
}
}
......
......@@ -16,13 +16,10 @@ QUERY(
) as a,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
),
......@@ -37,9 +34,9 @@ QUERY(
MATCH
(A:EHR), (A)-[*]->(B:CLUSTER), (B)-[:items]->(C:ELEMENT)
WHERE
C.value.value = 'Natrium_g_dl' AND
C.value = 'Natrium_g_dl' AND
C.archetype_node_id = 'at0024' AND
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -30,6 +30,6 @@ MATCH
WHERE
B.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1' AND
C.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -18,13 +18,10 @@ QUERY(
) as a,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
),
......@@ -39,13 +36,10 @@ QUERY(
) as b,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('b'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('b'),
'items',
'at0024'
),
'value'
),
......@@ -78,8 +72,8 @@ QUERY(
MATCH
(A:EHR), (A)-[*]->(B:CLUSTER), (A)-[*]->(C:CLUSTER), (B)-[:items]->(D:ELEMENT), (B)-[:items]->(E:ELEMENT), (E)-[:value]->(F:DATA_VALUE), (C)-[:items]->(G:ELEMENT), (C)-[:items]->(H:ELEMENT), (H)-[:value]->(I:DATA_VALUE)
WHERE
D.value.value = 'Natrium_g_dl' AND
G.value.value = 'H_moglobin_g_dl' AND
D.value = 'Natrium_g_dl' AND
G.value = 'H_moglobin_g_dl' AND
D.archetype_node_id = 'at0024' AND
G.archetype_node_id = 'at0024' AND
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte.v1' AND
......
......@@ -18,13 +18,10 @@ QUERY(
) as a,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
),
......@@ -39,13 +36,10 @@ QUERY(
) as b,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('b'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('b'),
'items',
'at0024'
),
'value'
),
......@@ -62,13 +56,13 @@ QUERY(
*Cypher
MATCH
(A:EHR), (A)-[:ehr_id]->(B:HIER_OBJECT_ID), (A)-[*]->(C:CLUSTER), (A)-[*]->(D:CLUSTER), (C)-[:items]->(E:ELEMENT), (D)-[:items]->(F:ELEMENT)
(A:EHR), (A)-[*]->(B:CLUSTER), (A)-[*]->(C:CLUSTER), (A)-[:ehr_id]->(D:HIER_OBJECT_ID), (B)-[:items]->(E:ELEMENT), (C)-[:items]->(F:ELEMENT)
WHERE
E.value.value = 'Natrium_g_dl' AND
F.value.value = 'H_moglobin_g_dl' AND
E.value = 'Natrium_g_dl' AND
F.value = 'H_moglobin_g_dl' AND
E.archetype_node_id = 'at0024' AND
F.archetype_node_id = 'at0024' AND
C.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte.v1' AND
D.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte.v1'
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte.v1' AND
C.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte.v1'
RETURN
B as e_ehr_id
D as e_ehr_id
......@@ -60,6 +60,6 @@ WHERE
F.archetype_node_id = 'at0001' AND
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1' AND
C.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -18,13 +18,10 @@ QUERY(
) as a,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('a'),
'items',
'at0024'
),
'value'
),
......@@ -39,13 +36,10 @@ QUERY(
) as b,
EQUALS(
FIELD(
FIELD(
INDEXED_FIELD(
ALIAS_REF('b'),
'items',
'at0024'
),
'value'
INDEXED_FIELD(
ALIAS_REF('b'),
'items',
'at0024'
),
'value'
),
......@@ -61,12 +55,12 @@ QUERY(
MATCH
(A:EHR), (A)-[*]->(B:CLUSTER), (A)-[*]->(C:CLUSTER), (B)-[:items]->(D:ELEMENT), (C)-[:items]->(E:ELEMENT)
WHERE
D.value.value = 'Natrium_g_dl' AND
E.value.value = 'H_moglobin_g_dl' AND
D.value = 'Natrium_g_dl' AND
E.value = 'H_moglobin_g_dl' AND
D.archetype_node_id = 'at0024' AND
E.archetype_node_id = 'at0024' AND
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1' AND
C.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -30,6 +30,6 @@ MATCH
WHERE
B.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1' AND
C.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -48,6 +48,6 @@ WHERE
C.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1' AND
E.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1' AND
D.archetype_node_id = 'openEHR-EHR-OBSERVATION.blood_pressure.v2'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
*AQL
SELECT e
SELECT a
FROM EHR e
CONTAINS COMPOSITION a[openEHR-EHR-COMPOSITION.report.v1]
WHERE a/content[openEHR-EHR-EVALUATION.gender.v1]/data[at0002]/items[at0022]/value/value = 'männlich'
WHERE a/content[openEHR-EHR-EVALUATION.gender.v1]/data[at0002]/items[at0022]/value/value = 'Männlich' AND a/archetype_details/template_id/value = 'template.v1'
*Graph
QUERY(
......@@ -14,8 +14,8 @@ QUERY(
'COMPOSITION',
'openEHR-EHR-COMPOSITION.report.v1'
) as a,
EQUALS(
FIELD(
AND(
EQUALS(
FIELD(
INDEXED_FIELD(
INDEXED_FIELD(
......@@ -32,24 +32,37 @@ QUERY(
),
'value'
),
'value'
'Männlich'
),
'männlich'
EQUALS(
FIELD(
FIELD(
FIELD(
ALIAS_REF('a'),
'archetype_details'
),
'template_id'
),
'value'
),
'template.v1'
)
)
)
),
RETURN(ALIAS_REF('e') out 'e')
RETURN(ALIAS_REF('a') out 'a')
)
*Cypher
MATCH
(A:EHR), (A)-[*]->(B:COMPOSITION), (B)-[:content]->(C:EVALUATION), (C)-[:data]->(D:ITEM_TREE), (D)-[:items]->(E:ELEMENT)
(A:EHR), (A)-[*]->(B:COMPOSITION), (B)-[:content]->(C:EVALUATION), (B)-[:archetype_details]->(D:ARCHETYPED), (C)-[:data]->(E:ITEM_TREE), (E)-[:items]->(F:ELEMENT), (D)-[:template_id]->(G:TEMPLATE_ID)
WHERE
E.value.value = 'männlich' AND
E.archetype_node_id = 'at0022' AND
D.archetype_node_id = 'at0002' AND
F.value = 'Männlich' AND
G.value = 'template.v1' AND
F.archetype_node_id = 'at0022' AND
E.archetype_node_id = 'at0002' AND
C.archetype_node_id = 'openEHR-EHR-EVALUATION.gender.v1' AND
B.archetype_node_id = 'openEHR-EHR-COMPOSITION.report.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(B, {relationshipFilter:'>'}) yield path as B_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(B_paths)) as a_rm_object, extract(r in relationships(B_paths) | type(r)) as a_relationships
\ No newline at end of file
......@@ -18,6 +18,6 @@ QUERY(
*Cypher
MATCH
(A:EHR), (A)-[*]->(B:Banana)
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -40,6 +40,6 @@ WHERE
120 < D.magnitude AND
C.archetype_node_id = 'at0001' AND
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1'
CALL apoc.path.spanningTree(A, {}) yield path as A_paths
CALL apoc.path.spanningTree(A, {relationshipFilter:'>'}) yield path as A_paths
RETURN
A_paths as ep, extract(r in relationships(A_paths) | type(r)) as e_relationships, extract(n in nodes(A_paths) | labels(n)) as e_nodetypes
\ No newline at end of file
last(nodes(A_paths)) as e_rm_object, extract(r in relationships(A_paths) | type(r)) as e_relationships
\ No newline at end of file
......@@ -58,10 +58,10 @@ QUERY(
*Cypher
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)
(A:EHR), (A)-[*]->(B:COMPOSITION), (A)-[:ehr_status]->(C:EHR_STATUS), (A)-[:ehr_id]->(D:HIER_OBJECT_ID), (B)-[*]->(E:ADMIN_ENTRY), (C)-[:subject]->(F:PARTY_SELF), (F)-[:external_ref]->(G:PARTY_REF)
WHERE
(NOT EXISTS ((D)-[:content]->(:ADMIN_ENTRY{archetype_node_id:'openEHR-EHR-ADMIN_ENTRY.discharge_summary.v0'})) OR 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'
(NOT EXISTS ((B)-[:content]->(:ADMIN_ENTRY{archetype_node_id:'openEHR-EHR-ADMIN_ENTRY.discharge_summary.v0'})) OR NOT(G.namespace = 'CEC')) AND
B.archetype_node_id = 'openEHR-EHR-COMPOSITION.encounter.v1' AND
E.archetype_node_id = 'openEHR-EHR-ADMIN_ENTRY.admission.v0'
RETURN
C.value as e_ehr_id_value
\ No newline at end of file
D.value as e_ehr_id_value
\ No newline at end of file
......@@ -51,10 +51,10 @@ QUERY(
*Cypher
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)
(A:EHR), (A)-[*]->(B:COMPOSITION), (A)-[:ehr_status]->(C:EHR_STATUS), (A)-[:ehr_id]->(D:HIER_OBJECT_ID), (B)-[*]->(E:ADMIN_ENTRY), (C)-[:subject]->(F:PARTY_SELF), (F)-[:external_ref]->(G:PARTY_REF)
WHERE
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'
NOT(G.namespace = 'CEC') AND
B.archetype_node_id = 'openEHR-EHR-COMPOSITION.encounter.v1' AND
E.archetype_node_id = 'openEHR-EHR-ADMIN_ENTRY.admission.v0'
RETURN
C.value as e_ehr_id_value
\ No newline at end of file
D.value as e_ehr_id_value
\ No newline at end of file