PSDGSRV ;BIR/JPW-Review and Complete Green Sheet ; 6 July 94
;;3.0; CONTROLLED SUBSTANCES ;**28,30,71**;13 Feb 97;Build 29
;References to ^PSDRUG( are covered by DBIA221
;Reference to PSD(58.8 supported by DBIA # 2711
;Reference to PSD(58.81 supported by DBIA # 2808
;Reference to VA(200 supported by DBIA # 10060
I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
S OK=$S($D(^XUSEC("PSJ RPHARM",DUZ)):1,$D(^XUSEC("PSJ PHARM TECH",DUZ)):1,$D(^XUSEC("PSD TECH ADV",DUZ)):1,1:0)
I 'OK W $C(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to complete",!,?12,"Green Sheets. PSJ RPHARM, PSJ PHARM TECH or PSD TECH ADV security",!?12,"key required.",! K OK Q
I $P($G(^VA(200,DUZ,20)),U,4)']"" N XQH S XQH="PSD ESIG" D EN^XQH Q
N X,X1 D SIG^XUSESIG Q:X1=""
ASKD ;ask disp location
S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
G:$P(PSDSITE,U,5) GS
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: ",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
GS ;select green sheet #
W !!,"Complete a Green Sheet" S PSDUZ=DUZ,PSDUZN=$P($G(^VA(200,PSDUZ,0)),"^")
W ! K DA,DIC S DIC("A")="Select the Green Sheet #: ",DIC("S")="I $P(^(0),""^"",3)=+PSDS,$P(^(0),""^"",11)<10!($P(^(0),U,11)=13)!($P(^(0),U,11)=12)",DIC=58.81,DIC(0)="QEASZ",D="D"
D IX^DIC K DIC G:Y<0 END S PSDA=+Y,NODE=Y(0)
S STAT=+$P(NODE,"^",11),PSDPN=$P(NODE,"^",17),STATN="" I STAT S STATN=$P($G(^PSD(58.82,STAT,0)),"^")
I (STAT<4)!(STAT>8)!(STAT=7)&(STAT'=13)&(STAT'=12) W !!,"This order has a status of "_$S(STATN]"":STATN,1:"UNKNOWN")_".",! D MSG G END
I STAT=4 D QUES G:NOK GS
S ORD=+$P(NODE,"^",20),NAOU=+$P(NODE,"^",18),PSDR=+$P(NODE,"^",5),PSDRN=$P($G(^PSDRUG(PSDR,0)),"^"),(COMP,OCOMP)=+$P(NODE,"^",12),QTY=+$P(NODE,"^",6)
S CPBY=+$P($G(^PSD(58.81,PSDA,1)),"^",14)
I $D(^PSD(58.81,PSDA,4)),+$P(^(4),"^",3) S QTY=$P(^(4),"^",3)
S NBKU=$P($G(^PSD(58.8,+PSDS,1,+PSDR,0)),"^",8)
START ;start processing
S PSDOUT=0
W ! K DA,DIC S DIC=58.83,DIC(0)="QEA",DIC("A")="Select Completion Status: " S:COMP DIC("B")=COMP S:'$D(^XUSEC("PSJ RPHARM",PSDUZ))&'$D(^XUSEC("PSD TECH ADV",PSDUZ)) DIC("S")="I $S(Y=2:0,Y=3:0,1:1)"
D ^DIC K DIC I Y<0 G END
S COMP=+Y,CSTAT=$S(COMP=1:7,COMP=2:7,COMP=3:7,1:8)
;perpetual inventory?
S:$G(COMP)=1&($P($G(^PSD(58.8,$G(NAOU),2)),U,5))&('$P($G(^PSD(58.8,+PSDS,1,+PSDR,7)),U,3)) CSTAT=13
K DA,DIR,DIRUT S DIR(0)="Y",DIR("A")="Is this OK",DIR("?",1)="Answer 'YES' to update the status",DIR("?")="or 'NO' to select another status."
S DIR("B")="YES" D ^DIR K DIR G:$D(DIRUT) END I 'Y G START
I (COMP=3)!(COMP=2) G ^PSDGSRV1
UPDATE ;up 58.81
W !!,"Accessing Green Sheet information...",!
D NOW^%DTC S (RECDT,Y)=+%
;
;PSD*3*30 (DAVE B) added next part to reset global if user
;up-arrows or times out.
S PSD10=$P($G(^PSD(58.81,PSDA,0)),"^",11) ;Order Status
S PSD11=$P($G(^PSD(58.81,PSDA,0)),"^",12) ;Completion Status
S NURSE=$P($G(^PSD(58.81,PSDA,1)),"^",10)
K DA,DIE,DR S DA=PSDA,DIE=58.81,DR="I NURSE S Y=22;29;22////"_+$E(RECDT,1,12)_";33////"_PSDUZ_";10////"_CSTAT_";11////"_COMP_";I X'=6 S Y=""@1"";72;@1"
D ^DIE K DA,DIE,DR S PSDDT=$P($G(^PSD(58.81,PSDA,0)),"^",19)
I $D(Y)!$D(DTOUT) W $C(7),!!,"*** THIS GREEN SHEET HAS NOT BEEN COMPLETED ***",!!,"The status remains "_STATN,! D S PSDOUT=1 G END
.;PSD*3*28 (Dave B. 19jun00) If up-arrowed on a referred, remove
.;completion status that was set in PSD(58.8
.K DR S DIE=58.81,DA=PSDA,DR="I NURSE S Y=22///@"_";29///@"_";33///@"_";10///"_$S($G(PSD10)'="":$G(PSD10),1:"@")_";11///"_$S($G(PSD11)'="":$G(PSD11),1:"@") D ^DIE
ORDER ;update drug balance & order info in 58.8
W !!,"Updating your records now..."
K DA,DIE,DR S DA=ORD,DA(1)=PSDR,DA(2)=NAOU,DIE="^PSD(58.8,"_DA(2)_",1,"_DA(1)_",3,",DR="10////"_CSTAT_";11////"_COMP_";12////"_PSDDT D ^DIE K DA,DIE,DR
I STAT=8 W "completion log..." S TYPE=4 D ^PSDCOR3
W "done.",!!
S STAT=$P($G(^PSD(58.81,PSDA,0)),"^",11) W ?2,"*** The status of your Green Sheet #"_PSDPN_" *** ",!
S CSTAT=$P($G(^PSD(58.81,PSDA,0)),"^",12) W ?6,$S($P($G(^PSD(58.82,STAT,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN"),!,?6,$P($G(^PSD(58.83,CSTAT,0)),"^")
G GS
END K %,%DT,%H,%I,C,COMP,CPBY,CSTAT,D,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT
K NAOU,NBKU,NODE,NOK,NURSE,OCOMP,OK,ORD,PSDA,PSDDT,PSDEV,PSDOUT,PSDPN,PSDR,PSDRN,PSDS,PSDSN,PSDUZ,PSDUZN,QTY,RECD,RECDT,STAT,STATN,SUB,TYPE,X,Y
Q
QUES ;ask ok if still active
S NOK=0
W ! K DA,DIR,DIRUT S DIR(0)="Y",DIR("A",1)="This Green Sheet is still ACTIVE on the NAOU.",DIR("A")="Do you want to continue"
S DIR("?",1)="Answer 'YES' to continue completing this Green Sheet",DIR("?")="or 'NO' to abort processing and select another Green Sheet."
D ^DIR K DIR I $D(DIRUT) S NOK=1 G MSG
Q:Y
I 'Y S NOK=1
MSG W !!,"** No action taken. **",!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDGSRV 4953 printed Dec 13, 2024@01:46:16 Page 2
PSDGSRV ;BIR/JPW-Review and Complete Green Sheet ; 6 July 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;**28,30,71**;13 Feb 97;Build 29
+2 ;References to ^PSDRUG( are covered by DBIA221
+3 ;Reference to PSD(58.8 supported by DBIA # 2711
+4 ;Reference to PSD(58.81 supported by DBIA # 2808
+5 ;Reference to VA(200 supported by DBIA # 10060
+6 IF '$DATA(PSDSITE)
DO ^PSDSET
if '$DATA(PSDSITE)
QUIT
+7 SET OK=$SELECT($DATA(^XUSEC("PSJ RPHARM",DUZ)):1,$DATA(^XUSEC("PSJ PHARM TECH",DUZ)):1,$DATA(^XUSEC("PSD TECH ADV",DUZ)):1,1:0)
+8 IF 'OK
WRITE $CHAR(7),!!,?9,"** Please contact your Pharmacy Coordinator for access to complete",!,?12,"Green Sheets. PSJ RPHARM, PSJ PHARM TECH or PSD TECH ADV security",!?12,"key required.",!
KILL OK
QUIT
+9 IF $PIECE($GET(^VA(200,DUZ,20)),U,4)']""
NEW XQH
SET XQH="PSD ESIG"
DO EN^XQH
QUIT
+10 NEW X,X1
DO SIG^XUSESIG
if X1=""
QUIT
ASKD ;ask disp location
+1 SET PSDS=$PIECE(PSDSITE,U,3)
SET PSDSN=$PIECE(PSDSITE,U,4)
+2 if $PIECE(PSDSITE,U,5)
GOTO GS
+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: "
SET DIC("B")=PSDSN
+5 DO ^DIC
KILL DIC
if Y<0
GOTO END
+6 SET PSDS=+Y
SET PSDSN=$PIECE(Y,"^",2)
SET $PIECE(PSDSITE,U,3)=+Y
SET $PIECE(PSDSITE,U,4)=PSDSN
GS ;select green sheet #
+1 WRITE !!,"Complete a Green Sheet"
SET PSDUZ=DUZ
SET PSDUZN=$PIECE($GET(^VA(200,PSDUZ,0)),"^")
+2 WRITE !
KILL DA,DIC
SET DIC("A")="Select the Green Sheet #: "
SET DIC("S")="I $P(^(0),""^"",3)=+PSDS,$P(^(0),""^"",11)<10!($P(^(0),U,11)=13)!($P(^(0),U,11)=12)"
SET DIC=58.81
SET DIC(0)="QEASZ"
SET D="D"
+3 DO IX^DIC
KILL DIC
if Y<0
GOTO END
SET PSDA=+Y
SET NODE=Y(0)
+4 SET STAT=+$PIECE(NODE,"^",11)
SET PSDPN=$PIECE(NODE,"^",17)
SET STATN=""
IF STAT
SET STATN=$PIECE($GET(^PSD(58.82,STAT,0)),"^")
+5 IF (STAT<4)!(STAT>8)!(STAT=7)&(STAT'=13)&(STAT'=12)
WRITE !!,"This order has a status of "_$SELECT(STATN]"":STATN,1:"UNKNOWN")_".",!
DO MSG
GOTO END
+6 IF STAT=4
DO QUES
if NOK
GOTO GS
+7 SET ORD=+$PIECE(NODE,"^",20)
SET NAOU=+$PIECE(NODE,"^",18)
SET PSDR=+$PIECE(NODE,"^",5)
SET PSDRN=$PIECE($GET(^PSDRUG(PSDR,0)),"^")
SET (COMP,OCOMP)=+$PIECE(NODE,"^",12)
SET QTY=+$PIECE(NODE,"^",6)
+8 SET CPBY=+$PIECE($GET(^PSD(58.81,PSDA,1)),"^",14)
+9 IF $DATA(^PSD(58.81,PSDA,4))
IF +$PIECE(^(4),"^",3)
SET QTY=$PIECE(^(4),"^",3)
+10 SET NBKU=$PIECE($GET(^PSD(58.8,+PSDS,1,+PSDR,0)),"^",8)
START ;start processing
+1 SET PSDOUT=0
+2 WRITE !
KILL DA,DIC
SET DIC=58.83
SET DIC(0)="QEA"
SET DIC("A")="Select Completion Status: "
if COMP
SET DIC("B")=COMP
if '$DATA(^XUSEC("PSJ RPHARM",PSDUZ))&'$DATA(^XUSEC("PSD TECH ADV",PSDUZ))
SET DIC("S")="I $S(Y=2:0,Y=3:0,1:1)"
+3 DO ^DIC
KILL DIC
IF Y<0
GOTO END
+4 SET COMP=+Y
SET CSTAT=$SELECT(COMP=1:7,COMP=2:7,COMP=3:7,1:8)
+5 ;perpetual inventory?
+6 if $GET(COMP)=1&($PIECE($GET(^PSD(58.8,$GET(NAOU),2)),U,5))&('$PIECE($GET(^PSD(58.8,+PSDS,1,+PSDR,7)),U,3))
SET CSTAT=13
+7 KILL DA,DIR,DIRUT
SET DIR(0)="Y"
SET DIR("A")="Is this OK"
SET DIR("?",1)="Answer 'YES' to update the status"
SET DIR("?")="or 'NO' to select another status."
+8 SET DIR("B")="YES"
DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO END
IF 'Y
GOTO START
+9 IF (COMP=3)!(COMP=2)
GOTO ^PSDGSRV1
UPDATE ;up 58.81
+1 WRITE !!,"Accessing Green Sheet information...",!
+2 DO NOW^%DTC
SET (RECDT,Y)=+%
+3 ;
+4 ;PSD*3*30 (DAVE B) added next part to reset global if user
+5 ;up-arrows or times out.
+6 ;Order Status
SET PSD10=$PIECE($GET(^PSD(58.81,PSDA,0)),"^",11)
+7 ;Completion Status
SET PSD11=$PIECE($GET(^PSD(58.81,PSDA,0)),"^",12)
+8 SET NURSE=$PIECE($GET(^PSD(58.81,PSDA,1)),"^",10)
+9 KILL DA,DIE,DR
SET DA=PSDA
SET DIE=58.81
SET DR="I NURSE S Y=22;29;22////"_+$EXTRACT(RECDT,1,12)_";33////"_PSDUZ_";10////"_CSTAT_";11////"_COMP_";I X'=6 S Y=""@1"";72;@1"
+10 DO ^DIE
KILL DA,DIE,DR
SET PSDDT=$PIECE($GET(^PSD(58.81,PSDA,0)),"^",19)
+11 IF $DATA(Y)!$DATA(DTOUT)
WRITE $CHAR(7),!!,"*** THIS GREEN SHEET HAS NOT BEEN COMPLETED ***",!!,"The status remains "_STATN,!
Begin DoDot:1
+12 ;PSD*3*28 (Dave B. 19jun00) If up-arrowed on a referred, remove
+13 ;completion status that was set in PSD(58.8
+14 KILL DR
SET DIE=58.81
SET DA=PSDA
SET DR="I NURSE S Y=22///@"_";29///@"_";33///@"_";10///"_$SELECT($GET(PSD10)'="":$GET(PSD10),1:"@")_";11///"_$SELECT($GET(PSD11)'="":$GET(PSD11),1:"@")
DO ^DIE
End DoDot:1
SET PSDOUT=1
GOTO END
ORDER ;update drug balance & order info in 58.8
+1 WRITE !!,"Updating your records now..."
+2 KILL DA,DIE,DR
SET DA=ORD
SET DA(1)=PSDR
SET DA(2)=NAOU
SET DIE="^PSD(58.8,"_DA(2)_",1,"_DA(1)_",3,"
SET DR="10////"_CSTAT_";11////"_COMP_";12////"_PSDDT
DO ^DIE
KILL DA,DIE,DR
+3 IF STAT=8
WRITE "completion log..."
SET TYPE=4
DO ^PSDCOR3
+4 WRITE "done.",!!
+5 SET STAT=$PIECE($GET(^PSD(58.81,PSDA,0)),"^",11)
WRITE ?2,"*** The status of your Green Sheet #"_PSDPN_" *** ",!
+6 SET CSTAT=$PIECE($GET(^PSD(58.81,PSDA,0)),"^",12)
WRITE ?6,$SELECT($PIECE($GET(^PSD(58.82,STAT,0)),"^")]"":$PIECE(^(0),"^"),1:"UNKNOWN"),!,?6,$PIECE($GET(^PSD(58.83,CSTAT,0)),"^")
+7 GOTO GS
END KILL %,%DT,%H,%I,C,COMP,CPBY,CSTAT,D,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT
+1 KILL NAOU,NBKU,NODE,NOK,NURSE,OCOMP,OK,ORD,PSDA,PSDDT,PSDEV,PSDOUT,PSDPN,PSDR,PSDRN,PSDS,PSDSN,PSDUZ,PSDUZN,QTY,RECD,RECDT,STAT,STATN,SUB,TYPE,X,Y
+2 QUIT
QUES ;ask ok if still active
+1 SET NOK=0
+2 WRITE !
KILL DA,DIR,DIRUT
SET DIR(0)="Y"
SET DIR("A",1)="This Green Sheet is still ACTIVE on the NAOU."
SET DIR("A")="Do you want to continue"
+3 SET DIR("?",1)="Answer 'YES' to continue completing this Green Sheet"
SET DIR("?")="or 'NO' to abort processing and select another Green Sheet."
+4 DO ^DIR
KILL DIR
IF $DATA(DIRUT)
SET NOK=1
GOTO MSG
+5 if Y
QUIT
+6 IF 'Y
SET NOK=1
MSG WRITE !!,"** No action taken. **",!
+1 QUIT