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

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

initial load of FOIAVistA 6/30/08 version

File size: 6.6 KB
Line 
1DGREGAZL ;ALB/DW - ZIP LINKING UTILITY ; 5/27/04 10:54am
2 ;;5.3;Registration;**522,560,581,730,760**;Aug 13, 1993;Build 11
3 ;
4EN(RESULT,DFN) ;Let user edit zip+4, city, state, county based on zip-linking
5 ; Output: RESULT(field#) = User Input External ^ Internal
6 K RESULT
7 N DGIND,DGTOT
8 I $G(DFN)="" S RESULT=-1 Q
9 N DGR,DGDFLT,DGALW,DGZIP,DGN
10 S DGN=""
11 I $$FOREIGN() D Q
12 . D FRGNEDT(.DGR,DFN)
13 . I $G(DGR)=-1 S RESULT=-1 Q
14 . F DGN=.1112,.114,.115,.117 S RESULT(DGN)=$G(DGR(DGN))
15 S DGZIP=$$ZIP(DFN)
16 I DGZIP=-1 S RESULT=-1 Q
17 S RESULT(.1112)=DGZIP
18 S DGIND=$$CITY(.DGR,DGZIP,DFN)
19 I DGIND=$G(DGTOT)+1 S DGIND=""
20 I $G(DGR)=-1 S RESULT=-1 Q
21 S RESULT(.114)=$G(DGR)
22 S DGALW=$$ALWEDT^DGREGDD1($G(DUZ),DGZIP)
23 I DGALW=1 D
24 . K DGR D STCNTY(.DGR,DGZIP,DFN,DGIND)
25 . I $G(DGR)=-1 S RESULT=-1 Q
26 . S RESULT(.115)=$G(DGR(.115))
27 . S RESULT(.117)=$G(DGR(.117))
28 I DGALW=0 D
29 . I DGZIP'="" D LINK(.DGDFLT,DGZIP,1)
30 . S RESULT(.115)=$G(DGDFLT(.115))
31 . S RESULT(.117)=$G(DGDFLT(.117))
32 Q
33ZIP(DFN) ;Let user input zip+4
34ZAGN N DIR,DTOUT,DUOUT,DIROUT,DGDATA
35 S DIR(0)="2,.1112"
36 S DA=DFN
37 D ^DIR
38 I $D(DTOUT) Q -1
39 I $D(DUOUT)!$D(DIROUT) D UPCT^DGREGAED G ZAGN
40 S DGZIP=$G(Y)
41 ;allow bogus zip:
42 I $D(^XUSEC("EAS GMT COUNTY EDIT",+DUZ)) Q DGZIP
43 I DGZIP="" Q DGZIP
44 D POSTALB^XIPUTIL(DGZIP,.DGDATA)
45 ;DG*730 - later commented out by DG*760
46 ;I $G(DGDATA(1,"CITY ABBREVIATION"))'="",$G(DGDATA(1,"CITY ABBREVIATION"))=$G(DGDATA(2,"CITY")) S DGDATA=1 K DGDATA(2)
47 I $D(DGDATA("ERROR")) D G ZAGN
48 . W $C(7)," ??"
49 Q DGZIP
50CITY(RESULT,ZIP,DFN) ;Base on zip, let user input city(#.114)
51 ; Input:
52 ; ZIP - user input zip for the patient primary address
53 ; DFN - Interal entry number of Patient File (#2)
54 ; Output:RESULT=-1 (input error or timed or ^ out)
55 ; or =user input city
56 ; Array index # of selected city.
57 K RESULT
58 N DGDATA,DIR,DA,Y,DTOUT,DUOUT,DIROUT,DGIND
59 N DGCITY,DGST,DGCNTY,DGABRV,DGN,DGECH,DGSOC
60 N DOLDCITY,DGSAME,DGELEVEN
61 ; DG*760 brought in DGCITI
62 N DGCITI
63 S DGIND=""
64 D POSTALB^XIPUTIL(ZIP,.DGDATA)
65 ;DG*730 - later commented out by DG*760
66 ;I $G(DGDATA(1,"CITY ABBREVIATION"))'="",$G(DGDATA(1,"CITY ABBREVIATION"))=$G(DGDATA(2,"CITY")) S DGDATA=1 K DGDATA(2)
67 D FIELD^DID(2,.114,"N","LABEL","DGCITY")
68 S DGN=""
69 I '$D(DGDATA("ERROR")) D
70 . S DOLDCITY=$$GET1^DIQ(2,DFN_",",.114)
71 . S DGSAME=0
72 . F S DGN=$O(DGDATA(DGN)) Q:DGN="" D
73 .. S DGCITI=$P($G(DGDATA(DGN,"CITY")),"*",1)
74 .. S DGABRV=$G(DGDATA(DGN,"CITY ABBREVIATION"))
75 .. I DOLDCITY'="",DGCITI=DOLDCITY!(DGABRV=DOLDCITY) S DGSAME=1
76 .. ; next 4 commented out lines done by DG*760
77 .. ;I DGABRV="" S DGABRV=$P($G(DGDATA(DGN,"CITY")),"*",1)
78 .. ;I DOLDCITY'="",DGABRV=DOLDCITY S DGSAME=1
79 .. ;I $G(DGDATA(DGN,"CITY"))["*" S:DGABRV'="" DGABRV=DGABRV_"*"
80 .. I $G(DGDATA(DGN,"CITY"))["*" S DGCITI=DGCITI_"*"
81 .. ;S DGECH=DGN_":"_DGABRV
82 .. S DGECH=DGN_":"_DGCITI
83 .. S DGSOC=$S($G(DGSOC)="":DGECH,1:DGSOC_";"_DGECH)
84 .. S DGTOT=DGN
85 .I 'DGSAME S DGELEVEN=$G(^DPT(DFN,.11)) D
86 ..Q:$P(DGELEVEN,U,6)'=$G(DGDATA(DGTOT,"POSTAL CODE"))
87 ..Q:$P(DGELEVEN,U,14)'="VAMC"
88 ..Q:$P(DGELEVEN,U,15)'=$$GETSITE^DGMTU4($G(DUZ))
89 ..Q:$P(DGELEVEN,U,17)'>.5
90 ..S DGN=DGTOT+1,DGECH=DGN_":"_DOLDCITY,DGSOC=DGSOC_";"_DGECH
91 .;
92 . I $D(^XUSEC("EAS GMT COUNTY EDIT",+DUZ)) D
93 .. S DGSOC=$G(DGSOC)_";"_99_":"_"FREE TEXT"
94 . S DIR(0)="SO^"_$G(DGSOC)
95 . ;if zip '= zip on file, default = ""; else default=city on file
96 . ;I ($G(DFN)'="")&($E(ZIP,1,5)=$$GET1^DIQ(2,DFN_",",.116)) D
97 . S DIR("B")=$$GET1^DIQ(2,DFN_",",.114)
98 . S DIR("A")=$G(DGCITY("LABEL"))
99CAGN1 . D ^DIR
100 . I $D(DTOUT) S RESULT=-1 Q
101 . I $D(DUOUT)!$D(DIROUT) D UPCT^DGREGAED G CAGN1
102 . S RESULT=$P($G(Y(0)),"*")
103 . S DGIND=$G(Y)
104 I ($G(Y)=99)!($D(DGDATA("ERROR"))) D
105CAGN2 . I '$D(^XUSEC("EAS GMT COUNTY EDIT",+DUZ)) Q
106 . N DIR,X,Y
107 . S DIR(0)="2,.114"
108 . S DA=DFN
109 . D ^DIR
110 . I $D(DTOUT) S RESULT=-1 Q
111 . I $D(DUOUT)!$D(DIROUT) D UPCT^DGREGAED G CAGN2
112 . S RESULT=$G(Y)
113 I $L($G(RESULT))>15 D
114 . S DGN=Y
115 . S RESULT=$G(DGDATA(DGN,"CITY ABBREVIATION"))
116 Q DGIND
117 ;
118LINK(RESULT,ZIP,DGN) ;From zip, get the linked state,county
119 K RESULT
120 N DGDATA,CNTYIEN
121 S CNTYIEN=""
122 S DGN=$G(DGN)
123 I (DGN="")&($$MLT^DGREGDD1(ZIP)) S DGN=1
124 I (DGN=99)&($$MLT^DGREGDD1(ZIP)) S DGN=1
125 I (DGN="")!(DGN=99) Q
126 D POSTALB^XIPUTIL(ZIP,.DGDATA)
127 S:$G(DGDATA(DGN,"STATE POINTER"))'="" CNTYIEN=$$FIND1^DIC(5.01,","_$G(DGDATA(DGN,"STATE POINTER"))_",","MOXQ",$E($G(DGDATA(DGN,"FIPS CODE")),3,5),"C")
128 D:'CNTYIEN ;could be duplicate county codes in subfile #5.01
129 .Q:'$D(^DIC(5,+$G(DGDATA(DGN,"STATE POINTER")),1))
130 .Q:$E($G(DGDATA(DGN,"FIPS CODE")),3,5)=""
131 .S CNTYIEN=$O(^DIC(5,$G(DGDATA(DGN,"STATE POINTER")),1,"C",$E($G(DGDATA(DGN,"FIPS CODE")),3,5),""))
132 S RESULT(.115)=$G(DGDATA(DGN,"STATE"))_U_$G(DGDATA(DGN,"STATE POINTER"))
133 S RESULT(.117)=$G(DGDATA(DGN,"COUNTY"))_U_$G(CNTYIEN)_U_$E($G(DGDATA(DGN,"FIPS CODE")),3,5)
134 Q
135 ;
136STCNTY(RESULT,ZIP,DFN,DGNUM) ;Based on zip,input state (#.115) and county (#.117)
137 K RESULT
138 S DGNUM=$G(DGNUM)
139 N DGN,DGDFLT,DGST,POP,DIR,X,Y,DTOUT,DUOUT,DIROUT
140 S POP=0
141 D LINK(.DGDFLT,ZIP,DGNUM)
142 F DGN=.115,.117 Q:POP D
143SCAGN . I DGN=.115 S DIR(0)=2_","_DGN
144 . I ($G(DGST)="")&(DGN=.117) Q
145 . I DGN=.117 S DIR(0)="POA^DIC(5,DGST,1,:AEMQ"
146 . S DIR("B")=$P($G(DGDFLT(DGN)),U)
147 . D ^DIR
148 . I $D(DTOUT) S POP=1 Q
149 . I $D(DUOUT)!$D(DIROUT) D UPCT^DGREGAED G SCAGN
150 . S RESULT(DGN)=$P($G(Y),U,2)_U_$P($G(Y),U)
151 . I DGN=.115 S DGST=$P($G(Y),U)
152 . I DGN=.117 S RESULT(.117)=$$CNTY(DGST,$P($G(RESULT(.117)),U,2))
153 I POP=1 S RESULT=-1
154 Q
155CNTY(DGST,DGCIEN) ;Return county name and code
156 ;Input:state number and county IEN
157 ;Output: CountyName^CountyIEN^CountyCode
158 I ($G(DGST)="")!($G(DGCIEN)="") S RESULT=-1 Q RESULT
159 N DGR,RESULT
160 S DGR=$G(^DIC(5,DGST,1,DGCIEN,0))
161 S RESULT=$P($G(DGR),U)_U_DGCIEN_U_$P($G(DGR),U,3)
162 Q RESULT
163FOREIGN() ;Manila (Philippines) doesn't need zip linking.
164 ;Output: 1 - area need no zip linking
165 ; 0 - zip-linking area
166 I $$STA^XUAF4(+$$KSP^XUPARAM("INST"))=358 Q 1
167 ;;;I $$STA^XUAF4(+$$KSP^XUPARAM("INST"))=500 Q 1 ;;HERE TEST
168 Q 0
169FRGNEDT(DGINPUT,DFN) ;Edit zip+4, city, state, county for no zip-linking area
170 K DGINPUT
171 N DGN,DIR,DTOUT,DUOUT,DIROUT,X,Y,POP,DGST
172 S POP=0
173 F DGN=.1112,.114,.115,.117 Q:POP D
174FAGN . I ($G(DGST)="")&(DGN=.117) Q
175 . S DIR(0)=2_","_DGN
176 . I DGN=.117 D
177 .. S DIR(0)="POA^DIC(5,DGST,1,:AEMQ"
178 .. S DIR("B")=$$GET1^DIQ(2,DFN_",",.117)
179 . I DGN'=.117 S DA=DFN
180 . D ^DIR
181 . I $D(DTOUT) S POP=1 Q
182 . I $D(DUOUT)!$D(DIROUT) D UPCT^DGREGAED G FAGN
183 . I (DGN=.114)!(DGN=.1112) S DGINPUT(DGN)=$G(Y)
184 . I (DGN=.115) D
185 .. S DGST=$P($G(Y),U)
186 .. I DGST=$$GET1^DIQ(2,DFN_",",.115,"I") D
187 ... S DGINPUT(.115)=$$GET1^DIQ(2,DFN_",",.115)_U_DGST
188 .. I DGST'=$$GET1^DIQ(2,DFN_",",.115,"I") D
189 ... S DGINPUT(.115)=$P($G(Y(0)),U)_U_DGST
190 . I DGN=.117 S DGINPUT(DGN)=$P($G(Y),U,2)_U_$P($G(Y),U)
191 I POP=1 S RESULT=-1
192 Q
Note: See TracBrowser for help on using the repository browser.