GraphGists

Using the Wiley Treatment Plan

I am using the "Wiley treatment plan" data set as the basis of our domain model since it is one standard that is used in behavioral health. A key aspect of treatment in the field of behavioral health involves creating a four-part treatment plan, packaged as libraries, consisting of a Problem, Goal, Objective, and Intervention.

The Problem

The Problem states, in general terms, what the patient is suffering with. For example, this might be Depression, Low self-Esteem, Substance Abuse, or something else.

The Goal

The Goal is the end result. For example, a patient might have the goal of "Demonstrate respect and regard for self and others".

The Objectives

Objectives are milestones along the way from the Problem to the Goal: ways in which the patient is going to improve.

The Intervention

Interventions are tasks or activities performed as part of the plan. These may be actions taken by the patient and others involved in the treatment plan.

Additional Complications

In practice, there are several snarls in the model described above that make the implementation of the Wiley plan difficult for relational databases.

The first is the existence of links from problem to goal to intervention restricting interventions to those related only to a specfic problem and/or goal. Setting this up in an SQL database required a separate table to maintain "linkages" for each plan. Generating an appropriate plan requires traversing the linkage table a number of times, resulting in queries that can run from two to ten seconds depending on how many libraries are loaded.

The second change is that not everyone uses the plan in the defined order of problem → goal → objective → intervention. Any practical implementation of the treatment plan system has to let the user start from any point in the plan and work from there. For example, the user can start with goal then jump to intervention and then on to problem.

Thirdly, the information (goals, objectives, interventions) is reused. For example, GoalA may be used for ProblemA in LibraryA but it maybe used again with other problems within the same library or span libraries.

Domain Model
Figure 1. The Wiley Treatment Plan Domain Model

Implementing The Wiley Plan using Neo4j

Implementing the model in Neo4j resulted in 300 nodes and 120k relationships. A typical query runs in about 500 ms and `RETURN`s 500-700 values. In addition, adding custom plans that deviate from the Wiley plan was easy and didn’t affect performance.

Domain Model
Figure 2. Modified Wiley Treatment Plan Domain Model

Nodes

(:Library)
(:Problem)
(:Goal)

Relationships

(:Library)-[:HAS_PROBLEM]->(:Problem)-[:HAS_GOAL]->(:Goal)
(:Problem)-[:HAS_OBJECTIVE]->(:Objective)
(:Problem)-[:HAS_INTERVENTION]->(:Intervenion)

Sample Dataset

The sample data set uses a one library, one problem, and four objectives, goals, and interventions.

Use Cases

Display All Objectives

MATCH (c:Objective)
RETURN c.Description AS Objective

Display All Problems

MATCH (c:Problem)
RETURN c.Description AS Problem

Display All Goals

MATCH (c:Goal)
RETURN c.Description AS Goal

Find nterventions for all libraries and problem number 17

MATCH (lib:Library)-[:HAS_PROBLEM]->(st:Problem{name:'17'})-[:HAS_INTERVENTION]-(i:Intervention)
RETURN lib.Description AS Library, st.Description AS Problem, i.Description AS Intervention;

Display All Problems, Interventions, and Objectives for one library

MATCH (lib:Library{GroupID:'230'})-[:HAS_PROBLEM]->(st:Problem{name:'17'})-[:HAS_INTERVENTION]-(i:Intervention) with i,st MATCH (st)-[:HAS_OBJECTIVE]->(m:Objective)
RETURN st.Description AS Problem, m.Description AS Objective, i.Description AS Intervention;

Conclusion

Developing the treatment planner in SQL took months to get correct and the performance to the point where it was useable. I used py2neo to populate import the data in to the graph. In all, it took less than a week from start to finish(it took longer to create this gist).