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

IBCF33.m

Go to the documentation of this file.
  1. IBCF33 ;ALB/ARH - UB-04 CMS-1450 (GATHER CODES) ;25-AUG-1993
  1. ;;2.0;INTEGRATED BILLING;**52,80,109,51,230,349,577,727**;21-MAR-94;Build 34
  1. ;;Per VA Directive 6402, this routine should not be modified
  1. ;
  1. ;IBIFN required
  1. ;
  1. ; Not all free text prints in these blocks as of MRA/EDI - only print
  1. ; REVENUE CODES and associated data, Rx's and prosthetics
  1. ; and last line to indicate multiple pages
  1. N IBI,IBJ,IBCU2,IBCOL,IBSTATE,IBCBILL,IBINPAT,IBX,IBY,Z,IBZ,IBLPG
  1. S IBLINES=22,IBCU2=$G(^DGCR(399,IBIFN,"U2")),IBCOL=1,IBNOCOM=0
  1. K IBXSAVE("RX-UB-04"),IBXSAVE("PROS-UB-04")
  1. D HOS^IBCEF22(IBIFN)
  1. ;
  1. I $$TXMT^IBCEF4(IBIFN) S IBNOCOM=1
  1. S Z="",IBNOCHG=0
  1. ; Add total line as last entry, if not already there
  1. ;S IBLCT=$O(IBXDATA(""),-1)
  1. ;I IBLCT,$P(IBXDATA(IBLCT),U)'="001" S IBXDATA(IBLCT+1)="001"
  1. ;S IBLCT=0
  1. S IBLPG=($O(IBXDATA(""),-1)+$O(IBXSAVE("RX-UB-04",""),-1)+$O(IBXSAVE("PROS-UB-04",""),-1))/22,IBLPG=IBLPG\1+$S($P(IBLPG,".",2):1,1:0)
  1. F S Z=$O(IBXDATA(Z)) Q:'Z D
  1. . N IBZ1
  1. . ;I $P(IBXDATA(Z),U)="001",'$O(IBXDATA(Z)) S IBZ="001",$P(IBZ,U,4)=$P(IBCBCOMM,U,1),IBDA=0 S:IBNOCHG $P(IBZ,U,9)=$G(IBNOCHG) S IBXDATA(Z)=IBZ D SET1 Q
  1. . ;Get modifiers
  1. . S IBZ1=$G(^DGCR(399,IBIFN,"RC",+$P(IBXDATA(Z),U,8),0)),IBMOD=""
  1. . I $P(IBZ1,U,6),$S($P(IBZ1,U,10)=4:$P(IBZ1,U,11),1:'$P(IBZ1,U,10)) S $P(IBXDATA(Z),U,9)=$$MOD(IBZ1,IBIFN)
  1. . S IBZ=$P(IBXDATA(Z),U)_U_$P(IBXDATA(Z),U,3,5)_"^^"_$P(IBXDATA(Z),U,2),$P(IBZ,U,9)=$P(IBXDATA(Z),U,6),$P(IBZ,U,13)=$P(IBXDATA(Z),U,7),$P(IBZ,U,10)=$P(IBXDATA(Z),U,9),$P(IBZ,U,14)=$P(IBXDATA(Z),U,10)
  1. . ; VAD-IB*2*577 - Add "NDC#", "Unit/Basis of Measure", and "Units/Qty" to pieces 20,21,22 of IBZ, respectively
  1. . S $P(IBZ,U,20)=$P(IBXDATA(Z),U,11),$P(IBZ,U,21)=$P(IBXDATA(Z),U,13),$P(IBZ,U,22)=$P(IBXDATA(Z),U,12)
  1. . I IBZ S IBNOCHG=IBNOCHG+$P(IBXDATA(Z),U,6),IBDA=$P(IBXDATA(Z),U,8) D SET1
  1. . ;S IBLCT=IBLCT+1
  1. I $D(IBXSAVE("RX-UB-04"))!$D(IBXSAVE("PROS-UB-04")) D
  1. . N Z
  1. . S Z=0 F S Z=$O(IBXSAVE("RX-UB-04",Z)) Q:'Z S IBZ=IBXSAVE("RX-UB-04",Z) D SET2
  1. . S Z=0 F S Z=$O(IBXSAVE("PROS-UB-04",Z)) Q:'Z S IBZ=IBXSAVE("PROS-UB-04",Z) D SET2
  1. D END
  1. Q
  1. ;
  1. RV ;rev codes sorted by bedsection - no longer used as of patch IB*2*51
  1. S (IBBSN,IBBS,IBNOCHG)=0 F S IBBS=$O(^DGCR(399,IBIFN,"RC","ABS",IBBS)) Q:'IBBS D
  1. . S IBRV=0 F S IBRV=$O(^DGCR(399,IBIFN,"RC","ABS",IBBS,IBRV)) Q:'IBRV D
  1. .. S IBDA=0 F S IBDA=$O(^DGCR(399,IBIFN,"RC","ABS",IBBS,IBRV,IBDA)) Q:'IBDA D
  1. ... S IBX=$G(^DGCR(399,IBIFN,"RC",IBDA,0))
  1. ... S IBZ=$P($G(^DGCR(399.1,+$P(IBX,U,5),0)),U,1) S IBBSN=IBZ,IBZ=IBX,IBNOCHG=IBNOCHG+$P(IBZ,U,9) D SET1
  1. ;
  1. ;loop through all rev codes, print those with no bedsection
  1. S IBDA=0 F S IBDA=$O(^DGCR(399,IBIFN,"RC",IBDA)) Q:'IBDA S IBZ=$G(^(IBDA,0)) I +IBZ,$P(IBZ,U,5)="" S IBNOCHG=IBNOCHG+$P(IBZ,U,9) D SET1
  1. ;
  1. TOTAL ;add total
  1. ;I +$P(IBCBCOMM,U,2) S IBZ="",$P(IBZ,U,2)="SUBTOTAL",$P(IBZ,U,4)=+$P(IBCBCOMM,U,1) D SET1
  1. ;
  1. ;S IBX=$S(+$P(IBCBCOMM,U,2):4,1:2) D SPACE
  1. S IBX=2 D SPACE
  1. ;S IBZ="" D SET2
  1. ;S IBJ=0 F IBI=4,5,6 S IBJ=IBJ+$P(IBCU2,U,IBI)
  1. ;I +$P(IBCBCOMM,U,2),+$P(IBCBCOMM,U,2)'=IBJ S (IBI,IBZ)="",$P(IBZ,U,2)="LESS "_$P(IBCBCOMM,U,3),$P(IBZ,U,4)=+$P(IBCBCOMM,U,2) D SET1 S IBZ="" D SET2
  1. ;
  1. ;S IBZ="001",$P(IBZ,U,2)="TOTAL",$P(IBZ,U,4)=IBCBCOMM-$S(IBI="":$P(IBCBCOMM,U,2),1:0) S:IBNOCHG $P(IBZ,U,9)=$G(IBNOCHG) D SET1
  1. ;
  1. ;
  1. CPT ;add additional procedures
  1. ;G:$G(IBFL(80))'>6 OPV S IBX=+IBFL(80)-4 D SPACE
  1. ;S IBZ="" D SET2
  1. ;S IBZ="ADDITIONAL PROCEDURE CODES:" D SET2
  1. ;S IBI=6 F S IBI=$O(IBFL(80,IBI)) Q:'IBI D
  1. ;. S IBX=$P(IBFL(80,IBI),U,2),IBZ=$E(IBX,1,2)_"/"_$E(IBX,3,4)_"/"_$E(IBX,5,6)_$J(" ",5)_$P(IBFL(80,IBI),U,1) D SET2
  1. ;
  1. OPV ;add outpatient visit dates
  1. ;G:'$O(^DGCR(399,IBIFN,"OP",0)) CONT S (IBX,IBY)=0 F S IBX=$O(^DGCR(399,IBIFN,"OP",IBX)) Q:'IBX S IBY=IBY+1
  1. ;S IBX=IBY/3,IBX=IBX\1+$S(+$P(IBX,".",2):1,1:0)+1 D SPACE
  1. ;S IBZ="" D SET2 S IBZ="OP VISIT DATE(S) BILLED:"_$J(" ",34-24)
  1. ;S (IBI,IBJ)=0 F S IBI=$O(^DGCR(399,IBIFN,"OP",IBI)) Q:'IBI D
  1. ;. S Y=$G(^DGCR(399,IBIFN,"OP",IBI,0)),IBZ=IBZ_$$FMTE^XLFDT(Y,2)_$S($O(^DGCR(399,IBIFN,"OP",IBI)):", ",1:"")
  1. ;. S IBJ=IBJ+1 I IBJ>2 D SET2 S IBZ=$J(" ",34),IBJ=0
  1. ;I $L(IBZ)>34 D SET2
  1. ;
  1. CONT ;D ^IBCF331 ;More free text - can no longer print on UB-04
  1. ;
  1. ; fill in rest of page
  1. END D:'$G(IBNOCOM) FILLPG S $P(^TMP($J,"IBC-RC"),U,2)=0 S IBPG=+$G(^TMP($J,"IBC-RC")),IBX=IBPG/22,IBPG=IBX\1+$S(+$P(IBX,".",2):1,1:0)
  1. K IBZ,IBBSN,IBBS,IBRV,IBDA,IBLN,IBCOL,IBLINES,IBARRAY,IBNOCHG,IBNOCOM,IBXSAVE("RX-UB-04"),IBXSAVE("PROS-UB-04")
  1. Q
  1. ;
  1. SPACE ;checks to see if IBX can fit on page, if not starts new page
  1. Q:'IBX N IBLN,IBY S IBLN=+$G(^TMP($J,"IBC-RC")),IBY=IBLN#22 S:IBY=0&(IBLN'=0) IBY=22 I IBX>(IBLINES-IBY) D FILLPG
  1. Q
  1. ;
  1. FILLPG ;fill rest of page with blank lines
  1. N IBI,IBLN,IBZ S IBFILL=1 F IBI=1:1:22 S IBLN=+$G(^TMP($J,"IBC-RC")) Q:'(IBLN#22) S IBZ="" D FILLUP Q:IBFILL=2
  1. K IBFILL Q
  1. ;
  1. SET1 ; add rev codes to array: rev cd ^ rev cd st abbrev. ^ CPT CODE ^ unit charge ^ units ^ total ^ non-cov charge ^ form locator 49 ^ rev code mult ien ^ cpt modifiers attached to revenue code/procedure (unlinked)^ outpt serv date
  1. ;formats for output into specific column blocks 42-48
  1. ;
  1. ;JRA;IB*2.0*577 Add Unit/Basis of Measure to array - added after 'units' so the string above will be changed to:
  1. ;rev cd ^ rev cd st abbrev. ^ CPT CODE ^ unit charge ^ units (Qty) ^ unit/basis of measure ^ total ^ non-cov charge ^ form locator 49 ^ rev code mult ien ^ cpt modifiers attached to revenue code/procedure (unlinked)^ outpt serv date
  1. ;
  1. N IBX,IBY,IBLN,IBN,IBMOD
  1. D NEXTLN S IBY=""
  1. ;set up rev cd item with appropriate output values, non-rev cd entries for old bills should already be in external form
  1. S IBN=$P(IBZ,U,9) ;non-covered charges
  1. ;S IBMOD=$P(IBZ,U,10) I IBMOD'="" S IBMOD=$E($TR(IBMOD,",;"),1,4) ; cpt modifiers
  1. S IBMOD=$P(IBZ,U,10) I IBMOD'="" S IBMOD=$E($TR(IBMOD,",;"),1,8) ; cpt modifiers ;TPF;IB*2.0*727;EBILL-1576;05/10/2022
  1. I +IBZ S IBX=$G(^DGCR(399.2,+IBZ,0)) Q:IBX="" D
  1. . S IBY=$P(IBX,U,1)_U_$P(IBX,U,2)_U_$$PRCD^IBCEF1($P(IBZ,U,6)_";ICPT(")_IBMOD
  1. . S IBY=IBY_U_$P(IBZ,U,2)_U_$P(IBZ,U,3)_U_$P(IBZ,U,4)_U_IBN_U_$P(IBZ,U,13)_U_$G(IBDA)_U_U_$$DATE^IBCF2($P(IBZ,U,14),"",1)
  1. I IBY="" S IBY=$P(IBZ,U,1)_U_$P(IBZ,U,2)_U_U_U_$P(IBZ,U,3)_U_$P(IBZ,U,4)_U_IBN_U_$P(IBZ,U,13)_U_$G(IBDA)_U_U_$$DATE^IBCF2($P(IBZ,U,14),"",1)
  1. S $P(IBY,U,20,22)=$P(IBZ,U,20,22) ;VAD Add "NDC#", "Unit/Basis of Measure", and "Units/Qty" to IBY
  1. S IBLN=+$G(^TMP($J,"IBC-RC"))+1,^TMP($J,"IBC-RC",IBLN)=1_U_IBY,^TMP($J,"IBC-RC")=IBLN I '(IBLN#22) S IBLINES=22
  1. Q
  1. ;
  1. SET2 ;set free text into block 42 array
  1. Q:$G(IBNOCOM) ;No comments wanted
  1. N IBLN D NEXTLN S IBCOL=$S('IBCOL:2,1:3)
  1. S IBLN=+$G(^TMP($J,"IBC-RC"))+1 I IBLN#22=1,$G(IBFILL) S IBFILL=2 Q
  1. S ^TMP($J,"IBC-RC",IBLN)=IBCOL_U_IBZ,^TMP($J,"IBC-RC")=IBLN I '(IBLN#22) S IBLINES=22
  1. Q
  1. ;
  1. FILLUP ; Fill block 42 with blank lines
  1. N IBLN D NEXTLN S IBCOL=$S('IBCOL:2,1:3)
  1. S IBLN=+$G(^TMP($J,"IBC-RC"))+1 I IBLN#22=1,$G(IBFILL) S IBFILL=2 Q
  1. S ^TMP($J,"IBC-RC",IBLN)=IBCOL_U_IBZ,^TMP($J,"IBC-RC")=IBLN I '(IBLN#22) S IBLINES=22
  1. Q
  1. ;
  1. NEXTLN ;checks counter for next line, resets if necessary,
  1. ;ie. if the line # indicated by the next line # var. has already been used then this increments the next line # var.
  1. S IBLN=+$G(^TMP($J,"IBC-RC"))+1 I $D(^TMP($J,"IBC-RC",IBLN)) S ^TMP($J,"IBC-RC")=IBLN S:'(IBLN#22) IBLINES=22 G NEXTLN
  1. Q
  1. ;
  1. MOD(RCLN,IBIFN) ; return modifier(s) for a directly linked CPT charge or for an indirectly linked one
  1. N IBCPTN,IBMOD
  1. S IBMOD=""
  1. I $P($G(RCLN),U,10)=4 S IBCPTN=+$P(RCLN,U,11) I +IBCPTN S IBMOD=$$GETMOD^IBEFUNC(IBIFN,IBCPTN,1) ;Linked
  1. I IBMOD="",$P(RCLN,U,14)'="" S IBMOD=$TR($P(RCLN,U,14),";",",") ; Not linked or linked, but manually entered modifiers only
  1. MODQ Q IBMOD
  1. ;
  1. DATE45(IBIFN,IBXDATA,IBDATE) ; What prints in the service date box of UB-04
  1. ; INPUT:
  1. ; IBIFN = ien of bill
  1. ; IBDATE = the default outpt service date
  1. ; OUTPUT:
  1. ; IBXDATA = the output formatter array with the service dates
  1. ; (pass by reference)
  1. N Z,Z0,IBR,IBIN
  1. S IBIN=$$INPAT^IBCEF(IBXIEN,1)
  1. F Z=1:1 Q:'$D(^TMP($J,"IBC-RC",Z)) S IBR=^(Z) D
  1. . S Z0=$S(+IBR=1&'IBIN&(+$P(IBR,U,2)'=1):$S($P(IBR,U,12):$P(IBR,U,12),1:$G(IBDATE)),+IBR=2:$E($P(IBR,U,2),46,52),1:$E($P(IBR,U,2),41,47))
  1. . S:Z'>22 IBXDATA(Z)=Z0 D:Z>22 CKREV^IBCEF3(Z,Z0)
  1. Q
  1. ;