Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGREGCP2

DGREGCP2.m

Go to the documentation of this file.
  1. DGREGCP2 ;ALB/CLT - ADDRESS UTILITIES ;23 May 2017 1:33 PM
  1. ;;5.3;Registration;**941**;Aug 13, 1993;Build 73
  1. ;
  1. POBOXRES(DGADDL1,STATE,CNTRY) ;TEST FOR UNALLOWED PO BOX AND GENERAL DELIVERY FOR RESIDENTIAL ADDRESS
  1. ; DGADDL1 - The address [LINE 1] text
  1. ; STATE - Internal State Code
  1. ; CNTRY - Internal Country Code
  1. ; returns 1 if PO box/general delivery not allowed for this address
  1. ; called from DGREGRED for validation of residential address on screen 1.1
  1. N DGCCHK
  1. ; If country/state are allowed to have PO box, quit 0
  1. I $$OKPO(STATE,CNTRY) Q 0
  1. S DGCCHK=0
  1. ; Get result from checking for PO/General Delivery
  1. I $$ISPO(DGADDL1) S DGCCHK=1
  1. Q DGCCHK
  1. ;
  1. 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)
  1. I '$D(^DPT(DFN,.11)) Q 0
  1. N DGRESADD,DGADDL1
  1. S DGRESADD=^DPT(DFN,.11)
  1. ; allow certain exceptions for countries/states that allow PO Box
  1. I $$OKPO($P(DGRESADD,U,5),$P(DGRESADD,U,10)) Q 0
  1. ; get address line 1
  1. S DGADDL1=$P(DGRESADD,U,1)
  1. ; return result from checking for PO/General Delivery
  1. Q $$ISPO(DGADDL1)
  1. ;
  1. OKPO(STATE,CNTRY) ;PO BOX CHECK FOR CERTAIN COUNTRIES AND STATES
  1. ; Returns 1 if the country/state allows for PO box/general delivery
  1. ; Pass in the state and country codes to check
  1. ;PO Box and general delivery allowed for: Veteran's Residential address is Alaska(2) or Hawaii (15)
  1. ;Veteran resides in one of the United States territories (Guam (state 66), American Samoa (state 60), CNMI (Mariana Islands state 69),
  1. ; U.S. Virgin Islands (state 78), and Philippines (country code 167))
  1. ; Philippines check
  1. I CNTRY=167 Q 1
  1. N DGSTATES
  1. S DGSTATES="^AS^AK^HI^GU^VI^MP^PH^"
  1. S STATE="^"_$$GET1^DIQ(5,STATE,1)_"^"
  1. ; If country=USA, check for allowed states/territories
  1. I CNTRY=1 I DGSTATES[STATE Q 1
  1. Q 0
  1. 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
  1. N DGCCHK
  1. S DGCCHK=0
  1. ; strip out leading spaces
  1. F QUIT:$E(DGADDL1,1)'=" " S DGADDL1=$E(DGADDL1,2,$L(DGADDL1))
  1. ; translate to UPPERCASE and strip out any '.' chars (eg as in P.O. Box)
  1. S DGADDL1=$TR(DGADDL1,"abcdefghijklmnopqrstuvwxyz.","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  1. 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
  1. Q DGCCHK