source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBEFURF.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 5.9 KB
Line 
1IBEFURF ;ALB/ARH - UTILITY: FIND RELATED FIRST PARTY BILLS ; 3/7/00
2 ;;2.0;INTEGRATED BILLING;**130,347**;21-MAR-94;Build 24
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; the following procedures search for First Party charges for specific events, matchs are returned in TMP
6 ; only a single record of a charge event is returned, defining the charges current status, although there may
7 ; have been cancellations or updates to the original charge
8 ; o Inpatient Events may have multiple charge events (Copay and Per Diem)
9 ; o Opt and Rx Events have only a single charge event (Copay)
10 ;
11 ; ^TMP("IBRBF",$J, XRF, charge ifn) =
12 ; BILL FROM ^ BILL TO ^ CANCELLED? (1/0)^ AR BILL NUMBER ^ TOTAL CHARGE ^ ACTION TYPE (SHORT) ^ # DAYS ON HOLD
13 ;
14FPINPT(DFN,ADMDT,XRF) ; given a patient and admission date, find any Inpatient Charges
15 ; find the record of the Event (based on Event Date) then find all charges with that Event as the Parent Event
16 N IBFPIFN,IBEVDT,IBEVIFN,IB0 S ADMDT=+$G(ADMDT)\1
17 I +$G(DFN),+$G(ADMDT) S IBEVDT=-(ADMDT+.01) F S IBEVDT=$O(^IB("AFDT",DFN,IBEVDT)) Q:'IBEVDT!(-IBEVDT<ADMDT) D
18 . S IBEVIFN=0 F S IBEVIFN=$O(^IB("AFDT",DFN,IBEVDT,IBEVIFN)) Q:'IBEVIFN D
19 .. S IBFPIFN=0 F S IBFPIFN=$O(^IB("AF",IBEVIFN,IBFPIFN)) Q:'IBFPIFN D
20 ... S IB0=$G(^IB(IBFPIFN,0)) Q:IB0="" I $P($G(^IBE(350.1,+$P(IB0,U,3),0)),U,1)["OPT" Q
21 ... D FPONE(IBFPIFN,$G(XRF))
22 Q
23 ;
24FPOPV(DFN,DT1,DT2,XRF) ; given a patient and date range, find any Outpatient Charges
25 ; find all records where the Event Date is within the selected date range and the charge is Outpatient
26 N IBFPIFN,IBEVDT,IB0 I '$G(DT2) S DT2=+$G(DT1)
27 I +$G(DFN),+$G(DT1) S IBEVDT=-(DT2+.01) F S IBEVDT=$O(^IB("AFDT",DFN,IBEVDT)) Q:'IBEVDT!(-IBEVDT<DT1) D
28 . S IBFPIFN=0 F S IBFPIFN=$O(^IB("AFDT",DFN,IBEVDT,IBFPIFN)) Q:'IBFPIFN D
29 .. S IB0=$G(^IB(IBFPIFN,0)) Q:IB0="" I $P($G(^IBE(350.1,+$P(IB0,U,3),0)),U,1)'["OPT" Q
30 .. D FPONE(IBFPIFN,$G(XRF))
31 Q
32 ;
33FPRX(RXIFN,FILLDT,XRF) ; given the prescription ifn (52) and the fill date, find any First Party charges
34 ; get specific charge entry for an Rx from the Prescription file (52,106 and 52,52,9)
35 N IBFPIFN,IBFILLN,DFN S IBFPIFN=""
36 I '+$G(RXIFN) Q
37 I '+$G(FILLDT) Q
38 S DFN=$$FILE^IBRXUTL(RXIFN,2) Q:'DFN
39 I $$FILE^IBRXUTL(RXIFN,22)=$G(FILLDT) D
40 . S IBFPIFN=+$P($$IBND^IBRXUTL(DFN,RXIFN),"^",2)
41 . D FPONE(IBFPIFN,$G(XRF))
42 E D
43 . S IBFILLN=$$RFLNUM^IBRXUTL(RXIFN,FILLDT)
44 . S IBFPIFN=+$$IBNDFL^IBRXUTL(DFN,RXIFN,IBFILLN)
45 . D FPONE(IBFPIFN,$G(XRF))
46 Q
47 ;
48FPONE(FPIFN,XRF) ; for a FP charge entry get the one line item that defines the entire events charge(s)
49 ; get the Parent Charge then use the last charge entry as the current record for the event
50 N IBPARENT,IBLAST,IBDATA Q:'$G(FPIFN)
51 ;
52 S IBPARENT=+$P($G(^IB(+FPIFN,0)),U,9) Q:'IBPARENT
53 S IBLAST=+$$LAST^IBECEAU(IBPARENT) Q:'IBLAST
54 ;
55 I '$$DONE(IBLAST,$G(XRF)) S IBDATA=$$LN2(IBLAST) D SAVELN2(IBLAST,IBDATA,$G(XRF))
56 Q
57 ;
58 ; ========================================================================================
59 ;
60DONE(FPIFN,XRF) ; return true if item charge (last) is already included
61 N IBX S IBX="" S XRF=$S($G(XRF)="":"FP",1:XRF) I +$G(FPIFN),$D(^TMP("IBRBF",$J,XRF,+FPIFN)) S IBX=1
62 Q IBX
63 ;
64SAVELN1(XRF,DATA) ; set charges found into array, ^TMP("IBRBF",$J,XRF) = DATA
65 S XRF=$S($G(XRF)="":"FP",1:XRF),^TMP("IBRBF",$J,XRF)=$G(DATA)
66 Q
67 ;
68SAVELN2(FPIFN,DATA,XRF) ; set charges found into array, ^TMP("IBRBF",$J,XRF,charge ifn) = DATA (from $$LN2)
69 I +$G(FPIFN),$D(^IB(+FPIFN,0)) S XRF=$S($G(XRF)="":"FP",1:XRF),^TMP("IBRBF",$J,XRF,+FPIFN)=$G(DATA)
70 Q
71 ;
72LN2(FPIFN) ; return data for a specific First Party Bill:
73 ; BILL FROM ^ BILL TO ^ CANCELLED? (1/0)^ AR BILL NUMBER ^ TOTAL CHARGE ^ ACTION TYPE (SHORT) ^ # DAYS ON HOLD
74 ; for rx's: FROM date is the (re)fill date in 52 and TO is the date entry added (release date)
75 ; also set # Days On Hold only if the bill is currently in On Hold status
76 N IBX,IB0,IB1 S IBX="",IB0=$G(^IB(+$G(FPIFN),0)) I IB0="" G LN2Q
77 S IB1=$G(^IB(+FPIFN,1))
78 ;
79 S $P(IBX,U,1)=$S(+$P(IB0,U,4)=52:$$RXDT(+FPIFN),+$P(IB0,U,14):+$P(IB0,U,14),1:+$P(IB1,U,2))\1
80 S $P(IBX,U,2)=$S(+$P(IB0,U,15):+$P(IB0,U,15),1:+$P(IB1,U,2))\1
81 S $P(IBX,U,3)=$$CANC(+FPIFN)
82 S $P(IBX,U,4)=$P(IB0,U,11)
83 S $P(IBX,U,5)=$P(IB0,U,7)
84 S $P(IBX,U,6)=$$ATAB($P(IB0,U,3))
85 S $P(IBX,U,7)=$$OHDT(+FPIFN)
86LN2Q Q IBX
87 ;
88 ; ========================================================================================
89 ;
90 ; these procedures return First Party charge specific data and status
91 ;
92ATAB(AT) ; given an Action Type (ptr to 350.1), return a shortened/abbreviated form of Action Type (350.1,.01)
93 N IBX,IBY S IBX="",IBY=$P($G(^IBE(350.1,+$G(AT),0)),U,1) I IBY="" G ATABQ
94 I "IB DG PSO"'[$E(IBY,1,3) S IBX=IBY
95 I IBX="" S IBY=$P(IBY," ",2,999),IBY=$P(IBY," ",1,$L(IBY," ")-1) S IBX=IBY
96ATABQ Q IBX
97 ;
98CANC(FPIFN) ; given a First Party Charge (ptr to 350), return 1 if charge is Cancelled, "" otherwise
99 ; is cancelled if the Action Type (350,.03) Sequence Number (350.1,.05) is Cancel
100 ; or is cancelled if the Status (350,.05) is Cancelled (350.21,.05) (never passed to AR)
101 N IBX,IBY,IB0 S IBX="",IB0=$G(^IB(+$G(FPIFN),0)) I IB0="" G CANCQ
102 S IBY=$P($G(^IBE(350.1,+$P(IB0,U,3),0)),U,5) I +IBY=2 S IBX=1 ; action is cancel
103 I 'IBX S IBY=$P($G(^IBE(350.21,+$P(IB0,U,5),0)),U,5) I +IBY S IBX=1 ; status is cancel
104CANCQ Q IBX
105 ;
106RXDT(FPIFN) ; return fill date of rx being billed, Resulting From must be 52
107 ; fill date for Original = (52,22), for Refill = (52,52,.01)
108 N IBX,IBY,IB0,IBRX,IBRXN S IBX="",IB0=$G(^IB(+$G(FPIFN),0)) I IB0="" G RXDTQ
109 S IBY=$P(IB0,U,4) I +IBY=52 S IBRX=+$P(IBY,":",2),IBRXN=+$P(IBY,":",3) D I +IBY S IBX=IBY\1
110 . S IBY=$S('IBRXN:$$FILE^IBRXUTL(IBRX,22),1:+$$SUBFILE^IBRXUTL(IBRX,IBRXN,52,.01))
111RXDTQ Q IBX
112 ;
113OHDT(FPIFN) ; return the bills # DAYS ON HOLD, if the bill is currently in the On Hold Status
114 N IBX,IBY,IB0 S IBX="",IB0=$G(^IB(+$G(FPIFN),0)) I IB0="" G OHDQ
115 S IBY=$P($G(^IBE(350.21,+$P(IB0,U,5),0)),U,6)
116 I +IBY S IBY=$P($G(^IB(+FPIFN,1)),U,6) I +IBY S IBX=$$FMDIFF^XLFDT(DT,IBY)
117OHDQ Q IBX
Note: See TracBrowser for help on using the repository browser.