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

ORWRPL.m

Go to the documentation of this file.
ORWRPL ; SLC/DCM - Background GUI Lab Print Driver;Dec 02, 2021@12:51:24;04/19/17  13:44
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,109,332,405**;Dec 17, 1997;Build 211
RPTLIST ; -- list of Lab reports
 ; <ID> ^ <report name> ^ <qualifier type> ^
 ; <qualifier type> = 0:none,2:DateTime
 ;;21^Cumulative^2
 ;;3^Interim^2
 ;;4^Interim for Selected Tests^2
 ;;20^Anatomic Path Report^0
 ;;2^Blood Bank Report^0
 ;;9^Microbiology Report^2
 ;;10^Lab Status Report^2
 ;;$$END
 ;
PRINT(ORY,ORIO,ORDFN,RPTID,ORDAYSBK,ORTESTS,ORALPHA,OROMEGA)        ; -- print report entry point
 ;  See RPC definition for details on input and output parameters
 IF '$$CHK() G PRINTQ
 N ZTDTH,ZTRTN,ZTSK,ZTDESC,ZTSAVE
 S ZTIO=ORIO,ZTDTH=$H
 S ZTDESC="GUI Lab Report Print"
 S ZTRTN="DEQUE^ORWRPL"
 S ZTSAVE("ORDFN")="",ZTSAVE("RPTID")="",ZTSAVE("ORDAYSBK")="",ZTSAVE("DUZ(")="",ZTSAVE("ORTESTS(")="",ZTSAVE("ORALPHA")="",ZTSAVE("OROMEGA")=""
 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,RPTID,ORHANDS) ;Print data for remote sites
 ;  RPC: ORWRP PRINT REMOTE REPORT
 N ZTDTH,ZTRTN,ZTSK,ZTDESC,ZTSAVE,I
 S ZTIO=ORIO,ZTDTH=$H
 S ZTDESC="Remote Lab Report Print"
 S ZTRTN="DEQUE^ORWRPL"
 F I="ORDFN","RPTID","ORHANDS(" 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,RPTID,ORDAYSBK,ORTESTS,ORALPHA,OROMEGA) ;Windows device print
 N ZTQUEUED,ORHFS,ORSUB,ROOT,ORIO
 N IOM,IOSL,IOST,IOF,IOT,IOS
 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS"
 S ORTEXT=$NA(^TMP(ORSUB,$J,1))
 I '$$CHK() S @ORTEXT@(0)=ORY G PRINTWQ
 S ORHFS=$$HFS^ORWRP()
 D HFSOPEN^ORWRP("ORWRP",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("ORWRP",ORHFS)
PRINTWQ Q
PRINTWR(ORTEXT,ORDFN,RPTID,ORHANDS) ;Windows Remote device print
 N ZTQUEUED,ORHFS,ORSUB,ROOT,ORIO,ORHANDLE
 N IOM,IOSL,IOST,IOF,IOT,IOS
 S (ORSUB,ROOT)="ORDATA",ORIO="OR WINDOWS HFS",ORTEXT=$NA(^TMP(ORSUB,$J,1)),ORHANDLE="ORWRP"
 S ORHFS=$$HFS^ORWRP()
 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
 S FALSE=0,TRUE=1
 IF $G(ORIO)']"" S OROK=FALSE,ORY="1^No device selected." G CHKQ
 IF '$G(RPTID) S OROK=FALSE,ORY="2^No report specified." G CHKQ
 ; -- get report definition
 S (TXT,ORRPT)=""
 F I=3:1 S TXT=$P($TEXT(RPTLIST+I),";;",2) Q:TXT="$$END"!(TXT="")  I +TXT=RPTID S ORRPT=TXT Q
 IF +ORRPT'=RPTID S OROK=FALSE,ORY="3^Report type specified is not valid." G CHKQ
 IF $P(ORRPT,U,3)=2,'$G(ORDAYSBK),'$G(ORALPHA) S OROK=FALSE,ORY="4^No date range specified." 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 ORPRTING ;Printing Flag, used when creating report
 S ORPRTING=1
 I '$O(ORHANDS(0)) D LOOP Q
 N ORI,ORX
 S ORI=0
 F  S ORI=$O(ORHANDS(ORI)) Q:'ORI  S ORX=ORHANDS(ORI) D
 . N ORY,PAGE,ORALPHA,OROMEGA,ORID
 . D RTNDATA^XWBDRPC(.ORY,$P(ORX,"^",2))
 . S:ORY="" ORY="ORY"
 . S PAGE=1,ORALPHA=$P(ORX,"^",3),OROMEGA=$P(ORX,"^",4),ORID=$$ID(RPTID)
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,ORID,$P(ORX,"^"))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,ORID,1,$P(ORX,"^"))
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,ORID,$P(ORX,"^"))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,ORID,1,$P(ORX,"^"))
 Q
ID(ID) ;Get Report ID
 I ID=21 Q "LAB CUMULATIVE ("_ORALPHA_" - "_OROMEGA_")"
 I ID=3 Q "LAB INTERIM ("_ORALPHA_" - "_OROMEGA_")"
 I ID=4 Q "LAB INTERIM FOR SELECTED TESTS ("_ORALPHA_" - "_OROMEGA_")"
 I ID=20 Q "PATIENT ANATOMIC PATHOLOGY REPORT"
 I ID=2 Q "PATIENT BLOOD BANK REPORT"
 I ID=9 Q "MICROBIOLOGY REPORT ("_ORALPHA_" - "_OROMEGA_")"
 I ID=10 Q "PATIENT LAB ORDER STATUS REPORT ("_ORALPHA_" - "_OROMEGA_")"
 Q ""
