source: WorldVistAEHR/trunk/r/FEE_BASIS-FB/FBPCR.m@ 619

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

initial load of WorldVistAEHR

File size: 8.4 KB
Line 
1FBPCR ;AISC/DMK,GRR,TET-POTENTIAL COST RECOVERY OUTPUT DRIVER ;23 May 2006 10:06 AM
2 ;;3.5;FEE BASIS;**12,48,76,98,103**;JAN 30, 1995;Build 19
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ; DBIA SUPPORTED REF $$NPI^XUSNPI = 4532
5DOC ;Refer to fbdoc, tag fbpcr, for documentation of fbpcr* routines
6PSF ;select one/many/all primary service failities
7 S FBARRLTC=""
8 W !! S DIC="^DIC(4,",VAUTSTR="Primary Service Facility",VAUTNI=2,VAUTVB="FBPSV" D FIRST^VAUTOMA K DIC I Y=-1 G EXIT
9ARRAY ;set fee program array for all programs
10 S FBPI=0 F S FBPI=$O(^FBAA(161.8,FBPI)) Q:'FBPI S FBPIN=$G(^(FBPI,0)) I $P(FBPIN,U,3) S FBPROG(FBPI)=$P(FBPIN,U)
11 I '$D(FBPROG) G EXIT
12 ;prepare array with LTC POV codes
13 D MKARRLTC^FBPCR4
14 ;what party to include
15 K DIR
16 S DIR(0)="SO^P:Patient;I:Insurance;B:Both",DIR("A")="Include (P)atient Co-pays / (I)nsurance / (B)oth",DIR("B")="Both"
17 S DIR("?")=" Select type of recover to include",DIR("?",1)=" P - include only recover from patient copays",DIR("?",2)=" I - include only recover from insurance",DIR("?",3)=" B - include both",DIR("L")=""
18 D ^DIR S FBPARTY=$S($G(Y(0))="Patient":1,$G(Y(0))="Insurance":2,$G(Y(0))="Both":3,X="Both":3,1:0)
19 K DIR
20 G:FBPARTY=0 EXIT
21 ;what type of copay to include
22 S FBCOPAY=3
23 I FBPARTY'=2 D
24 . S DIR(0)="SO^M:MeansTest;L:LTC;B:Both",DIR("A")="Include (M)eans Test Co-pays /(L)TC Co-pays /(B)oth",DIR("B")="Both"
25 . S DIR("?")=" Select services to include",DIR("?",1)=" M - include only Means Test copays",DIR("?",2)=" L - include only LTC copays",DIR("?",3)=" B - include both",DIR("L")=""
26 . D ^DIR S FBCOPAY=$S($G(Y(0))="LTC":1,$G(Y(0))="MeansTest":2,$G(Y(0))="Both":3,X="Both":3,1:0)
27 . K DIR
28 G:FBCOPAY=0 EXIT
29 ;
30 ;include patients if their insurance informations is unavailable?
31 S FBINCUNK=0
32 I FBPARTY=2!(FBPARTY=3) D
33 . S FBINCUNK=1
34 . N Y,X
35 . W !!
36 . S DIR("A")="Do you want to include patients whose insurance status is unavailable? "
37 . S DIR("?")="Please answer Yes or No."
38 . S DIR("B")="YES",DIR(0)="YA^^"
39 . D ^DIR K DIR
40 . I $G(DIRUT) S FBINCUNK=-1 Q
41 . I $G(Y)=0 S FBINCUNK=0
42 I FBINCUNK=-1 G EXIT ;uparrow - exit
43 ;
44DATE ;select date range
45 D DATE^FBAAUTL I FBPOP G PSF
46 S FBBDATE=BEGDATE,FBEDATE=ENDDATE
47 S Z=9999999.9999,FBBEG=Z-FBEDATE,FBEND=Z-FBBDATE
48Q K ^TMP($J,"FB"),^TMP($J,"FBINSIBAPI"),DIC
49 ;
50 S VAR="FBINCUNK^FBARRLTC^FBARRLTC(^FBPARTY^FBCOPAY^FBNAME^FBIEN^FBID^FBBEG^FBEND^FBBDATE^FBEDATE^FBPSV^FBPSV(^FBPROG(",VAL=VAR,PGM="DQ^FBPCR",IOP="Q" D ZIS^FBAAUTL G:FBPOP EXIT
51DQ S $P(FBDASH,"=",80)="",$P(FBDASH1,"-",80)="",FBPG=0,FBCRT=$S($E(IOST,1,2)="C-":1,1:0),FBOUT=0,FBBEG=FBBEG-.9 U IO
52SORT ;sort driver for payment output(s)
53 S FBPI=0 F S FBPI=$O(FBPROG(FBPI)) Q:'FBPI S FBXPROG=FBPROG(FBPI) D
54 .I FBPI=2 D EN^FBPCR2 ;outpatient payments
55 .I FBPI=3 D EN^FBPCR3 ;pharmacy payments
56 .I FBPI=6!(FBPI=7) S:FBPI=6&($D(FBPROG(7))) FBPI=67 D EN^FBPCR67 S:FBPI=67 FBPI=7 ;civil hospital/cnh payments
57PRINT ;print driver for payment output(s)
58 I $G(^TMP($J,"FBINSIBAPI"))>0 D HDRUNK
59 S FBPI=$O(^TMP($J,"FB",0)) I FBPI']"" D WMSG G OUT
60 S FBSTA=0
61 S FBPSF=0 F S FBPSF=$O(^TMP($J,"FB",FBPSF)) Q:'FBPSF!FBOUT D STA S FBPT="" F S FBPT=$O(^TMP($J,"FB",FBPSF,FBPT)) Q:FBPT']""!FBOUT S DFN=$P(FBPT,";",2) D VET S FBPI=0 F S FBPI=$O(FBPROG(FBPI)) Q:'FBPI S FBXPROG=FBPROG(FBPI) D Q:FBOUT
62 .I FBPSF_FBPT'=FBSTA D HDR Q:FBOUT
63 .I FBPI=2,$D(^TMP($J,"FB",FBPSF,FBPT,FBPI)) D PRINT^FBPCR2 Q
64 .I FBPI=3 D:$D(^TMP($J,"FB",FBPSF,FBPT,FBPI)) PRINT^FBPCR3 Q
65 .I FBPI=6!(FBPI=7) D:$D(^TMP($J,"FB",FBPSF,FBPT,FBPI)) PRINT^FBPCR671 Q
66OUT I $G(^TMP($J,"FBINSIBAPI"))>0 D ERRHDL^FBPCR4
67 I FBOUT!$D(ZTQUEUED) G EXIT
68 D EXIT G PSF
69 Q
70EXIT ;kill and quit
71KILL ;kill all variables set in the FBPCR* routines, other than fbx
72 D CLOSE^FBAAUTL K ^TMP($J,"FB")
73 K A1,A2,A3,BEGDATE,C,D,D2,DFN,DIC,DIR,DTOUT,DUOUT,ENDDATE,FBPDXC,FBPARTY,FBCOPAY,FBARRLTC,FBINCUNK
74 K FBAAA,FBAACPTC,FBAC,FBAP,FBBATCH,FBBDATE,FBBEG,FBBN,FBCATC,FBCNT,FBCP,FBCRT,FBDA1,FBDASH,FBDASH1,FBDATA,FBDOB,FBDRUG,FBDT,FBDT1,FBDOS,FBDX,FBDX1,FBEDATE,FBEND,FBERR,FBFD,FBFD1,FBHEAD
75 K FBI,FBID,FBIEN,FBIN,FBINS,FBINVN,FBIX,FBJ,FBLOC,FBM,FBNAME,FBOB,FBOPI,FBOUT,FBOV,FBP,FBPAT,FBPD,FBPDX,FBPG,FBPI,FBPID,FBPIN,FBPNAME,FBPROC,FBPROC1,FBPROG,FBPSF,FBPSFNAM,FBPSFNUM,FBPSV,FBPT,FBPV,FBQTY,FBREIM,FBRX
76 K FBSC,FBSL,FBSTA,FBSTR,FBSUSP,FBTA,FBTYPE,FBV,FBVCHAIN,FBVEN,FBVENID,FBVNAME,FBVI,FBVID,FBVP,FBXPROG,FBY,FBZ,I,IOP,J,K,L,M,N,PGM,T,V,VA,VAERR,VAL,VAR,VAUTNI,VAUTSTR,VAUTVB,X,Y,Z,FBSTANPI,FBXX
77 Q
78WMSG ;write message if no matches found
79 D HDR W !!?3,"There are no potential cost recoveries on file"
80 W !?5,"for specified date range: ",$$DATX^FBAAUTL(FBBDATE)," through ",$$DATX^FBAAUTL(FBEDATE)
81 I 'FBPSV D
82 .W ",",!?5,"and selected Primary Service Area(s):"
83 .S FBPSF=0 F S FBPSF=$O(FBPSV(FBPSF)) Q:'FBPSF W !?31,$G(FBPSV(FBPSF))
84 E W !?5,"and ALL Primary Service Areas "
85 W ".",*7,!!
86 Q
87 ;
88CATC(DFN,FBDT,FBPOV) ;
89 ;treats all copays as Means test for date < 3020705 (JULY 5,2002)
90 ;check if patient is liable for copay
91 ;INPUT:
92 ; DFN = IEN of Patient file
93 ; FBDT= Date
94 ; FBPOV = POV code (for LTC determination)
95 ;OUTPUT:
96 ;0 - the patient is not liable for any co-pay;
97 ;1 - if Means test catc or pending adjudication and agree to pay deduc
98 ;2 - the patient is liable for LTC co-pay;
99 ;3 - no 1010EC on file
100 ;4 - more analysis is needed to determine the patient liability
101 N FBLTC,FBISLTC
102 S FBCATC=$$BIL^DGMTUB(DFN,FBDT)
103 I '$D(FBPOV)!(FBDT<3020705) Q $S(FBCATC:1,1:0)
104 S FBISLTC=$$ISLTC^FBPCR4(FBPOV)
105 I FBISLTC=0 Q $S(FBCATC:1,1:0) ;Means test
106 I FBISLTC=2 Q 0 ;LTC-service, but LTC-copay is not applicable
107 S FBLTC=$$LTCST^FBPCR4(DFN,FBDT)
108 I FBLTC=2 Q 2 ;LTC copay
109 I FBLTC=0 Q 3 ;no 1010EC on file
110 I FBLTC=4 Q 4 ;more info needed
111 Q 0 ;exemption from LTC -copay
112 ;
113VET ;set vet name/ssn/dob info
114 ;INPUT: DFN = IEN of Patient file
115 ; FBPI = IEN of fee program (optional)
116 ;OUTPUT: FBPNAME = Patient's name
117 ; FBPID = Patient's pid
118 ; FBDOB = Patient's dob (if pharmacy fee program)
119 N N
120 S N=$G(^DPT(DFN,0)),FBPNAME=$P(N,U),FBPID=$$SSN^FBAAUTL(DFN),FBDOB=$$FMTE^XLFDT($P(N,U,3))
121 Q
122STA ;set station name & number
123 ;INPUT = FBPSF - IEN to institution file
124 ;OUTPUT = FBPSFNAM = station name
125 ; FBPSFNUM = station number
126 S FBPSFNAM=$P($G(^DIC(4,FBPSF,0)),U),FBPSFNUM=$P($G(^DIC(4,FBPSF,99)),U)
127 S:FBPSFNAM=+FBPSFNAM FBPSFNAM="UNKNOWN"
128 S FBSTANPI=$S($G(FBPSFNAM)="":"",FBPSFNAM="UNKNOWN":"",1:$P($$NPI^XUSNPI("Organization_ID",FBPSF),U,1))
129 Q
130PAGE ;form feed when new station/patient
131 S FBSTA=$G(FBPSF)_$G(FBPT)
132 I FBCRT&(FBPG'=0) D CR Q:FBOUT
133 I FBPG>0!FBCRT W @IOF
134 S FBPG=FBPG+1
135 Q
136CR ;read for display
137 S DIR(0)="E" W ! D ^DIR K DIR S:$D(DUOUT)!($D(DTOUT)) FBOUT=1
138 Q
139HDR ;general header for potential recoveries
140 D PAGE Q:FBOUT
141 W !?(IOM-30/2),"POTENTIAL COST RECOVERY REPORT"
142 W !?(IOM-(11+$L($G(FBPSFNAM))+$L($G(FBPSFNUM)))/2),"Division: ",$G(FBPSFNUM)," ",$G(FBPSFNAM)
143 W !?(IOM-14/2),"NPI: ",$S($G(FBSTANPI)="":"",$G(FBSTANPI)<1:"",1:$G(FBSTANPI))
144 W !?(IOM-19/2),$$DATX^FBAAUTL(FBBDATE)," - ",$$DATX^FBAAUTL(FBEDATE)
145 W !?71,"Page: ",FBPG
146 W !,"Patient: ",$G(FBPNAME),?40,"Pat. ID: ",$G(FBPID),?62,"DOB: ",$G(FBDOB)
147 W !
148 I FBINCUNK=1,$D(^TMP($J,"FBINSIBAPI",+$G(DFN))) W ">> Warning: accurate insurance information for the patient is unavailable"
149 W !?3,"('*' Represents Reimbursement to Patient",?50,"'#' Represents Voided Payment)"
150 W !,FBDASH
151 W ! D:$D(DFN) INS^DGRPDB
152 Q
153HDRUNK ;Warning message if patient's insurance status is unknown
154 D PAGE Q:FBOUT
155 W !?(IOM-30/2),"POTENTIAL COST RECOVERY REPORT"
156 W !?(IOM-(11+$L($G(FBPSFNAM))+$L($G(FBPSFNUM)))/2),"Division: ",$G(FBPSFNUM)," ",$G(FBPSFNAM)
157 W !?(IOM-19/2),$$DATX^FBAAUTL(FBBDATE)," - ",$$DATX^FBAAUTL(FBEDATE)
158 W !?71,"Page: ",FBPG
159 W !,"------------------------------ !!! WARNING !!! --------------------------------"
160 W !,"This report is incomplete due to problems with obtaining insurance information"
161 W !,"for those patients listed in a separate section in the end of the report. You"
162 W !,"may want to rerun the report again to get more accurate results."
163 W !,FBDASH
164 I FBINCUNK=1 D
165 . W !,"Note: You have chosen to include patients with unknown insurance status in"
166 . W !,"this report. Please be aware that these patients will be treated as if they"
167 . W !,"have billable insurance and their treatment details will be marked accordingly."
168 . W !,"The names of these patients will be accompanied with the following message"
169 . W !,"to order to identify them:"
170 . W !,">> Warning: accurate insurance information for the patient is unavailable"
171 . W !,FBDASH
172 Q
Note: See TracBrowser for help on using the repository browser.