PSBVDLPA ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
;;3.0;BAR CODE MED ADMIN;**5,16,13,38,32**;Mar 2004;Build 32
;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
;
; called by PSBVDLUD to find patches not removed
;
; Reference/IA
; $$GET^XPAR/2263
; $$FMADD^XLFDT/10103
;
EN ;
S PSBGNODE="^PSB(53.79,"_"""APATCH"""_","_DFN_")"
F S PSBGNODE=$Q(@PSBGNODE) Q:PSBGNODE']"" Q:($QS(PSBGNODE,2)'="APATCH")!($QS(PSBGNODE,3)'=DFN) D
.S PSBIEN=$QS(PSBGNODE,5)
.I '$D(^PSB(53.79,PSBIEN,.5,1)) Q
.I $P(^PSB(53.79,PSBIEN,.5,1,0),U,4)'="PATCH" Q
.I "G"'[$P(^PSB(53.79,PSBIEN,0),U,9)!($D(PSBONVDL(PSBIEN))) Q
.S PSBPBK=+($$GET^XPAR("DIV","PSB VDL PATCH DAYS"))
.S PSBZON=$P(^PSB(53.79,PSBIEN,.1),"^")
.D CLEAN^PSBVT
.D PSJ1^PSBVT(DFN,PSBZON)
.I PSBPBK'=0 D NOW^%DTC I ($$FMADD^XLFDT($P(PSBOSP,"."),(PSBPBK))<X) Q
.S $P(PSBREC,U,1)=DFN ; dfn
.S $P(PSBREC,U,2)=PSBONX ; order numer
.S $P(PSBREC,U,3)=PSBON ; order ien
.S $P(PSBREC,U,4)="U" ; order type U unit dose
.S $P(PSBREC,U,5)=PSBSCHT
.S $P(PSBREC,U,6)=PSBSCH
.S $P(PSBREC,U,7)=$S(PSBHSM:"HSM",PSBSM:"SM",1:"")
.S $P(PSBREC,U,8)=PSBOITX
.S $P(PSBREC,U,9)=PSBDOSE
.S $P(PSBREC,U,10)=PSBMR
.S:$D(PSBHSTAX(PSBOIT)) $P(PSBREC,U,11)=$O(PSBHSTAX(PSBOIT,""),-1),$P(PSBREC,U,20)=$O(PSBHSTAX(PSBOIT,$P(PSBREC,U,11),""),-1)
.D:'$D(PSBHSTAX(PSBOIT))
..N PSBX,PSBY,PSBDONE S PSBDONE=0,PSBX="" F S PSBX=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,PSBX),-1) Q:PSBX="" D:'PSBDONE
...S PSBY="" F S PSBY=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,PSBX,PSBY),-1) Q:PSBY="" D:'PSBDONE
....S:$P(^PSB(53.79,PSBY,0),U,9)'="N" $P(PSBREC,U,20)=$P(^PSB(53.79,PSBY,0),U,9) S:($P(PSBREC,U,20)'="N")&($P(PSBREC,U,20)]"") $P(PSBREC,U,11)=PSBX,PSBDONE=1
.S $P(PSBREC,U,12)=PSBIEN
.S $P(PSBREC,U,13)="G"
.S $P(PSBREC,U,14)=$P(^PSB(53.79,PSBIEN,.1),U,3)
.I $P(PSBREC,U,14)="" S $P(PSBREC,U,14)=PSBNOW\1
.S $P(PSBREC,U,15)=PSBOIT
.D:($G(PSBTAB)="CVRSHT")!($G(PSBTAB)="UDTAB")
..S $P(PSBREC,U,16)=$S($G(PSBX)="":0,1:PSBNJECT) ;Set injectable med route flag
..I $P(PSBREC,U,9)?1.4N1"-"1.4N.E S $P(PSBREC,U,17)=1
..E S $P(PSBREC,U,17)=0
..S $P(PSBREC,U,19)=$S(PSBVNI]"":PSBVNI,PSBVNI']"":"***")
..S $P(PSBREC,U,23)=""
..S $P(PSBREC,U,26)=PSBOSP
..S $P(PSBREC,U,27)=$$LASTG^PSBCSUTL($P(PSBREC,U),$P(PSBREC,U,15))
..S $P(PSBREC,U,28)=0
..I ($G(PSBTAB)="CVRSHT") S $P(PSBREC,U,28)=1
..I ($G(PSBTAB)="UDTAB") I PSBSCHT'="O" S:(PSBOSTS="E")!(PSBOSTS["D") $P(PSBREC,U,28)=1
..; Place into Coversheet activity ARRAY
..S PSBDIDX="" I $D(^PSB(53.79,"AORD",DFN,PSBONX)) D
...S PSBXDTI="",PSBXDTI=$O(^PSB(53.79,"AORD",DFN,PSBONX,PSBXDTI),-1)
...Q:'$D(^PSB(53.79,"AORD",DFN,PSBONX,PSBXDTI,PSBIEN))
...S PSBADMX(PSBONX,PSBXDTI,PSBIEN)="",PSBDIDX=1
..I ('PSBDIDX)&$D(^PSB(53.79,"AORDX",DFN,PSBONX)) D
...S PSBXXDTI="",PSBXXDTI=$O(^PSB(53.79,"AORDX",DFN,PSBONX,PSBXXDTI),-1)
...Q:'$D(^PSB(53.79,"AORDX",DFN,PSBONX,PSBXXDTI,PSBIEN))
...S PSBADMX(PSBONX,PSBXXDTI,PSBIEN)=""
.S $P(PSBREC,U,18)="PATCH"
.S $P(PSBREC,U,21)=PSBOST
.S $P(PSBREC,U,22)=PSBOSTS
.S PSBDDS="" F Y=0:0 S Y=$O(PSBDDA(Y)) Q:'Y S:$P(PSBDDA(Y),U,4)="" $P(PSBDDA(Y),U,4)=1 S PSBDDS=PSBDDS_U_$P(PSBDDA(Y),U,1,4),$P(PSBDDS,U,1)=PSBDDS+1
.S PSBQRR=1
.D ADD^PSBVDLU1(PSBREC,PSBOTXT,$P(PSBREC,U,14),PSBDDS,"","",$S($G(PSBTAB)="CVRSHT":"CVRSHT",1:"UDTAB"))
K PSBPBK,PSBONVDL
Q
PSBVDLPA ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
+1 ;;3.0;BAR CODE MED ADMIN;**5,16,13,38,32**;Mar 2004;Build 32
+2 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
+3 ;
+4 ; called by PSBVDLUD to find patches not removed
+5 ;
+6 ; Reference/IA
+7 ; $$GET^XPAR/2263
+8 ; $$FMADD^XLFDT/10103
+9 ;
EN ;
+1 SET PSBGNODE="^PSB(53.79,"_"""APATCH"""_","_DFN_")"
+2 FOR
SET PSBGNODE=$QUERY(@PSBGNODE)
IF PSBGNODE']""
QUIT
IF ($QSUBSCRIPT(PSBGNODE,2)'="APATCH")!($QSUBSCRIPT(PSBGNODE,3)'=DFN)
QUIT
Begin DoDot:1
+3 SET PSBIEN=$QSUBSCRIPT(PSBGNODE,5)
+4 IF '$DATA(^PSB(53.79,PSBIEN,.5,1))
QUIT
+5 IF $PIECE(^PSB(53.79,PSBIEN,.5,1,0),U,4)'="PATCH"
QUIT
+6 IF "G"'[$PIECE(^PSB(53.79,PSBIEN,0),U,9)!($DATA(PSBONVDL(PSBIEN)))
QUIT
+7 SET PSBPBK=+($$GET^XPAR("DIV","PSB VDL PATCH DAYS"))
+8 SET PSBZON=$PIECE(^PSB(53.79,PSBIEN,.1),"^")
+9 DO CLEAN^PSBVT
+10 DO PSJ1^PSBVT(DFN,PSBZON)
+11 IF PSBPBK'=0
DO NOW^%DTC
IF ($$FMADD^XLFDT($PIECE(PSBOSP,"."),(PSBPBK))<X)
QUIT
+12 ; dfn
SET $PIECE(PSBREC,U,1)=DFN
+13 ; order numer
SET $PIECE(PSBREC,U,2)=PSBONX
+14 ; order ien
SET $PIECE(PSBREC,U,3)=PSBON
+15 ; order type U unit dose
SET $PIECE(PSBREC,U,4)="U"
+16 SET $PIECE(PSBREC,U,5)=PSBSCHT
+17 SET $PIECE(PSBREC,U,6)=PSBSCH
+18 SET $PIECE(PSBREC,U,7)=$SELECT(PSBHSM:"HSM",PSBSM:"SM",1:"")
+19 SET $PIECE(PSBREC,U,8)=PSBOITX
+20 SET $PIECE(PSBREC,U,9)=PSBDOSE
+21 SET $PIECE(PSBREC,U,10)=PSBMR
+22 IF $DATA(PSBHSTAX(PSBOIT))
SET $PIECE(PSBREC,U,11)=$ORDER(PSBHSTAX(PSBOIT,""),-1)
SET $PIECE(PSBREC,U,20)=$ORDER(PSBHSTAX(PSBOIT,$PIECE(PSBREC,U,11),""),-1)
+23 IF '$DATA(PSBHSTAX(PSBOIT))
Begin DoDot:2
+24 NEW PSBX,PSBY,PSBDONE
SET PSBDONE=0
SET PSBX=""
FOR
SET PSBX=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,PSBX),-1)
IF PSBX=""
QUIT
IF 'PSBDONE
Begin DoDot:3
+25 SET PSBY=""
FOR
SET PSBY=$ORDER(^PSB(53.79,"AOIP",DFN,PSBOIT,PSBX,PSBY),-1)
IF PSBY=""
QUIT
IF 'PSBDONE
Begin DoDot:4
+26 IF $PIECE(^PSB(53.79,PSBY,0),U,9)'="N"
SET $PIECE(PSBREC,U,20)=$PIECE(^PSB(53.79,PSBY,0),U,9)
IF ($PIECE(PSBREC,U,20)'="N")&($PIECE(PSBREC,U,20)]"")
SET $PIECE(PSBREC,U,11)=PSBX
SET PSBDONE=1
End DoDot:4
End DoDot:3
End DoDot:2
+27 SET $PIECE(PSBREC,U,12)=PSBIEN
+28 SET $PIECE(PSBREC,U,13)="G"
+29 SET $PIECE(PSBREC,U,14)=$PIECE(^PSB(53.79,PSBIEN,.1),U,3)
+30 IF $PIECE(PSBREC,U,14)=""
SET $PIECE(PSBREC,U,14)=PSBNOW\1
+31 SET $PIECE(PSBREC,U,15)=PSBOIT
+32 IF ($GET(PSBTAB)="CVRSHT")!($GET(PSBTAB)="UDTAB")
Begin DoDot:2
+33 ;Set injectable med route flag
SET $PIECE(PSBREC,U,16)=$SELECT($GET(PSBX)="":0,1:PSBNJECT)
+34 IF $PIECE(PSBREC,U,9)?1.4N1"-"1.4N.E
SET $PIECE(PSBREC,U,17)=1
+35 IF '$TEST
SET $PIECE(PSBREC,U,17)=0
+36 SET $PIECE(PSBREC,U,19)=$SELECT(PSBVNI]"":PSBVNI,PSBVNI']"":"***")
+37 SET $PIECE(PSBREC,U,23)=""
+38 SET $PIECE(PSBREC,U,26)=PSBOSP
+39 SET $PIECE(PSBREC,U,27)=$$LASTG^PSBCSUTL($PIECE(PSBREC,U),$PIECE(PSBREC,U,15))
+40 SET $PIECE(PSBREC,U,28)=0
+41 IF ($GET(PSBTAB)="CVRSHT")
SET $PIECE(PSBREC,U,28)=1
+42 IF ($GET(PSBTAB)="UDTAB")
IF PSBSCHT'="O"
IF (PSBOSTS="E")!(PSBOSTS["D")
SET $PIECE(PSBREC,U,28)=1
+43 ; Place into Coversheet activity ARRAY
+44 SET PSBDIDX=""
IF $DATA(^PSB(53.79,"AORD",DFN,PSBONX))
Begin DoDot:3
+45 SET PSBXDTI=""
SET PSBXDTI=$ORDER(^PSB(53.79,"AORD",DFN,PSBONX,PSBXDTI),-1)
+46 IF '$DATA(^PSB(53.79,"AORD",DFN,PSBONX,PSBXDTI,PSBIEN))
QUIT
+47 SET PSBADMX(PSBONX,PSBXDTI,PSBIEN)=""
SET PSBDIDX=1
End DoDot:3
+48 IF ('PSBDIDX)&$DATA(^PSB(53.79,"AORDX",DFN,PSBONX))
Begin DoDot:3
+49 SET PSBXXDTI=""
SET PSBXXDTI=$ORDER(^PSB(53.79,"AORDX",DFN,PSBONX,PSBXXDTI),-1)
+50 IF '$DATA(^PSB(53.79,"AORDX",DFN,PSBONX,PSBXXDTI,PSBIEN))
QUIT
+51 SET PSBADMX(PSBONX,PSBXXDTI,PSBIEN)=""
End DoDot:3
End DoDot:2
+52 SET $PIECE(PSBREC,U,18)="PATCH"
+53 SET $PIECE(PSBREC,U,21)=PSBOST
+54 SET $PIECE(PSBREC,U,22)=PSBOSTS
+55 SET PSBDDS=""
FOR Y=0:0
SET Y=$ORDER(PSBDDA(Y))
IF 'Y
QUIT
IF $PIECE(PSBDDA(Y),U,4)=""
SET $PIECE(PSBDDA(Y),U,4)=1
SET PSBDDS=PSBDDS_U_$PIECE(PSBDDA(Y),U,1,4)
SET $PIECE(PSBDDS,U,1)=PSBDDS+1
+56 SET PSBQRR=1
+57 DO ADD^PSBVDLU1(PSBREC,PSBOTXT,$PIECE(PSBREC,U,14),PSBDDS,"","",$SELECT($GET(PSBTAB)="CVRSHT":"CVRSHT",1:"UDTAB"))
End DoDot:1
+58 KILL PSBPBK,PSBONVDL
+59 QUIT