source: WorldVistAEHR/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBCD2.m@ 1078

Last change on this file since 1078 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.1 KB
RevLine 
[613]1IBCD2 ;ALB/ARH - AUTOMATED BILLER (CREATE - SETUP/GATHER DATA FIELDS) ; 8/6/93
2 ;;2.0;INTEGRATED BILLING;**4,55,91,106**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5FIND ;
6 S IBX=$$CHKSYS^IBCD4 I 'IBX D TERR(0,0,$P(IBX,U,2)) G EXIT
7 S IBS="IBC0" F S IBS=$O(^TMP(IBS)) Q:IBS="" S IBX=$E(IBS,4,99) Q:$E(IBS,1,3)'="IBC"!'+IBX D
8 . N IBQUERY
9 . S IBDFN=0 F S IBDFN=$O(^TMP(IBS,$J,IBDFN)) Q:'IBDFN D
10 .. S IBSTDT="" F S IBSTDT=$O(^TMP(IBS,$J,IBDFN,IBSTDT)) Q:IBSTDT="" D I $D(IBCT)>9 D CREATE(.IBQUERY)
11 ... K IBCT S IBTRN=0 F S IBTRN=$O(^TMP(IBS,$J,IBDFN,IBSTDT,IBTRN)) Q:'IBTRN S IBCT(IBTRN)="",IBTF=^TMP(IBS,$J,IBDFN,IBSTDT,IBTRN)
12 .I $G(IBQUERY) D CLOSE^IBSDU(IBQUERY)
13EXIT K IBS,IBDFN,IBSTDT,IBCT,IBTRN,IBTF,IBX,X,DFN
14 Q
15 ;
16CREATE(IBQUERY) ;set up a bill, required: IBCT(IBTRN),IBDFN,IBSTDT
17 ; IBQUERY, if defined, will be used to activate the outpt visit QUERY
18 Q:$D(IBCT)<9 K IB
19 S IBSP=$G(^IBE(350.9,1,1)),IBDIV=$P(IBSP,U,25),IBTRN=+$O(IBCT(0))
20 S IBTRND=$G(^IBT(356,IBTRN,0)) I 'IBTRND D TERR(+IBTRN,0,"Claims Tracking Record not found or not complete.") G QUIT
21 S IBTYPE=$P(IBTRND,U,18) S IBX=$$CHK I 'IBX D TERR(+IBTRN,0,$P(IBX,U,2)) G QUIT
22 ;
23 S IBX=$$ARSET I 'IBX D TERR(IBTRN,0,$P(IBX,U,2)) G QUIT
24 S IBIFN=+IBX,IB(.01)=$P(IBX,U,2),IB(.17)=$P(IBX,U,3),IB(.2)=1,IB(.22)=IBDIV
25 S (IB(.02),DFN)=IBDFN,IB(.06)=IBTF
26 S IB(.07)=$O(^DGCR(399.3,"B","REIMBURSABLE INS.",0)) I 'IB(.07) S IB(.07)=8
27 S IBX=$O(^IBT(356.2,"ATRTP",IBTRN,1,"")) I +IBX S IB(163)=$P($G(^IBT(356.2,IBX,0)),U,28) ;pre-cert #
28 ;
29 S IBX=$P($G(^IBE(356.6,+IBTYPE,0)),U,1)
30 I IBX="INPATIENT ADMISSION" D INPT^IBCD5 G CONT
31 I IBX="PRESCRIPTION REFILL" D RXRF G CONT
32 I IBX="OUTPATIENT VISIT" D OUTPT G CONT
33 G QUIT
34 ;
35CONT S IBX=$$BDT^IBCU3(IBDFN,IB(.03)) S IB(.17)=$S(+IBX:IBX,1:IBIFN) ; continuing episode of care
36 ;Note if a primary bill is found for an outpatient bill then it allows them to choose the bill during bill creation, .17 is not editable on the screens
37 S IB(.18)=$$SC^IBCU3(IBDFN) ; SC at time of care
38 ;
39 ; Note: variable IBQUERY used in this call to ^IBCD3
40 D EN^IBCD3(.IBQUERY) ; create bill
41 ;
42 S IBTRN=0 F S IBTRN=$O(IBCT(IBTRN)) Q:'IBTRN D
43 . D TERR(IBTRN,IBIFN,"") ; bill created
44 . I ",2,3,"'[+$G(IB(.06)) D TEABD(IBTRN,0) ; remove eabd for final bills
45 . D TBILL(IBTRN,IBIFN) ; set index for bill and event (356.399)
46 . I $O(IB(43,0)),$$NABSCT^IBCU81(IBTRN) D TERR(IBTRN,IBIFN,"Stop/Clinic flagged to be ignored by auto biller but another visit is billed on same date.")
47 . I $O(IB(43,0)),$$NBOE^IBCU81(+$P($G(^IBT(356,+IBTRN,0)),U,4)) D TERR(IBTRN,IBIFN,"Visit flagged as SC in source file but has no RNB.")
48 ;
49 S IBTRN=$O(IBCT(IBTRN)) Q:'IBTRN D
50 . I $G(IB(.05))>2,$G(IB(.27))=1,+$G(^DGCR(399,IBIFN,"MP")),'$O(^DGCR(399,IBIFN,"RC",0)) D TERR(IBTRN,IBIFN,"This RC Opt bill appears to have no institutional charges but may have professional charges.")
51 ;
52 S X=$$PRCDIV^IBCU71(IBIFN) ; reset bill division from site default to first procedures division
53 ;
54QUIT K X,Y,IBX,IBY,IBSP,IBDIV,IBTRN,IBTRND,IBTYPE,IB
55 Q
56 ;
57OUTPT S IB(.04)=$S(+$P($G(^DG(40.8,+IBDIV,0)),U,3):7,1:1) ;division outpatient only or hospital
58 S IB(.05)=3,IB(.06)=1,IB(.09)=4
59 ;event dt is date of first visit, stmt from is first visit dt, stmt to is last visit dt on bill
60 S (IB(.03),IB(151))=9999999,IB(152)=""
61 S IBTRNX=0 F S IBTRNX=$O(IBCT(IBTRNX)) Q:'IBTRNX S IBX=$P($G(^IBT(356,IBTRNX,0)),U,6)\1 D
62 . S IB(43,+IBX)="" S:IB(152)<IBX IB(152)=IBX F IBI=.03,151 I IB(IBI)>IBX S IB(IBI)=IBX
63 I +$$BILLRATE^IBCRU3(+$G(IB(.07)),IB(.05),IB(.03),"RC") S IB(.27)=1 ; reasonable charges institutional bill
64 K IBI,IBX,IBTRNX
65 Q
66RXRF S IB(.04)=$S(+$P($G(^DG(40.8,+IBDIV,0)),U,3):7,1:1) ;division outpatient only or hospital
67 S IB(.05)=3,IB(.06)=1
68 ;event dt is date of first visit, stmt from is first visit dt, stmt to is last visit dt on bill
69 S (IB(.03),IB(151))=9999999,IB(152)=""
70 S IBTRNX=0 F S IBTRNX=$O(IBCT(IBTRNX)) Q:'IBTRNX S IBRX=$G(^IBT(356,IBTRNX,0)) D
71 . S IBX=$$RXRF^IBCD4(+$P(IBRX,U,8),+$P(IBRX,U,10)),IB(362.4,+$P(IBRX,U,8),+$P(IBRX,U,10))=IBX,IBX=$P(IBX,U,4)
72 . S:IB(152)<IBX IB(152)=IBX F IBI=.03,151 I IB(IBI)>IBX S IB(IBI)=IBX
73 K IBI,IBX,IBTRNX,IBRX
74 Q
75 ;
76ARSET() ; set up entry for new bill in AR returns IFN, bill number
77 ;otherwise "0^error meaasge"
78 N X S X="0^Can not set up bill in AR."
79 S PRCASV("SER")=$P($G(^IBE(350.9,1,1)),U,14),PRCASV("SITE")=+$P($$SITE^VASITE,U,3)
80 D SETUP^PRCASVC3
81 I $P(PRCASV("ARBIL"),U)=-1 S X="0^"_$P(PRCASV("ARBIL"),U,2)_" - "_$$ETXT^IBEFUNC($P(PRCASV("ARBIL"),U,2)) G ARSETQ
82 I $P(PRCASV("ARREC"),U)=-1 S X="0^"_$P(PRCASV("ARREC"),U,2)_" - "_$$ETXT^IBEFUNC($P(PRCASV("ARREC"),U,2)) G ARSETQ
83 S X=PRCASV("ARREC")_U_$P(PRCASV("ARBIL"),"-",2)
84ARSETQ K PRCASV
85 Q X
86 ;
87CHK() ;other checks
88 N X S X=1 I $G(^DPT(+$G(IBDFN),0))="" S X="0^Patient information lacking."
89 Q X
90 ;
91TEABD(TRN,IBDT) ;
92 S IBDT=+$G(IBDT),^TMP("IBEABD",$J,+TRN,+IBDT)=""
93 Q
94TERR(TRN,IFN,ER) ;
95 N X S TRN=+$G(TRN),IFN=+$G(IFN),X=+$G(^TMP("IBCE",$J,DT,TRN,IFN))+1
96 S ^TMP("IBCE",$J,DT,TRN,IFN,X)=$G(ER),^TMP("IBCE",$J,DT,TRN,IFN)=X
97 Q
98TBILL(TRN,IFN) ;
99 I '$D(^IBT(356,+$G(TRN),0))!('$D(^DGCR(399,+$G(IFN),0))) Q
100 S ^TMP("IBILL",$J,TRN,IFN)=""
101 Q
Note: See TracBrowser for help on using the repository browser.