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

IBTODD.m

Go to the documentation of this file.
  1. IBTODD ;ALB/AAS - CLAIMS TRACKING DENIED DAYS REPORT ; 27-OCT-93
  1. ;;2.0;INTEGRATED BILLING;**32,458,730**;21-MAR-94;Build 83
  1. ;
  1. % I '$D(DT) D DT^DICRW
  1. W !!,"Denied Days Report",!!
  1. ;
  1. S IBSORT="P",IBSELECT="1,2,3,4,"
  1. N DIR
  1. S DIR("?")="Answer YES if you only want to print a summary or answer NO if you want a detailed listing plus the summary."
  1. S DIR(0)="Y",DIR("A")="Print Summary Only",DIR("B")="YES" D ^DIR K DIR
  1. I $D(DIRUT) G END
  1. S IBSUM=Y
  1. G:IBSUM DATE
  1. ;
  1. ; -- ask what types of care to include
  1. D TYPE^IBTODD2 I IBSELECT<1 G END
  1. ;
  1. ; -- ask how they want inpatient sorted
  1. I IBSELECT[1 D SORT^IBTODD2 I IBSORT<0 G END
  1. ;
  1. DATE ; -- select date range
  1. W ! D DATE^IBOUTL
  1. I IBBDT=""!(IBEDT="") G END
  1. ;
  1. DEV ; -- select device, run option
  1. W !
  1. I 'IBSUM W !!,"You will need a 132 column printer for this report!",!
  1. S %ZIS="QM" D ^%ZIS G:POP END
  1. I $D(IO("Q")) S ZTRTN="DQ^IBTODD",ZTSAVE("IB*")="",ZTDESC="IB - Denied Days Report" D ^%ZTLOAD K IO("Q"),ZTSK D HOME^%ZIS G END
  1. ;
  1. U IO
  1. D DQ G END
  1. Q
  1. ;
  1. END ; -- Clean up
  1. W ! K ^TMP($J,"IBTODD")
  1. I $D(ZTQUEUED) S ZTREQ="@" Q
  1. D ^%ZISC
  1. K I,J,X,X2,Y,DFN,%ZIS,DGPM,VA,IBI,IBJ,IBTRN,IBTRND,IBTRND1,IBPAG,IBHDT,IBDISDT,IBETYP,IBQUIT,IBTAG,IBTRC,IBTRCD,IBDEN,IBDAY,IBTALL,IBADM,IBDISCH,IBMAX
  1. K IBAPL,IBBBS,IBBDT,IBC,IBCDT,IBCNT,IBDT,IBD,IBDATA,IBEDT,IBNAM,IBPRIM,IBPROV,IBRATE,IBSECN,IBSERV,IBSORT,IBSPEC,IBSUM,IBSUBT,IBTOTL,IBCNTO,IBEVNTYP,IBISV,IBSELECT
  1. D KVAR^VADPT
  1. Q
  1. DQ ; -- entry print from taskman
  1. K ^TMP($J,"IBTODD") F I=1:1 S J=$P(IBSELECT,",",I) Q:'J S ^TMP($J,"IBTODD",J)=""
  1. S X=132 X ^%ZOSF("RM")
  1. S IBPAG=0,IBHDT=$$HTE^XLFDT($H,1),IBQUIT=0
  1. S IBDEN=$O(^IBE(356.7,"ACODE",20,0))
  1. D BLD,PRINT^IBTODD1
  1. I $D(ZTQUEUED) G END
  1. Q
  1. ;
  1. BLD ; -- sort through data and build array to print from
  1. ;
  1. S IBTRC=0
  1. F S IBTRC=$O(^IBT(356.2,"ACT",IBDEN,IBTRC)) Q:'IBTRC D
  1. .N IBDAY S IBTRCD=$G(^IBT(356.2,+IBTRC,0))
  1. .S IBTRN=$P(IBTRCD,"^",2),IBTRND=$G(^IBT(356,+IBTRN,0))
  1. .Q:'$P(IBTRCD,"^",19) ; review is inactive
  1. .Q:'$P(IBTRND,"^",20) ; parent CT entry is inactive
  1. .S IBEVNTYP=$P(IBTRND,U,18) S:IBEVNTYP=5 IBEVNTYP=1
  1. . ;
  1. .I IBEVNTYP=1,IBSELECT[1 D Q
  1. ..S IBDDB=$P(IBTRCD,"^",15),IBDDE=$P(IBTRCD,"^",16)
  1. ..S IBTALL=$P($G(^IBT(356.2,+IBTRC,1)),"^",7)
  1. ..S IBLOSI=$$LOS(IBTRN) ; admissions length of stay
  1. ..I IBDDB,IBDDE Q:(IBDDB>IBEDT)!(IBDDE<IBBDT) D
  1. ...I IBDDB<IBBDT S IBDDB=IBBDT ; chk days denied in correct range
  1. ...I IBDDE>IBEDT S IBDDE=IBEDT
  1. ...S IBDAY=$$FMDIFF^XLFDT(IBDDE,IBDDB)+1 ; cals total denied days
  1. ..; if no days denied "to" and "from" and episode in range
  1. ..I (IBTALL),('$D(IBDAY)) S IBCDT=$$CDT^IBTODD1(IBTRN) D STRIP Q:('+IBCDT!(+IBCDT>IBEDT)) D
  1. ...;Q:'$P(IBTRND,U,5) ; quit if no link between ct and dgpm
  1. ...I '$P(IBCDT,U,2) S $P(IBCDT,U,2)=$$FMADD^XLFDT($P(IBCDT,U,1),1) ; unlinked all to event dt+1 los
  1. ...; if the care date is >the report range there is no discharge add 1
  1. ...I '$P(IBCDT,U,2)!($P(IBCDT,U,2)>IBEDT) S $P(IBCDT,U,2)=$$FMADD^XLFDT(IBEDT,1)
  1. ...I +IBCDT<IBBDT S $P(IBCDT,U,1)=IBBDT
  1. ...S IBDAY=$$FMDIFF^XLFDT($P(IBCDT,U,2),$P(IBCDT,U,1))
  1. ..I IBLOSI=1,$G(IBDAY)=0 S IBDAY=1 ; get one day stays
  1. ..Q:$G(IBDAY)<1
  1. ..S DFN=$P(IBTRCD,"^",5),IBNAM=$P($G(^DPT(+DFN,0)),"^") Q:IBNAM=""
  1. ..S IBD=$$PROV(DFN,IBTRCD,IBTRND,IBTALL),IBPROV=+IBD,IBSPEC=$P(IBD,"^",2),IBSERV=$P(IBD,"^",3)
  1. ..;S IBBBS=$$BBS^IBTOSUM1($P(IBD,"^",2))
  1. ..;S IBRATE=$$RATE^IBTOSUM1(IBBBS,+IBTRCD)
  1. ..S IBRATE=$$AMOUNT^IBJDB21(1,IBTRN) ; get events charge
  1. ..I +IBLOSI,+IBRATE S IBRATE=(IBRATE/IBLOSI)*IBDAY ; calculate amount for days denied
  1. ..D SET
  1. .;
  1. .I IBEVNTYP'=1,IBSELECT[IBEVNTYP D Q
  1. ..S IBDDB=$P(IBTRND,"^",6)
  1. ..Q:(IBDDB<IBBDT)!(IBDDB>IBEDT)
  1. ..S DFN=$P(IBTRCD,"^",5),IBNAM=$P($G(^DPT(+DFN,0)),"^") Q:IBNAM=""
  1. ..S IBPROV=0,IBSPEC=0,IBSERV=$S(IBEVNTYP=2:"OUTPATIENT",IBEVNTYP=3:"PROSTHETICS",IBEVNTYP=4:"PRESCRIPTION",1:"UNKNOWN")
  1. ..S IBDAY=1,IBRATE=$$AMOUNT^IBJDB21(IBEVNTYP,IBTRN) ; get events charge
  1. ..D SET
  1. K IBTRN,IBTRND,IBTRCD,DFN,IBDDB,IBDDE,IBCDT,IBLOSI
  1. Q
  1. ;
  1. SET ; -- set array to print from
  1. ; -- ^tmp($j,"ibtodd",evnt typ,primary sort,secondary sort,ibtrc)=DFN ^ attending ^ treating specialty ^ service ^ ^ billing rate^ no. days denied
  1. S IBPRIM=$S(IBSORT="P":IBNAM,IBSORT="A":IBPROV,1:IBSERV)
  1. S IBSECN=$S(IBSORT="P":IBPROV,1:IBNAM)
  1. I IBEVNTYP'=1 S IBPRIM=IBNAM,IBSECN=IBDDB
  1. S:IBPRIM="" IBPRIM="UNKNOWN" S:IBSECN="" IBSECN="UNKNOWN"
  1. S ^TMP($J,"IBTODD",IBEVNTYP,IBPRIM,IBSECN,IBTRC)=DFN_"^"_IBPROV_"^"_IBSPEC_"^"_IBSERV_"^^"_IBRATE_"^"_IBDAY
  1. Q
  1. ;
  1. PROV(DFN,IBTRCD,IBTRND,IBTALL) ; Find attending/serv/spec during the denied period
  1. ; Input: DFN -- Pointer to the patient in file #2
  1. ; IBTRCD -- Zeroth node of insurance review in file #356.2
  1. ; IBTRND -- Zeroth node of parent CT entry in file #356
  1. ; IBTALL -- 1=> deny entire admission
  1. ; Output: 1^2^3, where 1 => pointer to attending in file #200
  1. ; 2 => pointer to treating spec. in file #45.7
  1. ; 3 => service abbr. code
  1. ;
  1. N I,J,X,Y,DGPM,IBD,VA200,VAIN,VAIP,VAERR
  1. ;
  1. ; - determine date/time to calculate attending/serv/spec
  1. S DGPM=+$P(IBTRND,"^",5),IBD=+$G(^DGPM(DGPM,0))
  1. S:'IBD IBD=$P(IBTRND,"^",6)
  1. I IBTALL S Y=IBD
  1. I 'IBTALL D
  1. .I $P(IBTRCD,"^",16)>$P(IBTRCD,"^",15) S Y=$P(IBTRCD,"^",15)_.2359 Q
  1. .I $P(IBTRCD,"^",15)=(IBD\1) S Y=IBD Q
  1. .S VAIP("D")=$P(IBTRCD,"^",15) D IN5^VADPT
  1. .I +VAIP(16,1)\1=$P(IBTRCD,"^",15) S Y=+VAIP(16,1) Q
  1. .S Y=$P(IBTRCD,"^",15)
  1. S VA200="",VAINDT=Y D INP^VADPT
  1. ;
  1. S X=+VAIN(11)
  1. S Y=$G(^IBT(356.94,+$O(^IBT(356.94,"ATP",+DGPM,1,0)),0))
  1. S:$P(Y,"^",3) X=$P(Y,"^",3)
  1. PROVQ Q X_"^"_+VAIN(3)_"^"_$P($G(^DIC(42.4,+$P($G(^DIC(45.7,+$G(VAIN(3)),0)),"^",2),0)),"^",3)
  1. ;
  1. STRIP ; -- strip time from dates (if report run same day time could produce incorrect results)
  1. S $P(IBCDT,U,1)=$P(IBCDT,".",1),$P(IBCDT,U,2)=$P($P(IBCDT,U,2),".",1) Q
  1. ;
  1. LOS(IBTRN) ; compute admissions length of stay
  1. N X,Y,DGPM,BEG,END,LOS S X=$G(^IBT(356,+$G(IBTRN),0)),LOS=0,Y=0
  1. I $P(X,"^",5) S DGPM=$G(^DGPM($P(X,"^",5),0)) D
  1. . S BEG=+DGPM,END=DT
  1. . I $P(DGPM,"^",17) S END=+$G(^DGPM($P(DGPM,"^",17),0))
  1. . S LOS=$$FMDIFF^XLFDT(END,BEG)
  1. . I (BEG\1)=(END\1) S LOS=1
  1. I +LOS S Y=+LOS
  1. Q Y