source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWRPP.m@ 949

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

initial load of WorldVistAEHR

File size: 6.4 KB
Line 
1ORWRPP ; ALB/MJK - Background Report Print Driver ; 08 Feb 2001 09:02AM
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,109,192**;Dec 17, 1997
3PRINT(ORY,ORIO,ORDFN,ORRPTID,ORHSTYPE,ORDTRNG,OREXAMID,ORCOMP,ORALPHA,OROMEGA) ; -- print report entry point
4 ; RPC: ORWRP PRINT REPORT
5 ; See RPC definition for details on input and output parameters
6 N ORHSTAG
7 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
8 IF '$$CHK() G PRINTQ
9 N ZTDTH,ZTRTN,ZTSK,ZTDESC,ZTSAVE,I,ZTIO
10 S ZTIO=ORIO,ZTDTH=$H
11 S ZTDESC="Report Print"
12 S ZTRTN="DEQUE^ORWRPP"
13 F I="ORDFN","ORRPTID","ORHSTYPE","ORDTRNG","OREXAMID","DUZ(","ORCOMP(","ORALPHA","OROMEGA","ORHSTAG" S ZTSAVE(I)=""
14 D ^%ZTLOAD
15 I $D(ZTSK) D
16 . S ORY="0^Report queued. (Task #"_ZTSK_")"
17 E D
18 . S ORY="99^Task Rejected."
19PRINTQ Q
20REMOTE(ORY,ORIO,ORDFN,ORRPTID,ORHANDS) ;Print data for remote sites
21 ; RPC: ORWRP PRINT REMOTE REPORT
22 N ZTDTH,ZTRTN,ZTSK,ZTDESC,ZTSAVE,I,ORHSTAG,ZTIO
23 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
24 S ZTIO=ORIO,ZTDTH=$H
25 S ZTDESC="Remote Report Print"
26 S ZTRTN="DEQUE^ORWRPP"
27 F I="ORDFN","ORRPTID","ORHANDS(","ORHSTAG" S ZTSAVE(I)=""
28 D ^%ZTLOAD
29 I $D(ZTSK) D
30 . S ORY="0^Report queued. (Task #"_ZTSK_")"
31 E D
32 . S ORY="99^Task Rejected."
33 Q
34PRINTW(ORTEXT,ORDFN,ORRPTID,ORHSTYPE,ORDTRNG,OREXAMID,ORCOMP,ORALPHA,OROMEGA) ;Windows device print
35 N ZTQUEUED,ORHFS,ORSUB,ROOT,ORIO,ORHANDLE,ORWINDEV
36 N IOM,IOSL,IOST,IOF,IOT,IOS,ORHSTAG,POP
37 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
38 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS",ORTEXT=$NA(^TMP(ORSUB,$J,1)),ORHANDLE="ORWRP"
39 I '$$CHK() S @ORTEXT@(0)=ORY G PRINTWQ
40 S ORHFS=$$HFS^ORWRP(),ORWINDEV=1 ;Flag for printing to windows device
41 D HFSOPEN^ORWRP(ORHANDLE,ORHFS,"W")
42 I POP D Q
43 . I $D(ROOT) D SETITEM^ORWRP(.ROOT,"ERROR: Unable to open HFS file")
44 D IOVAR^ORWRP(.ORIO,,,"P-WINHFS80")
45 N $ETRAP,$ESTACK
46 S $ETRAP="D ERR^ORWRP Q"
47 U IO
48 D DEQUE
49 D HFSCLOSE^ORWRP(ORHANDLE,ORHFS)
50PRINTWQ Q
51PRINTWR(ORTEXT,ORDFN,ORRPTID,ORHANDS) ;Windows Remote device print
52 N ZTQUEUED,ORHFS,ORSUB,ROOT,ORIO,ORHANDLE,ORWINDEV
53 N IOM,IOSL,IOST,IOF,IOT,IOS,ORHSTAG,POP
54 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
55 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS",ORTEXT=$NA(^TMP(ORSUB,$J,1)),ORHANDLE="ORWRP"
56 S ORHFS=$$HFS^ORWRP(),ORWINDEV=1 ;Flag for printing to windows device
57 D HFSOPEN^ORWRP(ORHANDLE,ORHFS,"W")
58 I POP D Q
59 . I $D(ROOT) D SETITEM^ORWRP(.ROOT,"ERROR: Unable to open HFS file")
60 D IOVAR^ORWRP(.ORIO,,,"P-WINHFS80")
61 N $ETRAP,$ESTACK
62 S $ETRAP="D ERR^ORWRP Q"
63 U IO
64 D DEQUE
65 D HFSCLOSE^ORWRP(ORHANDLE,ORHFS)
66 Q
67CHK() ; -- do checks for required data
68 N OROK,FALSE,TRUE,ORRPT,TXT,I,J,REPORT
69 S FALSE=0,TRUE=1,I="",REPORT=""
70 IF $G(ORIO)']"" S OROK=FALSE,ORY="1^No device selected." G CHKQ
71 IF '$L($G(ORRPTID)) S OROK=FALSE,ORY="2^No report specified." G CHKQ
72 ; -- get report definition
73 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
74 . I $P($G(^ORD(101.24,J,0)),"^",2)=ORRPTID,$P(^(0),"^",8)="R" S REPORT=^(0)
75 I '$L(REPORT) S OROK=FALSE,ORY="2^Report not available." G CHKQ
76 S (TXT,ORRPT)=""
77 IF $P(REPORT,U,7)=1!($P(REPORT,U,7)=3),'$L($G(ORDTRNG)),'$G(ORALPHA) S OROK=FALSE,ORY="4^No date range specified." G CHKQ
78 IF $P(REPORT,U,4)=1,$G(ORHSTYPE)=0,'$O(ORCOMP(0)) S OROK=FALSE,ORY="10^No Adhoc components specified." G CHKQ
79 IF $P(REPORT,U,4)=1,'$G(ORHSTYPE),$P($G(ORHSTYPE),":")'=0 S OROK=FALSE,ORY="5^No health summary type specified." G CHKQ
80 IF $P(REPORT,U,4)=3,'$G(OREXAMID) S OROK=FALSE,ORY="7^No exam identified" G CHKQ
81 IF $P(REPORT,U,4)=4,'$L($G(OREXAMID)) S OROK=FALSE,ORY="9^No assessment identified" G CHKQ
82 IF $P(REPORT,U,4)=19,'$L($G(OREXAMID)) S OROK=FALSE,ORY="8^No procedure date identified" G CHKQ
83 IF '$D(^DPT(+$G(ORDFN),0)) S OROK=FALSE,ORY="6^Patient specified is not valid." G CHKQ
84 S OROK=TRUE
85CHKQ Q OROK
86 ;
87DEQUE ; -- logic to print queued report
88 ; -- call build report logic
89 N I,J,X0,X1,X2,X4,SITE,RTN,ENT,ID,ORID,ORHEADER,ORI,ORX,ORVP,OUT,PENT,POUT,PRTN,ROOT,MAX
90 S ORVP=ORDFN_";DPT(",ROOT="ORDATA",POUT=""
91 S I=0,(X1,X2,ORID,REPORT)="",SITE=$$SITE^VASITE,SITE=$P(SITE,"^",2)_";"_$P(SITE,"^",3)
92 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
93 . I $P($G(^ORD(101.24,J,0)),"^",2)=ORRPTID,$P(^(0),"^",8)="R" S X0=^(0),X2=$G(^(2)),ORID=$P(X2,"^",3),ORFHIE=$G(^(4)),X4=$P(ORFHIE,"^",2),ORFHIE=$P(ORFHIE,"^",3)
94 I '$L(X0) D NOTYET(.ROOT) Q
95 S RTN=$P(X0,"^",5),ENT=$P(X0,"^",6)
96 I '$L(RTN)!'$L(ENT) D NOTYET(.ROOT) Q
97 I '$L($T(@(ENT_"^"_RTN))) D NOTYET(.ROOT) Q
98 S PRTN=$P(X2,"^",7),PENT=$P(X2,"^",6)
99 I $G(ORALPHA) S X=ORALPHA-$G(OROMEGA) D
100 . I X<0 S X=X*(-1)
101 . I X4,X>X4 S:ORALPHA>OROMEGA OROMEGA=$$FMADD^XLFDT(ORALPHA,-X4) S:ORALPHA'>OROMEGA ORALPHA=$$FMADD^XLFDT(OROMEGA,-X4) S ORDTRNG=""
102 I X4,$G(ORDTRNG)>X4 S ORDTRNG=X4,ORALPHA=""
103 I $L($G(ORDTRNG)),'$G(ORALPHA) S ORALPHA=$$FMADD^XLFDT(DT,-ORDTRNG),OROMEGA=DT_".235959"
104 I $G(OROMEGA),$E(OROMEGA,8)'="." S OROMEGA=OROMEGA_".235959"
105 S ID=$G(ORHSTAG),$P(ID,";",5,8)=SITE_";"_$P(X2,"^",8)_";"_$P(X2,"^",9)
106 I $L($P($G(ORHSTAG),";",4)) S MAX=$P(ORHSTAG,";",4)
107 I $L($G(ORHSTYPE)) M ID=ORHSTYPE
108 I $L($G(OREXAMID)) M ID=OREXAMID
109 I $L(PRTN),$L(PENT),$L($T(@(PENT_"^"_PRTN))) S POUT=PENT_"^"_PRTN_"(.ROOT,ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDTRNG,.REMOTE,.MAX,.ORFHIE)"
110 S OUT=ENT_"^"_RTN_"(.ROOT,ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDTRNG,.REMOTE,.MAX,.ORFHIE)"
111 I '$O(ORHANDS(0)) D G OUT
112 . N ORY,PAGE
113 . I $L(POUT) D @POUT Q ;Go to non-standard print routine
114 . D @OUT
115 . Q:'$L(ROOT)
116 . S PAGE=1
117 . D HEAD^ORWRPP1(ORDFN,PAGE,ORID,$G(STATION))
118 . D HURL^ORWRPP1(.ROOT,ORDFN,ORID)
119 S ORI=0
120 F S ORI=$O(ORHANDS(ORI)) Q:'ORI S ORX=ORHANDS(ORI) D
121 . N ORY,PAGE,ORALPHA,OROMEGA
122 . D RTNDATA^XWBDRPC(.ORY,$P(ORX,"^",2))
123 . S:ORY="" ORY="ORY"
124 . S PAGE=1,ORALPHA=$P(ORX,"^",3),OROMEGA=$P(ORX,"^",4)
125 . D HEAD^ORWRPP1(ORDFN,PAGE,ORID,$P(ORX,"^"))
126 . D HURL^ORWRPP1(.ORY,ORDFN,ORID,1,$P(ORX,"^"))
127OUT I $L($G(ROOT)) K @ROOT
128 Q
129SITE(ORSTA) ;Print Station info
130 N X
131 I $G(ORSTA) S ORSTA=$$IEN^XUAF4(ORSTA)
132 S:'$L($G(ORSTA)) ORSTA=$G(DUZ(2))
133 S X="Report from: "_$$GET1^DIQ(4,+ORSTA,.01,"E")_" Station #"_$$GET1^DIQ(4,+ORSTA,99,"E")
134 W !?(IOM/2-($L(X)/2)),X
135 Q
136NOTYET(ROOT) ; -- standard not available display text
137 D SETITEM(.ROOT,"Report not available at this time.")
138 Q
139SETITEM(ROOT,X) ; -- set item in list
140 S @ROOT@($O(@ROOT@(9999),-1)+1)=X
141 Q
Note: See TracBrowser for help on using the repository browser.