VistA-WorldVistAEHR/r/OUTPATIENT_PHARMACY-PSO-APS.../PSODIR2.m

130 lines
5.1 KiB
Mathematica
Raw Normal View History

2009-11-29 13:37:14 -05:00
PSODIR2 ;IHS/DSD/JCM - rx order entry contd ;01/27/93 7:12
;;7.0;OUTPATIENT PHARMACY;**3,9,26,46,124,146,139,152,166**;DEC 1997
;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
;
;---------------------------------------------------------------------
;
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)
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
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 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) ;
I $G(DUZ("AG"))'="I" 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
S PSODIR("CLERK CODE")=+Y,PSORX("CLERK CODE")=$P(Y,"^")
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
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