Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ORWRPP

ORWRPP.m

Go to the documentation of this file.
ORWRPP ; ALB/MJK - Background Report Print Driver ;01/04/18  10:37
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,109,192,332,449,405**;Dec 17, 1997;Build 211
 ;
 ;
PRINT(ORY,ORIO,ORDFN,ORRPTID,ORHSTYPE,ORDTRNG,OREXAMID,ORCOMP,ORALPHA,OROMEGA)        ; -- print report entry point
 ;  RPC: ORWRP PRINT REPORT
 ;  See RPC definition for details on input and output parameters
 N ORHSTAG
 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
 IF '$$CHK() G PRINTQ
 N ZTDTH,ZTRTN,ZTSK,ZTDESC,ZTSAVE,I,ZTIO
 S ZTIO=ORIO,ZTDTH=$H
 S ZTDESC="Report Print"
 S ZTRTN="DEQUE^ORWRPP"
 F I="ORDFN","ORRPTID","ORHSTYPE","ORDTRNG","OREXAMID","DUZ(","ORCOMP(","ORALPHA","OROMEGA","ORHSTAG" S ZTSAVE(I)=""
 D ^%ZTLOAD
 I $D(ZTSK) D
 . S ORY="0^Report queued. (Task #"_ZTSK_")"
 E  D
 . S ORY="99^Task Rejected."
PRINTQ Q
REMOTE(ORY,ORIO,ORDFN,ORRPTID,ORHANDS) ;Print data for remote sites
 ;  RPC: ORWRP PRINT REMOTE REPORT
 N ZTDTH,ZTRTN,ZTSK,ZTDESC,ZTSAVE,I,ORHSTAG,ZTIO
 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
 S ZTIO=ORIO,ZTDTH=$H
 S ZTDESC="Remote Report Print"
 S ZTRTN="DEQUE^ORWRPP"
 F I="ORDFN","ORRPTID","ORHANDS(","ORHSTAG" S ZTSAVE(I)=""
 D ^%ZTLOAD
 I $D(ZTSK) D
 . S ORY="0^Report queued. (Task #"_ZTSK_")"
 E  D
 . S ORY="99^Task Rejected."
 Q
PRINTW(ORTEXT,ORDFN,ORRPTID,ORHSTYPE,ORDTRNG,OREXAMID,ORCOMP,ORALPHA,OROMEGA) ;Windows device print
 N ZTQUEUED,ORHFS,ORSUB,ROOT,ORIO,ORHANDLE,ORWINDEV
 N IOM,IOSL,IOST,IOF,IOT,IOS,ORHSTAG,POP
 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS",ORTEXT=$NA(^TMP(ORSUB,$J,1)),ORHANDLE="ORWRP"
 I '$$CHK() S @ORTEXT@(0)=ORY G PRINTWQ
 S ORHFS=$$HFS^ORWRP(),ORWINDEV=1 ;Flag for printing to windows device
 D HFSOPEN^ORWRP(ORHANDLE,ORHFS,"W")
 I POP D  Q
 . I $D(ROOT) D SETITEM^ORWRP(.ROOT,"ERROR: Unable to open HFS file")
 D IOVAR^ORWRP(.ORIO,,,"P-WINHFS80")
 N $ETRAP,$ESTACK
 S $ETRAP="D ERR^ORWRP Q"
 U IO
 D DEQUE
 D HFSCLOSE^ORWRP(ORHANDLE,ORHFS)
