PSBOMV ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
;;3.0;BAR CODE MED ADMIN;;Mar 2004
;
; Reference/IA
; ^DPT/10035
; ^NURSF(211.4/1409
;
EN ;
N CNT,PSBHDR,PSBPT,PSBINDX,DFN,PSBY,PSBSORT,PSBPRINT,PSBDT,PSBEV,PSBLOG,PSBPRCX,PSBRB,PSBSTOP,PSBSTRT,PSBTIME,PSBWLF,PSBWRD,PSBWRDA,PSBX,PSBY,PSBXX
;
K ^TMP("PSBO",$J)
S PSBSTRT=$P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7)
S PSBSTOP=$P(PSBRPT(.1),U,8)+$P(PSBRPT(.1),U,9)
S CNT=0,PSBPRINT=$P($G(PSBRPT(.1)),U)
I PSBPRINT="P" S PSBPT=$P(PSBRPT(.1),U,2)
I PSBPRINT="W" S PSBSORT=$P($G(PSBRPT(.1)),U,5),PSBWRD=$P(PSBRPT(.1),U,3) Q:'PSBWRD D WARD^NURSUT5("L^"_PSBWRD,.PSBWRDA)
;
RANGE ;Locate data between date range.
S PSBX=PSBSTRT F S PSBX=$O(^PSB(53.78,"ADT",PSBX)) Q:'PSBX!(PSBX>PSBSTOP) D
.F PSBY=0:0 S PSBY=$O(^PSB(53.78,"ADT",PSBX,PSBY)) Q:'PSBY D
..S DFN=+^PSB(53.78,PSBY,0),PSBWLF=$P($G(^(0)),U,9),PSBTIME=$P($G(^(0)),U,4),PSBLOG=$P($G(^(0)),U,8)
CHECK ..;Ward IEN must exist in Ward Field # 9.
..Q:'$G(PSBWLF)
..Q:'$G(PSBLOG)
..I $G(PSBTIME)=$P($G(^PSB(53.79,PSBLOG,0)),U,6),$P($G(^PSB(53.79,PSBLOG,0)),U,9)="RM" Q
..;Quit if Ward IEN is not in Nurse Location file.
..I PSBPRINT="W",'$O(^NURSF(211.4,"C",PSBWLF,PSBWRD,0)) Q
..;Compare date/time and Quit if order status set to Remove.
..;
BUILD ..I $G(PSBSORT)'="B" S ^TMP("PSBO",$J,DFN,PSBX,PSBY)=""
..I PSBPRINT="P",DFN=PSBPT S ^TMP("PSBO",$J,"B",$P(^DPT(DFN,0),U),DFN)="" Q
..S ^TMP("PSBO",$J,DFN,0)=^DPT(DFN,0)
..I PSBPRINT="W" D SORTING
;
BYWDPT ;Print by Ward and Sort by Patient.
I $G(PSBPRINT)="W",$G(PSBSORT)'="B" D
.;Print report by the selected ward name.
.W $$WRDHDR()
.S PSBINDX=""
.F S PSBINDX=$O(^TMP("PSBO",$J,"B",PSBINDX)) Q:PSBINDX="" D
..F DFN=0:0 S DFN=$O(^TMP("PSBO",$J,"B",PSBINDX,DFN)) Q:'DFN D
...W:$Y>(IOSL-10) $$WRDHDR()
...F PSBDT=0:0 S PSBDT=$O(^TMP("PSBO",$J,DFN,PSBDT)) Q:'PSBDT D
....F PSBY=0:0 S PSBY=$O(^TMP("PSBO",$J,DFN,PSBDT,PSBY)) Q:'PSBY D
.....D EVENTS ;Set Total Number of Events
.....S PSBRB=$$GET1^DIQ(53.78,PSBY_",",.02)
.....W !,PSBRB
.....W ?20,$P(^TMP("PSBO",$J,DFN,0),U,1)
.....W ?48,$$GET1^DIQ(53.78,PSBY_",",.04)
.....W ?75,$$GET1^DIQ(53.78,PSBY_",",.05)
.....W ?95,$$GET1^DIQ(53.78,PSBY_",",.06)
.....W ?102,$$GET1^DIQ(53.78,PSBY_",",.07)
.....W ?102,$$GET1^DIQ(53.78,PSBY_",","MED LOG PTR:ADMINISTRATION MEDICATION")
.....D VCOM ;Print Ward and Comments from Med Log.
.....W !?52
.W !! D EVEPRNT
;
BYWDRB ;Print by Ward and Sort by Room and Bed.
I $G(PSBPRINT)="W",$G(PSBSORT)="B" D
.;Print report by the selected ward name.
.W $$WRDHDR()
.S PSBINDX=""
.F S PSBINDX=$O(^TMP("PSBO",$J,"B",PSBINDX)) Q:PSBINDX="" D
..F DFN=0:0 S DFN=$O(^TMP("PSBO",$J,"B",PSBINDX,DFN)) Q:'DFN D
...W:$Y>(IOSL-10) $$WRDHDR()
...F PSBDT=0:0 S PSBDT=$O(^TMP("PSBO",$J,"B",PSBINDX,DFN,PSBDT)) Q:'PSBDT D
....F PSBY=0:0 S PSBY=$O(^TMP("PSBO",$J,"B",PSBINDX,DFN,PSBDT,PSBY)) Q:'PSBY D
.....D EVENTS ;Set Total Number of Events
.....S PSBRB=$$GET1^DIQ(53.78,PSBY_",",.02)
.....W !,PSBRB
.....W ?20,$P(^TMP("PSBO",$J,DFN,0),U,1)
.....W ?48,$$GET1^DIQ(53.78,PSBY_",",.04)
.....W ?75,$$GET1^DIQ(53.78,PSBY_",",.05)
.....W ?95,$$GET1^DIQ(53.78,PSBY_",",.06)
.....W ?102,$$GET1^DIQ(53.78,PSBY_",",.07)
.....W ?102,$$GET1^DIQ(53.78,PSBY_",","MED LOG PTR:ADMINISTRATION MEDICATION")
.....D VCOM ;Print Ward and Comments from Med Log.
.....W !?52
.W !! D EVEPRNT
;
BYDFN ;Print by Patient.
D:$G(PSBPRINT)="P"
.W $$PTHDR()
.S PSBINDX=""
.F S PSBINDX=$O(^TMP("PSBO",$J,"B",PSBINDX)) Q:PSBINDX="" D
..F DFN=0:0 S DFN=$O(^TMP("PSBO",$J,"B",PSBINDX,DFN)) Q:'DFN D
...W:$Y>(IOSL-10) $$PTHDR()
...F PSBDT=0:0 S PSBDT=$O(^TMP("PSBO",$J,DFN,PSBDT)) Q:'PSBDT D
....F PSBY=0:0 S PSBY=$O(^TMP("PSBO",$J,DFN,PSBDT,PSBY)) Q:'PSBY D
.....D EVENTS ;Set Total Number of Events
.....W !,$$GET1^DIQ(53.78,PSBY_",",.04)
.....W ?23,$$GET1^DIQ(53.78,PSBY_",",.05)
.....W ?43,$$GET1^DIQ(53.78,PSBY_",",.06)
.....W ?50,$$GET1^DIQ(53.78,PSBY_",",.07)
.....W ?50,$$GET1^DIQ(53.78,PSBY_",","MED LOG PTR:ADMINISTRATION MEDICATION")
.....D VCOM ;Print Ward and Comments from Med Log.
.W !! D EVEPRNT
.W $$PTFTR^PSBOHDR()
Q
;
WRDHDR() ;
S PSBHDR(1)="MEDICATION VARIANCE LOG"
D WARD^PSBOHDR(PSBWRD,.PSBHDR)
W !,"Rm-Bed",?20,"Patient Name",?48,"Event Date/Time",?75,"Event",?95,"Var",?102,"Medication",!,$TR($J("",IOM)," ","-")
Q ""
;
PTHDR() ;
S PSBHDR(1)="MEDICATION VARIANCE LOG"
D PT^PSBOHDR(PSBDFN,.PSBHDR)
W !,"Event Date/Time",?23,"Event",?43,"Var",?50,"Medication",!,$TR($J("",IOM)," ","-")
Q ""
;
VCOM ;Print Ward and Comments from Med Log on Variance Report.
N PSBCOM,PSBML,Y
Q:'$P($G(^PSB(53.78,PSBY,0)),"^",8) S PSBML=$P(^(0),"^",8)
I $P(PSBRPT(.1),U)="P" W !,?23,"Ward: ",?34 D
.I $P($G(^PSB(53.79,PSBML,0)),U,2)="" W "<No Ward>" Q
.W $P($G(^PSB(53.79,PSBML,0)),U,2)
W !,?23,"Comments: ",?34 I '$O(^PSB(53.79,PSBML,.3,0)) W "<No Comments>" Q
F PSBCOM=0:0 S PSBCOM=$O(^PSB(53.79,PSBML,.3,PSBCOM)) Q:'PSBCOM D
.W:$X>34 !?34
.S Y=$P(^PSB(53.79,PSBML,.3,PSBCOM,0),U,3)+.0000001
.W $E(Y,4,5),"/",$E(Y,6,7),"/",$E(Y,2,3)," ",$E(Y,9,10),":",$E(Y,11,12),?50,"By: ",$$GET1^DIQ(53.793,PSBCOM_","_PSBML_",","ENTERED BY:INITIAL"),$$WRAP^PSBO(60,75,$P(^PSB(53.79,PSBML,.3,PSBCOM,0),U,1))
Q
;
EVENTS ;Record total number of events.
S PSBEV=$P($G(^PSB(53.78,PSBY,0)),U,5) Q:'$G(PSBEV)
S ^TMP("PSBO",$J,"EVENTS",PSBEV,0)=$P($G(^TMP("PSBO",$J,"EVENTS",PSBEV,0)),U)+1
S CNT=CNT+1,^TMP("PSBO",$J,"EVENTSTOT",0)=CNT
Q
EVEPRNT ;Display Total and Percentage of Events.
;
Q:'$D(^TMP("PSBO",$J,"EVENTSTOT")) ;Quit if there are no events
W !,"Total Number of Events for the reporting period is: "_$P(^TMP("PSBO",$J,"EVENTSTOT",0),U)_".",!
F PSBXX=0:0 S PSBXX=$O(^TMP("PSBO",$J,"EVENTS",PSBXX)) Q:'PSBXX D
.W !,"Total number of "_$$EXTERNAL^DILFD(53.78,.05,"",PSBXX)_" events is "_$P($G(^TMP("PSBO",$J,"EVENTS",PSBXX,0)),U)_"."
.S PSBPRCX=$E($FN($P(^TMP("PSBO",$J,"EVENTS",PSBXX,0),U)/$P(^TMP("PSBO",$J,"EVENTSTOT",0),U),"",2),3,4)
.W !,"Percentage of Total Events: "_$S(PSBPRCX="00":"100",1:PSBPRCX)_"%",!
Q
;
SORTING ;Sort by Patient or Room and Bed Information
;
I $G(PSBSORT)="P"!($G(PSBSORT)="") S PSBINDX=$P(^DPT(DFN,0),U),^TMP("PSBO",$J,"B",PSBINDX,DFN)="" Q
I $G(PSBSORT)="B" S PSBINDX=$P($G(^PSB(53.78,+PSBY,0)),U,2) S:PSBINDX="" PSBINDX="** NO ROOM/BED **" S ^TMP("PSBO",$J,"B",PSBINDX,DFN,PSBX,PSBY)=""
Q
PSBOMV ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
+1 ;;3.0;BAR CODE MED ADMIN;;Mar 2004
+2 ;
+3 ; Reference/IA
+4 ; ^DPT/10035
+5 ; ^NURSF(211.4/1409
+6 ;
EN ;
+1 NEW CNT,PSBHDR,PSBPT,PSBINDX,DFN,PSBY,PSBSORT,PSBPRINT,PSBDT,PSBEV,PSBLOG,PSBPRCX,PSBRB,PSBSTOP,PSBSTRT,PSBTIME,PSBWLF,PSBWRD,PSBWRDA,PSBX,PSBY,PSBXX
+2 ;
+3 KILL ^TMP("PSBO",$JOB)
+4 SET PSBSTRT=$PIECE(PSBRPT(.1),U,6)+$PIECE(PSBRPT(.1),U,7)
+5 SET PSBSTOP=$PIECE(PSBRPT(.1),U,8)+$PIECE(PSBRPT(.1),U,9)
+6 SET CNT=0
SET PSBPRINT=$PIECE($GET(PSBRPT(.1)),U)
+7 IF PSBPRINT="P"
SET PSBPT=$PIECE(PSBRPT(.1),U,2)
+8 IF PSBPRINT="W"
SET PSBSORT=$PIECE($GET(PSBRPT(.1)),U,5)
SET PSBWRD=$PIECE(PSBRPT(.1),U,3)
IF 'PSBWRD
QUIT
DO WARD^NURSUT5("L^"_PSBWRD,.PSBWRDA)
+9 ;
RANGE ;Locate data between date range.
+1 SET PSBX=PSBSTRT
FOR
SET PSBX=$ORDER(^PSB(53.78,"ADT",PSBX))
IF 'PSBX!(PSBX>PSBSTOP)
QUIT
Begin DoDot:1
+2 FOR PSBY=0:0
SET PSBY=$ORDER(^PSB(53.78,"ADT",PSBX,PSBY))
IF 'PSBY
QUIT
Begin DoDot:2
+3 SET DFN=+^PSB(53.78,PSBY,0)
SET PSBWLF=$PIECE($GET(^(0)),U,9)
SET PSBTIME=$PIECE($GET(^(0)),U,4)
SET PSBLOG=$PIECE($GET(^(0)),U,8)
CHECK ;Ward IEN must exist in Ward Field # 9.
+1 IF '$GET(PSBWLF)
QUIT
+2 IF '$GET(PSBLOG)
QUIT
+3 IF $GET(PSBTIME)=$PIECE($GET(^PSB(53.79,PSBLOG,0)),U,6)
IF $PIECE($GET(^PSB(53.79,PSBLOG,0)),U,9)="RM"
QUIT
+4 ;Quit if Ward IEN is not in Nurse Location file.
+5 IF PSBPRINT="W"
IF '$ORDER(^NURSF(211.4,"C",PSBWLF,PSBWRD,0))
QUIT
+6 ;Compare date/time and Quit if order status set to Remove.
+7 ;
BUILD IF $GET(PSBSORT)'="B"
SET ^TMP("PSBO",$JOB,DFN,PSBX,PSBY)=""
+1 IF PSBPRINT="P"
IF DFN=PSBPT
SET ^TMP("PSBO",$JOB,"B",$PIECE(^DPT(DFN,0),U),DFN)=""
QUIT
+2 SET ^TMP("PSBO",$JOB,DFN,0)=^DPT(DFN,0)
+3 IF PSBPRINT="W"
DO SORTING
End DoDot:2
End DoDot:1
+4 ;
BYWDPT ;Print by Ward and Sort by Patient.
+1 IF $GET(PSBPRINT)="W"
IF $GET(PSBSORT)'="B"
Begin DoDot:1
+2 ;Print report by the selected ward name.
+3 WRITE $$WRDHDR()
+4 SET PSBINDX=""
+5 FOR
SET PSBINDX=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX))
IF PSBINDX=""
QUIT
Begin DoDot:2
+6 FOR DFN=0:0
SET DFN=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX,DFN))
IF 'DFN
QUIT
Begin DoDot:3
+7 IF $Y>(IOSL-10)
WRITE $$WRDHDR()
+8 FOR PSBDT=0:0
SET PSBDT=$ORDER(^TMP("PSBO",$JOB,DFN,PSBDT))
IF 'PSBDT
QUIT
Begin DoDot:4
+9 FOR PSBY=0:0
SET PSBY=$ORDER(^TMP("PSBO",$JOB,DFN,PSBDT,PSBY))
IF 'PSBY
QUIT
Begin DoDot:5
+10 ;Set Total Number of Events
DO EVENTS
+11 SET PSBRB=$$GET1^DIQ(53.78,PSBY_",",.02)
+12 WRITE !,PSBRB
+13 WRITE ?20,$PIECE(^TMP("PSBO",$JOB,DFN,0),U,1)
+14 WRITE ?48,$$GET1^DIQ(53.78,PSBY_",",.04)
+15 WRITE ?75,$$GET1^DIQ(53.78,PSBY_",",.05)
+16 WRITE ?95,$$GET1^DIQ(53.78,PSBY_",",.06)
+17 WRITE ?102,$$GET1^DIQ(53.78,PSBY_",",.07)
+18 WRITE ?102,$$GET1^DIQ(53.78,PSBY_",","MED LOG PTR:ADMINISTRATION MEDICATION")
+19 ;Print Ward and Comments from Med Log.
DO VCOM
+20 WRITE !?52
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+21 WRITE !!
DO EVEPRNT
End DoDot:1
+22 ;
BYWDRB ;Print by Ward and Sort by Room and Bed.
+1 IF $GET(PSBPRINT)="W"
IF $GET(PSBSORT)="B"
Begin DoDot:1
+2 ;Print report by the selected ward name.
+3 WRITE $$WRDHDR()
+4 SET PSBINDX=""
+5 FOR
SET PSBINDX=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX))
IF PSBINDX=""
QUIT
Begin DoDot:2
+6 FOR DFN=0:0
SET DFN=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX,DFN))
IF 'DFN
QUIT
Begin DoDot:3
+7 IF $Y>(IOSL-10)
WRITE $$WRDHDR()
+8 FOR PSBDT=0:0
SET PSBDT=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX,DFN,PSBDT))
IF 'PSBDT
QUIT
Begin DoDot:4
+9 FOR PSBY=0:0
SET PSBY=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX,DFN,PSBDT,PSBY))
IF 'PSBY
QUIT
Begin DoDot:5
+10 ;Set Total Number of Events
DO EVENTS
+11 SET PSBRB=$$GET1^DIQ(53.78,PSBY_",",.02)
+12 WRITE !,PSBRB
+13 WRITE ?20,$PIECE(^TMP("PSBO",$JOB,DFN,0),U,1)
+14 WRITE ?48,$$GET1^DIQ(53.78,PSBY_",",.04)
+15 WRITE ?75,$$GET1^DIQ(53.78,PSBY_",",.05)
+16 WRITE ?95,$$GET1^DIQ(53.78,PSBY_",",.06)
+17 WRITE ?102,$$GET1^DIQ(53.78,PSBY_",",.07)
+18 WRITE ?102,$$GET1^DIQ(53.78,PSBY_",","MED LOG PTR:ADMINISTRATION MEDICATION")
+19 ;Print Ward and Comments from Med Log.
DO VCOM
+20 WRITE !?52
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+21 WRITE !!
DO EVEPRNT
End DoDot:1
+22 ;
BYDFN ;Print by Patient.
+1 IF $GET(PSBPRINT)="P"
Begin DoDot:1
+2 WRITE $$PTHDR()
+3 SET PSBINDX=""
+4 FOR
SET PSBINDX=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX))
IF PSBINDX=""
QUIT
Begin DoDot:2
+5 FOR DFN=0:0
SET DFN=$ORDER(^TMP("PSBO",$JOB,"B",PSBINDX,DFN))
IF 'DFN
QUIT
Begin DoDot:3
+6 IF $Y>(IOSL-10)
WRITE $$PTHDR()
+7 FOR PSBDT=0:0
SET PSBDT=$ORDER(^TMP("PSBO",$JOB,DFN,PSBDT))
IF 'PSBDT
QUIT
Begin DoDot:4
+8 FOR PSBY=0:0
SET PSBY=$ORDER(^TMP("PSBO",$JOB,DFN,PSBDT,PSBY))
IF 'PSBY
QUIT
Begin DoDot:5
+9 ;Set Total Number of Events
DO EVENTS
+10 WRITE !,$$GET1^DIQ(53.78,PSBY_",",.04)
+11 WRITE ?23,$$GET1^DIQ(53.78,PSBY_",",.05)
+12 WRITE ?43,$$GET1^DIQ(53.78,PSBY_",",.06)
+13 WRITE ?50,$$GET1^DIQ(53.78,PSBY_",",.07)
+14 WRITE ?50,$$GET1^DIQ(53.78,PSBY_",","MED LOG PTR:ADMINISTRATION MEDICATION")
+15 ;Print Ward and Comments from Med Log.
DO VCOM
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
+16 WRITE !!
DO EVEPRNT
+17 WRITE $$PTFTR^PSBOHDR()
End DoDot:1
+18 QUIT
+19 ;
WRDHDR() ;
+1 SET PSBHDR(1)="MEDICATION VARIANCE LOG"
+2 DO WARD^PSBOHDR(PSBWRD,.PSBHDR)
+3 WRITE !,"Rm-Bed",?20,"Patient Name",?48,"Event Date/Time",?75,"Event",?95,"Var",?102,"Medication",!,$TRANSLATE($JUSTIFY("",IOM)," ","-")
+4 QUIT ""
+5 ;
PTHDR() ;
+1 SET PSBHDR(1)="MEDICATION VARIANCE LOG"
+2 DO PT^PSBOHDR(PSBDFN,.PSBHDR)
+3 WRITE !,"Event Date/Time",?23,"Event",?43,"Var",?50,"Medication",!,$TRANSLATE($JUSTIFY("",IOM)," ","-")
+4 QUIT ""
+5 ;
VCOM ;Print Ward and Comments from Med Log on Variance Report.
+1 NEW PSBCOM,PSBML,Y
+2 IF '$PIECE($GET(^PSB(53.78,PSBY,0)),"^",8)
QUIT
SET PSBML=$PIECE(^(0),"^",8)
+3 IF $PIECE(PSBRPT(.1),U)="P"
WRITE !,?23,"Ward: ",?34
Begin DoDot:1
+4 IF $PIECE($GET(^PSB(53.79,PSBML,0)),U,2)=""
WRITE "<No Ward>"
QUIT
+5 WRITE $PIECE($GET(^PSB(53.79,PSBML,0)),U,2)
End DoDot:1
+6 WRITE !,?23,"Comments: ",?34
IF '$ORDER(^PSB(53.79,PSBML,.3,0))
WRITE "<No Comments>"
QUIT
+7 FOR PSBCOM=0:0
SET PSBCOM=$ORDER(^PSB(53.79,PSBML,.3,PSBCOM))
IF 'PSBCOM
QUIT
Begin DoDot:1
+8 IF $X>34
WRITE !?34
+9 SET Y=$PIECE(^PSB(53.79,PSBML,.3,PSBCOM,0),U,3)+.0000001
+10 WRITE $EXTRACT(Y,4,5),"/",$EXTRACT(Y,6,7),"/",$EXTRACT(Y,2,3)," ",$EXTRACT(Y,9,10),":",$EXTRACT(Y,11,12),?50,"By: ",$$GET1^DIQ(53.793,PSBCOM_","_PSBML_",","ENTERED BY:INITIAL"),$$WRAP^PSBO(60,75,$PIECE(^PSB(53.79,PSBML,.3,PSBCOM,0),U,1)
)
End DoDot:1
+11 QUIT
+12 ;
EVENTS ;Record total number of events.
+1 SET PSBEV=$PIECE($GET(^PSB(53.78,PSBY,0)),U,5)
IF '$GET(PSBEV)
QUIT
+2 SET ^TMP("PSBO",$JOB,"EVENTS",PSBEV,0)=$PIECE($GET(^TMP("PSBO",$JOB,"EVENTS",PSBEV,0)),U)+1
+3 SET CNT=CNT+1
SET ^TMP("PSBO",$JOB,"EVENTSTOT",0)=CNT
+4 QUIT
EVEPRNT ;Display Total and Percentage of Events.
+1 ;
+2 ;Quit if there are no events
IF '$DATA(^TMP("PSBO",$JOB,"EVENTSTOT"))
QUIT
+3 WRITE !,"Total Number of Events for the reporting period is: "_$PIECE(^TMP("PSBO",$JOB,"EVENTSTOT",0),U)_".",!
+4 FOR PSBXX=0:0
SET PSBXX=$ORDER(^TMP("PSBO",$JOB,"EVENTS",PSBXX))
IF 'PSBXX
QUIT
Begin DoDot:1
+5 WRITE !,"Total number of "_$$EXTERNAL^DILFD(53.78,.05,"",PSBXX)_" events is "_$PIECE($GET(^TMP("PSBO",$JOB,"EVENTS",PSBXX,0)),U)_"."
+6 SET PSBPRCX=$EXTRACT($FNUMBER($PIECE(^TMP("PSBO",$JOB,"EVENTS",PSBXX,0),U)/$PIECE(^TMP("PSBO",$JOB,"EVENTSTOT",0),U),"",2),3,4)
+7 WRITE !,"Percentage of Total Events: "_$SELECT(PSBPRCX="00":"100",1:PSBPRCX)_"%",!
End DoDot:1
+8 QUIT
+9 ;
SORTING ;Sort by Patient or Room and Bed Information
+1 ;
+2 IF $GET(PSBSORT)="P"!($GET(PSBSORT)="")
SET PSBINDX=$PIECE(^DPT(DFN,0),U)
SET ^TMP("PSBO",$JOB,"B",PSBINDX,DFN)=""
QUIT
+3 IF $GET(PSBSORT)="B"
SET PSBINDX=$PIECE($GET(^PSB(53.78,+PSBY,0)),U,2)
IF PSBINDX=""
SET PSBINDX="** NO ROOM/BED **"
SET ^TMP("PSBO",$JOB,"B",PSBINDX,DFN,PSBX,PSBY)=""
+4 QUIT