source: FOIAVistA/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGSSNRP2.m@ 1586

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

initial load of FOIAVistA 6/30/08 version

File size: 9.5 KB
Line 
1DGSSNRP2 ;ALB/SEK/PHH - DUPLICATE SPOUSE/DEPENDENT Report - Continued; 04/07/2004
2 ;;5.3;Registration;**313,535,568**;Aug 13,1993
3 ;
4MAIN ;
5 N X S X=$$DT^XLFDT
6 S ^XTMP("DG-SSNRP2",0)=X+1_U_X_"^DG DUPLICATE SSN REPORT "
7 D GETDATA
8 I $D(ZTQUEUED) D
9 .N ZTRTN,ZTDESC,ZTSK,ZTIO
10 .S ZTRTN="PRINT^DGSSNRP2",ZTDESC="Duplicate Spouse/Dependent SSN Report",ZTIO="`"_DEV
11 .S:$D(HFS) IO("HFSIO")=HFS
12 .S:$D(PAR) IOPAR=PAR
13 .D ^%ZTLOAD
14 .S ZTREQ="@"
15 E S IOP="`"_IOS D ^%ZIS,PRINT,HOME^%ZIS
16 Q
17PRINT ;
18 N STATS,CRT,QUIT,PAGE,PART1D,PART2D,PART1ST,SECTION,DGVETNM,DGVETSSN,VA,VADM,VAERR
19 K DEV,HFS,PAR
20 S (QUIT,PAGE)=0,CRT=$S($E(IOST,1,2)="C-":1,1:0)
21 U IO
22 I CRT,PAGE=0 W @IOF
23 S (PAGE,PART1D,PART2D)=1,SECTION="PART1"
24 D CHECKP1,HEADER
25 I PART1D D PPART1
26 I QUIT K ^XTMP("DG-SSNRP2") Q
27 S SECTION="PART2"
28 S:'$D(^XTMP("DG-SSNRP2","DGPART2")) PART2D=0
29 D HEADER
30 I PART2D D PPART2
31 I CRT,'QUIT D PAUSE
32 I $D(ZTQUEUED) S ZTREQ="@"
33 D ^%ZISC
34 K ^XTMP("DG-SSNRP2"),^TMP("DGSSNAR",$J)
35 Q
36LINE(LINE) ; Prints header if end of page.
37 I CRT,($Y>(IOSL-4)) D Q:QUIT
38 .D PAUSE
39 .Q:QUIT
40 .W @IOF
41 .D HEADER Q:QUIT
42 .W:SECTION="PART1" !
43 .W LINE
44 ;
45 E I ('CRT),($Y>(IOSL-2)) D
46 .W @IOF
47 .D HEADER
48 .W !,LINE
49 ;
50 E W !,LINE
51 Q
52 ;
53GETDATA ;Setup global with vets included in the report
54 D GETPART1
55 D GETPART2
56 Q
57 ;
58GETPART1 ;1st part of report
59 ;S ^XTMP("DG-SSNRP2","DGPART1",DGVETSSN)=DGVETNM
60 ;S ^XTMP("DG-SSNRP2","DGPART1",DGVETSSN,DGCTR1)=DGDEPNM^DGDEPSSN^DGDEPREL
61 N DFN,DG40812,DGDEP,DGDEPIEN,DGIEN,DGSSNCTR,VARR
62 K ^TMP("DGSSNAR",$J) S VARR=1
63 S DFN=0 F S DFN=$O(^DGPR(408.12,"B",DFN)) Q:'DFN D
64 .S (DGIEN,DGSSNCTR)=0
65 .F S DGIEN=$O(^DGPR(408.12,"B",DFN,DGIEN)) D Q:'DGIEN
66 ..Q:'DGIEN
67 ..S DG40812=$G(^DGPR(408.12,DGIEN,0)) Q:'DG40812
68 ..I DG40812["DPT" D Q
69 ...;if can't get veteran's SSN kill array and get next veteran
70 ...D DEM^VADPT
71 ...I '$P(VADM(2),"^") K ^TMP("DGSSNAR",$J,DFN) S DGIEN="" Q
72 ...; Check if patient has a Date of Death
73 ...I '$$OKRPT(DFN,.VADM) Q
74 ...; Check if patient was IN/OUT patient in last 3 years
75 ...I $$OKIMP(DFN)
76 ...;^TMP("DGSSNAR",$J) for vet (subscript "V") = name^SSN (no P)^SSN (with P)
77 ...S ^TMP("DGSSNAR",$J,DFN,"V")=VADM(1)_"^"_$TR(VADM(2),"-P","")_"^"_$P(VADM(2),"^")
78 ..;^TMP("DGSSNAR",$J) for dependents = SSN or Not Available^name^relationship code
79 ..I DG40812["DGPR" D Q
80 ...S DGDEPIEN=$P($P(DG40812,"^",3),";") Q:'DGDEPIEN
81 ...S DGDEP=$G(^DGPR(408.13,DGDEPIEN,0)) Q:DGDEP']""
82 ...S DGSSNCTR=DGSSNCTR+1
83 ...S ^TMP("DGSSNAR",$J,DFN,"D",DGSSNCTR)=$S($P(DGDEP,"^",9):$P(DGDEP,"^",9),1:"Not Available")_"^"_$P(DGDEP,"^")_"^"_$P(DG40812,"^",2)
84 .D:$D(^TMP("DGSSNAR",$J,DFN)) VBLDARR(DFN)
85 ;
86 D SDAM,SETTMPA
87 Q
88 ;
89SETTMPA ;check if spouse/dep SSN is the same as the vet's SSN or if not available (missing)
90 N DGDEPSSN,DGSCTR,DGTMPN1,DGVETSNP,AFLG,APPCK,APPTYP
91 S DFN=0 F S DFN=$O(^TMP("DGSSNAR",$J,DFN)) Q:'DFN D
92 .; Only want appts kept in the last 3 years
93 .I '$$OK2RPT(DFN) K ^TMP("DGSSNAR",$J,DFN),^TMP($J,"SDAMA",DFN) Q
94 .S DGSSNCTR=+($O(^TMP("DGSSNAR",$J,DFN,"D",""),-1))
95 .I ('DGSSNCTR)!('$D(^TMP("DGSSNAR",$J,DFN,"V"))) K ^TMP("DGSSNAR",$J,DFN) Q
96 .S DGVETSNP=$P(^TMP("DGSSNAR",$J,DFN,"V"),"^",2)
97 .S DGTMPN1=0
98 .F DGSCTR=1:1:DGSSNCTR D
99 ..S DGDEPSSN=$P(^TMP("DGSSNAR",$J,DFN,"D",DGSCTR),"^")
100 ..Q:((DGDEPSSN'=DGVETSNP)&(DGDEPSSN))
101 ..I 'DGTMPN1 S ^XTMP("DG-SSNRP2","DGPART1",("A"_$P(^TMP("DGSSNAR",$J,DFN,"V"),"^",3)))=$P(^TMP("DGSSNAR",$J,DFN,"V"),"^"),DGTMPN1=1
102 ..S ^XTMP("DG-SSNRP2","DGPART1",("A"_$P(^TMP("DGSSNAR",$J,DFN,"V"),"^",3)),DGSCTR)=$P(^TMP("DGSSNAR",$J,DFN,"D",DGSCTR),"^",2)_"^"_DGDEPSSN_"^"_$P(^TMP("DGSSNAR",$J,DFN,"D",DGSCTR),"^",3)
103 Q
104 ;
105GETPART2 ;2nd part of report
106 ;S ^XTMP("DG-SSNRP2","DGPART2",DGDEPSSN,DGCTR2)=DGDEPNM^DGDEPEL^DGVETSSN
107 N DGSSN,DGSSND,DGSSNDA,DGSSN1,DGSSNCTR
108 K ^TMP("DGSSNAR",$J)
109 S DGSSN=0 F S DGSSN=$O(^DGPR(408.13,"SSN",DGSSN)) D Q:'DGSSN
110 .Q:'DGSSN
111 .S DGSSN1="A"_DGSSN
112 .S (DGSSNDA,DGSSNCTR)=0
113 .F S DGSSNDA=$O(^DGPR(408.13,"SSN",DGSSN,DGSSNDA)) D Q:'DGSSNDA
114 ..Q:'DGSSNDA
115 ..S DGSSND=$G(^DGPR(408.13,DGSSNDA,0)) Q:DGSSND']""
116 ..;^TMP("DGSSNAR",$J) array = IEN of INCOME PERSON file (#408.13)^dependent name
117 ..S DGSSNCTR=DGSSNCTR+1
118 ..S ^TMP("DGSSNAR",$J,DGSSN1,DGSSNCTR)=DGSSNDA_"^"_$P(DGSSND,"^")
119 ;
120 D SELPRT2,SDAM,SETTMP
121 Q
122 ;
123SETTMP ; Spouse/dependent with the same SSN
124 N DGSSNCTR,DGDEPNM,DGDEPREL,DGPAT,DGPATRL,DGSCTR,DGSSNDA1,DGVETSN2
125 S DGSSN="" F S DGSSN=$O(^TMP("DGSSNAR",$J,DGSSN)) Q:DGSSN="" D
126 .S DGSSNCTR=+($O(^TMP("DGSSNAR",$J,DGSSN,""),-1))
127 .F DGSCTR=1:1:DGSSNCTR D
128 ..S DGSSNDA1=$P(^TMP("DGSSNAR",$J,DGSSN,DGSCTR),"^")
129 ..S DGDEPNM=$P(^TMP("DGSSNAR",$J,DGSSN,DGSCTR),"^",2)
130 ..S DGPAT=$O(^DGPR(408.12,"C",DGSSNDA1_";DGPR(408.13,",0))
131 ..S DGPATRL=$G(^DGPR(408.12,+DGPAT,0))
132 ..;missing "C" x-ref or 0 node of 408.12 record
133 ..I 'DGPATRL S DGDEPREL="U",DGVETSN2="UNKNOWN"
134 ..E D I +DGVETSN2 Q:'$$OK2RPT(DFN)
135 ...S DFN=+DGPATRL
136 ...D DEM^VADPT
137 ...S DGVETSN2=$P($G(VADM(2)),"^")
138 ...S DGDEPREL=$P(DGPATRL,"^",2)
139 ..S ^XTMP("DG-SSNRP2","DGPART2",DGSSN,DGSCTR)=DGDEPNM_"^"_DGDEPREL_"^"_DGVETSN2
140 Q
141 ;
142CHECKP1 ;if there is no part1 data S PART1D=0
143 ;if data S PART1ST=1 indicating 1st time thru header
144 I '$D(^XTMP("DG-SSNRP2","DGPART1")) S PART1D=0 Q
145 S PART1ST=1
146 Q
147 ;
148HEADER ;Description: Prints the report header.
149 Q:QUIT
150 N LINE
151 I $Y>1 W @IOF
152 W !,?21,"Duplicate Spouse/Dependent SSN Report"
153 W ?70,"Page ",PAGE,!,?26,"Date Generated: "_$$FMTE^XLFDT(DT)
154 S PAGE=PAGE+1
155 ;
156 W !,$S(SECTION="PART1":" Spouse/Dependent with no SSN or the same SSN as Veteran",1:" Spouse/Dependent with the same SSN as another Spouse/Dependent")
157 I SECTION="PART1" D
158 .I 'PART1D,$D(^TMP($J,"SDAMA","ERR")) W !!,?10,"Appointment Database Unavailable to validate active veterans." Q
159 .I 'PART1D W !!,?25,"No entries meet this criteria" Q
160 .I 'PART1ST D PART1HD Q
161 .S PART1ST=0
162 I SECTION="PART2" D
163 .W !!
164 .I 'PART2D,$D(^TMP($J,"SDAMA","ERR")) W !!,?10,"Appointment Database Unavailable to validate active veterans." Q
165 .I 'PART2D W ?25,"No entries meet this criteria" Q
166 .W "Spouse/Dependent Name",?33,"Spouse/Dependent SSN",?55,"Relationship",?69,"Veteran SSN"
167 Q
168 ;
169PAUSE N DIR,DIRUT,X,Y
170 F Q:$Y>(IOSL-3) W !
171 S DIR(0)="E" D ^DIR
172 I ('(+Y))!$D(DIRUT) S QUIT=1
173 Q
174 ;
175PPART1 ;Description: Prints Part 1 - Spouse/Dependent with no SSN or the same SSN as Veteran
176 N DGPART1,DGSCTR,LINE S DGVETSSN=0
177 F S DGVETSSN=$O(^XTMP("DG-SSNRP2","DGPART1",DGVETSSN)) Q:DGVETSSN']"" D Q:QUIT
178 .S DGSCTR=0,DGVETNM=$G(^XTMP("DG-SSNRP2","DGPART1",DGVETSSN))
179 .Q:QUIT D PART1HEA Q:QUIT
180 .F S DGSCTR=$O(^XTMP("DG-SSNRP2","DGPART1",DGVETSSN,DGSCTR)) Q:'DGSCTR D Q:QUIT
181 ..S DGPART1=$G(^XTMP("DG-SSNRP2","DGPART1",DGVETSSN,DGSCTR))
182 ..Q:DGPART1']""
183 ..S LINE=$$LJ(" "_$P(DGPART1,"^"),25)_" "_$$LJ($P(DGPART1,"^",2),22)
184 ..S LINE=LINE_$$LJ($$RELCODE($P(DGPART1,"^",3)),12)
185 ..D LINE(LINE) Q:QUIT
186 ..Q:QUIT
187 .Q:QUIT
188 Q
189 ;
190PPART2 ;Description: Prints Part 2 -Spouse/Dependent with the same SSN as another Spouse/Dependent
191 N DGDEPSSN,DGPART2,DGP2F,DGSCTR,LINE
192 S DGP2F=1,DGDEPSSN=0
193 F S DGDEPSSN=$O(^XTMP("DG-SSNRP2","DGPART2",DGDEPSSN)) Q:DGDEPSSN']"" D Q:QUIT
194 .I 'DGP2F W !
195 .E S DGP2F=0
196 .S DGSCTR=0
197 .F S DGSCTR=$O(^XTMP("DG-SSNRP2","DGPART2",DGDEPSSN,DGSCTR)) Q:'DGSCTR D Q:QUIT
198 ..S DGPART2=$G(^XTMP("DG-SSNRP2","DGPART2",DGDEPSSN,DGSCTR))
199 ..Q:DGPART2']""
200 ..S LINE=$$LJ(" "_$P(DGPART2,"^"),29)_" "_$$LJ($E(DGDEPSSN,2,10),21)
201 ..S LINE=LINE_$$LJ($$RELCODE($P(DGPART2,"^",2)),13)
202 ..S LINE=LINE_$$LJ(" "_$P(DGPART2,"^",3),10)
203 ..D LINE(LINE) Q:QUIT
204 ..Q:QUIT
205 .Q:QUIT
206 Q
207 ;
208LJ(STRING,LENGTH) ;
209 Q $$LJ^XLFSTR($E(STRING,1,LENGTH),LENGTH)
210 ;
211RELCODE(DGCODE) ;returns relationship name from RELATIONSHIP file (#408.11)
212 ;
213 N DGNAME S DGNAME=$P($G(^DG(408.11,+DGCODE,0)),"^")
214 I DGNAME']"" Q "UNKNOWN"
215 Q DGNAME
216 ;
217PART1HEA ;heading for part1 (vet name & SSN and spouse/dep name & SSN)
218 I ('CRT),($Y>(IOSL-6)) D Q
219 .D HEADER
220 ;
221 E I CRT,($Y>(IOSL-8)) D Q:QUIT
222 .D PAUSE
223 .Q:QUIT
224 .D HEADER
225 ;
226 E D PART1HD
227 Q
228 ;
229PART1HD W !!,"Veteran: ",$$LJ(DGVETNM,30)," Veteran SSN: ",$$LJ($E(DGVETSSN,2,11),10),!!," Spouse/Dependent Name Spouse/Dependent SSN Relationship"
230 Q
231OKRPT(DFN,VADM) ; Date of Death?
232 N X,X1,X2
233 I '$D(VADM) D DEM^VADPT
234 I +VADM(6) Q 0
235 Q 1
236 ;
237OKIMP(DFN) ; Inpatient or Outpatient in the last 3 years?
238 N VAIP S VAIP("D")="LAST" D IN5^VADPT
239 I VAIP(3)'="" D Q '(X>1095)
240 .S X1=DT,X2=$P(VAIP(3),U)\1 D ^%DTC
241 .I X<1096 S ^TMP($J,"SDAMA",DFN,+VAIP(3))="^^I;INPATIENT"
242 Q 1
243 ;
244OK2RPT(DFN) ; Appt kept in the last 3 years?
245 N APPCK,AFLG S (APPCK,AFLG)=0
246 F S APPCK=$O(^TMP($J,"SDAMA",DFN,APPCK)) Q:'APPCK!(AFLG) D
247 .S APPTYP=$P($P(^TMP($J,"SDAMA",DFN,APPCK),U,3),";")
248 .I "^R^I^"[(U_APPTYP_U) S AFLG=1
249 Q AFLG
250 ;
251VBLDARR(DFN) ; Build array of specified veterans
252 S ^TMP($J,"SDAMAPI",VARR)=$G(^TMP($J,"SDAMAPI",VARR))_DFN_";"
253 I $L(^TMP($J,"SDAMAPI",VARR))>180 S VARR=VARR+1
254 Q
255 ;
256SDAM N DGARRAY,I,SDCNT
257 S DGARRAY(1)=$$FMADD^XLFDT(DT,-1095)_";"_DT,DGARRAY("FLDS")=3,DGARRAY("SORT")="P"
258 F I=1:1 Q:'$D(^TMP($J,"SDAMAPI",I)) D
259 .S DGARRAY(4)=^TMP($J,"SDAMAPI",I)
260 .S SDCNT=$$SDAPI^SDAMA301(.DGARRAY)
261 .I SDCNT'>0 K ^TMP($J,"SDAMA301"),^TMP($J,"SDAMAPI",I) Q
262 .M ^TMP($J,"SDAMA")=^TMP($J,"SDAMA301")
263 .K ^TMP($J,"SDAMA301"),^TMP($J,"SDAMAPI",I)
264 I '$D(^TMP($J,"SDAMA")) S ^TMP($J,"SDAMA","ERR")=""
265 Q
266 ;
267SELPRT2 ; Select records for Part 2
268 N DGSSN,DGCNT,DGSSNP,DGPTR,DGPTRL,VARR S VARR=1
269 S DGSSN="" F S DGSSN=$O(^TMP("DGSSNAR",$J,DGSSN)) Q:DGSSN="" D
270 .S DGCNT=$O(^TMP("DGSSNAR",$J,DGSSN,""),-1)
271 .I DGCNT<2 K ^TMP("DGSSNAR",$J,DGSSN) Q
272 .S DGSSNP=$P(^TMP("DGSSNAR",$J,DGSSN,DGCNT),U)
273 .S DGPTR=$O(^DGPR(408.12,"C",DGSSNP_";DGPR(408.13,",0))
274 .S DGPTRL=+$G(^DGPR(408.12,+DGPTR,0))
275 .I $$OKIMP(DGPTRL)
276 .Q:$D(^TMP($J,"SDAMA",DGPTRL))
277 .D VBLDARR(DGPTRL)
278 Q
Note: See TracBrowser for help on using the repository browser.