PSDRF4 ;BIR/JPW,LTL-Nurse RF damaged dose ; 8 Aug 94
;;3.0; CONTROLLED SUBSTANCES ;**25,60**;13 Feb 97
;Reference to ^PSD(58.8 are covered by DBIA #2711
;Reference to ^PSD(58.81 are covered by DBIA #2808
;Reference to ^PSDRUG( are covered by DBIA #221
;Reference to $$WITNESS^XUVERIFY are covered by DBIA #1513
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
I $P($G(^VA(200,DUZ,20)),U,4)']"" N XQH S XQH="PSD ESIG" D EN^XQH G END
S PSDUZ=DUZ,(MSG,MSG1)=0,Y=DT X ^DD("DD") S REQD=Y
NURSE N X,X1 D SIG^XUSESIG I X1="" G END
NAOU ;select NAOU to dispense from
I $G(NAOU) S PSDS=+$P(^PSD(58.8,NAOU,0),U,4) G DRUG
W !!,"Please enter the ward from which the defective drug(s) will be destroyed."
K DA,DIC S DIC=58.8,DIC(0)="QEA",DIC("A")="Select Ward: "
S DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)"
W ! D ^DIC K DIC G:Y<0 END S NAOU=+Y,NAOUN=$P(Y,"^",2)
I '$D(^PSD(58.8,NAOU,0)) S MSG=1 D MSG G END
I '$O(^PSD(58.8,NAOU,1,0)) S MSG=1,MSG1=2 D MSG G END
I '$P(^PSD(58.8,NAOU,0),U,4) S MSG=2 D MSG G END
S PSDS=+$P(^PSD(58.8,NAOU,0),"^",4),PSDS=PSDS_"^"_+$P(^PSD(58.8,+PSDS,0),"^",5) I '+PSDS S (MSG,MSG1)=1 D MSG G END
I '$D(^PSD(58.8,+PSDS,0)) S MSG=2 D MSG G END
I '$O(^PSD(58.8,+PSDS,1,0)) S MSG=2,MSG1=2 D MSG G END
DRUG ;select drug
N DIR,PSD,PSDR,PSDQ,PSDDT
S DIR(0)="FAO^1:40"
S DIR("A")="Scan Drug Label or Enter Label # or Drug: "
W ! D ^DIR K DIR G:$D(DIRUT) END
I $L(Y)=1,Y'=" " W $C(7),!!,"Please enter more than one character.",! G DRUG
I $O(^PSD(58.81,"D",Y,0)) D
.S PSD=0
.F S PSD=$O(^PSD(58.81,"D",Y,PSD)) Q:'PSD S PSD(1)=$G(^PSD(58.81,PSD,0)) I $P(PSD(1),U,11)>3,$P(PSD(1),U,18)=NAOU S PSDR=$P(PSD(1),U,5),PSDPN=$P(PSD(1),U,17),PSDTYP=17
I $D(PSDR),PSDR'=Y D
.I $D(^PSDRUG(Y)),$D(^PSD(58.8,NAOU,1,Y)) D
..S PSDDT=$$FMDIFF^DILIBF(DT,$P(PSD(1),U,4),"")
..I PSDDT>365 S PSDR=Y
.I '$D(^PSDRUG(Y)),$D(PSD(1)) D
..S PSDDT=$$FMDIFF^DILIBF(DT,$P(PSD(1),U,4),"")
..I PSDDT>365 K PSDR
.I '$D(^PSDRUG(Y)),'$D(^PSD(58.8,NAOU,1,Y)),'$D(PSDR) W $C(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!! G END
D:'$G(PSDR) G:$D(DTOUT)!($D(DUOUT)) END G:Y<1 DRUG
.S DIC="^PSD(58.8,NAOU,1,",DIC(0)="EMQSZ",DA(1)=NAOU
.W ! D ^DIC K DIC I $D(DTOUT)!($D(DUOUT))!(Y<1) W $C(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!! Q
.S PSDR=+Y,PSDTYP=9,PSDRE="DEFECTIVE DOSE"
I '$G(PSDR) W $C(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!! G END
W:$G(PSDR) !!,$P($G(^PSDRUG(PSDR,0)),U)
BAL S PSDR(1)=$G(^PSD(58.8,NAOU,1,PSDR,0)),OQTY=$P(PSDR(1),U,4)
I 'OQTY W !!,"Sorry, this drug has a zero balance." G DRUG
;PSD*3*25 (DAVE B)
K PSDDAVE D ^PSDRFV I $G(PSDDAVE)=1 K PSDDAVE S PSDOUT=1 G END
S DIR(0)="Y",DIR("A")="Starting Balance: "_OQTY_" "_$P(PSDR(1),U,8)_" Correct count"
S DIR("B")="Yes",NUR1=DUZ
S DIR("?")="Answer Yes if the amount on hand equals the starting balance."
W ! D ^DIR K DIR G:$D(DIRUT) END
I Y=0 D ^PSDRF2 G:$G(PSDOUT) END S $P(PSDR(1),U,4)=PSDQ(1),OQTY=PSDQ(1),PSDTYP=17
LIQ G:$P($G(^PSD(58.8,+PSDS,1,PSDR,7)),U) ^PSDRF5
DEF W ! S DIR(0)="NA^.01:"_OQTY_":2",DIR("A")="Amount defective: "
S DIR("B")=1 D ^DIR K DIR G:$D(DIRUT) END S (PSDQ,WQTY)=Y
WIT S NUR2=$$WITNESS^XUVERIFY("WITNESS")
I NUR2=DUZ W !!,"Wait a minute, you can't witness yourself!",$C(7) G WIT
I NUR2'>0 S PSDOUT=1 Q
W !!,"Thank you, ",$S($P($G(^VA(200,NUR2,.1)),U,4)]"":$P($G(^(.1)),U,4),1:$P($G(^VA(200,NUR2,0)),U))
W !!,"Remaining Balance: ",$P(PSDR(1),U,4)-PSDQ," ",$P(PSDR(1),U,8)
D UPDAT^PSDRF1
END W:$G(PSDOUT) !!,"No dose signed out.",$C(7),!! K %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1,NUR2,WQTY
K NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSDA,PSDEM,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,PSDPN,PSDTYP,PSDRE,OQTY,REQD,TEXT,TYPE,WORD,NUR1,X,Y
Q
MSG ;display error message
W $C(7),!!,?10,"Contact your Pharmacy Coordinator.",!,?10,"This "_$S(MSG=2:"Dispensing Site",MSG=1:"NAOU",1:"Drug")_" is missing "
W $S(MSG1=1:"Primary Disp. Site",MSG1=2:"stocked drugs",MSG1=3:"narcotic breakdown unit",MSG1=4:"narcotic package size",1:"data")_".",!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDRF4 4269 printed Dec 13, 2024@01:48:35 Page 2
PSDRF4 ;BIR/JPW,LTL-Nurse RF damaged dose ; 8 Aug 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;**25,60**;13 Feb 97
+2 ;Reference to ^PSD(58.8 are covered by DBIA #2711
+3 ;Reference to ^PSD(58.81 are covered by DBIA #2808
+4 ;Reference to ^PSDRUG( are covered by DBIA #221
+5 ;Reference to $$WITNESS^XUVERIFY are covered by DBIA #1513
+6 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
QUIT
+7 IF $PIECE($GET(^VA(200,DUZ,20)),U,4)']""
NEW XQH
SET XQH="PSD ESIG"
DO EN^XQH
GOTO END
+8 SET PSDUZ=DUZ
SET (MSG,MSG1)=0
SET Y=DT
XECUTE ^DD("DD")
SET REQD=Y
NURSE NEW X,X1
DO SIG^XUSESIG
IF X1=""
GOTO END
NAOU ;select NAOU to dispense from
+1 IF $GET(NAOU)
SET PSDS=+$PIECE(^PSD(58.8,NAOU,0),U,4)
GOTO DRUG
+2 WRITE !!,"Please enter the ward from which the defective drug(s) will be destroyed."
+3 KILL DA,DIC
SET DIC=58.8
SET DIC(0)="QEA"
SET DIC("A")="Select Ward: "
+4 SET DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S('$D(^(""I"")):1,'^(""I""):1,+^(""I"")>DT:1,1:0),$P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7)"
+5 WRITE !
DO ^DIC
KILL DIC
if Y<0
GOTO END
SET NAOU=+Y
SET NAOUN=$PIECE(Y,"^",2)
+6 IF '$DATA(^PSD(58.8,NAOU,0))
SET MSG=1
DO MSG
GOTO END
+7 IF '$ORDER(^PSD(58.8,NAOU,1,0))
SET MSG=1
SET MSG1=2
DO MSG
GOTO END
+8 IF '$PIECE(^PSD(58.8,NAOU,0),U,4)
SET MSG=2
DO MSG
GOTO END
+9 SET PSDS=+$PIECE(^PSD(58.8,NAOU,0),"^",4)
SET PSDS=PSDS_"^"_+$PIECE(^PSD(58.8,+PSDS,0),"^",5)
IF '+PSDS
SET (MSG,MSG1)=1
DO MSG
GOTO END
+10 IF '$DATA(^PSD(58.8,+PSDS,0))
SET MSG=2
DO MSG
GOTO END
+11 IF '$ORDER(^PSD(58.8,+PSDS,1,0))
SET MSG=2
SET MSG1=2
DO MSG
GOTO END
DRUG ;select drug
+1 NEW DIR,PSD,PSDR,PSDQ,PSDDT
+2 SET DIR(0)="FAO^1:40"
+3 SET DIR("A")="Scan Drug Label or Enter Label # or Drug: "
+4 WRITE !
DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO END
+5 IF $LENGTH(Y)=1
IF Y'=" "
WRITE $CHAR(7),!!,"Please enter more than one character.",!
GOTO DRUG
+6 IF $ORDER(^PSD(58.81,"D",Y,0))
Begin DoDot:1
+7 SET PSD=0
+8 FOR
SET PSD=$ORDER(^PSD(58.81,"D",Y,PSD))
if 'PSD
QUIT
SET PSD(1)=$GET(^PSD(58.81,PSD,0))
IF $PIECE(PSD(1),U,11)>3
IF $PIECE(PSD(1),U,18)=NAOU
SET PSDR=$PIECE(PSD(1),U,5)
SET PSDPN=$PIECE(PSD(1),U,17)
SET PSDTYP=17
End DoDot:1
+9 IF $DATA(PSDR)
IF PSDR'=Y
Begin DoDot:1
+10 IF $DATA(^PSDRUG(Y))
IF $DATA(^PSD(58.8,NAOU,1,Y))
Begin DoDot:2
+11 SET PSDDT=$$FMDIFF^DILIBF(DT,$PIECE(PSD(1),U,4),"")
+12 IF PSDDT>365
SET PSDR=Y
End DoDot:2
+13 IF '$DATA(^PSDRUG(Y))
IF $DATA(PSD(1))
Begin DoDot:2
+14 SET PSDDT=$$FMDIFF^DILIBF(DT,$PIECE(PSD(1),U,4),"")
+15 IF PSDDT>365
KILL PSDR
End DoDot:2
+16 IF '$DATA(^PSDRUG(Y))
IF '$DATA(^PSD(58.8,NAOU,1,Y))
IF '$DATA(PSDR)
WRITE $CHAR(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!!
GOTO END
End DoDot:1
+17 if '$GET(PSDR)
Begin DoDot:1
+18 SET DIC="^PSD(58.8,NAOU,1,"
SET DIC(0)="EMQSZ"
SET DA(1)=NAOU
+19 WRITE !
DO ^DIC
KILL DIC
IF $DATA(DTOUT)!($DATA(DUOUT))!(Y<1)
WRITE $CHAR(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!!
QUIT
+20 SET PSDR=+Y
SET PSDTYP=9
SET PSDRE="DEFECTIVE DOSE"
End DoDot:1
if $DATA(DTOUT)!($DATA(DUOUT))
GOTO END
if Y<1
GOTO DRUG
+21 IF '$GET(PSDR)
WRITE $CHAR(7),!!,"This is not a valid Pharmacy Dispensing number for this ward.",!!
GOTO END
+22 if $GET(PSDR)
WRITE !!,$PIECE($GET(^PSDRUG(PSDR,0)),U)
BAL SET PSDR(1)=$GET(^PSD(58.8,NAOU,1,PSDR,0))
SET OQTY=$PIECE(PSDR(1),U,4)
+1 IF 'OQTY
WRITE !!,"Sorry, this drug has a zero balance."
GOTO DRUG
+2 ;PSD*3*25 (DAVE B)
+3 KILL PSDDAVE
DO ^PSDRFV
IF $GET(PSDDAVE)=1
KILL PSDDAVE
SET PSDOUT=1
GOTO END
+4 SET DIR(0)="Y"
SET DIR("A")="Starting Balance: "_OQTY_" "_$PIECE(PSDR(1),U,8)_" Correct count"
+5 SET DIR("B")="Yes"
SET NUR1=DUZ
+6 SET DIR("?")="Answer Yes if the amount on hand equals the starting balance."
+7 WRITE !
DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO END
+8 IF Y=0
DO ^PSDRF2
if $GET(PSDOUT)
GOTO END
SET $PIECE(PSDR(1),U,4)=PSDQ(1)
SET OQTY=PSDQ(1)
SET PSDTYP=17
LIQ if $PIECE($GET(^PSD(58.8,+PSDS,1,PSDR,7)),U)
GOTO ^PSDRF5
DEF WRITE !
SET DIR(0)="NA^.01:"_OQTY_":2"
SET DIR("A")="Amount defective: "
+1 SET DIR("B")=1
DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO END
SET (PSDQ,WQTY)=Y
WIT SET NUR2=$$WITNESS^XUVERIFY("WITNESS")
+1 IF NUR2=DUZ
WRITE !!,"Wait a minute, you can't witness yourself!",$CHAR(7)
GOTO WIT
+2 IF NUR2'>0
SET PSDOUT=1
QUIT
+3 WRITE !!,"Thank you, ",$SELECT($PIECE($GET(^VA(200,NUR2,.1)),U,4)]"":$PIECE($GET(^(.1)),U,4),1:$PIECE($GET(^VA(200,NUR2,0)),U))
+4 WRITE !!,"Remaining Balance: ",$PIECE(PSDR(1),U,4)-PSDQ," ",$PIECE(PSDR(1),U,8)
+5 DO UPDAT^PSDRF1
END if $GET(PSDOUT)
WRITE !!,"No dose signed out.",$CHAR(7),!!
KILL %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1,NUR2,WQTY
+1 KILL NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSDA,PSDEM,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,PSDPN,PSDTYP,PSDRE,OQTY,REQD,TEXT,TYPE,WORD,NUR1,X,Y
+2 QUIT
MSG ;display error message
+1 WRITE $CHAR(7),!!,?10,"Contact your Pharmacy Coordinator.",!,?10,"This "_$SELECT(MSG=2:"Dispensing Site",MSG=1:"NAOU",1:"Drug")_" is missing "
+2 WRITE $SELECT(MSG1=1:"Primary Disp. Site",MSG1=2:"stocked drugs",MSG1=3:"narcotic breakdown unit",MSG1=4:"narcotic package size",1:"data")_".",!
+3 QUIT