Showing posts with label TL;DR. Show all posts
Showing posts with label TL;DR. Show all posts

Friday, March 22, 2013

On being Strategic rather than Comprehensive

In Meaningful Use, there are several components related to care planning that need to be communicated for transitions of care: The care team, the care plan (as described in CCDA), and patient instructions.  This was a good first start, but there's far more to do.  HL7, IHE, S&I Framework and many others have been working on developing a more comprehensive way to address care plans and care planning for quite some time.

This week, IHE PCC was reviewing content being developed for one of our work items related to care planning.  On the screen earlier this week was a proposal to add the following term to the IHE Glossary.

Care Plan   The synthesis and reconciliation of the multiple plans of care produced by each provider to address specific health concerns.

“You have defined care plan in terms of itself.” I comment.  Others immediately responded that they hadn’t.  “Sure you have: care plan and plans of care.” I chimed back.  I was then told that “Those are two different things.”, and thus began my education into what the current thinking is that's been developing across various groups.

This is what my daughter calls a face/palm (or in this case a head/desk) moment.  Those moments are usually accompanied by a loud noise as my palm (or my desk) comes quickly into contact with my face (or head).  I think the pain helps distract me from the former attack on my senses.

“OK,” I explained, “I’m never going to be able to explain this to anyone.  The way that the English language works, these two phrases mean the same thing.”  I did spend several years developing linguistic and natural language processing software, and managed to pick up a few things from my linguistic colleagues. 

A parse of “care plan” will result in in a noun phrase (a phrase acting as a noun) composed of “care” (noun adjunct = noun used as adjective) plan (noun).  Thus, plan is the main idea, and care is a qualifier that means the plan related to care.  I’m assuming I don’t need to define plan or care (yet).

A parse of plan of care results in a noun phrase, where “plan” and “care” are again nouns, “of” is a preposition, and care modifies/qualifies plan.  It is the plan about or related to care. 

My brain, and if you are reading this blog, likely yours, has been trained to treat “Care Plan” and “Plan of Care” as if they were the same thing.  We can all be indoctrinated to understand that they are different things, but recall what I said a few days ago about social interoperability, and what I said a few weeks before about not caring about what it is called, so long as I know what it is. 

These words fail the grandma test (and the developer test, and the provider test …). Something has to give here.  We need new words, because the ones we have only add to the confusion.  Definitions can be used to override instinct, but I'd much rather rely instincts, rather than circumvent them.  Let’s take a look at the words we have, and a picture to go along with them.

The image to your left shows that there is a first outer ring that encompasses the second inner ring, which has a third subcomponent containing a final inner component.  The image comes from material developed for the Longitudinal Coordination of Care project in the ONC S&I Framework from the Longitudinal Care Plan subworkgroup.  What follows are the words describing these rings that were suggested for the IHE PCC Glossary, and which are derived from the S&I Activities.




What it is called
What it is
Care Plan
The synthesis and reconciliation of the multiple plans of care produced by each provider to address specific health concerns.
Plan of Care
A concept some clinicians use to focus on discrete problems, the specific interventions to address the problem, and achieve a certain goal related to the problem.
Treatment Plan
A concept developed by a provider in collaboration with the individual to address an individual’s health concern under the purview of a single provider.
Instructions
Information or directions to the patient and other providers including how to care for the individual’s condition, what to do at home, when to call for help, any additional appointments, testing, and changes to the medication list or medication instructions, clinical guidelines and a summary of best practice. This is provided as a list of action steps given to a team member or patient to address health concerns.

The important part of what you see above is not the words on the left, but rather the words on the right.  The only notion of the “Care Plan” that I have ever seen is what my mother used to carry in her head for my step father, aided by her notes.  This concept exists rarely in the real world, but I have seen enough real world examples to know this isn’t a unicorn.  But it is rare enough to be a zebra (at least in my part of the world).

