Friday, November 18, 2011

Implementing Min, Max, First and Most Recent for EQMF

One of the commenters on this blog pointed out an interpretation error in my implementation of the NQF Measure for HbA1C control.  Instead of reporting on the most recent value of the HbA1C being over 9%, I had reported against any result in the time period being over 9%, which is not what the measure was asking for.

This is "new functionality" in my implementations, so I had to go back and see how easy it would be to fix.  It turns out it wasn't hard, but I also found another problem in HQMF while I was at it.

The <entry> elements in which the data criteria are specified need to be able to indicate whether the data element is the most recent, first, max or min in the reporting period.  To do that, I needed to add the <subsetCode> element to the HQMF format.  The subsetCode allows you to identify which data elements to select in the precondition.

For hQuery, implementing this was pretty simple.  There's a match() function, and I just made a small design change.  The transformation assumes the match() function returns a collection of objects, and I added selector functions to the collection class that would return the first, most recent, min and max objects.

The XQuery implementation was nearly as simple.  I just pass the code (MIN, MAX, FIRST, RECENT) to the match() function that it implements, and let it take care of the right selections using an order by clause on effectiveTime/@value or value/@value.

The SQL Implementation also turned out to be pretty easy and works almost the same way as the XQuery implementation.  I needed to turn this:


CREATE VIEW NUMERATOR AS (/* HbA1C*/
 SELECT DISTINCT PATIENTID FROM LabResults
  WHERE ( 
   CODE IN (SELECT CODE FROM VALUESETS WHERE ID = '2.16.840.1.113883.3.464.1.72')
   AND VALUE &gt; 9 AND UNITS = '%'
 )
);



Into this when there is a subsetCode element present:
CREATE VIEW NUMERATOR AS (/* HbA1C*/
 SELECT DISTINCT PATIENTID FROM LabResults
  WHERE ( 
   ID IN (SELECT TOP 1 FROM LabResults O WHERE LabResults.PATIENTID = O.PATIENTID ORDER BY EFFECTIVETIME DESC ) AND 
   CODE IN (SELECT CODE FROM VALUESETS WHERE ID = '2.16.840.1.113883.3.464.1.72')
   AND VALUE &gt; 9 AND UNITS = '%'
 )
);

If the code had been FIRST, I would have ORDER BY EFFECTIVETIME ASC, and if MIN or MAX, I would have ORDER BY VALUE [ASC|DESC].  So, problem solved and new feature added.  Oh, and ID is a new column I added to all the tables so that I can do just this sort of thing.

This is exactly the kind of thing that needs to go into a guide for developing an HQMF query, and is the kind of input I'll be providing to HL7 when they update the standard.



1 comment:

  1. Keith - why did you call it EQMF ?

    I recall that there were references to "E" early on .. but we settled on the "H" since it was HEALTH we're interested in .. not ELECTRONICS .. eh?

    ReplyDelete