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