source: FOIAVistA/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMPTRN3.m@ 1114

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

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1IVMPTRN3 ;ALB/KCL - SEND INITIAL TRANSMISSION TO IVM CENTER ; 9/24/03
2 ;;2.0;INCOME VERIFICATION MATCH;**1,9,34,92**; 21-OCT-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5FILE ; - call HL7 to send batch of segments
6 ;
7 I IVMCT'>0 Q
8 ;
9 N HLRESLT
10 ;
11 ; - send batch of HL7 messages
12 D GENERATE^HLMA(HLEID,"GB",1,.HLRESLT,MTIEN)
13 ;
14 K ^TMP("HLS",$J)
15 S IVMGTOT=$G(IVMGTOT)+HLEVN
16 S (HLEVN,IVMCT)=0
17 Q
18 ;
19FILE1 ; - call HL7 to send batch of segments
20 ; (V1.6 - call this if non-ack batch but still has an MSA segment.)
21 ; Called by ^IVMPTRN and ^IVMPTRN7 with ^TMP("HLS",$J) global set.
22 ; Must convert ^TMP("HLS" into ^TMP("HLA" for GENACK^HLMA1 to work.
23 ;
24 I IVMCT'>0 Q
25 ;
26 N HLP,HLRESLTA
27 S HLEIDS=$O(^ORD(101,HLEID,775,"B",0))
28 ;
29 ; - send batch of HL7 messages
30 K ^TMP("HLA",$J)
31 M ^TMP("HLA",$J)=^TMP("HLS",$J)
32 D GENACK^HLMA1(HLEID,MTIEN,HLEIDS,"GB",1,.HLRESLTA,.HLP)
33 ;
34 K ^TMP("HLS",$J)
35 K ^TMP("HLA",$J)
36 S IVMGTOT=$G(IVMGTOT)+HLEVN
37 S (HLEVN,IVMCT)=0
38 Q
39 ;
40FILEPT(DFN,IVMYR,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
41 ;Description: File patient in IVM PATIENT (#301.5) file and file
42 ;TRANSMISSION LOG entry.
43 ;
44 ;Input:
45 ; DFN - ien of record in the PATIENT file.
46 ; IVMYR - income year of the ORU~Z07 message.
47 ; WHEN - date/time message sent, in FM format.
48 ; MSGID - message id used for message, in format used by MESSAGE CONTROL ID field.
49 ; EVENTS () - an array of reasons for transmission, pass by reference.
50 ; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
51 ; EVENTS(" "DCD")=1 if transmission due to DCD criteria, 0 otherwise
52 ; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
53 ; MTSTAT - pointer to the MEANS TEST STATUS file. Is the status of the patient's means test at the time of the transmission for the income year of the transmission.
54 ; INSSTAT - 1 if the patient had active insurance at the time of the transmission, 0 otherwise.
55 ;
56 N IVMPTR,DGSENFLG
57 ;
58 ; - ignore security checks in MAS (DGSEC)
59 S DGSENFLG=1
60 ;
61 ;find or create entry in IVM PATIENT file
62 S IVMPTR=$$FIND^IVMPLOG(DFN,IVMYR)
63 S:'IVMPTR IVMPTR=$$LOG^IVMPLOG(DFN,IVMYR,.EVENTS)
64 Q:'IVMPTR
65 ;
66 ; Check the 301.5 record for Transmission Status
67 N TRSTAT S TRSTAT=+$P(^IVM(301.5,IVMPTR,0),U,3)
68 ;
69 ; If this record is not updated, update it only
70 I 'TRSTAT D UPDTLOG(IVMPTR,WHEN,MSGID,.EVENTS,MTSTAT,INSSTAT)
71 ;
72 ; If this record is already updated, check all other records
73 ; for this patient that should be updated.
74 I TRSTAT D
75 .N NXTPTR,NXTYR S NXTPTR=0
76 .F S NXTPTR=$O(^IVM(301.5,"B",DFN,NXTPTR)) Q:'NXTPTR D
77 ..Q:NXTPTR=IVMPTR
78 ..S TRSTAT=+$P(^IVM(301.5,NXTPTR,0),U,3)
79 ..Q:TRSTAT
80 ..S NXTYR=$P(^IVM(301.5,NXTPTR,0),U,2)
81 ..I $$LOG^IVMPLOG(DFN,NXTYR,.EVENTS)
82 ..D UPDTLOG(NXTPTR,WHEN,MSGID,.EVENTS,MTSTAT,INSSTAT)
83 ;
84 Q
85 ;
86UPDTLOG(IVMPTR,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
87 ; Update record to TRANSMITTED, and remove duplicates
88 ;
89 ; Update the IVM PATIENT (#301.5) record to a TRANSMITTED status.
90 I $$CLEAR^IVMPLOG(IVMPTR,WHEN)
91 ;
92 ; Add an entry in the IVM TRANSMISSION LOG (#301.6) File.
93 I $$LOG^IVMTLOG(IVMPTR,WHEN,MSGID,.EVENTS,MTSTAT,INSSTAT)
94 ;
95 D DUP(DFN,IVMYR,IVMPTR) ; remove duplicates
96 ;
97 Q
98 ;
99DUP(DFN,IVMYR,IVMPTR) ; remove duplicate entries in file 301.5
100 ;
101 ; Input - IVMPTR - IEN of original entry in file 301.5
102 ; DFN - IEN of PATIENT file
103 ; IVMYR - income year
104 ;
105 N DA,DIE,DIK,DR,IVMIEN,X,Y
106 ;
107 S IVMIEN=IVMPTR
108 F S IVMIEN=$O(^IVM(301.5,"APT",DFN,IVMYR,IVMIEN)) Q:'IVMIEN D
109 .;remove 301.5 entry
110 .I $$DELETE^IVMPLOG2(IVMIEN) F DA=0:0 S DA=$O(^IVM(301.6,"B",IVMIEN,DA)) Q:'DA D ; reset ptrs
111 ..S DIE="^IVM(301.6,",DR=".01///^S X=IVMPTR" D ^DIE
112 Q
Note: See TracBrowser for help on using the repository browser.