PSDNSCG ;BIR/JPW-Nurse Shift Check Log GS perpetual; 2 Aug 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
S OK=$S($D(^XUSEC("PSJ RNURSE",DUZ)):1,$D(^XUSEC("PSD NURSE",DUZ)):1,1:0)
I 'OK W $C(7),!!,?9,"** Please contact your Coordinator for access to",!,?12,"print this shift check log.",!!,"PSJ RNURSE or PSD NURSE security key required.",! K OK Q
ASKN ;ask naou
K DA,DIC S DIC=58.8,DIC(0)="QEA",DIC("A")="Select 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)"
D ^DIC K DIC G:Y<0 END S NAOU=+Y,NAOUN=$P(Y,"^",2)
DEV ;ask device and queue info
W !!,"You may queue this report to print at a later time.",!!
K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END
I $D(IO("Q")) K IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDNSCL",ZTDESC="CS Nursing Shift Check Log",(ZTSAVE("NAOU"),ZTSAVE("NAOUN"))="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;loops thru active orders
K ^TMP("PSDNSCL",$J) D NOW^%DTC S Y=+$E(%,1,12) X ^DD("DD") S RPDT=Y
F STAT=2.99:0 S STAT=$O(^PSD(58.8,"AC",STAT)) Q:('STAT)!(STAT>4) D LOOP
S STAT=10 F PSD=0:0 S PSD=$O(^PSD(58.8,"AC",STAT,PSD)) Q:'PSD D LOOP
PRINT ;prints the report
S (PG,PSDOUT)=0
K LN S $P(LN,"-",80)="" I '$D(^TMP("PSDNSCL",$J)) D HDR W !!,?10,"**** NO ACTIVE ORDERS TO REPORT ****",! G DONE
D HDR
S DRUG="" F S DRUG=$O(^TMP("PSDNSCL",$J,DRUG)) Q:DRUG=""!(PSDOUT) W !!,?2,"=> ",DRUG,! S NUM="" F S NUM=$O(^TMP("PSDNSCL",$J,DRUG,NUM)) Q:NUM=""!(PSDOUT) D
.I $Y+8>IOSL D HDR Q:PSDOUT W !!,?2,"=> ",DRUG,!
.S NODE=^TMP("PSDNSCL",$J,DRUG,NUM) W !,NUM,?12,$P(NODE,"^",3),?34,$J($P(NODE,"^",2),6),?45,$P(NODE,"^",4),?55,$P($P(NODE,"^")," ")
.W ! W:$P($G(^DPT(+$P($G(^PSD(58.81,+$O(^PSD(58.81,"D",NUM,0)),9)),U),0)),U)]"" $P($G(^(0)),U)
.W ?50,$S($P(NODE,"^",5)="*":$P($P(NODE,"^")," ",2,99),1:$P($P(NODE,"^"),"-",2)),!
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 K %,%H,%I,%ZIS,ALL,DA,DIC,DIR,DIROUT,DIRUT,DRUG,DRUGN,DTOUT,DUOUT,LN,NAOU,NAOUN,NODE,NUM,OK,ORD
K PG,POP,PSD,PSDOUT,PSDPN,PSDST,PSDT,PSDTR,QTY,REC,REQ,RPDT,RQTY,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDNSCL",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
Q
LOOP ;drug loop
F DRUG=0:0 S DRUG=$O(^PSD(58.8,"AC",STAT,NAOU,DRUG)) Q:'DRUG F ORD=0:0 S ORD=$O(^PSD(58.8,"AC",STAT,NAOU,DRUG,ORD)) Q:'ORD D
.Q:'$D(^PSD(58.8,NAOU,1,DRUG,3,ORD,0)) S NODE=^(0),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"DRUG NAME MISSING")
.S PSDTR=$P(NODE,"^",17) I STAT=10 Q:$D(^PSD(58.81,"AE",PSDTR))
.S STATN=$P($G(^PSD(58.82,STAT,0)),"^"),RQTY=$P(NODE,"^",20),PSDPN=$S($P(NODE,"^",16)]"":$P(NODE,"^",16),1:"UNKNOWN")
.Q:'$P($G(^PSD(58.81,+$O(^PSD(58.81,"D",+PSDPN,0)),"CS")),U,4)
.S REQ=$P(NODE,"^",15) I REQ S Y=REQ X ^DD("DD") S REQ=Y
.S REC=$P(NODE,"^",7),REC=$P($G(^VA(200,+REC,0)),"^"),REC=$E($P(REC,",",2))_$E(REC)
.S ^TMP("PSDNSCL",$J,DRUGN,PSDPN)=STATN_"^"_RQTY_"^"_REQ_"^"_REC_"^"_$S(STAT=10:"*",1:"")
Q
HDR ;header for log
I $E(IOST,1,2)="C-",PG W ! K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
S PG=PG+1 W:$Y @IOF W !,?15,"Nursing Shift Check Log for ",NAOUN,?70,"Page: ",PG,!,?20,RPDT,!
W !,?2,"=> DRUG",!,?18,"DATE",?44,"RECD"
W !,"DISP #",?18,"RECD",?37,"QTY",?45,"BY",?54,"ORDER STATUS"
W !,LN,!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDNSCG 3534 printed Nov 22, 2024@16:57:11 Page 2
PSDNSCG ;BIR/JPW-Nurse Shift Check Log GS perpetual; 2 Aug 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
+2 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
QUIT
+3 SET OK=$SELECT($DATA(^XUSEC("PSJ RNURSE",DUZ)):1,$DATA(^XUSEC("PSD NURSE",DUZ)):1,1:0)
+4 IF 'OK
WRITE $CHAR(7),!!,?9,"** Please contact your Coordinator for access to",!,?12,"print this shift check log.",!!,"PSJ RNURSE or PSD NURSE security key required.",!
KILL OK
QUIT
ASKN ;ask naou
+1 KILL DA,DIC
SET DIC=58.8
SET DIC(0)="QEA"
SET DIC("A")="Select 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 DO ^DIC
KILL DIC
if Y<0
GOTO END
SET NAOU=+Y
SET NAOUN=$PIECE(Y,"^",2)
DEV ;ask device and queue info
+1 WRITE !!,"You may queue this report to print at a later time.",!!
+2 KILL %ZIS,IOP,IO("Q"),POP
SET %ZIS="QM"
SET %ZIS("B")=""
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO END
+3 IF $DATA(IO("Q"))
KILL IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDNSCL"
SET ZTDESC="CS Nursing Shift Check Log"
SET (ZTSAVE("NAOU"),ZTSAVE("NAOUN"))=""
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+4 USE IO
START ;loops thru active orders
+1 KILL ^TMP("PSDNSCL",$JOB)
DO NOW^%DTC
SET Y=+$EXTRACT(%,1,12)
XECUTE ^DD("DD")
SET RPDT=Y
+2 FOR STAT=2.99:0
SET STAT=$ORDER(^PSD(58.8,"AC",STAT))
if ('STAT)!(STAT>4)
QUIT
DO LOOP
+3 SET STAT=10
FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.8,"AC",STAT,PSD))
if 'PSD
QUIT
DO LOOP
PRINT ;prints the report
+1 SET (PG,PSDOUT)=0
+2 KILL LN
SET $PIECE(LN,"-",80)=""
IF '$DATA(^TMP("PSDNSCL",$JOB))
DO HDR
WRITE !!,?10,"**** NO ACTIVE ORDERS TO REPORT ****",!
GOTO DONE
+3 DO HDR
+4 SET DRUG=""
FOR
SET DRUG=$ORDER(^TMP("PSDNSCL",$JOB,DRUG))
if DRUG=""!(PSDOUT)
QUIT
WRITE !!,?2,"=> ",DRUG,!
SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDNSCL",$JOB,DRUG,NUM))
if NUM=""!(PSDOUT)
QUIT
Begin DoDot:1
+5 IF $Y+8>IOSL
DO HDR
if PSDOUT
QUIT
WRITE !!,?2,"=> ",DRUG,!
+6 SET NODE=^TMP("PSDNSCL",$JOB,DRUG,NUM)
WRITE !,NUM,?12,$PIECE(NODE,"^",3),?34,$JUSTIFY($PIECE(NODE,"^",2),6),?45,$PIECE(NODE,"^",4),?55,$PIECE($PIECE(NODE,"^")," ")
+7 WRITE !
if $PIECE($GET(^DPT(+$PIECE($GET(^PSD(58.81,+$ORDER(^PSD(58.81,"D",NUM,0)),9)),U),0)),U)]""
WRITE $PIECE($GET(^(0)),U)
+8 WRITE ?50,$SELECT($PIECE(NODE,"^",5)="*":$PIECE($PIECE(NODE,"^")," ",2,99),1:$PIECE($PIECE(NODE,"^"),"-",2)),!
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 %,%H,%I,%ZIS,ALL,DA,DIC,DIR,DIROUT,DIRUT,DRUG,DRUGN,DTOUT,DUOUT,LN,NAOU,NAOUN,NODE,NUM,OK,ORD
+1 KILL PG,POP,PSD,PSDOUT,PSDPN,PSDST,PSDT,PSDTR,QTY,REC,REQ,RPDT,RQTY,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
+2 KILL ^TMP("PSDNSCL",$JOB)
DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 QUIT
LOOP ;drug loop
+1 FOR DRUG=0:0
SET DRUG=$ORDER(^PSD(58.8,"AC",STAT,NAOU,DRUG))
if 'DRUG
QUIT
FOR ORD=0:0
SET ORD=$ORDER(^PSD(58.8,"AC",STAT,NAOU,DRUG,ORD))
if 'ORD
QUIT
Begin DoDot:1
+2 if '$DATA(^PSD(58.8,NAOU,1,DRUG,3,ORD,0))
QUIT
SET NODE=^(0)
SET DRUGN=$SELECT($PIECE($GET(^PSDRUG(DRUG,0)),"^")]"":$PIECE(^(0),"^"),1:"DRUG NAME MISSING")
+3 SET PSDTR=$PIECE(NODE,"^",17)
IF STAT=10
if $DATA(^PSD(58.81,"AE",PSDTR))
QUIT
+4 SET STATN=$PIECE($GET(^PSD(58.82,STAT,0)),"^")
SET RQTY=$PIECE(NODE,"^",20)
SET PSDPN=$SELECT($PIECE(NODE,"^",16)]"":$PIECE(NODE,"^",16),1:"UNKNOWN")
+5 if '$PIECE($GET(^PSD(58.81,+$ORDER(^PSD(58.81,"D",+PSDPN,0)),"CS")),U,4)
QUIT
+6 SET REQ=$PIECE(NODE,"^",15)
IF REQ
SET Y=REQ
XECUTE ^DD("DD")
SET REQ=Y
+7 SET REC=$PIECE(NODE,"^",7)
SET REC=$PIECE($GET(^VA(200,+REC,0)),"^")
SET REC=$EXTRACT($PIECE(REC,",",2))_$EXTRACT(REC)
+8 SET ^TMP("PSDNSCL",$JOB,DRUGN,PSDPN)=STATN_"^"_RQTY_"^"_REQ_"^"_REC_"^"_$SELECT(STAT=10:"*",1:"")
End DoDot:1
+9 QUIT
HDR ;header for log
+1 IF $EXTRACT(IOST,1,2)="C-"
IF PG
WRITE !
KILL DA,DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET PSDOUT=1
QUIT
+2 SET PG=PG+1
if $Y
WRITE @IOF
WRITE !,?15,"Nursing Shift Check Log for ",NAOUN,?70,"Page: ",PG,!,?20,RPDT,!
+3 WRITE !,?2,"=> DRUG",!,?18,"DATE",?44,"RECD"
+4 WRITE !,"DISP #",?18,"RECD",?37,"QTY",?45,"BY",?54,"ORDER STATUS"
+5 WRITE !,LN,!
+6 QUIT