source: FOIAVistA/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMPREC1.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 5.3 KB
Line 
1IVMPREC1 ;ALB/SEK/BRM - PROCESS INCOMING HL7 (ACK) MESSAGES ; 07/28/2003
2 ;;2.0;INCOME VERIFICATION MATCH;**9,17,26,52,34,72,82**; 21-OCT-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ; This routine will process ACK HL7 messages received from the
6 ; IVM center.
7 ;
8ACK ; - Receive ACK Message from IVM Center stored in ^TMP("HLR".
9 ; If 1st segment is BHS then set(s) of MSH, MSA(AE) will follow
10 ; indicating error(s) in transmission received by IVM Center
11 ; If 1st segment is MSH than MSA (AA) indicating batch or individual
12 ; query was received ok. MSA (AE) indicates error in transmission of
13 ; individual query.
14 ;
15 ; - When acknowledgment code = "AA" (application accept)
16 ; Stuff 1 into STATUS field (.03) of ^IVM(301.6 indicating IVM Center
17 ; has received transmission.
18 ;
19 K HLNODE,IVMRTN,SEGCNT,CNT
20 S IVMRTN="IVMPREC1"
21 S HLFS=HL("FS"),HLQ=HL("Q"),HLECH=HL("ECH")
22 K ^TMP($J,IVMRTN)
23 F SEGCNT=1:1 X HLNEXT Q:HLQUIT'>0 D
24 . S CNT=0,^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE
25 . F S CNT=$O(HLNODE(CNT)) Q:'CNT D
26 . . S ^TMP($J,IVMRTN,SEGCNT,CNT)=HLNODE(CNT)
27 S HLDA=HLMTIEN
28 K HLNODE,SEGCNT,CNT
29 ;
30 S IVMSEG=$G(^TMP($J,IVMRTN,1,0))
31 I IVMSEG="" G ACKQ
32 I $P(IVMSEG,HLFS)'="BHS",$P(IVMSEG,HLFS)'="MSH" G ACKQ
33 ;
34 ; - process batches of acknowledges
35 I $P(IVMSEG,HLFS)="BHS" D AE G ACKQ
36 ;
37 ; - process MSH MSA message
38 S IVMSEG=$G(^TMP($J,IVMRTN,2,0))
39 I $P(IVMSEG,HLFS)'="MSA" G ACKQ
40 S IVMADDT=$P(IVMSEG,HLFS,3)
41 I $P(IVMSEG,HLFS,2)="AA" D G ACKQ
42 .F IVMDA=0:0 S IVMDA=$O(^IVM(301.6,"AE",IVMADDT,IVMDA)) Q:'IVMDA I $$SETSTAT^IVMTLOG(IVMDA,1)
43 ;
44 I $P(IVMSEG,HLFS,2)="AE" D G ACKQ
45 .S IVMMCI=$P(IVMSEG,HLFS,3)
46 .S IVMEM=$P(IVMSEG,HLFS,4)
47 .S IVMDA=$O(^IVM(301.6,"AE",IVMADDT,"")) I 'IVMDA D OTH Q
48 .I $$SETSTAT^IVMTLOG(IVMDA,3,IVMEM)
49 ;
50ACKQ ;
51 K ^TMP($J,IVMRTN)
52 K DA,DIE,DR,IVMADDT,IVMI,IVMCT,IVMDA,IVMMCI,IVMEM,IVMNAME,IVMPAT,IVMRTN,IVMSEG,IVMSSN,IVMTEXT,XMSUB
53 ;
54 Q
55 ;
56AE ; - When acknowledgment code = "AE" (application error)
57 ; Stuff 3 into STATUS field(.03), error message into ERROR MESSAGE
58 ; field(.04), and 1 (NEW) into the ERROR PROCESSING STATUS field.
59 ; Stuff 1 into STATUS field(.03) for transmissions (no 'AE' code
60 ; received) received by IVM Center.
61 ;
62 N Z07FLG,Z07RET
63 S IVMI=0 F S IVMI=$O(^TMP($J,IVMRTN,IVMI)) Q:'IVMI S IVMSEG=$G(^(IVMI,0)) D
64 .D:$E(IVMSEG,1,3)="MSH"
65 ..S Z07RET=0
66 ..I $P(IVMSEG,HLFS,9)["ORU~Z07" S Z07FLG=1 Q
67 ..K Z07FLG
68 .Q:IVMSEG']""!($E(IVMSEG,1,3)'="MSA")!($P(IVMSEG,HLFS,2)'="AE")
69 .S IVMMCI=$P(IVMSEG,HLFS,3)
70 .S IVMEM=$P(IVMSEG,HLFS,4)
71 .S IVMDA=$O(^IVM(301.6,"ADS",IVMMCI,"")) I 'IVMDA D Q:'Z07RET
72 ..I $D(Z07FLG) D Q
73 ...S Z07RET=$$Z07CHK(IVMI,IVMMCI,IVMEM)
74 ...S:Z07RET IVMDA=$O(^IVM(301.6,"ADS",IVMMCI,""))
75 ..D OTH
76 .I $$SETSTAT^IVMTLOG(IVMDA,3,IVMEM)
77 ;
78 ; - update messages in batch with no error
79 F IVMDA=0:0 S IVMDA=$O(^IVM(301.6,"AE",+$G(IVMMCI),IVMDA)) Q:'IVMDA I $$SETSTAT^IVMTLOG(IVMDA,1)
80 Q
81 ;
82OTH ; Generate message for errors other than Full/Initial Transmissions.
83 N IVMRMM,IVMNAM,IVMPID,IVMTMP,HLDA,HLDAT,HLSEG,DIC,DR,DA,DIQ
84 S (IVMNAM,IVMPID,HLDA,IVMTMP)=""
85 S HLDA=$O(^HL(772,"C",$P($G(IVMMCI),"-"),0))
86 Q:+$G(HLDA)'>0
87 Q:'$D(^HL(772,+HLDA,0))
88 S DIC="^HL(772,",DR=200,DA=HLDA,DR(200.02)=.01,DA(200.02)=17,DIQ="HLDAT"
89 D EN^DIQ1
90 F S IVMTMP=$O(HLDAT(772,HLDA,200,IVMTMP)) Q:((IVMTMP="")!($G(HLSEG)="PID")) D
91 .S HLSEG=$P($G(HLDAT(772,HLDA,200,IVMTMP)),"^")
92 .D:HLSEG="PID"
93 ..S IVMNAM=$P($G(HLDAT(772,HLDA,200,IVMTMP)),"^",6) ;PATIENT NAME
94 ..S IVMNAM=$P(IVMNAM,"~")_", "_$P(IVMNAM,"~",2)
95 ..S IVMPID=$P($G(HLDAT(772,HLDA,200,IVMTMP)),"^",20) ;SSN
96 ..;S IVMPID=$P(IVMPID,"~")
97 ..S IVMPID=$E(IVMPID,1,3)_"-"_$E(IVMPID,4,5)_"-"_$E(IVMPID,6,9)
98 ..S XMSUB="ERROR MESSAGE FROM THE HEC"
99 ..S IVMTEXT(1)="An Insurance Confirmation message or a Billing/Collections Transmission"
100 ..S IVMTEXT(2)="was rejected by the Health Eligibility Center with the following error:"
101 ..S IVMTEXT(3)=" ",IVMTEXT(4)=IVMEM,IVMTEXT(5)=" "
102 ..S IVMTEXT(6)="NAME: "_IVMNAM
103 ..S IVMTEXT(7)="PID : "_IVMPID,IVMTEXT(8)=" "
104 ..S IVMRMM=$$MMN^IVMPTRN4($P(IVMMCI,"-"))
105 ..S IVMTEXT(9)="Mailman Message # of Acknowledged Transmission: "_$S(IVMRMM:IVMRMM,1:"<unknown>")
106 ..S IVMTEXT(10)=" "
107 ..S IVMTEXT(11)="If you are unable to find the source of this problem,"
108 ..S IVMTEXT(12)="please contact your ISC Support Group or the HEC."
109 ..D MAIL^IVMUFNC()
110 Q
111 ;
112Z07CHK(CURSEQ,CURMCI,CUREM) ; Function ;
113 ; INPUT
114 ; CURSEQ : Current Sequence # reviewing in batch
115 ; CURMCI : Current Message Control ID reviewing in batch
116 ; CUREM : Current Error Message reviewing in batch
117 ;
118 ; Check for duplicate ACK sequence on the same batch
119 N SEQ,CHKSEG,CHKSEGN,DUP
120 S (SEQ,DUP)=0
121 F S SEQ=$O(^TMP($J,IVMRTN,SEQ)) Q:SEQ="" D
122 . S CHKSEG=^TMP($J,IVMRTN,SEQ,0),CHKSEGN=$E(CHKSEG,1,3)
123 . Q:CHKSEGN'="MSA"
124 . Q:SEQ=CURSEQ
125 . S:$P(CHKSEG,"^",3)=CURMCI DUP=1
126 I DUP Q "0^DUPLICATE SEQUENCE ON ACK BATCH"
127 ;
128 ; Check to see if ADS x-ref missing in last 1000 entries
129 N END,IEN,MCI,FND,LOG,RET,TMPCTR
130 S FND=0,RET="",IEN=" "
131 F TMPCTR=1:1:1000 S IEN=$O(^IVM(301.6,IEN),-1) Q:+IEN=0 D Q:FND
132 . S MCI=$P(^IVM(301.6,IEN,0),"^",5)
133 . I MCI=CURMCI S FND=1 D Q
134 . . S LOG=^IVM(301.6,IEN,0)
135 . . I $P(LOG,"^",3)=3&($P(LOG,"^",4)=CUREM) S RET="0^ACK TO THIS SEQUENCE HAS ALREADY BEEN PROCESSED" Q
136 . . S ^IVM(301.6,"ADS",CURMCI,IEN)="" S RET="1^ADS X-REF MISSING. X-REF HAS BEEN RESET."
137 Q RET
Note: See TracBrowser for help on using the repository browser.