LOOP ;
 IF RPTID=21 D  G DEQUEQ
 . N ORY,PAGE,TEXT,X1,X2,X
 . D CUM^ORWLR(.ORY,.ORDFN,.ORDAYSBK,.ORALPHA,.OROMEGA)
 . Q:'$L(ORY)
 . S PAGE=1,X1=DT,X2=-$G(ORDAYSBK,7)
 . D C^%DTC
 . S TEXT="LAB CUMULATIVE ("_$$FMTE^XLFDT(ORALPHA)_" - "_$$FMTE^XLFDT(OROMEGA)_")"
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,TEXT)
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,TEXT)
 IF RPTID=3 D  G DEQUEQ
 . N ORY,PAGE,TEXT,X
 . I $L(ORDAYSBK),'$G(ORALPHA) S ORALPHA=$$FMADD^XLFDT(DT,-ORDAYSBK),OROMEGA=$$NOW^XLFDT
 . Q:'$G(ORALPHA)  Q:'$G(OROMEGA)
 . D INTERIM^ORWLRR(.ORY,.ORDFN,OROMEGA,.ORALPHA)
 . Q:'$L(ORY)
 . S PAGE=1,TEXT="LAB INTERIM ("_$$FMTE^XLFDT(ORALPHA)_" - "_$$FMTE^XLFDT(OROMEGA)_")"
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,TEXT,1)
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,TEXT,1)
 IF RPTID=4 D  G DEQUEQ
 . N ORY,PAGE,TEXT,X
 . I $L(ORDAYSBK),'$G(ORALPHA) S ORALPHA=$$FMADD^XLFDT(DT,-ORDAYSBK),OROMEGA=$$NOW^XLFDT
 . Q:'$G(ORALPHA)  Q:'$G(OROMEGA)
 . D INTERIMS^ORWLRR(.ORY,.ORDFN,.OROMEGA,.ORALPHA,.ORTESTS)
 . Q:'$L(ORY)
 . S PAGE=1,TEXT="LAB INTERIM FOR SELECTED TESTS ("_$$FMTE^XLFDT(ORALPHA)_" - "_$$FMTE^XLFDT(OROMEGA)_")"
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,TEXT,1)
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,TEXT,1)
 IF RPTID=20 D  G DEQUEQ
 . N ORY,PAGE
 . D AP^ORWRP1(.ORY,.ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDTRNG,.REMOTE)
 . Q:'$L(ORY)
 . S PAGE=1
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,"PATIENT ANATOMIC PATHOLOGY REPORT",$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,"PATIENT ANATOMIC PATHOLOGY REPORT")
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,"PATIENT ANATOMIC PATHOLOGY REPORT",$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,"PATIENT ANATOMIC PATHOLOGY REPORT")
 IF RPTID=2 D  G DEQUEQ
 . N ORY,PAGE
 . D BLR^ORWRP1(.ORY,.ORDFN,.ID,.ORALPHA,.OROMEGA,.ORDAYSBK,.REMOTE)
 . Q:'$L(ORY)
 . S PAGE=1
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,"PATIENT BLOOD BANK REPORT",$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,"PATIENT BLOOD BANK REPORT")
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,"PATIENT BLOOD BANK REPORT",$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,"PATIENT BLOOD BANK REPORT")
 IF RPTID=9 D  G DEQUEQ
 . N ORY,PAGE,TEXT,X
 . I $L(ORDAYSBK),'$G(ORALPHA) S ORALPHA=$$FMADD^XLFDT(DT,-ORDAYSBK),OROMEGA=$$NOW^XLFDT
 . Q:'$G(ORALPHA)  Q:'$G(OROMEGA)
 . D MICRO^ORWLRR(.ORY,.ORDFN,.OROMEGA,.ORALPHA)
 . Q:'$L(ORY)
 . S PAGE=1,TEXT="MICROBIOLOGY REPORT ("_$$FMTE^XLFDT(ORALPHA)_" - "_$$FMTE^XLFDT(OROMEGA)_")"
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,TEXT,1)
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,TEXT,1)
 IF RPTID=10 D  G DEQUEQ
 . N ORY,PAGE,TEXT,X,ORVP
 . S ORVP=ORDFN_";DPT("
 . D EN1^LR7OSOS1(.ORY,ORVP,.ORALPHA,.OROMEGA,.ORDAYSBK)
 . I '$O(^TMP("ORDATA",$J,1,0)) S ^TMP("ORDATA",$J,1,1,0)="",^TMP("ORDATA",$J,1,2,0)="No Orders found..."
 . S PAGE=1,TEXT="PATIENT LAB ORDER STATUS REPORT ("_$$FMTE^XLFDT(ORALPHA)_" - "_$$FMTE^XLFDT(OROMEGA)_")"
 . ;D HEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . ;D HURL^ORWRPP1(.ORY,ORDFN,TEXT)
 . ;modified lab header to include facility address
 . D LRHEAD^ORWRPP1(ORDFN,PAGE,TEXT,$G(STATION))
 . D LRHURL^ORWRPP1(.ORY,ORDFN,TEXT)
DEQUEQ Q