source: WorldVistAEHR/trunk/r/INCOME_VERIFICATION_MATCH-IVM/IVMLDEM6.m@ 1154

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

initial load of WorldVistAEHR

File size: 9.1 KB
Line 
1IVMLDEM6 ;ALB/KCL/BRM/PHH/CKN - IVM DEMOGRAPHIC UPLOAD FILE ADDRESS ; 7/12/07 5:31pm
2 ;;2.0;INCOME VERIFICATION MATCH;**10,58,73,79,108,106,105,124**; 21-OCT-94;Build 1
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ;
6ADDR(DFN,IVMDA2,IVMDA1,IVMDA,IVMPPICK) ; - function to check if uploadable field
7 ; is an address field and return a flag
8 ;
9 ; Input: DFN - as patient IEN
10 ; IVMDA2 - pointer to case record in (#301.5) file
11 ; IVMDA1 - pointer to PID msg in (#301.501) sub-file
12 ; IVMDA - pointer to record in (#301.511) sub-file
13 ; IVMPPICK - residence phone number and/or another address
14 ; field selected
15 ; 0 - phone or an address field not selected
16 ; 1 - address field(s) selected
17 ; 2 - phone selected
18 ; 3 - both address field(s) and phone selected
19 ;
20 ; Output: IVMFLAG - 1 if address field
21 ; 0 if not an address field
22 ;
23 ;
24 N IVMFLAG,IVMI,IVMJ,IVMNODE,IVMPTR,Y
25 ;
26 ; - initialize flags
27 S IVMFLAG=0
28 ;
29 ; - check for required parameters
30 I '$G(DFN)!('$G(IVMDA))!('$G(IVMDA1))!'($G(IVMDA2)) G ADDRQ
31 ;
32 ; - get pointer to (#301.92) file from (#301.511) sub-file
33 S IVMPTR=+$G(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM",IVMDA,0)) G ADDRQ:'IVMPTR
34 ;
35ASK I '$D(^IVM(301.92,"AD",+IVMPTR)) G ADDRQ
36 I IVMPPICK=2 G ASK1
37 W ! S DIR("A")="Do you wish to proceed with this action"
38 S DIR("A",1)="You have selected to update an address field."
39 S DIR("A",2)="You will be required to upload the entire address."
40 S DIR("?")="Enter 'YES' to continue or 'NO' to abort."
41 S DIR(0)="Y",DIR("B")="NO"
42 D ^DIR K DIR
43 S IVMFLAG=1 G ADDRQ:'Y
44 W ! S DIR("A")="Are you sure that you want to update the complete address"
45 S:$$PHARM(+$G(DFN)) DIR("A",1)="*** WARNING: This patient has ACTIVE PRESCRIPTIONS on file."
46 S DIR("A",2)=""
47 I $$ADRDTCK^IVMLDEM9(+$G(DFN),IVMDA2,IVMDA1) S DIR("A",2)="*** WARNING: The address that you are attempting to file is OLDER than",DIR("A",3)=" the address on file.",DIR("A",4)=""
48 S DIR("?",1)="Enter 'YES' to update the complete address that was received from"
49 S DIR("?")="HEC. Enter 'NO' to quit."
50 S DIR(0)="Y",DIR("B")="NO"
51 D ^DIR K DIR
52 S IVMFLAG=1 G ADDRQ:'Y
53 W !,"Filing address fields... "
54 ;
55 ; determine correct address change date/time to use
56 D ADDRDT(DFN,IVMDA2,IVMDA1)
57 ;
58LOOP ;
59 N DGPRIOR D GETPRIOR^DGADDUTL(DFN,.DGPRIOR)
60 ;
61 ; - loop thru fields in ^IVM(301.92,"AD" x-ref
62 S IVMI=0 F S IVMI=$O(^IVM(301.92,"AD",IVMI)) Q:IVMI']"" D
63 .S IVMJ=0 F S IVMJ=$O(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM","B",IVMI,IVMJ)) Q:IVMJ']"" D
64 ..;
65 ..; - check for data node in (#301.511) sub-file
66 ..S IVMNODE=$G(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM",IVMJ,0)) Q:IVMNODE']""
67 ..Q:'(+IVMNODE)!($P(IVMNODE,"^",2)']"")
68 ..;
69 ..; - check if residence phone number and not selected to upload
70 ..Q:(IVMPPICK=1&(+IVMNODE=$O(^IVM(301.92,"B","PHONE NUMBER [RESIDENCE]",0))))
71 ..; - check if not residence phone number and only phone selected to upload
72 ..Q:(IVMPPICK=2&(+IVMNODE'=$O(^IVM(301.92,"B","PHONE NUMBER [RESIDENCE]",0))))
73 ..;
74 ..; - perform any necessary address field manipulation and
75 ..; load addr field rec'd from IVM into DHCP (#2) file
76 ..D UPLOAD(+DFN,$P($G(^IVM(301.92,+IVMNODE,0)),"^",5),$P(IVMNODE,"^",2)) S IVMFLAG=1
77 ..;
78 ..; - remove entry from (#301.511) sub-file
79 ..D DELENT^IVMLDEMU(IVMDA2,IVMDA1,IVMJ)
80 ;
81 I IVMFLAG W "completed.",! D
82 .N DGCURR
83 .D GETUPDTS^DGADDUTL(DFN,.DGCURR)
84 .D UPDADDLG^DGADDUTL(DFN,.DGPRIOR,.DGCURR)
85 ;
86 ; - if addr is uploaded and phone # is not - ask user delete phone
87 I IVMFLAG,$P($G(^DPT(+DFN,.13)),"^")]"",(2>IVMPPICK) D PHONE
88 S VALMBCK="R"
89 ;
90 ;
91ADDRQ ; - return --> 1 if uploadable field is an address field
92 ; --> 0 if uploadable field is not an address field
93 ;
94 I IVMFLAG D RESET^IVMLDEMU
95 Q IVMFLAG
96 ;
97 ;
98UPLOAD(DFN,IVMFIELD,IVMVALUE) ; - file address fields received from IVM
99 ;
100 ; Input: DFN - as patient IEN
101 ; IVMFIELD - as the field number to be updated
102 ; IVMVALUE - as the value of the field
103 ;
104 ; Output: None
105 ;
106 ;
107 ; - update specified address field in the Patient (#2) file
108 S DIE="^DPT(",DA=DFN,DR=IVMFIELD_"////^S X=IVMVALUE"
109 D ^DIE K DA,DIE,DR
110 ;
111 ; - delete inaccurate Addr Change Site data if Source is not VAMC
112 ; (trigger x-ref does not fire with 4 slash stuff)
113 I IVMFIELD=.119,IVMVALUE'="VAMC" S FDA(2,+DFN_",",.12)="@" D UPDATE^DIE("E","FDA")
114 ;
115 ; - delete the Bad Address Indicator field
116 I $$BADADR^DGUTL3(DFN) D DELBAI^DGUTL3(DFN)
117 Q
118 ;
119 ;
120PHONE ; - ask user to delete phone # [Residence] from Patient (#2) file
121 D FULL^VALM1
122 W ! S DIR("A")="Is it okay to delete the patient's Phone Number [Residence]"
123 W ! S DIR("A",1)="The patient's address has been updated and the phone number"
124 S DIR("A",2)="remains on file."
125 S DIR("A",3)=" "
126 S DIR("A",4)="Patient Name: "_$P($$PT^IVMUFNC4(+DFN),"^")_" ("_$P($$PT^IVMUFNC4(+DFN),"^",3)_")"
127 S DIR("A",5)="Phone Number [Residence]: "_$P($G(^DPT(+DFN,.13)),"^")
128 S DIR("A",6)=" "
129 S DIR("?",1)="Enter 'YES' to delete the patient's Phone Number [Residence] that is"
130 S DIR("?",2)="currently on file. Enter 'NO' to quit without deleting the patient's"
131 S DIR("?")="Phone Number [Residence]."
132 S DIR(0)="Y",DIR("B")="NO"
133 D ^DIR K DIR
134 S:Y $P(^DPT(DFN,.13),"^")="" W !!,"Patient's Phone Number [Residence] has ",$S(Y:"",1:"not "),"been deleted."
135 Q
136 ;
137ASK1 ; - phone selected to be uploaded - address fields not selected
138 W ! S DIR("A")="Okay to update the PHONE NUMBER [RESIDENCE] field"
139 S DIR("?",1)="Enter 'YES' to update the patient's Phone Number [Residence] that was"
140 S DIR("?",2)="received from HEC. Enter 'NO' to quit."
141 S DIR(0)="Y",DIR("B")="YES"
142 D ^DIR K DIR
143 S IVMFLAG=1 G ADDRQ:'Y
144 W !,"Updating PHONE NUMBER [RESIDENCE] field... "
145 G LOOP
146 ;
147AUTOADDR(DFN,IVMPPICK,NOUPDT) ;
148 ; this functionality is copied from above and modified to allow
149 ; an automated upload of patient address information as stipulated
150 ; in the business requirements for Address Indexing to support GMT
151 ;
152 ; Input: DFN - as patient IEN
153 ; IVMPPICK - residence phone number and/or another address
154 ; field selected
155 ; 1 - address field(s) selected
156 ; 3 - both address field(s) and phone selected
157 ; NOUPDT - (optional) this flag is set when the incoming
158 ; address data is older than the existing
159 ; address in the Patient (#2) file
160 ;
161 ; Output: IVMFLAG - 1 if address fields updated
162 ; 0 if address fields not updated
163 ;
164 ;
165 ;
166 N IVMFLAG,IVMI,IVMJ,IVMNODE,IVMPTR,Y,DELFLG
167 ;
168 ; - initialize flags
169 S IVMFLAG=0,DELFLG=1
170 S:'$G(NOUPDT) NOUPDT=0
171 ;
172 ; - check for required parameters
173 Q:'$G(DFN) IVMFLAG
174 ;
175 N DGPRIOR D GETPRIOR^DGADDUTL(DFN,.DGPRIOR)
176 ; Set the flag to don't auto-update if there is an active
177 ; Prescription record and the Bad Address Indicator is null
178 I ('NOUPDT),$$PHARM(+DFN),'$$BADADR^DGUTL3(+DFN) S DELFLG=0
179 I ('NOUPDT),DELFLG D EN^DGCLEAR(DFN) ;Deleting existing address before update
180 ;
181 S IVMDA2=$G(IVM3015)
182 Q:'$G(IVMDA2) IVMFLAG
183 S IVMDA1=$O(^HL(771.3,"B","PID",""))
184 S IVMDA1=$O(^IVM(301.5,IVMDA2,"IN","B",IVMDA1,""),-1)
185 Q:'IVMDA1 IVMFLAG
186 ;
187 S IVMI=0 F S IVMI=$O(^IVM(301.92,"AD",IVMI)) Q:IVMI']"" D
188 .S IVMJ=0 F S IVMJ=$O(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM","B",IVMI,IVMJ)) Q:IVMJ']"" D
189 ..;
190 ..; - check for data node in (#301.511) sub-file
191 ..S IVMNODE=$G(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM",IVMJ,0))
192 ..I ('+IVMNODE)!($P(IVMNODE,"^",2)']"") Q
193 ..;
194 ..; - check if residence phone number -> do not auto-upload
195 ..I (IVMPPICK=1&(+IVMNODE=$O(^IVM(301.92,"B","PHONE NUMBER [RESIDENCE]",0)))) D DEMBULL^IVMPREC6 Q
196 ..;
197 ..; don't auto-update if there is an active Prescription record and
198 ..; the Bad Address Indicator is null
199 ..I 'DELFLG D DEMBULL^IVMPREC6 Q
200 ..;
201 ..; - load addr field rec'd from IVM into DHCP (#2) file
202 ..I 'NOUPDT D UPLOAD(+DFN,$P($G(^IVM(301.92,+IVMNODE,0)),"^",5),$P(IVMNODE,"^",2)) S IVMFLAG=1
203 ..;
204 ..; - remove entry from (#301.511) sub-file
205 ..D DELENT^IVMLDEMU(IVMDA2,IVMDA1,IVMJ)
206 ..; - if no display or uploadable fields left, then delete the PID
207 ..; segment
208 ..I '$$DEMO^IVMLDEM5(IVMDA2,IVMDA1,0),'$$DEMO^IVMLDEM5(IVMDA2,IVMDA1,1) D
209 ...D DELETE^IVMLDEM5(IVMDA2,IVMDA1," ") ; Dummy up name parameter
210 I IVMFLAG D
211 .N DGCURR
212 .D GETUPDTS^DGADDUTL(DFN,.DGCURR)
213 .D UPDADDLG^DGADDUTL(DFN,.DGPRIOR,.DGCURR)
214 Q IVMFLAG
215 ;
216ADDRDT(DFN,IVMDA2,IVMDA1) ;
217 ; - validate Address Change Dt/Tm before filing
218 ; if incoming address is accepted and the change date is older
219 ; than what's on file, then use today's date for Addr Chg Dt/Tm
220 ;
221 Q:'$$ADRDTCK^IVMLDEM9(DFN,IVMDA2,IVMDA1)
222 N FDA,IEN92,IVMDA,IENS,ERR
223 S IEN92=$O(^IVM(301.92,"C","RF171","")) Q:'IEN92
224 Q:'$D(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM","B",IEN92))
225 S IVMDA=$O(^IVM(301.5,IVMDA2,"IN",IVMDA1,"DEM","B",IEN92,"")) Q:'IVMDA
226 S IENS=IVMDA_","_IVMDA1_","_IVMDA2_","
227 S FDA(301.511,IENS,.02)=$$NOW^XLFDT
228 D FILE^DIE("","FDA","ERR")
229 Q
230 ;
231PHARM(DFN) ;does this patient have active pharmacy prescriptions?
232 ;
233 ;External reference to $$EN^PSSRXACT supported by IA #4237
234 ;
235 Q $S('$G(DFN):0,1:$$EN^PSSRXACT(DFN))
Note: See TracBrowser for help on using the repository browser.