Objective
Pharmacists and clinical decision-support systems must flag patients on combinations of drugs known to interact dangerously. Modeling Patient → Drug and Drug → Drug interactions as a graph turns the screening query into one MATCH that looks for triangles in the network — sub-second even across a hospital's entire prescription history.
Step 1: Create the graph
// Patients
MERGE (p1:Patient {mrn: "MRN-101", name: "Sarah Chen", age: 67})
MERGE (p2:Patient {mrn: "MRN-102", name: "Raj Patel", age: 54})
MERGE (p3:Patient {mrn: "MRN-103", name: "Mia Rossi", age: 71})
MERGE (p4:Patient {mrn: "MRN-104", name: "Leo Park", age: 49})
MERGE (p5:Patient {mrn: "MRN-105", name: "Eli Tanaka", age: 62})
// Drugs
MERGE (warf:Drug {name: "Warfarin", class: "Anticoagulant"})
MERGE (asp:Drug {name: "Aspirin", class: "NSAID"})
MERGE (clop:Drug {name: "Clopidogrel", class: "Antiplatelet"})
MERGE (sim:Drug {name: "Simvastatin", class: "Statin"})
MERGE (ery:Drug {name: "Erythromycin", class: "Antibiotic"})
MERGE (met:Drug {name: "Metformin", class: "Antidiabetic"})
MERGE (lis:Drug {name: "Lisinopril", class: "ACE Inhibitor"})
// Prescriptions
MERGE (p1)-[:PRESCRIBED {since: "2026-01-12"}]->(warf)
MERGE (p1)-[:PRESCRIBED {since: "2026-03-04"}]->(asp)
MERGE (p2)-[:PRESCRIBED {since: "2025-11-22"}]->(sim)
MERGE (p2)-[:PRESCRIBED {since: "2026-04-15"}]->(ery)
MERGE (p3)-[:PRESCRIBED {since: "2026-02-08"}]->(warf)
MERGE (p3)-[:PRESCRIBED {since: "2026-02-08"}]->(clop)
MERGE (p4)-[:PRESCRIBED {since: "2025-06-10"}]->(met)
MERGE (p4)-[:PRESCRIBED {since: "2025-06-10"}]->(lis)
MERGE (p5)-[:PRESCRIBED {since: "2026-03-30"}]->(asp)
MERGE (p5)-[:PRESCRIBED {since: "2026-03-30"}]->(clop)
// Known interactions (severity 1=mild, 2=moderate, 3=severe)
MERGE (warf)-[:INTERACTS_WITH {severity: 3, effect: "Major bleeding risk"}]->(asp)
MERGE (warf)-[:INTERACTS_WITH {severity: 3, effect: "Major bleeding risk"}]->(clop)
MERGE (asp)-[:INTERACTS_WITH {severity: 2, effect: "Increased bleeding"}]->(clop)
MERGE (sim)-[:INTERACTS_WITH {severity: 3, effect: "Rhabdomyolysis risk"}]->(ery);