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

IBCD4.m

Go to the documentation of this file.
  1. IBCD4 ;ALB/ARH - AUTOMATED BILLER (ADD NEW BILL - GATHER DX AND PROCEDURES) ; 9/5/93
  1. ;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. ;
  1. IDX(PTF,DT1,DT2) ;find all 501 movement Diagnosis' for PTF record, check for billable bedsection and SC treatement
  1. ;results: IBT = number of billable movements within date range
  1. ; ^TMP("IBDX",$J)= PTF IFN, ^TMP("IBDX",$J,DX)="",IBMSG(X)=" error message "
  1. ;where DX = file 45, fields 45.02: 5-9
  1. N IBMDT,IBDA,IBI,IBX,IBY,IBZ K IBMSG,IBT,^TMP("IBDX",$J) I '$D(^DGPT(+$G(PTF),"M")) G IDXE
  1. ;get next movement after begin date: each movement entry contains data for the previous date range
  1. S (DT1,IBX)=+$G(DT1)\1 I +$P($G(^DGPT(+PTF,0)),U,2)\1'=DT1 D ;use all moves on admit date
  1. . S IBX=$O(^DGPT(+PTF,"M","AM",IBX-.00001)) S:(IBX\1)=DT1 IBX=IBX+.0001 S DT1=$S(+IBX:+IBX,1:+DT1) ;skip first move on begin date
  1. ;get next movement after end date, use all moves on end date
  1. S DT2=$S(+$G(DT2):DT2\1-.00001,1:DT),IBX=$O(^DGPT(+PTF,"M","AM",DT2)),DT2=$S('IBX:DT+.99,(IBX\1)=DT2:DT2+.6,1:IBX)
  1. S ^TMP("IBDX",$J)=+PTF
  1. S (IBT,IBBS,IBSC,IBDA)=0,IBCNT=1 F S IBDA=$O(^DGPT(+PTF,"M",IBDA)) Q:'IBDA D
  1. . S IBX=$G(^DGPT(+PTF,"M",IBDA,0)) Q:IBX="" S IBMDT=+$P(IBX,U,10) S:'IBMDT IBMDT=DT I IBMDT<DT1!(IBMDT>DT2) Q
  1. . S IBT=IBT+1 I $P(IBX,U,18)=1 S IBSC=IBSC+1,IBMSG(IBCNT)=$$FMTE^XLFDT(IBMDT)_" movement related to an SC condition.",IBCNT=IBCNT+1 Q
  1. . I $P($G(^DIC(42.4,+$P(IBX,U,2),0)),U,5)="" S IBBS=IBBS+1,IBMSG(IBCNT)=$$FMTE^XLFDT(IBMDT)_" movement is for a non-billable bedsection.",IBCNT=IBCNT+1 Q
  1. . S IBZ="" F IBI=5:1:9 S IBY=$P(IBX,U,IBI) I +IBY S ^TMP("IBDX",$J,IBY)=""
  1. I +IBSC S IBMSG(IBCNT)="PTF record indicates "_+IBSC_" of "_IBT_" movements are for Service Connected Care.",IBCNT=IBCNT+1
  1. I +IBBS S IBMSG(IBCNT)="PTF record indicates "_+IBBS_" of "_IBT_" movements are for a non-billable bedsection.",IBCNT=IBCNT+1
  1. S IBT=IBT-IBSC-IBBS I 'IBT S IBMSG(IBCNT)="0 movements are billable."
  1. IDXE Q
  1. ;
  1. IPRC(PTF,DT1,DT2) ;find 401 and 601 procedures for a PTF record
  1. ;results: ^TMP("IBIPRC",$J,PROC DATE)=PROC1^ ... ^PROC5
  1. ;where PROC DATE = (45.01,45.01,.01) and (45,45.05,.01) and PROC = (45,45.01,8-12) and (45,45.05,4-8)
  1. N IBX,IBY,IBZ,IBI K ^TMP("IBIPRC",$J) I '$D(^DGPT(+$G(PTF),0)) G IPRCE
  1. S DT1=$S(+$G(DT1):+DT1,1:0),DT2=$S(+$G(DT2):+DT2,1:9999999),^TMP("IBIPRC",$J)=+PTF
  1. S IBX=0 F S IBX=$O(^DGPT(+PTF,"S",IBX)) Q:'IBX S IBY=$G(^DGPT(+PTF,"S",IBX,0)) I +IBY'<DT1,+IBY'>DT2 D
  1. . S IBZ="" F IBI=8:1:12 I +$P(IBY,U,IBI) S IBZ=IBZ_+$P(IBY,U,IBI)_U
  1. . I +IBZ S ^TMP("IBIPRC",$J,+IBY)=$G(^TMP("IBIPRC",$J,+IBY))_IBZ
  1. S IBX=0 F S IBX=$O(^DGPT(+PTF,"P",IBX)) Q:'IBX S IBY=$G(^DGPT(+PTF,"P",IBX,0)) I +IBY'<DT1,+IBY'>DT2 D
  1. . S IBZ="" F IBI=5:1:9 I +$P(IBY,U,IBI) S IBZ=IBZ_+$P(IBY,U,IBI)_U
  1. . I +IBZ S ^TMP("IBIPRC",$J,+IBY)=$G(^TMP("IBIPRC",$J,+IBY))_IBZ
  1. IPRCE Q
  1. ;
  1. RXRF(PIFN,RIFN,IBDT) ; returns data on refill on date for rx (RX # ^ DRUG ^ DAYS SUPPLY ^ REFILL DATE ^ QTY ^ NDC #)
  1. N X,Y,PLN S X="",PLN=$G(^PSRX(+$G(PIFN),0)) I PLN'="" D
  1. . S RIFN=$G(RIFN) S:'RIFN RIFN=$O(^PSRX(+$G(PIFN),1,"B",+$G(IBDT),0)) S RLN=$G(^PSRX(+$G(PIFN),1,+RIFN,0)) Q:RLN=""
  1. . S X=$P(PLN,U,1)_"^"_$P(PLN,U,6)_"^"_$P(PLN,U,8)_"^"_$P(RLN,U,1)_"^"_$P(RLN,U,4)_"^"_$P($G(^PSDRUG(+$P(PLN,U,6),2)),U,4)
  1. Q X
  1. ;
  1. CHK() ;other checks
  1. N X S X=1 I $G(^DPT(+$G(IBDFN),0))="" S X="0^Patient information lacking."
  1. Q X
  1. ;
  1. CHKSYS() ;various checks to determine if bill can be created, returns true if passes XXXXXX
  1. ;if fails then returns "0^error message"
  1. ;requires nothing
  1. N X,Y,I S X=1
  1. I '$P($G(^IBE(350.9,1,1)),U,14) S X="0^MAS SERVICE PARAMETER UNKNOWN" G CHKSYSE
  1. I +$P($$SITE^VASITE,U,3)<1 S X="0^ACILITY UNDEFINED" G CHKSYSE
  1. ;G:$D(IBB) CHKSYSE
  1. ;I '$D(DUZ(0)) S X="0^FILEMAN ACCESS UNDEFINED" G CHKSYSE
  1. ;I $S($D(DLAYGO):2\1-(DLAYGO\1),1:1),DUZ(0)'="@",$D(^DIC(399,0,"LAYGO")) S DLAYGO=399
  1. CHKSYSE Q X
  1. ;
  1. GVARS(IFN) ;get data on bill IFN
  1. N I S X=1 I '$G(^DGCR(399,+$G(IFN),0)) S X=0 G GVARSE
  1. F I=0,"M" S IB(I)=$G(^DGCR(399,+IFN,I))
  1. S DGINPAR=$P($G(^DIC(36,+IB("M"),0)),U,6,10)
  1. GVARSE Q X