The second and third items are often confused, and in fact, IHE a few years back agreed that the code for the TREATMENT PLAN section in LOINC was the right place to put the CARE PLAN information (which has resulted in further discussions about change proposals to some existing profiles).  It’s confusing enough to experts, and healthcare providers certainly don’t agree on it either.  Instructions is perhaps a bit broader than I would expect, but seems to fit in with current notions.  And there seems to be agreement among healthcare providers that instructions are part of the care plan (at least those given to patients are).

The definition of the outermost object seems to be missing an important participant, the patient.  This is especially true when the phrase “Care Plan” is used with a definite article.  The only individual that has any chance of having access to “The Care Plan” is the patient or other care giver who has access to all the information available.  You can see why Care Plans are zebras.  You need an engaged patient or caregiver who wants to coordinate all this data, and they have to have access to it as well. 

My mother’s care plan  for my step father was flawed in that she did not have access to all the data, but that’s wasn’t for lack of trying. Using the definite article for a care plan ("The Care Plan") that is owned or developed by anyone other than the patient or their care giver is a mistake.  In the provider’s mouth, those words better be something like “this is the care plan that I’d suggest for you”, or “let’s go over your care plan”.  If “you” are not part of the care plan when your healthcare provider discusses it, then it’s probably his or her plan, and he or she shouldn’t be surprised when you change it to suit your needs.


In the battle for health and against disease, the commander-in-chief needs to be the patient.  They should be setting the objectives and goals, and approving the strategies used to reach them.  They may override some decisions where they feel necessary to in order to balance the priorities for each objective.  In the above definitions, I see the word “goals” used once, and the words “objective” and “priority” never appears.  The “plan” is what you do to meet goals.  The terms “goal” and “objective” are synonyms, and are often used interchangeably. 

I’ve been trained to specify objectives in a broad way, and to derive goals from objectives.  Goals allow you to measure whether the objective is being reached (in fact, if you work this way, the objective is often stated subjectively, and the goals are objective statements -- I never said social interoperability is easy).  If we talk about, and deliver goals and objectives together, I don’t think anyone will mind, and it’s still pretty easy to explain that goals need to be measurable.
"The key to strategy... is not to choose a path to victory, but to choose so that all paths lead to a victory." — Cavilo, The Vor Game
In a complex situation, there is never a single comprehensive plan which leads to success, but rather a collection of plans and alternatives in which enough plans succeed to result in the desired outcome.  Has your doctor ever told you: our plan is to try this (e.g., PT), and if that doesn’t work, then we will do that (Steroid injection), and finally, if necessary we will do the other thing (surgery)?  These represent the alternative paths (in a plan related to a knee problem).  I love this  doctorial we, but only when used collaboratively, that than in the royal fashion.

Planning is done at different levels, starting from principals, moving to strategies related to goals and objectives, and then on to tactics, which are executed via orders and instructions.  In developing a strategic plan for any purpose, you have high level principles and priorities, which lead to objectives and goals.  Each objective and goal can become the foundation of a tactical plan to achieve the objective.  In delegating the objectives from the strategic plan to others, the planner will often provide additional information and instructions about how to maneuver to reach the objective.

Strategic objectives and specific tactics are dynamic, responding to the changing system (thus, the need for alternatives).  I have never seen an overall comprehensive plan for patient care, such as would be describe in the “Care Plan”.  No organization I have ever worked with ever has an overall comprehensive plan in one place to reach its objectives.  Leaders can speak to the strategic objectives, and can often tell you what others are doing to achieve them at a high level.  The details of those tactics are delegated to experts in each objective.  If you want to know the detailed tactics, you have to speak to those experts.  The process is dynamic, as the tactics often change when alternatives are activated.

Rather than think about a comprehensive Care Plan as described above, I would prefer this view of the care planning process.

