Changeset 1518 for qrda/C0Q/trunk
- Timestamp:
- Aug 20, 2012, 10:04:00 PM (12 years ago)
- Location:
- qrda/C0Q/trunk
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
qrda/C0Q/trunk/p/C0QQRDA.m
r1517 r1518 1 C0QQRDA ; GPL - Quality Reporting QRDA Processing ; 8/ 1/12 4:24pm1 C0QQRDA ; GPL - Quality Reporting QRDA Processing ; 8/2/12 12:42am 2 2 ;;1.0;QUALITY MEASURES;**4**;May 21, 2012;Build 28 3 3 ;Copyright 2012 George Lilly. Licensed under the terms of the GNU … … 18 18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 19 ; 20 EN 21 N REF S REF=$NAME(^TMP("C0QQRDA",$J)) 22 K @REF 23 D WORK(REF) 24 D PRINTXML(REF) 25 QUIT 26 ; 27 ; Get measure set iens from Measure Set file 28 ; TODO: Populate from a config file. 29 WORK(C0QREF) 30 N C0Q1 S C0Q1=$O(^C0Q(201,"B","ED CMS REPORTING MEASURES","")) 31 N C0Q2 S C0Q2=$O(^C0Q(201,"B","STK CMS REPORTING MEASURES","")) 32 N C0Q3 S C0Q3=$O(^C0Q(201,"B","VTE CMS REPORTING MEASURES","")) 33 ; 34 ; For each measure, write it, count totals and move patients over 35 N C0QX F C0QX="C0Q1","C0Q2","C0Q3" D 36 . Q:'@C0QX 37 . D EN^DDIOL(@C0QX_": "_^C0Q(201,@C0QX,0)) 38 . D EN^DDIOL("") 39 . D UPDATE^C0QUPDT(.A,@C0QX) 40 . ; 41 . ; Get QRDA code for Measure Set. 42 . N C0QMSQRDA S C0QMSQRDA=$$GET1^DIQ($$C0QMFN^C0QUPDT(),@C0QX_",","QRDA TEMPLATE ROOT") 43 . N C0QI S C0QI=0 ; Fileman IEN looper 44 . F S C0QI=$O(^C0Q(201,@C0QX,5,C0QI)) Q:'C0QI D ; For each measure 45 . . N C0QMEASUREQRDA S C0QMEASUREQRDA=$$GET1^DIQ($$C0QMMFN^C0QUPDT(),C0QI_","_@C0QX_",",".01:QRDA TEMPLATE ROOT") 46 . . N C0QP S C0QP=0 47 . . F S C0QP=$O(^C0Q(201,@C0QX,5,C0QI,3,C0QP)) Q:'C0QP D ; For each patient in denominator 48 . . . N C0QDFN S C0QDFN=+^(C0QP,0) 49 . . . S @C0QREF@(C0QDFN,C0QMSQRDA,C0QMEASUREQRDA)="" 50 QUIT 51 ; 52 PRINTXML(C0QREF) ; Print the XML; Private EP 20 EN ; Private to this Package; Main Entry Point for this routine 21 ; This EP is interactive or silent depending on params 22 ; 23 ; Check for config errors first 24 N % S %=$$CHECKERR() 25 I % D EN^DDIOL($P(%,U,2)) QUIT 26 ; 27 ; Print Intro 28 N % 29 S %(1)="This program collects patients from the denominators of the measures" 30 S %(2)="STK, VTE, and ED and outputs modified CCR files to the kernel default" 31 S %(3)="directory (probably /tmp/)." 32 S %(4)="" 33 S %(5)="This will take some time to execute." 34 S %(6)="" 35 S %(6,"F")="!!!" 36 ; 37 D EN^DDIOL(.%) 38 ; 39 ; Ask user which measure set to run 40 N DIR,DTOUT,DUOUT,X,Y,DIRUT,DIROUT,DA ; DIR variables 41 S DIR(0)="SB^V:VTE;S:STK;E:ED" 42 S DIR("A")="Measure to calculate" 43 S DIR("A",1)="Which measure set would you like to produce QRDA documents for?" 44 S DIR("A",2)="Choose to Run [V]TE Measure Set, [S]TK Measure Set, or " 45 S DIR("A",3)="[E]D Measure Set" 46 D ^DIR 47 ; 48 I $G(DTOUT)!$G(DUOUT) QUIT ; Did user hit '^' or time out? 49 ; 50 ; Get the Measure Set IEN which the user has seleted. 51 ; NB: field names start with VTE, STK, or ED; so I can use the output 52 ; of DIR directly. 53 ; 54 N FLD S FLD=Y(0) 55 N C0QMSIEN S C0QMSIEN=$$GET1^DIQ(1130580001.401,$$INPPARM(),FLD,"I") 56 ; 57 S:'C0QMSIEN $EC=",U1," ; Debug.Assert that MSIEN is numeric. 58 ; 59 ; Do the work 60 N REF S REF=$NAME(^TMP("C0QQRDA",$J)) ; Global for data collection 61 K @REF ; Clear global 62 D WORK(REF,C0QMSIEN) ; Process Measure Set, collect data in global 63 D PRINTXML(REF,FLD) ; Generate XML; output to File. 64 K @REF ; Clear global 65 QUIT 66 ; 67 ;SILENTEN(RETURN) ; For future RPC calls...; needs to be reworked. 68 ; N % S %=$$CHECKERR() 69 ; I % S RETURN(0)=% Q 70 ; 71 ; N DIQUIET S DIQUIET=1 72 ; D EN 73 ; S RETURN(0)=0 74 ; QUIT 75 ; 76 CHECKERR() ; Private Proc; Check if environment is okay. 77 ; Output: 0 -> Okay; +ve^message for error 78 N INPPARM S INPPARM=$$INPPARM() ; Inpatient Parameters IEN 79 I 'INPPARM Q 1_U_"No Inpatient Parameters found" 80 ; 81 ; Pointer fields to Measurement Set file, we grab the IENs 82 N C0QED S C0QED=$$GET1^DIQ(1130580001.401,INPPARM,"ED","I") 83 N C0QSTK S C0QSTK=$$GET1^DIQ(1130580001.401,INPPARM,"STK","I") 84 N C0QVTE S C0QVTE=$$GET1^DIQ(1130580001.401,INPPARM,"VTE","I") 85 ; 86 N TXT S TXT="" ; Error text 87 I 'C0QED S TXT=TXT_"ED," 88 I 'C0QSTK S TXT=TXT_"STK," 89 I 'C0QVTE S TXT=TXT_"VTE" 90 I $E(TXT,$L(TXT)=",") S TXT=$E(TXT,1,$L(TXT)-1) 91 I $L(TXT) Q 2_U_"Measure Sets missing from parameters: "_TXT 92 ; 93 QUIT 0 ; All okay 94 ; 95 WORK(C0QREF,C0QMSIEN) ; Private Proc; Process Measure Sets; Collect the data. 96 ; Input/Output: C0QREF -> Global for Output passed by Name 97 ; C0QMSIEN -> (Input): Measurement Set IEN to calculate 98 ; 99 ; Print 100 D EN^DDIOL(C0QMSIEN_": "_^C0Q(201,C0QMSIEN,0)) 101 D EN^DDIOL("") 102 ; 103 ; Calculate totals and move patients over from individual measures 104 D UPDATE^C0QUPDT(.A,C0QMSIEN) ; FYI: A isn't used. 105 ; 106 ; Get QRDA code for Measure Set. 107 N C0QMSQRDA S C0QMSQRDA=$$GET1^DIQ($$C0QMFN^C0QUPDT(),C0QMSIEN_",","QRDA TEMPLATE ROOT") 108 ; 109 N C0QI S C0QI=0 ; Fileman IEN looper 110 F S C0QI=$O(^C0Q(201,C0QMSIEN,5,C0QI)) Q:'C0QI D ; For each measure in Measure Set 111 . ; 112 . ; Get QRDA code using relational jump 113 . N C0QMEASUREQRDA S C0QMEASUREQRDA=$$GET1^DIQ($$C0QMMFN^C0QUPDT(),C0QI_","_C0QMSIEN_",",".01:QRDA TEMPLATE ROOT") 114 . ; 115 . ; Then collect patients in the denominator, and store in output global 116 . N C0QP S C0QP=0 117 . F S C0QP=$O(^C0Q(201,C0QMSIEN,5,C0QI,3,C0QP)) Q:'C0QP D ; For each patient in denominator 118 . . N C0QDFN S C0QDFN=+^(C0QP,0) 119 . . S @C0QREF@(C0QDFN,C0QMSQRDA,C0QMEASUREQRDA)="" 120 QUIT 121 ; 122 INPPARM() ; $$ Private; Get Inpatient Parameters IEN 123 ; Output: IEN of Inpatient Parameter in C0Q PARAMETER file 124 ; 125 ; Browse this tree of xrefs to get the IEN of INP type (last line here). 126 ; ^C0Q(401,"B","INPATIENT",2)="" 127 ; ^C0Q(401,"B","OUTPATIENT",1)="" 128 ; ^C0Q(401,"MU","MU12",1)="" 129 ; ^C0Q(401,"MU","MU12",2)="" 130 ; ^C0Q(401,"MUTYP","MU12","EP",1)="" 131 ; ^C0Q(401,"MUTYP","MU12","INP",2)="" 132 ; 133 N MUID S MUID="" ; Looper for MU Year ID 134 N FOUND S FOUND=0 ; Found flag to get out of loop 135 N IEN ; Output variable 136 F S MUID=$O(^C0Q(401,"MUTYP",MUID),-1) Q:MUID="" Q:FOUND D ; Loop backwards 137 . N TYP S TYP="" ; Type ("EP" or "INP") 138 . F S TYP=$O(^C0Q(401,"MUTYP",MUID,TYP)) Q:TYP="" Q:FOUND D 139 . . I TYP="INP" S IEN=$O(^(TYP,"")),FOUND=1 Q ; If found, get IEN, quit out of loops 140 QUIT +$G(IEN) 141 ; 142 PRINTXML(C0QREF,C0QMNM) ; Print the XML; Private Proc 143 ; Input: C0QREF -> Global By Name 144 ; C0QMNM -> Measure Name -> Either VTE, STK, ED. For use in filenames. 145 ; Output: modified CCRs are saved in /tmp/ 53 146 N C0QDFN,C0QMS,C0QM S (C0QDFN,C0QMS,C0QM)="" ; DFN, Measure Set, Measure loopers 54 147 F S C0QDFN=$O(@C0QREF@(C0QDFN)) Q:C0QDFN="" D ; For each patient 55 . W !!,$C(27),"[1;37;42m","Prosessing DFN ",C0QDFN,$C(27),"[0m",! ; Print in Green. 56 . ; 148 . ; 149 . N GREEN S GREEN=$C(27)_"[1;37;42m" 150 . N RESET S RESET=$C(27)_"[0m" 151 . D EN^DDIOL(GREEN_"Prosessing DFN "_C0QDFN_RESET,"","!!!") 152 . D EN^DDIOL("","","!") 57 153 . ; 58 154 . ; CCR Generatation is next; protected against crashes. … … 61 157 . N OLDTRAP S OLDTRAP=$ET 62 158 . ; ET: Rollback to this level, write the error in red , clear it, then quit 159 . N ETTEXT S ETTEXT=$C(27)_"[1;37;41m"_$$EC^%ZOSV_$C(27)_RESET 63 160 . N $ES,$ET 64 . S $ET=" Q:($ES) W $C(27),""[1;37;41m"",$ZS,$C(27),""[0m"",! S $EC="""""161 . S $ET="W ETTEXT D ^%ZTER G ROLLDOWN^C0QQRDA" 65 162 . D CCRRPC^C0CCCR(.C0QCCRXML,C0QDFN) ; Run CCR RPC. 66 163 . S $ET=OLDTRAP … … 81 178 . ; 82 179 . ; 83 . ; Insert XML under the root of the document XPATH180 . ; Insert Quality XML under the root of the CCR document 84 181 . D INSERT^C0CXPATH($NA(C0QCCRXML),$NA(C0QXML),"//ContinuityOfCareRecord") 85 182 . ; … … 90 187 . ; 91 188 . ; Write out to a file. 92 . N FN S FN= "QRDA_CCR_DFN"_$$RJ^XLFSTR(C0QDFN,10,"0")_".XML" ; File Name93 . K C0QCCRXML(0) ; remove zero node 189 . N FN S FN=C0QMNM_"_QRDA_CCR_DFN"_$$RJ^XLFSTR(C0QDFN,10,"0")_".XML" ; File Name 190 . K C0QCCRXML(0) ; remove zero node; API doesn't support it. 94 191 . D EN^DDIOL($$OUTPUT^C0CXPATH($NA(C0QCCRXML(1)),FN,DEFDIR)) 95 192 QUIT … … 114 211 L2 S L=L-1 D WS Q ; Decrement and Write space 115 212 WS X "F I=1:1:L W "" """ Q ; Write Space 213 ; This is for rolling down the stack to the $ES level 214 ROLLDOWN S $ET="Q:$ES S $EC=""""",$EC=",U99," QUIT
Note:
See TracChangeset
for help on using the changeset viewer.