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

IBECEAU.m

Go to the documentation of this file.
  1. IBECEAU ;ALB/CPM - Cancel/Edit/Add... Utilities ;11-MAR-93
  1. ;;2.0;INTEGRATED BILLING;**91,249,402,651,663,678,715**;21-MAR-94;Build 25
  1. ;;Per VHA Directive 6402, this routine should not be modified.
  1. ;
  1. CHECK(TALK) ; Retrieve the institution and MAS Service pointer.
  1. ; Input: TALK -- 1 : do i/o (writes)
  1. ; 0 : no i/o
  1. N IBY,Y S (IBY,Y)=1
  1. D SITE^IBAUTL I Y<1 S IBY=Y W:$G(TALK) !!,"You must define your facility in the IB SITE PARAMETER file before proceeding!",!
  1. I IBY>0 D SERV^IBAUTL2 I IBY<1 W:$G(TALK) !!,"You must define the MAS Service Pointer in the IB SITE PARAMETER file",!,"before proceeding!",!
  1. Q IBY>0
  1. ;
  1. PAUSE ; Go to end of page to pause.
  1. N DIR,DIRUT,DUOUT,DTOUT,X,Y
  1. W ! F Y=$Y:1:21 W !
  1. S DIR("A")="Press RETURN to process the next charge or to return to the list"
  1. S DIR(0)="E" D ^DIR K DIR
  1. Q
  1. ;
  1. INPT(DAYS) ; Return a description for Billing Clock days.
  1. ; Input: DAYS -- Number of days in a billing clock
  1. ; Output: "1st", "2nd", "3rd", "4th"
  1. Q $S(DAYS>270:"4th",DAYS>180:"3rd",DAYS>90:"2nd",1:"1st")
  1. ;
  1. LAST(PAR) ; Find last action filed for any parent action.
  1. ; Input: PAR -- Parent IB Action
  1. ; Output: Last action filed for parent (or parent if none)
  1. N IBL,IBLDT,IBLAST
  1. S IBLAST="",IBLDT=$O(^IB("APDT",PAR,"")) I +IBLDT S IBL=0 F S IBL=$O(^IB("APDT",PAR,IBLDT,IBL)) Q:'IBL S IBLAST=IBL
  1. Q $S(IBLAST:IBLAST,1:PAR)
  1. ;
  1. BFO(DFN,DATE) ; Patient Billed For OPT Copay on a specified date?
  1. ; Input: DFN -- Pointer to the patient in file #2
  1. ; DATE -- Date of the Outpatient Visit
  1. ; Output: 0 -- Not billed the OPT copay on the visit date
  1. ; >0 -- Pointer to charge in file #350 that was billed
  1. N IBATYP,IBATYPN,IBL,IBND,IBN,Y
  1. I '$G(DFN)!'$G(DATE) G BFOQ
  1. S IBN=0 F S IBN=$O(^IB("AFDT",DFN,-DATE,IBN)) Q:'IBN D I ($P(IBATYPN,"^",11)=4)!($P(IBATYPN,"^",11)=8),"^1^3^"[("^"_$P(IBATYP,"^",5)_"^"),"^1^2^3^4^8^20^"[("^"_+$P(IBND,"^",5)_"^") S Y=IBL Q
  1. .S IBL=$$LAST(+$P($G(^IB(IBN,0)),"^",9)),IBND=$G(^IB(IBL,0))
  1. .S IBATYP=$G(^IBE(350.1,+$P(IBND,"^",3),0))
  1. .S IBATYPN=$G(^IBE(350.1,+$P(IBATYP,"^",9),0))
  1. BFOQ Q +$G(Y)
  1. ;
  1. CNP(DFN,DATE) ; Did the patient have a C&P Exam on a specified date?
  1. ; Input: DFN -- Pointer to the patient in file #2
  1. ; DATE -- Date of the Outpatient Visit
  1. ; Output: 0 -- Patient did not have a C&P Exam on the visit date
  1. ; 1 -- Patient had a C&P Exam on the visit date
  1. N I,IBD,IBSD,Y,IBVAL,IBCBK,IBFILTER,IBCNP,Z
  1. I '$G(DFN)!'$G(DATE) G CNPQ
  1. ; - check appts, stop codes
  1. S IBVAL("DFN")=DFN,IBVAL("BDT")=DATE,IBVAL("EDT")=DATE+.9999
  1. ; Only parent appt or add/edit encounters
  1. S IBFILTER=""
  1. S IBCBK="I '$P(Y0,U,6),$P(Y0,U,8)<3 N Z S Z=$P(Y0,U,8) I $S(Z=1:$P(Y0,U,10)=1&($P(Y0,U,12)<3),Z=2:$P(Y0,U,10)=1,1:0) S (IBCNP,SDSTOP)=1"
  1. S IBCNP=0
  1. D SCAN^IBSDU("PATIENT/DATE",.IBVAL,IBFILTER,IBCBK,1) K ^TMP("DIERR",$J)
  1. I IBCNP S Y=1
  1. CNPQ Q +$G(Y)
  1. ;
  1. HDR(OPT) ; Display the header for an action
  1. ; Input: OPT -- Action Header
  1. N ADD,HDR S ADD=OPT="A D D"
  1. D CLEAR^VALM1 S IBY=1,HDR=OPT_" A C H A R G E"
  1. I 'ADD S IBIDX=$G(^TMP("IBACMIDX",$J,IBNBR)),IBN=+$P(IBIDX,"^",4),IBND=$G(^IB(IBN,0))
  1. W !?(80-$L(HDR)\2),HDR W:'ADD !?29,"Processing Charge #",IBNBR
  1. W !,$$LINE,!?3,"Name: ",$P(IBNAM,"^") W:'ADD ?41,"Type: ",$P(IBIDX,"^",3)
  1. I ADD W ?41,"** " W:'IBCLDA "NO " W "ACTIVE BILLING CLOCK **"
  1. W !?5,"ID: ",$P(IBNAM,"^",2) W:'ADD ?42,"Amt:",$P(IBIDX,"^",5)," (",$P(IBIDX,"^",6),")"
  1. I ADD,IBCLDA W ?44,"Clock Begin Date: ",$$DAT1^IBOUTL(IBCLDT)
  1. W !,$$LINE,!
  1. Q
  1. ;
  1. LINE() ; Write a line.
  1. Q $TR($J("",80)," ","-")
  1. ;
  1. CLOCK(IBDOL,IBDAYPR,IBDAY) ; Display and update clock data.
  1. ; Input: IBDOL -- Dollar amount to add or subtract
  1. ; IBDAYPR -- Existing number of inpatient days
  1. ; IBDAY -- Inpatient days to add or subtract
  1. ; Also assumes that IBCLST,IBNAM, IBCLDA, and IBXA are defined.
  1. D CLDSP^IBECEAU1(IBCLST,IBNAM) I $P(IBCLST,"^",4)'=1 W !,"** Please note that an active billing clock was not selected for updating **"
  1. I IBXA=1!(IBXA=2) D CLAMT^IBECEAU1(IBCLST,IBDOL,IBCLDA)
  1. I IBXA=3 D CLINP^IBECEAU1(IBDAYPR,IBDAY,IBCLDA)
  1. Q
  1. ;
  1. ;IB*2.0*651 - added new duplicate check for medical copays for the date period listed by the copay.
  1. ;
  1. BFCHK(DFN,DATE,EDATE) ;
  1. ; Input: DFN -- Pointer to the patient in file #2
  1. ; SDATE -- Start Date of the Patient Visit (inpatient or outpatient)
  1. ; EDATE -- (Optional) End Date of the Patient Visit (inpatient only)
  1. ;
  1. ; Output: 0 -- Not billed the OPT copay on the visit date
  1. ; >0 -- Pointer to charge in file #350 that was billed
  1. ;
  1. N IBATYP,IBATYPN,IBATYPNM,IBL,IBND,IBN,Y,SDATE,IBFLG,EDATEH,DATEH,IBLPDT,IBSTAT,IBSEQNM,IBAT,IBATBG,DATEL
  1. N IBFDT,IBTDT,IBJ,IBDATA,IBTO
  1. I '$G(DFN)!'$G(DATE) G BFCHKQ
  1. S EDATE=$G(EDATE) ; ensuring optional end date is initialized.
  1. S:EDATE="" EDATE=$G(IBTO) ; use the To date
  1. I EDATE="" S EDATE=DATE ; if no To Date, assume 1 day, use the From date
  1. ;
  1. ;Pharmacy copays are allowed to duplicate with other Medical Copays.
  1. Q:IBXA=5 0
  1. ;
  1. ; Check for entries within the given start and end date range
  1. ;convert to internal dates
  1. S DATEH=$P($$F2H^XLFDT(DATE),","),EDATEH=$P($$F2H^XLFDT(EDATE),",")
  1. F IBLPDT=DATEH:1:EDATEH D G:+$G(Y) BFCHKQ
  1. .S Y=0
  1. .;Convert looping date back to Fileman Date Format
  1. .S SDATE=$$H2F^XLFDT(IBLPDT)
  1. .;Set the correct starting date for the lookup
  1. .S SDATE=$S($D(^IB("AFDT",DFN,-SDATE)):-SDATE,1:$O(^IB("AFDT",DFN,-SDATE)))
  1. .Q:SDATE=""
  1. .S IBN=0 F S IBN=$O(^IB("AFDT",DFN,SDATE,IBN)) Q:'IBN D I 'IBFLG I $P(IBATYPN,U,11)'=5,"^1^3^"[(U_$P(IBATYP,U,5)_U),"^1^2^3^4^8^20^"[(U_+$P(IBND,U,5)_U) S Y=IBL Q
  1. ..S IBFLG=0
  1. ..S IBL=$$LAST(+$P($G(^IB(IBN,0)),U,9)),IBND=$G(^IB(IBL,0)),IBFDT=$P(IBND,U,14),IBTDT=$P(IBND,U,15)
  1. ..S DATEL=-SDATE
  1. ..I (IBFDT=""),(IBTDT="") S IBFLG=1 Q ;This is a parent Admission (VA/CC/LTC Record. Does not Dup check.
  1. ..I EDATE<IBFDT S IBFLG=1 Q ;The end date of the bill is prior to the start date of the copay being entered.
  1. ..I DATE>IBTDT S IBFLG=1 Q ;The start date of the copay being entered is before the end date of the copay being checked.
  1. ..S IBATYP=$G(^IBE(350.1,+$P(IBND,U,3),0)) ;Grab the action type for the Copay
  1. ..S IBATYPN=$G(^IBE(350.1,+$P(IBATYP,U,9),0)) ;Grab the associated new Action Type for the Copay
  1. ..I IBXA=3,$P(IBATYPN,U,11)<3 S IBFLG=1 Q ;Allow Inpatient Per Diem on an Inpatient Copay
  1. ..; check for Tricare duplicates IB*2.0*715
  1. ..I IBXA=7 D
  1. ...I $P(IBATYPN,U,11)'=IBXA S IBFLG=1 Q ; non-Tricare charge is not a duplicate
  1. ...S IBATYPNM=$P(IBATYPN,U)
  1. ...I IBATYPNM["RX" S IBFLG=1 Q ; Tricare RX is not a duplicate
  1. ...Q
  1. ..;
  1. ..Q
  1. .Q
  1. I IBXA=7 Q 0 ; skip Per Diem check, if copay being charged is Tricare IB*2.0*715
  1. ;
  1. ;If the copay being charged is an Inpatient Copay (Bill groups 1 and 2) then skip the Per Diem check, no dup found
  1. I +IBXA<3,+IBXA>0 Q 0
  1. ;
  1. ;IB*2.0*663
  1. ;Check for an existing duplicate Inpatient Per Diem separately.
  1. S Y=0
  1. S IBJ=0 F S IBJ=$O(^IB("C",DFN,IBJ)) Q:'IBJ D Q:+$G(Y)
  1. . S IBDATA=$G(^IB(IBJ,0)),IBFDT=$P(IBDATA,U,14),IBTDT=$P(IBDATA,U,15),IBAT=$P(IBDATA,U,3),IBSTAT=$P(IBDATA,U,5)
  1. . Q:IBAT=""
  1. . S IBATBG=$P($G(^IBE(350.1,IBAT,0)),U,11)
  1. . Q:IBATBG'=3
  1. . S IBSEQNM=$P($G(^IBE(350.1,IBAT,0)),U,5)
  1. . I '$$CHKSTAT(IBSTAT) Q
  1. . I (IBSEQNM=1)!(IBSEQNM=3) D
  1. . . Q:EDATE<IBFDT ;The end date of the bill is prior to the start date of the copay being entered.
  1. . . Q:DATE>IBTDT ;The start date of the copay being entered is before the end date of the copay being checked.
  1. . . S Y=IBJ
  1. ;
  1. BFCHKQ Q +$G(Y)
  1. ;
  1. CHKSTAT(IBSTAT) ; Check to see if the status on the copay allows for the copay to be checked for a duplicate
  1. ;
  1. ;INPUT: IBSTAT - The status on the copay being evaluated
  1. ;RETURNS: 1 - Allow the duplicate copay check to continue (for the INCOMPLETE, COMPLETE, BILLED, UPDATED, ON HOLD, HOLD - RATE statuses)
  1. ; 0 - Don't check for duplication
  1. ;
  1. Q:IBSTAT=1 1 ; INCOMPLETE
  1. Q:IBSTAT=2 1 ; COMPLETE
  1. Q:IBSTAT=3 1 ; BILLED
  1. Q:IBSTAT=4 1 ; UPDATED
  1. Q:IBSTAT=8 1 ; ON HOLD
  1. Q:IBSTAT=20 1 ; HOLD - RATE status
  1. Q 0