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

PSOERUT2.m

Go to the documentation of this file.
  1. PSOERUT2 ;ALB/MFR - eRx Drug on Holding Queue - Listman Utilities; 06/25/2022 5:14pm
  1. ;;7.0;OUTPATIENT PHARMACY;**700,746,769**;DEC 1997;Build 26
  1. ;
  1. SETDRUG(MODE,NMSPC,ERXIEN,SUGGEST,RXIEN,SDERXFLG) ; Set ListMan Side-By-Side Section for eRx Vs. User entered data on Holding Queue
  1. ;Input: MODE - Display Mode: "RS": Roll & Scroll | "LM": ListMan
  1. ; (o)NMSPC - ListMan Temp Global Namespace (e.g., "PSOERXP1") - Required for LM Mode only
  1. ; ERXIEN - Pointer to ERX HOLDING QUEUE file (#52.49)
  1. ; SUGGEST - Suggestion?: 1 - YES (Suggesting an entry - MUST pass in RX # Pointer to #52) | 0 - NO (Actual Record Data)
  1. ; (o)RXIEN - Prescription IEN - Pointer to PRESCRIPTION file (#52). SUGGEST must be passed in as 1
  1. ; (o)SDERXFLG - Single eRx View/Display Flag - 1: Single eRx View/Display Interface | 0: eRx Holding Queue Interface
  1. ; Input Global Variable: LINE - Current ListMan Line # (Default)
  1. ; Output Global Variable: (ListMan Mode Only - Set by $$COMPARE^PSOERUT0)
  1. ; REVLN - Array Indicating Reverse Video for Line, position and size of the string
  1. ; HIGLN - Array Indicating Highlight for Line, position and size of the string
  1. ;
  1. S:'$G(LINE) LINE=1 S NMSPC=$G(NMSPC)
  1. N V2017,MTYPE,RSPTYPE,ERXDM,DATA,ERXDRUG,ERXSIG,ERXNOTES,ERXQTY,ERXQTYUM,ERXQTYQ,ERXDAYS,ERXREFS,ERXWRTDT,ERXEFDT,ERXRENS
  1. N VADRGIEN,VAOIIEN,VADRUG,VAPATIEN,RXPATIEN,VAPATINS,VAPRCOMM,VAQTY,VADAYS,VAREFS,VAQTYUM,VADRGMSG,ESIG,VSIG,FSIG,XE,XV
  1. N ERXDFORM,ERXDSTRE,XEI,XVI,I,DMARR,LMLINE,MEDIEN,VDRGLEN,VAPATSTS,VMAILWIN,VACLINIC,NONFORM,PSODIR,INS1,ARR,EARR,VARR
  1. N ERXSUBS,X,EQCOMM,EQDRUG,VAQTDMSG
  1. ;
  1. S V2017=+$$GET1^DIQ(52.49,ERXIEN,312.1,"I")
  1. S MTYPE=$$GET1^DIQ(52.49,ERXIEN,.08,"I")
  1. S RSPTYPE=$$GET1^DIQ(52.49,ERXIEN,52.1,"I")
  1. I V2017 D
  1. . I MTYPE="CX" S MEDIEN=$O(^PS(52.49,ERXIEN,311,"C","P",0))
  1. . I MTYPE="N" S MEDIEN=$O(^PS(52.49,ERXIEN,311,0)) Q
  1. . I MTYPE="RE",RSPTYPE="R" S MEDIEN=$O(^PS(52.49,ERXIEN,311,"C","MR",0))
  1. I '$G(MEDIEN) S MEDIEN=1
  1. ; eRx Data
  1. D GETS^DIQ(52.49,ERXIEN_",",".05;2.3;3.1;3.2;4.1;4.11;4.9;5.1;5.2;5.5;5.6;5.7;5.8;5.9;6.3;8;20.1;20.2;20.4;20.6;20.5;41;42;43","EI","DATA","ERR") I '$D(DATA) Q
  1. M ERXDM=DATA(52.49,ERXIEN_",")
  1. S ERXDRUG=ERXDM(3.1,"E"),ERXSIG=$$ERXSIG^PSOERXUT(ERXIEN)
  1. S ERXNOTES=ERXDM(8,"E"),ERXQTY=ERXDM(5.1,"E"),ERXDAYS=ERXDM(5.5,"E"),ERXWRTDT=ERXDM(5.9,"E"),ERXEFDT=ERXDM(6.3,"E")
  1. ; eRx Quantity Qualifier
  1. S ERXQTYQ=ERXDM(5.2,"E") I V2017 S ERXQTYQ=$$GET1^DIQ(52.49311,MEDIEN_","_ERXIEN_",",2.2,"I"),ERXQTYQ=$$GET1^DIQ(52.45,ERXQTYQ,.02,"E")
  1. ; Number of Refills
  1. S ERXREFS=ERXDM(5.6,"E") I MTYPE="RE",RSPTYPE="R",ERXREFS>0 S ERXREFS=$G(ERXREFS)-1
  1. S ERXSUBS=$S(ERXDM(5.8,"I")=1:"NO",ERXDM(5.8,"I")=0:"YES",1:""),ERXRENS=$S($$RENEWALS^PSOERXUT(ERXIEN):"YES",1:"NO")
  1. S ERXDFORM=ERXDM(41,"E"),ERXQTYUM=ERXDM(42,"E"),ERXDSTRE=ERXDM(43,"E")
  1. ; VistA Drug/Dose/Instructions Data
  1. S (VADRUG,VASIG,VAPATIEN,VAPATINS,VAPRCOMM,VAQTY,VADAYS,VAREFS,VAQTYUM,VADRGMSG,VAQTDMSG,VAPATSTS,VMAILWIN,VACLINIC)=""
  1. S VADRGIEN=+ERXDM(3.2,"I")
  1. I $G(VADRGIEN) D
  1. . S VAPATIEN=ERXDM(.05,"I"),VAPATSTS=$$GET1^DIQ(55,VAPATIEN,3,"E"),VADRUG=ERXDM(3.2,"E")
  1. . S VASIG=$$VISTASIG^PSOERXUT(ERXIEN),VAPATINS=$$GET1^DIQ(52.49,ERXIEN,27),VAPRCOMM=$$GET1^DIQ(52.49,ERXIEN,30)
  1. . S VAQTY=ERXDM(20.1,"E"),VADAYS=ERXDM(20.2,"E"),VMAILWIN=ERXDM(20.4,"E"),VAREFS=ERXDM(20.5,"E"),VACLINIC=ERXDM(20.6,"E")
  1. . S VAQTYUM=$$GET1^DIQ(50,VADRGIEN,14.5),VADRGMSG=$$GET1^DIQ(50,VADRGIEN,101),VAQTDMSG=$$GET1^DIQ(50,VADRGIEN,215)
  1. ;
  1. ; Non-Formulary
  1. S NONFORM=0 I $G(VADRGIEN),$P(^PSDRUG(VADRGIEN,0),"^",9) S NONFORM=1
  1. ;
  1. I $G(RXIEN) D
  1. . S RXPATIEN=+$$GET1^DIQ(52,RXIEN,2,"I"),VADRGIEN=+$$GET1^DIQ(52,RXIEN,6,"I"),VAOIIEN=+$$GET1^DIQ(50,VADRGIEN,2.1,"I")
  1. . S VADRUG=$$GET1^DIQ(50,VADRGIEN,.01)
  1. . ; Rx SIG (from Rx) & Qty fields
  1. . S VASIG=$$SUGSIG^PSOERUT3(RXIEN,ERXIEN)
  1. . S VAQTY=$$GET1^DIQ(52,RXIEN,7),VAQTYUM=$$GET1^DIQ(50,VADRGIEN,14.5)
  1. . S VADRGMSG=$$GET1^DIQ(50,VADRGIEN,101),VAQTDMSG=$$GET1^DIQ(50,VADRGIEN,215)
  1. . ; Days Supply and # of Refills
  1. . S VADAYS=$$GET1^DIQ(52,RXIEN,8)
  1. . S VAREFS=$$GET1^DIQ(52,RXIEN,9)
  1. . ; If #of Refills > Max allowed, sets to Max allowed
  1. . I VAREFS>$$MAXNUMRF^PSOUTIL(VADRGIEN,VADAYS) D
  1. . . S VAREFS=+$$MAXNUMRF^PSOUTIL(VADRGIEN,VADAYS)
  1. . I $G(SUGGEST) D
  1. . . ; VA Provider Comments (from eRx)
  1. . . S VAPRCOMM=$$PROVCOMM^PSOERUT4(ERXNOTES)
  1. ;
  1. ; - Drug Matching Header Line
  1. I $G(SDERXFLG) D DRUGHDR^PSOERX1H
  1. ;
  1. S EQDRUG=0 I ($$CLNSTR^PSOERUT0(ERXDRUG)[$$CLNSTR^PSOERUT0(VADRUG))!($$CLNSTR^PSOERUT0(VADRUG)[$$CLNSTR^PSOERUT0(ERXDRUG)) S EQDRUG=1
  1. S XE="Drug: "_$$COMPARE^PSOERUT0(MODE,$E(ERXDRUG,1,33),$S(EQDRUG:$E(ERXDRUG,1,33),1:""),7,,,'VADRGIEN)
  1. S VDRGLEN=$S($G(SDERXFLG):34,MODE="LM":32,1:33)
  1. S XV="|"_$S($G(SDERXFLG):"",MODE="LM":"1)",1:"")_"Drug: "_$$COMPARE^PSOERUT0(MODE,$E(VADRUG,1,VDRGLEN),$S(EQDRUG:$E(VADRUG,1,VDRGLEN),1:""),$S('$G(SDERXFLG):81-VDRGLEN,1:47))
  1. I MODE="LM",'$G(SDERXFLG) S UNDERLN(LINE,41)=2
  1. D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. I $L(ERXDRUG)>33!($L(VADRUG)>VDRGLEN) D
  1. . N XEDR,XVDR
  1. . S XEDR=$E(ERXDRUG,34,999),XVDR=$E(VADRUG,VDRGLEN+1,999)
  1. . F Q:(XEDR=""&(XVDR="")) D
  1. . . S XE=" "_$$COMPARE^PSOERUT0(MODE,$E(XEDR,1,33),$S(EQDRUG:$E(XEDR,1,33),1:""),7,,,'VADRGIEN)
  1. . . S XV="|"_$S($G(SDERXFLG):"",MODE="LM":" ",1:"")_" "_$$COMPARE^PSOERUT0(MODE,$E(XVDR,1,VDRGLEN),$S(EQDRUG:$E(XVDR,1,VDRGLEN),1:""),$S('$G(SDERXFLG):81-VDRGLEN,1:47))
  1. . . D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. . . S XEDR=$E(XEDR,34,999),XVDR=$E(XVDR,VDRGLEN+1,999)
  1. S XEI=0,XVI=0,LMLINE=LINE-1 K EARR,VARR
  1. I ERXDFORM'="" D
  1. . S XEI=XEI+1,LMLINE=LMLINE+1,EARR(XEI)="Drug Form: "_$$COMPARE^PSOERUT0(MODE,$E(ERXDFORM,1,28),$E(ERXDFORM,1,28),12,,LMLINE)
  1. . I $L(ERXDFORM)>28 D
  1. . . S XEI=XEI+1,LMLINE=LMLINE+1,EARR(XEI)=" "_$$COMPARE^PSOERUT0(MODE,$E(ERXDFORM,29,56),$E(ERXDFORM,29,56),12,,LMLINE)
  1. . . I $L(ERXDFORM)>56 D
  1. . . . S XEI=XEI+1,LMLINE=LMLINE+1,EARR(XEI)=" "_$$COMPARE^PSOERUT0(MODE,$E(ERXDFORM,57,84),$E(ERXDFORM,57,84),12,,LMLINE)
  1. I ERXDSTRE'="",$$UP^XLFSTR(ERXDSTRE)'="UNSPECIFIED" D
  1. . S XEI=XEI+1,LMLINE=LMLINE+1,EARR(XEI)="Drug Strength: "_$$COMPARE^PSOERUT0(MODE,ERXDSTRE,ERXDSTRE,16,,LMLINE)
  1. S XEI=XEI+1,LMLINE=LMLINE+1,EARR(XEI)="Substitution? "_$$COMPARE^PSOERUT0(MODE,ERXSUBS,$S(ERXSUBS'="":ERXSUBS,1:""),15,,LMLINE)
  1. S EARR(XEI)=EARR(XEI)_" Renewals? "_$$COMPARE^PSOERUT0(MODE,ERXRENS,ERXRENS,$S(ERXSUBS="YES":32,ERXSUBS="NO":31,1:29),,LMLINE)
  1. I NONFORM!($G(VADRGMSG)'="") S LMLINE=LINE-1
  1. I NONFORM D
  1. . S XVI=XVI+1,LMLINE=LMLINE+1,VARR(XVI)=$S($G(SDERXFLG):"",MODE="LM":" ",1:"")_" "_$$COMPARE^PSOERUT0(MODE,"*** NON-FORMULARY ***","*** NON-FORMULARY ***",$S('$G(SDERXFLG):49,1:47),,LMLINE)
  1. I $G(VADRGMSG)'="" D
  1. . S XVI=XVI+1,LMLINE=LMLINE+1,VARR(XVI)="Drug Message:"
  1. . K DMARR D WRAP^PSOERUT(VADRGMSG,38,.DMARR)
  1. . F I=1:1 Q:'$D(DMARR(I)) D
  1. . . S XVI=XVI+1,LMLINE=LMLINE+1,VARR(XVI)=" "_$$COMPARE^PSOERUT0(MODE,DMARR(I,0),DMARR(I,0),42,,LMLINE)
  1. ;
  1. F I=1:1 Q:('$D(EARR(I))&'$D(VARR(I))) D
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,$G(EARR(I)),"|"_$G(VARR(I)))
  1. I '$G(SDERXFLG) K LMLINE D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - eRx SIG
  1. K EARR D WRAP^PSOERUT(ERXSIG,38,.EARR)
  1. ; - VistA SIG
  1. K VARR D WRAP^PSOERUT($G(VASIG),39,.VARR)
  1. S XE="SIG:",XV="|SIG:" D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. F I=1:1 Q:('$D(EARR(I))&'$D(VARR(I))) D
  1. . S XE=" "_$$COMPARE^PSOERUT0(MODE,$G(EARR(I,0)),$G(EARR(I,0)),2)
  1. . S XV="| "_$$COMPARE^PSOERUT0(MODE,$G(VARR(I,0)),$G(VARR(I,0)),42)
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - Prescriber Drug Use Evaluation (DUE), Dosage and Patient Instructions information
  1. I MODE="LM" D
  1. . D DOSEDUE^PSOERUT7(MODE,NMSPC,ERXIEN,$G(SDERXFLG))
  1. . I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - Provider Notes/Comments
  1. I '$G(SUGGEST)!(ERXNOTES'="")!(VAPRCOMM'="") D
  1. . S EQCOMM=0 I $$PROVCOMM^PSOERUT4(ERXNOTES)=VAPRCOMM S EQCOMM=1
  1. . K EARR D WRAP^PSOERUT(ERXNOTES,38,.EARR)
  1. . K VARR D WRAP^PSOERUT($G(VAPRCOMM),38,.VARR)
  1. . S XE="Provider Notes/Comments:",XV="|"_$S($G(SDERXFLG):"",MODE="LM":"4)",1:"")_"Provider Comments:"
  1. . I MODE="LM",'$G(SDERXFLG) S UNDERLN(LINE,41)=2
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. . F I=1:1 Q:('$D(EARR(I))&'$D(VARR(I))) D
  1. . . S XE=" "_$$COMPARE^PSOERUT0(MODE,$G(EARR(I,0)),$S(EQCOMM:$G(EARR(I,0)),1:$G(VARR(I,0))),2)
  1. . . S XV="| "_$$COMPARE^PSOERUT0(MODE,$G(VARR(I,0)),$S(EQCOMM:$G(VARR(I,0)),1:$G(EARR(I,0))),42)
  1. . . D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. . I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. ; - Patient Status
  1. I (MODE="LM"),'$G(SDERXFLG) D
  1. . S XV="|"_$S($G(SDERXFLG):"",1:"5)")_"Pat. Status: "_$$COMPARE^PSOERUT0(MODE,VAPATSTS,VAPATSTS,56)
  1. . S UNDERLN(LINE,41)=2
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,"",XV)
  1. . I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - Quantity
  1. S XE="Quantity: "_$$COMPARE^PSOERUT0(MODE,ERXQTY,VAQTY,11,,,'VADRGIEN)
  1. S XV="|"_$S($G(SDERXFLG):"",MODE="LM":"6)",1:"")_"Quantity: "_$$COMPARE^PSOERUT0(MODE,VAQTY,ERXQTY,$S($G(SDERXFLG):51,MODE="LM":53,1:51))
  1. I MODE="LM",'$G(SDERXFLG) S UNDERLN(LINE,41)=2
  1. D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. ; - Dispense Unit
  1. S XE="Dispense Unit: "_$$COMPARE^PSOERUT0(MODE,$E(ERXQTYUM,1,24),$E(ERXQTYUM,1,24),16)
  1. S XV="|"_$S(MODE="LM":" ",1:"")_"Dispense Unit: "_$$COMPARE^PSOERUT0(MODE,$G(VAQTYUM),$G(VAQTYUM),$S(MODE="LM":58,1:56))
  1. D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. I $L(ERXQTYUM)>24 D
  1. . S XE=$E(ERXQTYUM,25,99),XV="|" D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. ;
  1. S XEI=0,XVI=0,LMLINE=LINE-1 K EARR,VARR
  1. ; - Quantity Qualifier
  1. I $G(ERXQTYQ)'=""!($G(VAQTDMSG)'="") D
  1. . S LMLINE=LMLINE+1
  1. . I '$G(SUGGEST),$G(ERXQTYQ)'="" S XEI=XEI+1,EARR(XEI)="Qty Qualifier: "_$$COMPARE^PSOERUT0(MODE,ERXQTYQ,ERXQTYQ,16,,LMLINE)
  1. . ; - VistA Dispense Message
  1. . I $G(VAQTDMSG)'="" D
  1. . . S XVI=XVI+1,LMLINE=LMLINE+1,VARR(XVI)="QTY Dispense Message:"
  1. . . K DMARR D WRAP^PSOERUT(VAQTDMSG,38,.DMARR)
  1. . . F I=1:1 Q:'$D(DMARR(I)) D
  1. . . . I MODE="LM" S HIGUNDLN(LMLINE,42)=$L(DMARR(I,0))
  1. . . . E S DMARR(I,0)=$G(IOINHI)_$G(IOUON)_DMARR(I,0)_$G(IOUOFF)_$G(IOINORM)
  1. . . . S XVI=XVI+1,LMLINE=LMLINE+1,VARR(XVI)=" "_DMARR(I,0)
  1. ;
  1. F I=1:1 Q:('$D(EARR(I))&'$D(VARR(I))) D
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,$G(EARR(I)),"|"_$G(VARR(I)))
  1. I '$G(SDERXFLG) K LMLINE D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - Days Supply & Number of Refills
  1. S XE="Days Supply: "_$$COMPARE^PSOERUT0(MODE,ERXDAYS,VADAYS,14,,,'VADRGIEN)
  1. S $E(XE,$S(MODE="LM"!(ERXDAYS=""):21,1:$L(XE)+6))="Refills: "_$$COMPARE^PSOERUT0(MODE,ERXREFS,VAREFS,30,,,'VADRGIEN)
  1. S XV="|"_$S($G(SDERXFLG):"",MODE="LM":"7)",1:"")_"Days Supply: "_$J($$COMPARE^PSOERUT0(MODE,VADAYS,ERXDAYS,$S($G(SDERXFLG):54,MODE="LM":56,1:54)),$L(VADAYS))
  1. S XV=XV_" "_$S($G(SDERXFLG):"",MODE="LM":"8)",1:"")_"Refills: "_$$COMPARE^PSOERUT0(MODE,VAREFS,ERXREFS,$S($G(SDERXFLG):68,MODE="LM":72,1:70)+$L(VADAYS))
  1. I MODE="LM",'$G(SDERXFLG) S UNDERLN(LINE,41)=2,UNDERLN(LINE,61+$L(VADAYS))=2
  1. D ADDLINE^PSOERUT0(MODE,NMSPC,XE,XV)
  1. I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - Routing (Mail/Window)
  1. I MODE="LM" D
  1. . S XV="|"_$S($G(SDERXFLG):"",1:"9)")_"Routing: "_$$COMPARE^PSOERUT0(MODE,VMAILWIN,VMAILWIN,$S($G(SDERXFLG):50,1:52))
  1. . I '$G(SDERXFLG) S UNDERLN(LINE,41)=2
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,"",XV)
  1. . I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. ;
  1. ; - Clinic
  1. I MODE="LM" D
  1. . S XV="|"_$S($G(SDERXFLG):"",1:"10)")_"Clinic: "_$$COMPARE^PSOERUT0(MODE,VACLINIC,VACLINIC,$S($G(SDERXFLG):49,1:52))
  1. . I MODE="LM",'$G(SDERXFLG) S UNDERLN(LINE,41)=3
  1. . D ADDLINE^PSOERUT0(MODE,NMSPC,"",XV)
  1. . I '$G(SDERXFLG) D BLANKLN^PSOERUT0(MODE)
  1. Q
  1. ;
  1. SAVEDRUG(ERXIEN,RXIEN) ; Save eRx Drug Information from VistA Rx (File #52) into the eRx record (File #52.49)
  1. ;Input: ERXIEN - eRx IEN - Pointer to ERX HOLDING QUEUE file (#52.49)
  1. ; RXIEN - VistA Prescription IEN - Pointer to PRESCRIPTION file (#52)
  1. ;
  1. I '$D(^PS(52.49,+$G(ERXIEN),0))!'$D(^PSRX(+$G(RXIEN),0)) Q
  1. N VAPATIEN,VADRGIEN,VAOIIEN,DIE,DA,NEWVAL,MTYPE,ERXSTS,VADOSE,DOSE,UPDARR,VAPATINS,ERR,SIG,SIGARR,ERXSIG
  1. N PSODRUG,VAQTY,VADAYS,VAREFS,I
  1. S VADRGIEN=+$$GET1^DIQ(52,RXIEN,6,"I"),VAOIIEN=+$$GET1^DIQ(50,VADRGIEN,2.1,"I")
  1. ; - Updating eRx Audit Log
  1. S NEWVAL(1)=$$GET1^DIQ(50,VADRGIEN,.01)_" (NDC#: "_$$GETNDC^PSSNDCUT(VADRGIEN)_")"
  1. D AUDLOG^PSOERXUT(ERXIEN,"DRUG",DUZ,.NEWVAL)
  1. ; - Saving VistA Drug
  1. S DIE="^PS(52.49,",DA=ERXIEN,DR="3.2///"_VADRGIEN D ^DIE
  1. ;
  1. ; - eRx Status Update
  1. S MTYPE=$$GET1^DIQ(52.49,ERXIEN,.08,"I")
  1. S ERXSTS=$$GET1^DIQ(52.49,ERXIEN,1,"E")
  1. I ERXSTS="N" D UPDSTAT^PSOERXU1(ERXIEN,"I")
  1. I MTYPE="RE",ERXSTS'="RXI" D UPDSTAT^PSOERXU1(ERXIEN,"RXI")
  1. ;
  1. ; - Deleting fields related to VA Dispense Drug
  1. F FLD=1.11,1.12,1.5,20.1,20.2,20.3,20.4,20.5,27 S UPDARR(52.49,ERXIEN_",",FLD)="@"
  1. D FILE^DIE(,"UPDARR") K UPDARR
  1. ;
  1. ; - Updating Audit Log
  1. S NEWVAL(1)=$$PROVCOMM^PSOERUT4($$GET1^DIQ(52.49,ERXIEN,8))
  1. I $G(NEWVAL(1))'="" D AUDLOG^PSOERXUT(ERXIEN,"PROVIDER COMMENTS",DUZ,.NEWVAL)
  1. ; - Saving Provider Comments
  1. K UPDARR S UPDARR(52.49,ERXIEN_",",30)=$$PROVCOMM^PSOERUT4($$GET1^DIQ(52.49,ERXIEN,8))
  1. D FILE^DIE(,"UPDARR") K UPDARR
  1. ;
  1. ; - Saving VA Orderable Item Patient Instructions and Updating Audit Log
  1. S VAPATIEN=+$$GET1^DIQ(52.49,ERXIEN,.05,"I")
  1. S VAPATINS=$$VAPATINS^PSOERUT3(VAOIIEN,VAPATIEN)
  1. I VAPATINS'="" D
  1. . ; - Updating Audit Log
  1. . S NEWVAL(1)=VAPATINS
  1. . D AUDLOG^PSOERXUT(ERXIEN,"PATIENT INSTRUCTIONS",DUZ,.NEWVAL)
  1. . ; - Saving Provider Comments
  1. . K UPDARR S UPDARR(52.49,ERXIEN_",",27)=VAPATINS
  1. . D FILE^DIE(,"UPDARR") K UPDARR
  1. ;
  1. ; - Deleting any existing Dosage Information
  1. K VADOSE S DOSE=0 F S DOSE=$O(^PS(52.49,ERXIEN,21,DOSE)) Q:'DOSE D
  1. . S VADOSE(52.4921,DOSE_","_ERXIEN_",",.01)="@" D FILE^DIE(,"VADOSE","ERR") K VADOSE
  1. ;
  1. ; - Retrieving VistA Rx Dose and Saving to the eRx
  1. K VADOSE D VARXDOSE^PSOERUT4(RXIEN,.VADOSE)
  1. K ERXDOSE
  1. F DOSE=1:1 Q:'$D(VADOSE("DOSE",DOSE)) D
  1. . K ERXDOSE,ERR
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",.01)=VADOSE("DOSE",DOSE)_"&"_VADOSE("NOUN",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",1)=VADOSE("SCHEDULE",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",2)=VADOSE("DURATION",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",6)=$S($G(VADOSE("CONJUNCTION",DOSE))="T":"S",1:$G(VADOSE("CONJUNCTION",DOSE)))
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",7)=+DOSE
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",8)=VADOSE("DOSE",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",9)=VADOSE("DOSE ORDERED",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",10)=VADOSE("ROUTE",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",11)=VADOSE("UNITS",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",12)=VADOSE("NOUN",DOSE)
  1. . S ERXDOSE(52.4921,"+1,"_ERXIEN_",",13)=VADOSE("VERB",DOSE)
  1. . D UPDATE^DIE("","ERXDOSE","ERR","")
  1. ;
  1. ; - Deleting any existing SIG Information
  1. K SIGARR
  1. S I=0 F S I=$O(^PS(52.49,ERXIEN,"SIG",I)) Q:'I D
  1. . S SIGARR(52.4926,I_","_ERXIEN_",",.01)="@"
  1. I $D(SIGARR) D FILE^DIE(,"SIGARR") K SIGARR
  1. ; - Retrieving VistA Rx SIG and Saving to the eRx
  1. S PSODRUG("IEN")=VADRGIEN,PSODRUG("OI")=VAOIIEN
  1. K SIG D EN^PSOFSIG(.VADOSE)
  1. ;Saving the eRx Audit Log for the SIG
  1. D AUDLOG^PSOERXUT(+PSOIEN,"SIG",DUZ,.SIG)
  1. K SIGARR
  1. S I=0 F S I=$O(SIG(I)) Q:'I D
  1. . I $G(SIG(I))'="" D
  1. . . S SIGARR(52.4926,"+1,"_ERXIEN_",",.01)=SIG(I)
  1. . . D UPDATE^DIE(,"SIGARR",,"SERR") K SIGARR
  1. ;
  1. ; - Qty/Days Supply/Route(Mail/Window)/# of Refills/Clinic (Auditing & Saving)
  1. S (VAQTY,NEWVAL(1))=+$$GET1^DIQ(52,RXIEN,7) D AUDLOG^PSOERXUT(ERXIEN,"QTY",DUZ,.NEWVAL)
  1. S (VADAYS,NEWVAL(1))=+$$GET1^DIQ(52,RXIEN,8) D AUDLOG^PSOERXUT(ERXIEN,"DAYS SUPPLY",DUZ,.NEWVAL)
  1. S (VAREFS,NEWVAL(1))=+$$GET1^DIQ(52,RXIEN,9) D AUDLOG^PSOERXUT(ERXIEN,"# OF REFILLS",DUZ,.NEWVAL)
  1. K UPDARR
  1. S UPDARR(52.49,ERXIEN_",",20.1)=+$$GET1^DIQ(52,RXIEN,7)
  1. S UPDARR(52.49,ERXIEN_",",20.2)=$$GET1^DIQ(52,RXIEN,8)
  1. S UPDARR(52.49,ERXIEN_",",20.4)="M"
  1. ; If #of Refills > Max allowed, sets to Max allowed
  1. I VAREFS>$$MAXNUMRF^PSOUTIL(VADRGIEN,VADAYS) D
  1. . S VAREFS=+$$MAXNUMRF^PSOUTIL(VADRGIEN,VADAYS)
  1. S UPDARR(52.49,ERXIEN_",",20.5)=VAREFS
  1. I $G(PSOCLNC) D
  1. . S UPDARR(52.49,ERXIEN_",",20.6)=PSOCLNC
  1. E D
  1. . S UPDARR(52.49,ERXIEN_",",20.6)=$$GET1^DIQ(59,PSOSITE,10,"I")
  1. D FILE^DIE(,"UPDARR") K UPDARR
  1. Q