Index: qrda/C0Q/trunk/p/C0QMU12.m
===================================================================
--- qrda/C0Q/trunk/p/C0QMU12.m	(revision 1577)
+++ qrda/C0Q/trunk/p/C0QMU12.m	(revision 1581)
@@ -1,4 +1,4 @@
-C0QMU12	;JJOH/ZAG/GPL - Patient Reminder List ; 10/17/12 12:52pm
-	;;1.0;QUALITY MEASURES;**1,5**;May 21, 2012;Build 32
+C0QMU12	;JJOH/ZAG/GPL - Patient Reminder List ; 10/22/12 4:29pm
+	;;1.0;QUALITY MEASURES;**1,5,6**;May 21, 2012;Build 32
 	;
 	;2011 Zach Gonzales<zach@linux.com> - Licensed under the terms of the GNU
@@ -10,5 +10,5 @@
 C0QPFN()	Q 1130580001.401 ; PARAMETER FILE
 C0QPCFN()	Q 1130580001.411 ; CLINIC SUBFILE
-C0QMFN()	Q 1130580001.201 ; FILE NUMBER FOR C0Q MEASUREMENT FILE
+C0QMFN()	Q 1130580001.201 ; FILE NUMBER FOR C0Q MEASUREMENT SET FILE
 C0QMMFN()	Q 1130580001.2011 ; FN FOR MEASURE SUBFILE
 INIT(ZARY,ZTYP)	; INITIALIZE THE PARAMETERS FOR BUILDING PATIENT LISTS
@@ -25,17 +25,22 @@
 	F  S ZIEN=$O(^C0Q(401,"MUTYP",ZMU,ZTYP,ZIEN)) Q:ZIEN=""  D  ;
 	. S ZCNT=ZCNT+1
+	. S @ZARY@(ZCNT,"IEN")=ZIEN
 	. S @ZARY@(ZCNT,"MU")=$$GET1^DIQ($$C0QPFN,ZIEN_",",.02)
 	. S @ZARY@(ZCNT,"TYPE")=$$GET1^DIQ($$C0QPFN,ZIEN_",",.03)
-	. S ZX=$$GET1^DIQ($$C0QPFN,ZIEN_",",1,"I")
-	. S @ZARY@(ZCNT,"InpatientMeasurementSet")=ZX
+	. ;
+	. ; Inpatient
+	. S (ZX,@ZARY@(ZCNT,"InpatientMeasurementSet"))=$$GET1^DIQ($$C0QPFN,ZIEN_",",1,"I")
 	. S @ZARY@(ZCNT,"InpatientBeginDate")=$$GET1^DIQ($$C0QMFN,ZX_",",.02,"I")
 	. S @ZARY@(ZCNT,"InpatientEndDate")=$$GET1^DIQ($$C0QMFN,ZX_",",.03,"I")
 	. S @ZARY@(ZCNT,"InpatientQualitySet")=$$GET1^DIQ($$C0QPFN,ZIEN_",",1.1,"I")
-	. S ZX=$$GET1^DIQ($$C0QPFN,ZIEN_",",2,"I")
-	. S @ZARY@(ZCNT,"EPMeasurementSet")=ZX
+	. ;
+	. ; Outpatient
+	. S (ZX,@ZARY@(ZCNT,"EPMeasurementSet"))=$$GET1^DIQ($$C0QPFN,ZIEN_",",2,"I")
 	. S @ZARY@(ZCNT,"EPBeginDate")=$$GET1^DIQ($$C0QMFN,ZX_",",.02,"I")
 	. S @ZARY@(ZCNT,"EPEndDate")=$$GET1^DIQ($$C0QMFN,ZX_",",.03,"I")
 	. S @ZARY@(ZCNT,"EPQualitySet")=$$GET1^DIQ($$C0QPFN,ZIEN_",",2.1,"I")
-	. S @ZARY@(ZCNT,"InpatientQualitySet")=$$GET1^DIQ($$C0QPFN,ZIEN_",",1.1,"I")
+	. S @ZARY@(ZCNT,"EPModelPerfSet")=$$GET1^DIQ($$C0QPFN,ZIEN_",",6.1,"I")
+	. S @ZARY@(ZCNT,"EPModelQualitySet")=$$GET1^DIQ($$C0QPFN,ZIEN_",",6.2,"I")
+	. ;
 	. D CLEAN^DILF
 	. D LIST^DIC($$C0QPCFN,","_ZIEN_",",".01I")
