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

IBCEOB0.m

Go to the documentation of this file.
  1. IBCEOB0 ;ALB/TMP/PJH - 835 EDI EOB MSG PROCESSING ; 8/24/10 7:23pm
  1. ;;2.0;INTEGRATED BILLING;**135,280,155,431,488,516,633,727**;21-MAR-94;Build 34
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. Q
  1. ;
  1. LINE() ;Extract Provider Line Reference from 42 record
  1. N SUB,NODE,VAL
  1. S VAL="",SUB=IBA1 ; from loop in UPD3611^IBCEOB
  1. ;IB*2.0*516/TAZ - Quit when another RT 40 is encountered to prevent group of
  1. ;mismatched procedures
  1. F S SUB=$O(@IBFILE@(SUB)) Q:SUB="" D Q:(+NODE>42)!(+NODE=40)
  1. .S NODE=$G(@IBFILE@(SUB,0))
  1. .S:NODE["RAW DATA" NODE=$P(NODE," ",3,99)
  1. .;Q:+NODE'=42 S VAL=$P(NODE,U,5) ;WCJ;IB727;sometimes (always) only the first 42 record has piece 5 so grab the last one that is there.
  1. .Q:+NODE'=42
  1. .S:$P(NODE,U,5)]"" VAL=$P(NODE,U,5)
  1. Q VAL
  1. ;
  1. 30(IB0,IBEOB,IBOK) ; Process record type 30 for EOB
  1. ; IB0 = the record being processed
  1. ; IBEOB = the ien of the EOB entry in file 361.1
  1. ; IBOK = Returned as 1 if record filed OK, 0 if error occurred
  1. ;
  1. N A
  1. S A="3;4.01;0;1;1^5;4.02;0;1;1^6;4.03;1;0;0^7;4.05;1;0;0^8;4.06;1;0;0^9;4.07;1;0;0^10;4.08;1;0;0^11;4.09;1;0;0^12;4.1;1;0;0^13;4.11;1;0;0^14;4.19;0;1;1"
  1. ;
  1. S IBOK=$$STORE^IBCEOB1(A,IB0,IBEOB)
  1. I 'IBOK S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Bad MEDICARE Inpt Adjudication data"
  1. Q30 Q
  1. ;
  1. 40(IB0,IBEOB,IBOK) ; Process record type 40 for EOB
  1. ; IB0 = the record being processed
  1. ; IBEOB = the ien of the EOB entry in file 361.1
  1. ; IBOK = Returned as 1 if record filed OK, 0 if error occurred
  1. ;
  1. ; IBZDATA is also assumed to exist or if not, it is created in FINDLN
  1. ;
  1. N A,LEVEL,IBSEQ,IBDA,IBPC,IBLREF,IBIFN,Q,X,Y,DA,DD,DO,DIC,DLAYGO,PLREF,ERRCOD
  1. K ^TMP($J,40) ; the entry # for corresponding 41, 42, and 45 records
  1. ;
  1. S IBIFN=+$G(^IBM(361.1,IBEOB,0))
  1. L +^IBM(361.1,IBEOB,15):0 I $T S IBSEQ=+$O(^IBM(361.1,IBEOB,15," "),-1)+1
  1. I '$G(IBSEQ) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Record lock failure - could not acquire next service line number" G Q40
  1. ;
  1. ; Update the 40 record data a little bit (pieces 3/4/16)
  1. I $P(IB0,U,21)="NU" S $P(IB0,U,4)=$P(IB0,U,3),$P(IB0,U,3)=""
  1. S $P(IB0,U,16)=$S(+$P(IB0,U,16):$P(IB0,U,16)/100,1:+$P(IB0,U,18)/100)
  1. I $P(IB0,U,4)?1.N S $P(IB0,U,4)=+$P(IB0,U,4)
  1. ;
  1. ; Find the line item from original bill for this adjustment
  1. S PLREF=$S('HIPAA:$P(IB0,U,22),1:$$LINE()) ; old format from 40 record, new format from 42
  1. S ERRCOD=0
  1. S IBLREF=+$$FINDLN^IBCEOB1(IB0,IBEOB,.IBZDATA,+PLREF,.ERRCOD)
  1. I 'IBLREF D G Q40
  1. . N Z,Z0,CT,ETEXT
  1. . S EFLAG=0,ETEXT=""
  1. . ;;S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line detail could not be matched to a billed item"
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)=" "
  1. . S ETEXT=$P("Revenue Code^Procedure Code^Amount of Units^Charge Amount^Procedure Code Modifier",U,+ERRCOD)
  1. . I ETEXT="" S ETEXT="Data"
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)=$$ERRTXT(ETEXT,IBEOB) ; IB*2.0*633
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)=" "
  1. . D DET40^IBCEOB00(IB0,.Z0,ERRCOD)
  1. . S CT=+$O(^TMP(IBEGBL,$J,""),-1),Z=0 F S Z=$O(Z0(Z)) Q:'Z S CT=CT+1,^TMP(IBEGBL,$J,CT)=Z0(Z)
  1. ;
  1. S DIC="^IBM(361.1,"_IBEOB_",15,",DIC(0)="L",DLAYGO=361.115,DA(1)=IBEOB
  1. S X=IBSEQ
  1. S DIC("DR")=".12////"_+IBLREF_$S($P(IBLREF,U,2)="":"",1:";.15////"_$P(IBLREF,U,2))_";.16////"_$$DATE^IBCEU($P(IB0,U,19))_$S($P(IB0,U,20):";.17////"_$$DATE^IBCEU($P(IB0,U,20)),1:"")
  1. D FILE^DICN K DIC,DO,DD,DLAYGO ;Add a new LINE LEVEL ADJUSTMENT ('SVC')
  1. I Y<0 S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not add a LINE LEVEL ADJUSTMENT ("_IBSEQ_")" G Q40
  1. ;
  1. L -^IBM(361.1,IBEOB,15)
  1. ;
  1. S LEVEL=15.1,LEVEL(0)=+Y,LEVEL(1)=IBEOB,LEVEL("DIE")="^IBM(361.1,"_IBEOB_",15,"
  1. S A="3;.04;0;0;0^4;.1;0;0;0^9;.09;0;0;0^17;.03;1;0;0^18;.11;0;1;D2^21;.18;0;0;0"
  1. I '$P(IB0,U,18),$P(IB0,U,16) S $P(A,U,5)="16;.11;0;1;1"
  1. I $$STORE^IBCEOB1(A,IB0,IBEOB,.LEVEL) S ^TMP($J,40)=LEVEL(0),IBOK=1
  1. I '$G(IBOK) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Bad data for line level adjustment "_IBSEQ G Q40
  1. ;
  1. ; Store modifiers in multiple
  1. S DIC="^IBM(361.1,"_IBEOB_",15,"_LEVEL(0)_",2,",DIC(0)="L",DLAYGO=361.1152,DA(2)=IBEOB,DA(1)=LEVEL(0)
  1. F Q=5:1:8 S X=$P(IB0,U,Q) I X'="" D FILE^DICN K DO,DD I Y<0 S IBOK=0 Q
  1. K DLAYGO,DIC,DR,DA
  1. I '$G(IBOK) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not file modifier data for line level adjustment "_IBSEQ G Q40
  1. Q40 Q
  1. ;
  1. 41(IB0,IBEOB,IBOK) ; Process record type 41 for EOB
  1. ; IB0 = the record being processed
  1. ; IBEOB = the ien of the EOB entry in file 361.1
  1. ; IBOK = Returned as 1 if record filed OK, 0 if error occurred
  1. ;
  1. N DA,DR,DIE,X,Y,Z,Z0,CT
  1. I '$G(^TMP($J,40)) D G Q41
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line adjustment (EEOB Record 41) has no matching service line"
  1. . D DET4X^IBCEOB00(41,IB0,.Z0)
  1. . S CT=+$O(^TMP(IBEGBL,$J,""),-1),Z=0 F S Z=$O(Z0(Z)) Q:'Z S CT=CT+1,^TMP(IBEGBL,$J,CT)=Z0(Z)
  1. ;
  1. S DR="",IBOK=1
  1. S DA=+^TMP($J,40),DA(1)=IBEOB
  1. S DIE="^IBM(361.1,"_DA(1)_",15,"
  1. I +$P(IB0,U,3) S DR=".13///"_$$DOLLAR^IBCEOB($P(IB0,U,3))
  1. I +$P(IB0,U,4) S DR=DR_$S(DR="":"",1:";")_".14///"_$$DOLLAR^IBCEOB($P(IB0,U,4))
  1. I DR'="" D ^DIE S IBOK=($D(Y)=0)
  1. I '$G(IBOK) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Mismatched data for service line adjustment-2 (EEOB Record 41)"
  1. ;
  1. ; For Medicare MRA's only:
  1. ; If the Allowed Amount field is present, then we need to file an
  1. ; adjustment: Group code PR, Reason code AAA, Amount, Quantity, and
  1. ; Reason Text. This is data normally found on the 45 record, so we're
  1. ; going to create our own "45" record and file it.
  1. ;
  1. I $P($G(^IBM(361.1,IBEOB,0)),U,4)=1,+$P(IB0,U,3) D
  1. . N IB45,IBSAV40
  1. . S IB45=45_U_$P(IB0,U,2)_U_"PR"_U_"AAA"_U_$P(IB0,U,3)_U_"0000000001"
  1. . S IB45=IB45_U_"Allowed Amount"
  1. . S IBSAV40=$G(^TMP($J,40))
  1. . D 45(IB45,IBEOB,.IBOK)
  1. . S ^TMP($J,40)=IBSAV40
  1. . I '$G(IBOK) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not file the PR-AAA adjustment for the Allowed Amount at line "_+^TMP($J,40)
  1. . Q
  1. ;
  1. Q41 Q
  1. ;
  1. 42(IB0,IBEOB,IBOK) ; Process record type 42 for EOB
  1. ; IB0 = the record being processed
  1. ; IBEOB = the ien of the EOB entry in file 361.1
  1. ; IBOK = Returned as 1 if record filed OK, 0 if error occurred
  1. ;
  1. N DO,DD,DLAYGO,DIC,DA,X,Y,Z,Z0,CT
  1. S IBOK=0
  1. I '$G(^TMP($J,40)) D G Q42
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line adjustment (EEOB Record 42) has no matching service line"
  1. . D DET4X^IBCEOB00(42,IB0,.Z0)
  1. . S CT=+$O(^TMP(IBEGBL,$J,""),-1),Z=0 F S Z=$O(Z0(Z)) Q:'Z S CT=CT+1,^TMP(IBEGBL,$J,CT)=Z0(Z)
  1. ;
  1. K DO,DD,DLAYGO
  1. S IBOK=1
  1. S DA(1)=+^TMP($J,40),DA(2)=IBEOB
  1. S X=+$O(^IBM(361.1,DA(2),15,DA(1),4," "),-1)+1,DIC="^IBM(361.1,"_DA(2)_",15,"_DA(1)_",4,",DIC(0)="L",DLAYGO=361.1154
  1. S DIC("DR")=$S($P(IB0,U,3)'="":".02////"_$P(IB0,U,3),1:"")
  1. I $P(IB0,U,4)'="" S:$L(DIC("DR")) DIC("DR")=DIC("DR")_";" S DIC("DR")=DIC("DR")_".03////"_$TR($P(IB0,U,4),";"," ")
  1. D FILE^DICN K DO,DD,DLAYGO
  1. I Y'>0 S IBOK=0
  1. I '$G(IBOK) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Mismatched data for service line adjustment-3 (EEOB Record 42)"
  1. ;
  1. ; For Medicare MRA's only:
  1. ; Process and store the line level remark code as an LQ kludge line
  1. ; level adjustment.
  1. ;
  1. I $P($G(^IBM(361.1,IBEOB,0)),U,4)=1,$P(IB0,U,3)'="" D
  1. . N IB45,IBSAV40
  1. . S IB45=45_U_$P(IB0,U,2)_U_"LQ"_U_$P(IB0,U,3)_U_0_U_0_U_$P(IB0,U,4)
  1. . S IBSAV40=$G(^TMP($J,40))
  1. . D 45(IB45,IBEOB,.IBOK)
  1. . S ^TMP($J,40)=IBSAV40
  1. . I '$G(IBOK) S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not file the LQ-remark code adjustment at line "_+^TMP($J,40)
  1. . Q
  1. Q42 Q
  1. ;
  1. 45(IB0,IBEOB,IBOK) ; Process record type 45 for EOB
  1. ; IB0 = the record being processed
  1. ; IBEOB = the ien of the EOB entry in file 361.1
  1. ; IBOK = Returned as 1 if record filed OK, 0 if error occurred
  1. ;
  1. N IBDA,LEVEL,A,Z0,CT,Z
  1. I '$G(^TMP($J,40)) D G Q45
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line adjustment (EEOB Record 45) has no matching service line"
  1. . D DET4X^IBCEOB00(45,IB0,.Z0)
  1. . S CT=+$O(^TMP(IBEGBL,$J,""),-1),Z=0 F S Z=$O(Z0(Z)) Q:'Z S CT=CT+1,^TMP(IBEGBL,$J,CT)=Z0(Z)
  1. ;
  1. I $P(IB0,U,3)'="" S $P(^TMP($J,40),U,2)=$P(IB0,U,3)
  1. I $P(IB0,U,3)="" S $P(IB0,U,3)=$P(^TMP($J,40),U,2)
  1. I $P(IB0,U,3)="" S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line adjustment (EEOB Record 45) is missing its group code" G Q45
  1. ;
  1. S IBDA(2)=+^TMP($J,40)
  1. S IBDA(1)=+$O(^IBM(361.1,IBEOB,15,IBDA(2),1,"B",$P(IB0,U,3),0))
  1. ;
  1. I 'IBDA(1) D ;Needs a new entry at group level
  1. . N X,Y,DA,DD,DO,DIC,DLAYGO
  1. . S DIC="^IBM(361.1,"_IBEOB_",15,"_IBDA(2)_",1,",DIC(0)="L",DLAYGO=361.1151,DA(2)=IBEOB,DA(1)=IBDA(2)
  1. . S DIC("P")=$$GETSPEC^IBEFUNC(361.115,1)
  1. . S X=$P(IB0,U,3)
  1. . D FILE^DICN K DIC,DO,DD,DLAYGO
  1. . I Y<0 K IBDA S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not add adjustment group code ("_$P(IB0,U,3)_") at line adjustment "_+^TMP($J,40) Q
  1. . S IBDA(1)=+Y
  1. ;
  1. ;Add a new entry at the reason code level
  1. I $G(IBDA(1)) D
  1. . S DIC="^IBM(361.1,"_IBEOB_",15,"_IBDA(2)_",1,"_IBDA(1)_",1,",DIC(0)="L",DLAYGO=361.11511,DA(1)=IBDA(1),DA(2)=IBDA(2),DA(3)=IBEOB
  1. . S DIC("P")=$$GETSPEC^IBEFUNC(361.1151,1)
  1. . S X=$P(IB0,U,4)
  1. . D FILE^DICN K DIC,DO,DD,DLAYGO
  1. . I Y<0 K IBDA S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not add reason code ("_$P(IB0,U,4)_") for adjustment group code ("_$P(IB0,U,3)_") at line adjustment "_+^TMP($J,40) Q
  1. . S IBDA=+Y
  1. ;
  1. I $G(IBDA) D
  1. . S LEVEL=15,LEVEL("DIE")="^IBM(361.1,"_IBEOB_",15,"_IBDA(2)_",1,"_IBDA(1)_",1,"
  1. . S LEVEL(0)=IBDA,LEVEL(1)=IBDA(1),LEVEL(2)=IBDA(2),LEVEL(3)=IBEOB
  1. . S A="5;.02;1;0;0^6;.03;0;1;1^7;.04;0;1;0"
  1. . S IBOK=$$STORE^IBCEOB1(A,IB0,IBEOB,.LEVEL)
  1. . I 'IBOK S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Mismatched data for reason code ("_$P(IB0,U,4)_"), adjustment group code ("_$P(IB0,U,3)_") at line adjustment "_+^TMP($J,40) Q
  1. ;
  1. Q45 Q
  1. ;
  1. 46(IB0,IBEOB,IBOK) ; Process record type 46 for EOB
  1. ; IB0 = the record being processed
  1. ; IBEOB = the ien of the EOB entry in file 361.1
  1. ; IBOK = Returned as 1 if record filed OK, 0 if error occurred
  1. ;
  1. S IBOK=0
  1. N AGC,IBDA,LEVEL,A,Z0,CT,Z
  1. I '$G(^TMP($J,40)) D G Q46
  1. . S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line adjustment (EEOB Record 46) has no matching service line"
  1. . D DET4X^IBCEOB00(46,IB0,.Z0)
  1. . ;S CT=+$O(^TMP(IBEGBL,$J,""),-1),Z=0 F S Z=$O(Z0(Z)) Q:'Z S CT=CT+1,^TMP(IBEGBL,$J,CT)=Z0(Z)
  1. ;
  1. S AGC=$P(^TMP($J,40),U,2)
  1. I AGC="" S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Service line adjustment (EEOB Record 46) is missing its group code" G Q46
  1. ;
  1. S IBDA(2)=+^TMP($J,40)
  1. S IBDA(1)=+$O(^IBM(361.1,IBEOB,15,IBDA(2),1,"B",AGC,0))
  1. ;
  1. ;
  1. ;Add a new entry at the Payer Policy level
  1. I $G(IBDA(1)) D
  1. . S DIC="^IBM(361.1,"_IBEOB_",15,"_IBDA(2)_",1,"_IBDA(1)_",2,",DIC(0)="L",DLAYGO=361.11511,DA(1)=IBDA(1),DA(2)=IBDA(2),DA(3)=IBEOB
  1. . S DIC("P")=$$GETSPEC^IBEFUNC(361.1151,1)
  1. . S X=$P(IB0,U,3)
  1. . D FILE^DICN K DIC,DO,DD,DLAYGO
  1. . I Y<0 K IBDA S ^TMP(IBEGBL,$J,+$O(^TMP(IBEGBL,$J,""),-1)+1)="Could not add payer policy ("_$P(IB0,U,4)_") for adjustment group code ("_$P(IB0,U,3)_") at line adjustment "_+^TMP($J,40) Q
  1. . S IBDA=+Y,IBOK=1
  1. ;
  1. Q46 Q
  1. ;
  1. ; IB*2.0*633 - Begin modified code block
  1. ERRTXT(X,IBEOB) ; Set error text based on circumstances
  1. ; Input - X = Standard Error message passed in
  1. ; IB0
  1. ; Returns modified error message text
  1. N RETURN
  1. S RETURN="Mismatched "_X_":"
  1. I '$$EBILL(IBEOB) S RETURN="Claim was not Billed Electronically:"
  1. Q RETURN
  1. ;
  1. EBILL(IBEOB) ; Check If EOB was billed electronically
  1. ; Input : IBEOB = Internal entry number from file 361.1
  1. ; Returns : 1 - Billed electronically
  1. ; 0 - Not billed electronically
  1. N IEN399,IEN364,STATUS
  1. S IEN399=$$GET1^DIQ(361.1,IBEOB_",",.01,"I")
  1. S IEN364=$O(^IBA(364,"B",+IEN399,0))
  1. I 'IEN364 Q 0 ; No EDI TRANSMIT BILL
  1. ;
  1. S STATUS=$$GET1^DIQ(364,IEN364,.03,"I")
  1. I STATUS="E"!(STATUS="C") Q 0 ; Error or canceled
  1. Q 1
  1. ; IB*2.0*633 - End modified code block