Querying the nodes
We have the patient data set along with the encounters with the healthcare system. We will look at a question and how we can represent it in Cypher. To find the total number of patients in the system, type the following into the console:
MATCH (p:Patient) RETURN count(p)
This Cypher query returns the total number of patients in the system. This screenshot shows the response in the browser:
Figure 4.7 – Patient count query
You can see that it is instantaneous. Neo4j maintains the count stores for labels, so when we ask for counts in this way, Neo4j uses the count stores to return the response. The response time is consistent when we have one node or one million nodes of this label.
The Patient
node only had one label. We know the Encounter
node has multiple labels. Let us write a query to find label distribution. The Cypher query looks as follows:
MATCH (e:Encounter) RETURN labels(e) as labels, count(e) as counts
This...