PSDLBL5 ;BIR/JPW-CS Label Prt for CS Disp Drug (cont'd) ; 17 May 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
START ;entry for compile and print labels
K ^TMP("PSDLBL",$J),PSDPRT D NOW^%DTC S PSDT=+$E(%,1,12)
F JJ=0,1 S @("PSDBAR"_JJ)="" I $D(^%ZIS(2,^%ZIS(1,IOS,"SUBTYPE"),"BAR"_JJ)) S @("PSDBAR"_JJ)=^("BAR"_JJ)
I PSDBAR1]"",PSDBAR0]"" S PSDPRT=1
S PSDCNT=1
I ANS="R" S PSD1="" F S PSD1=$O(PSD1(PSD1)) Q:PSD1="" D LOOP
I ANS="R" G PRINT
I ANS="N",$D(PSDG) F PSD=0:0 S PSD=$O(PSDG(PSD)) Q:'PSD F PSDN=0:0 S PSDN=$O(^PSI(58.2,PSD,3,PSDN)) Q:'PSDN I $D(^PSD(58.8,PSDN,0)),'$P(^(0),"^",7),$P(^(0),"^",3)=+PSDSITE S NAOU(PSDN)="",CNT=CNT+1
I ANS="N",$D(ALL) F PSD=0:0 S PSD=$O(^PSD(58.8,PSD)) Q:'PSD I $D(^PSD(58.8,PSD,0)),$P(^(0),"^",2)="N",$P(^(0),"^",3)=+PSDSITE S NAOU(+PSD)=""
S STAT=3
F PSD=0:0 S PSD=$O(^PSD(58.81,"AD",STAT,PSD)) Q:'PSD F PSDJ=0:0 S PSDJ=$O(^PSD(58.81,"AD",STAT,PSD,PSDJ)) Q:'PSDJ D SET1
PRINT ;print labels
S (PSD,PSDOUT)="" F S PSD=$O(^TMP("PSDLBL",$J,PSD)) Q:PSD=""!(PSDOUT) D
.S PSD(1)=$G(^TMP("PSDLBL",$J,PSD))
.W !,$P(PSD(1),U,2)
.I $D(PSDPRT) W !,@PSDBAR1,$P(PSD(1),U),@PSDBAR0
.W $P(PSD(1),U)," ",$P(PSD(1),U,3),!
DONE I $E(IOST)'="C" W @IOF
I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR,DIRUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu" D ^DIR K DIR
END ;kill variables and exit
K %,%DT,%H,%I,%ZIS,ALL,ANS,CNT,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DRUG,DTOUT,DUOUT,JJ,JLP1,LIQ,NAOU,NAOUN,NODE,OK
K POP,PSD,PSD1,PSD2,PSDA,PSDBAR0,PSDBAR1,PSDCNT,PSDEV,PSDG,PSDJ,PSDN,PSDPN,PSDOUT,PSDR,PSDRG,PSDPRT,PSDRN,PSDS,PSDSN,PSDT,PSDX1,PSDX2
K SEL,STAT,TEMP,TEST,TEXT,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDLBL",$J)
D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
LOOP S PSDPN=$P(PSD1(PSD1),",",PSDCNT),PSDCNT=PSDCNT+1 I PSDPN="" S PSDCNT=1 Q
F PSDJ=0:0 S PSDJ=$O(^PSD(58.81,"D",PSDPN,PSDJ)) Q:'PSDJ D SET1
G LOOP
Q
PRINT1 ;prints labels
W ! F PSDX1=0:1:PSDCNT-1 W ?PSDX1*33+1,$E(TEMP(PSDX1+1),1,30)
I $D(PSDPRT) W !! F PSDX1=1:1:PSDCNT W @PSDBAR1,$P(TEST(PSDX1)," "),@PSDBAR0
W ! F PSDX1=0:1:PSDCNT-1 W ?PSDX1*32+3,TEST(PSDX1+1)
W !!
S PSDCNT=0,PSDX2=PSDX2+1 S:PSDX2=11 PSDX2=1
Q
SET1 ;sets disp info
Q:'$D(^PSD(58.81,+PSDJ,0)) Q:$P($G(^PSD(58.81,+PSDJ,"CS")),"^",5) S NODE=^PSD(58.81,+PSDJ,0) Q:+$P(NODE,"^",3)'=+$G(PSDS)
I ANS="N" Q:'$D(NAOU(+PSD)) S PSDPN=$P(NODE,"^",17) Q:PSDPN']""
I ANS="R" S STAT=+$P(NODE,"^",11) Q:STAT'=3
S NAOU=+$P(NODE,"^",18) Q:'NAOU S NAOUN=$P($G(^PSD(58.8,+NAOU,0)),"^")
S PSDR=+$P(NODE,"^",5) Q:'PSDR
S PSDA=+$P(NODE,"^",20) Q:'PSDA
S PSDN=$P($G(^PSDRUG(+PSDR,0)),"^")
S TEXT(PSDR)=PSDN_"^"_NAOUN
SET ;sets ^tmp
S ^TMP("PSDLBL",$J,PSDPN)=PSDPN_"^"_$P(TEXT(PSDR),"^")_"^"_$E($P(TEXT(PSDR),"^",2),1,12)
DIE ;update label printed
Q:'PSDJ
K DA,DIE,DR S DA=+PSDJ,DIE=58.81,DR="104////"_PSDT D ^DIE K DA,DIE,DR
Q
PSDLBL5 ;BIR/JPW-CS Label Prt for CS Disp Drug (cont'd) ; 17 May 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
START ;entry for compile and print labels
+1 KILL ^TMP("PSDLBL",$JOB),PSDPRT
DO NOW^%DTC
SET PSDT=+$EXTRACT(%,1,12)
+2 FOR JJ=0,1
SET @("PSDBAR"_JJ)=""
IF $DATA(^%ZIS(2,^%ZIS(1,IOS,"SUBTYPE"),"BAR"_JJ))
SET @("PSDBAR"_JJ)=^("BAR"_JJ)
+3 IF PSDBAR1]""
IF PSDBAR0]""
SET PSDPRT=1
+4 SET PSDCNT=1
+5 IF ANS="R"
SET PSD1=""
FOR
SET PSD1=$ORDER(PSD1(PSD1))
IF PSD1=""
QUIT
DO LOOP
+6 IF ANS="R"
GOTO PRINT
+7 IF ANS="N"
IF $DATA(PSDG)
FOR PSD=0:0
SET PSD=$ORDER(PSDG(PSD))
IF 'PSD
QUIT
FOR PSDN=0:0
SET PSDN=$ORDER(^PSI(58.2,PSD,3,PSDN))
IF 'PSDN
QUIT
IF $DATA(^PSD(58.8,PSDN,0))
IF '$PIECE(^(0),"^",7)
IF $PIECE(^(0),"^",3)=+PSDSITE
SET NAOU(PSDN)=""
SET CNT=CNT+1
+8 IF ANS="N"
IF $DATA(ALL)
FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.8,PSD))
IF 'PSD
QUIT
IF $DATA(^PSD(58.8,PSD,0))
IF $PIECE(^(0),"^",2)="N"
IF $PIECE(^(0),"^",3)=+PSDSITE
SET NAOU(+PSD)=""
+9 SET STAT=3
+10 FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.81,"AD",STAT,PSD))
IF 'PSD
QUIT
FOR PSDJ=0:0
SET PSDJ=$ORDER(^PSD(58.81,"AD",STAT,PSD,PSDJ))
IF 'PSDJ
QUIT
DO SET1
PRINT ;print labels
+1 SET (PSD,PSDOUT)=""
FOR
SET PSD=$ORDER(^TMP("PSDLBL",$JOB,PSD))
IF PSD=""!(PSDOUT)
QUIT
Begin DoDot:1
+2 SET PSD(1)=$GET(^TMP("PSDLBL",$JOB,PSD))
+3 WRITE !,$PIECE(PSD(1),U,2)
+4 IF $DATA(PSDPRT)
WRITE !,@PSDBAR1,$PIECE(PSD(1),U),@PSDBAR0
+5 WRITE $PIECE(PSD(1),U)," ",$PIECE(PSD(1),U,3),!
End DoDot:1
DONE IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST,1,2)="C-"
IF 'PSDOUT
WRITE !
KILL DIR,DIRUT
SET DIR(0)="EA"
SET DIR("A")="END OF REPORT! Press <RET> to return to the menu"
DO ^DIR
KILL DIR
END ;kill variables and exit
+1 KILL %,%DT,%H,%I,%ZIS,ALL,ANS,CNT,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DRUG,DTOUT,DUOUT,JJ,JLP1,LIQ,NAOU,NAOUN,NODE,OK
+2 KILL POP,PSD,PSD1,PSD2,PSDA,PSDBAR0,PSDBAR1,PSDCNT,PSDEV,PSDG,PSDJ,PSDN,PSDPN,PSDOUT,PSDR,PSDRG,PSDPRT,PSDRN,PSDS,PSDSN,PSDT,PSDX1,PSDX2
+3 KILL SEL,STAT,TEMP,TEST,TEXT,X,Y,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
+4 KILL ^TMP("PSDLBL",$JOB)
+5 DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+6 QUIT
LOOP SET PSDPN=$PIECE(PSD1(PSD1),",",PSDCNT)
SET PSDCNT=PSDCNT+1
IF PSDPN=""
SET PSDCNT=1
QUIT
+1 FOR PSDJ=0:0
SET PSDJ=$ORDER(^PSD(58.81,"D",PSDPN,PSDJ))
IF 'PSDJ
QUIT
DO SET1
+2 GOTO LOOP
+3 QUIT
PRINT1 ;prints labels
+1 WRITE !
FOR PSDX1=0:1:PSDCNT-1
WRITE ?PSDX1*33+1,$EXTRACT(TEMP(PSDX1+1),1,30)
+2 IF $DATA(PSDPRT)
WRITE !!
FOR PSDX1=1:1:PSDCNT
WRITE @PSDBAR1,$PIECE(TEST(PSDX1)," "),@PSDBAR0
+3 WRITE !
FOR PSDX1=0:1:PSDCNT-1
WRITE ?PSDX1*32+3,TEST(PSDX1+1)
+4 WRITE !!
+5 SET PSDCNT=0
SET PSDX2=PSDX2+1
IF PSDX2=11
SET PSDX2=1
+6 QUIT
SET1 ;sets disp info
+1 IF '$DATA(^PSD(58.81,+PSDJ,0))
QUIT
IF $PIECE($GET(^PSD(58.81,+PSDJ,"CS")),"^",5)
QUIT
SET NODE=^PSD(58.81,+PSDJ,0)
IF +$PIECE(NODE,"^",3)'=+$GET(PSDS)
QUIT
+2 IF ANS="N"
IF '$DATA(NAOU(+PSD))
QUIT
SET PSDPN=$PIECE(NODE,"^",17)
IF PSDPN']""
QUIT
+3 IF ANS="R"
SET STAT=+$PIECE(NODE,"^",11)
IF STAT'=3
QUIT
+4 SET NAOU=+$PIECE(NODE,"^",18)
IF 'NAOU
QUIT
SET NAOUN=$PIECE($GET(^PSD(58.8,+NAOU,0)),"^")
+5 SET PSDR=+$PIECE(NODE,"^",5)
IF 'PSDR
QUIT
+6 SET PSDA=+$PIECE(NODE,"^",20)
IF 'PSDA
QUIT
+7 SET PSDN=$PIECE($GET(^PSDRUG(+PSDR,0)),"^")
+8 SET TEXT(PSDR)=PSDN_"^"_NAOUN
SET ;sets ^tmp
+1 SET ^TMP("PSDLBL",$JOB,PSDPN)=PSDPN_"^"_$PIECE(TEXT(PSDR),"^")_"^"_$EXTRACT($PIECE(TEXT(PSDR),"^",2),1,12)
DIE ;update label printed
+1 IF 'PSDJ
QUIT
+2 KILL DA,DIE,DR
SET DA=+PSDJ
SET DIE=58.81
SET DR="104////"_PSDT
DO ^DIE
KILL DA,DIE,DR
+3 QUIT