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

PSOERRX0.m

Go to the documentation of this file.
PSOERRX0 ;BIRM/MFR - All Rxs eRx Queue - ListManager ;08/28/22
 ;;7.0;OUTPATIENT PHARMACY;**700,746**;DEC 1997;Build 106
 ;
EN ; Entry point for the RX Action in the Patient Centric View
 N STSFLTR,MATFLTR,REDTFLTR,PRVFLTR,DRGFLTR,MSTPFLTR,MTARR,PSODETDP
 S MBMSITE=$S($$GET1^DIQ(59.7,1,102,"I")="MBM":1,1:0)
 ;
 ;Division selection
 I '$G(PSOSITE) D ^PSOLSET I '$D(PSOPAR) W $C(7),!!,"Pharmacy Division Must be Selected!",! G EXIT
 I '$G(PSNPINST) S PSNPINST=$$GET1^DIQ(59,PSOSITE,101,"I")
 ;
 ; Loading User's preferences
 S MTARR("RR")="RXRENEWALREQUEST",MTARR("RE")="RXRENEWALRESPONSE",MTARR("N")="NEWRX(ALL)",MTARR("CR")="RXCHANGEREQUEST"
 S MTARR("RXF")="RXFILL",MTARR("IE")="INBOUND ERROR",MTARR("OE")="OUTBOUND ERROR",MTARR("CA")="CANCELRX",MTARR("CN")="CANCELRXRESPONSE"
 S MTARR("CX")="RXCHANGERESPONSE",MTARR("N")="NEWRX"
 D LOAD^PSOERPR1
 W !,"Please wait..."
 D EN^VALM("PSO ERX ALL RXS QUEUE")
 ;
 G EXIT
 ;
LMHDR ; ListMan Header Code
 D SHOW^VALM,HDR^PSOERRX0
 I $G(MBMSITE) S XQORM("B")="Next Screen"
 S XQORM("#")=$O(^ORD(101,"B","PSO ERX ALL RXS SELECT",""))_"^1:"_VALMCNT
 S XQORM("??")="D HELP^VALM2,HDR^PSOERRX0"
 Q
 ;
HDR      ; - Builds the Header section
 D HDR^PSOERRX1
 Q
 ;
INIT ;Populates the Body section for ListMan
 N LOCKPATS,PAT
 K ^TMP("PSOERRX0",$J),^TMP("PSOERRXS",$J)
 S PAT=0 F  S PAT=$O(^XTMP("PSOERXLOCK",PAT)) Q:'PAT  S LOCKPATS(PAT)=+$G(^XTMP("PSOERXLOCK",PAT))
 D SETSORT^PSOERRX1(PSOSRTBY),SETLINE
 S:$G(VALMSG)="" VALMSG="Select the entry # to view or ?? for more actions"
 Q
 ;
