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

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

initial load of FOIAVistA 6/30/08 version

File size: 8.2 KB
Line 
1IBCE837A ;ALB/TMP - OUTPUT FOR 837 TRANSMISSION - CONTINUED ;8/6/03 10:50am
2 ;;2.0;INTEGRATED BILLING;**137,191,211,232,296,377**;21-MAR-94;Build 23
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5UPD(MSGNUM,BATCH,CNT,BILLS,DESC,IBBTYP,IBINS) ; Upd current batch + bills w/new status
6 ;MSGNUM = mail msg # for batch
7 ;BATCH = batch #
8 ;CNT = # of bills in batch
9 ;BILLS = array BILLS(bill ien in 364) in batch
10 ;DESC = 1-80 character description of batch
11 ;IBBTYP = X-Y where X = P for professional or I for institution
12 ; Y = 1 for test or 0 for live transmission
13 ; or 2 for live claim resubmitted as test
14 ;IBINS = ien of single insurance company for the batch (optional)
15 ;
16 N DIC,DIE,DR,DA,IBBATCH,IBIFN,IBIEN,IBYY,IBTXTEST,IBMRA
17 S IBBATCH=$O(^IBA(364.1,"B",+BATCH,"")) Q:'IBBATCH
18 S IBTXTEST=+$P(IBBTYP,"-",2)
19 I '$P($G(^IBE(350.9,1,8)),U,7) S IBINS=""
20 ;
21 S DIE="^IBA(364.1,",DA=IBBATCH,DR=".02////P;.03///"_CNT_";.04///"_MSGNUM_";.05///0;.07////1;.08///^S X="""_DESC_""""_$S($G(IBINS):";.12////"_IBINS,1:"")
22 ;
23 I '$P($G(^TMP("IBRESUBMIT",$J)),U,3) S DR=DR_";1.01///NOW;1.02///.5"
24 I $P($G(^TMP("IBRESUBMIT",$J)),U,2) S DR=DR_";.15////"_$P(^($J),U,2)
25 ;
26 S DR=DR_";.14////"_$S('IBTXTEST:0,1:1)_";.06////"_$S($E(IBBTYP)="P":2,1:3) D ^DIE ; Update batch
27 ;
28 I IBTXTEST=2 D ADDTXM^IBCEPTM(.BILLS,IBBATCH,$$NOW^XLFDT()) Q
29 I IBTXTEST'=2 S IBIEN=0 F S IBIEN=$O(BILLS(IBIEN)) Q:'IBIEN D ;Update each bill
30 .S DA=IBIEN,DIE="^IBA(364,",DR=".02////"_IBBATCH_";.03///P;.04///NOW" D ^DIE
31 .S IBIFN=+$G(^IBA(364,IBIEN,0))
32 . ;
33 . ; If this claim has just been retransmitted, set the .06 field for the previous transmission entry
34 . N PRVTXI,PRVTXD
35 . S PRVTXI=$O(^IBA(364,"B",IBIFN,IBIEN),-1) ; previous transmission for this claim
36 . I PRVTXI D
37 .. S PRVTXD=$G(^IBA(364,PRVTXI,0))
38 .. I '$F(".R.E.","."_$P(PRVTXD,U,3)_".") Q ; prev trans must have status of "R" or "E"
39 .. I $P(PRVTXD,U,7,8)'=$P($G(^IBA(364,IBIEN,0)),U,7,8) Q ; test bill and COB must be the same
40 .. S DA=PRVTXI,DIE=364,DR=".06///"_IBBATCH D ^DIE ; update the resubmit batch number
41 .. Q
42 . ;
43 .Q:$D(^TMP("IBRESUBMIT",$J))!($P($G(^DGCR(399,IBIFN,0)),U,13)=4)!(+$$TXMT^IBCEF4(IBIEN)=2)
44 .S IBMRA=$$NEEDMRA^IBEFUNC(IBIFN)
45 .I IBMRA="C",$P($G(^DGCR(399,IBIFN,0)),U,13)=2 S IBMRA=1
46 .I IBIFN D
47 ..S (DIC,DIE)="^DGCR(399,",DA=$P($G(^IBA(364,IBIEN,0)),U),DR="[IB STATUS]",IBYY=$S('IBMRA:"@91",1:"@911") D:DA ^DIE
48 ..D BSTAT^IBCDC(IBIFN) ; remove from AB list
49 Q
50 ;
51PRE ; Run before processing a bill entry
52 K IBXSAVE,IBXERR,^UTILITY("VAPA",$J),^TMP("IBXSAVE",$J),^TMP($J),^TMP("DIERR",$J)
53 Q
54 ;
55POST ; Run after processing a bill entry for cleanup
56 N Q
57 I $G(IBXERR)'="" D
58 .S ^TMP("IBXERR",$J,IBXIEN)=IBXERR K ^TMP("IBXDATA",$J)
59 .K ^TMP("IBHDR1",$J)
60 .I $D(^TMP("IBRESUBMIT",$J)),'$G(^TMP("IBEDI_TEST_BATCH",$J)) D ;Set not resub flag for non-test bill
61 ..N Z,Z0
62 ..S Z0=$P($G(^TMP("IBRESUBMIT",$J)),U) Q:Z0=""
63 ..S Z=$O(^IBA(364,"ABABI",+$O(^IBA(364.1,"B",Z0,"")),IBXIEN,""))
64 ..I Z S ^TMP("IBNOT",$J,Z)=IBXIEN
65 K IBXSAVE,IBXNOREQ,^TMP("IBXSAVE",$J),^TMP($J)
66 S Q="VA" F S Q=$O(^UTILITY(Q)) Q:$E(Q,1,2)'="VA" I $D(^(Q,$J)) K ^UTILITY(Q,$J)
67 D CLEAN^DILF
68 Q
69 ;
70MAILIT(IBQUEUE,IBBILL,IBCTM,IBDUZ,IBDESC,IBBTYP,IBINS) ; Send mail msg, update bills
71 ;IBQUEUE = mail queue name to send 837 transactions to
72 ;IBBILL = array of ien's in file 364 of bills in batch - IBBILL(IEN)=""
73 ;IBCTM = # of bills in batch, returned reset to 0
74 ;IBDUZ = ien of user 'running' extract (if any)
75 ;IBDESC = description of batch
76 ;IBBTYP = X-Y where X = P for professional or I for institution
77 ; Y = 1 or 2 for test or 0 for live transmission
78 ;IBINS = ien of insurance company if only one/batch option (optional)
79 ;
80 N DIK,DA,XMTO,XMZ,XMBODY,XMDUZ,XMSUBJ,IBBDA,IBBNO
81 ;
82 S IBBNO=+$P($G(^TMP("IBHDR",$J)),U),IBBDA=$O(^IBA(364.1,"B",IBBNO,""))
83 I '$P($G(^IBE(350.9,1,8)),U,7) S IBINS=""
84 ;
85 I IBCTM D
86 . I +$G(^TMP("IBEDI_TEST_BATCH",$J)) S IBQUEUE="MCT"
87 . I IBQUEUE'="",IBQUEUE'["@" S XMTO("XXX@Q-"_IBQUEUE_".VA.GOV")=""
88 . I IBQUEUE["@" S XMTO(IBQUEUE)=""
89 . S XMDUZ=$G(IBDUZ),XMBODY="^TMP(""IBXMSG"","_$J_")",XMSUBJ=$S($P(IBBTYP,U,2):"** TEST"_$S($P(IBBTYP,U,2)=2:"/RESUB OF LIVE",1:""),1:"")_" CLAIM BATCH: "_$S(IBQUEUE'["@":IBQUEUE,1:$P(IBQUEUE,"@"))_"/"_IBBNO
90 . K XMZ
91 . D SENDMSG^XMXAPI(XMDUZ,XMSUBJ,XMBODY,.XMTO,,.XMZ)
92 . I $G(XMZ) D
93 .. D UPD(XMZ,$P($G(^TMP("IBHDR",$J)),U),IBCTM,.IBBILL,IBDESC,IBBTYP,IBINS) ;Update batch/bills
94 .. S ^TMP("IBCE-BATCH",$J,IBBNO)=IBBDA_U_IBCTM_U_$P($G(^TMP("IBRESUBMIT",$J)),U)
95MAILQ S IBCTM=0
96 D CHKBTCH(+$G(^TMP("IBHDR",$J)))
97 K ^TMP("IBHDR",$J),^TMP("IBHDR1",$J),^TMP("IBXMSG",$J),IBBILL
98 Q
99 ;
100CHKNEW(IBQ,IBBILL,IBCTM,IBDESC,IBBTYP,IBINS,IBSITE,IBSIZE) ;
101 ; Determine if ok to send msg
102 ; Check for one insurance per batch if IBINS defined
103 ; Returns IBSIZE, IBCTM, IBBILL (pass by reference)
104 ;
105 ; IBQ = data queue name
106 ; IBBILL = the 'list' of bill #'s in the batch
107 ; IBCTM = the # of claims output so far to the batch
108 ; IBDESC = the batch description text
109 ; IBBTYP = X-Y where X = P for professional or I for institution
110 ; Y = 1 for test or 0 for live transmission
111 ; IBINS = the ien of the single insurance co. for the batch (optional)
112 ; IBSITE = the '8' node of file 350.9 (IB PARAMETERS)
113 ; IBSIZE = the 'running' size of the output message
114 ;
115 Q:$S($G(IBINS)="":0,1:'$P(IBSITE,U,7))
116 ;
117 ; New batch needed
118 I IBCTM D MAILIT(IBQ,.IBBILL,.IBCTM,"",IBDESC,IBBTYP,IBINS) S IBSIZE=0
119 Q
120 ;
121ERRMSG(XMBODY) ; Send bulletin for error message
122 N XMTO,XMSUBJ
123 S XMTO("I:G.IB EDI")="",XMSUBJ="EDI 837 TRANSMISSION ERRORS"
124 ;
125 D SENDMSG^XMXAPI(,XMSUBJ,XMBODY,.XMTO)
126 D ALERT("One or more EDI bills were not transmitted. Check your mail for details","G.IB EDI")
127 Q
128 ;
129CLEANUP ; Cleans up bill transmission environment
130 ;
131 N IBTEST
132 S IBTEST=+$G(^TMP("IBEDI_TEST_BATCH",$J))
133 L -^IBA(364,0)
134 I $D(^TMP("IBRESUBMIT",$J,"IBXERR"))!$D(^TMP("IBONE",$J,"IBXERR"))!$D(^TMP("IBSELX",$J,"IBXERR")) D ;Error message to mail group
135 . N XMTO,XMBODY,XMDUZ,XMSUBJ,XMZ,IBFUNC
136 . S IBFUNC=$S($D(^TMP("IBRESUBMIT",$J,"IBXERR")):$S('IBTEST:1,1:4),$D(^TMP("IBONE",$J,"IBXERR")):2,1:3)
137 . Q:'IBFUNC
138 . S XMTO("I:G.IB EDI")="",XMDUZ="",XMBODY="^TMP("""_$S(IBFUNC=1!(IBFUNC=4):"IBRESUBMIT",1:"IBONE")_""","_$J_",""IBXERR"")"
139 . S XMSUBJ="EDI 837 B"_$P("ATCH^ILL^ILL(s)^ILL(s)",U,IBFUNC)_" NOT "_$S($G(^TMP("IBONE",$J)):"RE",1:"")_"SUBMITTED"_$S('IBTEST:"",1:" AS TEST CLAIMS")
140 . D SENDMSG^XMXAPI(XMDUZ,XMSUBJ,XMBODY,.XMTO,,.XMZ)
141 . K ^TMP("IBRESUBMIT",$J),^TMP("IBONE",$J)
142 ;
143 I $D(^TMP("IBRESUBMIT",$J)),'IBTEST D RESUBUP^IBCEM02 ;Upd resubmtd batch bills
144 I '$D(^TMP("IBSELX",$J)) K ^TMP("IBCE-BATCH",$J)
145 K ^TMP("IBXERR",$J),IBXERR
146 I 'IBTEST D CHKBTCH(+$G(^TMP("IBHDR",$J)))
147CLEANP ; Entrypoint for extract data disply
148 K ^TMP("IBTXMT",$J),^TMP("IBXINS",$J)
149 K ^TMP("IBRESUBMIT",$J),^TMP("IBRESUB",$J),^TMP("IBNOT",$J),^TMP("IBONE",$J),^TMP("IBHDR",$J),^TMP("IBTX",$J),^TMP("IBEDI_TEST_BATCH",$J)
150 K ^UTILITY("VADM",$J)
151 D CLEAN^DILF
152 K ZTREQ S ZTREQ="@"
153 Q
154 ;
155ALERT(XQAMSG,IBGRP) ; Send alert message
156 N XQA
157 S XQA(IBGRP)=""
158 D SETUP^XQALERT
159 Q
160CHKBTCH(IBBNO) ; Delete batch whose batch # is IBBNO if no entries in file 364
161 ; and not a resubmitted batch
162 N IBZ,DA,DIK
163 S IBZ=+$O(^IBA(364.1,"B",+IBBNO,""))
164 I IBZ,'$O(^IBA(364,"C",IBZ,0)),'$P($G(^IBA(364.1,IBZ,0)),U,14) S DA=IBZ,DIK="^IBA(364.1," D ^DIK
165 Q
166 ;
167TESTLIM(IBINS) ; Check for test bill limit per day has been reached
168 N IB3,DA,DIK
169 S IB3=$G(^DIC(36,IBINS,3))
170 I $P(IB3,U,5)'=DT S $P(IB3,U,7)=0
171 I ($P(IB3,U,7)+$G(^TMP("IBICT",$J,IBINS))+1)>$P(IB3,U,6) D Q
172 . S IBINS="" ;max # hit
173 . S DA=IBX,DIK="^IBA(364," D ^DIK
174 S ^TMP("IBICT",$J,IBINS)=$G(^TMP("IBICT",$J,IBINS))+1
175 Q
176 ;
177SETVAR(IBXIEN,IBINS,IB0,IBSEC,IBNID,IB837R,IBDIV) ;
178 ; Set up variables needed for subscripts in sort global
179 ; ejk added IBSEC logic for patch 296
180 ; IBSEC=1 if primary bill, 2 if 2nd/non-MRA, 3 if 2nd/MRA
181 S IBSEC=$S($$COBN^IBCEF(IBXIEN)=1:1,'$$MRASEC^IBCEF4(IBXIEN):2,1:3)
182 S IBNID=$$PAYERID^IBCEF2(IBXIEN)
183 S IB837R=$$RECVR^IBCEF2(IBXIEN)
184 S IBDIV=$P($S($P(IB0,U,22):$$SITE^VASITE(DT,$P(IB0,U,22)),1:$$SITE^VASITE()),U,3)
185 I IBNID'="","RPIHS"[$E(IBNID),$E(IBNID,2,$L(IBNID))="PRNT" S IBNID=IBNID_"*"_IBINS
186 I IBNID="" S IBNID="*"_IBINS
187 S $P(IBNID,"*",3)=$S($P(IB0,U,22):$P(IB0,U,22),1:"")
188 Q
189 ;
Note: See TracBrowser for help on using the repository browser.