Index: qrda/C0Q/trunk/p/C0QMU12.m
===================================================================
--- qrda/C0Q/trunk/p/C0QMU12.m	(revision 1519)
+++ qrda/C0Q/trunk/p/C0QMU12.m	(revision 1572)
@@ -1,4 +1,4 @@
-C0QMU12	;JJOH/ZAG/GPL - Patient Reminder List ; 7/31/12 12:34pm
-	;;1.0;C0Q;;May 21, 2012;Build 63
+C0QMU12	;JJOH/ZAG/GPL - Patient Reminder List ; 10/10/12 11:28am
+	;;1.0;QUALITY MEASURES;**1**;May 21, 2012;Build 32
 	;
 	;2011 Zach Gonzales<zach@linux.com> - Licensed under the terms of the GNU
@@ -78,8 +78,10 @@
 	K C0QLIST
 	S C0QLIST(ZYR_"HasDemographics")=""
-	S C0QLIST(ZYR_"Patient")=""
+	S C0QLIST(ZYR_"Patient")="" ; VEN/SMH - Is this needed? Not used in EP.
 	S C0QLIST(ZYR_"HasProblem")=""
 	S C0QLIST(ZYR_"HasAllergy")=""
 	S C0QLIST(ZYR_"HasMed")=""
+	S C0QLIST(ZYR_"HasERX")="" ; VEN/SMH C0Q*1*5
+	S C0QLIST(ZYR_"HasMedRecon")="" ; VEN/SMH C0Q*1*5
 	S C0QLIST(ZYR_"HasVitalSigns")=""
 	S C0QLIST(ZYR_"HasMedOrders")=""
@@ -224,4 +226,5 @@
 	D DT^DILF(,"JULY 3,2011",.C0QSDT) ; START DATE
 	D DT^DILF(,"T",.C0QEDT) ; END DATE TODAY
+	S C0QEDT=C0QEDT+.999999 ; Move to the end of the day! VEN/SMH C0Q*1*5
 	D VITALS^ORQQVI(.VITRSLT,DFN,C0QSDT,C0QEDT) ; CALL FAST VITALS
 	I $D(VITRSLT) D  ;ZWR VITRSLT B  ;
@@ -347,5 +350,6 @@
 	S ZI="" ; BEGIN AT LATEST DATE FOR THIS LOC IN VISIT FILE
 	F  S ZI=$O(^AUPNVSIT("AHL",ULOC,ZI)) Q:(ZI="")!(ZI>IDTE)  D  ; FOR EACH DATE
-	. W !,$$FMTE^XLFDT(9999999-ZI) ;B  ;
+	. N C0QDATE S C0QDATE=9999999-$P(ZI,".")_"."_$P(ZI,".",2) ; VEN/SMH *5
+	. W !,$$FMTE^XLFDT(C0QDATE) ; VEN/SMH *5
 	. I ZI="" Q  ;
 	. N ZJ S ZJ=""
@@ -389,4 +393,6 @@
 	S DFN=""
 	S ZYR=ZYR_"EP-"
+	D INITCLST ; VEN/SMH - Initialize Empty Lists just in case we don't have
+	           ; any. C0Q*1*5
 	F  S DFN=$O(C0QLIST(ZYR_"ALL-PATIENTS",DFN)) Q:DFN=""  D  ; EACH PATIENT
 	. D DEMO^C0QMU122
@@ -398,9 +404,17 @@
 	. D VITALS
 	D FILE ; FILE THE PATIENT LISTS
-	N C0QCIEN
-	S ZI=""
+	; 
+	; Now process eRx MU measures for these patients
+	; Check for eRx template and code first; if they exist, run the code
+	I $D(^C0PX("B","GETMEDS6")),$L($T(SOAP^C0PWS2)) DO
+	. N C0QDEBUG S C0QDEBUG=1 ; This causes the code to print out data;
+	. D EN^C0QMUERX($$PATLN^C0QMU12(ZYR_"HasERX")) ; Pass the eRx patient list
+	;
+	N ZI S ZI=""
 	F  S ZI=$O(C0QPARM(ZI)) Q:ZI=""  D  ;
