DoctorFinder!
This GraphGist represents a mobile application backend helping users to find adequate drugs and specialists given their physical characteristics, location and current symptoms.
Our resulting model
From VIDAL with ♥ (Suzanne
, Nicolas
, Édouard
, Marouane
, Sébastian
, Thibaut
, Olivier
, Sylvain
, Florent
(aka Cypher translator)).
User stories
Symptom autocompletion
As an application user,
When I start typing my symptoms Then matching symptoms are returned in alphabetical order.
Example
User types 'c'.
MATCH (s:Symptom)
WHERE toUpper(s.name)=~ toUpper('c.*')
RETURN s.name AS `Symptom`
ORDER BY s.name ASC
For simplicity’s sake, this query will not be included in the following examples. However, it would definitely be the first clause of each (as user types only symptom starts). Subsequent queries will assume symptom names were resolved by this first sub-query.
Drug advisor
As an application user,
When I start typing my symptomsThen adequate drugs are returned, grouped by their therapeutic class.
Example
Current user is a 35-year old man, manifesting wheezing and chest tightness, suffering from hypersensitivity to Betametasone allergy.
We expect all drugs of class Bronchodilators
(Betametasone
drug excluded, because of the aforementioned allergy) and Xanthine
to appear as they are the only therapeutic classes suitable for adults in our dataset.
MATCH (patho:Pathology)-[:MAY_MANIFEST_SYMPTOMS]->(symptoms:Symptom)
WHERE symptoms.name IN ['Chest tightness', 'Wheezing']
WITH patho
MATCH (DrugClass:DrugClass)-[cures:CURES]->(patho)
WHERE cures.age_min <= 35 AND 35 < cures.age_max
WITH DrugClass
MATCH (drug:Drug)-[:BELONGS_TO_CLASS]->(DrugClass), (allergy:ALLERGY)
WHERE allergy.name IN ['Hypersensitivity to Betametasone']
AND (NOT (drug)-[:MAY_CAUSE_ALLERGY]->(allergy))
RETURN DrugClass.name AS `Therapeutic class`, COLLECT(DISTINCT drug.name) AS `Drugs`;
Doctor finder
As an application user,
When I start typing my symptomsThen the doctors who (ahah!) can prescribe adequate drugs are returned with these drugs, ordered by proximity.
See definition above for what 'adequate drugs' mean. If drugs can be purchased without prescription, the mention 'No doctor required' for these drugs should be returned, with a distance to user home of 0.
Example
Current user is a 19-year old woman, manifesting cough, suffering from hypersensitivity to Betametasone allergy and living at '14, rue de Bruxelles 75009 PARIS, FRANCE' (latitude:48.88344, longitude:2.33180).
We expect all angiologists to be returned as the drugs they can prescribe can cure illnesses related to the user symptom.
Moreover, drugs of class Xanthine
do not require a prescription and they can cure the same kind of illnesses as well.
MATCH (patho:Pathology)-[:MAY_MANIFEST_SYMPTOMS]->(symptoms:Symptom)
WHERE symptoms.name IN ['Cough']
WITH patho
MATCH (DrugClass:DrugClass)-[cures:CURES]->(patho)
WHERE cures.age_min <= 19 AND 19 < cures.age_max
WITH DrugClass
MATCH (drug:Drug)-[:BELONGS_TO_CLASS]->(DrugClass), (allergy:ALLERGY)
WHERE allergy.name IN ['Hypersensitivity to Betametasone']
AND (NOT (drug)-[:MAY_CAUSE_ALLERGY]->(allergy))
WITH DrugClass, drug
OPTIONAL MATCH (doctor:Doctor)-->(spe:DoctorSpecialization)-[:CAN_PRESCRIBE]->(DrugClass)
RETURN COALESCE(doctor.name + ' (' + spe.name + ')', 'No doctor required') AS `Doctor`, COLLECT(DISTINCT drug.name) AS `Drugs for your symptoms`, 2 * 6371 * asin(sqrt(haversin(radians(48.88344 - COALESCE(doctor.latitude,48.88344))) + cos(radians(48.88344)) * cos(radians(COALESCE(doctor.latitude,90)))* haversin(radians(2.33180 - COALESCE(doctor.longitude,2.33180))))) AS `Distance to home (km)`
ORDER BY `Distance to home (km)` ASC;
As obfuscated as it looks, the distance computation is just a null-safe variant of the haversin formula explained in Cypher manual (indeed, there are drugs that do not require a doctor prescription).
Is this page helpful?