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

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

revised back to 6/30/08 version

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