-	. S C0QCIEN=C0QPARM(ZI,"EPMeasurementSet") ; ien of measurement set
-	. D UPDATE^C0QUPDT(.G,C0QCIEN) ; UPDATE THE MU MEASUREMENT SET
+	. N C0QDEBUG S C0QDEBUG=1 ; This causes the code to print out data;
+	. D UPDATE^C0QUPDT(.G,C0QPARM(ZI,"EPMeasurementSet")) ; UPDATE THE MU MEASUREMENT SET
+	. ; VEN/SMH -- Quality Set missing for Outpatient -- adding
+	. D UPDATE^C0QUPDT(.G,C0QPARM(ZI,"EPQualitySet")) ; C0Q*1*5
 	Q
 	;
Index: qrda/C0Q/trunk/p/C0QUPDT.m
===================================================================
--- qrda/C0Q/trunk/p/C0QUPDT.m	(revision 1519)
+++ qrda/C0Q/trunk/p/C0QUPDT.m	(revision 1572)
@@ -1,4 +1,4 @@
-C0QUPDT	; GPL - Quality Reporting List Update Routines ; 5/30/12 3:47pm
-	;;1.0;C0Q;;May 21, 2012;Build 44
+C0QUPDT	; GPL - Quality Reporting List Update Routines ; 10/10/12 11:36am
+	;;1.0;C0Q;**1**;May 21, 2012;Build 32
 	;Copyright 2009 George Lilly.  Licensed under the terms of the GNU
 	;General Public License See attached copy of the License.
@@ -48,8 +48,8 @@
 	. ; 
 	. ; Special processing for eRx measure.
-	. I $P(C0QM(ZII),U,2)="MU EP ERX" D ERXCOUNT(MSET,ZII) QUIT
+	. I $$GET1^DIQ(1130580001.101,+C0QM(ZII)_",",4,"I")="E" D ERXCOUNT(MSET,ZII) Q
 	. ;
 	. ; Otherwise, we go on
-	. N C0QNL,C0QDL,C0QFLTN,C0QFLTD
+	. N C0QNL,C0QDL,C0QFLTN,C0QFLTD,C0QNALT ; VEN/SMH - line changed in *5 
 	. S C0QFLTN=$P(C0QM(ZII),U,3) ;IEN OF NUMERATOR FILTER LIST
 	. S C0QFLTD=$P(C0QM(ZII),U,4) ; IEN OF DENOMINATOR FILTER LIST
@@ -204,5 +204,5 @@
 	K ZERR
 	D CLEAN^DILF
-	N % S %=$NA(C0QFDA) F  S %=$Q(@%) Q:%=""  W %_"="_@%,! ; smh instead of zwrite
+	D ZWRITE^C0QUTIL("C0QFDA")
 	D UPDATE^DIE("","C0QFDA","","ZERR")
 	I $D(ZERR) S ZZERR=ZZERR ; ZZERR DOESN'T EXIST, INVOKE THE ERROR TRAP IF TASKED
@@ -213,66 +213,71 @@
 	Q
 	;
