source: WorldVistAEHR/trunk/r/CMOP-PSX/PSXTNRPT.m@ 1722

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1PSXTNRPT ;BIR/WPB-Routine to Provide Turnaround Reports at Host & Remote Facilities ; 04/08/97 2:06 PM
2 ;;2.0;CMOP;**45**;11 Apr 97
3REMOTE S FLAG=1
4R1 W !! S %DT="AEX",%DT("A")="Enter Begin Date for Report: ",%DT(0)="-NOW",%DT("B")="TODAY" D ^%DT G:Y<0!($D(DTOUT)) EXIT S BB=Y,BEG=$$FMADD^XLFDT(BB,-1,0,0,0)_".9999"
5 W !! S %DT("A")="Enter End Date for Report: " D ^%DT K %DT G:Y<0!($D(DTOUT)) EXIT S EE=Y,END=EE_".9999"
6 K %DT("A"),%DT("B"),%DT(0),Y,X,DTOUT
7 I BB>EE W !,"Beginning date must be before ending date." G REMOTE
8 Q:$G(FLAG)=0
9DEVICE S %ZIS="Q",%ZIS("B")="" D ^%ZIS S PSXLION=ION G:POP EXIT I $G(IOST)["C-" W !,"You must select a printer." G DEVICE
10 I $D(IO("Q")) D QUE,EXIT Q
11 D:$G(FLAG)=1 REMOTE1
12 D:$G(FLAG)=0 HOST1
13 G EXIT
14QUE S ZTRTN=$S($G(FLAG)=1:"REMOTE1^PSXTNRPT",$G(FLAG)=0:"HOST1^PSXTNRPT",1:""),ZTIO=PSXLION,ZTSAVE("BB")="",ZTSAVE("BEG")="",ZTSAVE("EE")="",ZTSAVE("END")="",ZTDESC="CMOP Turn Around Report"
15 S:$G(FLAG)=0 ZTSAVE("SNAME")="",ZTSAVE("SITE")="" D ^%ZTLOAD
16 I $D(ZTSK)[0 W !!,"Job Canceled"
17 E W !!,"Job Queued"
18 D HOME^%ZIS
19 Q
20 ;Called by Taskman to begin Turnaround report for Remote
21REMOTE1 U IO S (LTT,STT,CNT,CNTA,AVTTM,TURN,TOTTM)=0
22 F S BEG=$O(^PSRX("AR",BEG)) Q:(BEG'>0)!(BEG>END) S RX=0 F S RX=$O(^PSRX("AR",BEG,RX)) Q:RX'>0 S FILL="" F S FILL=$O(^PSRX("AR",BEG,RX,FILL)) Q:FILL="" D
23 .Q:'$O(^PSRX(RX,4,0))
24 .S RXTTM=0
25 .S XX=0 F S XX=$O(^PSRX(RX,4,XX)) Q:XX'>0 S:$P($G(^PSRX(RX,4,XX,0)),"^",3)=FILL BAT=$P($G(^PSRX(RX,4,XX,0)),"^",1),STAT=$P(^PSRX(RX,4,XX,0),"^",4)
26 .Q:STAT'=1
27 .I $G(FILL)>0 S:'$D(^PSRX(RX,1,FILL,0)) CNTA=CNTA+1
28 .S TTM=$P($G(^PSX(550.2,BAT,0)),"^",6)
29 .S TURN=$$FMDIFF^XLFDT(BEG,TTM,2)
30 .S:LTT<TURN LRX=RX S:LTT<TURN LTT=TURN S:STT=0 STT=TURN S:STT>TURN!(STT=TURN) SRX=RX S:STT>TURN STT=TURN S TOTTM=TOTTM+TURN
31 .S CNT=CNT+1
32 .S:CNT=1 LRX=RX
33 G:CNT'>0 RPT1
34 S AVTTM=TOTTM/CNT
35 S LTT=$P($$STHMS^PSXTNRPT(LTT),"."),STT=$P($$STHMS^PSXTNRPT(STT),"."),AVTTM=$$STHMS^PSXTNRPT($P(AVTTM,"."))
36 I IOST["C-" W @IOF
37RPT1 W !!!,"TURNAROUND TIME FOR PERIOD"
38 W !,$$FMTE^XLFDT(BB,"1P")," - ",$$FMTE^XLFDT(EE,"1P")
39 I $G(CNT)=0 W !,"No Rx's completed during this period." G EXIT
40 W !!,"Total Rx's Completed : ",CNT
41 W !,"Maximum turnaround time: ",LTT," Rx: ",$P(^PSRX(LRX,0),"^",1)
42 W !,"Minimum turnaround time: ",STT," Rx: ",$P(^PSRX(SRX,0),"^",1)
43 W !,"Average turnaround time: ",AVTTM
44 I $G(CNTA)>0 W !!,"Number of Rx's missing refill node: ",CNTA
45EXIT W @IOF
46 D ^%ZISC
47 K AVT,BB,BEG,CMDT,CNT,EE,END,PTR514,SITE,SNAME,ST,TDT,TOTTM,XX,YY,LT,PSXLION,XS,CNTA,DIC,DTOUT,DUOUT,FLAG,AVRTM,AVTTM,BAT,FILL,LRT,LTT,RTURN,RX,RXRTM,TTM,RXTTM,SRT,STAT,STT,TRTM,TURN,X,Y,LRX,SRX,%DT,%ZIS,FLAG
48 S:$D(ZTQUEUED) ZTREQ="@"
49 Q
50HOST S FLAG=0
51 D R1 Q:$G(FLAG)=""
52 W !! S DIC=552,DIC(0)="AEQMZ",DIC("A")="Enter site: " D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT))!(Y<0) EXIT S XS=$P(Y,"^",2),SNAME=Y(0,0),FACDA=+Y K X,Y
53 S SITE=$$GET1^DIQ(552,FACDA,5) K FACDA
54 I SITE="" S SITE=$P(^DIC(4,XS,99),"^",1)
55 D DEVICE
56 Q
57 ;Called by Taskman to begin Turnaround report for HOST
58HOST1 U IO S (LT,ST,AVT,CNT,CNTA,TOTTM)=0
59 F S BEG=$O(^PSX(552.4,"AD",BEG)) Q:(BEG'>0)!(BEG>EE) S XX=0 F S XX=$O(^PSX(552.4,"AD",BEG,XX)) Q:XX'>0 S YY=0 F S YY=$O(^PSX(552.4,"AD",BEG,XX,YY)) Q:YY'>0 D
60 .S PTR514=$P(^PSX(552.4,XX,0),"^",1)
61 .Q:$P($P(^PSX(552.1,PTR514,0),"^",1),"-",1)'=SITE
62 .Q:$P($G(^PSX(552.4,XX,1,YY,0)),"^",2)=2
63 .Q:$P($G(^PSX(552.4,XX,1,YY,2)),"^",2)'=""
64 .S:$P(^PSX(552.4,XX,1,YY,0),"^",10)=2 CNTA=CNTA+1
65 .S (TDT,CMDT)=0,CNT=CNT+1
66 .S CMDT=$P(^PSX(552.4,XX,1,YY,0),"^",9),TDT=$P(^PSX(552.1,PTR514,0),"^",3)
67 .S TT=$$FMDIFF^XLFDT(CMDT,TDT,2) S:TT>LT LRX=$P(^PSX(552.4,XX,1,YY,0),"^",1) S:TT>LT LT=TT S:ST=0 ST=TT S:(TT<ST)!(ST=TT) SRX=$P(^PSX(552.4,XX,1,YY,0),"^",1),ST=TT
68 .S TOTTM=TOTTM+TT
69 .S:CNT=1 LRX=$P(^PSX(552.4,XX,1,YY,0),"^",1)
70 .K TT
71 G:CNT'>0 RPT
72 S AVT=TOTTM/CNT
73RPT I IOST["C-" W @IOF
74 W !!!,"TURNAROUND TIME REPORT FOR "_SNAME
75 W !,"FOR "_$$FMTE^XLFDT(BB,"1P")," - ",$$FMTE^XLFDT(EE,"1P")
76 I $G(CNT)=0 W !!,"No Rx's completed during this time period." G EXIT
77 W !!,"Total Rx's Completed : ",CNT
78 I $G(CNTA)>0 W !,"Number of Rx's not processed at remote: ",CNTA
79 W !,"Maximum turnaround time: ",$P($$STHMS^PSXTNRPT(LT),".")," Rx: ",LRX
80 W !,"Minimum turnaround time: ",$P($$STHMS^PSXTNRPT(ST),".")," Rx: ",SRX
81 W !,"Average turnaround time: ",$P($$STHMS^PSXTNRPT(AVT),"."),!
82 G EXIT
83STHMS(X) ;
84 Q:(X<1)!(X="") 0
85 N XX,YY,X1,X2,X3,Y1,Y2,Y3,T1,U1,E1,R1,W1
86 S XX=X/3600,X1=$P(XX,".",1),X2=X1*3600,X3=X-X2,YY=X3/60,Y1=$P(YY,".",1),Y2=Y1*60,Y3=X3-Y2 S:X1>24 T1=(X1/24),U1=$P(T1,".",1),E1=(X1-(U1*24)),X1=E1
87 S R1=$S($G(U1)>0:U1_" days ",1:"")_$S($G(X1)>0:X1_" hrs ",1:"")_$S($G(Y1)>0:Y1_" mins ",1:"")_$S($G(Y3)>0:Y3_" secs",1:"")
88 K XX,YY,X1,X2,X3,Y1,Y2,Y3,T1,U1,E1,W1
89 Q R1
Note: See TracBrowser for help on using the repository browser.