Strategic Care Plan:  This is an overview, containing the patient’s objectives and goals for overall care.  It identifies the patient’s principals and priorities that the care must meet.  It synthesizes and is used to reconcile differences between individual tactical care plans, but summarizes rather than contains all of them, although it should reference them in some way.  It most closely resembles the “Care Plan” described above.

Tactical Care Plan: This is a plan designed to achieve one (or more related) objectives.  It combines features of the Plan of Care and the Treatment plan above.  In the continuum between strategy and tactics, high level tactical plans will reference other, more detailed tactical plans.  My provider’s overall plan to control my blood pressure includes tactics that he is responsible for, and those he has delegate to others (e.g., a dietitian and me).  Those delegates may have tactical plans of their own.  Delegation is often represented through orders (e.g., medications, referrals and consultations) and instructions.

Orders and Instructions:  This component represents the orders and instructions in a tactical plan and most closely resembles the Instructions described above.  Orders and instructions in the tactical plan provide can provide links to those others who may have their own plans, and may provide alternatives to address changing conditions.  Advance Directives are nothing more than orders and instructions from the patient to the provider for care and treatment that are based on their principals and priorities.  They belong in the mix for care plans as well.


The "Care Planning" process should be less about comprehensive planning, and more about collaboration and objectives.  Yes, it is important to understand the steps to achieve an objective, but those plans need to be more agile and dynamic, coordinated through self-organizing care teams.

As I think about how my mother manages care, she is the commander-in-chief.  She doesn't have to know everything, but she does know where to go to get the details when she needs them.  In the mountains of data that healthcare can generate, it's not necessarily about what you know, but what you know about how to find out (Dr. Google is so powerful because of that).  Health IT can help, but we should not assume that all of the data will or must ever reside in one place.  It needs to be strongly linked together though, so that the generals can pull together the information they need, in order to carry out the hopes of the commander-in-chief.

-- Keith

Thursday, July 12, 2012

An XSLT Breadth-First Search for Processing XML Schema (TL;DR)

Last night after spending several hours working with the HL7 HQMF ballot content, I started getting frustrated with the content structure.  The HL7 Publication DTD (yes, I know) is rather roughly documented.  It's based on the W3C Publication DTD, and as in many things in IT, "nobody knows how that works anymore".  Actually, I know just the person who does, but he's retired into his second career, taking pictures of birds.

One of the limitations (and a not unreasonable one at that) is the level of nesting allowed.  They only number sections to the fourth level.  After that, it starts getting funky (and it looks bad too).  So, I want to navigate through the R-MIM Walkthrough, and I just can't organize things the way I want.  One of the problems is that the document has been edited by several people, and the outline wasn't consistent.  Since this section was basically a walk of the DAG (directed acyclic graph) that is the RMIM, I figured I could probably automate generating the Table of Contents.

So I got someone to give me the latest schema generated by the HL7 tools, and started writing a stylesheet to traverse the schema and generate the outline.  Well, that was daring.  After all, here we are in the 11th hour (or perhaps at this point the 35th hour), and I want to completely reorganize a major chunk of the documentation.  Well, needless to say, I didn't get any sleep last night, but that's not because I reorganized things, but rather because of what I discovered when I did finally succeed.  I'll talk about that later.  What I really want to discuss today is this cool stylesheet that I wound up building.

You see, it walks the Schema, starting with the complexType that is used for the root of the HQMF document schema.  It then identifies each Participation, Role, Entity and ActRelationship in the tree, and generates my outline.

Here's the general structure I worked out.  It isn't ideal, but it works and people can navigate it.

1.1 Act
1.1.1 Act Attributes
1.1.1.1 Act.attribute1
1.1.1.1 Act.attribute2
1.1.2 Act Participations
1.1.2.1 Act.participation1
1.1.2.2 participation1.attribute1
1.1.2.3 participation1.attribute2
1.1.2.4 participation1.role1
1.1.2.5 role1.attribute1
1.1.2.6 role1.attribute2
1.1.2.7 role1.player1
1.1.2.8 player1.attribute1
1.1.2.9 role1.scoper1
1.1.2.10 scoper1.attribute1
1.1.3 Act Relationships
1.1.3.1 Act.relationship1
1.1.3.2 relationship1.attribute1
1.1.3.3 relationship1.attribute2
1.1.3.4 relationship1.act2
1.2 Act2
 ... and so on

