IBCRBG ;ALB/ARH - RATES: BILL SOURCE EVENTS (INPT) ; 21 MAY 96 ;;2.0;INTEGRATED BILLING;**52,80,106,51,142,159,210,245**;21-MAR-94 ;;Per VHA Directive 10-93-142, this routine should not be modified. ; INPTPTF(IBIFN,CS) ; search PTF record for billable bedsections, transfer DRGs, and length of stay ; - screens out days for pass, leave and SC treatment ; - adds charges for only one BS if the ins company does not allow multiple bedsections per bill (36,.06) ; Output: ^TMP($J,"IBCRC-INDT", BILLABLE DATE) = MOVE DT/TM ^ BILL BS ^ SC FLAG ^ DRG ^ DIVISION ^ SPECIALTY ; N IB0,DFN,PTF,IBU,IBBDT,IBEDT,IBTF,IBADM,IBX,IBINSMBS K ^TMP($J,"IBCRC-PTF"),^TMP($J,"IBCRC-DIV"),^TMP($J,"IBCRC-INDT") ; S IB0=$G(^DGCR(399,+$G(IBIFN),0)),DFN=$P(IB0,U,2) Q:'DFN S IBTF=$P(IB0,U,6),PTF="" S:$P(IB0,U,5)<3 PTF=$P(IB0,U,8) Q:'PTF S IBINSMBS=0,IBX=+$G(^DGCR(399,+IBIFN,"MP")) I 'IBX,$$MCRWNR^IBEFUNC($$CURR^IBCEF2(IBIFN)) S IBX=$$CURR^IBCEF2(IBIFN) I $P($G(^DIC(36,+IBX,0)),U,6)=0 S IBINSMBS=1 ; 1 bs per bill ; S IBU=$G(^DGCR(399,+IBIFN,"U")) Q:'IBU S IBBDT=+IBU,IBEDT=$P(IBU,U,2) Q:'IBEDT ; S IBADM=$O(^DGPM("APTF",PTF,0)) ; find corresponding admission ; D PTF(PTF) ; get movements and bedsections D PTFDV(PTF) ; reset movements and bedsections for ward/division ; D BSLOS(IBBDT,IBEDT,IBTF,IBADM,IBINSMBS) ; calculate days in bedsections within timeframe of the bill ; K ^TMP($J,"IBCRC-PTF"),^TMP($J,"IBCRC-DIV") ; D INPTRSET^IBCRBG2(IBIFN,$G(CS)) Q ; PTF(PTF) ; find all movements in PTF for the admission by date and billing bedsection (501 movement) ; the movement date is the date the patient left the bedsection ; Output: ^TMP($J,"IBCRC-PTF", MOVE DT/TM)=MOVE DT/TM ^ BILL BEDSECTION ^ SC FLAG ^ TRANSFER DRG ^ ^ SPECIALTY ; N IBMOVE,IBMVLN,IBBILLBS,IBENDDT,IBMSC,IBMDRG S PTF=+$G(PTF) S IBMOVE=0 F S IBMOVE=$O(^DGPT(PTF,"M",IBMOVE)) Q:'IBMOVE D . S IBMVLN=^DGPT(PTF,"M",IBMOVE,0) . S IBBILLBS=+$$SPBB($P(IBMVLN,U,2)) ; billable bedsection . S IBENDDT=+$P(IBMVLN,U,10) I 'IBENDDT S IBENDDT=DT ; movement date (last date in bedsection) . S IBMSC="" I +$P(IBMVLN,U,18)=1 S IBMSC=1 ; sc movement . S IBMDRG=$$MVDRG(PTF,IBMOVE) ; movement DRG . S ^TMP($J,"IBCRC-PTF",IBENDDT)=IBENDDT_U_IBBILLBS_U_IBMSC_U_IBMDRG_U_U_+$P(IBMVLN,U,2) Q ; SPBB(SPCLTY) ; find the billable bedsection for a Specialty (42.4) ; returns billable bedsection IFN ^ billable bedsection name N IBX,IBY,IBZ S IBZ=0 S IBX=$P($G(^DIC(42.4,+$G(SPCLTY),0)),U,5) I IBX'="" S IBY=$O(^DGCR(399.1,"B",IBX,0)) I +IBY S IBZ=IBY_U_IBX Q IBZ ; BSLOS(IBBDT,IBEDT,IBTF,IBADM,IBINSMBS) ; from the array of PTF movments get all bedsections and their LOS covered by date range of the bill ; adds all days for first cronological bs if ins comp wants only a single bs per bill, even if not sequential ; the movement date is the date the patient left the bedsection, so admission date is not in PTF array ; ; Input: ^TMP($J,"IBCRC-PTF", MOVE DT/TM) = MOVE DT/TM ^ BILL BS ^ SC FLAG ^ DRG ^ DIVISION ^ SPECIALTY ; Output: ^TMP($J,"IBCRC-INDT", BILLABLE DATE) = MOVE DT/TM ^ BILL BS ^ SC FLAG ^ DRG ^ DIVISION ^ SPECIALTY ; N IBSBDT,IBSEDT,IBS,IBLASTDT,IBX S IBSBDT=IBBDT+.3 ; discount any movements ending on or before the begin date S IBSEDT=IBEDT\1 ; I ",2,3,"'[IBTF S IBSEDT=IBSEDT-.01 ; final bill, do not count last day ; I +$G(IBADM) S IBX=$$AD^IBCU64(IBADM) I +IBX,($P(IBX,U,1)\1)=($P(IBX,U,2)\1) S IBSBDT=IBBDT ; reset 1 day stays ; S IBS=IBSBDT-.01 F S IBS=$O(^TMP($J,"IBCRC-PTF",IBS)) Q:'IBS D SET S IBLASTDT=IBS Q:(IBLASTDT\1)>IBSEDT ; Q ; SET ; checks a specific movement to determine if it should be billed and what the length of stay is ; setting of the movement date determines how many days are counted in the bedsection N IBMVLN,IBMBDT,IBMEDT,IBMTF,IBMLOS,IBI,IBCHGDT S IBMVLN=$G(^TMP($J,"IBCRC-PTF",IBS)) I '$P(IBMVLN,U,2) Q ; non-billable bedsection I +$P(IBMVLN,U,3) Q ; sc movement I +IBINSMBS,+$G(IBLASTDT) Q ; ins does not allow multiple bs ; S IBMBDT=$S(IBBDT>$G(IBLASTDT):IBBDT,1:IBLASTDT),IBMBDT=IBMBDT\1 ; start cnt on begin dt or last move dt S IBMEDT=$S(IBS5 S ICDEXP=1 ; patient expired . I IBDSST=4 S ICDDMS=1 ; patient left against medical advice . I IBDSST=5,+$P(PTF70,U,13) S ICDTRS=1 ; patient transfered to another facility ; S IBJ=0 F IBI=5:1:9 S IBDX=$P(PTFM0,U,IBI) I +IBDX,($$ICD9^IBACSV(+IBDX)'="") S IBJ=IBJ+1,ICDDX(IBJ)=IBDX ; I '$O(ICDDX(0)) G MVDRGQ ; S IBJ=0 S IBP=0 F S IBP=$O(^DGPT(+PTF,"S",IBP)) Q:'IBP D ; surguries . S IBPRC0=$G(^DGPT(+PTF,"S",IBP,0)) Q:'IBPRC0 . I +IBPRC0'IBEND D .. F IBI=8:1:12 S IBPRC=$P(IBPRC0,U,IBI) I +IBPRC,($$ICD0^IBACSV(+IBPRC)'="") S IBJ=IBJ+1,ICDPRC(IBJ)=+IBPRC ; S IBP=0 F S IBP=$O(^DGPT(+PTF,"P",IBP)) Q:'IBP D ; procedures . S IBPRC0=$G(^DGPT(+PTF,"P",IBP,0)) Q:'IBPRC0 . I +IBPRC0'IBEND D .. F IBI=5:1:9 S IBPRC=$P(IBPRC0,U,IBI) I +IBPRC,($$ICD0^IBACSV(+IBPRC)'="") S IBJ=IBJ+1,ICDPRC(IBJ)=+IBPRC ; S ICDDATE=$P(PTFM0,U,10) ; use the movement date for the DRG Grouper versioning D ^ICDDRG S IBDRG=$G(ICDDRG) ; MVDRGQ Q IBDRG