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

IBCEMRAX.m

Go to the documentation of this file.
  1. IBCEMRAX ;ALB/DSM - MEDICARE REMITTANCE ADVICE DETAIL-PART A Cont'd ;25-APR-2003
  1. ;;2.0;INTEGRATED BILLING;**155,432**;21-MAR-94;Build 192
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. DEV(IBIFN,IBMRANOT) ; Prompt the user for a device ; WCJ IB*2.0*432
  1. ; Input: IBIFN= ien# of Claim file
  1. ; IBMRANOT = 1 if NOT an MRA ; WCJ IB*2.0*432
  1. N %ZIS,ZTRTN,ZTSAVE,ZTDESC,POP,MRACNT
  1. I '$G(IBIFN) Q ;DEV
  1. W !!,"This report displays Medicare-equivalent Remittance Advice Detail."
  1. S MRACNT=$$MRACNT^IBCEMU1(IBIFN,$G(IBMRANOT))
  1. I MRACNT>1 W !,"*** Multiple MRAs on File for this claim. ",MRACNT," MRAs will be printed. ***"
  1. W !,"You will need a 132 column printer for this report",!
  1. ;
  1. S %ZIS="QM" D ^%ZIS I POP S IBQUIT=1 Q
  1. ; handle queuing report next
  1. I $D(IO("Q")) D S IBQUIT=1 Q
  1. . S ZTRTN="PROC^IBCEMRAA" ; background re-entry point
  1. . S ZTDESC="Medicare-equivalent Remittance Advice Detail Print"
  1. . S ZTSAVE("IB*")=""
  1. . D ^%ZTLOAD
  1. . W !!,$S($D(ZTSK):"Your task number "_ZTSK_" has been queued.",1:"Unable to queue this job.")
  1. . K ZTSK,IO("Q") D HOME^%ZIS
  1. U IO ; Output device
  1. Q ;DEV
  1. ;
  1. SRVHDR ; Print Srvice Level Header
  1. ; ROW 23 -
  1. ; Service (Line) Level Adjustments Data
  1. W !!! I '$G(INPAT) W "SERV DATE" ;print only on outpatient claims
  1. W ?12,"PT",?15,"PROC",?21,"MODS",?30,"REV",?35,"APC",?43,"UNITS",?50,"TOT CHARGES"
  1. W ?67,"DEDUCT",?80,"COINS",?90,"ALLOWED",?102,"PAYMENT",?111,"GRP-RC",?123,"ADJ AMT"
  1. Q ;SRVHDR
  1. ;
  1. SRVDATA ; Get Service Level Data of EOB file (#361.1 Level 15)
  1. ;
  1. N LNLVL,RLVL,GLVL,RLVLD,GLVLD,SRVDED,GRPCD,RSNCD,SRVCOIN,I,MOD,SRMKS,LNLVLD
  1. N PRCD,REVCD,UNIT,SRVDT,PRCTYP,ALWD,PAID,SRVDED,GLVL,RCNT,OPRCD,TOTL,LNORD,LNCNT
  1. ; Use array LNORD to sort Service Lines in order of Referenced Line #
  1. S LNLVL=0,LNCNT=1000
  1. F S LNLVL=$O(^IBM(361.1,IEN,15,LNLVL)) Q:'LNLVL S LNORD=$P(^(LNLVL,0),U,12) D ;
  1. . I LNORD S LNORD(LNORD)=LNLVL Q
  1. . S LNORD(LNCNT)=LNLVL,LNCNT=LNCNT+1
  1. ;
  1. S LNORD=0
  1. F S LNORD=$O(LNORD(LNORD)) Q:'LNORD S LNLVL=LNORD(LNORD) D I IBQUIT Q
  1. . S LNLVLD=$G(^IBM(361.1,IEN,15,LNLVL,0)) I LNLVLD="" Q
  1. . I ($Y+4)>IOSL D I IBQUIT Q
  1. . . D PAUSE I IBQUIT Q
  1. . . W @IOF D CLMHDR^IBCEMRAA
  1. . . D SRVHDR
  1. . ;
  1. . K MOD,RCNT,TOTL S RCNT=0
  1. . ; Procedure Code, Revenue Code, Units, From Service Date, Procedure Type
  1. . S PRCD=$P(LNLVLD,U,4),REVCD=$P(LNLVLD,U,10),UNIT=$P(LNLVLD,U,11),SRVDT=$P(LNLVLD,U,16)
  1. . S PRCTYP=$P(LNLVLD,U,18) I PRCTYP="NU" S PRCTYP="" ;don't display NU for Proc Type
  1. . ; Resolve Revenue Code Pointer
  1. . I REVCD'="" S REVCD=$P($G(^DGCR(399.2,REVCD,0)),U)
  1. . ; Allowed, Payment, Original Procedure Code
  1. . S ALWD=$P(LNLVLD,U,13),PAID=$P(LNLVLD,U,3),OPRCD=$P(LNLVLD,U,15)
  1. . ; Handle Multiple Paid Modifiers from the Service Line Level (may have 4 mod's, could only fit 3)
  1. . M MOD=^IBM(361.1,IEN,15,LNLVL,2) S MOD="" F I=1:1:3 Q:'$D(MOD(I)) S MOD=MOD_$S(MOD="":"",1:",")_MOD(I,0)
  1. . ; Get Total Charge by matching 837 Extract Records with Bill's Original Line# on the current Service Line (LNLVLD)
  1. . S TOTL=$P($G(IBZDATA($P(LNLVLD,U,12))),U,5)
  1. . ; Service Line Level Remarks Codes
  1. . S SRMKS=$G(^IBM(361.1,IEN,15,LNLVL,3))
  1. . ; Row 24 - print Service date only on Outpatient claims (skip on Inpatients)
  1. . W ! I '$G(INPAT) W $$FMTE^XLFDT(SRVDT,5)
  1. . W ?12,PRCTYP,?15,PRCD,?21,MOD,?30,REVCD,?41,$J(UNIT,7),?49,$J($G(TOTL),12,2)
  1. . ;
  1. . ; Get Service Level Group Code/Reason Code Data
  1. . ; RLVLD=reason_code^amount^quantity^reason text
  1. . S (SRVDED,GLVL,RCNT,SRVCOIN)=0 K RSNCD
  1. . F S GLVL=$O(^IBM(361.1,IEN,15,LNLVL,1,GLVL)) Q:'GLVL S GLVLD=^(GLVL,0) D ;
  1. . . S GRPCD=$P(GLVLD,U),RLVL=0
  1. . . F S RLVL=$O(^IBM(361.1,IEN,15,LNLVL,1,GLVL,1,RLVL)) Q:'RLVL S RLVLD=^(RLVL,0),RSNCD=$P(RLVLD,U) D ;
  1. . . . I GRPCD="PR",RSNCD="AAA" Q ;exception
  1. . . . I GRPCD="OA",RSNCD="AB3" Q ;exception
  1. . . . I GRPCD="LQ" Q ;exception
  1. . . . I GRPCD="PR",RSNCD=1!(RSNCD=66) S SRVDED=SRVDED+$P(RLVLD,U,2) Q ;deductible
  1. . . . I GRPCD="PR",RSNCD=2 S SRVCOIN=$P(RLVLD,U,2) Q ;coinsurance
  1. . . . S RCNT=RCNT+1,RSNCD(RCNT)=GRPCD_"-"_RSNCD_U_$P(RLVLD,U,2)
  1. . ; Print Service Level Group Code/Reason Code Data
  1. . ; Service Level deductible, Coinsurance, Allowed, Paid Amount
  1. . W ?62,$J(SRVDED,11,2),?74,$J(SRVCOIN,11,2),?86,$J(ALWD,11,2),?98,$J(PAID,11,2)
  1. . ; Print Group Code-Reason Code, Adjustment Amount
  1. . F I=1:1:RCNT W:I>1 ! W ?111,$P(RSNCD(I),U),?118,$J($P(RSNCD(I),U,2),12,2)
  1. . ; Row 25
  1. . I OPRCD="",(SRMKS="") Q
  1. . W ! I OPRCD'="" W ?15,"(",$E(OPRCD,1,4),")"
  1. . I SRMKS'="" W ?26,"REM:",?30,$P(SRMKS,U)
  1. ;
  1. Q ;SRVDATA
  1. ;
  1. PAUSE ; Pause at the bottom of screen. This section is called
  1. ; from different points of the MRA report.
  1. ;
  1. I $E(IOST,1,2)'["C-" Q ;if not terminal, don't pause
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT
  1. S DIR(0)="E" D ^DIR
  1. I $D(DIRUT)!($D(DUOUT)) S IBQUIT=1 Q
  1. Q ;PAUSE
  1. ;
  1. DSCLMR ;
  1. N LINE
  1. S $P(LINE,"-",122)=""
  1. W !!,LINE
  1. W !,"This is a printed representation of a remittance advice, developed through a joint effort between the Centers for Medicare and"
  1. W !,"Medicaid Services and the Department of Veterans Affairs, for a claim for services or supplies furnished to a Medicare-eligible"
  1. W !,"veteran through a facility of the Department of Veterans Affairs. The remittance advice shows the amount that Medicare would have"
  1. W !,"paid had the claim been payable by Medicare, as well as the coinsurance and deductible amounts that would have applied."
  1. W !,"The claim is not payable under the Medicare program, and no Medicare payment was issued."
  1. W !
  1. Q ;DSCLMR
  1. ;
  1. LINELVL ; This section is called when printing Institutional Reports
  1. ; The values of Coinsurance, Contractual Adjustment, Noncovered Charges
  1. ; and Deductible are calculated from the Service Line level and not
  1. ; from the Claim level.
  1. ;
  1. ; RLVLD=reason_code^amount^quantity^reason text
  1. ; IBCOINS,IBCTADJ,NCVRCHRG,CLMADJ are set to zero in the calling section CLMDATA
  1. ;
  1. N LNLVL,LNLVLD,GLVL,GLVLD,RLVL,RLVLD,GRPCD,RSNCD
  1. S LNLVL=0
  1. F S LNLVL=$O(^IBM(361.1,IEN,15,LNLVL)) Q:'LNLVL S LNLVLD=^(LNLVL,0) D ;
  1. . S GLVL=0 F S GLVL=$O(^IBM(361.1,IEN,15,LNLVL,1,GLVL)) Q:'GLVL S GLVLD=^(GLVL,0) D ;
  1. . . S GRPCD=$P(GLVLD,U),RLVL=0
  1. . . F S RLVL=$O(^IBM(361.1,IEN,15,LNLVL,1,GLVL,1,RLVL)) Q:'RLVL S RLVLD=^(RLVL,0),RSNCD=$P(RLVLD,U) D ;
  1. . . . I GRPCD="PR",RSNCD="AAA" Q ;exception
  1. . . . I GRPCD="OA",RSNCD="AB3" Q ;exception
  1. . . . I GRPCD="LQ" Q ;exception
  1. . . . ; set Claim Adjustment only if none were found at the claim level (don't check for group code)
  1. . . . I RCLMADJ[(","_RSNCD_",") S CLMADJ=CLMADJ+$P(RLVLD,U,2)
  1. . . . ; Coinsurance
  1. . . . I GRPCD="PR",RCOINS[(","_RSNCD_",") S IBCOINS=IBCOINS+$P(RLVLD,U,2) Q
  1. . . . ; Deductible
  1. . . . I GRPCD="PR" I RCDED[(","_RSNCD_",") S IBDED=IBDED+$P(RLVLD,U,2) Q
  1. . . . I GRPCD="CO" D ;
  1. . . . . ; Contractual Adjustment
  1. . . . . I RCTADJ[(","_RSNCD_",") S IBCTADJ=IBCTADJ+$P(RLVLD,U,2)
  1. . . . . ; Noncovered Charges
  1. . . . . I RCNCVR'[(","_RSNCD_",") S NCVRCHRG=NCVRCHRG+$P(RLVLD,U,2)
  1. Q ;LINELVL
  1. ;