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

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

revised back to 6/30/08 version

File size: 7.8 KB
RevLine 
[623]1IBCEF22 ;ALB/TMP - FORMATTER SPECIFIC BILL FUNCTIONS ;06-FEB-96
2 ;;2.0;INTEGRATED BILLING;**51,137,135,155,309,349**;21-MAR-94;Build 46
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; OVERFLOW FROM ROUTINE IBCEF2
6HOS(IBIFN) ; Extract rev codes for episode billed on a UB-04 into IBXDATA
7 ; IBIFN = bill ien
8 ; Format: IBXDATA(n) =
9 ; rev cd ptr ^ CPT CODE ptr ^ unit chg ^ units ^ tot charge
10 ; ^ tot uncov^ FL49 value ^ ien of rev code multiple entry(s)
11 ; (separated by ";")
12 ; ^ modifiers specific to rev code/proc (separated by ",")
13 ; ^ rev code date, if it can be determined by a corresponding proc
14 ;
15 ; Also Returns IBXDATA(IBI,"COB",COB,m) with COB data for each line
16 ; item found in an accepted EOB for the bill and = the reference
17 ; line in the first '^' piece followed by the '0' node of file
18 ; 361.115 (LINE LEVEL ADJUSTMENTS)
19 ; COB = COB seq # of adjustment's ins co, m = seq #
20 ; -- AND --
21 ; IBXDATA(IBI,"COB",COB,m,z,p)=
22 ; the '0' node for each subordinate entry of file
23 ; 361.11511 (REASONS) (Only first 3 pieces for 837)
24 ; z = group code, sometimes preceeded by a space p = seq #
25 ;
26 N IBDA,IBCOMB,IBINPAT,IBLN,IBX,IBY,IBZ,IBS,IBSS,IBXTRA,IBX1,IBXS,IBP,IBPO,IBP1,IBDEF,Z,Z0,Z1,ZX,QQ,IBMOD
27 S IBINPAT=$$INPAT^IBCEF(IBIFN,1)
28 I 'IBINPAT D F^IBCEF("N-STATEMENT COVERS FROM DATE","IBZ",,IBIFN)
29 S IBDEF=$G(IBZ)
30 ; loop through all proc codes - sort by procedure, modifiers and print order
31 S IBDA=0 F S IBDA=$O(^DGCR(399,IBIFN,"CP",IBDA)) Q:'IBDA S IBZ=$G(^(IBDA,0)) I IBZ D
32 . S IBP(+$P(IBZ,U)_U_$$GETMOD^IBEFUNC(IBIFN,IBDA,1),$S($P(IBZ,U,4):$P(IBZ,U,4),1:999),IBDA)=$P(IBZ,U,2)
33 ; loop through all rev codes - sort by rev code
34 S IBDA=0 F S IBDA=$O(^DGCR(399,IBIFN,"RC",IBDA)) Q:'IBDA S IBZ=$G(^(IBDA,0)) I IBZ S IBMOD="" D
35 . S IBX=$G(^DGCR(399.2,+IBZ,0)),IBX1="",IBPO=0
36 . ; Auto-added procedure charge
37 . I $P(IBZ,U,10)=4,$P(IBZ,U,11) D ; Soft link to proc
38 .. S Z=$G(^DGCR(399,IBIFN,"CP",$P(IBZ,U,11),0))
39 .. Q:Z=""
40 .. S ZX=+Z_U_$$GETMOD^IBEFUNC(IBIFN,$P(IBZ,U,11),1)
41 .. Q:'$O(IBP(ZX,0))&'$O(IBP1(ZX,0))
42 .. I $P(IBZ,U,6) Q:$S($P(Z,U)'["ICPT":1,1:+$P(Z,U)'=$P(IBZ,U,6))
43 .. S Z0=$S($D(IBP(ZX)):$O(IBP(ZX,0)),1:$O(IBP1(ZX,0)))
44 .. S:'Z0 Z0=999
45 .. Q:'$D(IBP(ZX,+Z0,$P(IBZ,U,11)))&'$D(IBP1(ZX,+Z0,$P(IBZ,U,11)))
46 .. I '$D(IBP1(ZX,+Z0,$P(IBZ,U,11))) S IBP1(ZX,+Z0,$P(IBZ,U,11))=IBP(ZX,+Z0,$P(IBZ,U,11)) K IBP(ZX,+Z0,$P(IBZ,U,11))
47 .. S IBX1=$P(Z,U,2),IBPO=+Z0,IBMOD=$P(ZX,U,2)
48 . ; Manually added charge with a procedure
49 . I $P(IBZ,U,6),$S($P(IBZ,U,10)=4:'$P(IBZ,U,11),1:1),+$O(IBP($P(IBZ,U,6)))=$P(IBZ,U,6) D
50 .. ; No direct link, but a proc exists on rev code and in procedure mult without and then with modifiers
51 .. S ZX=$O(IBP($P(IBZ,U,6)))
52 .. F QQ=1,2 Q:IBPO S Z="" F S Z=$O(IBP(ZX,Z),-1) Q:'Z!(IBPO) S Z0=0 F S Z0=$O(IBP(ZX,Z,Z0)) Q:'Z0 S Z1=$G(^DGCR(399,IBIFN,"CP",Z0,0)) D Q:IBPO
53 ... ; Ignore if not a CPT or a modifier exists and this is first pass
54 ... S IBMOD=$$GETMOD^IBEFUNC(IBIFN,Z0,1)
55 ... Q:$S($P(Z1,U)'["ICPT":1,QQ=1:IBMOD'="",1:0)
56 ... S IBPO=+$P(Z1,U,4),IBX1=$P(Z1,U,2)
57 ... K IBP(+Z1_U_IBMOD,Z,Z0)
58 . ;
59 . I IBX'="" D ; revenue code is valid
60 .. F Z=900:1 S Z0=$S(IBPO:IBPO,$D(IBX(" "_$P(IBX,U),Z)):0,1:Z) I Z0 S IBPO=Z0 Q
61 .. S IBX(" "_$P(IBX,U),IBPO,IBDA)=IBX,IBX(" "_$P(IBX,U),IBPO,IBDA,"DT")=$S(IBX1:IBX1,1:IBDEF),IBX(" "_$P(IBX,U),IBPO,IBDA,"MOD")=IBMOD
62 ;
63 S IBS="" F S IBS=$O(IBX(IBS)) Q:IBS="" S IBPO=0 F S IBPO=$O(IBX(IBS,IBPO)) Q:'IBPO D
64 . S IBDA=0 F S IBDA=$O(IBX(IBS,IBPO,IBDA)) Q:'IBDA S IBX=$G(IBX(IBS,IBPO,IBDA)),IBZ=$G(^DGCR(399,IBIFN,"RC",IBDA,0)) I IBX'="" D
65 .. ;S IBXS=$P(IBZ,U,2)_U_$P(IBZ,U,6)_U_$G(IBX(IBS,IBPO,IBDA,"MOD"))
66 .. S IBXS=U_$P(IBZ,U,6)_U_$G(IBX(IBS,IBPO,IBDA,"MOD")) ;combine same proc and modifiers regardless of rate
67 .. S:IBPO'<900&'$$ACCRV($P(IBS," ",2))&$S(IBINPAT:$P(IBZ,U,6),1:1) IBCOMB(IBS,IBXS,IBPO)=IBDA
68 .. S:'$D(IBX1(IBS,IBPO,IBXS,1)) IBX1(IBS,IBPO,IBXS,1)=IBX,IBX1(IBS,IBPO,IBXS,2)=IBZ
69 .. S $P(IBX1(IBS,IBPO,IBXS),U)=$P($G(IBX1(IBS,IBPO,IBXS)),U)+$P(IBZ,U,3)
70 .. S $P(IBX1(IBS,IBPO,IBXS),U,2)=$P($G(IBX1(IBS,IBPO,IBXS)),U,2)+$P(IBZ,U,4)
71 .. S IBX1(IBS,IBPO,IBXS,"DT")=$G(IBX(IBS,IBPO,IBDA,"DT")),IBX1(IBS,IBPO,IBXS,"IEN")=$G(IBX1(IBS,IBPO,IBXS,"IEN"))_$S($G(IBX1(IBS,IBPO,IBXS,"IEN")):";",1:"")_IBDA
72 ;
73 S IBS="" F S IBS=$O(IBX1(IBS)) Q:IBS="" S IBPO=899 F S IBPO=$O(IBX1(IBS,IBPO)) Q:'IBPO D ; Check to combine like rev codes without print order
74 . N Q,Q0,Q1,Z,Z0,Z1,Z2,IBZ1,IBZ2
75 . S Z=""
76 . N IBACC
77 . F S Z=$O(IBX1(IBS,IBPO,Z)) Q:Z="" S Q=IBPO F S Q=$O(IBCOMB(IBS,Z,Q)) Q:'Q I Q'=IBPO S IBZ1=$G(IBX1(IBS,IBPO,Z,1)),IBZ2=$G(IBX1(IBS,IBPO,Z,2)) D
78 .. Q:$G(IBX1(IBS,IBPO,Z,1))'=$G(IBX1(IBS,Q,Z,1))
79 .. S Q1=1,IBACC=$$ACCRV(+$P(IBS," ",2))
80 .. F Q0=1,5:1:7,10:1:13,15 D Q:'Q1
81 ... I IBACC Q:Q0=5!(Q0>6)
82 ... I (Q0=11!(Q0=15))&($P($G(IBX1(IBS,Q,Z,2)),U,10)=3) Q
83 ... I Q0=5,'IBINPAT Q
84 ... I $P($G(IBX1(IBS,IBPO,Z,2)),U,Q0)'=$P($G(IBX1(IBS,Q,Z,2)),U,Q0) S Q1=0
85 .. Q:'Q1
86 .. S $P(IBX1(IBS,IBP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TRA) I $D(IBXTRA) D COMBO^IBCEU2(.IBXDATA,.IBXTRA,1) ;Handle bundled/unbundled
100 I $D(^IBA(362.4,"AIFN"_IBIFN))!$D(^IBA(362.5,"AIFN"_IBIFN)) D
101 . N IBARRAY,IBX,IBZ,IBRX,IBLCNT
102 . S IBLCNT=0
103 . ; Print prescriptions, prosthetics on front of UB-04
104 . D SET^IBCSC5A(IBIFN,.IBARRAY)
105 . I $P(IBARRAY,U,2) D
106 .. S IBX=+$P(IBARRAY,U,2)+2
107 .. S IBLCNT=IBLCNT+1,IBXSAVE("RX-UB-04",IBLCNT)=""
108 .. S IBLCNT=IBLCNT+1,IBXSAVE("RX-UB-04",IBLCNT)="PRESCRIPTION REFILLS:",IBLCNT=2
109 .. S IBX=0 F S IBX=$O(IBARRAY(IBX)) Q:IBX="" S IBY=0 F S IBY=$O(IBARRAY(IBX,IBY)) Q:'IBY S IBRX=IBARRAY(IBX,IBY) D
110 ... D ZERO^IBRXUTL(+$P(IBRX,U,2))
111 ... S IBLCNT=IBLCNT+1,IBXSAVE("RX-UB-04",IBLCNT)=IBX_$J(" ",(11-$L(IBX)))_" "_$J($S($P(IBRX,U,6):"$"_$FN($P(IBRX,U,6),",",2),1:""),10)_" "_$J($$FMTE^XLFDT(IBY,2),8)_" "_$G(^TMP($J,"IBDRUG",+$P(IBRX,U,2),.01))
112 ... S IBZ=$S(+$P(IBRX,U,4):"QTY: "_$P(IBRX,U,4)_" ",1:"")_$S(+$P(IBRX,U,3):"for "_$P(IBRX,U,3)_" days supply ",1:"") I IBZ'="" S IBLCNT=IBLCNT+1,IBXSAVE("RX-UB-04",IBLCNT)=$J(" ",35)_IBZ
113 ... S IBZ=$S($P(IBRX,U,5)'="":"NDC #: "_$P(IBRX,U,5),1:"") I IBZ'="" S IBLCNT=IBLCNT+1,IBXSAVE("RX-UB-04",IBLCNT)=$J(" ",35)_IBZ
114 ... K ^TMP($J,"IBDRUG")
115 ... Q
116 . ;
117 . D SET^IBCSC5B(IBIFN,.IBARRAY)
118 . I $P(IBARRAY,U,2) D
119 .. S IBLCNT=0
120 .. S IBX=+$P(IBARRAY,U,2)+2
121 .. S IBLCNT=IBLCNT+1,IBXSAVE("PROS-UB-04",IBLCNT)=""
122 .. S IBLCNT=IBLCNT+1,IBXSAVE("PROS-UB-04",IBLCNT)="PROSTHETIC REFILLS:",IBLCNT=2
123 .. S IBX=0 F S IBX=$O(IBARRAY(IBX)) Q:IBX="" S IBY=0 F S IBY=$O(IBARRAY(IBX,IBY)) Q:'IBY D
124 ... S IBLCNT=IBLCNT+1,IBXSAVE("PROS-UB-04",IBLCNT)=$$FMTE^XLFDT(IBX,2)_" "_$J($S($P(IBARRAY(IBX,IBY),U,2):"$"_$FN($P(IBARRAY(IBX,IBY),U,2),",",2),1:""),10)_" "_$E($P($$PIN^IBCSC5B(IBY),U,2),1,54)
125 Q
126 ;
127ACCRV(X) ; Returns 1 if X is an accomodation RC, 0 if not
128 Q ((X'<100&(X'>219))!(X=224))
129 ;
Note: See TracBrowser for help on using the repository browser.