PSODIR2 ;IHS/DSD/JCM - rx order entry contd ;29-May-2012 14:44;PLS
;;7.0;OUTPATIENT PHARMACY;**3,9,26,46,124,146,139,152,166,1005,1008,1013,1014,1015**;DEC 1997;Build 62
;External reference to ^DD(52 supported by DBIA 999
;External reference to ^VA(200 supported by DBIA 10060
;External reference to ^%DTC supported by DBIA 10000
;External reference to ^DIC supported by DBIA 10006
;External reference to ^DIR supported by DBIA 10026
;
;---------------------------------------------------------------------
; Modified - IHS/CIA/PLS - 12/29/03 - Line DIR+4 and CLERK+6
; IHS/MSC/PLS - 12/30/2008 - Line FILLDT+11
; 10/31/2011 - Line CLERK+1
; 02/13/2012 - Line FILLDT+7
; 05/22/2012 - Line CLERK+1
EXP(PSODIR) ;
K DIR,DIC
I $G(PSODRUG("EXPIRATION DATE"))]"" S Y=PSODRUG("EXPIRATION DATE") X ^DD("DD") S PSORX("EXPIRATION DATE")=Y
S DIR("A")="EXPIRES",DIR("B")=$S($G(PSORX("EXPIRATION DATE"))]"":PSORX("EXPIRATION DATE"),1:"T+6M")
S DIR(0)="D^NOW::EX"
S DIR("?")="Both the month and date are required."
D DIR G:PSODIR("DFLG")!PSODIR("FIELD") EXPX
S PSODIR("EXPIRATION DATE")=Y
EXPX K X,Y
Q
;
CLINIC(PSODIR) ;
K DIR,DIC S PSODIR("FIELD")=0
S DIR(0)="52,5" S:$G(PSORX("CLINIC"))]"" DIR("B")=PSORX("CLINIC"),DIR("A")="CLINIC"
D ^DIR G:PSODIR("DFLG")!PSODIR("FIELD") CLINICX
I +Y>0 S PSODIR("CLINIC")=+Y,PSORX("CLINIC")=$P(Y,"^",2)
E S (PSORX("CLINIC"),PSODIR("CLINIC"))=""
CLINICX K X,Y,PSOX,DIC
Q
;
MW(PSODIR) ;
K DIR,DIC
S DIR(0)="52,11" S:$G(POERR)&'$D(PSORX("MAIL/WINDOW")) PSORX("MAIL/WINDOW")=$S($P($G(OR0),"^",17)="M":"MAIL",1:"WINDOW")
S DIR("B")=$S($G(PSORX("MAIL/WINDOW"))]"":PSORX("MAIL/WINDOW"),$G(PSOTPBFG)&($G(PSOFROM)="NEW"):"MAIL",1:"WINDOW")
D DIR G:PSODIR("DFLG")!PSODIR("FIELD") MWX
I $G(Y(0))']"" S PSODIR("DFLG")=1 G MWX
S PSODIR("MAIL/WINDOW")=Y,PSORX("MAIL/WINDOW")=Y(0)
I $G(PSORX("EDIT"))]"",PSODIR("MAIL/WINDOW")'="W" K PSODIR("METHOD OF PICK-UP")
MW1 G:PSODIR("MAIL/WINDOW")'="W"!('$P($G(PSOPAR),"^",12)) MWX
S DIR(0)="52,35O"
S:$G(PSORX("METHOD OF PICK-UP"))]"" DIR("B")=PSORX("METHOD OF PICK-UP")
D DIR G:PSODIR("DFLG") MWX
I X[U W !,"Cannot jump to another field ..",! G MW1
S (PSODIR("METHOD OF PICK-UP"),PSORX("METHOD OF PICK-UP"))=Y
MWX K X,Y
Q
;
RMK(PSODIR) ;
RMKEN K DIR,DIC
S DIR(0)="52,12"
S:$G(PSODIR("REMARKS"))]"" DIR("B")=PSODIR("REMARKS")
D DIR G:PSODIR("DFLG") RMKX
I X[U W !,"Cannot jump to another field ..",! G RMKEN
S:$L(X)>0 PSODIR("REMARKS")=X
S:X="@" PSODIR("REMARKS")=""
RMKX K X,Y
Q
;
ISSDT(PSODIR) ;
K DIR,DIC
S DIR("A")="ISSUE DATE",DIR("B")=$S($G(POERR)&($G(PSORX("ISSUE DATE"))']"")&($G(PSODIR("ISSUE DATE"))]""):PSODIR("ISSUE DATE"),$G(PSORX("ISSUE DATE"))]"":PSORX("ISSUE DATE"),1:"TODAY")
I DIR("B") S Y=DIR("B") X ^DD("DD") S DIR("B")=Y
S DIR(0)="52,1"
D DIR G:PSODIR("DFLG")!PSODIR("FIELD") ISSDTX
S (PSODIR("ISSUE DATE"),PSOID)=Y
X ^DD("DD") S (PSORX("ISSUE DATE"),PSODIR("ISSUE DATE"))=Y
ISSDTX K X,Y
Q
;
FILLDT(PSODIR) ;
K DIR,DIC
S:'$G(PSONEW("DAYS SUPPLY")) PSONEW("DAYS SUPPLY")=30,PSONEW("# OF REFILLS")=1
S DIR("A")="FILL DATE",DIR("B")=$S($G(PSORX("FILL DATE"))]"":PSORX("FILL DATE"),1:"TODAY")
S X2=PSONEW("DAYS SUPPLY")*(PSONEW("# OF REFILLS")+1)\1
S X1=$S($G(PSOID):PSOID,1:DT)
;S X2=$S(PSONEW("DAYS SUPPLY")=X2:X2,+$G(PSODIR("CS")):184,1:366)
S X2=$S(+$G(PSODIR("CS")):184,1:366) ;IHS/MSC/PLS - 02/10/2012
;I X2<30 D
;. N % S %=$P($G(PSORX("PATIENT STATUS")),"^"),X2=30
;. S:%?.N %=$P($G(^PS(53,+%,0)),"^") I %["AUTH ABS" S X2=5
D C^%DTC S PSOFDMX=$P(X,".") I DT>X S Y=$S($G(PSOID):PSOID,1:PSORX("ISSUE DATE")) X ^DD("DD") S DIR("B")=Y
;IHS/MSC/PLS - 12/30/2008 - Check for Suspense
;S DIR(0)="D^"_$S($G(PSOID):PSOID,+$G(PSODIR("ISSUE DATE")):PSODIR("ISSUE DATE"),1:DT)_$S($G(DUZ("AG"))="I":":"_DT_":EX",1:":"_PSOFDMX_":EX")
S DIR(0)="D^"_$S($G(PSOID):PSOID,+$G(PSODIR("ISSUE DATE")):PSODIR("ISSUE DATE"),1:DT)_$S($G(DUZ("AG"))="I"&('$P(PSOPAR,U,24)):":"_DT_":EX",1:":"_PSOFDMX_":EX")
S Y=PSOFDMX X ^DD("DD")
S DIR("?",1)="The earliest fill date allowed is determined by the ISSUE DATE,"
S DIR("?",2)="the FILL DATE cannot be before the ISSUE DATE or AFTER the Expiration Date "
S DIR("?")=Y_". Both the month and date are required."
D DIR G:PSODIR("DFLG")!PSODIR("FIELD") FILLDTX
S PSODIR("FILL DATE")=Y
X ^DD("DD") S PSORX("FILL DATE")=Y
FILLDTX K X,Y,PSOFDMX
Q
;
CLERK(PSODIR) ;
;IHS/MSC/PLS - 10/31/2011
;I $G(DUZ("AG"))'="I" D G CLERKX
;IHS/MSC/PLS - 05/22/2012 REMOVED THE DOTTED DO
;D G CLERKX
S PSODIR("CLERK CODE")=$S($G(PSOFDR):$P(OR0,"^",4),1:DUZ),PSORX("CLERK CODE")=$P($G(^VA(200,PSODIR("CLERK CODE"),0)),"^")
K DIR,DIC
S DIR("A")="CLERK",DIR("B")=$S($G(PSORX("CLERK CODE"))]"":PSORX("CLERK CODE"),1:$P($G(^VA(200,DUZ,0)),"^",2)),DIR(0)="52,16"
D DIR G:PSODIR("DFLG")!PSODIR("FIELD") CLERKX
; IHS/CIA/PLS - 01/25/04 - Next line commented out
;S PSODIR("CLERK CODE")=+Y,PSORX("CLERK CODE")=$P(Y,"^")
S PSODIR("CLERK CODE")=+Y,PSORX("CLERK CODE")=$P(Y,"^",2) ; IHS/CIA/PLS - 01/25/04 - Changed to Name from initials
CLERKX Q
;
DIR ;
S PSODIR("FIELD")=0
G:$G(DIR(0))']"" DIRX
D ^DIR K DIR,DIE,DIC,DA I X="^^" S (PSODIR("QFLG"),PSODIR("DFLG"))=1 G DIRX
DIRS ; EP - IHS/CIA/PLS - 12/23/03 - New entry point DIRS added.
I $D(DUOUT)!($D(DTOUT))!($D(DIROUT)),$L($G(X))'>1!(Y="") S PSODIR("DFLG")=1 S:$G(SPEED) PSODIR("QFLG")=1 G DIRX
I $D(DUOUT)!($D(DTOUT)),$G(SPEED) S PSODIR("DFLG")=1 G DIRX
I X[U,$L(X)>1 D JUMP
DIRX K DIRUT,DTOUT,DUOUT,DIROUT,PSOX
Q
;
JUMP ;
I $G(PSOEDIT)!($G(OR0)) S PSODIR("DFLG")=1 Q
S X=$P(X,"^",2),DIC="^DD(52,",DIC(0)="QM" D ^DIC K DIC
I Y=-1 S PSODIR("FIELD")=$G(PSODIR("FLD")) G JUMPX
I $G(PSONEW1)=0 D JUMP^PSONEW1 G JUMPX
I $G(PSONEW3)=0 D JUMP^PSONEW3 G JUMPX
I $G(PSORENW3)=0 D JUMP^PSORENW3 G JUMPX
JUMPX S X="^"_X
Q
;Reset refills when drug changed to a controlled sub
RFRSET ;
N RFN,RFNC
S (RFN,RFNC)=0
F S RFN=$O(^PSRX(+$G(PSODIR("IRXN")),1,RFN)) Q:'RFN S RFNC=RFNC+1
I $D(PSODIR("FIELD")) S PSODIR("FIELD")=0
S PSODIR("# OF REFILLS")=RFNC
S VALMSG="The drug has been changed and no longer allows refills."
W !,VALMSG,!
Q
PSODIR2 ;IHS/DSD/JCM - rx order entry contd ;29-May-2012 14:44;PLS
+1 ;;7.0;OUTPATIENT PHARMACY;**3,9,26,46,124,146,139,152,166,1005,1008,1013,1014,1015**;DEC 1997;Build 62
+2 ;External reference to ^DD(52 supported by DBIA 999
+3 ;External reference to ^VA(200 supported by DBIA 10060
+4 ;External reference to ^%DTC supported by DBIA 10000
+5 ;External reference to ^DIC supported by DBIA 10006
+6 ;External reference to ^DIR supported by DBIA 10026
+7 ;
+8 ;---------------------------------------------------------------------
+9 ; Modified - IHS/CIA/PLS - 12/29/03 - Line DIR+4 and CLERK+6
+10 ; IHS/MSC/PLS - 12/30/2008 - Line FILLDT+11
+11 ; 10/31/2011 - Line CLERK+1
+12 ; 02/13/2012 - Line FILLDT+7
+13 ; 05/22/2012 - Line CLERK+1
EXP(PSODIR) ;
+1 KILL DIR,DIC
+2 IF $GET(PSODRUG("EXPIRATION DATE"))]""
SET Y=PSODRUG("EXPIRATION DATE")
XECUTE ^DD("DD")
SET PSORX("EXPIRATION DATE")=Y
+3 SET DIR("A")="EXPIRES"
SET DIR("B")=$SELECT($GET(PSORX("EXPIRATION DATE"))]"":PSORX("EXPIRATION DATE"),1:"T+6M")
+4 SET DIR(0)="D^NOW::EX"
+5 SET DIR("?")="Both the month and date are required."
+6 DO DIR
IF PSODIR("DFLG")!PSODIR("FIELD")
GOTO EXPX
+7 SET PSODIR("EXPIRATION DATE")=Y
EXPX KILL X,Y
+1 QUIT
+2 ;
CLINIC(PSODIR) ;
+1 KILL DIR,DIC
SET PSODIR("FIELD")=0
+2 SET DIR(0)="52,5"
IF $GET(PSORX("CLINIC"))]""
SET DIR("B")=PSORX("CLINIC")
SET DIR("A")="CLINIC"
+3 DO ^DIR
IF PSODIR("DFLG")!PSODIR("FIELD")
GOTO CLINICX
+4 IF +Y>0
SET PSODIR("CLINIC")=+Y
SET PSORX("CLINIC")=$PIECE(Y,"^",2)
+5 IF '$TEST
SET (PSORX("CLINIC"),PSODIR("CLINIC"))=""
CLINICX KILL X,Y,PSOX,DIC
+1 QUIT
+2 ;
MW(PSODIR) ;
+1 KILL DIR,DIC
+2 SET DIR(0)="52,11"
IF $GET(POERR)&'$DATA(PSORX("MAIL/WINDOW"))
SET PSORX("MAIL/WINDOW")=$SELECT($PIECE($GET(OR0),"^",17)="M":"MAIL",1:"WINDOW")
+3 SET DIR("B")=$SELECT($GET(PSORX("MAIL/WINDOW"))]"":PSORX("MAIL/WINDOW"),$GET(PSOTPBFG)&($GET(PSOFROM)="NEW"):"MAIL",1:"WINDOW")
+4 DO DIR
IF PSODIR("DFLG")!PSODIR("FIELD")
GOTO MWX
+5 IF $GET(Y(0))']""
SET PSODIR("DFLG")=1
GOTO MWX
+6 SET PSODIR("MAIL/WINDOW")=Y
SET PSORX("MAIL/WINDOW")=Y(0)
+7 IF $GET(PSORX("EDIT"))]""
IF PSODIR("MAIL/WINDOW")'="W"
KILL PSODIR("METHOD OF PICK-UP")
MW1 IF PSODIR("MAIL/WINDOW")'="W"!('$PIECE($GET(PSOPAR),"^",12))
GOTO MWX
+1 SET DIR(0)="52,35O"
+2 IF $GET(PSORX("METHOD OF PICK-UP"))]""
SET DIR("B")=PSORX("METHOD OF PICK-UP")
+3 DO DIR
IF PSODIR("DFLG")
GOTO MWX
+4 IF X[U
WRITE !,"Cannot jump to another field ..",!
GOTO MW1
+5 SET (PSODIR("METHOD OF PICK-UP"),PSORX("METHOD OF PICK-UP"))=Y
MWX KILL X,Y
+1 QUIT
+2 ;
RMK(PSODIR) ;
RMKEN KILL DIR,DIC
+1 SET DIR(0)="52,12"
+2 IF $GET(PSODIR("REMARKS"))]""
SET DIR("B")=PSODIR("REMARKS")
+3 DO DIR
IF PSODIR("DFLG")
GOTO RMKX
+4 IF X[U
WRITE !,"Cannot jump to another field ..",!
GOTO RMKEN
+5 IF $LENGTH(X)>0
SET PSODIR("REMARKS")=X
+6 IF X="@"
SET PSODIR("REMARKS")=""
RMKX KILL X,Y
+1 QUIT
+2 ;
ISSDT(PSODIR) ;
+1 KILL DIR,DIC
+2 SET DIR("A")="ISSUE DATE"
SET DIR("B")=$SELECT($GET(POERR)&($GET(PSORX("ISSUE DATE"))']"")&($GET(PSODIR("ISSUE DATE"))]""):PSODIR("ISSUE DATE"),$GET(PSORX("ISSUE DATE"))]"":PSORX("ISSUE DATE"),1:"TODAY")
+3 IF DIR("B")
SET Y=DIR("B")
XECUTE ^DD("DD")
SET DIR("B")=Y
+4 SET DIR(0)="52,1"
+5 DO DIR
IF PSODIR("DFLG")!PSODIR("FIELD")
GOTO ISSDTX
+6 SET (PSODIR("ISSUE DATE"),PSOID)=Y
+7 XECUTE ^DD("DD")
SET (PSORX("ISSUE DATE"),PSODIR("ISSUE DATE"))=Y
ISSDTX KILL X,Y
+1 QUIT
+2 ;
FILLDT(PSODIR) ;
+1 KILL DIR,DIC
+2 IF '$GET(PSONEW("DAYS SUPPLY"))
SET PSONEW("DAYS SUPPLY")=30
SET PSONEW("# OF REFILLS")=1
+3 SET DIR("A")="FILL DATE"
SET DIR("B")=$SELECT($GET(PSORX("FILL DATE"))]"":PSORX("FILL DATE"),1:"TODAY")
+4 SET X2=PSONEW("DAYS SUPPLY")*(PSONEW("# OF REFILLS")+1)\1
+5 SET X1=$SELECT($GET(PSOID):PSOID,1:DT)
+6 ;S X2=$S(PSONEW("DAYS SUPPLY")=X2:X2,+$G(PSODIR("CS")):184,1:366)
+7 ;IHS/MSC/PLS - 02/10/2012
SET X2=$SELECT(+$GET(PSODIR("CS")):184,1:366)
+8 ;I X2<30 D
+9 ;. N % S %=$P($G(PSORX("PATIENT STATUS")),"^"),X2=30
+10 ;. S:%?.N %=$P($G(^PS(53,+%,0)),"^") I %["AUTH ABS" S X2=5
+11 DO C^%DTC
SET PSOFDMX=$PIECE(X,".")
IF DT>X
SET Y=$SELECT($GET(PSOID):PSOID,1:PSORX("ISSUE DATE"))
XECUTE ^DD("DD")
SET DIR("B")=Y
+12 ;IHS/MSC/PLS - 12/30/2008 - Check for Suspense
+13 ;S DIR(0)="D^"_$S($G(PSOID):PSOID,+$G(PSODIR("ISSUE DATE")):PSODIR("ISSUE DATE"),1:DT)_$S($G(DUZ("AG"))="I":":"_DT_":EX",1:":"_PSOFDMX_":EX")
+14 SET DIR(0)="D^"_$SELECT($GET(PSOID):PSOID,+$GET(PSODIR("ISSUE DATE")):PSODIR("ISSUE DATE"),1:DT)_$SELECT($GET(DUZ("AG"))="I"&('$PIECE(PSOPAR,U,24)):":"_DT_":EX",1:":"_PSOFDMX_":EX")
+15 SET Y=PSOFDMX
XECUTE ^DD("DD")
+16 SET DIR("?",1)="The earliest fill date allowed is determined by the ISSUE DATE,"
+17 SET DIR("?",2)="the FILL DATE cannot be before the ISSUE DATE or AFTER the Expiration Date "
+18 SET DIR("?")=Y_". Both the month and date are required."
+19 DO DIR
IF PSODIR("DFLG")!PSODIR("FIELD")
GOTO FILLDTX
+20 SET PSODIR("FILL DATE")=Y
+21 XECUTE ^DD("DD")
SET PSORX("FILL DATE")=Y
FILLDTX KILL X,Y,PSOFDMX
+1 QUIT
+2 ;
CLERK(PSODIR) ;
+1 ;IHS/MSC/PLS - 10/31/2011
+2 ;I $G(DUZ("AG"))'="I" D G CLERKX
+3 ;IHS/MSC/PLS - 05/22/2012 REMOVED THE DOTTED DO
+4 ;D G CLERKX
+5 SET PSODIR("CLERK CODE")=$SELECT($GET(PSOFDR):$PIECE(OR0,"^",4),1:DUZ)
SET PSORX("CLERK CODE")=$PIECE($GET(^VA(200,PSODIR("CLERK CODE"),0)),"^")
+6 KILL DIR,DIC
+7 SET DIR("A")="CLERK"
SET DIR("B")=$SELECT($GET(PSORX("CLERK CODE"))]"":PSORX("CLERK CODE"),1:$PIECE($GET(^VA(200,DUZ,0)),"^",2))
SET DIR(0)="52,16"
+8 DO DIR
IF PSODIR("DFLG")!PSODIR("FIELD")
GOTO CLERKX
+9 ; IHS/CIA/PLS - 01/25/04 - Next line commented out
+10 ;S PSODIR("CLERK CODE")=+Y,PSORX("CLERK CODE")=$P(Y,"^")
+11 ; IHS/CIA/PLS - 01/25/04 - Changed to Name from initials
SET PSODIR("CLERK CODE")=+Y
SET PSORX("CLERK CODE")=$PIECE(Y,"^",2)
CLERKX QUIT
+1 ;
DIR ;
+1 SET PSODIR("FIELD")=0
+2 IF $GET(DIR(0))']""
GOTO DIRX
+3 DO ^DIR
KILL DIR,DIE,DIC,DA
IF X="^^"
SET (PSODIR("QFLG"),PSODIR("DFLG"))=1
GOTO DIRX
DIRS ; EP - IHS/CIA/PLS - 12/23/03 - New entry point DIRS added.
+1 IF $DATA(DUOUT)!($DATA(DTOUT))!($DATA(DIROUT))
IF $LENGTH($GET(X))'>1!(Y="")
SET PSODIR("DFLG")=1
IF $GET(SPEED)
SET PSODIR("QFLG")=1
GOTO DIRX
+2 IF $DATA(DUOUT)!($DATA(DTOUT))
IF $GET(SPEED)
SET PSODIR("DFLG")=1
GOTO DIRX
+3 IF X[U
IF $LENGTH(X)>1
DO JUMP
DIRX KILL DIRUT,DTOUT,DUOUT,DIROUT,PSOX
+1 QUIT
+2 ;
JUMP ;
+1 IF $GET(PSOEDIT)!($GET(OR0))
SET PSODIR("DFLG")=1
QUIT
+2 SET X=$PIECE(X,"^",2)
SET DIC="^DD(52,"
SET DIC(0)="QM"
DO ^DIC
KILL DIC
+3 IF Y=-1
SET PSODIR("FIELD")=$GET(PSODIR("FLD"))
GOTO JUMPX
+4 IF $GET(PSONEW1)=0
DO JUMP^PSONEW1
GOTO JUMPX
+5 IF $GET(PSONEW3)=0
DO JUMP^PSONEW3
GOTO JUMPX
+6 IF $GET(PSORENW3)=0
DO JUMP^PSORENW3
GOTO JUMPX
JUMPX SET X="^"_X
+1 QUIT
+2 ;Reset refills when drug changed to a controlled sub
RFRSET ;
+1 NEW RFN,RFNC
+2 SET (RFN,RFNC)=0
+3 FOR
SET RFN=$ORDER(^PSRX(+$GET(PSODIR("IRXN")),1,RFN))
IF 'RFN
QUIT
SET RFNC=RFNC+1
+4 IF $DATA(PSODIR("FIELD"))
SET PSODIR("FIELD")=0
+5 SET PSODIR("# OF REFILLS")=RFNC
+6 SET VALMSG="The drug has been changed and no longer allows refills."
+7 WRITE !,VALMSG,!
+8 QUIT