source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWRP.m@ 613

Last change on this file since 613 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 9.4 KB
Line 
1ORWRP ; ALB/MJK,dcm Report Calls ; 12/05/02 11:03
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**1,10,85,109,132,160,194,227,215,262,243**;Dec 17, 1997;Build 242
3 ;
4LABLIST(LST) ; -- report list for labs tab
5 ; RPC: ORWRP LAB REPORT LIST
6 N I,J,X,X0,X2,CNT,EOF,IFN,ROOT,RPC,ORLIST,HEAD
7 S EOF="$$END",ROOT=$NA(LST),(CNT,I)=0
8 D SETITEM(ROOT,"[LAB REPORT LIST]")
9 D GETLST^XPAR(.ORLIST,"ALL","ORWRP REPORT LAB LIST")
10 F S I=$O(ORLIST(I)) Q:'I Q:'$D(^ORD(101.24,$P(ORLIST(I),"^",2),0)) S X0=^(0),X2=$G(^(2)) D
11 . Q:$P(X0,"^",12)="L"
12 . S RPC=$$GET1^DIQ(8994,+$P(X0,"^",13),.01),IFN=ORLIST(I),HEAD=$P(X0,"^")
13 . I $L($P(X2,"^",3)) S HEAD=$P(X2,"^",3)
14 . S X=$P(X0,"^",2)_"^"_HEAD_"^"_$P(X0,"^",3)_"^"_$P(X0,"^",12)_"^"_$P(X0,"^",7)_"^"_RPC_"^"_IFN
15 . D SETITEM(.ROOT,X)
16 D SETITEM(.ROOT,"$$END")
17 Q
18LIST(LST) ; -- report lists for reports tab
19 ; RPC: ORWRP REPORT LIST
20 N EOF,ROOT
21 S EOF="$$END",ROOT=$NA(LST)
22 K @ROOT
23 D GETRPTS(.ROOT,.EOF) ; -report list
24 D GETHS(.ROOT,.EOF) ; -health summary types
25 D GETDT(.ROOT,.EOF) ; -date ranges
26 Q
27GETCOL(ROOT,IFN) ; -- get Column headers for ListView
28 N I,J,X,VAL
29 Q:'$G(IFN)
30 S I=0,ROOT=$NA(ROOT)
31 F S I=$O(^ORD(101.24,IFN,3,"C",I)) Q:'I D
32 . S VAL=$$GET^XPAR(DUZ_";VA(200,","ORWCH COLUMNS REPORTS",IFN,"I"),J=0
33 . F S J=$O(^ORD(101.24,IFN,3,"C",I,J)) Q:'J I $D(^ORD(101.24,IFN,3,J)) S X=^(J,0) D
34 .. I $L(VAL),$P(VAL,",",I) S $P(X,"^",10)=$P(VAL,",",I)
35 .. D SETITEM(.ROOT,X)
36 Q
37GETRPTS(ROOT,EOF) ; -- get report list
38 N I,J,X,X0,X2,CNT,IFN,ORLIST,HEAD
39 D SETITEM(.ROOT,"[REPORT LIST]"),GETLST^XPAR(.ORLIST,"ALL","ORWRP REPORT LIST")
40 S (CNT,I)=0
41 F S I=$O(ORLIST(I)) Q:'I Q:'$D(^ORD(101.24,$P(ORLIST(I),"^",2),0)) S X0=^(0),X2=$G(^(2)) D
42 . Q:$P(X0,"^",12)="L"
43 . S RPC=$$GET1^DIQ(8994,+$P(X0,"^",13),.01),IFN=ORLIST(I),HEAD=$P(X0,"^")
44 . I $L($P(X2,"^",3)) S HEAD=$P(X2,"^",3)
45 . S X=$P(X0,"^",2)_"^"_HEAD_"^"_$P(X0,"^",4)_"^"_$P(X0,"^",19)_";"_$P(X0,"^",20)_"^"_$P(X0,"^",6)_"^"_$P(X0,"^",5)_"^"_$P(X0,"^",3)_"^"_$P(X0,"^",12)_"^"_$P(X0,"^",7)_"^"_RPC_"^"_IFN
46 . D SETITEM(.ROOT,X)
47 D SETITEM(.ROOT,"$$END")
48 Q
49GETHS(ROOT,EOF) ; --get health summary types
50 N C,I,IFN,ORHSPARM,ORERR,X,T
51 K ^TMP("ORHSPARM",$J)
52 S ORHSROOT="^TMP(""ORHSPARM"",$J)"
53 I $$GET^XPAR("ALL","ORWRP HEALTH SUMMARY LIST ALL",1) S I="",C=0 D
54 . F S I=$O(^GMT(142,"B",I)) Q:I="" S IFN=$O(^(I,0)) Q:'IFN D
55 .. S X=$G(^GMT(142,IFN,0)) Q:'$L(X)
56 .. S T=$G(^GMT(142,IFN,"T")),C=C+1,@ORHSROOT@(C)=IFN_"^"_$S($L(T):T,1:$P(X,"^"))_"^^^^^1"
57 .. I I="GMTS HS ADHOC OPTION" S @ORHSROOT@(C)="0^GMTS Adhoc Report"
58 I '$$GET^XPAR("ALL","ORWRP HEALTH SUMMARY LIST ALL",1) D
59 . D:$L($T(GETLIST^GMTSXAL)) GETLIST^GMTSXAL($NA(@ORHSROOT),$G(DUZ),1,.ORERR)
60 . Q:$G(ORERR)
61 . S I=0 F S I=$O(@ORHSROOT@(I)) Q:'I S @ORHSROOT@(I)=@ORHSROOT@(I)_"^^^^^1" I $P(@ORHSROOT@(I),"^",2)="GMTS HS ADHOC OPTION" S @ORHSROOT@(I)="0^Adhoc Report"
62 D SETITEM(.ROOT,"[HEALTH SUMMARY TYPES]")
63 S I=0 F S I=$O(@ORHSROOT@(I)) Q:'I D SETITEM(.ROOT,"h"_@ORHSROOT@(I))
64 D SETITEM(.ROOT,EOF)
65 Q
66GETDT(ROOT,EOF) ; -- get date range choices
67 N I,X
68 D SETITEM(.ROOT,"[DATE RANGES]")
69 F I=2:1 S X=$P($T(DTLIST+I),";",3) Q:X=EOF D SETITEM(.ROOT,"d"_X)
70 Q
71DTLIST ; -- list of date ranges
72 ;<number of days>^ <display text>
73 ;;S^Date Range...
74 ;;0^Today
75 ;;7^One Week Back
76 ;;14^Two Weeks Back
77 ;;30^One Month Back
78 ;;180^Six Months Back
79 ;;365^One Year Back
80 ;;732^Two Years Back
81 ;;50000^All Results
82 ;;$$END
83 ;
84SETITEM(ROOT,X) ; -- set item in list
85 S @ROOT@($O(@ROOT@(9999),-1)+1)=X
86 Q
87RPT(ROOT,DFN,RPTID,HSTYPE,DTRANGE,EXAMID,ALPHA,OMEGA) ; -- return report text
88 ;ROOT=Output in ^TMP("ORDATA",$J)
89 ;DFN=Patient DFN ; ICN for remote sites
90 ;RPTID=Unique report ID_";"_Remote ID_"~"_HSComponent for listview (ent;rtn;0;MaxOcc) or text (ent;rtn;#component;MaxOcc)
91 ;HSTYPE=Health Sum Type
92 ;DTRANGE=# days back from today
93 ;EXAMID=Rad exam ID
94 ;ALPHA=Start date
95 ;OMEGA=End date
96 ; RPC: ORWRP REPORT TEXT
97 ;
98 N X,X0,X2,X4,I,J,ENT,RTN,ID,REMOTE,GO,OUT,MAX,SITE,ORFHIE,%ZIS,HSTAG,DIRECT,TAB
99 K ^TMP("ORDATA",$J)
100 S TAB="R"
101 I $E(RPTID,1,2)="L:" S TAB="L",RPTID=$P(RPTID,":",2,999) ;an ID beginning with "L:" forces TAB to LAB - "L:" added in GUI code
102 S HSTAG=$P($G(RPTID),"~",2),RPTID=$P($G(RPTID),"~"),ROOT=$NA(^TMP("ORDATA",$J,1)),REMOTE=+$P(RPTID,";",2),RPTID=$P($P(RPTID,";"),":")
103 I 'REMOTE S DFN=+DFN ;DFN = DFN;ICN for remote calls
104 S I=0,X0="",X2="",X4="",SITE=$$SITE^VASITE,SITE=$P(SITE,"^",2)_";"_$P(SITE,"^",3)
105 F S I=$O(^ORD(101.24,"AC",I)) Q:I="" S J=0 F S J=$O(^ORD(101.24,"AC",I,J)) Q:'J D
106 . I $P($G(^ORD(101.24,J,0)),"^",2)=RPTID,$P(^(0),"^",8)=TAB S X0=^(0),X2=$G(^(2)),ORFHIE=$G(^(4)),DIRECT=$P(ORFHIE,"^",4),X4=$P(ORFHIE,"^",2),ORFHIE=$P(ORFHIE,"^",3)
107 I '$L(X0) D NOTYET(.ROOT) Q
108 S RTN=$P(X0,"^",5),ENT=$P(X0,"^",6)
109 I '$L(RTN)!'$L(ENT) D NOTYET(.ROOT) Q
110 I '$L($T(@(ENT_"^"_RTN))) D NOTYET(.ROOT) Q
111 ;I $G(ALPHA) S X=ALPHA-$G(OMEGA) D ;jeh 243
112 I $G(ALPHA) D
113 . N X1,X2
114 . S X=ALPHA
115 . S X1=ALPHA,X2=$G(OMEGA) D:X2 ^%DTC ;X returned, # of days diff
116 . I X<0 S X=X*(-1)
117 . I X4,X>X4 S:ALPHA>OMEGA OMEGA=$$FMADD^XLFDT(ALPHA,-X4) S:ALPHA'>OMEGA ALPHA=$$FMADD^XLFDT(OMEGA,-X4) S DTRANGE=""
118 I X4,$G(DTRANGE)>X4 S DTRANGE=X4,ALPHA=""
119 I $L($G(DTRANGE)),'$G(ALPHA) S ALPHA=$$FMADD^XLFDT(DT,-DTRANGE),OMEGA=DT_".235959"
120 I $G(OMEGA),$E(OMEGA,8)'="." S OMEGA=OMEGA_".235959"
121 S ID=$G(HSTAG),$P(ID,";",5,10)=SITE_";"_$P(X2,"^",8)_";"_$P(X2,"^",9)_";"_RPTID_";"_$G(DIRECT) ;HDRHX CHANGE
122 I $L($P($G(HSTAG),";",4)) S MAX=$P(HSTAG,";",4)
123 I $L($G(HSTYPE)) M ID=HSTYPE
124 I $L($G(EXAMID)) M ID=EXAMID
125 S OUT=ENT_"^"_RTN_"(.ROOT,DFN,.ID,.ALPHA,.OMEGA,.DTRANGE,.REMOTE,.MAX,.ORFHIE)"
126 I REMOTE S GO=0 D Q:'GO
127 . I '$L($T(GETDFN^MPIF001)) D SETITEM(.ROOT,"MPI routines missing on remote system ("_SITE_")") S GO=0 Q
128 . S ICN=+$P(DFN,";",2),DFN=+$$GETDFN^MPIF001(ICN)
129 . I DFN<0 D SETITEM(.ROOT,"Patient not found on remote system ("_SITE_")") S GO=0 Q
130 . S GO=+$P(X0,"^",3)
131 . I 'GO D SETITEM(.ROOT,"Remote access not available for this report ("_SITE_")")
132 S %ZIS="0N"
133 D @OUT
134 Q
135NOTYET(ROOT) ; -- not available
136 D SETITEM(.ROOT,"Report not available at this time.")
137 Q
138START(RM,GOTO,ORIOSL) ;
139 ;RM=Right margin
140 N ZTQUEUED,ORHFS,ORSUB,ORIO,ORHANDLE,IOM,IOSL,IOST,IOF,IOT,IOS
141 S ORHFS=$$HFS(),ORSUB="ORDATA",ORHANDLE="ORWRP"
142 D HFSOPEN(ORHANDLE,ORHFS,"W")
143 I POP D Q
144 . I $D(ROOT) D SETITEM(.ROOT,"ERROR: Unable to open HFS file")
145 D IOVAR(.ORIO,.RM,.ORIOSL)
146 N $ETRAP,$ESTACK
147 S $ETRAP="D ERR^ORWRP Q"
148 U IO
149 D @GOTO
150 D HFSCLOSE(ORHANDLE,ORHFS)
151 Q
152ERR ;Error trap
153 S $ETRAP="D UNWIND^ORWRP Q"
154 N %ZIS
155 S %ZIS="0N"
156 D @^%ZOSF("ERRTN") ;file error
157 I $D(ORHANDLE) D CLOSE^%ZISH(ORHANDLE)
158 I $D(ORHFS) D
159 . N ORARR,OROK
160 . S ORARR(ORHFS)="",OROK=$$DEL^%ZISH("",$NA(ORARR)) ;delete HFS file
161 S $ECODE=",UOR69 error during CPRS report build,"
162 Q
163UNWIND ;Unwind Error stack
164 Q:$ESTACK>1 ;pop stack
165 ;
166 Q
167HFS() ; -- get hfs file name
168 N H
169 S H=$H
170 Q "ORU_"_$J_"_"_$P(H,",")_"_"_$P(H,",",2)_".DAT"
171HFSOPEN(HANDLE,ORHFS,ORMODE) ;
172 D OPEN^%ZISH(HANDLE,,ORHFS,$G(ORMODE,"W")) Q:POP
173 Q
174IOVAR(ORIO,ORRM,ORIOSL,ORIOST,ORIOF,ORIOT) ;Setup IO variables based on IO Device
175 N IFN,IFN1
176 S ORIO=$G(ORIO,"OR WORKSTATION"),ION=ORIO,IOM=$G(ORRM,80),IOSL=$G(ORIOSL,62),IOST=$G(ORIOST,"P-OTHER"),IOF=$G(ORIOF,""""""),IOT=$G(ORIOT,"HFS")
177 I $O(^%ZIS(1,"B",ORIO,0)) S IFN=$O(^(0)),IOS=IFN
178 I $D(^%ZIS(1,IFN,0)) S IOST(0)=+$G(^("SUBTYPE")),IOT=$G(ORIOT,^("TYPE")),IOST=$G(ORIOST,$P($G(^%ZIS(2,IOST(0),0),IOST),"^"))
179 I $O(^%ZIS(2,"B",IOST,0)) S IFN=$O(^(0)) I IFN S IOST(0)=IFN,IFN1=$G(^%ZIS(2,IFN,1)),IOM=$G(ORRM,$P(IFN1,"^")),IOF=$G(ORIOF,$P(IFN1,"^",2)),IOSL=$G(ORIOSL,$P(IFN1,"^",3))
180 Q
181HFSCLOSE(HANDLE,ORHFS) ;Close HFS and unload data
182 N ORDEL,X,%ZIS
183 S %ZIS="0N"
184 I IO[ORHFS D CLOSE^%ZISH(HANDLE)
185 S ROOT=$NA(^TMP(ORSUB,$J,1)),ORDEL(ORHFS)=""
186 K @ROOT
187 S X=$$FTG^%ZISH(,ORHFS,$NA(@ROOT@(1)),4)
188 D STRIP
189 S X=$$DEL^%ZISH(,$NA(ORDEL))
190 Q
191USEHFS ; -- use host file to build global array
192 N OROK,SECTION
193 S SECTION=0
194 D INIT
195 S OROK=$$FTG^%ZISH(,ORHFS,$NA(@ROOT@(1)),4) I 'OROK Q
196 D STRIP
197 N ORARR S ORARR(ORHFS)=""
198 S OROK=$$DEL^%ZISH("",$NA(ORARR))
199 Q
200INIT ; -- initialize counts and global section
201 S (INC,CNT)=0,SECTION=SECTION+1,ROOT=$NA(^TMP(ORSUB,$J,SECTION))
202 K @ROOT
203 Q
204FINAL ; -- set 'x of y' for each section CALLED FROM ^ORWLR
205 N I
206 F I=1:1:SECTION S ^TMP(ORSUB,$J,I,.1)=I_U_SECTION
207 Q
208STRIP ; -- strip off control chars
209 N I,X
210 S I=0 F S I=$O(@ROOT@(I)) Q:'I S X=^(I) D
211 . I X[$C(8) D ;BS
212 .. I $L(X,$C(8))=$L(X,$C(95)) S (X,@ROOT@(I))=$TR(X,$C(8,95),"") Q ;BS & _
213 .. S (X,@ROOT@(I))=$TR(X,$C(8),"")
214 . I X[$C(7)!(X[$C(12)) S @ROOT@(I)=$TR(X,$C(7,12),"") ;BEL or FF
215 Q
216WINDFLT(ORY) ;Windows printer as default?
217 S ORY=+$$GET^XPAR("ALL","ORWDP WINPRINT DEFAULT")
218 Q
219GETDFPRT(Y,ORUSER,ORLOC) ; Returns default printer for user
220 N IEN,X0,ENT
221 S ENT="ALL"
222 I $G(ORLOC) S ORLOC=+ORLOC_";SC(",ENT=ENT_"^"_ORLOC
223 I +$$GET^XPAR(ENT,"ORWDP WINPRINT DEFAULT") S Y="WIN;Windows Printer" Q
224 S IEN=$$GET^XPAR(ENT,"ORWDP DEFAULT PRINTER",1) Q:+IEN=0
225 Q:'$D(^%ZIS(1,IEN,0)) S X0=^(0)
226 S Y=IEN_";"_$P(X0,U)
227 Q
228SAVDFPRT(Y,ORDEV) ; Save new default printer for user
229 N ORPAR,ORERR,ORWINDEF
230 Q:$L(ORDEV)=0
231 ; Reset Windows printer default to True/False
232 S ORPAR="ORWDP WINPRINT DEFAULT"
233 I ORDEV="WIN" S ORWINDEF="Y"
234 E S ORWINDEF="N"
235 I $$GET^XPAR(DUZ_";VA(200,",ORPAR,1)'="" D CHG^XPAR(DUZ_";VA(200,",ORPAR,1,ORWINDEF,.ORERR)
236 E D ADD^XPAR(DUZ_";VA(200,",ORPAR,1,ORWINDEF,.ORERR)
237 Q:ORDEV="WIN"
238 ; If not Windows printer selected, save VistA default printer
239 S ORPAR="ORWDP DEFAULT PRINTER",ORDEV="`"_ORDEV
240 I $$GET^XPAR(DUZ_";VA(200,",ORPAR,1)'="" D CHG^XPAR(DUZ_";VA(200,",ORPAR,1,ORDEV,.ORERR)
241 E D ADD^XPAR(DUZ_";VA(200,",ORPAR,1,ORDEV,.ORERR)
242 Q
Note: See TracBrowser for help on using the repository browser.