source: WorldVistAEHR/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSNCPDP.m@ 1306

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

initial load of WorldVistAEHR

File size: 9.5 KB
Line 
1BPSNCPDP ;BHAM ISC/LJE - API to submit a claim to ECME ;8/01/03
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,4,2,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; For comments regarding this API, see routine BPSNCPD1.
6 ; They were moved to BPSNCPD1 due to size constraints
7 ;
8EN(BRXIEN,BFILL,BFILLDAT,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH) ;
9EN1 N DFN,PNAME,BRX,BPSARRY,MOREDATA,SITE,WFLG,OLDRESP,IEN59
10 N %,%I,%H,X,TODAY
11 N QUIT,CERTIEN
12 N REBILL,REVONLY,CLMSTAT,RESPONSE,BPSTART,IB,RESP
13 ;
14 ; Default variables
15 S RESPONSE="",CLMSTAT=""
16 ;
17 ; Check for valid RX and fill
18 I '$G(BRXIEN) S CLMSTAT="Prescription IEN parameter missing",RESPONSE=5 G END
19 I '$G(BFILL) S BFILL=0
20 ;
21 ; Setup IEN59, and initialize log
22 S IEN59=$$IEN59^BPSOSRX(BRXIEN,BFILL)
23 I IEN59="" S CLMSTAT="BPS Transaction IEN could not be calculated",RESPONSE=1 G END
24 D LOG^BPSOSL(IEN59,$T(+0)_"-Start of claim","DT")
25 ;
26 ; Check for BWHERE parameter
27 I $G(BWHERE)="" S CLMSTAT="RX Action parameter missing",RESPONSE=5 G END
28 ;
29 ; Get prescription number
30 S BRX=$$RXAPI1^BPSUTIL1(BRXIEN,.01,"I")
31 ;
32 ; Check that the prescription exists
33 I BRX="" S CLMSTAT="Prescription does not exist",RESPONSE=5 G END
34 ;
35 ; Get the NDC if it was not passed in
36 I $G(BILLNDC)="" S BILLNDC=$$GETNDC^PSONDCUT(BRXIEN,BFILL)
37 ;
38 ; Patient Info
39 S DFN=$$RXAPI1^BPSUTIL1(BRXIEN,2,"I"),PNAME=$$GET1^DIQ(2,DFN,.01)
40 ;
41 ; Set write flag
42 S WFLG=1
43 I ",ARES,AREV,CRLB,CRLR,CRLX,DDED,DE,EREV,HLD,PC,PE,PL,RS,"[(","_BWHERE_",") S WFLG=0
44 ;
45 ; Get status of previously submitted claim and set rebill/revonly flags
46 S (REBILL,REVONLY)=0
47 S OLDRESP=$P($$STATUS^BPSOSRX(BRXIEN,BFILL,1),U,1)
48 I ",AREV,CRLR,CRLX,DC,DDED,DE,EREV,HLD,RS,"[(","_BWHERE_",") S REVONLY=1
49 E I OLDRESP="E PAYABLE"!(OLDRESP="E DUPLICATE") S REBILL=1
50 ;
51 ; Get Site info and check if the site has ECME turned on. Note that
52 ; ECMEON will also return false if there is no NPI after the drop
53 ; dead date. Do not do this check for reversals/rebill as these
54 ; need to be processed for the old site
55 I 'BFILL S SITE=$$RXAPI1^BPSUTIL1(BRXIEN,20,"I")
56 I BFILL S SITE=$$RXSUBF1^BPSUTIL1(BRXIEN,52,52.1,+BFILL,8,"I")
57 I 'REVONLY,'REBILL D I RESPONSE=1 G END
58 . I '$G(SITE) S CLMSTAT="No Site Information",RESPONSE=1 Q
59 . I '$$ECMEON^BPSUTIL(SITE) S CLMSTAT="ECME switch is not on for the site",RESPONSE=1
60 ;
61 ; In Progress/Stranded claims check
62 I OLDRESP["IN PROGRESS" D G END
63 . S CLMSTAT="Previous request is IN PROGRESS. It may need to be unstranded.",RESPONSE=4
64 . I WFLG W !,CLMSTAT,! H 2
65 . ; If not OP, then send an email to the OPECC
66 . I ",AREV,BB,ERES,EREV,"'[(","_BWHERE_",") D BULL^BPSNCPD1(BRXIEN,BFILL,$G(SITE),$G(DFN),$G(PNAME))
67 ;
68 ; Backbilling check
69 I BWHERE="BB",OLDRESP'="" D G END
70 . S CLMSTAT="Previously billed through ECME: "_OLDRESP,RESPONSE=1
71 . I WFLG W !,CLMSTAT,! H 2
72 ;
73 ; Do not reverse if the prescription was not previously billed through ECME
74 I OLDRESP="",(",AREV,CRLR,CRLX,DC,DDED,DE,EREV,HLD,RS,"[(","_BWHERE_",")) D G END
75 . S CLMSTAT="Prescription not previously billed through ECME. Cannot Reverse claim.",RESPONSE=1
76 . I WFLG W !,CLMSTAT,! H 2
77 ;
78 ; If returning to stock or deleting and the previous claim was not paid, then no reversal is needed
79 ; so close the prescription and quit
80 I OLDRESP'["E PAYABLE",OLDRESP'["E REVERSAL REJECTED",(",RS,DE,"[(","_BWHERE_",")) D G END
81 . D CLOSE2^BPSBUTL(BRXIEN,BFILL,BWHERE)
82 . S CLMSTAT="Claim was not payable so it has been closed. No ECME claim created.",RESPONSE=3
83 . I WFLG W !,CLMSTAT,! H 2
84 ;
85 ; Do not reverse if the claim is not E PAYABLE
86 I OLDRESP'["E PAYABLE",OLDRESP'["E DUPLICATE",(",AREV,CRLR,CRLX,DC,DDED,HLD,"[(","_BWHERE_",")) D G END
87 . S CLMSTAT="Claim has status "_OLDRESP_". Not reversed.",RESPONSE=1
88 . I WFLG W !,CLMSTAT,! H 2
89 ;
90 ; EREV can be re-reversed if the previous submission is Payable or Rejected Revesal
91 I BWHERE="EREV",",E PAYABLE,E DUPLICATE,E REVERSAL REJECTED,E REVERSAL STRANDED,"'[(","_OLDRESP_",") D G END
92 . S CLMSTAT="Claim has status "_OLDRESP_". Not reversed.",RESPONSE=1
93 . I WFLG W !,CLMSTAT,! H 2
94 ;
95 ; Make sure fill date is not in the future or empty
96 D NOW^%DTC
97 S TODAY=$P(%,".",1)
98 I '$G(BFILLDAT)!($G(BFILLDAT)>TODAY) S BFILLDAT=TODAY
99 ;
100 ; Store needed parameters into MOREDATA
101 ; In instances where duz is null set it equal to .5 (postmaster)
102 S MOREDATA("USER")=$S('DUZ:.5,1:DUZ)
103 S MOREDATA("RX ACTION")=$G(BWHERE)
104 S MOREDATA("DATE OF SERVICE")=$P($G(BFILLDAT),".",1)
105 S MOREDATA("REVERSAL REASON")=$S($G(REVREAS)="":"UNKNOWN",1:$E($G(REVREAS),1,40))
106 I $G(DURREC)]"" S MOREDATA("DUR",1,0)=DURREC
107 I $G(BPOVRIEN)]"" S MOREDATA("BPOVRIEN")=BPOVRIEN
108 I $G(BPSCLARF)]"" S MOREDATA("BPSCLARF")=BPSCLARF
109 I $TR($G(BPSAUTH),"^")]"" S MOREDATA("BPSAUTH")=BPSAUTH
110 ;
111 ; Do a reversal for the appropriate actions
112 I ",AREV,CRLR,CRLX,DC,DDED,DE,EREV,HLD,RS,"[(","_BWHERE_",") D G STATUS:RESPONSE=0,END:RESPONSE=4
113 . ; If override flag is set, prompt for override values - MUST be commented out for any release.
114 . ;I $L($T(CHECK^ZZGIZOV1))>0,$$CHECK^ZZGIZOV1 D GETOVER^ZZGIZOV1(BRXIEN,BFILL,OLDRESP,BWHERE,"R")
115 . ;
116 . ; Needed for Turn-Around Stats - Do NOT delete/alter!!
117 . D LOG(IEN59,"Before Submit of Reversal")
118 . S BPSTART=$$STTM()
119 . S RESP=$$UNCLAIM^BPSOSRX(BRXIEN,BFILL,.MOREDATA)
120 . D LOG(IEN59,"After Submit of Reversal. Return Value: "_RESP)
121 . I RESP=1 D
122 .. S RESPONSE=0,CLMSTAT="Reversing prescription "_BRX_"."
123 .. I WFLG W !,CLMSTAT H 2
124 . I RESP=0 D
125 .. S RESPONSE=4,CLMSTAT="No claim submission made. Unable to queue reversal."
126 .. D LOG(IEN59,CLMSTAT)
127 .. I WFLG W !,CLMSTAT,! H 2
128 .. L -^BPST
129 ;
130 ; Can not resubmit reversed claims unless they are accepted
131 I OLDRESP]"",OLDRESP["E REVERSAL",OLDRESP'="E REVERSAL ACCEPTED" D G END
132 . S CLMSTAT="Can not resubmit a rejected or stranded reversal",RESPONSE=1
133 . I WFLG W !,CLMSTAT,! H 2
134 ;
135 ; Some actions require a paid claim (they will not do a reversal/resubmit)
136 I OLDRESP]"",OLDRESP'="E REVERSAL ACCEPTED",OLDRESP'="E REJECTED",(",CRLB,ED,ERES,RL,RRL,"'[(","_BWHERE_",")) D G END
137 . S CLMSTAT="Previously billed through ECME: "_OLDRESP,RESPONSE=1
138 . I WFLG W !,CLMSTAT,! H 2
139 ;
140 ; Certification Testing
141 S QUIT=0,CERTIEN=""
142 I ^BPS(9002313.99,1,"CERTIFIER")=DUZ D I QUIT S CLMSTAT="User exited from certification questions",RESPONSE=1 G END
143C1 . R !,"ENTER NDC: ",BILLNDC:120 S:BILLNDC="^" QUIT=1 Q:QUIT I BILLNDC="" G C1
144C3 . R !,"CERTIFICATION ENTRY: ",CERTIEN:120 I '$D(^BPS(9002313.31,CERTIEN)) S:CERTIEN="^" QUIT=1 Q:QUIT W !,"INVALID IEN" G C3
145 I WFLG W !!
146 ;
147 ; Build array BPSARRY with prescription data
148 D STARRAY^BPSNCPD1(BRXIEN,BFILL,BWHERE,.BPSARRY,$G(SITE))
149 ;
150 ; Do IB billing determination and check response
151 ; If IB=2, then not billable, so write messages
152 S IB=0
153 D EN^BPSNCPD2(DFN,BWHERE,.MOREDATA,.BPSARRY,.IB)
154 I IB=2,(OLDRESP="E PAYABLE")!(OLDRESP="E DUPLICATE"),(",CRLB,ED,ERES,RL,RRL,"[(","_BWHERE_",")) D
155 .S MOREDATA("REVERSE THEN RESUBMIT")=2
156 .S CLMSTAT=$P(MOREDATA("BILL"),"^",2)
157 .D LOG(IEN59,CLMSTAT_" - Claim Will Be Reversed But Will Not Be Resubmitted")
158 .I WFLG W !,CLMSTAT_" - Claim Will Be Reversed But Will Not Be Resubmitted" H 2
159 I IB=2,$G(MOREDATA("REVERSE THEN RESUBMIT"))'=2 D G END
160 . S RESPONSE=2
161 . S CLMSTAT=$P(MOREDATA("BILL"),"^",2)
162 . I OLDRESP]"" D LOG(IEN59,CLMSTAT)
163 ;
164 ; Check for missing data (Will IB billing determination catch this?)
165 I $D(MOREDATA("IBDATA",1,1)),$P(MOREDATA("IBDATA",1,1),"^",1)="",$G(MOREDATA("REVERSE THEN RESUBMIT"))'=2 D G END
166 . S RESPONSE=2,CLMSTAT="Information missing from IB data."
167 . I WFLG W !,CLMSTAT,! H 2
168 ;
169 ; Check for missing/invalid payer sheets (I think IB billing determination will catch this)
170 I $P($G(MOREDATA("IBDATA",1,1)),"^",4)="",$G(MOREDATA("REVERSE THEN RESUBMIT"))'=2 D G END
171 . S RESPONSE=2,CLMSTAT="Invalid/missing payer sheet from IB data."
172 . I WFLG W !,CLMSTAT,! H 2
173 ;
174 ; Check if IB says to bill
175 I '$G(MOREDATA("BILL")),$G(MOREDATA("REVERSE THEN RESUBMIT"))'=2 D G END
176 . S RESPONSE=2
177 . S CLMSTAT="Flagged by IB to not 3rd Party Insurance bill through ECME."
178 . I WFLG W !,CLMSTAT,! H 2
179 ;
180 ; Log message to ECME log
181 ; Needed for Turn-Around Stats - Do NOT delete/alter!!
182 D LOG(IEN59,"Before submit of claim")
183 ;
184 ; If override flag is set, prompt for override values - MUST be commented out for any release.
185 ;I $L($T(CHECK^ZZGIZOV1))>0,$$CHECK^ZZGIZOV1 D GETOVER^ZZGIZOV1(BRXIEN,BFILL,OLDRESP,BWHERE,"S")
186 ;
187 ; Get require data
188 S BPSTART=$$STTM()
189 ;
190 ; Submit claim and check result
191 S RESP=$$CLAIM^BPSOSRX(BRXIEN,BFILL,.MOREDATA)
192 D LOG(IEN59,"After Submit of Claim. Return Value: "_RESP)
193 I RESP=1 D
194 . S RESPONSE=0
195 . I $G(MOREDATA("REVERSE THEN RESUBMIT"))=2 S CLMSTAT="Prescription "_BRX_" successfully submitted to ECME for claim reversal."
196 . E S CLMSTAT="Prescription "_BRX_" successfully submitted to ECME for claim generation."
197 . I WFLG W !!,CLMSTAT
198 I RESP=0 D G END
199 . S RESPONSE=4
200 . S CLMSTAT="No claim submission made. Unable to queue claim submission."
201 . I WFLG W !!,CLMSTAT,!
202 . D LOG(IEN59,CLMSTAT)
203 ;
204 ; Display status
205STATUS I 'WFLG H 1
206 E D STATUS^BPSNCPD1(BRXIEN,BFILL,REBILL,REVONLY,BPSTART,BWHERE)
207 ;
208 ;Update Response for Reversal but no Resubmit
209 I $G(MOREDATA("REVERSE THEN RESUBMIT"))=2 S RESPONSE=10,CLMSTAT=$P($G(MOREDATA("BILL")),U,2)
210 ;
211 ; Clean up and quit
212END K BRXIEN,BFILL,BFILLDAT,BWHERE,MOREDATA
213 S:'$D(RESPONSE) RESPONSE=1
214 I $G(IEN59) D
215 . N MSG
216 . S MSG="Foreground Process Complete-RESPONSE="_$G(RESPONSE)
217 . I $G(RESPONSE)'=0 S MSG=MSG_", CLMSTAT="_$G(CLMSTAT)
218 . D LOG(IEN59,MSG)
219 Q RESPONSE_"^"_$G(CLMSTAT)
220 ;
221LOG(IEN59,MSG) ;
222 D LOG^BPSOSL(IEN59,$T(+0)_"-"_MSG)
223 Q
224STTM() ;
225 N %,%H,%I
226 D NOW^%DTC
227 Q %
Note: See TracBrowser for help on using the repository browser.