PSBOCE1 ;BIRMINGHAM/TEJ-Expired/DC'd/EXPIRING ORDERS REPORT (1) ;Mar 2004
;;3.0;BAR CODE MED ADMIN;**32,50**;Mar 2004;Build 78
;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
;
FMTDT(Y) ;
; Format date/time as displayed by GUI ie. 02/25/2005@2323
N X S X=$E(Y,4,5) X ^DD("DD") S Y=$TR(Y," ,:","//") S $P(Y,"/")=X
Q Y
BUILDLN ; Constr recs
K J S J(0)="" F PSBFLD=1:1:8 S J=1 D FORMDAT(PSBFLD) S J($O(PSBRPLN(""),-1))=""
; Write administration info...
Q:'PSBXFLG
S J=($O(J(""),-1)+1),PSBRPLN(J)=PSBBLANK,J(J)="",J=J+1
S (N,Y)=""
M PSBLGD("INITIALS")=PSBLGD(PSBX2X,"X","INITIALS")
F S Y=$O(PSBADM(PSBX2X,Y)) Q:Y']"" D
.F S N=$O(PSBADM(PSBX2X,Y,N)) Q:N']"" D
..I $D(PSBBID(PSBX2X,$P(N,U,2))) S PSBDATA(2,0)="BAG ID: "_PSBBID(PSBX2X,$P(N,U,2))
..S $E(PSBDATA(2,0),25)="ACTION BY: "_$P(PSBADM(PSBX2X,Y,N),U,7)_" "_$$FMTDT^PSBOCE1($E($P(PSBADM(PSBX2X,Y,N),U,6),1,12))
..S X=$P(PSBADM(PSBX2X,Y,N),U,5) S $E(PSBDATA(2,0),56)="ACTION: "_$S(X="G":"GIVEN",X="R":"REFUSED",X="RM":"REMOVED",X="H":"HELD",X="S":"STOPPED",X="I":"INFUSING",X="C":"COMPLETED",X="M":"MISSING DOSE",X=" ":"*UNKNOWN*",1:" ")
..I $D(PSBPRNR(PSBX2X)) S $E(PSBDATA(2,0),72)="PRN REASON: "_PSBPRNR(PSBX2X,$P(N,U,2))
..I $G(PSBDATA(2,0))]" " D WRAPPER(1,132-1,PSBDATA(2,0)) K PSBDATA(2) S J=J+1
..N PSBEIECMT S PSBEIECMT="" I $D(PSBPRNEF(PSBX2X,$P(N,U,2))),$P($G(PSBRPT(.2)),U,8)=0 S PSBEIECMT=$$PRNEFF^PSBO(PSBEIECMT,$P(N,U,2))
..I $D(PSBPRNEF(PSBX2X,$P(N,U,2))) S PSBDATA(2,0)="PRN EFFECTIVENESS: "_PSBPRNEF(PSBX2X,$P(N,U,2))_PSBEIECMT
..I $G(PSBDATA(2,0))]" " D WRAPPER(30,132-30,PSBDATA(2,0)) K PSBDATA(2) S J=J+1
..I ('PSBCFLG)!('$D(PSBCMT(PSBX2X,$P(N,U,2)))) S PSBRPLN(J)=PSBBLANK,J(J)="",J=J+1 Q
..M PSBLGD("INITIALS")=PSBLGD(PSBX2X,"C","INITIALS")
..S X="" F S X=$O(PSBCMT(PSBX2X,$P(N,U,2),X)) Q:X']"" D
...N PSBDAT S PSBDAT="" F S PSBDAT=$O(PSBCMT(PSBX2X,$P(N,U,2),X,PSBDAT)) Q:PSBDAT']"" D
....S PSBDATA(2,0)="COMMENT BY: "_$S($P(PSBCMT(PSBX2X,$P(N,U,2),X,PSBDAT),U,5)]"":$P(PSBCMT(PSBX2X,$P(N,U,2),X,PSBDAT),U,5)_" "_$$FMTDT^PSBOCE1($E($P(PSBCMT(PSBX2X,$P(N,U,2),X,PSBDAT),U,6),1,12)),1:" n/a ")
....S PSBDATA(2,0)=PSBDATA(2,0)_" COMMENT: "_$S($P(PSBCMT(PSBX2X,$P(N,U,2),X,PSBDAT),U,2)]"":$P(PSBCMT(PSBX2X,$P(N,U,2),X,PSBDAT),U,2),1:" ")
....I $G(PSBDATA(2,0))]" " D WRAPPER(30,132-30,PSBDATA(2,0)) K PSBDATA(2) S J=J+1
..S PSBRPLN(J)=PSBBLANK,J(J)="",J=J+1
Q
FORMDAT(FLD) ;
K PSBVAL
Q:'$D(PSBDATA(1,FLD))
S PSBVAL=PSBDATA(1,FLD)
D WRAPPER(@("PSBTAB"_(FLD-1))+1,((@("PSBTAB"_(FLD))-(@("PSBTAB"_(FLD-1))+1))),PSBVAL)
I FLD=4 S J=$O(J(""),-1)+1,PSBVAL=PSBDATA(1,4,0) D WRAPPER(@("PSBTAB"_(FLD-1))+1,((@("PSBTAB"_(FLD))-(@("PSBTAB"_(FLD-1))+1))),PSBVAL)
Q
WRAPPER(X,Y,Z) ; Text WRAP
N PSB
I ($L(Z)>0),$F(Z,"""")>1 F Q:$F(Z,"""")'>1 S Z=$TR(Z,"""","^")
F Q:'$L(Z) D
.I $L(Z)<Y S $E(PSBRPLN(J),X)=Z S Z="" Q
.F PSB=Y:-1:0 Q:$E(Z,PSB)=" "
.S:PSB<1 PSB=Y
.S $E(PSBRPLN(J),X)=$E(Z,1,PSB)
.I $L(PSBRPLN(J),"^")>1 F X=1:1:$L(PSBRPLN(J),"^")-1 S $P(PSBRPLN(J),"^",X)=$P(PSBRPLN(J),"^",X)_""""
.S PSBRPLN(J)=$TR(PSBRPLN(J),"^","""")
.S Z=$E(Z,PSB+1,250),J=J+1,J(J)=""
Q ""
PGC ;
S PSBPGNUM=PSBPGNUM+1,PSBLNTOT=PSBTOPHD S PSBMORE=$S(PSBMORE>(IOSL-(PSBTOPHD)):(IOSL-(PSBTOPHD)),1:PSBMORE)
S NOTE(PSBPGNUM)="( "_PSBX1X_" - Continued )"
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSBOCE1 3370 printed Dec 13, 2024@01:40:24 Page 2
PSBOCE1 ;BIRMINGHAM/TEJ-Expired/DC'd/EXPIRING ORDERS REPORT (1) ;Mar 2004
+1 ;;3.0;BAR CODE MED ADMIN;**32,50**;Mar 2004;Build 78
+2 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
+3 ;
FMTDT(Y) ;
+1 ; Format date/time as displayed by GUI ie. 02/25/2005@2323
+2 NEW X
SET X=$EXTRACT(Y,4,5)
XECUTE ^DD("DD")
SET Y=$TRANSLATE(Y," ,:","//")
SET $PIECE(Y,"/")=X
+3 QUIT Y
BUILDLN ; Constr recs
+1 KILL J
SET J(0)=""
FOR PSBFLD=1:1:8
SET J=1
DO FORMDAT(PSBFLD)
SET J($ORDER(PSBRPLN(""),-1))=""
+2 ; Write administration info...
+3 if 'PSBXFLG
QUIT
+4 SET J=($ORDER(J(""),-1)+1)
SET PSBRPLN(J)=PSBBLANK
SET J(J)=""
SET J=J+1
+5 SET (N,Y)=""
+6 MERGE PSBLGD("INITIALS")=PSBLGD(PSBX2X,"X","INITIALS")
+7 FOR
SET Y=$ORDER(PSBADM(PSBX2X,Y))
if Y']""
QUIT
Begin DoDot:1
+8 FOR
SET N=$ORDER(PSBADM(PSBX2X,Y,N))
if N']""
QUIT
Begin DoDot:2
+9 IF $DATA(PSBBID(PSBX2X,$PIECE(N,U,2)))
SET PSBDATA(2,0)="BAG ID: "_PSBBID(PSBX2X,$PIECE(N,U,2))
+10 SET $EXTRACT(PSBDATA(2,0),25)="ACTION BY: "_$PIECE(PSBADM(PSBX2X,Y,N),U,7)_" "_$$FMTDT^PSBOCE1($EXTRACT($PIECE(PSBADM(PSBX2X,Y,N),U,6),1,12))
+11 SET X=$PIECE(PSBADM(PSBX2X,Y,N),U,5)
SET $EXTRACT(PSBDATA(2,0),56)="ACTION: "_$SELECT(X="G":"GIVEN",X="R":"REFUSED",X="RM":"REMOVED",X="H":"HELD",X="S":"STOPPED",X="I":"INFUSING",X="C":"COMPLETED",X="M":"MISSING DOSE",X=" ":"*UNKNOWN*",1:" ")
+12 IF $DATA(PSBPRNR(PSBX2X))
SET $EXTRACT(PSBDATA(2,0),72)="PRN REASON: "_PSBPRNR(PSBX2X,$PIECE(N,U,2))
+13 IF $GET(PSBDATA(2,0))]" "
DO WRAPPER(1,132-1,PSBDATA(2,0))
KILL PSBDATA(2)
SET J=J+1
+14 NEW PSBEIECMT
SET PSBEIECMT=""
IF $DATA(PSBPRNEF(PSBX2X,$PIECE(N,U,2)))
IF $PIECE($GET(PSBRPT(.2)),U,8)=0
SET PSBEIECMT=$$PRNEFF^PSBO(PSBEIECMT,$PIECE(N,U,2))
+15 IF $DATA(PSBPRNEF(PSBX2X,$PIECE(N,U,2)))
SET PSBDATA(2,0)="PRN EFFECTIVENESS: "_PSBPRNEF(PSBX2X,$PIECE(N,U,2))_PSBEIECMT
+16 IF $GET(PSBDATA(2,0))]" "
DO WRAPPER(30,132-30,PSBDATA(2,0))
KILL PSBDATA(2)
SET J=J+1
+17 IF ('PSBCFLG)!('$DATA(PSBCMT(PSBX2X,$PIECE(N,U,2))))
SET PSBRPLN(J)=PSBBLANK
SET J(J)=""
SET J=J+1
QUIT
+18 MERGE PSBLGD("INITIALS")=PSBLGD(PSBX2X,"C","INITIALS")
+19 SET X=""
FOR
SET X=$ORDER(PSBCMT(PSBX2X,$PIECE(N,U,2),X))
if X']""
QUIT
Begin DoDot:3
+20 NEW PSBDAT
SET PSBDAT=""
FOR
SET PSBDAT=$ORDER(PSBCMT(PSBX2X,$PIECE(N,U,2),X,PSBDAT))
if PSBDAT']""
QUIT
Begin DoDot:4
+21 SET PSBDATA(2,0)="COMMENT BY: "_$SELECT($PIECE(PSBCMT(PSBX2X,$PIECE(N,U,2),X,PSBDAT),U,5)]"":$PIECE(PSBCMT(PSBX2X,$PIECE(N,U,2),X,PSBDAT),U,5)_" "_$$FMTDT^PSBOCE1($EXTRACT($PIECE(PSBCMT(PSBX2X,$PIECE(N,U,2),X,PSB
DAT),U,6),1,12)),1:" n/a ")
+22 SET PSBDATA(2,0)=PSBDATA(2,0)_" COMMENT: "_$SELECT($PIECE(PSBCMT(PSBX2X,$PIECE(N,U,2),X,PSBDAT),U,2)]"":$PIECE(PSBCMT(PSBX2X,$PIECE(N,U,2),X,PSBDAT),U,2),1:" ")
+23 IF $GET(PSBDATA(2,0))]" "
DO WRAPPER(30,132-30,PSBDATA(2,0))
KILL PSBDATA(2)
SET J=J+1
End DoDot:4
End DoDot:3
+24 SET PSBRPLN(J)=PSBBLANK
SET J(J)=""
SET J=J+1
End DoDot:2
End DoDot:1
+25 QUIT
FORMDAT(FLD) ;
+1 KILL PSBVAL
+2 if '$DATA(PSBDATA(1,FLD))
QUIT
+3 SET PSBVAL=PSBDATA(1,FLD)
+4 DO WRAPPER(@("PSBTAB"_(FLD-1))+1,((@("PSBTAB"_(FLD))-(@("PSBTAB"_(FLD-1))+1))),PSBVAL)
+5 IF FLD=4
SET J=$ORDER(J(""),-1)+1
SET PSBVAL=PSBDATA(1,4,0)
DO WRAPPER(@("PSBTAB"_(FLD-1))+1,((@("PSBTAB"_(FLD))-(@("PSBTAB"_(FLD-1))+1))),PSBVAL)
+6 QUIT
WRAPPER(X,Y,Z) ; Text WRAP
+1 NEW PSB
+2 IF ($LENGTH(Z)>0)
IF $FIND(Z,"""")>1
FOR
if $FIND(Z,"""")'>1
QUIT
SET Z=$TRANSLATE(Z,"""","^")
+3 FOR
if '$LENGTH(Z)
QUIT
Begin DoDot:1
+4 IF $LENGTH(Z)<Y
SET $EXTRACT(PSBRPLN(J),X)=Z
SET Z=""
QUIT
+5 FOR PSB=Y:-1:0
if $EXTRACT(Z,PSB)=" "
QUIT
+6 if PSB<1
SET PSB=Y
+7 SET $EXTRACT(PSBRPLN(J),X)=$EXTRACT(Z,1,PSB)
+8 IF $LENGTH(PSBRPLN(J),"^")>1
FOR X=1:1:$LENGTH(PSBRPLN(J),"^")-1
SET $PIECE(PSBRPLN(J),"^",X)=$PIECE(PSBRPLN(J),"^",X)_""""
+9 SET PSBRPLN(J)=$TRANSLATE(PSBRPLN(J),"^","""")
+10 SET Z=$EXTRACT(Z,PSB+1,250)
SET J=J+1
SET J(J)=""
End DoDot:1
+11 QUIT ""
PGC ;
+1 SET PSBPGNUM=PSBPGNUM+1
SET PSBLNTOT=PSBTOPHD
SET PSBMORE=$SELECT(PSBMORE>(IOSL-(PSBTOPHD)):(IOSL-(PSBTOPHD)),1:PSBMORE)
+2 SET NOTE(PSBPGNUM)="( "_PSBX1X_" - Continued )"
+3 QUIT