source: qrda/C0Q/trunk/p/C0QQRDA.m@ 1517

Last change on this file since 1517 was 1517, checked in by Sam Habiel, 12 years ago

Updated C0QQRDA file

File size: 4.6 KB
Line 
1C0QQRDA ; GPL - Quality Reporting QRDA Processing ; 8/1/12 4:24pm
2 ;;1.0;QUALITY MEASURES;**4**;May 21, 2012;Build 28
3 ;Copyright 2012 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20EN
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.
29WORK(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 ;
52PRINTXML(C0QREF) ; Print the XML; Private EP
53 N C0QDFN,C0QMS,C0QM S (C0QDFN,C0QMS,C0QM)="" ; DFN, Measure Set, Measure loopers
54 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 . ;
57 . ;
58 . ; CCR Generatation is next; protected against crashes.
59 . ; ET set to new value then restored.
60 . N C0QCCRXML ; CCR XML
61 . N OLDTRAP S OLDTRAP=$ET
62 . ; ET: Rollback to this level, write the error in red , clear it, then quit
63 . N $ES,$ET
64 . S $ET="Q:($ES) W $C(27),""[1;37;41m"",$ZS,$C(27),""[0m"",! S $EC="""""
65 . D CCRRPC^C0CCCR(.C0QCCRXML,C0QDFN) ; Run CCR RPC.
66 . S $ET=OLDTRAP
67 . ;
68 . ;
69 . ; Quality XML Section generated by hand next...
70 . N C0QXML ; Generated Quality XML
71 . D XMLSTORE(.C0QXML,$$OT("QUALITY")) ; Open Tag
72 . F S C0QMS=$O(@C0QREF@(C0QDFN,C0QMS)) Q:C0QMS="" D ; For each measure set
73 . . D XMLSTORE(.C0QXML,$$OT("MEASURE_SET")) ; Open tag
74 . . D XMLSTORE(.C0QXML,$$TAG("ID",C0QMS)) ; Write out set QRDA code
75 . . D XMLSTORE(.C0QXML,$$OT("MEASURES")) ; Open tag
76 . . F S C0QM=$O(@C0QREF@(C0QDFN,C0QMS,C0QM)) Q:C0QM="" D ; for each measure
77 . . . D XMLSTORE(.C0QXML,$$TAG("MEASURE",C0QM)) ; Write <measure> and qrda code
78 . . D XMLSTORE(.C0QXML,$$CT("MEASURES")) ; Close tag
79 . . D XMLSTORE(.C0QXML,$$CT("MEASURE_SET")) ; Close tag
80 . D XMLSTORE(.C0QXML,$$CT("QUALITY")) ; Close tag
81 . ;
82 . ;
83 . ; Insert XML under the root of the document XPATH
84 . D INSERT^C0CXPATH($NA(C0QCCRXML),$NA(C0QXML),"//ContinuityOfCareRecord")
85 . ;
86 . ;
87 . ; Get Kernel Default Directory
88 . N DEFDIR S DEFDIR=$$DEFDIR^%ZISH()
89 . ;
90 . ;
91 . ; Write out to a file.
92 . N FN S FN="QRDA_CCR_DFN"_$$RJ^XLFSTR(C0QDFN,10,"0")_".XML" ; File Name
93 . K C0QCCRXML(0) ; remove zero node
94 . D EN^DDIOL($$OUTPUT^C0CXPATH($NA(C0QCCRXML(1)),FN,DEFDIR))
95 QUIT
96 ;
97 ; Quick XML stuff ; All Private
98OT(STR) Q "<"_STR_">" ; $$ Open Tag
99CT(STR) Q "</"_STR_">" ; $$ Close Tag
100TAG(NM,CONTENT) Q "<"_NM_">"_CONTENT_"</"_NM_">" ; $$ Whole tag
101 ;
102XMLSTORE(REF,STR) ; Priv Proc - Store XML
103 ; REF -> Save Array. Pass by Reference.
104 ; STR -> What to store. Pass by Value.
105 ; Use like this: D XMLSTORE(.STORE,"<tag>")
106 ; Output: STORE(1)="<tag>"
107 N L ; Number Subscript to use
108 S L=$O(REF(" "),-1) S L=L+1 ; Get last number and increment
109 S REF(L)=STR,REF(0)=L ; Store string in numbered sub, store last number in 0 node (not used here)
110 QUIT
111 ;
112 ; Following is for formatting printed XML. L passed in Symbol Table and starts at 0.
113L1 D WS S L=L+1 Q ; Write space and increment
114L2 S L=L-1 D WS Q ; Decrement and Write space
115WS X "F I=1:1:L W "" """ Q ; Write Space
Note: See TracBrowser for help on using the repository browser.