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

PSSDEEA.m

Go to the documentation of this file.
PSSDEEA ;PBM/RMS - DRUG FILE ENTER/EDIT AUDIT ; 18 May 2018  10:55 AM
 ;;1.0;PHARMACY DATA MANAGEMENT;**227**;;Build 18
 ;------------------------------------------------------------------
BEFORE(TAG) ;
 ; Capture the drug entry before it is edited to have to compare to
 ; after the user completes the editing.  Email changes in
 ; linetag 'AFTER' (called at the end of PSSDEE).
 ; From: PSSDEE [PSS DRUG ENTER/EDIT]
 ; Output:
 ;   1. ^UTILITY(TAG,$J,DA)=Drug file entry number DA before editing
 ;   2. ZDA ; DA or IEN of Drug file #50 entry
 ;   3. ZN    ; Will be equal to 1 if a new drug was entered into file
 ;
 ;ZEXCEPT: DA,Y,ZDA,ZN
 ;
 K ^UTILITY(TAG,$J,DA)
 M ^UTILITY(TAG,$J,DA)=^PSDRUG(DA)
 ;
 S ZDA=DA,ZN=$P(Y,"^",3)
 ;
 Q
 ;------------------------------------------------------------------
AFTER(TAG) ;
 ;
 ; DOCUMENTATION AND SETUP INFORMATION
 ;
 ; Modifications:
 ;
 ; * PSSDEE calls BEFORE^PSSDEEA to create ^UTILITY("PSSDEE",$J,DA) data.
 ;   ^UTILITY data holds all ^PSDRUG data for drug prior to any
 ;   editing.
 ; * PSSDEE later calls AFTER^PSSDEEA to compare the value of the drug
 ;   file entry after editing to the pre-snapshot values held in
 ;   ^UTILITY.  If changes have been made, a Mailman message is
 ;   sent to members of a mail group.  (See SETUP below)
 ;
 ; Note: USING the Drug Enter/Edit option is sufficient to trigger
 ; the audit email, even if a non-audited field is the only change
 ; made by the user.
 ;
 ; ZEXCEPT: PSSZMES,PSSZNOC,ANS,CHANGES,COUNT,FIELD,FLAG,LABEL,NEWVAL,OLDVAL,USER,ZDA,ZDAN,ZN,PSSZNODE,ZZJ
EN Q:'$G(ZDA)
 N COUNT,USER S COUNT=6,USER=$P(^VA(200,DUZ,0),"^"),ZDAN=$P(^PSDRUG(ZDA,0),"^")
 D HEADER
 D COMPAR
 D SEND
 K PSSZMES,ZDA,ZDAN,LABEL,PSSZNODE,OLDVAL,NEWVAL,FIELD,CHANGES,FLAG,ZZJ,ANS,ZN,PSSZNOC
 S NEWVAL=""
 Q
 ; ZEXCEPT: PSSZMES,USER,ZDAN
 S PSSZMES(1)="Please Note:  The Drug Enter/Edit option was used by "_USER_"."
 S PSSZMES(2)="The drug that was entered/edited was "_ZDAN_"."
 S PSSZMES(3)="-------------------------------------------------------------------------------"
 Q
