DGREGCP2 ;ALB/CLT - ADDRESS UTILITIES ;23 May 2017 1:33 PM
;;5.3;Registration;**941**;Aug 13, 1993;Build 73
;
POBOXRES(DGADDL1,STATE,CNTRY) ;TEST FOR UNALLOWED PO BOX AND GENERAL DELIVERY FOR RESIDENTIAL ADDRESS
; DGADDL1 - The address [LINE 1] text
; STATE - Internal State Code
; CNTRY - Internal Country Code
; returns 1 if PO box/general delivery not allowed for this address
; called from DGREGRED for validation of residential address on screen 1.1
N DGCCHK
; If country/state are allowed to have PO box, quit 0
I $$OKPO(STATE,CNTRY) Q 0
S DGCCHK=0
; Get result from checking for PO/General Delivery
I $$ISPO(DGADDL1) S DGCCHK=1
Q DGCCHK
;
POBOXPM(DFN) ;Check for PO Box/General Delivery in Permanent Mailing Address
; Returns 1 if Perm address contains PO Box or General delivery (allowing for exceptions)
I '$D(^DPT(DFN,.11)) Q 0
N DGRESADD,DGADDL1
S DGRESADD=^DPT(DFN,.11)
; allow certain exceptions for countries/states that allow PO Box
I $$OKPO($P(DGRESADD,U,5),$P(DGRESADD,U,10)) Q 0
; get address line 1
S DGADDL1=$P(DGRESADD,U,1)
; return result from checking for PO/General Delivery
Q $$ISPO(DGADDL1)
;
OKPO(STATE,CNTRY) ;PO BOX CHECK FOR CERTAIN COUNTRIES AND STATES
; Returns 1 if the country/state allows for PO box/general delivery
; Pass in the state and country codes to check
;PO Box and general delivery allowed for: Veteran's Residential address is Alaska(2) or Hawaii (15)
;Veteran resides in one of the United States territories (Guam (state 66), American Samoa (state 60), CNMI (Mariana Islands state 69),
; U.S. Virgin Islands (state 78), and Philippines (country code 167))
; Philippines check
I CNTRY=167 Q 1
N DGSTATES
S DGSTATES="^AS^AK^HI^GU^VI^MP^PH^"
S STATE="^"_$$GET1^DIQ(5,STATE,1)_"^"
; If country=USA, check for allowed states/territories
I CNTRY=1 I DGSTATES[STATE Q 1
Q 0
ISPO(DGADDL1) ; check address line for presence of PO Box or General Delivery
; Returns 1 if the address line DGADDL1 contains PO/General Delivery
N DGCCHK
S DGCCHK=0
; strip out leading spaces
F QUIT:$E(DGADDL1,1)'=" " S DGADDL1=$E(DGADDL1,2,$L(DGADDL1))
; translate to UPPERCASE and strip out any '.' chars (eg as in P.O. Box)
S DGADDL1=$TR(DGADDL1,"abcdefghijklmnopqrstuvwxyz.","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
I $E(DGADDL1,1,3)="PO "!($E(DGADDL1,1,11)="POST OFFICE")!(DGADDL1["GENERAL DELIVERY")!(DGADDL1?1"BOX "1N.ANP)!($E(DGADDL1,1,4)="P O ") S DGCCHK=1
Q DGCCHK
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGREGCP2 2489 printed Dec 13, 2024@02:54:56 Page 2
DGREGCP2 ;ALB/CLT - ADDRESS UTILITIES ;23 May 2017 1:33 PM
+1 ;;5.3;Registration;**941**;Aug 13, 1993;Build 73
+2 ;
POBOXRES(DGADDL1,STATE,CNTRY) ;TEST FOR UNALLOWED PO BOX AND GENERAL DELIVERY FOR RESIDENTIAL ADDRESS
+1 ; DGADDL1 - The address [LINE 1] text
+2 ; STATE - Internal State Code
+3 ; CNTRY - Internal Country Code
+4 ; returns 1 if PO box/general delivery not allowed for this address
+5 ; called from DGREGRED for validation of residential address on screen 1.1
+6 NEW DGCCHK
+7 ; If country/state are allowed to have PO box, quit 0
+8 IF $$OKPO(STATE,CNTRY)
QUIT 0
+9 SET DGCCHK=0
+10 ; Get result from checking for PO/General Delivery
+11 IF $$ISPO(DGADDL1)
SET DGCCHK=1
+12 QUIT DGCCHK
+13 ;
POBOXPM(DFN) ;Check for PO Box/General Delivery in Permanent Mailing Address
+1 ; Returns 1 if Perm address contains PO Box or General delivery (allowing for exceptions)
+2 IF '$DATA(^DPT(DFN,.11))
QUIT 0
+3 NEW DGRESADD,DGADDL1
+4 SET DGRESADD=^DPT(DFN,.11)
+5 ; allow certain exceptions for countries/states that allow PO Box
+6 IF $$OKPO($PIECE(DGRESADD,U,5),$PIECE(DGRESADD,U,10))
QUIT 0
+7 ; get address line 1
+8 SET DGADDL1=$PIECE(DGRESADD,U,1)
+9 ; return result from checking for PO/General Delivery
+10 QUIT $$ISPO(DGADDL1)
+11 ;
OKPO(STATE,CNTRY) ;PO BOX CHECK FOR CERTAIN COUNTRIES AND STATES
+1 ; Returns 1 if the country/state allows for PO box/general delivery
+2 ; Pass in the state and country codes to check
+3 ;PO Box and general delivery allowed for: Veteran's Residential address is Alaska(2) or Hawaii (15)
+4 ;Veteran resides in one of the United States territories (Guam (state 66), American Samoa (state 60), CNMI (Mariana Islands state 69),
+5 ; U.S. Virgin Islands (state 78), and Philippines (country code 167))
+6 ; Philippines check
+7 IF CNTRY=167
QUIT 1
+8 NEW DGSTATES
+9 SET DGSTATES="^AS^AK^HI^GU^VI^MP^PH^"
+10 SET STATE="^"_$$GET1^DIQ(5,STATE,1)_"^"
+11 ; If country=USA, check for allowed states/territories
+12 IF CNTRY=1
IF DGSTATES[STATE
QUIT 1
+13 QUIT 0
ISPO(DGADDL1) ; check address line for presence of PO Box or General Delivery
+1 ; Returns 1 if the address line DGADDL1 contains PO/General Delivery
+2 NEW DGCCHK
+3 SET DGCCHK=0
+4 ; strip out leading spaces
+5 FOR
if $EXTRACT(DGADDL1,1)'=" "
QUIT
SET DGADDL1=$EXTRACT(DGADDL1,2,$LENGTH(DGADDL1))
+6 ; translate to UPPERCASE and strip out any '.' chars (eg as in P.O. Box)
+7 SET DGADDL1=$TRANSLATE(DGADDL1,"abcdefghijklmnopqrstuvwxyz.","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+8 IF $EXTRACT(DGADDL1,1,3)="PO "!($EXTRACT(DGADDL1,1,11)="POST OFFICE")!(DGADDL1["GENERAL DELIVERY")!(DGADDL1?1"BOX "1N.ANP)!($EXTRACT(DGADDL1,1,4)="P O ")
SET DGCCHK=1
+9 QUIT DGCCHK