IBCU41 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (OP VISIT DATES) ;6-JUN-93
;;2.0;INTEGRATED BILLING;**80,106,51,294,592,714**;21-MAR-94;Build 8
;;Per VA Directive 6402, this routine should not be modified.
;
;
OPV(DATE,IFN) ;input transform for outpatient visit dates (399,43,.01)
;input: DATE - to add
; IFN - bill to add to
;returns: 1 - if OK to add
; 0 - if not
N X,Y S X=1
I '$$OPV2(DATE,IFN,1) S X=0
I '$$OPV1(IFN,1) S X=0
S Y=$$APPT^IBCU3(DATE,$P($G(^DGCR(399,IFN,0)),U,2),1)
S Y=$$DUPCHK(DATE,IFN,1)
Q X
;
OPV1(IFN,DISP,CNT) ;edit checks for adding visit dates, if any of these fail then no visit date should be added to the bill
;these are the types of checks that if they fail a message should be displayed to the user
;does not check date passed in against existing dates, assumes new visit date
;input: IFN - required, internal file number of bill to check
; DISP - if true then error messager will be printed, if any
; CNT - number of visit dates user wants to add to bill
;returns: "1^warning message" - if OK to add more visit dates to the bill
; "0^error message" - if no more visit dates should added to the bill
;
N X,Y S Y=1 S:$G(CNT)="" CNT=1 S:$G(UN)="" UN=$G(^DGCR(399,+IFN,"U"))
I '$P(UN,U,1) S Y="0^No 'Statement From' date on file ... Can't enter OP visit dates ..." G OPV1E
I '$P(UN,U,2) S Y="0^No 'Statement To' date on file ... Can't enter OP visit dates ..." G OPV1E
G:'$O(^DGCR(399,IFN,"OP",0))&(CNT<2) OPV1E
I $P($G(^DGCR(399,IFN,"OP",0)),U,4)+CNT>30 S Y="0^Maximum of 30 visit dates allowed per bill!" G OPV1E
I +$P($G(^DGCR(399,+IFN,0)),U,19)'=2,$D(^DGCR(399,IFN,"CP","ASC")) S Y="0^Only one visit date allowed on bills with Billable Amb. Surg. Codes!" G OPV1E
;warnings:
I +Y,+$P($G(^DIC(36,$S(+$G(^DGCR(399,IFN,"MP")):+^("MP"),$$MCRWNR^IBEFUNC(+$$CURR^IBCEF2(IFN)):+$$CURR^IBCEF2(IFN),1:0),0)),U,8) S Y="1^This insurance Company will only accept one visit per bill!" G OPV1E
OPV1E I +$G(DISP),$P(Y,U,2)'="" W !,?10,$P(Y,U,2)
Q Y
;
OPV2(DATE,IFN,DISP,UN) ;edit checks for adding visit dates, if any if these fail then the given date should not be added to the bill
;these are the types of checks that determine if a particular visit date should be presented to the user for possible addition to the bill
;does not check date passed in against existing dates, assumes new visit date
;also being used for Procedure Date (399,304,1) input transform
;input: DATE - required, date to check for addition to the bill
; IFN - required, internal file number of bill to check
; DISP - if true then error messager will be printed, if any
; UN - the "U" node of the bill, pass if alrady defined in a var
;returns: "1^warning message" - if date is OK to add to the bill
; "0^error message" - if date should not be added to the bill
;
N IBINDTS
N X,Y S Y=1,DATE=$P(DATE,".",1) S:$G(UN)="" UN=$G(^DGCR(399,+IFN,"U"))
S IBINDTS=+$P($G(^DGCR(399,+IFN,0)),U,28) ; IB*2.0*714
I IBINDTS>0,DATE<IBINDTS S Y="0^Can't enter a visit date prior to the initial date of service..." G OPV2E ; IB*2.0*714
I IBINDTS'>0,DATE<+UN S Y="0^Can't enter a visit date prior to the 'Statement From' date ..." G OPV2E ; IB*2.0*714
I DATE>+$P(UN,U,2) S Y="0^Can't enter a visit date later than the 'Statement To' date ..." G OPV2E
OPV2E I +$G(DISP),$P(Y,U,2)'="" W !,?10,$P(Y,U,2)
Q Y
;
DUPCHK(DATE,IFN,DISP,DFN,RTG,CTE) ;Check for duplicate billing of opt visit - checks for given visit date on other
;bills with the same rate type and that have not been cancelled (if not IFN then use DFN and RTG)
;input: DATE - visit date to check
; IFN - internal file number of bill date is being added to
; DISP - true if error message should be printed before exit, if any
; DFN - patient'S IFN (required only if IFN is not passed)
; RTG - rate group to check for (""), if no rate group (0 passed and/or no IFN) then any bill found for
; visit date will cause error message
; CTE - Claims Tracking entry IEN, for autobiller and dental claims - IB*2.0*592
;returns: 0 - if another bill was not found with this visit date, patient, and rate type
; (dup IFN)_"^error message" - if duplicate date found, same rate group, IFN of other bill w/visit date
;(initially set up to check for same rate group because MT billing was done on the UB-82 so it was valid to have multiple bills with different rate groups for the same episode)
N IFN2,Y,X,IBDENT S Y=0,DATE=$P(+$G(DATE),".",1),IFN=+$G(IFN),X=$G(^DGCR(399,IFN,0))
S DFN=$S(+$G(DFN):$G(DFN),1:$P(X,U,2)),RTG=$S($G(RTG)'="":RTG,1:$P(X,U,7)) G:'DFN DUPCHKE
I '$D(^DGCR(399,"AOPV",DFN,DATE)) G DUPCHKE
S IFN2=0 F S IFN2=$O(^DGCR(399,"AOPV",DFN,DATE,IFN2)) Q:'IFN2 I IFN2'=IFN D Q:+Y
. S X=$G(^DGCR(399,IFN2,0)) I $P(X,U,13)=7 Q ; bill for date cancelled
. I +RTG,RTG'=$P(X,U,7) Q ; different rate group
. ;JWS;IB*2.0*592 - allow for Dental claim, just not duplicate Dental claims for same date
. ;IA# 2056
. I +$G(CTE),$P($G(^IBT(356,CTE,0)),"^",3)'="" S IBDENT=$F($$GET1^DIQ(9000010,$P($G(^IBT(356,CTE,0)),"^",3)_",",.08),"DENTAL") I $G(IBDENT),$$FT^IBCEF(IFN2)'=7 Q
. S Y=IFN2_"^A "_$P($G(^DGCR(399.3,+$P(X,U,7),0)),U,1)_" bill ("_$P(X,U,1)_") exists for visit date ("_$$DAT1^IBOUTL(DATE)_")."
DUPCHKE I +$G(DISP),+Y W !,?10,$P(Y,U,2)
Q Y
;
CTCHK(IBIFN) ; if professional/institutional bill passed in has a corresponding institutional/professional
; bill defined return it's bill number
; check/match: patient, bill type, event date, rate type, payer seq, statement from, statement to, not cancelled
;
N IBFND,IB0,IBCT,IBDFN,IBEVDT,IBBT,IBRT,IBSEQ,IBSTDTS,IBCT1,IBIFN1,IB01 S IBFND=0
S IB0=$G(^DGCR(399,+$G(IBIFN),0)),IBCT=$P(IB0,U,27) I 'IBCT G CTCHKQ
S IBDFN=$P(IB0,U,2),IBEVDT=$P(IB0,U,3),IBBT=$P(IB0,U,5),IBRT=$P(IB0,U,7),IBSEQ=$P(IB0,U,21)
S IBSTDTS=$P($G(^DGCR(399,IBIFN,"U")),U,1,2),IBCT1=$S(IBCT=1:2,IBCT=2:1,1:"") I 'IBCT1 G CTCHKQ
;
S IBIFN1=0 F S IBIFN1=$O(^DGCR(399,"D",IBEVDT,IBIFN1)) Q:'IBIFN1 D Q:IBFND
. S IB01=$G(^DGCR(399,IBIFN1,0))
. I $P(IB01,U,13)=7 Q ; cancelled bill
. I IBDFN'=$P(IB01,U,2) Q ; patient
. I IBCT1'=$P(IB01,U,27) Q ; charge type
. I IBBT'=$P(IB01,U,5) Q ; bill type/classification
. I IBRT'=$P(IB01,U,7) Q ; rate type
. I '$P($G(^DGCR(399,IBIFN1,"S")),U,7),IBSEQ'=$P(IB01,U,21) Q ; payer sequence (applies to non-MRA claims only; IB*2*294 modification)
. I IBSTDTS'=$P($G(^DGCR(399,IBIFN1,"U")),U,1,2) Q ; from/thru dates
. S IBFND=IBIFN1 ; found a match
. Q
;
CTCHKQ Q IBFND
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCU41 6735 printed Oct 16, 2024@18:21:19 Page 2
IBCU41 ;ALB/ARH - THIRD PARTY BILLING UTILITIES (OP VISIT DATES) ;6-JUN-93
+1 ;;2.0;INTEGRATED BILLING;**80,106,51,294,592,714**;21-MAR-94;Build 8
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ;
OPV(DATE,IFN) ;input transform for outpatient visit dates (399,43,.01)
+1 ;input: DATE - to add
+2 ; IFN - bill to add to
+3 ;returns: 1 - if OK to add
+4 ; 0 - if not
+5 NEW X,Y
SET X=1
+6 IF '$$OPV2(DATE,IFN,1)
SET X=0
+7 IF '$$OPV1(IFN,1)
SET X=0
+8 SET Y=$$APPT^IBCU3(DATE,$PIECE($GET(^DGCR(399,IFN,0)),U,2),1)
+9 SET Y=$$DUPCHK(DATE,IFN,1)
+10 QUIT X
+11 ;
OPV1(IFN,DISP,CNT) ;edit checks for adding visit dates, if any of these fail then no visit date should be added to the bill
+1 ;these are the types of checks that if they fail a message should be displayed to the user
+2 ;does not check date passed in against existing dates, assumes new visit date
+3 ;input: IFN - required, internal file number of bill to check
+4 ; DISP - if true then error messager will be printed, if any
+5 ; CNT - number of visit dates user wants to add to bill
+6 ;returns: "1^warning message" - if OK to add more visit dates to the bill
+7 ; "0^error message" - if no more visit dates should added to the bill
+8 ;
+9 NEW X,Y
SET Y=1
if $GET(CNT)=""
SET CNT=1
if $GET(UN)=""
SET UN=$GET(^DGCR(399,+IFN,"U"))
+10 IF '$PIECE(UN,U,1)
SET Y="0^No 'Statement From' date on file ... Can't enter OP visit dates ..."
GOTO OPV1E
+11 IF '$PIECE(UN,U,2)
SET Y="0^No 'Statement To' date on file ... Can't enter OP visit dates ..."
GOTO OPV1E
+12 if '$ORDER(^DGCR(399,IFN,"OP",0))&(CNT<2)
GOTO OPV1E
+13 IF $PIECE($GET(^DGCR(399,IFN,"OP",0)),U,4)+CNT>30
SET Y="0^Maximum of 30 visit dates allowed per bill!"
GOTO OPV1E
+14 IF +$PIECE($GET(^DGCR(399,+IFN,0)),U,19)'=2
IF $DATA(^DGCR(399,IFN,"CP","ASC"))
SET Y="0^Only one visit date allowed on bills with Billable Amb. Surg. Codes!"
GOTO OPV1E
+15 ;warnings:
+16 IF +Y
IF +$PIECE($GET(^DIC(36,$SELECT(+$GET(^DGCR(399,IFN,"MP")):+^("MP"),$$MCRWNR^IBEFUNC(+$$CURR^IBCEF2(IFN)):+$$CURR^IBCEF2(IFN),1:0),0)),U,8)
SET Y="1^This insurance Company will only accept one visit per bill!"
GOTO OPV1E
OPV1E IF +$GET(DISP)
IF $PIECE(Y,U,2)'=""
WRITE !,?10,$PIECE(Y,U,2)
+1 QUIT Y
+2 ;
OPV2(DATE,IFN,DISP,UN) ;edit checks for adding visit dates, if any if these fail then the given date should not be added to the bill
+1 ;these are the types of checks that determine if a particular visit date should be presented to the user for possible addition to the bill
+2 ;does not check date passed in against existing dates, assumes new visit date
+3 ;also being used for Procedure Date (399,304,1) input transform
+4 ;input: DATE - required, date to check for addition to the bill
+5 ; IFN - required, internal file number of bill to check
+6 ; DISP - if true then error messager will be printed, if any
+7 ; UN - the "U" node of the bill, pass if alrady defined in a var
+8 ;returns: "1^warning message" - if date is OK to add to the bill
+9 ; "0^error message" - if date should not be added to the bill
+10 ;
+11 NEW IBINDTS
+12 NEW X,Y
SET Y=1
SET DATE=$PIECE(DATE,".",1)
if $GET(UN)=""
SET UN=$GET(^DGCR(399,+IFN,"U"))
+13 ; IB*2.0*714
SET IBINDTS=+$PIECE($GET(^DGCR(399,+IFN,0)),U,28)
+14 ; IB*2.0*714
IF IBINDTS>0
IF DATE<IBINDTS
SET Y="0^Can't enter a visit date prior to the initial date of service..."
GOTO OPV2E
+15 ; IB*2.0*714
IF IBINDTS'>0
IF DATE<+UN
SET Y="0^Can't enter a visit date prior to the 'Statement From' date ..."
GOTO OPV2E
+16 IF DATE>+$PIECE(UN,U,2)
SET Y="0^Can't enter a visit date later than the 'Statement To' date ..."
GOTO OPV2E
OPV2E IF +$GET(DISP)
IF $PIECE(Y,U,2)'=""
WRITE !,?10,$PIECE(Y,U,2)
+1 QUIT Y
+2 ;
DUPCHK(DATE,IFN,DISP,DFN,RTG,CTE) ;Check for duplicate billing of opt visit - checks for given visit date on other
+1 ;bills with the same rate type and that have not been cancelled (if not IFN then use DFN and RTG)
+2 ;input: DATE - visit date to check
+3 ; IFN - internal file number of bill date is being added to
+4 ; DISP - true if error message should be printed before exit, if any
+5 ; DFN - patient'S IFN (required only if IFN is not passed)
+6 ; RTG - rate group to check for (""), if no rate group (0 passed and/or no IFN) then any bill found for
+7 ; visit date will cause error message
+8 ; CTE - Claims Tracking entry IEN, for autobiller and dental claims - IB*2.0*592
+9 ;returns: 0 - if another bill was not found with this visit date, patient, and rate type
+10 ; (dup IFN)_"^error message" - if duplicate date found, same rate group, IFN of other bill w/visit date
+11 ;(initially set up to check for same rate group because MT billing was done on the UB-82 so it was valid to have multiple bills with different rate groups for the same episode)
+12 NEW IFN2,Y,X,IBDENT
SET Y=0
SET DATE=$PIECE(+$GET(DATE),".",1)
SET IFN=+$GET(IFN)
SET X=$GET(^DGCR(399,IFN,0))
+13 SET DFN=$SELECT(+$GET(DFN):$GET(DFN),1:$PIECE(X,U,2))
SET RTG=$SELECT($GET(RTG)'="":RTG,1:$PIECE(X,U,7))
if 'DFN
GOTO DUPCHKE
+14 IF '$DATA(^DGCR(399,"AOPV",DFN,DATE))
GOTO DUPCHKE
+15 SET IFN2=0
FOR
SET IFN2=$ORDER(^DGCR(399,"AOPV",DFN,DATE,IFN2))
if 'IFN2
QUIT
IF IFN2'=IFN
Begin DoDot:1
+16 ; bill for date cancelled
SET X=$GET(^DGCR(399,IFN2,0))
IF $PIECE(X,U,13)=7
QUIT
+17 ; different rate group
IF +RTG
IF RTG'=$PIECE(X,U,7)
QUIT
+18 ;JWS;IB*2.0*592 - allow for Dental claim, just not duplicate Dental claims for same date
+19 ;IA# 2056
+20 IF +$GET(CTE)
IF $PIECE($GET(^IBT(356,CTE,0)),"^",3)'=""
SET IBDENT=$FIND($$GET1^DIQ(9000010,$PIECE($GET(^IBT(356,CTE,0)),"^",3)_",",.08),"DENTAL")
IF $GET(IBDENT)
IF $$FT^IBCEF(IFN2)'=7
QUIT
+21 SET Y=IFN2_"^A "_$PIECE($GET(^DGCR(399.3,+$PIECE(X,U,7),0)),U,1)_" bill ("_$PIECE(X,U,1)_") exists for visit date ("_$$DAT1^IBOUTL(DATE)_")."
End DoDot:1
if +Y
QUIT
DUPCHKE IF +$GET(DISP)
IF +Y
WRITE !,?10,$PIECE(Y,U,2)
+1 QUIT Y
+2 ;
CTCHK(IBIFN) ; if professional/institutional bill passed in has a corresponding institutional/professional
+1 ; bill defined return it's bill number
+2 ; check/match: patient, bill type, event date, rate type, payer seq, statement from, statement to, not cancelled
+3 ;
+4 NEW IBFND,IB0,IBCT,IBDFN,IBEVDT,IBBT,IBRT,IBSEQ,IBSTDTS,IBCT1,IBIFN1,IB01
SET IBFND=0
+5 SET IB0=$GET(^DGCR(399,+$GET(IBIFN),0))
SET IBCT=$PIECE(IB0,U,27)
IF 'IBCT
GOTO CTCHKQ
+6 SET IBDFN=$PIECE(IB0,U,2)
SET IBEVDT=$PIECE(IB0,U,3)
SET IBBT=$PIECE(IB0,U,5)
SET IBRT=$PIECE(IB0,U,7)
SET IBSEQ=$PIECE(IB0,U,21)
+7 SET IBSTDTS=$PIECE($GET(^DGCR(399,IBIFN,"U")),U,1,2)
SET IBCT1=$SELECT(IBCT=1:2,IBCT=2:1,1:"")
IF 'IBCT1
GOTO CTCHKQ
+8 ;
+9 SET IBIFN1=0
FOR
SET IBIFN1=$ORDER(^DGCR(399,"D",IBEVDT,IBIFN1))
if 'IBIFN1
QUIT
Begin DoDot:1
+10 SET IB01=$GET(^DGCR(399,IBIFN1,0))
+11 ; cancelled bill
IF $PIECE(IB01,U,13)=7
QUIT
+12 ; patient
IF IBDFN'=$PIECE(IB01,U,2)
QUIT
+13 ; charge type
IF IBCT1'=$PIECE(IB01,U,27)
QUIT
+14 ; bill type/classification
IF IBBT'=$PIECE(IB01,U,5)
QUIT
+15 ; rate type
IF IBRT'=$PIECE(IB01,U,7)
QUIT
+16 ; payer sequence (applies to non-MRA claims only; IB*2*294 modification)
IF '$PIECE($GET(^DGCR(399,IBIFN1,"S")),U,7)
IF IBSEQ'=$PIECE(IB01,U,21)
QUIT
+17 ; from/thru dates
IF IBSTDTS'=$PIECE($GET(^DGCR(399,IBIFN1,"U")),U,1,2)
QUIT
+18 ; found a match
SET IBFND=IBIFN1
+19 QUIT
End DoDot:1
if IBFND
QUIT
+20 ;
CTCHKQ QUIT IBFND