COMPAR ;
 ; ZEXCEPT: PSSZMES,ANS,FLAG,LABEL,NEWVAL,OLDVAL,ZDA,TAG,PSSZNOC
 N CHANGES,NEWVAL,OLDVAL,SPACES,PSSZNODE,ZZJ
 S $P(SPACES," ",80)="",PSSZNOC=0
 F PSSZNODE=0,2,3,8.5,660,660.1,"EPH","I","ND" I $G(ZDA) D
 .S:ZN=1 ^UTILITY(TAG,$J,ZDA,PSSZNODE)=""
 .Q:'$D(^PSDRUG(ZDA,PSSZNODE))&('$D(^UTILITY(TAG,$J,ZDA,PSSZNODE)))
 .I '$D(^UTILITY(TAG,$J,ZDA,PSSZNODE))&($D(^PSDRUG(ZDA,PSSZNODE))) S CHANGES(PSSZNODE)=^PSDRUG(ZDA,PSSZNODE)
 .I '$D(^PSDRUG(ZDA,PSSZNODE))&($D(^UTILITY(TAG,$J,ZDA,PSSZNODE))) S CHANGES(PSSZNODE)=^UTILITY(TAG,$J,ZDA,PSSZNODE)
 .Q:$D(CHANGES(PSSZNODE))!('$D(^PSDRUG(ZDA,PSSZNODE)))!('$D(^UTILITY(TAG,$J,ZDA,PSSZNODE)))
 .Q:^UTILITY(TAG,$J,ZDA,PSSZNODE)=^PSDRUG(ZDA,PSSZNODE)
 .S CHANGES(PSSZNODE)=""
 .F ZZJ=1:1:10 S FLAG=0,ANS="" S:$P(^PSDRUG(ZDA,PSSZNODE),"^",ZZJ)'=$P(^UTILITY(TAG,$J,ZDA,PSSZNODE),"^",ZZJ) ANS=$P(^UTILITY(TAG,$J,ZDA,PSSZNODE),"^",ZZJ),FLAG=1 S:FLAG=1&(ANS="") ANS="NULL" S CHANGES(PSSZNODE)=CHANGES(PSSZNODE)_ANS_"^"
 I '$D(CHANGES) S PSSZNOC=1,PSSZMES(4)="     ***   No Audited Changes Made  ***" Q
 S FLAG=0
 F PSSZNODE=0,2,3,8.5,660,660.1,"EPH","I","ND" S LABEL="SUB"_PSSZNODE I $D(CHANGES(PSSZNODE)) F ZZJ=1:1:11 Q:"^^^^^^^^^^^^^^^^^"[$P(CHANGES(PSSZNODE),"^",ZZJ,11)  Q:$P(CHANGES(PSSZNODE),"^",ZZJ,11)=""  D:'$D(^UTILITY(TAG,$J,ZDA)) SETLB Q:FLAG  D
 .S OLDVAL=$P(CHANGES(PSSZNODE),"^",ZZJ) Q:OLDVAL=""  S OLDVAL=OLDVAL_$$OLDEXT(OLDVAL,PSSZNODE,ZZJ)
 .S:$D(^PSDRUG(ZDA,PSSZNODE)) NEWVAL=$P(^PSDRUG(ZDA,PSSZNODE),"^",ZZJ)_$$NEWEXT(ZDA,PSSZNODE,ZZJ)
 .D STOR
 Q
OLDEXT(OLDVAL,PSSZNODE,PIECE) ;COMPUTE EXTERNAL 'OLD' VALUE WHERE NECESSARY
 N FIELDNUM,FIELDTYP,PTRFILE
 S FIELDNUM=$O(^DD(50,"GL",PSSZNODE,PIECE,0))
 Q:'+FIELDNUM ""
 S FIELDTYP=$P(^DD(50,FIELDNUM,0),U,2)
 I $E(FIELDTYP)'="P" Q ""
 S PTRFILE=+$E(FIELDTYP,2,99)
 Q " ("_$$GET1^DIQ(PTRFILE,OLDVAL,.01)_")"
NEWEXT(ZDA,PSSZNODE,PIECE) ;COMPUTE EXTERNAL 'NEW' VALUE WHERE NECESSARY
 N FIELDNUM,INTERNAL,EXTERNAL
 S FIELDNUM=$O(^DD(50,"GL",PSSZNODE,PIECE,0))
 Q:'+FIELDNUM ""
 S EXTERNAL=$$GET1^DIQ(50,ZDA,FIELDNUM)
 S INTERNAL=$$GET1^DIQ(50,ZDA,FIELDNUM,"I")
 Q:(INTERNAL=EXTERNAL) ""
 Q " ("_EXTERNAL_")"
SEND ;
 ; ZEXCEPT: ZDA,ZDAN,PSSZNOC
 N XMDUZ,XMSUB,XMTEXT,XMY
 S XMSUB=$S(PSSZNOC:"DRUG ENTER/EDIT ACCESS (",1:"DRUG ENTER/EDIT AUDIT (")_$G(ZDA)_":"_$G(ZDAN)_")",XMDUZ=$S($G(DUZ):DUZ,1:.5)
 S XMTEXT="PSSZMES("
 S XMY("G.PSS DEE AUDIT")="",XMY(DUZ)=""
 D ^XMD
 Q
STOR ;STORES VALUES INTO MAILMAN VARIABLES
 ; ZEXCEPT: PSSZMES,COUNT,FIELD,LABEL,NEWVAL,OLDVAL,SPACES
 S:LABEL["660.1" LABEL="SUB6601"
 S:LABEL["8.5" LABEL="SUB85"
 S FIELD=$P($T(@(LABEL)+ZZJ),";",3)
 ;S PSSZMES(COUNT)=FIELD_$E(SPACES,1,30-$L(FIELD))_OLDVAL_$E(SPACES,1,30-$L(OLDVAL))_$G(NEWVAL),COUNT=COUNT+1
 S PSSZMES(COUNT)=FIELD,COUNT=COUNT+1
 S PSSZMES(COUNT)=$E(SPACES,1,5)_"OLD: "_OLDVAL,COUNT=COUNT+1
 S PSSZMES(COUNT)=$E(SPACES,1,5)_"NEW: "_$G(NEWVAL),COUNT=COUNT+1
 S PSSZMES(COUNT)=" ",COUNT=COUNT+1
 Q
SETLB ;SETS $TEXT LABEL
 ; ZEXCEPT: LABEL,PSSZNODE
 S LABEL=$S(PSSZNODE=0:"SUB0",PSSZNODE=2:"SUB2",PSSZNODE=3:"SUB3",PSSZNODE=8.5:"SUB85",PSSZNODE=660:"SUB660",PSSZNODE=660.1:"SUB6601",PSSZNODE="EPH":"SUBEPH",PSSZNODE="ND":"SUBND",1:"SUBI")
 Q
SUB0 ;FIELDS FOR ^PSDRUG(ZDA,0)
 ;;GENERIC NAME
 ;;VA CLASSIFICATION
 ;;DEA, SPECIAL HDLG
 ;;MAXIMUM DOSE PER DAY
 ;;STANDARD SIG
 ;;FSN
 ;;DRUG GROUP/INTERACTION
 ;;WARNING LABEL
 ;;NON-FORMULARY
 ;;MESSAGE
SUB2 ;FIELDS FOR ^PSDRUG(ZDA,2)
 ;;PHARMACY ORDERABLE ITEM
 ;;RESTRICTION
 ;;APPLICATION PACKAGES' USE
 ;;NDC
 ;;
 ;;*PRIMARY DRUG
SUB3 ;FIELDS FOR ^PSDRUG(ZDA,3)
 ;;CMOP DISPENSE
SUB85 ;
 ;;*ATC CANISTER
 ;;ATC MNEMONIC
SUB660 ;FIELDS FOR ^PSDRUG(ZDA,660)
 ;;REORDER LEVEL
 ;;ORDER UNIT
 ;;PRICE PER ORDER UNIT
 ;;NORMAL AMOUNT TO ORDER
 ;;DISPENSE UNITS PER ORDER UNIT
 ;;PRICE PER DISPENSE UNIT
 ;;SOURCE OF SUPPLY
 ;;DISPENSE UNIT
SUB6601 ;FIELDS FOR ^PSDRUG(ZDA,660.1)
 ;;CURRENT INVENTORY
SUBEPH ;FIELDS FOR ^PSDRUG(ZDA,"EPH")
 ;;DAW CODE
 ;;NCPDP DISPENSE UNIT
 ;;NCPDP QUANTITY MULTIPLIER
 ;;EPHARMACY BILLABLE
 ;;EPHARMACY BILLABLE (TRICARE)
 ;;EPHARMACY BILLABLE (CHAMPVA)
 ;;SENSITIVE DIAGNOSIS DRUG
SUBI ;FIELDS FOR ^PSDRUG(ZDA,"I")
 ;;INACTIVE DATE
SUBND ;FIELDS FOR ^PSDRUG(ZDA,"ND")
 ;;NATIONAL DRUG FILE ENTRY
 ;;VA PRODUCT NAME
 ;;PSNDF VA PRODUCT NAME ENTRY
 ;;PACKAGE SIZE
 ;;PACKAGE TYPE
 ;;NATIONAL DRUG CLASS
 ;;
 ;;
 ;;
 ;;CMOP ID
 ;;NATIONAL FORMULARY INDICATOR