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

PSOERHL0.m

Go to the documentation of this file.
  1. PSOERHL0 ;BIRM/MFR - eRx History Log View - Listman Driver ;04/12/23
  1. ;;7.0;OUTPATIENT PHARMACY;**700,746**;DEC 1997;Build 106
  1. ;
  1. EN(PSOERXID) ;Menu option entry point
  1. N PSOSRTBY,PSORDER,UNDLN,HIGHLN,REVLN,LASTLINE,VALMCNT
  1. ;
  1. S PSOSRTBY="DT",PSORDER="A"
  1. W !,"Please wait..."
  1. D EN^VALM("PSO ERX HISTORY LOG")
  1. D FULL^VALM1
  1. G EXIT
  1. ;
  1. HDR ;Header
  1. N LINE,POS,LINE1,LINE2,LINE3,LINE4,WT,WTDT,HT,HTDT,VADM,DFN,PNAME,DOB,SEX,X,GMRAL,ADVREA
  1. K VALMHDR S VALMHDR(1)="eRx Patient: "_$$GET1^DIQ(52.49,PSOERXID,.04,"E")
  1. S VALMHDR(2)="eRx Reference #: "_$$GET1^DIQ(52.49,PSOERXID,.01)
  1. Q
  1. ;
  1. INIT ;Populates the Body section for ListMan
  1. K ^TMP("PSOERXHL",$J)
  1. D SETSORT(PSOSRTBY),SETLINE
  1. Q
  1. ;
  1. SETLINE ;Sets the line to be displayed in ListMan
  1. ;
  1. I '$D(^TMP("PSOERXHL",$J)) D Q
  1. . F I=1:1:6 S ^TMP("PSOERXHL",$J,I,0)=""
  1. . S ^TMP("PSOERXHL",$J,7,0)=" No History Log for this eRx"
  1. . S VALMCNT=1
  1. ;
  1. ;Saving NORMAL video attributes to be reset later
  1. I LINE>$G(LASTLINE) D
  1. . F I=($G(LASTLINE)+1):1:LINE D SAVE^VALM10(I)
  1. . S LASTLINE=LINE
  1. S VALMCNT=+$G(LINE)
  1. D VIDEO
  1. ;
  1. Q
  1. ;
  1. VIDEO ; - Changes the Video Attributes for the list
  1. ; - Highlighting the group lines (order type and status)
  1. N LN
  1. F LN=1:1:LASTLINE D
  1. . I $G(UNDLN(LN)) D CNTRL^VALM10(LN,+UNDLN(LN),$P(UNDLN(LN),"^",2),IOUON,IOINORM)
  1. . I $G(HIGHLN(LN)) D CNTRL^VALM10(LN,+HIGHLN(LN),$P(HIGHLN(LN),"^",2),IOINHI,IOINORM)
  1. . I $G(REVLN(LN)) D CNTRL^VALM10(LN,+REVLN(LN),$P(REVLN(LN),"^",2),IORVON,IORVOFF)
  1. Q
  1. ;
  1. SETSORT(SORTBY) ;Building the list (line by line)
  1. ;Resetting list to NORMAL video attributes
  1. D RESET^PSOERUT0()
  1. S LINE=0
  1. N PAAM,PRAM,DRAM,PAME,PRME,DRME,DISP,X1,X2,X3
  1. K ^TMP("PSOERXHL",$J)
  1. S PAAM=$$GET1^DIQ(52.49,PSOERXID,1.6,"E") S PAME=$$GET1^DIQ(52.49,PSOERXID,1.7,"E")
  1. S PRAM=$$GET1^DIQ(52.49,PSOERXID,1.2,"E") S PRME=$$GET1^DIQ(52.49,PSOERXID,1.3,"E")
  1. S DRAM=$$GET1^DIQ(52.49,PSOERXID,1.4,"E") S DRME=$$GET1^DIQ(52.49,PSOERXID,1.5,"E")
  1. S X1="Pat Auto-Match: "_PAAM,$E(X1,39)="Pat Manual Edit: "_PRAM
  1. S X2="Prov Auto-Match: "_PRAM,$E(X2,39)="Prov Manual Edit: "_PRME
  1. S X3="Drug Auto-Match: "_DRAM,$E(X3,39)="Drug Manual Edit: "_DRME
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X1
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X2
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X3
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=""
  1. ;
  1. N AUD,ZAUD,IENS,DATETIME,EDITEDBY,STADE,X1,X2,I,VAL1,RET,II,HFFDT
  1. S AUD=0 ;STATUS HISTORY LOOP
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Status History:",REVLN(LINE)="1^15"
  1. S X1="Date/Time",$E(X1,19)="Status",$E(X1,60)="Entered By"
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X1,UNDLN(LINE)="1^80"
  1. I '$D(^PS(52.49,PSOERXID,19)) S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="No Status History Available"
  1. F S AUD=$O(^PS(52.49,PSOERXID,19,AUD)) Q:'AUD D
  1. . S ZAUD=$G(^PS(52.49,PSOERXID,19,AUD,0))
  1. . S IENS=AUD_","_PSOERXID_","
  1. . S DATETIME=$P(ZAUD,"^",1)
  1. . S EDITEDBY=$P(ZAUD,"^",3)
  1. . S EDITEDBY=$E(EDITEDBY,1,16)
  1. . S STADE=$$GET1^DIQ(52.45,$P(ZAUD,"^",2),.02)
  1. . S STADE=$E(STADE,1,36)
  1. . S X2=$$FMTE^XLFDT(DATETIME,"2Z"),$E(X2,19)=$$GET1^DIQ(52.45,$P(ZAUD,"^",2),.01)_"-"_$E(STADE,1,34)
  1. . ; Un-Accept Flag
  1. . I $P(ZAUD,"^",4) S X2=X2_" (Un-Accept)"
  1. . ; Hold for Future Fill Date
  1. . I $$GET1^DIQ(52.45,$P(ZAUD,"^",2),.01)="HFF" S X2=X2_" ("_$$FMTE^XLFDT($P(ZAUD,"^",5))_")"
  1. . S $E(X2,60)=$E($$GET1^DIQ(200,EDITEDBY,.01),1,19) ;eRx Status
  1. . S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)=X2
  1. . S VAL1=$$GET1^DIQ(52.4919,IENS,1,"E")
  1. . I $G(VAL1)'="" D
  1. . . K RET D TXT2ARY^PSOERXD1(.RET,VAL1,,60)
  1. . . F II=1:1:+$O(RET(""),-1) S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)=$S(II=1:"Status Comments: ",1:"")_RET(II),HIGHLN(LINE)="1^80"
  1. ;
  1. N OERR,ORSTAT,IEN,DATETM,FLGDT,FLGBY,FLGREA,UNFLGDT,UNFLGBY,UNFLGRE,X1,X2
  1. S OERR=$$GET1^DIQ(52.49,PSOERXID,.12)
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=""
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Order:",REVLN(LINE)="1^6"
  1. S X1="Date/Time",$E(X1,24)="Order#",$E(X1,43)="Status"
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X1,UNDLN(LINE)="1^80"
  1. I 'OERR S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="No Order History Available"
  1. I OERR D
  1. . S ORSTAT=$$GET1^DIQ(100,OERR_",",5,"E") ;Order Status
  1. . S DATETM=$$GET1^DIQ(100,OERR_",",31,"I") ;Date/Time
  1. . S X2=$$FMTE^XLFDT(DATETM,"2Z"),$E(X2,24)=OERR,$E(X2,43)=ORSTAT
  1. . S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)=X2
  1. . S IEN=0 ;ORDER LOOP
  1. . S IEN=$O(^PS(52.41,"B",OERR,IEN))
  1. . I IEN D
  1. . . S FLGDT=$$GET1^DIQ(52.41,IEN,33) ;Date/Time FLAGGED ^PS(52.41, NODE FLG PIECE 1 FLD#33
  1. . . S FLGBY=$$GET1^DIQ(52.41,IEN,34,"I") ;Flagged By ^PS(52.41, NODE FLG PIECE 2 FLD#34
  1. . . S FLGREA=$$GET1^DIQ(52.41,IEN,35) ;Reason for FLAG ^PS(52.41, NODE FLG PIECE 3 FLD#35
  1. . . S UNFLGDT=$$GET1^DIQ(52.41,IEN,36) ;Date/Time UNFLAGGED ^PS(52.41, NODE FLG PIECE 4 FLD#36
  1. . . S UNFLGBY=$$GET1^DIQ(52.41,IEN,37,"I") ;UNFLAGGED By ^PS(52.41, NODE FLG PIECE 5 FLD#37
  1. . . S UNFLGRE=$$GET1^DIQ(52.41,IEN,38) ;Reason for UNFLAG ^PS(52.41, NODE FLG PIECE 6 FLD#38
  1. . . I $G(FLGDT)'="" S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)="Date/Time Flagged:"_" "_$$FMTE^XLFDT(FLGDT,"2Z")
  1. . . I $G(FLGBY)'="" S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)="Flagged By:"_" "_$E($$GET1^DIQ(200,FLGBY,.01),1,26)
  1. . . I $G(FLGREA)'="" S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)="Reason for Flag:"_" "_$G(FLGREA),HIGHLN(LINE)="1^80"
  1. . . I $G(UNFLGDT)'="" S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)="Date/Time Unflagged:"_" "_$$FMTE^XLFDT(UNFLGDT,"2Z")
  1. . . I $G(UNFLGBY)'="" S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)="Unflagged By:"_" "_$E($$GET1^DIQ(200,UNFLGBY,.01),1,26)
  1. . . I $G(UNFLGRE)'="" S LINE=LINE+1 S ^TMP("PSOERXHL",$J,LINE,0)="Reason for Unflag:"_" "_$G(UNFLGRE),HIGHLN(LINE)="1^80"
  1. ;
  1. N ERXHUB,PSRX,AUD,ZAUD,IENS,PRESE,PRESI,DATETIME,FLDNAME,EDITEDBY,FILL,COMMENT,X,X1,X2
  1. S ERXHUB=$P(^PS(52.49,PSOERXID,0),"^",1)
  1. S (PSRX,AUD,IEN)=0 ;RX ACTIVITY LOG
  1. S PRESE=$$GET1^DIQ(52.49,PSOERXID,.13,"E")
  1. S PRESI=$$GET1^DIQ(52.49,PSOERXID,.13,"I")
  1. I PRESE'="" D
  1. . S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=""
  1. . S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Prescription:",REVLN(LINE)="1^13",UNDLN(LINE)="14^80"
  1. . S X="Prescription#: ",$E(X,16)=PRESE,$E(X,38)="Status: ",$E(X,47)=$$GET1^DIQ(52,PRESI,100,"E")
  1. . S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=""
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Activity Log:",REVLN(LINE)="1^13"
  1. S X1="Date/Time",$E(X1,19)="Reason",$E(X1,41)="Rx Ref",$E(X1,57)="Initiator Of Activity"
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X1
  1. S LINE=LINE+1,$P(^TMP("PSOERXHL",$J,LINE,0),"=",79)="="
  1. I '$D(^PSRX("D",ERXHUB,"PHARMACY")) S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="No Activity Log Available"
  1. F S PSRX=$O(^PSRX("D",ERXHUB,"PHARMACY",PSRX)) Q:'PSRX D
  1. . I '$D(^PSRX(PSRX,"A")) Q
  1. . F S AUD=$O(^PSRX(PSRX,"A",AUD)) Q:'AUD D
  1. . . S ZAUD=$G(^PSRX(PSRX,"A",AUD,0))
  1. . . S IENS=AUD_","_PSRX_","
  1. . . I $$GET1^DIQ(52.3,IENS,.02,"I")="M" Q
  1. . . S DATETIME=$P(ZAUD,"^",1)
  1. . . S EDITEDBY=$P(ZAUD,"^",3)
  1. . . S FILL=$P(ZAUD,"^",4)
  1. . . S COMMENT=$P(ZAUD,"^",5)
  1. . . S FILL=$S(FILL>0&(FILL<6):"REFILL "_FILL,FILL=6:"PARTIAL",FILL>6:"REFILL "_(FILL-1),1:"ORIGINAL")
  1. . . S X2=$$FMTE^XLFDT(DATETIME,"2Z"),$E(X2,19)=$$GET1^DIQ(52.3,IENS,.02,"E"),$E(X2,41)=FILL,$E(X2,57)=$E($$GET1^DIQ(200,EDITEDBY,.01),1,24)
  1. . . S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X2
  1. . . I $G(COMMENT)'="" S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Comments: "_$P(ZAUD,"^",5),HIGHLN(LINE)="1^80"
  1. ;
  1. N PSRX,AUD,ZAUD,ZAUD1,TRANS,SEQNO,FILL,FILLD,STAT,STATD,BREF,DATE,NDC,COMMENTS,CARR,PKGID,FLDNAME,X1,X2,X3
  1. S PSRX=$$GET1^DIQ(52.49,PSOERXID,.13,"I")
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=""
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="CMOP Event Log:",REVLN(LINE)="1^15"
  1. S X1="Date/Time",$E(X1,19)="Rx Ref",$E(X1,28)="TRN-Order",$E(X1,42)="Stat",$E(X1,62)="NDC"
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X1
  1. S LINE=LINE+1,$P(^TMP("PSOERXHL",$J,LINE,0),"=",79)="="
  1. I '$G(PSRX) S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="No CMOP Log Available"
  1. I $G(PSRX),'$D(^PSRX(PSRX,4)) S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="No CMOP Log Available"
  1. I $G(PSRX),$D(^PSRX(PSRX,4)) D
  1. . S AUD=0 ;CMOP LOOP
  1. . F S AUD=$O(^PSRX(PSRX,4,AUD)) Q:'AUD D
  1. . . S ZAUD=$G(^PSRX(PSRX,4,AUD,0))
  1. . . S ZAUD1=$G(^PSRX(PSRX,4,AUD,1))
  1. . . S TRANS=$P(ZAUD,U) ;Transmission #
  1. . . S SEQNO=$P(ZAUD,U,2) ;Sequence #
  1. . . S FILL=$P(ZAUD,U,3) ;Rx Indicator
  1. . . S FILLD=$S(FILL>0&(FILL<6):"REFILL "_FILL,FILL=6:"PARTIAL",FILL>6:"REFILL "_(FILL-1),1:"ORIGINAL")
  1. . . S STAT=$P(ZAUD,U,4) ;Status
  1. . . S STATD=$$STATDSP(STAT)
  1. . . S BREF=$G(TRANS)_"-"_$G(SEQNO)
  1. . . S DATE=$$CMOPDT(PSRX,FILL) ;Date
  1. . . S NDC=$P(ZAUD,U,8) ;NDC Received
  1. . . S COMMENTS=$S($G(STAT)=3:$E($P($G(ZAUD1),"^"),1,35),$G(NDC)'="":"NDC: "_NDC,1:"") ;They only want to see comments if STATUS=3/Not Dispensed
  1. . . S CARR=$P(ZAUD1,U,3) ;Carrier
  1. . . S PKGID=$P(ZAUD1,U,4) ;Package ID
  1. . . S X2=$$FMTE^XLFDT(DATE,"2Z"),$E(X2,19)=FILLD,$E(X2,28)=BREF,$E(X2,42)=STATD,$E(X2,62)=NDC
  1. . . S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X2
  1. . . S X3="Carrier: "_CARR,$E(X3,28)="Package ID: "_PKGID
  1. . . S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X3
  1. . . I $G(COMMENTS)'="" S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Comments: "_COMMENTS,HIGHLN(LINE)="1^80"
  1. ;
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=""
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)="Change, Cancel, Renewal Log:",REVLN(LINE)="1^28"
  1. S X1="Date/Time",$E(X1,19)="MessageType",$E(X1,37)="eRx ID",$E(X1,63)="eRx Order Status"
  1. S LINE=LINE+1,^TMP("PSOERXHL",$J,LINE,0)=X1,UNDLN(LINE)="1^80"
  1. N FLAG,MTYPE,REQIEN,REQID,RESIEN,RESID,RELERX,RELMES,RELTYPE,RESTYPE,REQTYPE
  1. S (FLAG,RELMES)=0
  1. S MTYPE=$$GET1^DIQ(52.49,PSOERXID,.08,"I")
  1. I ",RR,CA,CR,"[(","_MTYPE_",") D
  1. . S FLAG=1,REQIEN=PSOERXID,RESIEN=$$GETRESP^PSOERXU2(PSOERXID) ;If the message is a Request
  1. . S RESTYPE=$$GET1^DIQ(52.49,RESIEN,.08,"I")
  1. . I ",N,RR,CA,CR,"[(","_RESTYPE_",") S RESIEN=""
  1. I ",RE,CN,CX,"[(","_MTYPE_",") D
  1. . S FLAG=1,RESIEN=PSOERXID,REQIEN=$$RESOLV^PSOERXU2(PSOERXID) ;If the message is a Response
  1. . S REQTYPE=$$GET1^DIQ(52.49,REQIEN,.08,"I")
  1. . I ",N,RE,CN,CX,"[(","_REQTYPE_",") S REQIEN=""
  1. I ",N,"[(","_MTYPE_",") D ;If the message is a New eRx
  1. . D GETDATA^PSOERHL1(PSOERXID)
  1. . F S RELMES=$O(^PS(52.49,PSOERXID,201,"B",RELMES)) Q:'RELMES D
  1. . . S RELTYPE=$$GET1^DIQ(52.49,RELMES,.08,"I")
  1. . . I ",RR,CA,CR,RE,CN,CX,"[(","_RELTYPE_",") D
  1. . . . D GETDATA^PSOERHL1(RELMES)
  1. I MTYPE="IE" S FLAG=1,RESIEN=PSOERXID,REQIEN=$$RESOLV^PSOERXU2(PSOERXID) ;If the message is an Inbound Error
  1. ;Inbound Error, Request and Response below
  1. I $G(FLAG) D
  1. . I $G(REQIEN)'="" S REQID=$$GET1^DIQ(52.49,REQIEN,.01,"E"),RELERX=$$GET1^DIQ(52.49,REQIEN,.14)
  1. . I $G(RESIEN)'="" S RESID=$$GET1^DIQ(52.49,RESIEN,.01,"E")
  1. . I $G(RELERX)'="" D ;New eRX
  1. . . N ERXIEN S ERXIEN=$O(^PS(52.49,"B",RELERX,0))
  1. . . D GETDATA^PSOERHL1(ERXIEN)
  1. . I $G(REQID)'="" D ;Request
  1. . . N ERXIEN S ERXIEN=$O(^PS(52.49,"B",REQID,0))
  1. . . D GETDATA^PSOERHL1(ERXIEN)
  1. . I $G(RESID)'="" D ;Response
  1. . . N ERXIEN S ERXIEN=$O(^PS(52.49,"B",RESID,0))
  1. . . D GETDATA^PSOERHL1(ERXIEN)
  1. Q
  1. ;
  1. STATDSP(STAT) ;Determine Status to display
  1. ;0:TRANSMITTED
  1. ;1:DISPENSED
  1. ;2:RETRANSMITTED
  1. ;3:NOT DISPENSED
  1. N STATD
  1. S:STAT=0 STATD="TRAN"
  1. S:STAT=1 STATD="DISP"
  1. I $G(STATD)="DISP" D
  1. . I FILL>0,('$D(^PSRX(PSRX,1,FILL,0))) S STATD="DISP Refill Deleted" Q
  1. S:STAT=2 STATD="RTRN"
  1. S:STAT=3 STATD="NDISP"
  1. Q STATD
  1. ;
  1. CMOPDT(PSRX,FILL) ;Determine date to display
  1. ;Use Cancelled DT/TM first if available
  1. ;If Cancelled DT/TM is not populated, use Release DT/TM
  1. ;If Release DT/TM is not populated, use Transmission Create DT/TM
  1. ;
  1. N CANDT,CDATE
  1. I $G(STAT)=3 S CANDT=$P(ZAUD,U,5) I CANDT'="" Q CANDT ;Cancelled DT/TM
  1. ;If status = 3 (not dispensed) and there is a cancelled date/time then quit with the cancelled date/time
  1. I $G(STAT)=1 D
  1. . S CDATE=$S(FILL=0:$P(^PSRX(PSRX,2),"^",13),1:$P(^PSRX(PSRX,1,FILL,0),"^",18))
  1. . ;If Original Fill set to Released Date/Time (node 2 piece 13)
  1. . ;If Fill greater than 0 (not Original) set to Released Date in the Refill Node (node 1 piece 18)
  1. I $G(STAT)=3,'FILL,$$GET1^DIQ(52,PSRX,32.1,"I") Q $$FMTE^XLFDT($$GET1^DIQ(52,PSRX,32.1,"I"),2) ;If original fill and RTS
  1. I $G(STAT)=3,FILL,$$GET1^DIQ(52.1,FILL_","_PSRX,5,"I") Q $$FMTE^XLFDT($$GET1^DIQ(52.1,FILL_","_PSRX,32.1,"I"),2) ;If refill and there is a lot#
  1. I '$G(CDATE) D
  1. . S CDATE=$P(^PSX(550.2,TRANS,0),"^",6) ;Transmission DT/TM
  1. Q $G(CDATE)
  1. ;
  1. REFRESH ;Screen Refresh
  1. W ?52,"Please wait..." D INIT,HDR S VALMBCK="R"
  1. Q
  1. ;
  1. EXIT ;
  1. K ^TMP("PSOERXHL",$J)
  1. Q
  1. ;
  1. HELP Q
  1. ;