The focus in the HL7 RIM is on the acts being documented, and this documentation structure keeps the attention on the acts, and doesn't exceed a nesting depth of 4, so I was pretty happy.

So I began writing the stylesheet.  After about 45 lines, I had everything by the recursion back to Act all working.  There were 6 templates in the whole thing.  One called Act, another Participation, another Role, another Entity and a final one called ActRelationship.   I knew I was going to have to break cycles in my traversal, because sections can have sections and so on.  So I wrote a little bit of code to detect the cycles, and the first thing that happened was a stack crash.  After a few moments adding some <xsl:message> elements, I was able to see that my cycle detection only worked for cycles of length two (after all, I knew there weren't any longer cycles in the R-MIM).

As it turns out, I was wrong.  The R-MIM designed allows for something called a Choice box in which you can include multiple model elements.  Then you can attach relationships from the choice box back to itself.  This is such a common thing in HL7 V3 that there's even a special shape for it in the tools.  The problem there is that if you have such a choice box that can go back to itself, the cycle length increases.  Say you had two items, A and B, and a link between them through C.  Now instead of having to detect this loop:  ACA, you also have to detect ACBCA and BCACB.  The more items you put in the choice box, the longer your loop detection has to detect loops for.

OK, so I tried the next best thing which was, as I iterated over things and went down the stack, to pass a list of where I'd been.  Well, the problem with that (besides being clunky), was that it just didn't work.  There were too many pathways through the cycles, and you could get into a real mess.  Now I was really stuck and it was around 10pm.  I recalled a post by Michael Kay (author of the XSLT Programmers Reference) somewhere about loop detection in XSLT, so I dug out my second edition.  No good.  It's described in the third edition, and he finally got the code right in the fourth edition (neither of which I have or needed until last night).  And he wrote it in XSLT 2.0, which is no good for me, because I'm still working in XSLT 1.0 (I know, I'm a glutton for punishment).

So after an hour of digging around trying to find a DFS or BFS (depth- or breadth-first search) implementation in XSLT I gave up, made some coffee and took a walk.  Then I went back to my desk, wrote the recursive BFS code down a couple of different ways, and then made it tail recursive.  Tail recursion is a good thing to do when you are writing in XSLT, because you can overcome a lot of limitations that way.  XSLT doesn't let you change the values of variables once you set them, but a tail recursive call lets you change the input parameters, and it can be optimized by a good XSLT parser into loop.

Here's the basic algorithm:

process(node)
{ ... whatever you want to do ... }


BFS(list todo, list done)
{
    if (!empty(todo)) {
      head = car(todo);
      tail = cdr(todo);
      newNodes = nodesReachableFrom(head);
      needsDoing = (newNodes - todo) - done;
      process(head);
      BFS(todo + tail, done + head);
   }
}


BFS(root, null);

You will note that I never modify a variable after setting it.

This is how it looks translated into XSLT.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xsl:key name="node" use="." match="xs:complexType/@name"/>
  <xsl:key name="neighbors" 
    use="//xs:complexType[.//xs:element/@type = current()]/@name"
    match="xs:complexType/@name"/>

  <xsl:template match="/">
    <xsl:call-template name="BFS">
      <xsl:with-param name="todo"
         select="key('node','POQM_MT000001UV.QualityMeasureDocument')"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template name="process">
    <p><xsl:value-of select="."/></p>
  </xsl:template>
  
  <!-- BFS generates an XML fragment containing the keys
    of elements which need to be processed in the order they
    should be handled based on a breadth-first search of the 
    tree represented 
  -->
  <xsl:template name="BFS">
    <!-- todo is a node-set() containing a list of all nodes that have 
      yet to be processed -->
    <xsl:param name="todo" select="/.."/>
    <!-- done is a node-set() containing a list of all nodes that have
      already been processed -->
    <xsl:param name="done" select="/.."/>

    <!-- If todo is empty, we don't do anything -->
    <xsl:if test='count($todo)!=0'>
      <!-- head is the first node in todo in document order -->
      <xsl:variable name="head" select="$todo[1]"/>
      <!-- tail is the rest of todo in document order -->
      <xsl:variable name="tail" select="$todo[position() != 1]"/>
      
      <xsl:variable name="reachable" select="key('neighbors',$head)"/>
      <xsl:variable name="needsDoing" 
        select="$reachable[not(. = ($todo|$done))]"/>

      <xsl:for-each select="$head">
        <xsl:call-template name="process"/>
      </xsl:for-each>

      <xsl:call-template name="BFS">
        <xsl:with-param name="todo" select="$tail|$needsDoing"/>
        <xsl:with-param name="done" select="$done|$head"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>

This is pretty generalizable to any problem where you need to traverse a DAG without crossing links.  A couple of notes are in order:
<xsl:key> and key(N, V) are XSLT elements and functions that are designed to do element lookup by key values.  These are worthy tools to have in your kit if you do a lot of XSLT programming.  Larn em!
I've set up two keys, one called "node" which returns the @name attribute of the xs:complexType element that has the name you specify.  That's a very straight-forward use of key in XSLT.  However, the second one called "neighbors" is much trickier.  It uses the key mechanism to return the set of xs:complexType/@name values that are needed by the elements in the named complexType.  For what I'm doing, I'm only interested in elements, so this isn't as hard as it could have been.

The reason that these return the @name attributes instead of the xs:complexType element is because the node-set returned can then be used as an argument to the key() function.  I won't go into all the details. You can use other problem-specific logic to find the "neighbors" of your node.

The next bit is also tricky.  The todo variable is a node-set, that I'm treating as a list.  $todo[1] is the head of the list.  $todo[position() != 1] is everything but the head.  So I have a built in CAR/CDR functions (remember LISP?).

Finally, given that you have two lists of items, how do you select items in the first list that aren't also in the second list.  This is how you do that: $first[not(. = $second)].
Where most people go wrong is in writing: $first[. != $second].  Since . and $second are node-sets, they use node-set comparision logic.  X = Y is true for node-sets X and Y if the string values of any to nodes in X and Y are the same.  X != Y is true if there is a node in X whose string value is not = to the string value of a node in Y.  If you don't believe me, read the spec.  Anyway, I showed you this little trick a few weeks ago.

This works, but the output wasn't in the order I expected.  My list is really a priority queue.  The nodes in the node-set are processed in document order.  So, when I "remove" the first node from the list, I'm actually getting the first @name attribute that appears in the document.  That is NOT the order I'm adding them in however.  They get added in whatever order the Schema follows.

It's important to me that I process this stuff in BFS order, because it makes it easier to follow the documentation that way.  To fix that, I had to use another XSLT trick, and that was to keep the lists in document fragments, which I then converted to node-sets using the EXSLT node-set() extension.

BTW: It isn't clear to me yet whether BFS or DFS produces a better order for documentation, but either one can be made to work.

The final XSLT for creating my table of contents can be found here.

This took me about four hours to figure out.  It created more work for me because I was able to see what content was missing.  It also vastly improved the HQMF result because the content is generated from the HQMF artifacts, so I cleaned up a lot of naming errors introduced by a new version of the HL7 RIM and Datatypes (we were using an much older RIM and Datatypes R1.1 for HQMF Release 1.0).  And because I was able to fix those errors, I'm a lot happier about the ballot quality (although still not satisfied).  I'll probably feel better after I get some sleep.