@@ -346,4 +351,6 @@
 	; PREFIX WILL GO IN C0XLIST(PREFIX_"-PATIENT",DFN)=""
 	; LOC IS HOSPITAL LOCATION
+	; Initially, make an empty list (C0Q*1.0*6)
+	S C0QLIST(PREFIX_"Patient")=""
 	S ULOC=$O(^SC("B",LOC,"")) ; IEN OF HOSPITAL LOCATION
 	I ULOC="" D  Q  ; OOPS
@@ -394,4 +401,6 @@
 	. I $D(DEBUG) D ZWRITE^C0QUTIL("C0QLIST")
 	. M C0QLIST(ZYR_"EP-ALL-PATIENTS")=C0QLIST(PRE_"Patient")
+	. ; update parameter list with filter list (1.0*6)
+	. S C0QPARM(ZI,"FilterListName")=PRE_"Patient"
 	S DFN=""
 	S ZYR=ZYR_"EP-"
@@ -413,8 +422,49 @@
 	. 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  ;
 	. N C0QDEBUG S C0QDEBUG=1 ; This causes the code to print out data;
+	. I 'C0QPARM(ZI,"EPMeasurementSet"),C0QPARM(ZI,"EPModelPerfSet") D
+	. . N C0QCLNC S C0QCLNC=C0QPARM(ZI,"CLINICS",1,1)
+	. . N FLN S FLN=C0QPARM(ZI,"FilterListName")
+	. . ;
+	. . ; 1. BUILD New Measure Set from Model Performance Measure Set
+	. . ; Get IEN back of the newly created measure set.
+	. . N MSIEN ; Measure Set IEN that gets created
+	. . S MSIEN=$$CLONE^C0QMU123(C0QPARM(ZI,"EPModelPerfSet"),C0QCLNC,0,FLN)
+	. . ;
+	. . ; 2. File Measure Set
+	. . N C0QFDA S C0QFDA($$C0QPFN(),C0QPARM(ZI,"IEN")_",",2)=MSIEN
+	. . N C0QERR
+	. . D FILE^DIE("",$NA(C0QFDA),$NA(C0QERR))
+	. . I $D(C0QERR) S $EC=",U1,"
+	. . ;
+	. . ; 3. Set this IEN to be the one in EPMeasurementSet
+	. . S C0QPARM(ZI,"EPMeasurementSet")=MSIEN
+	. . ; DONE
+	. . ;
+	. I 'C0QPARM(ZI,"EPQualitySet"),C0QPARM(ZI,"EPModelQualitySet") D
+	. . N C0QCLNC S C0QCLNC=C0QPARM(ZI,"CLINICS",1,1)
+	. . N FLN S FLN=C0QPARM(ZI,"FilterListName")
+	. . ;
+	. . ; 1. BUILD New Measure Set from Model Performance Measure Set
+	. . ; Get IEN back of the newly created measure set.
+	. . N MSIEN ; Measure Set IEN that gets created
+	. . S MSIEN=$$CLONE^C0QMU123(C0QPARM(ZI,"EPModelQualitySet"),C0QCLNC,1,FLN)
+	. . ;
+	. . ; 2. File Measure Set
+	. . N C0QFDA S C0QFDA($$C0QPFN(),C0QPARM(ZI,"IEN")_",",2.1)=MSIEN
+	. . N C0QERR
+	. . D FILE^DIE("",$NA(C0QFDA),$NA(C0QERR))
+	. . I $D(C0QERR) S $EC=",U1,"
+	. . ;
+	. . ; 3. Set this IEN to be the one in EPMeasurementSet
+	. . S C0QPARM(ZI,"EPQualitySet")=MSIEN
+	. . ; DONE
+	. ;
+	. ; Quit if we still don't have measurement sets
+	. I 'C0QPARM(ZI,"EPMeasurementSet")&('C0QPARM(ZI,"EPQualitySet")) QUIT
+	. ;
 	. D UPDATE^C0QUPDT(.G,C0QPARM(ZI,"EPMeasurementSet")) ; UPDATE THE MU MEASUREMENT SET
 	. ; VEN/SMH -- Quality Set missing for Outpatient -- adding