SETLINE ;Sets the line to be displayed in ListMan
 N SORT,TYPE,STS,SUB,SEQ,LINE,Z,Z1,TOTAL,I,X,X1,ORDCNT,LBL,LN,GROUP,QTYL,ORNUM1,ERXIEN1,HIGHLN
 N X,POS
 K ^TMP("PSOERRX0",$J)
 I '$D(^TMP("PSOERRXS",$J)) D  Q
 . F I=1:1:6 S ^TMP("PSOERRX0",$J,I,0)=""
 . S ^TMP("PSOERRX0",$J,7,0)="                    No prescriptions found."
 . S VALMCNT=1
 ;
 ;Resetting list to NORMAL video attributes
 D RESET^PSOERUT0() K GRPLN
 ;
 ;Building the list (line by line)
 S (GROUP,SORT)="",(SEQ,LINE)=0,SORTORD=$S(PSORDER="A":1,1:-1)
 F  S GROUP=$O(^TMP("PSOERRXS",$J,GROUP)) Q:GROUP=""  D
 . I GROUP'="ALL" D
 . . N LBL,POS,X
 . . S LBL=$S(GROUP="NON-CS":"NON-",1:"")_"CONTROLLED SUBSTANCE Rx's"
 . . S POS=41-($L(LBL)\2) S X="",$P(X," ",81)="",$E(X,POS,POS-1+$L(LBL))=LBL
 . . S LINE=LINE+1,^TMP("PSOERRX0",$J,LINE,0)=X,GRPLN(LINE)=LBL
 . F  S SORT=$O(^TMP("PSOERRXS",$J,GROUP,SORT),SORTORD) Q:SORT=""  D
 . . S Z=$G(^TMP("PSOERRXS",$J,GROUP,SORT)),SEQ=SEQ+1
 . . S Z1=$G(^TMP("PSOERRXS",$J,GROUP,SORT,"ERXIEN")),ERXIEN=+Z1
 . . S X1=SEQ_$S(+$G(^PS(52.49,ERXIEN,95)):"]",1:".")
 . . S $E(X1,$S(SEQ>999:6,1:5))=$E($P(Z,"^",1),1,$S(SEQ>999:19,1:20)),$E(X1,26)=$P(Z,"^",2),$E(X1,35)=$E($P(Z,"^",3),1,21)
 . . I $G(MBMSITE),$E($P(Z,"^",5),1,3)="REM" S $P(Z,"^",5)="R"_$E($P(Z,"^",5),4,9)
 . . S $E(X1,57)=$E($P(Z,"^",4),1,11),$E(X1,69)=$E($P(Z,"^",5),1,3),$E(X1,73)=$P(Z,"^",6)
 . . S LINE=LINE+1,^TMP("PSOERRX0",$J,LINE,0)=X1,^TMP("PSOERRX0",$J,SEQ,"ERXIEN")=ERXIEN
 . . I $P(Z1,"^",2) S HIGHLN(LINE)=1
 . . I $G(PSODETDP) D SETDET^PSOERPT0(ERXIEN,.LINE,"PSOERRX0")
 ;
 ;Saving NORMAL video attributes to be reset later
 I LINE>$G(LASTLINE) D
 . F I=($G(LASTLINE)+1):1:LINE D SAVE^VALM10(I)
 . S LASTLINE=LINE
 D VIDEO^PSOERPT1()
 S VALMCNT=+$G(LINE) D RV^PSOPMP1
 Q
 ;
FLTRMT(MSGTYPE) ; Filter By Message Type Action
 S MSTPFLTR=MSGTYPE
 D REF S VALMBCK="R",VALMBG=1
 Q
 ;
CS ;Group/Un-group Controlled Substances
 S PSOCSGRP=$S($G(PSOCSGRP):0,1:1) D REF
 Q
 ;
DET ;Display/Remove DET
 S PSODETDP=$S($G(PSODETDP):0,1:1),LINE=0 D REF
 I 'PSODETDP S VALMBG=VALMBG\2
 I PSODETDP S VALMBG=VALMBG*2-1
 S:VALMBG>(VALMCNT-10) VALMBG=VALMCNT-10 S:VALMBG<1 VALMBG=1
 Q
 ;
CV ;Change View
 D EN^PSOERPR1 I $G(PSORFRSH) D REF S VALMBG=1
 S VALMBCK="R"
 Q
 ;
SORT(FIELD) ;Sort entries by FIELD
 I PSOSRTBY=FIELD S PSORDER=$S(PSORDER="A":"D",1:"A")
 E  S PSOSRTBY=FIELD,PSORDER="A"
 D REF
 Q
 ;
LBD ;Change Look Back Days Parameter Action
 D FULL^VALM1 S VALMBCK="R"
 W ! K DIR,DIRUT,DIROUT,SAVEX,DA
 S DIR(0)="52.353,1",DIR("B")=PSOLKBKD
 D ^DIR I $D(DIRUT)!$D(DIROUT) Q
 S PSOLKBKD=Y,RESETLBD=0 D REF S VALMBG=1
 Q
 ;
PC ;Patient Centri View Switch
 D EN^PSOERPC0 S VALMBCK="Q"
 Q
 ;
