PSDEM4 ;BIR/JPW,LTL-Nurse CS Priority Order Status; 25 Apr 95
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
S PSDUZ=DUZ,(MSG,MSG1)=0,Y=DT X ^DD("DD") S REQD=Y
NAOU ;select NAOU to check priority orders for
K DA,DIC S DIC=58.8,DIC(0)="QEA",DIC("A")="Select Ordering NAOU: "
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
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
S TYPE=$P(^PSD(58.8,+PSDS,0),"^",2),OKTYP=$S(TYPE="M":1,TYPE="S":1,1:0) I 'OKTYP W !!,"Contact your Pharmacy Coordinator.",!,"The Pharmacy Dispensing Site is invalid for this NAOU." G END
LOOP S PSDT=DT
W:$O(^PSD(58.81,"AEM",DT)) !!,"Today's Priority Orders:"
F S PSDT=$O(^PSD(58.81,"AEM",PSDT)) Q:'PSDT S PSDT(1)=0 F S PSDT(1)=$O(^PSD(58.81,"AEM",PSDT,+PSDS,PSDT(1))) Q:'PSDT(1) S PSDT(2)=0 F S PSDT(2)=$O(^PSD(58.81,"AEM",PSDT,+PSDS,PSDT(1),PSDT(2))) Q:'PSDT(2) D
.S PSDT(3)=$G(^PSD(58.81,PSDT(2),0)) Q:$P(PSDT(3),U,18)'=NAOU
.S PSDT(4)=PSDT(2)
.W !!,$P($G(^PSDRUG(PSDT(1),0)),U)," ",$P(PSDT(3),U,6)," "
.W $P($G(^PSD(58.8,+PSDS,1,PSDT(1),0)),U,8)
.W !,$P($G(^PSD(58.82,$P(PSDT(3),U,11),0)),U)
W:'$G(PSDT(4)) !!,"No Priority Orders ready for ",NAOUN,"."
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,PSDA,PSDEM,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,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
PSDEM4 ;BIR/JPW,LTL-Nurse CS Priority Order Status; 25 Apr 95
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
+2 IF '$DATA(PSDSITE)
DO ^PSDSET
IF '$DATA(PSDSITE)
QUIT
+3 SET PSDUZ=DUZ
SET (MSG,MSG1)=0
SET Y=DT
XECUTE ^DD("DD")
SET REQD=Y
NAOU ;select NAOU to check priority orders for
+1 KILL DA,DIC
SET DIC=58.8
SET DIC(0)="QEA"
SET DIC("A")="Select Ordering NAOU: "
+2 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)"
+3 WRITE !
DO ^DIC
KILL DIC
IF Y<0
GOTO END
SET NAOU=+Y
SET NAOUN=$PIECE(Y,"^",2)
+4 IF '$DATA(^PSD(58.8,NAOU,0))
SET MSG=1
DO MSG
GOTO END
+5 IF '$ORDER(^PSD(58.8,NAOU,1,0))
SET MSG=1
SET MSG1=2
DO MSG
GOTO END
+6 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
+7 IF '$DATA(^PSD(58.8,+PSDS,0))
SET MSG=2
DO MSG
GOTO END
+8 IF '$ORDER(^PSD(58.8,+PSDS,1,0))
SET MSG=2
SET MSG1=2
DO MSG
GOTO END
+9 SET TYPE=$PIECE(^PSD(58.8,+PSDS,0),"^",2)
SET OKTYP=$SELECT(TYPE="M":1,TYPE="S":1,1:0)
IF 'OKTYP
WRITE !!,"Contact your Pharmacy Coordinator.",!,"The Pharmacy Dispensing Site is invalid for this NAOU."
GOTO END
LOOP SET PSDT=DT
+1 IF $ORDER(^PSD(58.81,"AEM",DT))
WRITE !!,"Today's Priority Orders:"
+2 FOR
SET PSDT=$ORDER(^PSD(58.81,"AEM",PSDT))
IF 'PSDT
QUIT
SET PSDT(1)=0
FOR
SET PSDT(1)=$ORDER(^PSD(58.81,"AEM",PSDT,+PSDS,PSDT(1)))
IF 'PSDT(1)
QUIT
SET PSDT(2)=0
FOR
SET PSDT(2)=$ORDER(^PSD(58.81,"AEM",PSDT,+PSDS,PSDT(1),PSDT(2)))
IF 'PSDT(2)
QUIT
Begin DoDot:1
+3 SET PSDT(3)=$GET(^PSD(58.81,PSDT(2),0))
IF $PIECE(PSDT(3),U,18)'=NAOU
QUIT
+4 SET PSDT(4)=PSDT(2)
+5 WRITE !!,$PIECE($GET(^PSDRUG(PSDT(1),0)),U)," ",$PIECE(PSDT(3),U,6)," "
+6 WRITE $PIECE($GET(^PSD(58.8,+PSDS,1,PSDT(1),0)),U,8)
+7 WRITE !,$PIECE($GET(^PSD(58.82,$PIECE(PSDT(3),U,11),0)),U)
End DoDot:1
+8 IF '$GET(PSDT(4))
WRITE !!,"No Priority Orders ready for ",NAOUN,"."
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,PSDA,PSDEM,PSDOUT,PSDQTY,PSDRD,PSDR,PSDRN,PSDS,PSDT,PSDUZ,PSDUZN,REQD,TEXT,TYPE,WORD,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