Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSODIR2

PSODIR2.m

Go to the documentation of this file.
PSODIR2 ;IHS/DSD/JCM - rx order entry contd ;Apr 08, 2020@14:45:14
 ;;7.0;OUTPATIENT PHARMACY;**3,9,26,46,124,146,139,152,166,504,526,457,574,441**;DEC 1997;Build 208
 ;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:$G(PSODIR("DFLG"))!$G(PSODIR("FIELD")) CLINICX  ;526
 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,PSOIEN52,PSOIEN50,PSODEAHD,PSOCLOZ ;441 PAPI
 I '$D(PSORX("MAIL/WINDOW")),$D(PSODIR("MAIL/WINDOW")) S PSORX("MAIL/WINDOW")=$S($G(PSODIR("MAIL/WINDOW"))="M":"MAIL",$G(PSODIR("MAIL/WINDOW"))="P":"PARK",1:"WINDOW")
 S DIR(0)="52,11" S:$G(POERR)&'$D(PSORX("MAIL/WINDOW")) PSORX("MAIL/WINDOW")=$S($P($G(OR0),"^",17)="M":"MAIL",$P($G(OR0),"^",17)="P":"PARK",1:"WINDOW")  ;441 PAPI
 S DIR("B")=$S(($G(PSODRUG("DEA"))["D")!($G(PSODRUG("NAME"))["CLOZAPINE")&($G(PSORX("MAIL/WINDOW"))="PARK"):"WINDOW",$G(PSORX("MAIL/WINDOW"))]"":PSORX("MAIL/WINDOW"),$G(PSOTPBFG)&($G(PSOFROM)="NEW"):"MAIL",1:"WINDOW")
 ; DO NOT ALLOW "PARK" CHOICE FOR REFILLS OR RENEWS FOR DEA NOT-PARKABLE MEDICATIONS
 I $G(SPEED),$D(PSOLST) D
 . Q:'$G(LST)
 . S PSOIEN52=$P(PSOLST(+LST),U,2)
 . Q:PSOIEN52=""
 . S PSOIEN50=$$GET1^DIQ(52,PSOIEN52_",",6,"I")
 . Q:PSOIEN50=""
 . S PSODEAHD=$$GET1^DIQ(50,PSOIEN50_",",3),PSOCLOZ=$$GET1^DIQ(50,PSOIEN50_",",.01)  ;441 PAPI set PSOCLOZ for Clozapine check
 I $E($G(DIR("B")))="P" I (($G(PSODEAHD)["D")!($G(PSODRUG("DEA"))["D")) S DIR("B")="WINDOW" G MW0  ;IF NOT PARKABLE REMOVE PARK OPTION FROM PROMPT
 I $G(PSOFROM)="REFILL"!($G(PSODRUG("DEA"))["D")!($G(PSODEAHD)["D")!($G(PSODRUG("NAME"))["CLOZAPINE") S DIR(0)="S^M:MAIL;W:WINDOW",DIR("A")="MAIL/WINDOW" G MW0
 I $G(PSOCLOZ)["CLOZAPINE" S DIR(0)="S^M:MAIL;W:WINDOW",DIR("A")="MAIL/WINDOW" G MW0  ;for SPEED refills
 N RESULTS,PSOPARKX
 S RESULTS="PSOPARKX" D GETPARK^PSORPC01()
 I $G(PSOPARKX(0))="YES",$G(PSODIR("FLD"))'=2 S DIR(0)="S^M:MAIL;W:WINDOW;P:PARK",DIR("A")="MAIL/WINDOW/PARK"
 I $G(PSOPARKX(0))'="YES"!($G(PSODIR("FLD"))=2) S DIR(0)="S^M:MAIL;W:WINDOW",DIR("A")="MAIL/WINDOW"
MW0 D DIR G:$G(PSODIR("DFLG"))!$G(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:$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:$G(PSODIR("DFLG")) RMKX  ;*526
 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
 ; START NCC REMEDIATION >> 457*RJS
 ; PSO*7*574 ADJUST EXPIRE DATE FOR 4 DAY SUPPLY, fix defect 969788?
 I $G(CLOZFLG),PSONEW("DAYS SUPPLY")<5 S X2=PSONEW("DAYS SUPPLY")*(PSONEW("# OF REFILLS")+1)\1
 ; END NCC REMEDIATION << 457*RJS
 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")
 I $G(PSODIR("MAIL/WINDOW"))="P" D FILLDTPK G FILLDTX  ;441 PAPI
 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:$G(PSODIR("DFLG"))!$G(PSODIR("FIELD")) FILLDTX  ;*526
 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
 ;
FILLDTPK ; If parked, don't prompt for fill date, but save it to be set to next possible fill date when filed 441 PAPI
 D NOW^%DTC
 S Y=%
 D DD^%DT
 S PSODIR("FILL DATE")=X
 S PSORX("FILL DATE")=$P(Y,"@")
 Q