SEL ;Process selection of one entry
 N PSOSEL,ERXIEN,ERXPTIEN
 S VALMBCK="R"
 S PSOSEL=+$P(XQORNOD(0),"=",2) I 'PSOSEL S VALMSG="Invalid selection!" Q
 S ERXIEN=$G(^TMP("PSOERRX0",$J,PSOSEL,"ERXIEN")) I 'ERXIEN S VALMSG="Invalid selection!" Q
 S ERXPTIEN=$$GETPAT^PSOERXU5(ERXIEN)
 ; - Locking the eRx Patient
 I ERXPTIEN,'$$LOCK^PSOERPC1(ERXPTIEN) Q
 ; - Entering the eRx Record
 D EN^PSOERX1(ERXIEN) K ERXIEN
 ; - Unlocking the eRx Patient
 I ERXPTIEN D UL^PSOERX1A(ERXPTIEN)
 I $G(PSORFRSH) D REF
 Q
 ;
SQ ; - Search Queue Entry Point
 D FULL^VALM1 S VALMBCK="R"
 N DIR,DUOUT,DIRUT,Y,X,CHANGE,ERXLOCK,ERXPTIEN,PSOFPICK
 S CHANGE=0
REP ; Re-Entry Point
 K DIR S DIR("?",1)="Choose one or multiple filter criteria(s) to sort the current list."
 S DIR("?",2)="To remove an existing filter type ^#, where '#' is the filter number below."
 S DIR("?")=" "
 S DIR("A")="SEARCH BY"
 S DIR(0)="SO^1:ERX PATIENT" I $D(PATFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$EPATFLST^PSOERUT(44)_")"_IOINORM
 S DIR(0)=DIR(0)_";2:ERX DATE OF BIRTH" I $G(DOBFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$FMTE^XLFDT(DOBFLTR,"2Z")_")"_IOINORM
 S DIR(0)=DIR(0)_";3:RECEIVED DATE RANGE" I $G(REDTFLTR) S DIR(0)=DIR(0)_IOINHI_" ("_$$FMTE^XLFDT(+REDTFLTR,"2Z")_" TO "_$$FMTE^XLFDT($P(REDTFLTR,"^",2),"2Z")_")"_IOINORM
 S DIR(0)=DIR(0)_";4:ERX PROVIDER" I $D(PRVFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$EPRVFLST^PSOERUT(44)_")"_IOINORM
 S DIR(0)=DIR(0)_";5:ERX STATUS" I $G(STSFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$GET1^DIQ(52.45,+STSFLTR,.01)_")"_IOINORM
 S DIR(0)=DIR(0)_";6:DRUG NAME" I $G(DRGFLTR)'="" S DIR(0)=DIR(0)_" "_IOINHI_"('"_DRGFLTR_"')"_IOINORM
 S DIR(0)=DIR(0)_";7:MESSAGE TYPE" I $G(MSTPFLTR)'="" S DIR(0)=DIR(0)_" "_IOINHI_"("_MTARR(MSTPFLTR)_")"_IOINORM
 S DIR(0)=DIR(0)_";8:ERX REFERENCE NUMBER"
 S DIR(0)=DIR(0)_";9:VISTA RX #"
 S DIR(0)=DIR(0)_";10:VISTA PATIENT" I $D(VPATFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$VPATFLST^PSOERUT(44)_")"_IOINORM
 S DIR(0)=DIR(0)_";11:VISTA PROVIDER" I $D(VPRVFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$VPRVFLST^PSOERUT(44)_")"_IOINORM
 S DIR(0)=DIR(0)_";12:MATCH STATUS" I $G(MATFLTR) S DIR(0)=DIR(0)_" "_IOINHI_"("_$$MATCHLBL^PSOERPC2(MATFLTR)_")"_IOINORM
 D ^DIR
 I X'="^",X?1"^".N D  G REP
 . K:X="^1" PATFLTR,VPATFLTR K:X="^2" DOBFLTR K:X="^3" REDTFLTR K:X="^4" PRVFLTR,VPRVFLTR K:X="^5" STSFLTR
 . K:X="^6" DRGFLTR K:X="^7" MSTPFLTR K:X="^10" PATFLTR,VPATFLTR K:X="^11" PRVFLTR,VPRVFLTR K:X="^12" MATFLTR
 . S CHANGE=1
 I X=""!$D(DUOUT)!($D(DIRUT)) D:CHANGE REF S:CHANGE VALMBG=1 Q
 S PSOFPICK=+$G(Y)
 I PSOFPICK=1 D EPATFLTR^PSOERPC0 S CHANGE=1 G REP
 I PSOFPICK=2 D DOBFLTR^PSOERPC0 S CHANGE=1 G REP
 I PSOFPICK=3 D REDTFLTR S CHANGE=1 G REP
 I PSOFPICK=4 D PRVFLTR S CHANGE=1 G REP
 I PSOFPICK=5 D STSFLTR S CHANGE=1 G REP
 I PSOFPICK=6 D  S CHANGE=1 G REP
 . D DRGFLTR
 I PSOFPICK=7 D MSTPFLTR S CHANGE=1 G REP
 I PSOFPICK=8 D ERXFLTR^PSOERPC0 G:'$G(ERXFLTR) REP D  I '$G(CHANGE) Q
 . ; - Entering the eRx Record
 . D EN^PSOERX1(ERXFLTR)
 . ; - Unlocking the eRx Patient
 . S ERXPTIEN=$$GET1^DIQ(52.49,ERXFLTR,.04,"I") Q:'ERXPTIEN
 . D UL^PSOERX1A(ERXPTIEN)
 . S CHANGE=1
 I PSOFPICK=9 D RXFLTR^PSOERPC0 G:'$G(ERXFLTR) REP D  I '$G(CHANGE) Q
 . ; - Entering the eRx Record
 . D EN^PSOERX1(ERXFLTR)
 . ; - Unlocking the eRx Patient
 . S ERXPTIEN=$$GET1^DIQ(52.49,ERXFLTR,.04,"I") Q:'ERXPTIEN
 . D UL^PSOERX1A(ERXPTIEN)
 . S CHANGE=1
 I PSOFPICK=10 D VPATFLTR^PSOERPC0 S CHANGE=1 G REP
 I PSOFPICK=11 D VPRVFLTR^PSOERRX1 S CHANGE=1 G REP
 I PSOFPICK=12 D MATFLTR^PSOERPC0 S CHANGE=1 G REP
 D REF S VALMBG=1
 Q 
 ;
REDTFLTR ; - Received Date Range Filter
 N %DT,PSOFROM,PSOTO,Y,DTOUT,DIROUT
 S %DT(0)=-DT,%DT="AEP",%DT("A")="BEGIN DATE: "
 S %DT("B")="T-45" I $P($G(REDTFLTR),"^") S %DT("B")=$$FMTE^XLFDT($P($G(REDTFLTR),"^"),"5Z")
 W ! D ^%DT I Y<0!($D(DTOUT)) Q
 S PSOFROM=Y\1
 ;
 K %DT S %DT(0)=PSOFROM\1,%DT="AEP",%DT("A")="END DATE: "
 S %DT("B")="TODAY" I $P($G(REDTFLTR),"^",2) S %DT("B")=$$FMTE^XLFDT($P($G(REDTFLTR),"^",2),"5Z")
 W ! D ^%DT I Y<0!($D(DTOUT)) Q
 S PSOTO=Y\1
 ;
 S REDTFLTR=PSOFROM_"^"_PSOTO
 Q
 ;
PRVFLTR ; - eRx Provider Filter
 N DIR,PRV,XX,PRVLST,RANGE,COMSEG,I,J,DIRUT,DIROUT,QUIT
 S DIR(0)="F^3:30",DIR("A")="ERX PROVIDER NAME"
 W ! D ^DIR I $D(DIRUT)!$D(DIROUT) Q
 D FIND^DIC(52.48,"","@;.01;1.5;1.6;4.3;4.4;IX","",X,,"B","","","PRVLST")
 I '$D(PRVLST("DILIST",2)) W !,"No eRx Provider found" K PRVLST G PRVFLTR
 ;
 W !!,"#",?4,"ERX PROVIDER NAME",?35,"NPI",?48,"CITY",?68,"STATE"
 S (QUIT,CNT)=0,$P(XX,"-",80)="" W !,XX K DIRUT,DTOUT
 S PRV="" F  S PRV=$O(PRVLST("DILIST","ID",PRV)) Q:'PRV  D  I QUIT Q
 . W !,PRV,".",?4,$E(PRVLST("DILIST","ID",PRV,.01),1,30),?35,PRVLST("DILIST","ID",PRV,1.5)
 . W ?48,$E(PRVLST("DILIST","ID",PRV,4.3),1,20),?68,$$STATEABB^PSOERUT(52.48,PRVLST("DILIST",2,PRV))
 . S CNT=CNT+1
 . I CNT>18,$O(PRVLST("DILIST","ID",PRV)),$Y>(IOSL-4) D
 . . K DIR S DIR(0)="E" D ^DIR I $D(DIRUT)!$D(DIROUT) S QUIT=1 Q
 . . W @IOF,!,"#",?4,"ERX PROVIDER NAME",?35,"NPI",?48,"CITY",?68,"STATE",!,XX
 ;
 K DIR S DIR("A")="SELECT (1-"_+$G(PRVLST("DILIST",0))_"): "
 S DIR(0)="LA^1:"_+$G(PRVLST("DILIST",0)) W ! D ^DIR I $D(DIRUT)!$D(DIROUT) G PRVFLTR
 S RANGE=X
 ;
 K PRVFLTR
 F I=1:1:$L(RANGE,",") D
 . S COMSEG=$P(RANGE,",",I)
 . F J=+COMSEG:1:$S(COMSEG["-":$P(COMSEG,"-",2),1:+COMSEG) D
 . . I '$D(PRVLST("DILIST",2,J)) Q
 . . S PRVFLTR(PRVLST("DILIST",2,J))=""
 Q
 ;
MSTPFLTR ; - Message Type Filter 
 K DIR,DIRUT,DIROUT,X,Y
 W ! S DIR(0)="52.49,.08" S:$G(MSTPFLTR)'="" DIR("B")=MSTPFLTR
 D ^DIR I $D(DIRUT)!$D(DIROUT) Q
 S MSTPFLTR=Y
 Q
 ;
STSFLTR ; - eRx Status Filter
 ; prompt for erx status
 N DIC,Y,DTOUT,DUOUT
 I $G(STSFLTR) S DIC("B")=$$GET1^DIQ(52.45,STSFLTR,.01)
 S DIC("A")="ERX STATUS: ",DIC=52.45,DIC(0)="AEQ",DIC("S")="I $D(^PS(52.45,""TYPE"",""ERX"",Y))"
 ; MbM Sites only - Allow selection of Removed Reasons as Status
 I $G(MBMSITE) S DIC("S")=DIC("S")_"!$D(^PS(52.45,""TYPE"",""REM"",Y))"
 W ! D ^DIC I Y<1 Q
 S STSFLTR=+Y
 Q
 ;
DRGFLTR ; - eRx Drug Name Filter
 N DIR,X,Y,DIRUT,DIROUT
 S DIR(0)="F^3:30",DIR("A")="DRUG NAME"
 W ! D ^DIR I $D(DIRUT)!$D(DIROUT) Q
 S DRGFLTR=Y
 Q
 ;
RF ; Remove All Filters
 K PATFLTR,VPATFLTR,DOBFLTR,REDTFLTR,PRVFLTR,VPRVFLTR,STSFLTR,MSTPFLTR,DRGFLTR,MATFLTR
 D REF S VALMBG=1
 Q
 ;
REF ;Screen Refresh
 W ?52,"Please wait..." D INIT,HDR S VALMBCK="R"
 Q
 ;
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ;
 K ^TMP("PSOERRX0",$J),^TMP("PSOERRXS",$J)
 D FULL^VALM1
 Q