I have developed the following query to find all nodes that meet a certain query criteria. Specifically, all the disease codes that satisfy certain parameters. I have used UNION to accomplish this in the code:
//Find all diagnosis codes
MATCH p = (a:ObjectConcept{sctid:233604007}) <-[:ISA*]- (b:ObjectConcept),
q = (c:ObjectConcept{sctid:58800005})<-[:ISA*]-(d:ObjectConcept)
WHERE NOT (b)-->()--(c) AND NOT (b)-->()-->(d)
RETURN distinct b
UNION
MATCH p = (a:ObjectConcept{sctid:233604007}) <-[:ISA*]- (b:ObjectConcept),
t = (e:ObjectConcept{sctid:65119002})<-[:ISA*]-(f:ObjectConcept)
WHERE NOT (b)-->()-->(e) AND NOT (b)-->()-->(f)
RETURN distinct b
I would like to care the result from this query. That is the set (distinct b) and find all patients with any of these diseases.
Pseudo-code: Match s = (nodes in distinct b) <-[:HAS_DX]- (z:Patient)
RETURN distinct z
However, I do not know the Cypher syntax to carry the set of distinct nodes b into this subsequent query statement. I am using Neo4j v 2.1.7.
Thanks