1 | IVMZ07C ;BAJ/PHH - HL7 Z07 CONSISTENCY CHECKER -- DRIVER ROUTINE ; 1/17/2008
|
---|
2 | ;;2.0;INCOME VERIFICATION MATCH;**105,128**;JUL 8,1996;Build 2
|
---|
3 | ;
|
---|
4 | ;
|
---|
5 | ; This routine calls various checking subroutines and manages arrays and data filing
|
---|
6 | ; for inconsistency checking prior to building a Z07 HL7 record. This routine returns
|
---|
7 | ; a value and must be called as an API:
|
---|
8 | ;
|
---|
9 | ; I '$$EN^IVMZ07C(DFN) Q
|
---|
10 | ;
|
---|
11 | ; Values returned:
|
---|
12 | ; 0 = Fail: inconsistencies found, do not build Z07 record
|
---|
13 | ; 1 = Pass: No inconsistencies found, Ok to build Z07 record
|
---|
14 | ;
|
---|
15 | ; Must be called from entry point
|
---|
16 | Q
|
---|
17 | ;
|
---|
18 | EN(DFN) ; entry point. Patient DFN is sent from calling routine.
|
---|
19 | ; initialize working variables
|
---|
20 | N PASS,DGP,DGSD,U
|
---|
21 | S U="^"
|
---|
22 | ;
|
---|
23 | ; Input: DFN = ^DPT(DFN) of record to check
|
---|
24 | ; BATCH = 1 batch/background job records should be counted
|
---|
25 | ; = 0 single job, do not count records
|
---|
26 | ; structure:
|
---|
27 | ; 1. delete existing Z07 inconsistencies
|
---|
28 | ; 2. load data arrays
|
---|
29 | ; 3. call subroutines
|
---|
30 | ; 4. check for Pass/Fail
|
---|
31 | ; 5. update file 38.5 if necessary
|
---|
32 | ; 6. return Pass/Fail
|
---|
33 | ;
|
---|
34 | ; Set flag
|
---|
35 | S PASS=0
|
---|
36 | I '$D(^DPT(DFN)) Q PASS
|
---|
37 | S PASS=1
|
---|
38 | ;
|
---|
39 | ; Load Patient and Spouse/dependent data
|
---|
40 | D LOADPT(DFN,.DGP),LOADSD^IVMZ072(DFN,.DGSD)
|
---|
41 | ;
|
---|
42 | ; Do checks and file inconsistencies
|
---|
43 | D WORK(DFN,.DGP,.DGSD)
|
---|
44 | ;
|
---|
45 | ; Delete old Inconsistency info
|
---|
46 | D DELETE(DFN)
|
---|
47 | ;
|
---|
48 | ; File new inconsistencies if necessary
|
---|
49 | I $$FILE(DFN) S PASS=0
|
---|
50 | ;
|
---|
51 | ; update counters
|
---|
52 | D COUNT(PASS)
|
---|
53 | ;
|
---|
54 | ; return pass/fail flag
|
---|
55 | Q PASS
|
---|
56 | ;
|
---|
57 | COUNT(PASS) ; counter for batch run
|
---|
58 | N I
|
---|
59 | ; Set it up the first time through
|
---|
60 | I '$D(^TMP($J,"CC")) D
|
---|
61 | . F I=0,1 S ^TMP($J,"CC",I)=0
|
---|
62 | ;
|
---|
63 | ; Increment Batch counter
|
---|
64 | S ^TMP($J,"CC",PASS)=^TMP($J,"CC",PASS)+1
|
---|
65 | Q
|
---|
66 | ;
|
---|
67 | LOADPT(DFN,DGP) ; load patient data into arrays
|
---|
68 | N NIEN,IEN,I,DTTM,NAMCOM,NAME
|
---|
69 | ; we need to load data from the following files
|
---|
70 | ; Patient File 2
|
---|
71 | ; Name Components 20
|
---|
72 | ; Patient Enrollment 27.11
|
---|
73 | ; Means test file 408.31
|
---|
74 | ; MST History file 29.11
|
---|
75 | ; Note: we also need Catastrophic data info, but that subroutine loads its own data array.
|
---|
76 | ;
|
---|
77 | ; ***************************
|
---|
78 | ; DGP("PAT") Patient file
|
---|
79 | F I=0,.3,.15,.29,.31,.32,.321,.322,.35,.36,.361,.38,.52,"SSN","TYPE","VET" S DGP("PAT",I)=$G(^DPT(DFN,I))
|
---|
80 | S NAME=$P($G(^DPT(DFN,0)),"^",1),NAMCOM=$P($G(^DPT(DFN,"NAME")),"^",1)'=""
|
---|
81 | ;
|
---|
82 | ; ***************************
|
---|
83 | ; DGP("NAME") Name Components
|
---|
84 | I NAMCOM S NIEN=$P(^DPT(DFN,"NAME"),U,1) I '$D(^VA(20,NIEN,1)) S NAMCOM=0
|
---|
85 | S DGP("NAME",1)=$S(NAMCOM:$G(^VA(20,NIEN,1)),1:$P(NAME,",")_"^"_$P($P(NAME,",",2)," ",1)_"^"_$P($P(NAME,",",2)," ",2))
|
---|
86 | ;
|
---|
87 | ; ***************************
|
---|
88 | ;
|
---|
89 | ; DGP("ENR") Patient Enrollment
|
---|
90 | S NIEN="",NIEN=$P($G(^DPT(DFN,"ENR")),U,1)
|
---|
91 | I NIEN]"",$D(^DGEN(27.11,NIEN)) M DGP("ENR")=^DGEN(27.11,NIEN)
|
---|
92 | ;
|
---|
93 | ; ***************************
|
---|
94 | ; DGP("MEANS") Means Test
|
---|
95 | S NIEN=+$$LST^DGMTU(DFN) I NIEN,$D(^DGMT(408.31,NIEN,0)) S DGP("MEANS",0)=^DGMT(408.31,NIEN,0)
|
---|
96 | ;
|
---|
97 | ; ***************************
|
---|
98 | ; DGP("MST") MST History
|
---|
99 | S (DTTM,NIEN)=""
|
---|
100 | S DTTM=$O(^DGMS(29.11,"APDT",DFN,""),-1)
|
---|
101 | I DTTM'="" D
|
---|
102 | . S NIEN=$O(^DGMS(29.11,"APDT",DFN,DTTM,""),-1)
|
---|
103 | . I $D(^DGMS(29.11,NIEN,0)) S DGP("MST",0)=^DGMS(29.11,NIEN,0)
|
---|
104 | ;
|
---|
105 | ; ***************************
|
---|
106 | Q
|
---|
107 | ;
|
---|
108 | WORK(DFN,DGP,DGSD) ;
|
---|
109 | ; call subroutines to run rules and file any inconsistencies
|
---|
110 | ;
|
---|
111 | ; Demographics rules
|
---|
112 | D EN^IVMZ7CD(DFN,.DGP,.DGSD)
|
---|
113 | ;
|
---|
114 | ; Enrollment/Eligibility rules
|
---|
115 | D EN^IVMZ7CE(DFN,.DGP)
|
---|
116 | ;
|
---|
117 | ; Service rules
|
---|
118 | D EN^IVMZ7CS(DFN,.DGP)
|
---|
119 | ;
|
---|
120 | ; Catastrophic Disability rules
|
---|
121 | D EN^IVMZ7CCD(DFN)
|
---|
122 | ;
|
---|
123 | ; Registration Inconsistencies
|
---|
124 | D EN^IVMZ7CR(DFN,.DGP,.DGSD)
|
---|
125 | ;
|
---|
126 | Q
|
---|
127 | ;
|
---|
128 | DELETE(DFN) ; delete all Z07 inconsistencies from INCONSISTENT DATA file (#38.5). Since we're not sure which rules
|
---|
129 | ; will block a Z07 record, we need to loop through the INCONSISTENT DATA ELEMENTS file (#38.6) and grab only
|
---|
130 | ; those rules which are marked to prevent building a Z07 record:
|
---|
131 | ;
|
---|
132 | ;
|
---|
133 | N DELARRY,RULE,DIK,DA
|
---|
134 | ;
|
---|
135 | ; create an array of rules which prevent Z07 records
|
---|
136 | S RULE=0 F S RULE=$O(^DGIN(38.6,RULE)) Q:RULE="" Q:$A(RULE)>$A(9) D
|
---|
137 | . I '$P(^DGIN(38.6,RULE,0),U,5),$P(^DGIN(38.6,RULE,0),U,6) S DELARRY(RULE)=""
|
---|
138 | ;
|
---|
139 | ; Now we have to check the patient INCONSISTENT DATA file (#38.5) and delete any records which have to be rechecked.
|
---|
140 | ;
|
---|
141 | S DIK="^DGIN(38.5,"_DFN_","_"""I"""_","
|
---|
142 | ;
|
---|
143 | S DA="" F S DA=$O(DELARRY(DA)) Q:DA="" D ^DIK
|
---|
144 | Q
|
---|
145 | ;
|
---|
146 | FILE(DFN) ;
|
---|
147 | N FILE,SUCCESS,CCS,I,DGENDA,DATA,SUBFILE,DIK,DA
|
---|
148 | S FILE=38.5,CCS=0
|
---|
149 | ; if no inconsistencies, return 0
|
---|
150 | I '$D(^TMP($J,DFN)) D Q CCS
|
---|
151 | . ; clean up INCONSISTENT DATA file if no inconsistencies exist
|
---|
152 | . I '$P($G(^DGIN(38.5,DFN,"I",0)),"^",4) D
|
---|
153 | . . S DIK="^DGIN(38.5,",DA=DFN
|
---|
154 | . . D ^DIK
|
---|
155 | ;
|
---|
156 | ; else process inconsistencies and return PASS=0
|
---|
157 | S CCS=1
|
---|
158 | ; if a new entry, create a stub
|
---|
159 | S DATA(.01)=DFN
|
---|
160 | I '$D(^DGIN(FILE,"B",DFN)) D
|
---|
161 | . S DATA(2)=$$DT^XLFDT,DATA(3)=.5
|
---|
162 | . S SUCCESS=$$ADD^DGENDBS(FILE,,.DATA,,DFN)
|
---|
163 | ;
|
---|
164 | ; update file header with data and user info.
|
---|
165 | ; Last Updated field (#4) = Today's date
|
---|
166 | ; Last Updated by field (#5) = Postmaster
|
---|
167 | S DGENDA=DFN,DATA(4)=$$DT^XLFDT,DATA(5)=.5
|
---|
168 | S SUCCESS=$$UPD^DGENDBS(FILE,.DGENDA,.DATA)
|
---|
169 | ;
|
---|
170 | ; add inconsistencies to file
|
---|
171 | K DATA
|
---|
172 | S SUBFILE=38.51,DGENDA(1)=DFN
|
---|
173 | S I="" F S I=$O(^TMP($J,DFN,I)) Q:I="" D
|
---|
174 | . S (DATA(.01),DATA(.001),DGENDA)=I
|
---|
175 | . S SUCCESS=$$ADD^DGENDBS(SUBFILE,.DGENDA,.DATA)
|
---|
176 | ;
|
---|
177 | ; kill temp file before exit
|
---|
178 | K ^TMP($J,DFN)
|
---|
179 | ;
|
---|
180 | Q CCS
|
---|
181 | ;
|
---|