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

FBAAV8.m

Go to the documentation of this file.
  1. FBAAV8 ;ALB/FA - BUILD IPAC MRA MESSAGE ;18 Dec 2013 10:04 AM
  1. ;;3.5;FEE BASIS;**123,158**;JAN 30, 1995;Build 94
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;
  1. ;-----------------------------------------------------------------------------
  1. ; Entry Points
  1. ; EN - Transmit IPAC MRA Messages
  1. ; NOTE: (actually called from first line of routine)
  1. ;-----------------------------------------------------------------------------
  1. ;
  1. EN ;EP
  1. ; Transmit IPAC MRA messages
  1. ; Input: FBFEE - Current # of FEE messages
  1. ; Output: IPAC MRA messages Transmitted
  1. ; FBFEE - Updated # of FEE messages
  1. ; FBNVP - 1 (if its not already set)
  1. ; FBSITE - Array Fee Basis Site Parameters (161.4)
  1. ; (if not already passed in)
  1. ; Called From: RTRAN@FBAAV0
  1. N FBMSG,FBLN,FBSN,FBTXT,FBXMZ,MARIEN,X,ZMCNT
  1. S ZMCNT=0,FBTXT=0,FBLN=0
  1. S MRAIEN=""
  1. F D Q:MRAIEN=""
  1. . S MRAIEN=$O(^FBAA(161.96,"AS","P",MRAIEN))
  1. . Q:MRAIEN=""
  1. . Q:'$$EN1(MRAIEN,.FBMSG,.FBTXT,.FBLN,.FBSN,.FBXMZ,.ZMCNT) ; Build Message
  1. ;
  1. Q:'$D(FBMSG) ; No more records to transmit
  1. D XMIT^FBAAV01 ; Transmit data remaining records
  1. D MRAUPDT(.FBMSG) ; Update MRA records with transmission date
  1. Q
  1. ;
  1. EN1(MRAIEN,FBMSG,FBTXT,FBLN,FBSN,FBXMZ,ZMCNT) ; Build the message lines for the specified
  1. ; MRA Record.
  1. ; Input: MRAIEN - IEN of the IPAC MRA record being sent
  1. ; FBMSG - Current Array of the MRA records that have currently been built
  1. ; for transmission, sorted by message number
  1. ; FBTXT - 0 - Header message not yet built
  1. ; 1 - Header message already built
  1. ; FBLN - Current Line count
  1. ; FBSN - 6 character (blank padded) station number or "" if not yet set
  1. ; FBXMZ - Current Message Number, "" if no header has been built yet
  1. ; ZMCNT - Current total line count
  1. ; Output: FBMSG - Updated Array of the MRA records that have currently been built
  1. ; for transmission, sorted by message number
  1. ; FBTXT - Updated to 1 if it was initially 0 to indicate that the
  1. ; IPAC MRA message header line was built
  1. ; FBLN - Updated Line count
  1. ; FBSN - 6 character (blank padded) station number
  1. ; FBXMZ - Updated Message Number (only updated if HEAD is called)
  1. ; ZMCNT - Updated total line count
  1. ; Returns: 1 - Message is built for the specified MRA record, 0 otherwise
  1. ; Called From: EN
  1. N IX1,VAIEN
  1. S VAIEN=$P(^FBAA(161.96,MRAIEN,0),U,2) ; IEN of the selected IPAC agreement
  1. I VAIEN'="",'$D(^FBAA(161.95,VAIEN)) Q 0 ; Invalid IPAC Agreement IEN
  1. S FBMSG(MRAIEN)="" ; Log the MRA record to be transmitted
  1. D LNBLD(VAIEN,MRAIEN,.FBMSG,.FBXMZ,.FBLN,.FBSN,.FBTXT,.ZMCNT) ; Build message to be transmitted
  1. Q 1
  1. ;
  1. LNBLD(VAIEN,MRAIEN,FBMSG,FBXMZ,FBLN,FBSN,FBTXT,ZMCNT) ; Build the message
  1. ; Input: VAIEN - IEN of the IPAC Agreement of selected MRA record
  1. ; MRAIEN - IEN of the selected MRA record
  1. ; FBMSG - Array of the MRA records that have currently been built for
  1. ; transmission, sorted by message number
  1. ; FBXMZ - Current Message number
  1. ; FBLN - Current Line count
  1. ; FBSN - 6 character (blank padded) station number or "" if not yet set
  1. ; FBTXT - 0 - Header message not yet built
  1. ; 1 - Header message already built
  1. ; ZMCNT - Current total line count
  1. ; Output: FBXMZ - Updated Message number
  1. ; FBLN - Updated line count
  1. ; FBSN - 6 character (blank padded) station number
  1. ; FBTXT - Updated to 1 if it was initially 0 to indicate that the
  1. ; IPAC MRA message header line was built
  1. ; ZMCNT - Updated total line count
  1. ;
  1. N ACT,FBSTR,IX1,VADATA,VAID,XX
  1. S ACT=$P(^FBAA(161.96,MRAIEN,0),U,4) ; MRA Record Action
  1. S VAID=$P(^FBAA(161.96,MRAIEN,0),U,3) ; Agreement ID
  1. I ACT'="D" D ; Not a delete record
  1. . F IX1=0:1:6 D
  1. . . S VADATA(IX1)=$G(^FBAA(161.95,VAIEN,IX1)) ; Array of IPAC Vendor Agreement data
  1. E D
  1. . S VADATA(0)=VAID
  1. ;
  1. I 'FBTXT D ; No header yet, build it now
  1. . S FBTXT=1,ZMCNT=1,FBLN=0
  1. . D HEAD(.FBLN,.FBXMZ,.FBSN)
  1. ;
  1. S FBSTR=$$LINE1(MRAIEN,FBSN,.VADATA) ; 1st line of data for the MRA record
  1. D STORE^FBAAV01
  1. S ZMCNT=ZMCNT+1
  1. I ACT'="D" D ; If we're not transmitting a delete record
  1. . S FBSTR=$$LINE2(.VADATA) ; 2nd line of data for the MRA record
  1. . D STORE^FBAAV01
  1. . S FBSTR=$$LINE3(.VADATA) ; 3rd line of data for the MRA record
  1. . D STORE^FBAAV01
  1. . S FBSTR=$$LINE4(.VADATA) ; 4th line of data for the MRA record
  1. . D STORE^FBAAV01
  1. . S FBSTR=$$LINE5(.VADATA) ; 5th line of data for the MRA record
  1. . D STORE^FBAAV01
  1. . S FBSTR=$$LINE6(.VADATA) ; 6th line of data for the MRA record
  1. . D STORE^FBAAV01
  1. . S FBSTR=$$LINE7(.VADATA) ; 7th line of data for the MRA record
  1. . D STORE^FBAAV01
  1. . S ZMCNT=ZMCNT+6 ; Increment total line count
  1. ;
  1. ; Maximum total line count reached, transmit current lines
  1. I ZMCNT>27 D
  1. . D XMIT^FBAAV01 ; Transmit the current data
  1. . D MRAUPDT(.FBMSG) ; Update MRA records with transmission date
  1. . S ZMCNT=0,FBLN=0,FBTXT=0 ; Reset total line count, line count, header flag
  1. Q
  1. ;
  1. ; Input: FBLN - Current Line count of the message
  1. ; FBXMZ - Current Message number
  1. ; Output: FBLN - Updated Line count
  1. ; FBSN - Agency Station Number
  1. ; FBXMZ - Updated Message Number
  1. ;
  1. N FB,FBAASN,FBBN,FBHD,FBJ,FBSTR
  1. D NEWMSG^FBAAV01 ; FBOKTX,XMSUB,XMDUZ
  1. S FBHD=$$HDR^FBAAUTL3() ; 'FEE' - first piece of batch header
  1. D STATION^FBAAUTL ; Returns FBSN,FBAASN (and maybe FBSITE)
  1. S FBSN=$$LJ^XLFSTR(FBSN,6) ; Station number padded with trailing spaces
  1. D GETNXB^FBAAUTL ; Next Fee Basis Batch Number (FBBN)
  1. ;FB*3.5*158
  1. S FBBN=$$RJ^XLFSTR(FBBN,7,"0") ; Padded with leading 0s to 7 digits as necessary
  1. ;
  1. ; Build header line for IPAC MRA Messages
  1. S FBSTR=FBHD_"C8"_$TR($$FMTE^XLFDT(DT,"5DZ"),"/","")_FBSN_FBBN_"$"
  1. D STORE^FBAAV01
  1. Q
  1. ;
  1. LINE1(MRAIEN,FBSN,VADATA) ; Create 1st message line for an MRA record
  1. ; Input: MRAIEN - IEN of the IPAC MRA record being transmitted
  1. ; FBSN - Agency Station # (6 chars padded with trailing spaces)
  1. ; VADATA - Array of IPAC Agreement data
  1. ; Returns: 1st line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,VID,XX
  1. ;
  1. ; Build Line 1 of the Message for the selected MRA record
  1. S FBSTR=8 ; 1st char, 1st line of IPAC Agreement data
  1. S FBSTR=FBSTR_$P(^FBAA(161.96,MRAIEN,0),U,4) ; 2nd char - IPAC MRA Action type (A,C,D)
  1. S FBSTR=FBSTR_FBSN ; 3-8 char - Agency Station Number
  1. S XX=$P(VADATA(0),U,1) ; IPAC Agreement ID
  1. S XX=$$LJ^XLFSTR(XX,10) ; IPAC Agreement ID padded with trailing spaces
  1. S FBSTR=FBSTR_XX ; 9-18 char - IPAC Agreement ID
  1. I '$D(VADATA(1)) Q FBSTR_"~$" ; Delete action being transmitted, quit now
  1. S VID=$P(VADATA(0),U,2) ; IEN of the IPAC Agreement Vendor, "" for deleted
  1. S XX=$P(^FBAAV(VID,0),U,2) ; Vendor ID number
  1. S XX=$$LJ^XLFSTR(XX,11) ; Vendor ID # left justified, padded with trailing spaces
  1. I $P(^FBAAV(VID,0),U,7)="3" D ; Pharmacy Vendor
  1. . N CHAIN
  1. . S CHAIN=$P(^FBAAV(VID,0),U,10) ; Pharmacy chain #
  1. . S CHAIN=$$RJ^XLFSTR(CHAIN,4,"0") ; Chain padded with leading 0's
  1. . S XX=$E(XX,1,9)_CHAIN ; Chain appended to the Vendor ID for pharmacy
  1. E S XX=XX_" " ; Non-Pharmacy Vendor
  1. S FBSTR=FBSTR_XX ; 19-31 char - Vendor ID
  1. S FBSTR=FBSTR_$P(VADATA(0),U,3) ; 32-35 - IPAC Agreement Fiscal Year
  1. S XX=$P(VADATA(0),U,5) ; IPAC Agreement Description
  1. S XX=$$LJ^XLFSTR(XX,60) ; Description with trailing spaces
  1. S FBSTR=FBSTR_XX ; 36-95 char - IPAC Agreement Description
  1. S XX=$P(VADATA(0),U,6) ; IPAC Agreement Sharing #
  1. S XX=$$LJ^XLFSTR(XX,13) ; Sharing Agreement padded with trailing spaces
  1. S FBSTR=FBSTR_XX ; 96-108 char - Sharing Agreement #
  1. S FBSTR=FBSTR_$P(VADATA(0),U,4)_"~" ; 109 char - IPAC Agreement Status ('A' or 'I')
  1. Q FBSTR
  1. ;
  1. LINE2(VADATA) ; Create 2nd message line for an MRA record
  1. ; Input: VADATA - Array of IPAC Agreement data
  1. ; Returns: 2nd line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,XX
  1. S XX=$P(VADATA(1),U,1) ; IPAC Agreement Customer ALC
  1. S XX=$$LJ^XLFSTR(XX,8) ; Customer ALC with trailing spaces
  1. S FBSTR=XX ; 1-8 Char - Customer ALC
  1. S XX=$P(VADATA(1),U,2) ; IPAC Agreement Receiver TAS
  1. S XX=$$LJ^XLFSTR(XX,27) ; Receiver TAS with trailing spaces
  1. S FBSTR=FBSTR_XX ; 9-35 Char - Receiver TAS
  1. S XX=$P(VADATA(1),U,5) ; IPAC Agreement Sender TAS
  1. S XX=$$LJ^XLFSTR(XX,27) ; Sender TAS with trailing spaces
  1. S FBSTR=FBSTR_XX ; 36-62 Char - Receiver TAS
  1. S XX=$P(VADATA(1),U,3) ; IPAC Agreement Agency Field Station Number
  1. S XX=$$LJ^XLFSTR(XX,8) ; Agency Field Station Number with trailing spaces
  1. S FBSTR=FBSTR_XX ; 63-70 Char - Agency Field Station Number
  1. S XX=$P(VADATA(1),U,4) ; IPAC Agreement Obligating Document #
  1. S XX=$$LJ^XLFSTR(XX,17) ; Obligating Document # with trailing spaces
  1. S FBSTR=FBSTR_XX_"~" ; 71-87 Char - Obligating Document #
  1. Q FBSTR
  1. LINE3(VADATA) ; Create 3rd message line for an MRA record
  1. ; Input: VADATA - Array of IPAC Agreement data
  1. ; Returns: 3rd line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,XX
  1. S XX=$P(VADATA(2),U,1) ; IPAC Agreement Station Contact Name
  1. S XX=$$LJ^XLFSTR(XX,60) ; Station Contact Name with trailing spaces
  1. S FBSTR=XX ; 1-60 char - Station Contact Name
  1. S XX=$P(VADATA(2),U,2) ; IPAC Agreement Station Contact Phone
  1. S XX=$$LJ^XLFSTR(XX,17) ; Station Contact Phone with trailing spaces
  1. S FBSTR=FBSTR_XX ; 61-77 char - Station Contact Phone
  1. S XX=$P(VADATA(2),U,3) ; IPAC Agreement Station Contact Email
  1. S XX=$$LJ^XLFSTR(XX,100) ; Station Contact Email with trailing spaces
  1. S FBSTR=FBSTR_XX_"~" ; 78-177 char - Station Contact Phone
  1. Q FBSTR
  1. ;
  1. LINE4(VADATA) ; Create 4th message line for an MRA record
  1. ; Input: VADATA - Array of IPAC Agreement data
  1. ; Returns: 4th line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,XX
  1. S XX=$P(VADATA(3),U,1) ; IPAC Agreement Station Complete line of Accounting
  1. S XX=$$LJ^XLFSTR(XX,60) ; Complete line of accounting with trailing spaces
  1. S FBSTR=XX_"~" ; 1-60 char - Complete line of Accounting
  1. Q FBSTR
  1. ;
  1. LINE5(VADATA) ; Create 5th message line for an MRA record
  1. ; Input: VADATA - Array of IPAC Agreement data
  1. ; Returns: 5th line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,XX
  1. S XX=$P(VADATA(4),U,1) ; IPAC Agreement Station Goods & Services
  1. S XX=$$LJ^XLFSTR(XX,200) ; Goods & Services with trailing spaces
  1. S FBSTR=XX_"~" ; 1-200 char - Goods & Services
  1. Q FBSTR
  1. ;
  1. LINE6(VADATA) ; Create 6th message line for an MRA record
  1. ; Input: VADATA - Array of IPAC Agreement data
  1. ; Returns: 6th line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,XX
  1. S XX=$P(VADATA(5),U,1) ; IPAC Agreement Miscellaneous Line 1
  1. S XX=$$LJ^XLFSTR(XX,220) ; Miscellaneous Line 1 with trailing spaces
  1. S FBSTR=XX_"~" ; 1-220 char - Miscellaneous Line 1
  1. Q FBSTR
  1. ;
  1. LINE7(VADATA) ; Create 7th message line for an MRA record
  1. ; Input: VADATA - Array of IPAC Agreement data
  1. ; Returns: 7tht line of data for the MRA record
  1. ; Called From: LNBLD
  1. N FBSTR,XX
  1. S XX=$P(VADATA(6),U,1) ; IPAC Agreement Miscellaneous Line 2
  1. S XX=$$LJ^XLFSTR(XX,100) ; Miscellaneous Line 2 with trailing spaces
  1. S FBSTR=XX_"~$" ; 1-100 char - Miscellaneous Line 2
  1. Q FBSTR
  1. Q
  1. ;
  1. MRAUPDT(FBMSG) ; Update MRA records with transmit status and date
  1. ; Input: FBMSG() - Array of MRA IENs that were transmitted
  1. ; Output: MRA records updated with transmit status and date
  1. ; Called From: EN, LNBLD
  1. N DA,DIE,DR,MRAIEN,X
  1. S MRAIEN=""
  1. F D Q:MRAIEN=""
  1. . S MRAIEN=$O(FBMSG(MRAIEN))
  1. . Q:MRAIEN=""
  1. . S DIE="^FBAA(161.96,",DA=MRAIEN
  1. . S DR="4///^S X="_"""TRANSMITTED"""
  1. . S DR=DR_";5///TODAY"
  1. . D ^DIE
  1. . K FBMSG(MRAIEN)
  1. Q
  1. ;