PSDCRP ;BIR/JPW-Green Sheet Discrepancy Report ; 29 Aug 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"review this narcotics report.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",! K OK Q
ASKD ;ask dispensing location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) ASKN
K DIC,DA S DIC=58.8,DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
S DIC("A")="Select Primary Dispensing Site: "
S DIC("B")=PSDSN
D ^DIC K DIC G:Y<0 END
S PSDS=+Y,PSDSN=$P(Y,"^",2),$P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
ASKN ;ask NAOU(s)
W !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
K DA,DIC
F S DIC=58.8,DIC("A")="Select NAOU: ",DIC(0)="QEA",DIC("S")="I $P(^(0),""^"",2)=""N"",$P(^(0),""^"",4)=+PSDS" D ^DIC K DIC Q:Y<0 S NAOU(+Y)=""
I '$D(NAOU)&(X'="^ALL") G END
I X="^ALL" F PSD=0:0 S PSD=$O(^PSD(58.8,PSD)) Q:'PSD I $P($G(^PSD(58.8,PSD,0)),"^",2)="N",$P($G(^(0)),"^",4)=+PSDS S NAOU(PSD)=""
DEV ;ask device and queue info
W !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")=PSDEV 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^PSDCRP",ZTDESC="CS Green Sheet Discrep Report" S ZTSAVE("PSDS")="" S:$D(NAOU) ZTSAVE("NAOU(")="" D ^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
START ;compile data
K ^TMP("PSDCRP",$J)
F PSD=0:0 S PSD=$O(NAOU(PSD)) Q:'PSD F STAT=3.99:0 S STAT=$O(^PSD(58.81,"AG",STAT)) Q:'STAT!(STAT>6) F PSDA=0:0 S PSDA=$O(^PSD(58.81,"AG",STAT,PSD,PSDA)) Q:'PSDA I $D(^PSD(58.81,PSDA,0)),$P(^(0),"^",3)=+PSDS D
.S NODE=^PSD(58.81,PSDA,0),PSDPN=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN"),STATN=$P($G(^PSD(58.83,+STAT,0)),"^")
.S NAOUN=$S($P($G(^PSD(58.8,PSD,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSD) I NAOUN'="UNKNOWN" S NAOUN=$E(NAOUN,1,10)
.S DRUG=+$P(NODE,"^",5),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_DRUG)
.S PHARM=$P($G(^PSD(58.81,PSDA,1)),"^",14),PHARMN=$S($P($G(^VA(200,+PHARM,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN") I PHARMN'="UNKNOWN" S PHARMN=$P(PHARMN,",")_","_$E($P(PHARMN,",",2))
.S NURS=$P($G(^PSD(58.81,PSDA,1)),"^",10),NURSN=$S($P($G(^VA(200,+NURS,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN") I NURSN'="UNKNOWN" S NURSN=$P(NURSN,",")_","_$E($P(NURSN,",",2))
.S REAS=$P($G(^PSD(58.81,PSDA,1)),"^",15)
.S PSDST=$P(NODE,"^",19) I PSDST S Y=PSDST X ^DD("DD") S PSDST=Y
.S ^TMP("PSDCRP",$J,NAOUN,PSDPN,PSDA)=DRUGN_"^"_STATN_"^"_PHARMN_"^"_NURSN_"^"_PSDST_"^"_REAS
PRINT ;print comp stat discrep report
D NOW^%DTC S Y=X X ^DD("DD") S RPDT=Y
S (PG,PSDOUT)=0
K LN S $P(LN,"-",132)="" I '$D(^TMP("PSDCRP",$J)) D HDR W !!,?40,"**** NO PENDING GREEN SHEET DISCREPANCIES ****",! G DONE
S PSD="" F S PSD=$O(^TMP("PSDCRP",$J,PSD)) Q:PSD=""!(PSDOUT) D HDR W !,?2,"=> ",PSD,! S NUM="" F S NUM=$O(^TMP("PSDCRP",$J,PSD,NUM)) Q:NUM=""!(PSDOUT) D
.F PSDA=0:0 S PSDA=$O(^TMP("PSDCRP",$J,PSD,NUM,PSDA)) Q:'PSDA!(PSDOUT) D
..I $Y+8>IOSL D HDR Q:PSDOUT W !,?2,"=> ",PSD,!
..S NODE=^TMP("PSDCRP",$J,PSD,NUM,PSDA) W !,NUM,?15,$P(NODE,"^"),?58,$P(NODE,"^",5),?80,$P(NODE,"^",2)
..W !!,?15,"*RPh: ",$P(NODE,"^",3),?58,"*Comp. by Nurse: ",$P(NODE,"^",4),!
..I $P(NODE,"^",6)]"" W ?25,"**Reason Referred: ",$P(NODE,"^",6),!
DONE I $E(IOST)'="C" W @IOF
I $E(IOST,1,2)="C-",'PSDOUT 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 %,%DT,%H,%I,%ZIS,C,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DRUG,DRUGN,DUOUT,LN,NAOU,NAOUN,NODE,NUM,NURS,NURSN
K OK,PG,PHARM,PHARMN,POP,PSD,PSDA,PSDEV,PSDOUT,PSDPN,PSDS,PSDSN,PSDST,REAS,RPDT,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
K ^TMP("PSDCRP",$J) D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
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 !,?45,"Green Sheet Discrepancies Report",?115,"Page: ",PG,!,?48,"Date Printed: ",RPDT,!
W !,?2,"=> NAOU",!,"DISP #",?15,"DRUG",?58,"DATE POSTED",?80,"COMPLETION STATUS"
W !,LN,!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDCRP 4495 printed Dec 13, 2024@01:45:26 Page 2
PSDCRP ;BIR/JPW-Green Sheet Discrepancy Report ; 29 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 RPHARM",DUZ)):1,$DATA(^XUSEC("PSJ PHARM TECH",DUZ)):1,1:0)
+4 IF 'OK
WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to",!,?12,"review this narcotics report.",!!,"PSJ RPHARM or PSJ PHARM TECH security key required.",!
KILL OK
QUIT
ASKD ;ask dispensing location
+1 SET PSDS=$PIECE(PSDSITE,U,3)
SET PSDSN=$PIECE(PSDSITE,U,4)
+2 if $PIECE(PSDSITE,U,5)
GOTO ASKN
+3 KILL DIC,DA
SET DIC=58.8
SET DIC(0)="QEAZ"
SET DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
+4 SET DIC("A")="Select Primary Dispensing Site: "
+5 SET DIC("B")=PSDSN
+6 DO ^DIC
KILL DIC
if Y<0
GOTO END
+7 SET PSDS=+Y
SET PSDSN=$PIECE(Y,"^",2)
SET $PIECE(PSDSITE,U,3)=+Y
SET $PIECE(PSDSITE,U,4)=PSDSN
ASKN ;ask NAOU(s)
+1 WRITE !!,?5,"You may select a single NAOU, several NAOUs,",!,?5,"or enter ^ALL to select all NAOUs.",!!
+2 KILL DA,DIC
+3 FOR
SET DIC=58.8
SET DIC("A")="Select NAOU: "
SET DIC(0)="QEA"
SET DIC("S")="I $P(^(0),""^"",2)=""N"",$P(^(0),""^"",4)=+PSDS"
DO ^DIC
KILL DIC
if Y<0
QUIT
SET NAOU(+Y)=""
+4 IF '$DATA(NAOU)&(X'="^ALL")
GOTO END
+5 IF X="^ALL"
FOR PSD=0:0
SET PSD=$ORDER(^PSD(58.8,PSD))
if 'PSD
QUIT
IF $PIECE($GET(^PSD(58.8,PSD,0)),"^",2)="N"
IF $PIECE($GET(^(0)),"^",4)=+PSDS
SET NAOU(PSD)=""
DEV ;ask device and queue info
+1 WRITE !!,"This report is designed for a 132 column format.",!,"You may queue this report to print at a later time.",!!
+2 SET Y=$PIECE($GET(^PSD(58.8,+PSDS,2)),"^",9)
SET C=$PIECE(^DD(58.8,24,0),"^",2)
DO Y^DIQ
SET PSDEV=Y
+3 KILL %ZIS,IOP,IO("Q"),POP
SET %ZIS="QM"
SET %ZIS("B")=PSDEV
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO END
+4 IF $DATA(IO("Q"))
KILL IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="START^PSDCRP"
SET ZTDESC="CS Green Sheet Discrep Report"
SET ZTSAVE("PSDS")=""
if $DATA(NAOU)
SET ZTSAVE("NAOU(")=""
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+5 USE IO
START ;compile data
+1 KILL ^TMP("PSDCRP",$JOB)
+2 FOR PSD=0:0
SET PSD=$ORDER(NAOU(PSD))
if 'PSD
QUIT
FOR STAT=3.99:0
SET STAT=$ORDER(^PSD(58.81,"AG",STAT))
if 'STAT!(STAT>6)
QUIT
FOR PSDA=0:0
SET PSDA=$ORDER(^PSD(58.81,"AG",STAT,PSD,PSDA))
if 'PSDA
QUIT
IF $DATA(^PSD(58.81,PSDA,0))
IF $PIECE(^(0),"^",3)=+PSDS
Begin DoDot:1
+3 SET NODE=^PSD(58.81,PSDA,0)
SET PSDPN=$SELECT($PIECE(NODE,"^",17)]"":$PIECE(NODE,"^",17),1:"UNKNOWN")
SET STATN=$PIECE($GET(^PSD(58.83,+STAT,0)),"^")
+4 SET NAOUN=$SELECT($PIECE($GET(^PSD(58.8,PSD,0)),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_PSD)
IF NAOUN'="UNKNOWN"
SET NAOUN=$EXTRACT(NAOUN,1,10)
+5 SET DRUG=+$PIECE(NODE,"^",5)
SET DRUGN=$SELECT($PIECE($GET(^PSDRUG(DRUG,0)),"^")]"":$PIECE(^(0),"^"),1:"ZZ/"_DRUG)
+6 SET PHARM=$PIECE($GET(^PSD(58.81,PSDA,1)),"^",14)
SET PHARMN=$SELECT($PIECE($GET(^VA(200,+PHARM,0)),"^")]"":$PIECE(^(0),"^"),1:"UNKNOWN")
IF PHARMN'="UNKNOWN"
SET PHARMN=$PIECE(PHARMN,",")_","_$EXTRACT($PIECE(PHARMN,",",2))
+7 SET NURS=$PIECE($GET(^PSD(58.81,PSDA,1)),"^",10)
SET NURSN=$SELECT($PIECE($GET(^VA(200,+NURS,0)),"^")]"":$PIECE(^(0),"^"),1:"UNKNOWN")
IF NURSN'="UNKNOWN"
SET NURSN=$PIECE(NURSN,",")_","_$EXTRACT($PIECE(NURSN,",",2))
+8 SET REAS=$PIECE($GET(^PSD(58.81,PSDA,1)),"^",15)
+9 SET PSDST=$PIECE(NODE,"^",19)
IF PSDST
SET Y=PSDST
XECUTE ^DD("DD")
SET PSDST=Y
+10 SET ^TMP("PSDCRP",$JOB,NAOUN,PSDPN,PSDA)=DRUGN_"^"_STATN_"^"_PHARMN_"^"_NURSN_"^"_PSDST_"^"_REAS
End DoDot:1
PRINT ;print comp stat discrep report
+1 DO NOW^%DTC
SET Y=X
XECUTE ^DD("DD")
SET RPDT=Y
+2 SET (PG,PSDOUT)=0
+3 KILL LN
SET $PIECE(LN,"-",132)=""
IF '$DATA(^TMP("PSDCRP",$JOB))
DO HDR
WRITE !!,?40,"**** NO PENDING GREEN SHEET DISCREPANCIES ****",!
GOTO DONE
+4 SET PSD=""
FOR
SET PSD=$ORDER(^TMP("PSDCRP",$JOB,PSD))
if PSD=""!(PSDOUT)
QUIT
DO HDR
WRITE !,?2,"=> ",PSD,!
SET NUM=""
FOR
SET NUM=$ORDER(^TMP("PSDCRP",$JOB,PSD,NUM))
if NUM=""!(PSDOUT)
QUIT
Begin DoDot:1
+5 FOR PSDA=0:0
SET PSDA=$ORDER(^TMP("PSDCRP",$JOB,PSD,NUM,PSDA))
if 'PSDA!(PSDOUT)
QUIT
Begin DoDot:2
+6 IF $Y+8>IOSL
DO HDR
if PSDOUT
QUIT
WRITE !,?2,"=> ",PSD,!
+7 SET NODE=^TMP("PSDCRP",$JOB,PSD,NUM,PSDA)
WRITE !,NUM,?15,$PIECE(NODE,"^"),?58,$PIECE(NODE,"^",5),?80,$PIECE(NODE,"^",2)
+8 WRITE !!,?15,"*RPh: ",$PIECE(NODE,"^",3),?58,"*Comp. by Nurse: ",$PIECE(NODE,"^",4),!
+9 IF $PIECE(NODE,"^",6)]""
WRITE ?25,"**Reason Referred: ",$PIECE(NODE,"^",6),!
End DoDot:2
End DoDot:1
DONE IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST,1,2)="C-"
IF 'PSDOUT
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 ;
+1 KILL %,%DT,%H,%I,%ZIS,C,DA,DIC,DIR,DIROUT,DIRUT,DTOUT,DRUG,DRUGN,DUOUT,LN,NAOU,NAOUN,NODE,NUM,NURS,NURSN
+2 KILL OK,PG,PHARM,PHARMN,POP,PSD,PSDA,PSDEV,PSDOUT,PSDPN,PSDS,PSDSN,PSDST,REAS,RPDT,STAT,STATN,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
+3 KILL ^TMP("PSDCRP",$JOB)
DO ^%ZISC
if $DATA(ZTQUEUED)
SET ZTREQ="@"
+4 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 !,?45,"Green Sheet Discrepancies Report",?115,"Page: ",PG,!,?48,"Date Printed: ",RPDT,!
+3 WRITE !,?2,"=> NAOU",!,"DISP #",?15,"DRUG",?58,"DATE POSTED",?80,"COMPLETION STATUS"
+4 WRITE !,LN,!
+5 QUIT