source: FOIAVistA/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMTLOG.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 6.9 KB
Line 
1IVMTLOG ;ALB/CJM - API for IVM TRANSMISSION LOG file; 4-SEP-97
2 ;;2.0;INCOME VERIFICATION MATCH;**9**; 21-OCT-94
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5LOCK(IEN) ;
6 ;Description: Locks a record in the IVM TRANSMISSION LOG file.
7 ;Input:
8 ; IEN - ien of record in IVM TRANSMISSION LOG file.
9 ;Output:
10 ; Function Value - 1 if successful, 0 otherwise.
11 ;
12 I $G(IEN) L +^IVM(301.6,IEN):3
13 Q $T
14 ;
15UNLOCK(IEN) ;
16 ;Description: Unlocks a record in the IVM TRANSMISSION LOG file.
17 ;Input:
18 ; IEN - ien of record in the IVM TRANSMISSION LOG file.
19 ;Output: None
20 ;
21 I $G(IEN) L -^IVM(301.6,IEN)
22 Q
23 ;
24SETSTAT(IEN,STATUS,ERROR) ;
25 ;Description: Sets the value of the STATUS field of the
26 ; IVM TRANSMISSION LOG file for a particular record.
27 ;Input:
28 ; IEN - internal entry number of a record in IVM TRANSMISSION LOG file.
29 ; STATUS - status code - 1:RECEIVED, 0:TRANSMITTED, 2:RE-TRANSMITTED, 3:ERROR IN TRANSMITTED RECORD
30 ; ERROR - optional - text error message
31 ;Output:
32 ; Function Value - 1 on success, 0 on failure.
33 ;
34 Q:'$$TESTVAL^DGENDBS(301.6,.03,STATUS) 0
35 ;
36 N DATA,RET
37 Q:'$$LOCK($G(IEN)) 0
38 S DATA(.03)=STATUS
39 I $G(ERROR)'="" S DATA(.04)=$E(ERROR,1,80)
40 ;
41 ;DATE/TIME ACK RECEIVED should only be entered for appropriate status
42 I (STATUS=1)!(STATUS=3) D
43 .S DATA(.06)=$$NOW^XLFDT
44 E S DATA(.06)="@"
45 ;
46 ;ERROR PROCESSING STATUS should only be entered if error status
47 I (STATUS=3) D
48 .S DATA(.07)=1
49 E S DATA(.07)="@"
50 ;
51 S RET=$$UPD^DGENDBS(301.6,IEN,.DATA)
52 D UNLOCK(IEN)
53 Q RET
54 ;
55ERRSTAT(IEN,STATUS,ERROR) ;
56 ;Description: Sets the ERROR PROCESSING STATUS field of a record in the IVM TRANSMISSION LOG file.
57 ;
58 ;Input:
59 ; IEN - ien of record in IVM TRANSMISSION LOG file.
60 ; STATUS - error processing status code
61 ;Output:
62 ; Function Value - 1 if successful, 0 otherwise.
63 ; ERROR - error message (optional), pass by reference - will return message on failure
64 ;
65 N DATA,RET
66 ;
67 S ERROR=""
68 I '$$TESTVAL^DGENDBS(301.6,.07,STATUS) S ERROR="INVALID TRANSMISSION PROCESSING STATUS" Q 0
69 I '$G(IEN) S ERROR="NO RECORD SPECIFIED" Q 0
70 I $P(^IVM(301.6,IEN,0),"^",3)'=3 S ERROR="STATUS IS NOT 'ERROR IN TRANSMITTED RECORD'" Q 0
71 I '$$LOCK($G(IEN)) S ERROR="COULD NOT OBTAIN LOCK ON RECORD" Q 0
72 S DATA(.07)=STATUS
73 S RET=$$UPD^DGENDBS(301.6,IEN,.DATA,.ERROR)
74 D UNLOCK(IEN)
75 Q RET
76 ;
77GET(IEN,TLOG) ;
78 ;Description: Used to obtain a record in the IVM TRANSMISSION LOG file. The
79 ;values are returned in the TLOG() array.
80 ;Input:
81 ; IEN - internal entry number of a record in the IVM TRANSMISSION LOG file.
82 ;Output:
83 ; Function Value - 1 on success, 0 on failure.
84 ; TLOG() array, pass by reference. Subscripts are
85 ; "PAT" - value of the IVM PATIENT field (#.01) which is the ien of record in the IVM PATIENT file.
86 ; "DFN" - ien, PATIENT file
87 ; "DT/TM SENT" - value of the TRANSMISSION DATE/TIME field (#.02)
88 ; "STATUS" - value of the STATUS field (#.03)
89 ; "ERROR" - value of the ERROR MESSAGE field (#.04)
90 ; "MSGID" - value of the MESSAGE CONTROL ID field (#.05)
91 ; "EVENTS","IVM" - value of the IVM EVENT (#30.01) field
92 ; "EVENTS","DCD" - value of the DCD EVENT (#30.02) field
93 ; "EVENTS","ENROLL" - value of the ENROLLMENT EVENT (#30.03) field
94 ; "DT/TM ACK" - value of the DATE/TIME ACK RECEIVED (#.06) field
95 ; "ERROR STATUS" - value of the ERROR PROCESSING STATUS (#.07) field
96 ; "MT STATUS" - value of the MEANS TEST STATUS field (#1.01)
97 ; "INS STATUS" - value of the INSURANCE STATUS field (#1.02)
98 ;
99 N NODE
100 K TLOG S TLOG=""
101 Q:'$G(IEN) 0
102 S NODE=$G(^IVM(301.6,IEN,0))
103 Q:(NODE="") 0
104 S TLOG("PAT")=$P(NODE,"^")
105 S TLOG("DFN")=$S(TLOG("PAT"):$P(^IVM(301.5,TLOG("PAT"),0),"^"),1:"")
106 S TLOG("DT/TM SENT")=$P(NODE,"^",2)
107 S TLOG("STATUS")=$P(NODE,"^",3)
108 S TLOG("ERROR")=$P(NODE,"^",4)
109 S TLOG("MSGID")=$P(NODE,"^",5)
110 S TLOG("DT/TM ACK")=$P(NODE,"^",6)
111 S TLOG("ERROR STATUS")=$P(NODE,"^",7)
112 S NODE=$G(^IVM(301.6,IEN,"E"))
113 S TLOG("EVENTS","IVM")=$P(NODE,"^")
114 S TLOG("EVENTS","DCD")=$P(NODE,"^",2)
115 S TLOG("EVENTS","ENROLL")=$P(NODE,"^",3)
116 S NODE=$G(^IVM(301.6,IEN,1))
117 S TLOG("MT STATUS")=$P(NODE,"^")
118 S TLOG("INS STATUS")=$P(NODE,"^",2)
119 Q 1
120 ;
121LOG(PAT,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
122 ;Description: Called after completing a transmission for a particular
123 ;patient. It creates a new record in the IVM TRANSMISSION LOG file.
124 ;
125 ;Input:
126 ; PAT - ien of record in the IVM PATIENT file.
127 ; WHEN - date/time message sent, in FM format.
128 ; MSGID - message id used for message, in format used by MESSAGE CONTROL ID field.
129 ; EVENTS () - an array of reasons for transmission, pass by reference.
130 ; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
131 ; EVENTS("DCD")=1 if transmission due to DCD criteria, 0 otherwise
132 ; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
133 ; 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. (Optional)
134 ; INSSTAT - 1 if the patient had active insurance at the time of the transmission, 0 otherwise. (Optional)
135 ;
136 ;Output:
137 ; Function Value - If successful, returns the internal entry number of the record in the IVM TRANSMSISION LOG file, otherwise returns NULL.
138 ;
139 Q:'$$TESTVAL^DGENDBS(301.6,.01,PAT) ""
140 Q:'$$TESTVAL^DGENDBS(301.6,.02,WHEN) ""
141 ;
142 ;skip this test - msgid is created by HL7 pkg, they can change it, so do not want to pass it by IVM's input transform
143 ;Q:'$$TESTVAL^DGENDBS(301.6,.05,MSGID) ""
144 ;
145 I ($G(MTSTAT)'=""),'$$TESTVAL^DGENDBS(301.6,1.01,MTSTAT) Q ""
146 I ($G(INSSTAT)'=""),'$$TESTVAL^DGENDBS(301.6,1.02,INSSTAT) Q ""
147 ;
148 N DATA
149 S DATA(.01)=PAT,DATA(.02)=WHEN,DATA(.03)=0,DATA(.05)=MSGID
150 S:($G(MTSTAT)'="") DATA(1.01)=MTSTAT
151 S:($G(INSSTAT)'="") DATA(1.02)=INSSTAT
152 S:($G(EVENTS("IVM"))=1) DATA(30.01)=1
153 S:($G(EVENTS("DCD"))=1) DATA(30.02)=1
154 S:($G(EVENTS("ENROLL"))=1) DATA(30.03)=1
155 Q $$ADD^DGENDBS(301.6,,.DATA)
156 ;
157DELETE(IEN) ;
158 ;Description: Used to delete a record in the IVM TRANSMISSION LOG file.
159 ;
160 ;Input:
161 ; IEN - the internal entry number for a record in the IVM TRANSMISSION LOG file
162 ;Output:
163 ; Function Value - 1 on success, 0 on failure
164 ;
165 Q:'$G(IEN) 1
166 ;
167 Q:'$$LOCK(IEN) 0
168 ;
169 N DIK,DA
170 S DIK="^IVM(301.6,"
171 S DA=IEN
172 D ^DIK
173 D UNLOCK(IEN)
174 Q 1
175 ;
176EXT(SUB,VAL) ;
177 ;Description: Given the subscript used in the IVM TRANSMISSION LOG
178 ; array and a field value, returns the external representation of the
179 ; value, as defined in the fields output transform of the IVM
180 ; TRANSMISSION LOG file.
181 ;Input:
182 ; SUB - array subscript
183 ; VAL - field value
184 ;Output:
185 ; Function Value - returns the external value of the field
186 ;
187 Q:(($G(SUB)="")!($G(VAL)="")) ""
188 ;
189 N FLD
190 S FLD=$S(SUB="PAT":.01,SUB="DT/TM SENT":.02,SUB="STATUS":.03,SUB="ERROR":.04,SUB="MSGID":.05,SUB="DT/TM ACK":.06,SUB="ERROR STATUS":.07,SUB="IVM":30.01,SUB="DCD":30.02,SUB="ENROLL":30.03,SUB="MT STATUS":1.01,SUB="INS STATUS":1.02,1:"")
191 ;
192 Q:(FLD="") ""
193 Q $$EXTERNAL^DILFD(301.6,FLD,"F",VAL)
Note: See TracBrowser for help on using the repository browser.