PRINTWQ Q
PRINTWR(ORTEXT,ORDFN,ORRPTID,ORHANDS) ;Windows Remote device print
 N ZTQUEUED,ORHFS,ORSUB,ROOT,ORIO,ORHANDLE,ORWINDEV
 N IOM,IOSL,IOST,IOF,IOT,IOS,ORHSTAG,POP
 S ORHSTAG=$P($G(ORRPTID),"~",2),ORRPTID=$P($G(ORRPTID),"~"),ORRPTID=$P($P(ORRPTID,";"),":")
 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS",ORTEXT=$NA(^TMP(ORSUB,$J,1)),ORHANDLE="ORWRP"
 S ORHFS=$$HFS^ORWRP(),ORWINDEV=1 ;Flag for printing to windows device
 D HFSOPEN^ORWRP(ORHANDLE,ORHFS,"W")
 I POP D  Q
 . I $D(ROOT) D SETITEM^ORWRP(.ROOT,"ERROR: Unable to open HFS file")
 D IOVAR^ORWRP(.ORIO,,,"P-WINHFS80")
 N $ETRAP,$ESTACK
 S $ETRAP="D ERR^ORWRP Q"
 U IO
 D DEQUE
 D HFSCLOSE^ORWRP(ORHANDLE,ORHFS)
 Q
CHK() ; -- do checks for required data
 N OROK,FALSE,TRUE,ORRPT,TXT,I,J,REPORT
 S FALSE=0,TRUE=1,I="",REPORT=""
 IF $G(ORIO)']"" S OROK=FALSE,ORY="1^No device selected." G CHKQ
 IF '$L($G(ORRPTID)) S OROK=FALSE,ORY="2^No report specified." G CHKQ
 ; -- get report definition
 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
 . I $P($G(^ORD(101.24,J,0)),"^",2)=ORRPTID,$P(^(0),"^",8)="R" S REPORT=^(0)
 I '$L(REPORT) S OROK=FALSE,ORY="2^Report not available." G CHKQ
 S (TXT,ORRPT)=""
 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
 IF $P(REPORT,U,4)=1,$G(ORHSTYPE)=0,'$O(ORCOMP(0)) S OROK=FALSE,ORY="10^No Adhoc components specified." G CHKQ
 IF $P(REPORT,U,4)=1,'$G(ORHSTYPE),$P($G(ORHSTYPE),":")'=0 S OROK=FALSE,ORY="5^No health summary type specified." G CHKQ
 IF $P(REPORT,U,4)=3,'$G(OREXAMID) S OROK=FALSE,ORY="7^No exam identified" G CHKQ
 IF $P(REPORT,U,4)=4,'$L($G(OREXAMID)) S OROK=FALSE,ORY="9^No assessment identified" G CHKQ
 IF $P(REPORT,U,4)=19,'$L($G(OREXAMID)) S OROK=FALSE,ORY="8^No procedure date identified" G CHKQ
 IF '$D(^DPT(+$G(ORDFN),0)) S OROK=FALSE,ORY="6^Patient specified is not valid." G CHKQ
 S OROK=TRUE
CHKQ Q OROK
 ;
