source: WorldVistAEHR/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMZ07C.m@ 824

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

revised back to 6/30/08 version

File size: 5.4 KB
Line 
1IVMZ07C ;BAJ - HL7 Z07 CONSISTENCY CHECKER -- DRIVER ROUTINE ; 9/27/2006
2 ;;2.0;INCOME VERIFICATION MATCH;**105**;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 ;
18EN(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 ;
57COUNT(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 ;
67LOADPT(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 DTTM=$O(^DGMS(29.11,"APDT",DFN,""))
103 . S NIEN=$O(^DGMS(29.11,"APDT",DFN,DTTM,""))
104 . I $D(^DGMS(29.11,NIEN,0)) S DGP("MST",0)=^DGMS(29.11,NIEN,0)
105 ;
106 ; ***************************
107 Q
108 ;
109WORK(DFN,DGP,DGSD) ;
110 ; call subroutines to run rules and file any inconsistencies
111 ;
112 ; Demographics rules
113 D EN^IVMZ7CD(DFN,.DGP,.DGSD)
114 ;
115 ; Enrollment/Eligibility rules
116 D EN^IVMZ7CE(DFN,.DGP)
117 ;
118 ; Service rules
119 D EN^IVMZ7CS(DFN,.DGP)
120 ;
121 ; Catastrophic Disability rules
122 D EN^IVMZ7CCD(DFN)
123 ;
124 ; Registration Inconsistencies
125 D EN^IVMZ7CR(DFN,.DGP,.DGSD)
126 ;
127 Q
128 ;
129DELETE(DFN) ; delete all Z07 inconsistencies from INCONSISTENT DATA file (#38.5). Since we're not sure which rules
130 ; will block a Z07 record, we need to loop through the INCONSISTENT DATA ELEMENTS file (#38.6) and grab only
131 ; those rules which are marked to prevent building a Z07 record:
132 ;
133 ;
134 N DELARRY,RULE,DIK,DA
135 ;
136 ; create an array of rules which prevent Z07 records
137 S RULE=0 F S RULE=$O(^DGIN(38.6,RULE)) Q:RULE="" Q:$A(RULE)>$A(9) D
138 . I '$P(^DGIN(38.6,RULE,0),U,5),$P(^DGIN(38.6,RULE,0),U,6) S DELARRY(RULE)=""
139 ;
140 ; Now we have to check the patient INCONSISTENT DATA file (#38.5) and delete any records which have to be rechecked.
141 ;
142 S DIK="^DGIN(38.5,"_DFN_","_"""I"""_","
143 ;
144 S DA="" F S DA=$O(DELARRY(DA)) Q:DA="" D ^DIK
145 Q
146 ;
147FILE(DFN) ;
148 N FILE,SUCCESS,CCS,I,DGENDA,DATA,SUBFILE,DIK,DA
149 S FILE=38.5,CCS=0
150 ; if no inconsistencies, return 0
151 I '$D(^TMP($J,DFN)) D Q CCS
152 . ; clean up INCONSISTENT DATA file if no inconsistencies exist
153 . I '$P($G(^DGIN(38.5,DFN,"I",0)),"^",4) D
154 . . S DIK="^DGIN(38.5,",DA=DFN
155 . . D ^DIK
156 ;
157 ; else process inconsistencies and return PASS=0
158 S CCS=1
159 ; if a new entry, create a stub
160 S DATA(.01)=DFN
161 I '$D(^DGIN(FILE,"B",DFN)) D
162 . S DATA(2)=$$DT^XLFDT,DATA(3)=.5
163 . S SUCCESS=$$ADD^DGENDBS(FILE,,.DATA,,DFN)
164 ;
165 ; update file header with data and user info.
166 ; Last Updated field (#4) = Today's date
167 ; Last Updated by field (#5) = Postmaster
168 S DGENDA=DFN,DATA(4)=$$DT^XLFDT,DATA(5)=.5
169 S SUCCESS=$$UPD^DGENDBS(FILE,.DGENDA,.DATA)
170 ;
171 ; add inconsistencies to file
172 K DATA
173 S SUBFILE=38.51,DGENDA(1)=DFN
174 S I="" F S I=$O(^TMP($J,DFN,I)) Q:I="" D
175 . S (DATA(.01),DATA(.001),DGENDA)=I
176 . S SUCCESS=$$ADD^DGENDBS(SUBFILE,.DGENDA,.DATA)
177 ;
178 ; kill temp file before exit
179 K ^TMP($J,DFN)
180 ;
181 Q CCS
182 ;
Note: See TracBrowser for help on using the repository browser.