PSDORD ;BIR/JPW,LTL - Nurse CS Order Request Entry DIR style; 8 Aug 94
;;3.0; CONTROLLED SUBSTANCES ;**51**;13 Feb 97
;Any requests not ordered?
K PSD,PSDA,PSDB S PSD=0
W !,"Searching for ",$P($G(^VA(200,DUZ,.1)),U,4),"'s pending requests."
F S PSD=$O(^PSD(58.8,"AC",.5,+NAOU,PSD)) Q:'PSD D
.S PSD(1)=0 F S PSD(1)=$O(^PSD(58.8,"AC",.5,+NAOU,PSD,PSD(1))) Q:'PSD(1) W "." S:$P($G(^PSD(58.8,+NAOU,1,+PSD,3,PSD(1),0)),U,4)=DUZ PSDA(PSD,PSD(1))=$G(^(0))
I $O(PSDA(0)) D ^PSDORD1 G:$G(PSDOUT) END
W:'$O(PSDA(0)) " No pending requests.",!
DRUG ;select drug
S MSG=0 ;; PSD*3*51 - RJS
K DA,DIC,PSDR S DIC("W")="W:$P(^PSDRUG(Y,0),""^"",9) "" N/F"" W $S('$G(^PSD(58.8,NAOU,1,Y,0)):"" NOT STOCKED BY ""_NAOUN,$P(^(0),U,14)&($P(^(0),U,14)'>DT):"" INACTIVE on ""_NAOUN,1:"""")"
S DIC("S")="I '$P($G(^(7)),U,2),$S('$P(^(0),""^"",14):1,+$P(^(0),""^"",14)>DT:1,1:0)"
S DA(1)=+PSDS,DIC(0)="QEAM",DIC="^PSD(58.8,"_+PSDS_",1,"
;one time requests not allowed by dispensing site
D:'$P($G(^PSD(58.8,+PSDS,0)),U,13)
.S DIC("W")="W:$P(^PSDRUG(Y,0),U,9) "" N/F"" I $P(^PSD(58.8,NAOU,1,Y,0),U,14)]"""",$P(^(0),U,14)'>DT W $C(7),"" *** INACTIVE ***"""
.S DIC("S")="I $S('$P(^(0),U,14):1,+$P(^(0),U,14)>DT:1,1:0)"
.S DA(1)=+NAOU,DIC="^PSD(58.8,"_NAOU_",1,"
D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT)) END G:Y<1&($O(PSDA(0))) ^PSDORD1 G:Y<1 END S PSDR=+Y,PSDRN=$S($P(^PSDRUG(PSDR,0),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING")
I $S('$D(^PSD(58.8,NAOU,1,PSDR,0)):1,$P(^(0),U,14)&($P(^(0),U,14)'>DT):1,1:0) D ^PSDORD4 G:$D(DIRUT) END G DRUG
I '$D(^PSD(58.8,NAOU,1,PSDR,0)) D MSG G END
I '$D(^PSD(58.8,+PSDS,1,PSDR,0)) S MSG=2 D MSG G END
S NBKU=$P(^PSD(58.8,+PSDS,1,PSDR,0),"^",8),NPKG=+$P(^(0),"^",9)
I NBKU']"" S MSG1=3 D MSG G END
I 'NPKG S MSG1=4 D MSG G END
D LIST^PSDORL
;Perpetual?
G:$P($G(^PSD(58.8,+NAOU,2)),U,5) ^PSDORD3
QTY K ORD S PSDOUT=0 S DIR(0)="58.800118,5A"
S DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_"): ",DIR("B")=NPKG
D ^DIR K DIR G:$D(DIRUT) END G:Y<1 DRUG
I Y=NPKG S PSDQTY=Y D DIE W ! G DRUG
I X["?"!(X'?1.N)!(X#NPKG)!('X) W !!,"Quantity must be "_NPKG_" or a multiple of "_NPKG,! G QTY
S CNT=X/NPKG W !!,"This will be "_CNT_" separate order requests. The quantity is "_NPKG_" per request."
W ! K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Do you want me to generate the "_CNT_" separate order requests",DIR("B")="YES",DIR("?",1)="Answer 'YES' to create the multiple order requests,"
S DIR("?")="Answer 'NO' to edit your comments or '^' to quit." D ^DIR K DIR G:$D(DIRUT) END
I 'Y W !,"No order request created. You must edit quantity.",! G QTY
I Y W !!,"The "_CNT_" requests are being created.",! S PSDQTY=NPKG D W ! G DRUG
.F ORD=1:1:CNT W !!,"Creating your order request # "_ORD_" of "_CNT_" for "_PSDRN D DIE S PSDA(+PSDR,PSDA)=$G(^PSD(58.8,+NAOU,1,+PSDR,3,+PSDA,0))
I '$G(PSDOUT) W ! G DRUG
END K %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1
K NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSD,PSDA,PSDB,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,X,Y
Q
DIE ;create the order request
S:'$D(^PSD(58.8,NAOU,1,PSDR,3,0)) ^(0)="^58.800118A^^"
S PSDA=$P(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1 I $D(^PSD(58.8,NAOU,1,PSDR,3,PSDA)) S $P(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)=$P(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1 G DIE
K DA,DIC,DIE,DD,DR,DO S DIC(0)="L",(DIC,DIE)="^PSD(58.8,"_NAOU_",1,"_PSDR_",3,",DA(2)=NAOU,DA(1)=PSDR,(X,DINUM)=PSDA D FILE^DICN K DIC
D NOW^%DTC S PSDT=+$E(%,1,12) W ?10,!!,"processing now..."
S DA=PSDA,DA(1)=PSDR,DA(2)=NAOU,DR="1////"_PSDT_";2////"_+PSDS_";3////"_PSDUZ_";10////.5;5////"_PSDQTY_";13" D ^DIE K DIE,DR
S PSDA(+PSDR,+PSDA)=$G(^PSD(58.8,+NAOU,1,+PSDR,3,PSDA,0))
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
PSDORD ;BIR/JPW,LTL - Nurse CS Order Request Entry DIR style; 8 Aug 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;**51**;13 Feb 97
+2 ;Any requests not ordered?
+3 KILL PSD,PSDA,PSDB
SET PSD=0
+4 WRITE !,"Searching for ",$PIECE($GET(^VA(200,DUZ,.1)),U,4),"'s pending requests."
+5 FOR
SET PSD=$ORDER(^PSD(58.8,"AC",.5,+NAOU,PSD))
IF 'PSD
QUIT
Begin DoDot:1
+6 SET PSD(1)=0
FOR
SET PSD(1)=$ORDER(^PSD(58.8,"AC",.5,+NAOU,PSD,PSD(1)))
IF 'PSD(1)
QUIT
WRITE "."
IF $PIECE($GET(^PSD(58.8,+NAOU,1,+PSD,3,PSD(1),0)),U,4)=DUZ
SET PSDA(PSD,PSD(1))=$GET(^(0))
End DoDot:1
+7 IF $ORDER(PSDA(0))
DO ^PSDORD1
IF $GET(PSDOUT)
GOTO END
+8 IF '$ORDER(PSDA(0))
WRITE " No pending requests.",!
DRUG ;select drug
+1 ;; PSD*3*51 - RJS
SET MSG=0
+2 KILL DA,DIC,PSDR
SET DIC("W")="W:$P(^PSDRUG(Y,0),""^"",9) "" N/F"" W $S('$G(^PSD(58.8,NAOU,1,Y,0)):"" NOT STOCKED BY ""_NAOUN,$P(^(0),U,14)&($P(^(0),U,14)'>DT):"" INACTIVE on ""_NAOUN,1:"""")"
+3 SET DIC("S")="I '$P($G(^(7)),U,2),$S('$P(^(0),""^"",14):1,+$P(^(0),""^"",14)>DT:1,1:0)"
+4 SET DA(1)=+PSDS
SET DIC(0)="QEAM"
SET DIC="^PSD(58.8,"_+PSDS_",1,"
+5 ;one time requests not allowed by dispensing site
+6 IF '$PIECE($GET(^PSD(58.8,+PSDS,0)),U,13)
Begin DoDot:1
+7 SET DIC("W")="W:$P(^PSDRUG(Y,0),U,9) "" N/F"" I $P(^PSD(58.8,NAOU,1,Y,0),U,14)]"""",$P(^(0),U,14)'>DT W $C(7),"" *** INACTIVE ***"""
+8 SET DIC("S")="I $S('$P(^(0),U,14):1,+$P(^(0),U,14)>DT:1,1:0)"
+9 SET DA(1)=+NAOU
SET DIC="^PSD(58.8,"_NAOU_",1,"
End DoDot:1
+10 DO ^DIC
KILL DIC
IF $DATA(DTOUT)!($DATA(DUOUT))
GOTO END
IF Y<1&($ORDER(PSDA(0)))
GOTO ^PSDORD1
IF Y<1
GOTO END
SET PSDR=+Y
SET PSDRN=$SELECT($PIECE(^PSDRUG(PSDR,0),"^")]"":$PIECE(^(0),"^"),1:"DRUG NAME MISSING")
+11 IF $SELECT('$DATA(^PSD(58.8,NAOU,1,PSDR,0)):1,$PIECE(^(0),U,14)&($PIECE(^(0),U,14)'>DT):1,1:0)
DO ^PSDORD4
IF $DATA(DIRUT)
GOTO END
GOTO DRUG
+12 IF '$DATA(^PSD(58.8,NAOU,1,PSDR,0))
DO MSG
GOTO END
+13 IF '$DATA(^PSD(58.8,+PSDS,1,PSDR,0))
SET MSG=2
DO MSG
GOTO END
+14 SET NBKU=$PIECE(^PSD(58.8,+PSDS,1,PSDR,0),"^",8)
SET NPKG=+$PIECE(^(0),"^",9)
+15 IF NBKU']""
SET MSG1=3
DO MSG
GOTO END
+16 IF 'NPKG
SET MSG1=4
DO MSG
GOTO END
+17 DO LIST^PSDORL
+18 ;Perpetual?
+19 IF $PIECE($GET(^PSD(58.8,+NAOU,2)),U,5)
GOTO ^PSDORD3
QTY KILL ORD
SET PSDOUT=0
SET DIR(0)="58.800118,5A"
+1 SET DIR("A")="QUANTITY ("_NBKU_"/"_NPKG_"): "
SET DIR("B")=NPKG
+2 DO ^DIR
KILL DIR
IF $DATA(DIRUT)
GOTO END
IF Y<1
GOTO DRUG
+3 IF Y=NPKG
SET PSDQTY=Y
DO DIE
WRITE !
GOTO DRUG
+4 IF X["?"!(X'?1.N)!(X#NPKG)!('X)
WRITE !!,"Quantity must be "_NPKG_" or a multiple of "_NPKG,!
GOTO QTY
+5 SET CNT=X/NPKG
WRITE !!,"This will be "_CNT_" separate order requests. The quantity is "_NPKG_" per request."
+6 WRITE !
KILL DA,DIR,DIRUT
SET DIR(0)="Y"
SET DIR("A")="Do you want me to generate the "_CNT_" separate order requests"
SET DIR("B")="YES"
SET DIR("?",1)="Answer 'YES' to create the multiple order requests,"
+7 SET DIR("?")="Answer 'NO' to edit your comments or '^' to quit."
DO ^DIR
KILL DIR
IF $DATA(DIRUT)
GOTO END
+8 IF 'Y
WRITE !,"No order request created. You must edit quantity.",!
GOTO QTY
+9 IF Y
WRITE !!,"The "_CNT_" requests are being created.",!
SET PSDQTY=NPKG
Begin DoDot:1
+10 FOR ORD=1:1:CNT
WRITE !!,"Creating your order request # "_ORD_" of "_CNT_" for "_PSDRN
DO DIE
SET PSDA(+PSDR,PSDA)=$GET(^PSD(58.8,+NAOU,1,+PSDR,3,+PSDA,0))
End DoDot:1
WRITE !
GOTO DRUG
+11 IF '$GET(PSDOUT)
WRITE !
GOTO DRUG
END KILL %,%DT,%H,%I,CNT,CNT1,DA,DIC,DIE,DINUM,DIR,DIROUT,DIRUT,DIWF,DIWL,DIWR,DR,DTOUT,DUOUT,LN,MSG,MSG1
+1 KILL NAOU,NAOUN,NBKU,NPKG,OK,OKTYP,ORD,PSD,PSDA,PSDB,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,X,Y
+2 QUIT
DIE ;create the order request
+1 IF '$DATA(^PSD(58.8,NAOU,1,PSDR,3,0))
SET ^(0)="^58.800118A^^"
+2 SET PSDA=$PIECE(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1
IF $DATA(^PSD(58.8,NAOU,1,PSDR,3,PSDA))
SET $PIECE(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)=$PIECE(^PSD(58.8,NAOU,1,PSDR,3,0),"^",3)+1
GOTO DIE
+3 KILL DA,DIC,DIE,DD,DR,DO
SET DIC(0)="L"
SET (DIC,DIE)="^PSD(58.8,"_NAOU_",1,"_PSDR_",3,"
SET DA(2)=NAOU
SET DA(1)=PSDR
SET (X,DINUM)=PSDA
DO FILE^DICN
KILL DIC
+4 DO NOW^%DTC
SET PSDT=+$EXTRACT(%,1,12)
WRITE ?10,!!,"processing now..."
+5 SET DA=PSDA
SET DA(1)=PSDR
SET DA(2)=NAOU
SET DR="1////"_PSDT_";2////"_+PSDS_";3////"_PSDUZ_";10////.5;5////"_PSDQTY_";13"
DO ^DIE
KILL DIE,DR
+6 SET PSDA(+PSDR,+PSDA)=$GET(^PSD(58.8,+NAOU,1,+PSDR,3,PSDA,0))
+7 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