Index: qrda/C0Q/trunk/p/C0QMU12.m
===================================================================
--- qrda/C0Q/trunk/p/C0QMU12.m	(revision 1335)
+++ qrda/C0Q/trunk/p/C0QMU12.m	(revision 1361)
@@ -1,4 +1,4 @@
-C0QMU12 ;JJOH/ZAG/GPL - Patient Reminder List for 2012 ;7/5/11 8:50pm
- ;;1.0;MU PACKAGE;;;Build 20
+C0QPRML ;JJOH/ZAG/GPL - Patient Reminder List ;7/5/11 8:50pm
+ ;;1.0;MU PACKAGE;;;Build 26
  ;
  ;2011 Zach Gonzales<zach@linux.com> - Licensed under the terms of the GNU
@@ -21,4 +21,42 @@
  ; GPL - THIS ROUTINE IS A COPY OF JJOHMU11 THAT HAS BEEN MODIFIED
  ; FOR MEANINGFUL USE CALCULATION FOR FISCAL YEAR 2012 AT OROVILLE HOSPITAL
+ ;
+C0QPFN() Q 1130580001.401 ; PARAMETER FILE
+C0QPCFN() Q 1130580001.411 ; CLINIC SUBFILE
+C0QMFN() Q 1130580001.201 ; FILE NUMBER FOR C0Q MEASUREMENT FILE
+C0QMMFN() Q 1130580001.2011 ; FN FOR MEASURE SUBFILE
+INIT(ZARY,ZTYP) ; INITIALIZE THE PARAMETERS FOR BUILDING PATIENT LISTS
+ ; ZARY IS PASSED BY NAME
+ ; ZTYP IS "INP" OR "EP"
+ N ZMU S ZMU="MU12" ; THIS IS THE ONLY HARD CODED VALUE LEFT
+ ; TBD - CHANGE IT TO A READ FROM SYSTEM PARAMETERS
+ K @ZARY ; CLEAR RETURN ARRAY
+ N ZIEN,ZCNT,ZX
+ I $O(^C0Q(401,"MUTYP",ZMU,ZTYP,""))="" D  Q  ; OOPS NO RECORD THERE
+ . W !,"ERROR, NO PARAMETERS AVAILABLE"
+ S ZIEN=""
+ S ZCNT=0
+ F  S ZIEN=$O(^C0Q(401,"MUTYP",ZMU,ZTYP,ZIEN)) Q:ZIEN=""  D  ;
+ . S ZCNT=ZCNT+1
+ . 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
+ . 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
+ . 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")
+ . D CLEAN^DILF
+ . D LIST^DIC($$C0QPCFN,","_ZIEN_",",".01I")
+ . I $D(^TMP("DIERR",$J)) D  Q  ; ERROR READING CLINIC LIST
+ . . W !,"ERROR READING CLINIC PARAMETER LIST"
+ . M @ZARY@(ZCNT,"CLINICS")=^TMP("DILIST",$J)
+ ;
+ Q
  ;
 BUILD ; CALL ALL AND DIS AND BUILD THE GRSLT ARRAY or print or create
@@ -49,4 +87,45 @@
  . D UPDATE^C0QUPDT(.G,10) ; UPDATE THE MU MEASUREMENT SET - CHANGE EVERY YR
  . D UPDATE^C0QUPDT(.G,11) ; UPDATE THE MU MEASUREMENT SET - CHANGE EVERY YR
