source: WorldVistAEHR/trunk/r/FEE_BASIS-FB/FBPCR3.m@ 1154

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

initial load of WorldVistAEHR

File size: 5.2 KB
Line 
1FBPCR3 ;AISC/GRR,TET-PHARMACY POTENTIAL COST RECOVERY, SORT/PRINT ;30 Jun 2006 1:49 PM
2 ;;3.5;FEE BASIS;**48,69,98**;JAN 30, 1995;Build 54
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4EN ;entry point
5 S (FBCATC,FBINS,FBPSF)=0
6SORT ;sort by date certified for payment, patient, invoice number ien, rx ien
7 S I=FBBDATE-.1 F S I=$O(^FBAA(162.1,"AA",I)) Q:'I!(I>FBEDATE) S J=0 F S J=$O(^FBAA(162.1,"AA",I,J)) Q:'J D
8 .S DFN=J D VET^FBPCR
9 .S K=0 F S K=$O(^FBAA(162.1,"AA",I,J,K)) Q:K'>0 S L=0 F S L=$O(^FBAA(162.1,"AA",I,J,K,L)) Q:L'>0 D S (FBCATC,FBINS,FBPSF)=0
10 ..D SET Q:'FBPSV&('$D(FBPSV(FBPSF))) I FBCATC!FBINS D SETTMP
11KILL ;kill variables set in sort
12 K A1,A2,DFN,FBAAA,FBAC,FBAP,FBBATCH,FBCATC,FBDA1,FBDRUG,FBFD,FBFD1,FBIN,FBINS,FBINVN,FBLOC,FBPAT,FBPD,FBPSF,FBPV,FBQTY,FBREIM,FBRX,FBSC,FBSTR,FBSUSP,FBVEN,FBVI,I,J,K,L,N,V,Y
13 K FBVNAME,FBVID,FBVCHAIN,FBPNAME,FBPID,FBDOB
14 K FBADJLA,FBADJLR,TAMT,FBRRMKL
15 D KILL^FBPCR2
16 Q
17SET ;set variables
18 N FBX
19 S Y(0)=$G(^FBAA(162.1,+K,"RX",+L,0)) I Y(0)']""!($P(Y(0),U,9)=1) Q
20 I $G(^FBAA(162.1,+K,"RX",+L,"FBREJ"))]"" Q
21 S Y(2)=$G(^FBAA(162.1,+K,0))
22 S Y(1)=$G(^FBAA(162.1,+K,"RX",+L,2))
23 S FBX=$$ADJLRA^FBRXFA(+L_","_+K_",")
24 S FBADJLR=$P(FBX,U) ;adjustment code
25 S FBADJLA=$P(FBX,U,2) ;adjustment amount
26 S TAMT=$FN($P(Y(0),"^",7),"",2) ;suspend amount
27 S FBRRMKL=$$RRL^FBRXFR(+L_","_+K_",") ;remitt remarks
28 S FBPSF=+$P(Y(1),U,5),FBFD=$P(Y(0),U,3),FBAAA=$P(Y(0),U,5)
29 Q:'FBPSV&('$D(FBPSV(FBPSF))) S FBCATC=$$CATC^FBPCR(DFN,FBFD)
30 ;,FBINS=$S($O(^FBAAA("AIC",FBAAA,+$O(^FBAAA("AIC",FBAAA,-FBFD)),0))="Y":1,1:0)
31 S FBINS=$S($$INSCK(FBFD,FBAAA,FBPI)=1:$$INSURED^FBPCR4(DFN,FBFD),1:0)
32 Q:'FBCATC&'FBINS
33 S FBINVN=$P(Y(2),U) D VEN
34 S FBRX=$P(Y(0),U,1),FBDRUG=$P(Y(0),U,2),FBAC=$P(Y(0),U,4),FBAP=$P(Y(0),U,16),FBSUSP=$P(Y(0),U,8),FBPD=$P(Y(0),U,19),FBBATCH=$P(Y(0),U,17),FBBATCH=$P($G(^FBAA(161.7,+FBBATCH,0)),U)
35 I FBSUSP]"" S FBSUSP=$P($G(^FBAA(161.27,+FBSUSP,0)),U)
36 S FBREIM=$S($P(Y(0),U,20)="R":"*",1:""),FBSTR=$P(Y(0),U,12),FBQTY=$P(Y(0),U,13),A1=$J(FBAC,6,2),A2=$J(FBAP,6,2),FBPV=""
37 S FBPD=$$DATX^FBAAUTL(FBPD),FBFD=$$DATX^FBAAUTL(FBFD)
38 S FBPV=$S($P(Y(1),U,3)="V":"#",1:""),FBFD1=$S(FBPV="":" ",1:FBPV)_$S(FBREIM="":" ",1:FBREIM)_FBFD,FBRX="Rx: "_FBRX
39 S FBVEN=FBVNAME_";"_FBVID,FBPAT=FBPNAME_";"_DFN
40 Q
41SETTMP ;sort data by primary service facility, patient, fee program, vendor, date
42 Q:$$FILTER^FBPCR4()=0
43 S ^TMP($J,"FB",FBPSF,FBPAT,FBPI,FBVEN,I,K_L)=FBFD1_U_FBRX_U_FBDRUG_U_FBSTR_U_FBQTY_U_A1_U_A2_U_FBSUSP_U_FBINVN_U_FBBATCH_U_FBPD_U_FBDOB_U_FBVCHAIN_U_FBPI_U_FBCATC_U_FBINS
44 S ^TMP($J,"FB",FBPSF,FBPAT,FBPI,FBVEN,I,K_L,"FBADJ")=FBADJLR_U_FBADJLA_U_FBRRMKL_U_TAMT
45 S ^TMP($J,"FB",FBPSF,FBPAT,FBPI,FBVEN)=FBVCHAIN,^TMP($J,"FB",FBPSF,FBPAT)=FBDOB
46 ;S FBIN(5)=$P(Y(1),U,6) I FBIN(5)]"",$D(^TMP($J,"FB",FBPSF,FBPAT,FBPI,FBVEN,I,L)) D ANC^FBPCR67
47 Q
48VEN ;set variables for vendor
49 S V=$G(^FBAAV(+$P(Y(2),U,4),0)),FBVNAME=$E($P(V,U),1,23),FBVID=$P(V,U,2),FBVCHAIN=$P(V,U,10)
50 Q
51PRINT ;write output
52 I FBPG>1&(($Y+10)>IOSL) D HDR Q:FBOUT
53 E D HDR1
54 S FBVI="" F S FBVI=$O(^TMP($J,"FB",FBPSF,FBPT,FBPI,FBVI)) Q:FBVI']""!(FBOUT) D SH Q:FBOUT D Q:FBOUT
55 .S FBDT=0 F S FBDT=$O(^TMP($J,"FB",FBPSF,FBPT,FBPI,FBVI,FBDT)) Q:'FBDT S L=0 F S L=$O(^TMP($J,"FB",FBPSF,FBPT,FBPI,FBVI,FBDT,L)) Q:'L D Q:FBOUT
56 ..I ($Y+6)>IOSL D PAGE Q:FBOUT
57 ..S FBDATA=^TMP($J,"FB",FBPSF,FBPT,FBPI,FBVI,FBDT,L),FBCATC=$P(FBDATA,U,15),FBINS=$P(FBDATA,U,16)
58 ..S FBADJ=^TMP($J,"FB",FBPSF,FBPT,FBPI,FBVI,FBDT,L,"FBADJ")
59 ..W !,$P(FBDATA,U),?64,$P(FBDATA,U,11),!
60 ..W ?2,$P(FBDATA,U,2),?15,$P(FBDATA,U,3),?45,$P(FBDATA,U,4),?63,$P(FBDATA,U,5)
61 ..W !?4,$P(FBDATA,U,6),?12,$P(FBDATA,U,7)
62 ..W ?20 I $P(FBADJ,U,1)]"" W $P(FBADJ,U,1),?30,$J($P(FBADJ,U,2),14)
63 ..;If no adjustment code then print suspend cpde amd amount
64 ..I $P(FBADJ,U,1)="" W $P(FBDATA,U,8),?30,$J($P(FBADJ,U,4),14)
65 ..W ?47,$P(FBDATA,U,9),?58,$P(FBDATA,U,10),?66,$P(FBADJ,U,3)
66 ..I FBCATC!FBINS W !?5,">>> Cost recover from "_$S(FBCATC:"means testing",FBINS:"insurance",1:"") W:FBCATC&FBINS " and insurance" W "."
67 ..W !
68EXIT ;kill and quit
69 Q
70HDR ;main header
71 D HDR^FBPCR Q:FBOUT
72HDR1 W !!?(IOM-(13+$L(FBXPROG))/2),"FEE PROGRAM: ",FBXPROG
73 W !?4,"Fill Date",?64,"Date Certified"
74 W !,?15,"Drug Name",?44,"Strength",?60,"Quantity"
75 W !?2,"Claimed",?12,"Paid",?20,"Adj Code",?33,"Adj Amounts",?47,"Invoice #",?58,"Batch #",?66,"Remit Remarks",!,FBDASH
76 Q
77SH ;subheader - vendor, prints when name changes
78 I ($Y+4)>IOSL D HDR Q:FBOUT
79 W !!,"Vendor: ",$P(FBVI,";"),?41,"Vendor ID: ",$P($P(FBVI,";",2),"/",1),?65,"Chain #: ",$P($G(^TMP($J,"FB",FBPSF,FBPT,FBPI,FBVI)),U)
80 W !?20,"Fee Basis Billing Provider NPI: ",$P(FBVI,"/",2)
81 Q
82CR ;read for display
83 S DIR(0)="E" W ! D ^DIR K DIR S:$D(DUOUT)!($D(DTOUT)) FBOUT=1
84 Q
85PAGE ;new page
86 D HDR Q:FBOUT D SH
87 Q
88INSCK(FBDT,FBDA1,FBPI) ;possible cost recovery fcn call
89 ;Passed variables: fbdt=fill date or treatment from date
90 ; fbda1=ien if fee patient file, patient ien
91 ; fbpi=fee program
92 ;Output variables: fbins=1 if possible recovery, 0 if no
93 S FBINS=0,FBDT=FBDT+.1,FBDT=+$O(^FBAAA("AIC",FBDA1,-FBDT))
94 I FBDT S FBINS=$O(^FBAAA("AIC",FBDA1,FBDT,0)) I FBINS="Y" D
95 .N FBDA S FBDA=+$O(^FBAAA("AIC",FBDA1,FBDT,FBINS,0))
96 .I $P($G(^FBAAA(FBDA1,1,FBDA,0)),U,3)'=FBPI S FBINS=0
97 Q $S(FBINS="Y":1,1:0)
Note: See TracBrowser for help on using the repository browser.