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

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

initial load of FOIAVistA 6/30/08 version

File size: 5.8 KB
Line 
1IBCU7A1 ;ALB/ARH - BILL PROCEDURE MANIPULATIONS (BUNDLED) ; 10-OCT-03
2 ;;2.0;INTEGRATED BILLING;**245,270**;21-MAR-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ;
6BNDL(IBIFN) ; manipulate a bill's CPT codes, replace bundled codes
7 ; on facility and profesional bills global codes should be billed using their components
8 ; on freestanding bills component codes should be billed as global
9 ; - on facility bill, if a global code is found in the clinical data and on the bill then
10 ; replace it on the bill with the institutional components
11 ; - on professional bill, if the global code is found in the clinical data and the institutional components
12 ; are found on the bill then replace the institutional components with the professional components
13 ; - on a freestanding bill if all institutional and professional components are found then
14 ; replace them with the global code
15 ; maximum of 10 is insurance against infinite loops
16 N IB0,IBCT,IBDVTY,IBTYPE,IBI,IBJ,IBLN,IBGLB,IBNLN,IBNEW,IBDEL,IBRPL,IBX,IBMSG,IBCHANGE S IBCHANGE=0
17 S IB0=$G(^DGCR(399,+$G(IBIFN),0)) Q:IB0=""
18 S IBCT=$P(IB0,U,27) Q:'IBCT S IBDVTY=$P($$RCDV^IBCRU8($P(IB0,U,22)),U,3)
19 S IBTYPE=$S(IBDVTY=3:3,1:+IBCT)
20 ;
21 I +$O(^DGCR(399,+$G(IBIFN),"CP","B","94017;ICPT("),-1)<93000 Q ; none of the bundled codes on bill
22 ;
23 I IBDVTY'=3 D GETSD^IBCU7U(IBIFN) ; for provider based sites global charge should be in clincal data
24 ;
25 ; loop through list of bundled procedures and find any on bill
26 F IBI=1:1 S IBLN=$P($T(IPBI+IBI),";;",2) Q:IBLN="" D
27 . S IBGLB=$P(IBLN,":",1),IBCHANGE=0
28 . ;
29 . S IBNLN=$$IPB(IBLN,IBTYPE) Q:'IBNLN S IBNEW=$P(IBNLN,":",2),IBDEL=$P(IBNLN,":",1)
30 . ;
31 . I IBDVTY'=3,'$D(^UTILITY($J,"CPT-CLN",+IBGLB)) Q
32 . ;
33 . ; search the bill for the list of procedures to be replaced
34 . F IBJ=1:1 S IBRPL=$$FND(IBIFN,IBDEL) Q:'IBRPL D Q:IBJ>10
35 .. ;
36 .. I IBDVTY'=3,'$D(^UTILITY($J,"CPT-CLN",+IBGLB,+IBRPL)) Q
37 .. S IBRPL=$P(IBRPL,U,2,999) I $L(IBRPL,U)'=$L(IBDEL,U) Q
38 .. ;
39 .. I +$$RPL(IBIFN,IBNEW,IBRPL) S IBCHANGE=1 ; replace procedures
40 . ;
41 . I +IBCHANGE S IBMSG(IBI)=$TR(IBDEL,"^",",")_" replaced by "_$TR(IBNEW,"^",",")
42 ;
43 I '$D(ZTQUEUED),'$G(IBAUTO),+$O(IBMSG(0)) S IBI=0 F S IBI=$O(IBMSG(IBI)) Q:'IBI W !,IBMSG(IBI)
44 Q
45 ;
46RPL(IBIFN,NEWCPTS,OLDLIST) ; replace procedures on the bill
47 ; Input: NEWCPTS - list of CPT codes to add to the bill
48 ; OLDLIST - list of procedure ifn's on the bill to be replaced
49 ; Output: returns true if changes made
50 ; the list of new and replaced may not be the same length
51 ; - if more CPT's to be added than exist then the first existing procedure is copied for the new CPT
52 ; - if fewer CPT's to be added than exist then the extra entries on the bill are deleted
53 N IBJ,IBFFN,IBRFN,IBNCPT,IBFND S IBFND=0
54 ;
55 S NEWCPTS=$G(NEWCPTS),OLDLIST=$G(OLDLIST),IBFFN=+OLDLIST
56 ;
57 F IBJ=1:1 S IBRFN=$P(OLDLIST,U,IBJ),IBNCPT=$P(NEWCPTS,U,IBJ) Q:('IBRFN)&('IBNCPT) D Q:'IBFND
58 . I +IBRFN,'IBNCPT S IBFND=$$DELCPT^IBCU7U(IBIFN,IBRFN) Q
59 . I 'IBRFN,+IBNCPT S IBFND=$$COPYCPT^IBCU7U(IBIFN,IBFFN,IBNCPT) Q
60 . I +IBRFN,+IBNCPT S IBFND=$$EDITCPT^IBCU7U(IBIFN,IBRFN,IBNCPT)
61 ;
62 Q IBFND
63 ;
64FND(IBIFN,LIST) ; find first set of the procedures on the bill to be replaced
65 ; if all found then returns procedure date followed by 'CP' ifn list
66 ; Input: list of CPT's to be replaced separated by '^', internal format
67 ; Output: procedure date ^ ifn of procedures in bill CP multiple
68 N IBJ,IBC1,IBC1N,IBC1D,IBC2,IBC2N,IBC2D,IBFND,IBNLIST S (IBFND,IBNLIST)=0 I '$G(LIST) G FNDQ
69 ;
70 ; start with the first procedure to be replaced if it is on the bill then search for the rest on same date
71 S IBC1=$P(LIST,U,1)
72 S IBC1N=0 F S IBC1N=$O(^DGCR(399,+$G(IBIFN),"CP","B",IBC1_";ICPT(",IBC1N)) Q:'IBC1N D Q:IBFND
73 . S IBC1D=$P($G(^DGCR(399,IBIFN,"CP",IBC1N,0)),U,2)
74 . S IBFND=1,IBNLIST=IBC1D_U_IBC1N
75 . ;
76 . ; find other procedures to be replaced for same date
77 . F IBJ=2:1 S IBC2=$P(LIST,U,IBJ) Q:'IBC2 S IBFND=0 D Q:'IBFND
78 .. S IBC2N=0 F S IBC2N=$O(^DGCR(399,IBIFN,"CP","B",IBC2_";ICPT(",IBC2N)) Q:'IBC2N D Q:IBFND
79 ... S IBC2D=$P($G(^DGCR(399,IBIFN,"CP",IBC2N,0)),U,2) I IBC1D'=IBC2D S IBFND=0 Q
80 ... S IBFND=1,IBNLIST=IBNLIST_U_IBC2N
81 . ;
82 . I 'IBFND S IBNLIST=0
83 ;
84FNDQ Q IBNLIST
85 ;
86CHKIPB(CPT,TYPE) ; return procedures that may replace procedure passed in
87 ; Input: TYPE - 1 for institutional, 2 for professional, 3 for Non-Provider Based
88 ; Output: Procedures to be replaced ':' Procedures they are replaced with
89 N IBX,IBI,IBLN,IBRPL S IBX="",CPT=$G(CPT),TYPE=+$G(TYPE)
90 I +TYPE,CPT>92999,CPT<94017 F IBI=1:1 S IBLN=$P($T(IPBI+IBI),";;",2) Q:IBLN="" D Q:+IBX
91 . S IBRPL=$$IPB(IBLN,TYPE) I $P(IBRPL,":",1)[CPT S IBX=IBRPL
92 Q IBX
93 ;
94 ;
95IPB(LINE,TYPE) ; return procedures to be replaced and those they are replaced by for the type of bill
96 ; Input: LINE - line of bundled procedures from IPBI
97 ; TYPE - 1 for institutional, 2 for professional, 3 for Non-Provider Based
98 ; Output: Procedures to be replaced ':' Procedures they are replaced with
99 ; - institutional type the global is replaced by the technical componentes
100 ; - professional type: the institutional components are replaced by the professional components
101 ; - non-provider based: the institutional and professional components are preplaced by the global
102 ;
103 N IBNEW,IBDEL,IBX S (IBX,IBDEL,IBNEW)="",TYPE=$G(TYPE),LINE=$G(LINE)
104 I TYPE=1 S IBNEW=$P(LINE,":",2),IBDEL=$P(LINE,":",1)
105 I TYPE=2 S IBNEW=$P(LINE,":",3),IBDEL=$P(LINE,":",2)
106 I TYPE=3 S IBNEW=$P(LINE,":",1),IBDEL=$P(LINE,":",2)_U_$P(LINE,":",3)
107 S IBX=IBDEL_":"_IBNEW
108 Q IBX
109 ;
110IPBI ; Facility Provider Based Replace Global by Technical Component: global:technical:professional
111 ;;93000:93005:93010
112 ;;93015:93017:93016^93018
113 ;;93040:93041:93042
114 ;;93224:93225^93226:93227
115 ;;93230:93231^93232:93233
116 ;;93235:93236:93237
117 ;;93268:93270^93271:93272
118 ;;93720:93721:93722
119 ;;93784:93786^93788:93790
120 ;;94014:94015:94016
121 ;;
Note: See TracBrowser for help on using the repository browser.