BEXRUTL ;IHS/CMI/DAY - Print reports [ 03/02/2010 11:14 AM ] ; 12 Mar 2012 4:21 PM
;;1.0;BEX TELEPHONE REFILL SYSTEM;**4,5**;MAR 12, 2012;Build 1
;
;Report Utilities
;
;IHS/CMI/DAY - 07/26/2011 - Patch 5 - Add Mail/Window field for CMOP
Q
;
PARSE ;EP - Parse BEX Transaction and lookup variables
;
;Set Patient IEN
S BEXPTIEN=""
S BEXPTIEN=$P(BEX(0),U)
;
;Set Transaction Date/Time
S BEXTXDAT=""
S BEXTXDAT=$P(BEX(0),U,2)
;
;Calculate Transaction Date
S BEXDAT=$P(BEXTXDAT,".")
;
;Calculate Transaction Time
S BEXTIM=$P(BEXTXDAT,".",2)
;
;Set RX Number
S BEXRXNUM=""
S BEXRXNUM=$P(BEX(0),U,3)
;
;Calculate RX IEN
S BEXRXIEN=""
I BEXRXNUM]"" S BEXRXIEN=$O(^PSRX("B",BEXRXNUM,0))
;
;Calculate Mail/Window
S BEXMLWIN=""
I +BEXRXIEN S BEXMLWIN=$P(^PSRX(BEXRXIEN,0),U,11)
;
;Set Type
S BEXTYPE=""
S BEXTYPE=$P(BEX(0),U,4)
;
;Set Result
S BEXRESLT=""
S BEXRESLT=$P(BEX(0),U,5)
;Check for invalid result, like ",0"
I BEXRESLT?1P.E S BEXRESLT=""
;
;Set Renewal
S BEXRENWL=""
S BEXRENWL=$P(BEX(0),U,6)
;
;Set Division IEN
S BEXDVIEN=""
S BEXDVIEN=$P(BEX(0),U,10)
;
;Set Drug IEN
S BEXDRIEN=""
S BEXDRIEN=$P(BEX(0),U,11)
;
;Calculate Drug IEN if not in Piece 10
I BEXDRIEN="",+BEXRXIEN S BEXDRIEN=$P(^PSRX(BEXRXIEN,0),U,6)
;
;Calculate Drug Name
S BEXDRNAM=""
I +BEXDRIEN S BEXDRNAM=$P(^PSDRUG(BEXDRIEN,0),U)
;
;Calculate Refill Date
;We want the first date AFTER the transaction date
S BEXRFDAT=""
I BEXRXIEN D
.;
.S Y=0
.F S Y=$O(^PSRX(BEXRXIEN,1,Y)) Q:'Y D Q:BEXRFDAT]""
..;
..;Set Refill Date
..S X=$P(^PSRX(BEXRXIEN,1,Y,0),U)
..I X<$P(BEXTXDAT,".") Q
..I X=$P(BEXTXDAT,".") S BEXRFDAT=X
..I X>$P(BEXTXDAT,".") S BEXRFDAT=X
..;
..;Set Pharmacist
..S BEXRPH=""
..S BEXRPH=$P(^PSRX(BEXRXIEN,1,Y,0),U,5)
..;
..;IHS/CMI/DAY - Patch 5 - Add Mail/Window field for CMOP
..;Get Mail or Window for CMOP
S BEXMAIL=$P(BEX(0),U,12)
;
Q
;
BEXRUTL ;IHS/CMI/DAY - Print reports [ 03/02/2010 11:14 AM ] ; 12 Mar 2012 4:21 PM
+1 ;;1.0;BEX TELEPHONE REFILL SYSTEM;**4,5**;MAR 12, 2012;Build 1
+2 ;
+3 ;Report Utilities
+4 ;
+5 ;IHS/CMI/DAY - 07/26/2011 - Patch 5 - Add Mail/Window field for CMOP
+6 QUIT
+7 ;
PARSE ;EP - Parse BEX Transaction and lookup variables
+1 ;
+2 ;Set Patient IEN
+3 SET BEXPTIEN=""
+4 SET BEXPTIEN=$PIECE(BEX(0),U)
+5 ;
+6 ;Set Transaction Date/Time
+7 SET BEXTXDAT=""
+8 SET BEXTXDAT=$PIECE(BEX(0),U,2)
+9 ;
+10 ;Calculate Transaction Date
+11 SET BEXDAT=$PIECE(BEXTXDAT,".")
+12 ;
+13 ;Calculate Transaction Time
+14 SET BEXTIM=$PIECE(BEXTXDAT,".",2)
+15 ;
+16 ;Set RX Number
+17 SET BEXRXNUM=""
+18 SET BEXRXNUM=$PIECE(BEX(0),U,3)
+19 ;
+20 ;Calculate RX IEN
+21 SET BEXRXIEN=""
+22 IF BEXRXNUM]""
SET BEXRXIEN=$ORDER(^PSRX("B",BEXRXNUM,0))
+23 ;
+24 ;Calculate Mail/Window
+25 SET BEXMLWIN=""
+26 IF +BEXRXIEN
SET BEXMLWIN=$PIECE(^PSRX(BEXRXIEN,0),U,11)
+27 ;
+28 ;Set Type
+29 SET BEXTYPE=""
+30 SET BEXTYPE=$PIECE(BEX(0),U,4)
+31 ;
+32 ;Set Result
+33 SET BEXRESLT=""
+34 SET BEXRESLT=$PIECE(BEX(0),U,5)
+35 ;Check for invalid result, like ",0"
+36 IF BEXRESLT?1P.E
SET BEXRESLT=""
+37 ;
+38 ;Set Renewal
+39 SET BEXRENWL=""
+40 SET BEXRENWL=$PIECE(BEX(0),U,6)
+41 ;
+42 ;Set Division IEN
+43 SET BEXDVIEN=""
+44 SET BEXDVIEN=$PIECE(BEX(0),U,10)
+45 ;
+46 ;Set Drug IEN
+47 SET BEXDRIEN=""
+48 SET BEXDRIEN=$PIECE(BEX(0),U,11)
+49 ;
+50 ;Calculate Drug IEN if not in Piece 10
+51 IF BEXDRIEN=""
IF +BEXRXIEN
SET BEXDRIEN=$PIECE(^PSRX(BEXRXIEN,0),U,6)
+52 ;
+53 ;Calculate Drug Name
+54 SET BEXDRNAM=""
+55 IF +BEXDRIEN
SET BEXDRNAM=$PIECE(^PSDRUG(BEXDRIEN,0),U)
+56 ;
+57 ;Calculate Refill Date
+58 ;We want the first date AFTER the transaction date
+59 SET BEXRFDAT=""
+60 IF BEXRXIEN
Begin DoDot:1
+61 ;
+62 SET Y=0
+63 FOR
SET Y=$ORDER(^PSRX(BEXRXIEN,1,Y))
IF 'Y
QUIT
Begin DoDot:2
+64 ;
+65 ;Set Refill Date
+66 SET X=$PIECE(^PSRX(BEXRXIEN,1,Y,0),U)
+67 IF X<$PIECE(BEXTXDAT,".")
QUIT
+68 IF X=$PIECE(BEXTXDAT,".")
SET BEXRFDAT=X
+69 IF X>$PIECE(BEXTXDAT,".")
SET BEXRFDAT=X
+70 ;
+71 ;Set Pharmacist
+72 SET BEXRPH=""
+73 SET BEXRPH=$PIECE(^PSRX(BEXRXIEN,1,Y,0),U,5)
+74 ;
+75 ;IHS/CMI/DAY - Patch 5 - Add Mail/Window field for CMOP
+76 ;Get Mail or Window for CMOP
End DoDot:2
IF BEXRFDAT]""
QUIT
End DoDot:1
+77 SET BEXMAIL=$PIECE(BEX(0),U,12)
+78 ;
+79 QUIT
+80 ;