source: FOIAVistA/trunk/r/ACCOUNTS_RECEIVABLE-PRCA-PRY-RC/RCDPESR6.m@ 1800

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

initial load of FOIAVistA 6/30/08 version

File size: 5.2 KB
Line 
1RCDPESR6 ;ALB/TMK - Server auto-update file 344.4 - EDI Lockbox ;10/29/02
2 ;;4.5;Accounts Receivable;**173,214,208,230**;Mar 20, 1995
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5UPD3444(RCRTOT) ; Add EOB detail to list in 344.41 for file 344.4 entry RCRTOT
6 ; If passed by reference, RCRTOT is returned = "" if errors
7 ;
8 N RC,RCCT,RC1,RC2,RCEOB,DA,DR,DO,DD,DLAYGO,DIC,DIK,X,Y,Z
9 S RC=0 F S RC=$O(^TMP($J,"RCDPEOB",RC)) Q:'RC S RC1=$G(^(RC)),RC2=$G(^(RC,"EOB")),RCEOB=+RC2 D Q:'RCRTOT
10 . ; Upd 344.41 with reference to this record if it doesn't already exist
11 . I RCEOB>0 Q:$D(^RCY(344.4,RCRTOT,1,"AC",RCEOB,RC))
12 . I RCEOB'>0,$S($P(RC1,U,2)'="":$D(^RCY(344.4,RCRTOT,1,"AD",$P(RC1,U,2),RC)),1:0) Q
13 . ; Disregard ECME reject related EEOBs
14 . I RCEOB'>0,'$P(RC2,U,2),$P(RC1,U,2)?1.7N,$$REJECT^IBNCPDPU($P(RC1,U,2),$P(RC1,U,3)) Q
15 . S DA(1)=RCRTOT,X=RC,DIC="^RCY(344.4,"_DA(1)_",1,",DIC(0)="L",DLAYGO=344.41
16 . S DIC("DR")=$S($G(RCEOB)>0:".02////"_RCEOB,1:".05////"_$P(RC1,U,2)_";.07////1")
17 . I $P(RC2,U,2)'="" S DIC("DR")=DIC("DR")_$S($L(DIC("DR")):";",1:"")_".03///"_$P(RC2,U,2) ; amt
18 . I $P(RC2,U,3)'="" S DIC("DR")=DIC("DR")_$S($L(DIC("DR")):";",1:"")_".04////"_$P(RC2,U,3) ; ins co
19 . I $P(RC2,U,4) S DIC("DR")=DIC("DR")_$S($L(DIC("DR")):";",1:"")_".14////1" ; reversal
20 . I $P(RC2,U,5)'="" S DIC("DR")=DIC("DR")_$S($L(DIC("DR")):";",1:"")_".15////^S X=$E($P(RC2,U,5),1,30)" ; Patient name
21 . D FILE^DICN K DO,DD,DLAYGO,DIC,DIK
22 . S RCCT=+Y
23 . I RCCT<0 D Q
24 .. S DA=RCRTOT,DIK="^RCY(344.4," D ^DIK
25 .. S RCRTOT=0
26 . ; If there is no IB EOB record, store the raw data in 344.411
27 . I RC1'>0!(RCEOB'>0) D
28 .. N RCDATA,RCC,RCDA
29 .. S RCC=2,RCDATA(1)=$G(^TMP($J,"RCDPEOB","HDR"))
30 .. S Z=0 F S Z=$O(^TMP($J,"RCDPEOB",RCCT,Z)) Q:'Z S RCC=RCC+1,RCDATA(RCC)=$G(^TMP($J,"RCDPEOB",RCCT,Z))
31 .. S RCDA(1)=RCRTOT,RCDA=RCCT
32 .. D WP^DIE(344.41,$$IENS^DILF(.RCDA),1,"A","RCDATA")
33 Q
34 ;
35 ;
36ERATOT(RCTDA,RCERR) ; File ERA TOTAL rec in 344.4 from entry RCTDA in 344.5
37 ; RCTDA = ien file 344.5
38 ; Returns: the ien file 344.4
39 ; RCERR if passed by reference, with error text
40 ; RCERR(1)=duplicated message
41 N RCTYPE,RCDA,RCMETH,RCTRACE,RCID,RCDT,RCAMT,RCDUP,RCZ,RCX,RCPAYER,DIE,DIK,DIC,DLAYGO,DD,DO,DR,DA,X,Y,Z0,Z1
42 S (RCERR,RCDA)=""
43 S RCZ=$G(^RCY(344.5,RCTDA,2,1,0))
44 S RCTYPE=$P(RCZ,U),RCTRACE=$P(RCZ,U,8),RCID=$P(RCZ,U,7),RCPAYER=$P(RCZ,U,6),RCMETH=$P(RCZ,U,17)
45 ; Need header record as first entry in field
46 I RCTYPE'["835ERA" S RCERR="No header record found in message. An EEOB exception record was created" G ERATOTQ
47 ;
48 S RCDT=$$FMDT^RCDPESR1($P(RCZ,U,9)),RCAMT=$J(($P(RCZ,U,10)/100),0,2)
49 ;Elec ERA's must have a trace # and an ins co id
50 I RCTRACE=""!(RCID="") S RCERR="Trace # or ins ID missing on ERA transaction. An EEOB exception record was created." G ERATOTQ
51 ; Make sure it's not already there
52 S (RCDUP,Z1)=0
53 F S Z1=$O(^RCY(344.4,"ATRID",RCTRACE,RCID,Z1)) Q:'Z1 S Z0=$G(^RCY(344.4,Z1,0)) I $P(Z0,U,4)=RCDT,+$P(Z0,U,5)=+RCAMT S RCDUP=1 Q
54 ;
55 I RCDUP,$P(Z0,U,8) D G ERATOTQ ; Receipt already exists - no update
56 . S RCERR="This is a duplicate ERA and has already been posted",RCERR(1)=-2
57 I RCDUP S RCERR="DUP",RCERR(1)=$S($P(Z0,U,12)'=$P($G(^RCY(344.5,RCTDA,0)),U,11):$P(Z0,U,12),1:-1) G ERATOTQ
58 ;
59 S RCX=+$O(^RCY(344.4," "),-1)
60 S DIC(0)="L",DIC="^RCY(344.4,",DLAYGO=344.4
61 S DIC("DR")=".02////"_RCTRACE_";.03////"_RCID_";.04////"_RCDT_";.05////"_RCAMT_";.06////"_$P(RCZ,U,6)_";.09////0;.12////"_$P($G(^RCY(344.5,RCTDA,0)),U,11)_";.07////"_$$NOW^XLFDT()_";.1////1"
62 I RCMETH'="" S DIC("DR")=DIC("DR")_";.15////"_RCMETH
63 F RCX=RCX+1:1 L +^RCY(344.4,RCX,0):1 I $T,'$D(^RCY(344.4,RCX,0)) S X=RCX Q
64 D FILE^DICN K DO,DLAYGO,DD,DIC
65 L -^RCY(344.4,RCX,0)
66 S RCDA=$S(Y<0:"",1:+Y)
67 I 'RCDA D
68 . S RCERR="An error was encountered that prevented the adding of an ERA totals record. An EEOB exception record was created."
69 ;
70ERATOTQ Q RCDA
71 ;
72UPDCON(RCRTOT) ; Add contact information to file 344.4 for an ERA
73 N DIE,DA,DR,Z,Q,X,Y
74 S Z=$G(^TMP($J,"RCDPEOB","CONTACT"))
75 Q:$TR($P(Z,U,3,9),U)=""
76 S DA=RCRTOT,DIE="^RCY(344.4,",DR=""
77 F Q=3:1:9 S DR=DR_$S(DR'="":";3.0",1:"3.0")_(Q-2)_"///"_$S($P(Z,U,Q)="":"@",1:"/"_$P(Z,U,Q))
78 D ^DIE
79 Q
80 ;
81UPDADJ(RCRTOT) ; Add ERA level adj data to file 344.4
82 N Z,Z0,DA,DIC,DLAYGO,DR,X,Y,DO,DD
83 ; Remove any already there
84 S Z=0 F S Z=$O(^RCY(344.4,RCRTOT,2,Z)) Q:'Z S DA(1)=RCRTOT,DA=Z D ^DIK
85 ;
86 S Z=0 F S Z=$O(^TMP($J,"RCDPEOB","ADJ",Z)) Q:'Z S Z0=$G(^(Z)) D
87 . S DIC(0)="L",X=$P(Z0,U,3)_" ",DA(1)=RCRTOT,DIC="^RCY(344.4,"_DA(1)_",2,",DIC("DR")=$S($P(Z0,U,2)'="":".02////"_$P(Z0,U,2),1:"")
88 . S DIC("DR")=DIC("DR")_$S(DIC("DR")'="":";",1:"")_$S($P(Z0,U,4)'="":".03////"_$J(-$P(Z0,U,4)/100,"",2),1:"")
89 . S DIC("DR")=DIC("DR")_$S(DIC("DR")'="":";",1:"")_$S($P(Z0,U,5)'="":".04////"_$P(Z0,U,5),1:""),DLAYGO=344.42
90 . S:$O(^RCY(344.4,RCRTOT,2,"B",X,0)) X=""""_X_""""
91 . D FILE^DICN K DIC,DO,DD
92 Q
93 ;
94DUPREC(RCET,RCCT,RCSTAR,RCFILE,RCALLDUP,RCEOB,RCBILL,RCDUPEOB) ; Overflow from RCDPESR2
95 S ^TMP("RCERR1",$J,RCCT)=" ",^TMP("RCERR1",$J,RCCT,1)=RCET_RCCT_RCSTAR
96 S ^TMP("RCERR1",$J,RCCT,2)="(Warning): EEOB detail already filed for "_RCBILL_" - "_$S(RCALLDUP:"Duplicate not stored",1:"EEOB updated"),^TMP("RCERR1",$J,RCCT,3)=" " S:RCFILE=5 ^TMP("RCERR1",$J,RCCT,"*")=^TMP("RCERR1",$J,RCCT,2)
97 I RCALLDUP S RCEOB="",RCDUPEOB=-1 Q
98 S $P(^TMP($J,"RCDPEOB",RCCT,"EOB"),U)=RCEOB
99 Q
100 ;
Note: See TracBrowser for help on using the repository browser.