-ERXCOUNT(MSETIEN,MIEN) ; Private Proc; Get eRx and file as Numerator, Denominator, and %
- ; Inputs:
- ; MSETIEN - Measurement Set IEN - By Value
- ; MIEN - Measurement IEN inside the Measurement Set - By Value
- ; No check is done to see if the caller is sending bad data. Measurement must be
- ; in a subfile under Measurement Set.
- ;
- ; Example of Data we go through in the C0Q Parameter File, so the code below
- ; will make sense.
- ; ^C0Q(401,"AMMS",2,1)=""
- ; ^C0Q(401,"AMMS",2,2)=""
- ; ^C0Q(401,"AQMS",6,2)=""
- ; ^C0Q(401,"B","INPATIENT",2)=""
- ; ^C0Q(401,"B","OUTPATIENT",1)=""
- ; ^C0Q(401,"MU","MU12",1)=""
- ; ^C0Q(401,"MU","MU12",2)=""
- ; ^C0Q(401,"MUTYP","MU12","EP",1)=""
- ; ^C0Q(401,"MUTYP","MU12","INP",2)=""
- ;
- ; Get Parameter year from the Parameters file.
- ; 1. Get parameter associated with this measurement set from AMMS x-ref (new in C0Q*1*1).
- N C0QPARAM
- N % S %="" F  S %=$O(^C0Q(401,"AMMS",MSETIEN,%)) Q:%=""  S C0QPARAM(%)=""
- ;
- ; 2. Find the year for each of those--store as value of node; IEN still subscript.
- N % S %="" F  S %=$O(C0QPARAM(%)) Q:%=""  S C0QPARAM(%)=$$GET1^DIQ(1130580001.401,%_",",.02)
- ;
- ; 3. Now make sure that this parameter that point to an Outpatient Parameters
- ; WARNING: CONFUSING CODE WRITTEN BY ME AHEAD
- ; The % loop will stop with a valid value if found; % is used in the lines immediately below
- N % S %="" F  S %=$O(C0QPARAM(%)) Q:%=""  Q:$D(^C0Q(401,"MUTYP",C0QPARAM(%),"EP",%))
- ;
- ; 4. If % has a valid IEN (there can be multiple, we take the first), then off we go.
- ; Otherwise, if it is back to "", we quit.
- N MUYEAR
- IF '% W "No suitable parameter found. Cannot determine Measurement Year.",! QUIT
- ELSE  S MUYEAR=C0QPARAM(%)
- ; 
- ; Now, based on the MU year, construct the patient list name that has the eRx data.
- N LISTNAME S LISTNAME=MUYEAR_"-"_"EP"_"-"_"HasERX"
- ;
- ; Call the API in C0QMUERX to get the counts already calculated
- ; Data is returned NUM/DEN
- N COUNTS S COUNTS=$$COUNT^C0QMUERX($$PATLN^C0QMU12(LISTNAME))
- ;
- ; File the count
- N NUM S NUM=$P(COUNTS,"/") ; Numerator
- N DEN S DEN=$P(COUNTS,"/",2) ; Denominator
- ;
- ; Prepare FDA
- N C0QFDA,C0QERR
- S C0QFDA($$C0QMMFN(),MIEN_","_MSETIEN_",",1.1)=NUM ; Numerator
- S C0QFDA($$C0QMMFN(),MIEN_","_MSETIEN_",",2.1)=DEN ; Denominator
- S C0QFDA($$C0QMMFN(),MIEN_","_MSETIEN_",",3)=$S(DEN=0:0,1:$J(100*NUM/DEN,0,0)) ; Percentage; avoid dividing by zero!
- ;
- ; File FDA using Filer not updater (editing existing entry only)
- D FILE^DIE("ET",$NAME(C0QFDA),$NAME(C0QERR)) ; Flags: External, Transaction
- ;
- ; If error, print it out
- I $D(C0QERR) DO
- . W "Error filing data",!
- . N % S %=$NAME(C0QERR) F  S %=$Q(@%) Q:%=""  W %_": "_@%,!
- ;
- QUIT
+ERXCOUNT(MSETIEN,MIEN)	; Private Proc; Get eRx and file as Numerator, Denominator, and %
+	; Inputs:
+	; MSETIEN - Measurement Set IEN - By Value
+	; MIEN - Measurement IEN inside the Measurement Set - By Value
+	; 
+	; Optional Symtab input: C0QDEBUG to print out debug messages to STDOUT.
+	; ZEXCEPT: C0QDEBUG ; For Dr. Ivey's parser.
+	;
+	; No check is done to see if the caller is sending bad data. Measurement must be
+	; in a subfile under Measurement Set.
+	;
+	W:$G(C0QDEBUG) "Processing E-Prescribing Counts",!
+	; Example of Data we go through in the C0Q Parameter File, so the code below
+	; will make sense.
+	; ^C0Q(401,"AMMS",2,1)=""
+	; ^C0Q(401,"AMMS",2,2)=""
+	; ^C0Q(401,"AQMS",6,2)=""
+	; ^C0Q(401,"B","INPATIENT",2)=""
+	; ^C0Q(401,"B","OUTPATIENT",1)=""
+	; ^C0Q(401,"MU","MU12",1)=""
+	; ^C0Q(401,"MU","MU12",2)=""
+	; ^C0Q(401,"MUTYP","MU12","EP",1)=""
+	; ^C0Q(401,"MUTYP","MU12","INP",2)=""
+	;
+	; Get Parameter year from the Parameters file.
+	; 1. Get parameter associated with this measurement set from AMMS x-ref (new in C0Q*1*1).
+	N C0QPARAM
+	N % S %="" F  S %=$O(^C0Q(401,"AMMS",MSETIEN,%)) Q:%=""  S C0QPARAM(%)=""
+	;
+	; 2. Find the year for each of those--store as value of node; IEN still subscript.
+	N % S %="" F  S %=$O(C0QPARAM(%)) Q:%=""  S C0QPARAM(%)=$$GET1^DIQ(1130580001.401,%_",",.02)
+	;
+	; 3. Now make sure that this parameter that point to an Outpatient Parameters
+	; WARNING: CONFUSING CODE WRITTEN BY ME AHEAD
+	; The % loop will stop with a valid value if found; % is used in the lines immediately below
+	N % S %="" F  S %=$O(C0QPARAM(%)) Q:%=""  Q:$D(^C0Q(401,"MUTYP",C0QPARAM(%),"EP",%))
+	;
+	; 4. If % has a valid IEN (there can be multiple, we take the first), then off we go.
+	; Otherwise, if it is back to "", we quit.
+	N MUYEAR
+	IF '% W "No suitable parameter found. Cannot determine Measurement Year.",! QUIT
+	ELSE  S MUYEAR=C0QPARAM(%)
+	; 
+	; Now, based on the MU year, construct the patient list name that has the eRx data.
+	N LISTNAME S LISTNAME=MUYEAR_"-"_"EP"_"-"_"HasERX"
+	;
+	; Call the API in C0QMUERX to get the counts already calculated
+	; Data is returned NUM/DEN
+	N COUNTS S COUNTS=$$COUNT^C0QMUERX($$PATLN^C0QMU12(LISTNAME))
+	;
+	; File the count
+	N NUM S NUM=$P(COUNTS,"/") ; Numerator
+	N DEN S DEN=$P(COUNTS,"/",2) ; Denominator
+	;
+	; Prepare FDA
+	N C0QFDA,C0QERR
+	S C0QFDA($$C0QMMFN(),MIEN_","_MSETIEN_",",1.1)=NUM ; Numerator
+	S C0QFDA($$C0QMMFN(),MIEN_","_MSETIEN_",",2.1)=DEN ; Denominator
+	S C0QFDA($$C0QMMFN(),MIEN_","_MSETIEN_",",3)=$S(DEN=0:0,1:$J(100*NUM/DEN,0,0)) ; Percentage; avoid dividing by zero!
+	;
+	; File FDA using Filer not updater (editing existing entry only)
+	D FILE^DIE("ET",$NAME(C0QFDA),$NAME(C0QERR)) ; Flags: External, Transaction
+	;
+	; If error, print it out
+	I $D(C0QERR) DO
+	. W "Error filing data",!
+	. N % S %=$NAME(C0QERR) F  S %=$Q(@%) Q:%=""  W %_": "_@%,!
+	;
+	QUIT
