source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBCEM02.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.1 KB
Line 
1IBCEM02 ;ALB/TMP - 837 EDI RESUBMIT BATCH PROCESSING ;12-SEP-96
2 ;;2.0;INTEGRATED BILLING;**137,191,296**;21-MAR-94
3 Q
4 ;
5BATCH2 ; Resubmit a batch of bills not necessarily in error
6 N DIR,DIC,X,Y,IB
7 K ^TMP("IBEDI_TEST_BATCH",$J)
8 F S DIC="^IBA(364.1,",DIC(0)="AEMQ" D ^DIC Q:Y<0 S IB=+Y D I IB Q:'$$BATCH(+IB)
9 . N Y,IB0
10 . S IB0=$G(^IBA(364.1,IB,0)) I $P(IB0,U,14),'$O(^IBA(364,"C",IB,0)) D Q:'IB
11 .. S DIR("A",1)="THIS IS A TEST BATCH AND CANNOT BE RESUBMITTED."
12 .. I +$P(IB0,U,15) S DIR("A",2)="IT WAS CREATED AS A RESULT OF BATCH "_$P($G(^IBA(364.1,+$P(IB0,U,15),0)),U)_" BEING RESUBMITTED.",DIR("A",3)="RESUBMIT THIS ORIGINAL BATCH INSTEAD."
13 .. S DIR("A")="PRESS RETURN TO CONTINUE: "
14 .. S DIR(0)="EA"
15 .. W ! D ^DIR K DIR W !
16 .. S IB=0
17 . ;
18 . S DIR("A")="Are you resubmitting the claims in this batch for testing?: ",DIR("B")="NO",DIR(0)="YA" D ^DIR K DIR
19 . I $D(DTOUT)!$D(DUOUT) S IB=0 Q
20 . I +Y S ^TMP("IBEDI_TEST_BATCH",$J)=1 Q
21 . K ^TMP("IBEDI_TEST_BATCH",$J)
22 K ^TMP("IBEDI_TEST_BATCH",$J)
23 Q
24 ;
25BATCH(IBBDA) ;
26 N DIR,IBOK,IB0,IB1,ZTSK,IBSTAT,IBCE,IBASK,IBSTOP,IBTEST
27 S IB0=$G(^IBA(364.1,IBBDA,0)),IB1=$G(^(1)),IBSTAT=$P(IB0,U,2),IBASK=0
28 S IBTEST=+$G(^TMP("IBEDI_TEST_BATCH",$J))
29 ;
30 I 'IBTEST,$P(IB0,U,9) D I 'IBOK S IBASK=1 G BATCHQ
31 . S IBOK=1,ZTSK=$P(IB0,U,9) D STAT^%ZTLOAD
32 . I ZTSK(0)=0 S DIE="^IBA(364.1,",DA=IBBDA,DR=".09///@" D ^DIE Q ;Task not scheduled - delete task #
33 . I "125"[ZTSK(1) W *7,!,"Cannot resubmit this batch.",!,"This batch is currently ",$S("2"[ZTSK(1):"being resubmitted",1:"scheduled for resubmission")," - Task # is: ",$P(IB0,U,9),! S IBOK=0
34 ;
35 W !
36 S DIR("A",1)=$P(IB0,U,8)
37 S DIR("A",2)="Current Batch Status: "_$$EXPAND^IBTRE(364.1,.02,IBSTAT)
38 S DIR("A",3)=" Recorded On: "_$$FMTE^XLFDT($P(IB1,U,6),2)
39 S DIR("A",4)=" "
40 S DIR("A",5)=" Date Last Sent: "_$$FMTE^XLFDT($P(IB1,U,3),2)
41 S DIR("A",6)=" Last Sent By: "_$$EXPAND^IBTRE(364.1,1.04,$P(IB1,U,4))
42 S DIR("A",7)=" "
43 S DIR("A",8)=" Date First Sent: "_$$FMTE^XLFDT($P(IB1,U),2)
44 S DIR("A",9)=" First Sent By: "_$$EXPAND^IBTRE(364.1,1.02,$P(IB1,U,2))
45 S DIR("A",10)=" Number Of Bills: "_$P(IB0,U,3)
46 S DIR("A",11)=" "
47 ;
48 I $P(IB0,U,13),'IBTEST D G:IBSTOP BATCHQ
49 . S DIR("A",12)="BATCH WAS LAST RESUBMITTED ON "_$$FMTE^XLFDT($P(IB0,U,13),2),DIR("A",13)=" "
50 . S DIR(0)="YA",DIR("A")="ARE YOU SURE YOU WANT TO RESUBMIT IT AGAIN?: ",DIR("B")="NO" D ^DIR K DIR I 'Y!$D(DTOUT)!$D(DUOUT) S IBSTOP=1 Q
51 . S IBSTOP=0
52 ;
53 I IBSTAT'="P",'IBTEST S DIR("A",11)="WARNING - BATCH TRANSMITTED PREVIOUSLY & CONFIRMED RECEIVED BY "_$P("AUSTIN^PAYER/INTERMEDIARY",U,$TR(IBSTAT,"A")+1)
54 S DIR("A")="ARE YOU SURE YOU WANT TO RESUBMIT THIS BATCH"_$S(IBTEST:" FOR TEST",1:"")_"?: "
55 S DIR(0)="YA",DIR("B")="NO"
56 D ^DIR K DIR
57 S IBSTOP=('Y)
58 ;
59 K ^TMP("IBNOT",$J)
60 W !
61 I IBSTOP S IBASK=1 G BATCHQ
62 I IBSTAT'="P"!IBTEST D
63 . S DIR("A")="Do you want to exclude any bills from being resubmitted?: ",DIR("B")="NO",DIR(0)="YA" D ^DIR K DIR
64 . I Y D
65 .. N IBDAB,Z,IBCEFUNC
66 .. S IBCEFUNC=1,IBCE("VALMSG")="Select bills that should NOT be resubmitted"
67 .. D EN^VALM("IBCEM BATCH BILL LIST")
68 W !
69 D RESUB(IBBDA,$S(IBTEST:0,IBSTAT="P":1,1:0))
70 ;
71BATCHQ Q IBASK
72 ;
73RESUB(IBBDA,IBOLD) ; Resubmit a batch entry # IBBDA in file 364.1
74 ;IBOLD = 1 if old batch # should be used 0 if new batch # needed
75 ;
76 N IBIFN,IB0,IBS,IBS1,IBSCT,IBEXCT,IBE,IB,DIR,Y,IBT,IBPT,IBB,IBZTSK,IBTEST
77 K ^TMP("IBRESUBMIT",$J),^TMP("IBRESUB",$J)
78 S IBTEST=+$G(^TMP("IBEDI_TEST_BATCH",$J))
79 S IBOLD=+$G(IBOLD),^TMP("IBRESUB",$J)=$P($G(^IBA(364.1,IBBDA,0)),U)_U_IBBDA_U_IBOLD_U_IBTEST
80 ;
81 S (IBE,IBE(0),IBSCT,IBEXCT,IBIFN)=0
82 F S IBIFN=$O(^IBA(364,"ABABI",IBBDA,IBIFN)) Q:'IBIFN S IB=$O(^IBA(364,"ABABI",IBBDA,IBIFN,"")) Q:'IB S IB0=$G(^IBA(364,IB,0)),IBS=$P($G(^DGCR(399,IBIFN,0)),U,13) D
83 . I $D(^TMP("IBNOT",$J,IB)) S IBEXCT=IBEXCT+1 Q
84 . S IBSCT=IBSCT+1,IBS1=$P(IB0,U,3)
85 . I IBTEST!(IBS>1&(IBS<6)&("CRDZ"'[IBS1)) S ^TMP("IBRESUB",$J,IB)=IBIFN Q
86 . S IBE(0)=IBE(0)+1
87 . I IBS1'="","CRDZ"[IBS1 S IBE(IBS1)=$G(IBE(IBS1))+1 Q
88 . S IBE=IBE+1,^TMP("IBNOT",$J,IB)=IBIFN
89 ;
90 I 'IBTEST,'IBE(0),'IBSCT,'$D(^TMP("IBNOT",$J)) D CKRES^IBCESRV2(IBBDA) G RESUBQ
91 I IBE(0)!'IBSCT S Y=1 D G:'Y RESUBQ
92 . I IBE(0)=IBSCT W !,*7,"There are no bill(s) in this batch in a valid status to be resubmitted" W:IBEXCT !,IBEXCT," bill(s) in this batch have been specifically excluded" D PAUSE^VALM1 S Y="" Q
93 . F Z="C","R","D" I $D(IBE(Z)) W !,*7,IBE(Z)," bill(s) in this batch have been ",$S(Z="C":"cancelled",Z="R":"resubmitted",1:"deleted from batch")," previously"
94 . I IBE W !,*7,IBE," bill(s) in this batch are not in a valid status to be re-submitted"
95 . I IBEXCT W !,IBEXCT," bill(s) in this batch have been specifically excluded" Q:'IBE
96 . K DIR S DIR("A")="Do you want to resubmit the other "_(IBSCT-IBE(0))_" bill(s) in this batch?: ",DIR(0)="YA",DIR("B")="NO" D ^DIR K DIR
97 . W !
98 . I 'Y W !,*7,"Batch NOT resubmitted" D PAUSE^VALM1 S Y=0,IBSTOP=1 K ^TMP("IBRESUB",$J),^TMP("IBNOT",$J) Q
99 ;
100 S IBZTSK=""
101 I $O(^TMP("IBRESUB",$J,0)) D
102 . S ^TMP("IBRESUBMIT",$J)=$G(^TMP("IBRESUB",$J))
103 . S IB="" F S IB=$O(^TMP("IBRESUB",$J,IB)) Q:'IB S IBIFN=$P($G(^IBA(364,IB,0)),U),Y=$S('IBOLD&'IBTEST:$$ADDTBILL^IBCB1(IBIFN),1:IB) D
104 .. I IBTEST Q:$D(^TMP("IBNOT",$J,IB))
105 .. I 'IBTEST,'IBOLD,'$P(Y,U,3) S ^TMP("IBNOT",$J,IB)=IBIFN K ^TMP("IBRESUB",$J,IB) Q
106 .. S ^TMP("IBRESUBMIT",$J,+Y)=^TMP("IBRESUB",$J,IB),^TMP("IBRESUBMIT",$J,+Y,"OLD")=$S('IBTEST:IB,1:0)
107 . D EN1^IBCE837B(.IBZTSK,0)
108 . I 'IBTEST,$G(^TMP("IBRESUBMIT",$J))="ABORT" D ; No resubmit - delete entries
109 .. S IB="" F S IB=$O(^TMP("IBRESUBMIT",$J,IB)) Q:'IB S DIK="^IBA(364,",DA=IB D ^DIK
110 .. K ^TMP("IBRESUBMIT",$J)
111 I IBZTSK S ^TMP("IBRESUBMIT",$J)=^TMP("IBRESUB",$J),DIE="^IBA(364.1,",DR=".09////"_IBZTSK,DA=$S('IBTEST:+$P($G(^TMP("IBRESUBMIT",$J)),U,2),1:0) D:DA ^DIE ;task was queued
112 ;
113RESUBQ Q
114 ;
115RESUBUP ; Update old entries in file 364 for resubmitted bills, send bulletin
116 ; for bills not resubmitted in batch, if any, update new batch(s) with
117 ; old batch reference
118 N IBBA,IBE,IBT,IB,IBV,IBB,XMSUBJ,XMBODY,XMTO,XMDUZ
119 ;
120 S IBBA=+$P($G(^TMP("IBRESUBMIT",$J)),U,2) ;Original batch entry #
121 ;
122 I $O(^TMP("IBNOT",$J,0)) D
123 . S IBE=5,IB=""
124 . F S IB=$O(^TMP("IBNOT",$J,IB)) Q:IB="" S IBB=+$G(^(IB)),IBV=$$DISP^IBCEM3(IBB,"",1) D
125 .. Q:"CRDZ"[$P($G(^IBA(364,IB,0)),U,3)
126 .. S IBE=IBE+1,IBPT=$P(IBV,U,3)
127 .. S IBT(IBE)=" "_$E($P(IBV,U,2)_$J("",10),1,10)_$E($E($P(IBPT,"("),1,20)_"("_$P(IBPT,"(",2)_$J("",32),1,32)_" "_$E($P(IBV,U,4)_$J("",10),1,10)_" "_$$EXPAND^IBTRE(399,.13,$P($G(^DGCR(399,IBB,0)),U,13))
128 . I IBE>5 D ;Batch resubmit is still incomplete
129 .. S IBT(1)="The resubmission of bills in batch "_$P($G(^TMP("IBRESUB",$J)),U)_" was incomplete."
130 .. S IBT(2)="The following bills were NOT resubmitted:"
131 .. S IBT(3)=" ",IBT(4)=" BILL # PATIENT"_$J("",27)_"TYPE BILL STATUS",IBT(5)="",$P(IBT(5),"-",76)="",IBT(5)=" "_IBT(5)
132 .. S XMSUBJ="BILLS NOT RESUBMITTED WITH THEIR BATCH",XMBODY="IBT",XMDUZ="",XMTO("I:G.IB EDI")=""
133 .. D SENDMSG^XMXAPI(XMDUZ,XMSUBJ,XMBODY,.XMTO,,.XMZ)
134 .. I '$P($G(^IBE(364.1,IBBA,0)),U,10) S DIE="^IBA(364.1,",DR=".1////1",DA=IBBA D ^DIE
135 ;
136 I $G(^TMP("IBRESUBMIT",$J,0)),'$P($G(^TMP("IBRESUBMIT",$J)),U,3) D
137 . N IB,IBCT,IBO,IBIFN
138 . S (IB,IBCT)=0
139 . F S IB=$O(^TMP("IBRESUBMIT",$J,IB)) Q:'IB S IBIFN=+$G(^(IB)),IBO=$G(^(IB,"OLD")) D:IBO
140 .. S IBCT=IBCT+1
141 .. D UPDEDI^IBCEM(IBO,"R",1)
142 . D CTDOWN(IBBA,IBCT)
143 S DA=IBBA,DIE="^IBA(364.1,",DR=".09///@;.13///NOW;1.03///NOW;1.04////.5" D ^DIE
144 L -^IBA(364.1,DA)
145 K ^TMP("IBNOT",$J),^TMP("IBRESUB",$J)
146 Q
147 ;
148CTDOWN(IBBA,IBCT) ; Upd the count, incomplete resubmit status on the batch
149 ;IBBA = batch file ien
150 ;IBCT = the # to decrease the count
151 Q:'IBBA
152 N IBCT1,IBSTAT,IB0
153 S IB0=$G(^IBA(364.1,IBBA,0)),IBCT1=$P(IB0,U,3)-IBCT,IBSTAT=$P(IB0,U,10)
154 S:IBCT1<0 IBCT1=0
155 S IBINC=$S('IBSTAT:"",1:$$CKINC^IBCEM02(IBBA)),DIE="^IBA(364.1,",DR=".03////"_IBCT1_$S(IBINC'="":";.1////"_IBINC,1:""),DA=IBBA D ^DIE
156 Q
157 ;
158CKINC(IBBA) ;Check to see if batch resubmit is incomplete
159 ; IBBA = internal file 364.1 entry # of batch to check
160 N IBZ,IBINC,DR,DA,DIE
161 S IBZ="",IBINC=0
162 F S IBZ=$O(^IBA(364,"ABAST",IBBA,IBZ)) Q:IBZ="" I "CRD"'[IBZ S IBINC=1 Q
163 Q IBINC
164 ;
165LOCK(FILE,IBBDA) ; Lock file # FILE entry # IBBDA
166 I IBBDA L +^IBA(FILE,IBBDA):5
167 Q $T
168 ;
Note: See TracBrowser for help on using the repository browser.