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

FBFHLL.m

Go to the documentation of this file.
  1. FBFHLL ;AISC/LEG-FPPS QUEUED INVOICE FILE ;9/10/2003
  1. ;;3.5;FEE BASIS;**61**;JULY 18, 2003
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. LOG(FBN,FBTYPE) ; processes batch and logs 0.00 invoices to FILE #163.5
  1. ; input
  1. ; FBN - pointer to FEE BASIS BATCH file
  1. ; FBTYPE - batch type (B3,B5,B9,BT)
  1. N FBX,FBERR
  1. S FBERR=""
  1. F FBX="FBN","FBTYPE" S:'$L(@FBX) FBERR=FBX_":0 LENGTH"
  1. I $L(FBERR) W FBERR Q
  1. I "B3,B5,B9"[FBTYPE D @FBTYPE ;either B3, B5, B9
  1. Q
  1. ;
  1. B3 ; process outpatient/ancillary batch
  1. Q:FBTYPE'="B3"
  1. N DA,FBAAIN,FBAMTPD,FBINV,FBY0
  1. ;
  1. ; loop thru items in batch and build list of EDI invoices and their $
  1. S DA(3)=0 F S DA(3)=$O(^FBAAC("AC",FBN,DA(3))) Q:'DA(3) D
  1. . S DA(2)=0 F S DA(2)=$O(^FBAAC("AC",FBN,DA(3),DA(2))) Q:'DA(2) D
  1. . . S DA(1)=0
  1. . . F S DA(1)=$O(^FBAAC("AC",FBN,DA(3),DA(2),DA(1))) Q:'DA(1) D
  1. . . . S DA=0
  1. . . . F S DA=$O(^FBAAC("AC",FBN,DA(3),DA(2),DA(1),DA)) Q:'DA D
  1. . . . . Q:$P($G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,3)),U)="" ; not EDI
  1. . . . . S FBY0=$G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,0))
  1. . . . . S FBAAIN=$P(FBY0,U,16)
  1. . . . . S FBAMTPD=$P(FBY0,U,3)
  1. . . . . I FBAAIN]"" S FBINV(FBAAIN)=$G(FBINV(FBAAIN))+FBAMTPD
  1. ;
  1. ; loop thru EDI invoices and queue invoices with 0.00 payment
  1. S FBAAIN="" F S FBAAIN=$O(FBINV(FBAAIN)) Q:FBAAIN="" D
  1. . Q:$G(FBINV(FBAAIN))>0 ; not zero dollar invoice
  1. . D FILEQUE(FBAAIN,3)
  1. Q
  1. ;
  1. B5 ; processes pharmacy batch
  1. Q:FBTYPE'="B5"
  1. N DA,FBAAIN,FBAMTPD,FBINV,FBRXY0,FBY0
  1. ;
  1. ; loop thru items in batch and build list of EDI invoices and their $
  1. S DA(1)=0 F S DA(1)=$O(^FBAA(162.1,"AE",FBN,DA(1))) Q:'DA(1) D
  1. . S DA=0 F S DA=$O(^FBAA(162.1,"AE",FBN,DA(1),DA)) Q:'DA D
  1. . . S FBY0=$G(^FBAA(162.1,DA(1),0))
  1. . . S FBRXY0=$G(^FBAA(162.1,DA(1),"RX",DA,0))
  1. . . Q:$P(FBY0,U,13)="" ; not EDI
  1. . . S FBAAIN=$P(FBY0,U)
  1. . . S FBAMTPD=$P(FBRXY0,U,16)
  1. . . I FBAAIN]"" S FBINV(FBAAIN)=$G(FBINV(FBAAIN))+FBAMTPD
  1. ;
  1. ; loop thru EDI invoices and queue invoices with 0.00 payment
  1. S FBAAIN="" F S FBAAIN=$O(FBINV(FBAAIN)) Q:FBAAIN="" D
  1. . Q:$G(FBINV(FBAAIN))>0 ; not zero dollar invoice
  1. . D FILEQUE(FBAAIN,5)
  1. Q
  1. ;
  1. B9 ; processes inpatient batch
  1. Q:FBTYPE'="B9"
  1. N DA,FBAAIN,FBAMTPD,FBY0
  1. ;
  1. ; loop thru items in batch and log 0.00 EDI invoices
  1. S DA=0 F S DA=$O(^FBAAI("AC",FBN,DA)) Q:'DA D
  1. . Q:$P($G(^FBAAI(DA,3)),U)="" ; not EDI
  1. . S FBY0=$G(^FBAAI(DA,0))
  1. . S FBAAIN=$P(FBY0,U)
  1. . S FBAMTPD=$P(FBY0,U,9)
  1. . Q:FBAMTPD>0 ; not 0.00 invoice
  1. . D FILEQUE(FBAAIN,9)
  1. Q
  1. ;
  1. PAIDLOG(FBINV) ; process EDI invoices from payment conf/canc message
  1. ; input FBINV array, passed by reference
  1. ; format FBINV(fbtype,fbaain)=""
  1. ; where fbtype = 3, 5, or 9
  1. ; fbaain = invoice number
  1. ;
  1. N FBAAIN,FBTYPE
  1. ; loop thru type
  1. F FBTYPE=3,5,9 D
  1. . ; loop thru invoices
  1. . S FBAAIN="" F S FBAAIN=$O(FBINV(FBTYPE,FBAAIN)) Q:FBAAIN="" D
  1. . . ; queue invoice
  1. . . D FILEQUE(FBAAIN,FBTYPE)
  1. Q
  1. ;
  1. FILEQUE(FBAAIN,FBTYPE) ; file invoice into FPPS Queue
  1. ; input
  1. ; FBAAIN - invoice number
  1. ; FBTYPE - type (3, 5, or 9)
  1. ; where 3 = outpatient/ancillary - file 162
  1. ; 5 = pharmacy - file 162.1
  1. ; 9 = inpatient - file 162.5
  1. ;
  1. N FBDA,FBFDA
  1. ;
  1. ;
  1. S FBDA=$O(^FBHL(163.5,"B",FBAAIN,""),-1) ; last entry for invoice
  1. I FBDA,$D(^FBHL(163.5,"AC",0,FBDA)) Q ; already queued to be sent
  1. ;
  1. S FBFDA(163.5,"+1,",.01)=FBAAIN
  1. S FBFDA(163.5,"+1,",1)=FBTYPE
  1. S FBFDA(163.5,"+1,",2)=0
  1. D UPDATE^DIE("","FBFDA")
  1. Q
  1. ;
  1. CKFPPS(FBAAIN) ; checks if invoice was previously sent to FPPS
  1. ; input
  1. ; FBAAIN - invoice number
  1. ; result
  1. ; status (0,1,X) of 1st entry for invoice in file 163.5
  1. ; where 0 = waiting to be transmitted
  1. ; 1 = transmitted
  1. ; X = not logged
  1. N FBDA,FBRET,FBSTAT
  1. S FBRET=""
  1. ;
  1. ; loop thru entries for invoice (look until end or return value is true)
  1. S FBDA=0 F S FBDA=$O(^FBHL(163.5,"B",FBAAIN,FBDA)) Q:'FBDA D Q:FBRET
  1. . S FBSTAT=$P($G(^FBHL(163.5,FBDA,0)),U,3)
  1. . I "^1^2^"[(U_FBSTAT_U) S FBRET=1 ; status=transmitted or acknowledged
  1. . I "^0^"[(U_FBSTAT_U) S FBRET=0 ; status=pending
  1. ;
  1. ; if no status found for invoice then return X for not logged
  1. I FBRET="" S FBRET="X"
  1. Q FBRET
  1. ;
  1. ;FBFHLL