DEQUE ; -- logic to print queued report
 ; -- call build report logic
 N I,J,X0,X1,X2,X4,SITE,RTN,ENT,ID,ORID,ORHEADER,ORI,ORX,ORVP,OUT,PENT,POUT,PRTN,ROOT,MAX,ORPRTING
 S ORVP=ORDFN_";DPT(",ROOT="ORDATA",POUT="",ORPRTING=1
 S I=0,(X1,X2,ORID,REPORT)="",SITE=$$SITE^VASITE,SITE=$P(SITE,"^",2)_";"_$P(SITE,"^",3)
 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
 . 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)
 I '$L(X0) D NOTYET(.ROOT) Q
 S RTN=$P(X0,"^",5),ENT=$P(X0,"^",6)
 I '$L(RTN)!'$L(ENT) D NOTYET(.ROOT) Q
 I '$L($T(@(ENT_"^"_RTN))) D NOTYET(.ROOT) Q
 S PRTN=$P(X2,"^",7),PENT=$P(X2,"^",6)
 I $G(ORALPHA) S X=$$FMDIFF^XLFDT(ORALPHA,$G(OROMEGA)) D
 . I X<0 S X=X*(-1)
 . I X4,X>X4 S:ORALPHA>OROMEGA OROMEGA=$$FMADD^XLFDT(ORALPHA,-X4) S:ORALPHA'>OROMEGA ORALPHA=$$FMADD^XLFDT(OROMEGA,-X4) S ORDTRNG=""
 I X4,$G(ORDTRNG)>X4 S ORDTRNG=X4,ORALPHA=""
 I $L($G(ORDTRNG)),'$G(ORALPHA) S ORALPHA=$$FMADD^XLFDT(DT,-ORDTRNG),OROMEGA=DT_".235959"
 I $G(OROMEGA),$E(OROMEGA,8)'="." S OROMEGA=OROMEGA_".235959"
 S ID=$G(ORHSTAG),$P(ID,";",5,8)=SITE_";"_$P(X2,"^",8)_";"_$P(X2,"^",9)
 I $L($P($G(ORHSTAG),";",4)) S MAX=$P(ORHSTAG,";",4)
 I $L($G(ORHSTYPE)) M ID=ORHSTYPE
 I $L($G(OREXAMID)) M ID=OREXAMID
 I $L(PRTN),$L(PENT),$L($T(@(PENT_"^"_PRTN))) S POUT=PENT_"^"_PRTN_"(.ROOT,ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDTRNG,.REMOTE,.MAX,.ORFHIE)"
 S OUT=ENT_"^"_RTN_"(.ROOT,ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDTRNG,.REMOTE,.MAX,.ORFHIE)"
 I '$O(ORHANDS(0)) D  G OUT
 . N ORY,PAGE
 . I $L(POUT) D @POUT Q  ;Go to non-standard print routine
 . D @OUT
 . Q:'$L(ROOT)
 . S PAGE=1
 . D HEAD^ORWRPP1(ORDFN,PAGE,ORID,$G(STATION))
 . D HURL^ORWRPP1(.ROOT,ORDFN,ORID)
 S ORI=0
 F  S ORI=$O(ORHANDS(ORI)) Q:'ORI  S ORX=ORHANDS(ORI) D
 . N ORY,PAGE,ORALPHA,OROMEGA
 . D RTNDATA^XWBDRPC(.ORY,$P(ORX,"^",2))
 . S:ORY="" ORY="ORY"
 . S PAGE=1,ORALPHA=$P(ORX,"^",3),OROMEGA=$P(ORX,"^",4)
 . D HEAD^ORWRPP1(ORDFN,PAGE,ORID,$P(ORX,"^"))
 . D HURL^ORWRPP1(.ORY,ORDFN,ORID,1,$P(ORX,"^"))
OUT I $L($G(ROOT)) K @ROOT
 Q
SITE(ORSTA)   ;Print Station info
 N X
 I $G(ORSTA) S ORSTA=$$IEN^XUAF4(ORSTA)
 S:'$L($G(ORSTA)) ORSTA=$G(DUZ(2))
 S X="Report from: "_$$GET1^DIQ(4,+ORSTA,.01,"E")_"    Station #"_$$GET1^DIQ(4,+ORSTA,99,"E")
 W !?(IOM/2-($L(X)/2)),X
 Q
LRSITE(ORSTA)   ;Print Station info
 N X,ORADD
 I $G(ORSTA) S ORSTA=$$IEN^XUAF4(ORSTA)
 S:'$L($G(ORSTA)) ORSTA=$G(DUZ(2))
 S X="Report from: "_$$GET1^DIQ(4,+ORSTA,.01,"E")_"    Station #"_$$GET1^DIQ(4,+ORSTA,99,"E")
 W !?(IOM/2-($L(X)/2)),X
 S ORADD=$$PADD^XUAF4(+ORSTA)
 S ORADD=$P(ORADD,"^")_", "_$P(ORADD,"^",2)_", "_$P(ORADD,"^",3)_" "_$P(ORADD,"^",4)
 S ORADD=$E(ORADD,1,76)
 W !?(IOM/2-($L(ORADD)/2)),ORADD
 Q
NOTYET(ROOT) ; -- standard not available display text
 D SETITEM(.ROOT,"Report not available at this time.")
 Q
SETITEM(ROOT,X) ; -- set item in list
 S @ROOT@($O(@ROOT@(9999),-1)+1)=X
 Q