PSBOIV ;BIRMINGHAM/TEJ-IV BAG STATUS REPORT ;Mar 2004
;;3.0;BAR CODE MED ADMIN;**32**;Mar 2004;Build 32
;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
;
; Reference/IA
; File 52.6/436
; File 52.7/437
; File 4/10090
; File 2/10035
EN ; Entry
N PSB1,PSBFUTR
K PSBSRTBY,PSBOCRIT,PSBACRIT,NO S PSBCFLG=0
S PSBFUTR=$TR(PSBRPT(1),"~","^")
I $D(PSBRPT(.2)) I $P(PSBRPT(.2),U,8) S PSBCFLG=1
S PSBDTST=+$P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7)
S PSBDTSP=+$P(PSBRPT(.1),U,8)+$P(PSBRPT(.1),U,9)
S PSBOCRIT="" ; Ord Sttus "A"ctive, "D"C ed, "E"xprd"
S:$P(PSBFUTR,U,5) PSBOCRIT=PSBOCRIT_"A"
S:$P(PSBFUTR,U,7) PSBOCRIT=PSBOCRIT_"D"
S:$P(PSBFUTR,U,8) PSBOCRIT=PSBOCRIT_"E"
S PSBACRIT="" ; Actn Sttus "C"ompl, "I"nfusi, "M"issng, "S"tpped, "H"ld, "R"efsd", "N"o Actn
S:$P(PSBFUTR,U,12) PSBACRIT=PSBACRIT_"I"
S:$P(PSBFUTR,U,13) PSBACRIT=PSBACRIT_"S"
S:$P(PSBFUTR,U,14) PSBACRIT=PSBACRIT_"C"
S:$P(PSBFUTR,U,15) PSBACRIT=PSBACRIT_"N"
S:$P(PSBFUTR,U,16) PSBACRIT=PSBACRIT_"M"
S:$P(PSBFUTR,U,17) PSBACRIT=PSBACRIT_"H"
S:$P(PSBFUTR,U,18) PSBACRIT=PSBACRIT_"R"
D NOW^%DTC S (Y,PSBXNOW)=% D DD^%DT S:PSBDTSP=0 PSBDTSP=Y S PSBDTTM=Y
I +PSBDTST=0 S PSBDTST=X S PSBDTST=$$FMADD^XLFDT(PSBDTST,-3)_".0000"
S (PSBPGNUM,PSBLNTOT,PSBTOT,PSB1)=""
K PSBLIST,PSBLIST2,PSBBGS,PSBNOX
S PSBXDFN=$P(PSBRPT(.1),U,2)
S PSBLIST(PSBXDFN)=""
S PSB1=$O(PSBLIST("")) I +PSB1'=0 K ^TMP("PSJ",$J) D EN^PSJBCMA(PSB1,PSBDTST,PSBDTST)
I ^TMP("PSJ",$J,1,0)'=-1 D
.S PINX=0 F S PINX=$O(^TMP("PSJ",$J,PINX)) Q:+PINX'>0 D
..S PSB2=$P(^TMP("PSJ",$J,PINX,0),U,3)
..I PSB2["V" D Q
...; flter critri
...D CLEAN^PSBVT,PSJ1^PSBVT(PSB1,PSB2)
...Q:$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,$G(PSBIVPSH,0))
...Q:PSBOST>PSBDTSP
...I "DE"'[PSBOSTS I PSBOSP'>PSBXNOW S PSBOSTS="E"
...Q:PSBOCRIT'[PSBOSTS ;incl ord stat crit
...Q:(PSBOSP<PSBXNOW)&(PSBOCRIT'["E")&(PSBOSTS'="D")
...S PSBLIST2(PSB2,"OStart")=PSBOST
...S PSBLIST2(PSB2,"OStop")=PSBOSP
...S PSBLIST2(PSB2,"OStatus")=$S((PSBOSTS="D"):"Discontinued",(PSBOSTS="DE"):"Discontinued (Edit)",PSBXNOW>PSBOSP:"Expired",PSBOSTS="A":"Active",PSBOSTS="H":"On Hold",1:PSBOSTS)
...S PSBLIST2(PSB2,"OPI")=PSBOTXT
...M PSBLIST2(PSB2,"ADD")=PSBADA
...M PSBLIST2(PSB2,"SOL")=PSBSOLA
...D EN^PSBPOIV(PSB1,PSB2)
...I +$O(^TMP("PSBAR",$J,""))>0 S X="" F S X=$O(^TMP("PSBAR",$J,X)) Q:+X=0 S PSBBGS(PSB2,X)=$P(^TMP("PSBAR",$J,X),U,2)
...D:PSBACRIT["N"
....S NO=1
....I $D(PSBBGS(PSB2)) S X="" F S X=$O(PSBBGS(PSB2,X)) Q:+X=0 I PSBBGS(PSB2,X)'="" S NO=0 Q
....I $D(^PSB(53.79,"AORDX",PSB1,PSB2)) S NO=0 Q
...I $G(NO,0) I PSBOSTS="A" S PSBNOX(PSB2)="",PSBTOT=PSBTOT+1 Q
...I $D(^PSB(53.79,"AUID",PSB1,PSB2)) M PSBBGS(PSB2)=^PSB(53.79,"AUID",PSB1,PSB2)
...; Get X - "ASSOC BAGS"
...S X="" F S X=$O(PSBBGS(PSB2,X)) Q:+X=0 I $G(PSBBGS(PSB2,X),"")'="" D
....S Y="" F S Y=$O(^PSB(53.79,"AUID",PSB1,Y)) Q:Y="" D Q:Y="DONE"
.....I $D(^PSB(53.79,"AUID",PSB1,Y,X)) S PSBBGS(PSB2,X,$O(^PSB(53.79,"AUID",PSB1,Y,X,"")))="" S Y="DONE"
...S X="" F S X=$O(PSBBGS(PSB2,X)) Q:+X=0 I $O(PSBBGS(PSB2,X,""))="" K PSBBGS(PSB2,X)
...S PSB3="" F S PSB3=$O(PSBBGS(PSB2,PSB3)) Q:PSB3="" D
....S PSB4="" F S PSB4=$O(PSBBGS(PSB2,PSB3,PSB4)) Q:+PSB4=0 D
.....I ($$GET1^DIQ(53.79,PSB4_",",.06,"I")'>PSBDTST)!($$GET1^DIQ(53.79,PSB4_",",.06,"I")'<PSBDTSP) K PSBBGS(PSB2,PSB3) Q
.....I PSBACRIT'[$$GET1^DIQ(53.79,PSB4_",",.09,"I") K PSBBGS(PSB2,PSB3) Q
.....S PSBBSTS(PSB2,PSB3,$$GET1^DIQ(53.79,PSB4_",",.09))=$$GET1^DIQ(53.79,PSB4_",",.06,"I"),PSBTOT=PSBTOT+1
.....I "SI"[$$GET1^DIQ(53.79,PSB4_",",.09,"I") I PSBXNOW>$$FMADD^XLFDT($$GET1^DIQ(53.79,PSB4_",",.06,"I"),,24) S PSB24HR(PSB2,PSB3)=""
.....I PSBCFLG S PSB5=0 F S PSB5=$O(^PSB(53.79,PSB4,.3,PSB5)) Q:+PSB5=0 D
......I $P(^PSB(53.79,PSB4,.3,PSB5,0),U,3)=$$GET1^DIQ(53.79,PSB4_",",.06,"I") S PSBCMNT(PSB2,PSB3)="Comment: "_$P(^PSB(53.79,PSB4,.3,PSB5,0),U)
S INX="" F S INX=$O(PSBLIST2(INX)) Q:INX="" I '$D(PSBBGS(INX))&'$D(PSBNOX(INX)) K PSBLIST2(INX)
I +PSBTOT=0 K PSBLIST
S Y=PSBDTST D DD^%DT S Y1=Y S Y=PSBDTSP D DD^%DT S Y2=Y
D CREATHDR
D SUBHDR^PSBOIV1
D BLDRPT
D WRTRPT
K PSBSILN,PSBOUTP,PSBLIST2,PSBCMNT,PSBNOX
Q
BLDRPT ; Buld Reprt
S (PSB2,PSB3,PSB4)=""
S PSBTOPHD=PSBLNTOT
I '$D(PSBLIST2) D Q
.S PSBOUTP(0,14)="W !!,""<<<< NO DATA TO DISPLAY >>>>"",!!"
S PSBTOT1=0
K PSBDATA
K J S J=1
F S PSB2=$O(PSBLIST2(PSB2)) Q:+PSB2=0 D
.S PSBORDX="" S PSBORDX=PSB2
.S PSBDATA(1)=$$FMTDT^PSBOIV1($E(PSBLIST2(PSB2,"OStart"),1,12))
.S PSBDATA(2)=$$FMTDT^PSBOIV1($E(PSBLIST2(PSB2,"OStop"),1,12))
.S PSBDATA(3)=PSBLIST2(PSB2,"OStatus")
.M PSBDATA(4,"ADD")=PSBLIST2(PSB2,"ADD") I $D(PSBDATA(4,"ADD",1)) S PSBDATA(4)="MED"
.M PSBDATA(4,"SOL")=PSBLIST2(PSB2,"SOL") I $D(PSBDATA(4,"SOL",1)) S PSBDATA(4)="MED"
.; Bag(s)
.I $D(PSBNOX(PSB2)) S PSBFLGD(PSB2," * No Action Taken On Order * ")=""
.I '$D(PSBNOX(PSB2))!(PSBACRIT["N") F S PSB3=$O(PSBBGS(PSB2,PSB3)) Q:+PSB3=0 D
..S PSBDATA(5,PSB3)=PSB3
..S PSBDATA(6,PSB3)=$O(PSBBSTS(PSB2,PSB3,""))
..I $D(PSB24HR(PSB2,PSB3)) S PSBDATA(7,PSB3)=">24h"
..I '$D(PSBNOX(PSB2)) S PSBDATA(8,PSB3)=$$FMTDT^PSBOIV1($E(PSBBSTS(PSB2,PSB3,PSBDATA(6,PSB3)),1,12))
..E S PSBDATA(8,PSB3)="No Action On Order"
.K PSBOPDAT S PSBOPDAT(1)=$G(PSBLIST2(PSB2,"OPI"),"")
.S PSBTOT1=PSBTOT1+1
.K PSBRPLN,PSBSILN
.D BUILDLN,SIOPI^PSBOCM(.PSBOPDAT,PSBTAB8,"Other Print Info:")
.I $D(PSBRPLN) S PSBMORE=$O(PSBRPLN(""),-1)+4 I $D(PSBSILN) S PSBMORE=PSBMORE+$O(PSBSILN(""),-1)
.S (PSB1,PSB)="" I $D(PSBFLGD(PSB2)) F S PSB=$O(PSBFLGD(PSB2,PSB)) Q:PSB="" I ($P(PSB,":")'="STAT") S PSB1=$G(PSB1,"")_PSB
.S PSBCNT=PSBTOT1_" ("_PSB2_") "_PSB1,$E(PSBCNT,IOM)="|"
.S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBCNT_""""
.F N=$O(PSBRPLN("")):1:$O(PSBRPLN(""),-1) D
..S PSB1X=0 S PSB1X=(($L(PSBRPLN(N),"""")-1)\2) I ($E(PSBRPLN(N),(PSBTAB8)+PSB1X)']" ") S $E(PSBRPLN(N),(PSBTAB8)+PSB1X)="|"
..S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBRPLN(N)_""""
.K PSBRPLN,PSBDATA
.S I="" F S I=$O(PSBSILN(I)) Q:+I=0 D
..S PSB1X=0 S PSB1X=(($L(PSBSILN(I),"""")-1)\2)
..I ($E(PSBSILN(I),(PSBTAB8)+PSB1X)']" ") S $E(PSBSILN(I),(PSBTAB8)+PSB1X)="|"
..S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBSILN(I)_""""
.S PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBTAB8),"" "",""-""),!"
Q
BUILDLN ; Constr recs
K J,LN S J(0)="" F PSBFLD=1:1:3 I $G(PSBDATA(PSBFLD))]"" S J=1 D FORMDAT^PSBOIV1(PSBFLD) S J=1
F X=1:1 Q:'$D(PSBDATA(4,"ADD",X)) D
.S PSBDATA(4)=$P(PSBDATA(4,"ADD",X),U,3)
.D FORMDAT^PSBOIV1(4)
.S J=$O(J(""),-1)+1
F X=1:1 Q:'$D(PSBDATA(4,"SOL",X)) D
.S PSBDATA(4)=$P(PSBDATA(4,"SOL",X),U,3)
.D FORMDAT^PSBOIV1(4)
.S J=$O(J(""),-1)+1
F PSBFLD=5:1:8 I $D(PSBDATA(PSBFLD)) K J S J=1 D
.S X="" F S X=$O(PSBDATA(PSBFLD,X)) Q:+X=0 D
..S PSBDATA(PSBFLD)=PSBDATA(PSBFLD,X)
..I PSBFLD=5 S LN(X,J)=""
..D:PSBFLD'=8 FORMDAT^PSBOIV1(PSBFLD)
..S J=$O(J(""),-1)+1
..I (PSBCFLG&(PSBFLD=5)),($D(PSBCMNT(PSB2,X))) D WRAPPER^PSBOIV1(PSBTAB4+1,(PSBTAB8-PSBTAB4)-1,PSBCMNT(PSB2,X)),WRAPPER^PSBOIV1(PSBTAB4+1,PSBTAB8-PSBTAB4," ")
.I PSBFLD=5 F J=1:1:$O(J(""),-1) S PREVLN(J)=$G(PSBRPLN(J),"")
.I PSBFLD'=5 I $D(PREVLN) S X="" F S X=$O(LN(X)) Q:X="" S J=$O(LN(X,"")) D:$D(PSBDATA(PSBFLD,X))
..S $E(PREVLN(J),@("PSBTAB"_(PSBFLD-1))+1,@("PSBTAB"_(PSBFLD)))=PSBDATA(PSBFLD,X)
I $D(PREVLN) F J=1:1:$O(PREVLN(""),-1) S PSBRPLN(J)=PREVLN(J)
K PREVLN,LN
Q
WRTRPT ;
I $O(PSBOUTP(""),-1)<1 D Q
.X PSBOUTP($O(PSBOUTP(""),-1),14)
.D FTR
S PSBPGNUM=1
S PSBZ="" F S PSBZ=$O(PSBOUTP(PSBZ)) Q:PSBZ="" D
.I PSBPGNUM'=PSBZ D FTR S PSBPGNUM=PSBZ D HDR,SUBHDR^PSBOIV1
.S PSB2="" F S PSB2=$O(PSBOUTP(PSBZ,PSB2)) Q:PSB2="" D
..X PSBOUTP(PSBZ,PSB2)
D FTR
Q
HDR ;
W:$Y>1 @IOF
W:$X>1 !
S PSBRPNM="BCMA IV BAG STATUS REPORT"
S LN=0
D:$P(PSBRPT(.1),U,1)="P"
.S LN=LN+1,PSBHDR(LN)=PSBRPNM_" for "_$$FMTE^XLFDT($P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7))_" to "_$$FMTE^XLFDT($P(PSBRPT(.1),U,8)+$P(PSBRPT(.1),U,9))
.S LN=LN+1,PSBHDR(LN)="Order Status(es): --"
.F Y=5,7,8 I $P(PSBFUTR,U,Y) S $P(PSBHDR(LN),": ",2)=$P(PSBHDR(LN),": ",2)_$S(PSBHDR(2)["--":"",1:"/ ")_$P("^^^^Active^^DC'd^Expired^^^^^^^^^^",U,Y)_" " S PSBHDR(LN)=$TR(PSBHDR(LN),"-","")
.S LN=LN+1,PSBHDR(LN)="Bag Status(es): --"
.F Y=12:1:18 I $P(PSBFUTR,U,Y) S $P(PSBHDR(LN),": ",2)=$P(PSBHDR(LN),": ",2)_$S(PSBHDR(LN)["--":"",1:"/ ")_$P("^^^^^^^^^^^Infusing^Stopped^Completed^No Action Taken^Missing Dose^Held^Refused",U,Y)_" " S PSBHDR(LN)=$TR(PSBHDR(LN),"-","")
.I PSBCFLG S LN=LN+1,PSBHDR(LN)="Include Comments/Reasons"
.D PT^PSBOHDR(PSBXDFN,.PSBHDR) W !
Q
FTR ;
I (IOSL<100) F Q:$Y>(IOSL-5) W !,?(IOM-1),"|"
S PSBPG="Page: "_PSBPGNUM_" of "_$S($O(PSBOUTP(""),-1)=0:1,1:$O(PSBOUTP(""),-1))
S PSBPGRM=PSBTAB8-($L(PSBPG))
D PTFTR^PSBOHDR()
W !,PSBRPNM," ",?(PSBPGRM-($L(PSBDTTM)+3)),PSBDTTM_" "_PSBPG
Q
PGTOT(X) ;mnt PAGE Number
I (PSBLNTOT+PSBMORE)>(IOSL) S PSBPGNUM=PSBPGNUM+1,PSBLNTOT=PSBTOPHD S PSBMORE=$S(PSBMORE>(IOSL-(PSBTOPHD)):(IOSL-(PSBTOPHD)),1:PSBMORE)
I $G(X,1) S PSBLNTOT=PSBLNTOT+$G(X,1),PSBMORE=PSBMORE-$G(X,1)
Q PSBPGNUM
CREATHDR ;
K PSBHD1,PSBHD2
I IOM'<132 S PSBMORE=4,PSBHD1=$P($T(HD132A),";",2),PSBHD2=$P($T(HD132B),";",2),PSBBLANK=$P($T(H132BLK),";",2)
E S PSBHD1="THIS REPORT SUPPORTS >131 CHAR./LINE PRINT FORMATS ONLY" K PSBLIST2 Q
; reset tabs
S PSBTAB0=1 F PSBI=0:1:($L(PSBHD1,"|")-1) S:PSBI>0 @("PSBTAB"_PSBI)=($F(PSBHD1,"|",@("PSBTAB"_(PSBI-1))+1))-1
S PSBPGNUM=1
D HDR
Q
HD132A ; Order | Order | Order | Medication | Bag UID | Bag | | Action Date/Time |
Q
HD132B ; Start Date | Stop Date | Status | | | Status | | |
Q
H132BLK ;;
Q
PSBOIV ;BIRMINGHAM/TEJ-IV BAG STATUS REPORT ;Mar 2004
+1 ;;3.0;BAR CODE MED ADMIN;**32**;Mar 2004;Build 32
+2 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
+3 ;
+4 ; Reference/IA
+5 ; File 52.6/436
+6 ; File 52.7/437
+7 ; File 4/10090
+8 ; File 2/10035
EN ; Entry
+1 NEW PSB1,PSBFUTR
+2 KILL PSBSRTBY,PSBOCRIT,PSBACRIT,NO
SET PSBCFLG=0
+3 SET PSBFUTR=$TRANSLATE(PSBRPT(1),"~","^")
+4 IF $DATA(PSBRPT(.2))
IF $PIECE(PSBRPT(.2),U,8)
SET PSBCFLG=1
+5 SET PSBDTST=+$PIECE(PSBRPT(.1),U,6)+$PIECE(PSBRPT(.1),U,7)
+6 SET PSBDTSP=+$PIECE(PSBRPT(.1),U,8)+$PIECE(PSBRPT(.1),U,9)
+7 ; Ord Sttus "A"ctive, "D"C ed, "E"xprd"
SET PSBOCRIT=""
+8 IF $PIECE(PSBFUTR,U,5)
SET PSBOCRIT=PSBOCRIT_"A"
+9 IF $PIECE(PSBFUTR,U,7)
SET PSBOCRIT=PSBOCRIT_"D"
+10 IF $PIECE(PSBFUTR,U,8)
SET PSBOCRIT=PSBOCRIT_"E"
+11 ; Actn Sttus "C"ompl, "I"nfusi, "M"issng, "S"tpped, "H"ld, "R"efsd", "N"o Actn
SET PSBACRIT=""
+12 IF $PIECE(PSBFUTR,U,12)
SET PSBACRIT=PSBACRIT_"I"
+13 IF $PIECE(PSBFUTR,U,13)
SET PSBACRIT=PSBACRIT_"S"
+14 IF $PIECE(PSBFUTR,U,14)
SET PSBACRIT=PSBACRIT_"C"
+15 IF $PIECE(PSBFUTR,U,15)
SET PSBACRIT=PSBACRIT_"N"
+16 IF $PIECE(PSBFUTR,U,16)
SET PSBACRIT=PSBACRIT_"M"
+17 IF $PIECE(PSBFUTR,U,17)
SET PSBACRIT=PSBACRIT_"H"
+18 IF $PIECE(PSBFUTR,U,18)
SET PSBACRIT=PSBACRIT_"R"
+19 DO NOW^%DTC
SET (Y,PSBXNOW)=%
DO DD^%DT
IF PSBDTSP=0
SET PSBDTSP=Y
SET PSBDTTM=Y
+20 IF +PSBDTST=0
SET PSBDTST=X
SET PSBDTST=$$FMADD^XLFDT(PSBDTST,-3)_".0000"
+21 SET (PSBPGNUM,PSBLNTOT,PSBTOT,PSB1)=""
+22 KILL PSBLIST,PSBLIST2,PSBBGS,PSBNOX
+23 SET PSBXDFN=$PIECE(PSBRPT(.1),U,2)
+24 SET PSBLIST(PSBXDFN)=""
+25 SET PSB1=$ORDER(PSBLIST(""))
IF +PSB1'=0
KILL ^TMP("PSJ",$JOB)
DO EN^PSJBCMA(PSB1,PSBDTST,PSBDTST)
+26 IF ^TMP("PSJ",$JOB,1,0)'=-1
Begin DoDot:1
+27 SET PINX=0
FOR
SET PINX=$ORDER(^TMP("PSJ",$JOB,PINX))
IF +PINX'>0
QUIT
Begin DoDot:2
+28 SET PSB2=$PIECE(^TMP("PSJ",$JOB,PINX,0),U,3)
+29 IF PSB2["V"
Begin DoDot:3
+30 ; flter critri
+31 DO CLEAN^PSBVT
DO PSJ1^PSBVT(PSB1,PSB2)
+32 IF $$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,$GET(PSBIVPSH,0))
QUIT
+33 IF PSBOST>PSBDTSP
QUIT
+34 IF "DE"'[PSBOSTS
IF PSBOSP'>PSBXNOW
SET PSBOSTS="E"
+35 ;incl ord stat crit
IF PSBOCRIT'[PSBOSTS
QUIT
+36 IF (PSBOSP<PSBXNOW)&(PSBOCRIT'["E")&(PSBOSTS'="D")
QUIT
+37 SET PSBLIST2(PSB2,"OStart")=PSBOST
+38 SET PSBLIST2(PSB2,"OStop")=PSBOSP
+39 SET PSBLIST2(PSB2,"OStatus")=$SELECT((PSBOSTS="D"):"Discontinued",(PSBOSTS="DE"):"Discontinued (Edit)",PSBXNOW>PSBOSP:"Expired",PSBOSTS="A":"Active",PSBOSTS="H":"On Hold",1:PSBOSTS)
+40 SET PSBLIST2(PSB2,"OPI")=PSBOTXT
+41 MERGE PSBLIST2(PSB2,"ADD")=PSBADA
+42 MERGE PSBLIST2(PSB2,"SOL")=PSBSOLA
+43 DO EN^PSBPOIV(PSB1,PSB2)
+44 IF +$ORDER(^TMP("PSBAR",$JOB,""))>0
SET X=""
FOR
SET X=$ORDER(^TMP("PSBAR",$JOB,X))
IF +X=0
QUIT
SET PSBBGS(PSB2,X)=$PIECE(^TMP("PSBAR",$JOB,X),U,2)
+45 IF PSBACRIT["N"
Begin DoDot:4
+46 SET NO=1
+47 IF $DATA(PSBBGS(PSB2))
SET X=""
FOR
SET X=$ORDER(PSBBGS(PSB2,X))
IF +X=0
QUIT
IF PSBBGS(PSB2,X)'=""
SET NO=0
QUIT
+48 IF $DATA(^PSB(53.79,"AORDX",PSB1,PSB2))
SET NO=0
QUIT
End DoDot:4
+49 IF $GET(NO,0)
IF PSBOSTS="A"
SET PSBNOX(PSB2)=""
SET PSBTOT=PSBTOT+1
QUIT
+50 IF $DATA(^PSB(53.79,"AUID",PSB1,PSB2))
MERGE PSBBGS(PSB2)=^PSB(53.79,"AUID",PSB1,PSB2)
+51 ; Get X - "ASSOC BAGS"
+52 SET X=""
FOR
SET X=$ORDER(PSBBGS(PSB2,X))
IF +X=0
QUIT
IF $GET(PSBBGS(PSB2,X),"")'=""
Begin DoDot:4
+53 SET Y=""
FOR
SET Y=$ORDER(^PSB(53.79,"AUID",PSB1,Y))
IF Y=""
QUIT
Begin DoDot:5
+54 IF $DATA(^PSB(53.79,"AUID",PSB1,Y,X))
SET PSBBGS(PSB2,X,$ORDER(^PSB(53.79,"AUID",PSB1,Y,X,"")))=""
SET Y="DONE"
End DoDot:5
IF Y="DONE"
QUIT
End DoDot:4
+55 SET X=""
FOR
SET X=$ORDER(PSBBGS(PSB2,X))
IF +X=0
QUIT
IF $ORDER(PSBBGS(PSB2,X,""))=""
KILL PSBBGS(PSB2,X)
+56 SET PSB3=""
FOR
SET PSB3=$ORDER(PSBBGS(PSB2,PSB3))
IF PSB3=""
QUIT
Begin DoDot:4
+57 SET PSB4=""
FOR
SET PSB4=$ORDER(PSBBGS(PSB2,PSB3,PSB4))
IF +PSB4=0
QUIT
Begin DoDot:5
+58 IF ($$GET1^DIQ(53.79,PSB4_",",.06,"I")'>PSBDTST)!($$GET1^DIQ(53.79,PSB4_",",.06,"I")'<PSBDTSP)
KILL PSBBGS(PSB2,PSB3)
QUIT
+59 IF PSBACRIT'[$$GET1^DIQ(53.79,PSB4_",",.09,"I")
KILL PSBBGS(PSB2,PSB3)
QUIT
+60 SET PSBBSTS(PSB2,PSB3,$$GET1^DIQ(53.79,PSB4_",",.09))=$$GET1^DIQ(53.79,PSB4_",",.06,"I")
SET PSBTOT=PSBTOT+1
+61 IF "SI"[$$GET1^DIQ(53.79,PSB4_",",.09,"I")
IF PSBXNOW>$$FMADD^XLFDT($$GET1^DIQ(53.79,PSB4_",",.06,"I"),,24)
SET PSB24HR(PSB2,PSB3)=""
+62 IF PSBCFLG
SET PSB5=0
FOR
SET PSB5=$ORDER(^PSB(53.79,PSB4,.3,PSB5))
IF +PSB5=0
QUIT
Begin DoDot:6
+63 IF $PIECE(^PSB(53.79,PSB4,.3,PSB5,0),U,3)=$$GET1^DIQ(53.79,PSB4_",",.06,"I")
SET PSBCMNT(PSB2,PSB3)="Comment: "_$PIECE(^PSB(53.79,PSB4,.3,PSB5,0),U)
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
QUIT
End DoDot:2
End DoDot:1
+64 SET INX=""
FOR
SET INX=$ORDER(PSBLIST2(INX))
IF INX=""
QUIT
IF '$DATA(PSBBGS(INX))&'$DATA(PSBNOX(INX))
KILL PSBLIST2(INX)
+65 IF +PSBTOT=0
KILL PSBLIST
+66 SET Y=PSBDTST
DO DD^%DT
SET Y1=Y
SET Y=PSBDTSP
DO DD^%DT
SET Y2=Y
+67 DO CREATHDR
+68 DO SUBHDR^PSBOIV1
+69 DO BLDRPT
+70 DO WRTRPT
+71 KILL PSBSILN,PSBOUTP,PSBLIST2,PSBCMNT,PSBNOX
+72 QUIT
BLDRPT ; Buld Reprt
+1 SET (PSB2,PSB3,PSB4)=""
+2 SET PSBTOPHD=PSBLNTOT
+3 IF '$DATA(PSBLIST2)
Begin DoDot:1
+4 SET PSBOUTP(0,14)="W !!,""<<<< NO DATA TO DISPLAY >>>>"",!!"
End DoDot:1
QUIT
+5 SET PSBTOT1=0
+6 KILL PSBDATA
+7 KILL J
SET J=1
+8 FOR
SET PSB2=$ORDER(PSBLIST2(PSB2))
IF +PSB2=0
QUIT
Begin DoDot:1
+9 SET PSBORDX=""
SET PSBORDX=PSB2
+10 SET PSBDATA(1)=$$FMTDT^PSBOIV1($EXTRACT(PSBLIST2(PSB2,"OStart"),1,12))
+11 SET PSBDATA(2)=$$FMTDT^PSBOIV1($EXTRACT(PSBLIST2(PSB2,"OStop"),1,12))
+12 SET PSBDATA(3)=PSBLIST2(PSB2,"OStatus")
+13 MERGE PSBDATA(4,"ADD")=PSBLIST2(PSB2,"ADD")
IF $DATA(PSBDATA(4,"ADD",1))
SET PSBDATA(4)="MED"
+14 MERGE PSBDATA(4,"SOL")=PSBLIST2(PSB2,"SOL")
IF $DATA(PSBDATA(4,"SOL",1))
SET PSBDATA(4)="MED"
+15 ; Bag(s)
+16 IF $DATA(PSBNOX(PSB2))
SET PSBFLGD(PSB2," * No Action Taken On Order * ")=""
+17 IF '$DATA(PSBNOX(PSB2))!(PSBACRIT["N")
FOR
SET PSB3=$ORDER(PSBBGS(PSB2,PSB3))
IF +PSB3=0
QUIT
Begin DoDot:2
+18 SET PSBDATA(5,PSB3)=PSB3
+19 SET PSBDATA(6,PSB3)=$ORDER(PSBBSTS(PSB2,PSB3,""))
+20 IF $DATA(PSB24HR(PSB2,PSB3))
SET PSBDATA(7,PSB3)=">24h"
+21 IF '$DATA(PSBNOX(PSB2))
SET PSBDATA(8,PSB3)=$$FMTDT^PSBOIV1($EXTRACT(PSBBSTS(PSB2,PSB3,PSBDATA(6,PSB3)),1,12))
+22 IF '$TEST
SET PSBDATA(8,PSB3)="No Action On Order"
End DoDot:2
+23 KILL PSBOPDAT
SET PSBOPDAT(1)=$GET(PSBLIST2(PSB2,"OPI"),"")
+24 SET PSBTOT1=PSBTOT1+1
+25 KILL PSBRPLN,PSBSILN
+26 DO BUILDLN
DO SIOPI^PSBOCM(.PSBOPDAT,PSBTAB8,"Other Print Info:")
+27 IF $DATA(PSBRPLN)
SET PSBMORE=$ORDER(PSBRPLN(""),-1)+4
IF $DATA(PSBSILN)
SET PSBMORE=PSBMORE+$ORDER(PSBSILN(""),-1)
+28 SET (PSB1,PSB)=""
IF $DATA(PSBFLGD(PSB2))
FOR
SET PSB=$ORDER(PSBFLGD(PSB2,PSB))
IF PSB=""
QUIT
IF ($PIECE(PSB,":")'="STAT")
SET PSB1=$GET(PSB1,"")_PSB
+29 SET PSBCNT=PSBTOT1_" ("_PSB2_") "_PSB1
SET $EXTRACT(PSBCNT,IOM)="|"
+30 SET PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBCNT_""""
+31 FOR N=$ORDER(PSBRPLN("")):1:$ORDER(PSBRPLN(""),-1)
Begin DoDot:2
+32 SET PSB1X=0
SET PSB1X=(($LENGTH(PSBRPLN(N),"""")-1)\2)
IF ($EXTRACT(PSBRPLN(N),(PSBTAB8)+PSB1X)']" ")
SET $EXTRACT(PSBRPLN(N),(PSBTAB8)+PSB1X)="|"
+33 SET PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBRPLN(N)_""""
End DoDot:2
+34 KILL PSBRPLN,PSBDATA
+35 SET I=""
FOR
SET I=$ORDER(PSBSILN(I))
IF +I=0
QUIT
Begin DoDot:2
+36 SET PSB1X=0
SET PSB1X=(($LENGTH(PSBSILN(I),"""")-1)\2)
+37 IF ($EXTRACT(PSBSILN(I),(PSBTAB8)+PSB1X)']" ")
SET $EXTRACT(PSBSILN(I),(PSBTAB8)+PSB1X)="|"
+38 SET PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBSILN(I)_""""
End DoDot:2
+39 SET PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBTAB8),"" "",""-""),!"
End DoDot:1
+40 QUIT
BUILDLN ; Constr recs
+1 KILL J,LN
SET J(0)=""
FOR PSBFLD=1:1:3
IF $GET(PSBDATA(PSBFLD))]""
SET J=1
DO FORMDAT^PSBOIV1(PSBFLD)
SET J=1
+2 FOR X=1:1
IF '$DATA(PSBDATA(4,"ADD",X))
QUIT
Begin DoDot:1
+3 SET PSBDATA(4)=$PIECE(PSBDATA(4,"ADD",X),U,3)
+4 DO FORMDAT^PSBOIV1(4)
+5 SET J=$ORDER(J(""),-1)+1
End DoDot:1
+6 FOR X=1:1
IF '$DATA(PSBDATA(4,"SOL",X))
QUIT
Begin DoDot:1
+7 SET PSBDATA(4)=$PIECE(PSBDATA(4,"SOL",X),U,3)
+8 DO FORMDAT^PSBOIV1(4)
+9 SET J=$ORDER(J(""),-1)+1
End DoDot:1
+10 FOR PSBFLD=5:1:8
IF $DATA(PSBDATA(PSBFLD))
KILL J
SET J=1
Begin DoDot:1
+11 SET X=""
FOR
SET X=$ORDER(PSBDATA(PSBFLD,X))
IF +X=0
QUIT
Begin DoDot:2
+12 SET PSBDATA(PSBFLD)=PSBDATA(PSBFLD,X)
+13 IF PSBFLD=5
SET LN(X,J)=""
+14 IF PSBFLD'=8
DO FORMDAT^PSBOIV1(PSBFLD)
+15 SET J=$ORDER(J(""),-1)+1
+16 IF (PSBCFLG&(PSBFLD=5))
IF ($DATA(PSBCMNT(PSB2,X)))
DO WRAPPER^PSBOIV1(PSBTAB4+1,(PSBTAB8-PSBTAB4)-1,PSBCMNT(PSB2,X))
DO WRAPPER^PSBOIV1(PSBTAB4+1,PSBTAB8-PSBTAB4," ")
End DoDot:2
+17 IF PSBFLD=5
FOR J=1:1:$ORDER(J(""),-1)
SET PREVLN(J)=$GET(PSBRPLN(J),"")
+18 IF PSBFLD'=5
IF $DATA(PREVLN)
SET X=""
FOR
SET X=$ORDER(LN(X))
IF X=""
QUIT
SET J=$ORDER(LN(X,""))
IF $DATA(PSBDATA(PSBFLD,X))
Begin DoDot:2
+19 SET $EXTRACT(PREVLN(J),@("PSBTAB"_(PSBFLD-1))+1,@("PSBTAB"_(PSBFLD)))=PSBDATA(PSBFLD,X)
End DoDot:2
End DoDot:1
+20 IF $DATA(PREVLN)
FOR J=1:1:$ORDER(PREVLN(""),-1)
SET PSBRPLN(J)=PREVLN(J)
+21 KILL PREVLN,LN
+22 QUIT
WRTRPT ;
+1 IF $ORDER(PSBOUTP(""),-1)<1
Begin DoDot:1
+2 XECUTE PSBOUTP($ORDER(PSBOUTP(""),-1),14)
+3 DO FTR
End DoDot:1
QUIT
+4 SET PSBPGNUM=1
+5 SET PSBZ=""
FOR
SET PSBZ=$ORDER(PSBOUTP(PSBZ))
IF PSBZ=""
QUIT
Begin DoDot:1
+6 IF PSBPGNUM'=PSBZ
DO FTR
SET PSBPGNUM=PSBZ
DO HDR
DO SUBHDR^PSBOIV1
+7 SET PSB2=""
FOR
SET PSB2=$ORDER(PSBOUTP(PSBZ,PSB2))
IF PSB2=""
QUIT
Begin DoDot:2
+8 XECUTE PSBOUTP(PSBZ,PSB2)
End DoDot:2
End DoDot:1
+9 DO FTR
+10 QUIT
HDR ;
+1 IF $Y>1
WRITE @IOF
+2 IF $X>1
WRITE !
+3 SET PSBRPNM="BCMA IV BAG STATUS REPORT"
+4 SET LN=0
+5 IF $PIECE(PSBRPT(.1),U,1)="P"
Begin DoDot:1
+6 SET LN=LN+1
SET PSBHDR(LN)=PSBRPNM_" for "_$$FMTE^XLFDT($PIECE(PSBRPT(.1),U,6)+$PIECE(PSBRPT(.1),U,7))_" to "_$$FMTE^XLFDT($PIECE(PSBRPT(.1),U,8)+$PIECE(PSBRPT(.1),U,9))
+7 SET LN=LN+1
SET PSBHDR(LN)="Order Status(es): --"
+8 FOR Y=5,7,8
IF $PIECE(PSBFUTR,U,Y)
SET $PIECE(PSBHDR(LN),": ",2)=$PIECE(PSBHDR(LN),": ",2)_$SELECT(PSBHDR(2)["--":"",1:"/ ")_$PIECE("^^^^Active^^DC'd^Expired^^^^^^^^^^",U,Y)_" "
SET PSBHDR(LN)=$TRANSLATE(PSBHDR(LN),"-","")
+9 SET LN=LN+1
SET PSBHDR(LN)="Bag Status(es): --"
+10 FOR Y=12:1:18
IF $PIECE(PSBFUTR,U,Y)
SET $PIECE(PSBHDR(LN),": ",2)=$PIECE(PSBHDR(LN),": ",2)_$SELECT(PSBHDR(LN)["--":"",1:"/ ")_$PIECE("^^^^^^^^^^^Infusing^Stopped^Completed^No Action Taken^Missing Dose^Held^Refused",U,Y)_" "
SET PSBHDR(LN)=$TRANSLATE(PSBHDR(LN),"-","")
+11 IF PSBCFLG
SET LN=LN+1
SET PSBHDR(LN)="Include Comments/Reasons"
+12 DO PT^PSBOHDR(PSBXDFN,.PSBHDR)
WRITE !
End DoDot:1
+13 QUIT
FTR ;
+1 IF (IOSL<100)
FOR
IF $Y>(IOSL-5)
QUIT
WRITE !,?(IOM-1),"|"
+2 SET PSBPG="Page: "_PSBPGNUM_" of "_$SELECT($ORDER(PSBOUTP(""),-1)=0:1,1:$ORDER(PSBOUTP(""),-1))
+3 SET PSBPGRM=PSBTAB8-($LENGTH(PSBPG))
+4 DO PTFTR^PSBOHDR()
+5 WRITE !,PSBRPNM," ",?(PSBPGRM-($LENGTH(PSBDTTM)+3)),PSBDTTM_" "_PSBPG
+6 QUIT
PGTOT(X) ;mnt PAGE Number
+1 IF (PSBLNTOT+PSBMORE)>(IOSL)
SET PSBPGNUM=PSBPGNUM+1
SET PSBLNTOT=PSBTOPHD
SET PSBMORE=$SELECT(PSBMORE>(IOSL-(PSBTOPHD)):(IOSL-(PSBTOPHD)),1:PSBMORE)
+2 IF $GET(X,1)
SET PSBLNTOT=PSBLNTOT+$GET(X,1)
SET PSBMORE=PSBMORE-$GET(X,1)
+3 QUIT PSBPGNUM
CREATHDR ;
+1 KILL PSBHD1,PSBHD2
+2 IF IOM'<132
SET PSBMORE=4
SET PSBHD1=$PIECE($TEXT(HD132A),";",2)
SET PSBHD2=$PIECE($TEXT(HD132B),";",2)
SET PSBBLANK=$PIECE($TEXT(H132BLK),";",2)
+3 IF '$TEST
SET PSBHD1="THIS REPORT SUPPORTS >131 CHAR./LINE PRINT FORMATS ONLY"
KILL PSBLIST2
QUIT
+4 ; reset tabs
+5 SET PSBTAB0=1
FOR PSBI=0:1:($LENGTH(PSBHD1,"|")-1)
IF PSBI>0
SET @("PSBTAB"_PSBI)=($FIND(PSBHD1,"|",@("PSBTAB"_(PSBI-1))+1))-1
+6 SET PSBPGNUM=1
+7 DO HDR
+8 QUIT
HD132A ; Order | Order | Order | Medication | Bag UID | Bag | | Action Date/Time |
+1 QUIT
HD132B ; Start Date | Stop Date | Status | | | Status | | |
+1 QUIT
H132BLK ;;
+1 QUIT