+ Q
+ ;
+BUILD2 ; CALL ALL AND DIS AND BUILD THE GRSLT ARRAY or print or create
+ ; patient lists
+ ;N GRSLT ; ARRAY FOR RESULTS
+ I '$D(C0QSS) S C0QSS=0 ;default don't build spreadsheet array
+ I '$D(C0QPR) S C0QPR=0 ;default don't print out results
+ I '$D(C0QPL) S C0QPL=1 ;default do create patient lists
+ S ZYR="MU12-"
+ D INITCLST ; initialize C0QLIST
+ N G1 ; ONE SET OF VALUES - RNF1 FORMAT
+ N C0QPARM
+ D INIT("C0QPARM","INP") ; initialize inpatient parms
+ I $O(C0QPARM(""))="" D  Q  ; no parms for inpatient
+ . W !,"No inpatient parameters"
+ N ZDIV S ZDIV=""
+ F  S ZDIV=$O(C0QPARM(ZDIV)) Q:ZDIV=""  D  ; for each inpatient division
+ . D ALL ; all currently admitted patients in the hospital
+ . D DIS ; all patients discharged since the reporting period began
+ . I C0QSS ZWR GRSLT
+ . D ICUPAT ; GENERATE ICU PATIENT LIST
+ . I C0QPL D  ;
+ . . D FILE ; FILE THE PATIENT LISTS
+ . . D UPDATE^C0QUPDT(.G,C0QPARM(ZDIV,"InpatientMeasurementSet")) ; 
+ . . D UPDATE^C0QUPDT(.G,C0QPARM(ZDIV,"InpatientQualitySet")) ; 
+ . K C0QLIST
+ Q
+ ;
+INITCLST ; initialize C0QLIST
+ ; INITIALIZE LISTS
+ ; this is done so that if there are no matching patients, the patient list
+ ; will be zeroed out
+ K C0QLIST
+ S C0QLIST(ZYR_"HasDemographics")=""
+ S C0QLIST(ZYR_"Patient")=""
+ S C0QLIST(ZYR_"HasProblem")=""
+ S C0QLIST(ZYR_"HasAllergy")=""
+ S C0QLIST(ZYR_"HasMed")=""
+ S C0QLIST(ZYR_"HasVitalSigns")=""
+ S C0QLIST(ZYR_"HasMedOrders")=""
+ S C0QLIST(ZYR_"HasSmokingStatus")=""
  Q
  ;
@@ -738,13 +817,20 @@
  ;
 DOEP ; DO EP COMPUTATIONS
- S DTE=3111000
+ S ZYR="MU12-"
+ N C0QPARM,C0QCLNC
+ D INIT("C0QPARM","EP") ; INITIALIZE PARAMETERS
  K C0QLIST ; CLEAR THE LIST
- S PRE="MU12-EP-OIM-BOWEN-"
- S ZYR=PRE
- D LOCPAT(PRE,"OIM-BOWEN") ; GET THE PATIENTS
- ZWR C0QLIST
- ;B
+ N ZI S ZI=""
+ F  S ZI=$O(C0QPARM(ZI)) Q:ZI=""  D  ; FOR EACH EP
+ . S DTE=C0QPARM(ZI,"EPBeginDate") ; beginning of measurement period
+ . S EDTE=C0QPARM(ZI,"EPEndDate") ; end of measurement period -- tbd use this
+ . S C0QCLNC=C0QPARM(ZI,"CLINICS",1,1) ; only one clinic for now
+ . S PRE=ZYR_"EP-"_C0QCLNC_"-"
+ . D LOCPAT(PRE,C0QCLNC) ; GET THE PATIENTS
+ . I $D(DEBUG) ZWR C0QLIST
+ . M C0QLIST(ZYR_"EP-ALL-PATIENTS")=C0QLIST(PRE_"Patient")
  S DFN=""
- F  S DFN=$O(C0QLIST(PRE_"Patient",DFN)) Q:DFN=""  D  ; FOR EACH PATIENT
+ S ZYR=ZYR_"EP-"
+ F  S DFN=$O(C0QLIST(ZYR_"EP-ALL-PATIENTS",DFN)) Q:DFN=""  D  ; EACH PATIENT
  . D DEMO
  . D PROBLEM
@@ -755,5 +841,9 @@
  . D VITALS
  D FILE ; FILE THE PATIENT LISTS
- D UPDATE^C0QUPDT(.G,12) ; UPDATE THE MU MEASUREMENT SET - CHANGE EVERY YR
+ N C0QCIEN
+ 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
  Q
  ;
