Last active
June 23, 2016 14:54
-
-
Save jeremykendall/bad4d110aed690ee25d980d57f623e9f to your computer and use it in GitHub Desktop.
OSMI Graph Query Scratchpad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Top 10 self diagnoses WITHOUT a corresponding professional diagnosis | |
MATCH (selfDiagnosis:Disorder)<-[:SELF_DIAGNOSIS]-(p:Person) | |
WHERE NOT (p)-[:PROFESSIONAL_DIAGNOSIS]->() | |
RETURN selfDiagnosis.name, COUNT(p) AS diagnoses | |
ORDER BY diagnoses DESC | |
LIMIT 10; | |
// Top 10 Diagnoses: Self-diagnoses vs MD-diagnoses | |
MATCH (d:Disorder)<-[sd:SELF_DIAGNOSIS]-() | |
WITH d, COUNT(sd) AS selfDiagnoses | |
MATCH (d)<-[mdd:PROFESSIONAL_DIAGNOSIS]-() | |
WITH d, selfDiagnoses, COUNT(mdd) AS mdDiagnoses | |
RETURN d.name AS disorder, selfDiagnoses, mdDiagnoses | |
// Order by selfDiagnoses or mdDiagnoses, depending on preference | |
ORDER BY selfDiagnoses DESC | |
LIMIT 10; | |
// Incidence of self-diagnoses (WITHOUT corresponding MD diagnosis) compared to available | |
// employer provided mental health coverage | |
// JOINs: Question to Answer. | |
// If ANSWERED, SELF_DIAGNOSIS, and PROFESSIONAL_DIAGNOSIS all represent pivot tables, then: | |
// * Question -> Answer | |
// * Person -> PersonAnswer -> Answer | |
// * Person -> PersonSelfDiagnosis -> Diagnosis | |
// * Person -> PersonProfessionalDiagnosis -> Diagnosis | |
// PROFESSIONAL_DIAGNOSIS rel would also likely represent a pivot table | |
MATCH (q:Question { field_id: 18065507 })-[:HAS_ANSWER]->(a)<-[:ANSWERED]-(p)-[sd:SELF_DIAGNOSIS]->(d) | |
WHERE NOT (p)-[:PROFESSIONAL_DIAGNOSIS]->() | |
RETURN a.answer, COUNT(sd) AS selfDiagnoses | |
ORDER BY selfDiagnoses DESC | |
LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment