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

XIPUTIL1.m

Go to the documentation of this file.
  1. XIPUTIL1 ;OIFO/SO- CONTINUATION OF ROUTINE XIPUTIL;2:15 PM 10 Jul 2003
  1. ;;8.0;KERNEL;**292**;Jul 10, 1995
  1. ; Continuation of API POSTALB
  1. Q
  1. ;
  1. PBC ; POSTALB's Continuation Entry Point
  1. ;
  1. ; INPUT
  1. ; PCODE - Postal Code for which to return the data
  1. ;
  1. ; OUTPUT
  1. ; XIP(n) - the number of primary subscripts
  1. ; XIP(n,"POSTAL CODE") - the value used to lookup postal data
  1. ; XIP(n,"CITY") - the city that the USPS assigned to this PCODE
  1. ; XIP(n,"COUNTY") - The county associated with this PCODE
  1. ; XIP(n,"COUNTY POINTER") - pointer to the county in file #5.13
  1. ; XIP(n,"STATE") - The state associated with this PCODE
  1. ; XIP(n,"STATE POINTER") - pointer to the state in file #5
  1. ; XIP(n"CITY KEY") - USPS's assigned city key
  1. ; XIP(n,"PREFERRED CITY KEY") - USPS's Preferred (DEFAULT) city key
  1. ; XIP(n,"CITY ABBREVIATION") - USPS's assigned abbreviation
  1. ; XIP(n,"UNIQUE KEY") - a unique look-up value
  1. ; XIP(n,"FIPS CODE") - 5 digit FIPS code associated with the county
  1. ; XIP("ERROR") - returns errors encountered during look-up
  1. ;
  1. N D512,XIPERR
  1. S XIP=0
  1. D
  1. . N DIERR,FIELDS,S512
  1. . S FIELDS="@;.01"
  1. . S S512="I $P(^(0),U,5)=""""" ; Screen out INACTIVE Zip Codes
  1. . D LIST^DIC(5.12,"",FIELDS,"P","","",LPCODE,"B",S512,"","D512","XIPERR")
  1. . Q
  1. I $D(XIPERR) S XIP("ERROR")=XIPERR("DIERR",1,"TEXT",1) Q
  1. I +D512("DILIST",0)=0 S XIP("ERROR")="Postal Code cannot be found" Q
  1. N I,I1
  1. S I=0
  1. F I1=0:1 S I=$O(D512("DILIST",I)) Q:'I D
  1. . N X
  1. . S XIP512=+$P(D512("DILIST",I,0),"^")
  1. . S X=^XIP(5.12,XIP512,0)
  1. . S XIP(I,"POSTAL CODE")=LPCODE
  1. . S XIP(I,"CITY")=$P(X,"^",2)
  1. . I $P(X,"^",6)=$P(X,"^",7) S XIP(I,"CITY")=XIP(I,"CITY")_"*" ; Indicate this is the DEFAULT city
  1. . S XIP(I,"COUNTY POINTER")=$P(X,"^",3)
  1. . S XIP(I,"STATE POINTER")=$P(X,"^",4)
  1. . S XIP(I,"CITY KEY")=$P(X,"^",6)
  1. . S XIP(I,"PREFERRED CITY KEY")=$P(X,"^",7)
  1. . S XIP(I,"CITY ABBREVIATION")=$P(X,"^",8)
  1. . S XIP(I,"UNIQUE KEY")=$P(X,"^",9)
  1. . S XIP(I,"STATE")=$P($G(^DIC(5,+XIP(I,"STATE POINTER"),0)),"^")
  1. . S XIP(I,"COUNTY")=$P($G(^XIP(5.13,+XIP(I,"COUNTY POINTER"),0)),"^",2)
  1. . S XIP(I,"FIPS CODE")=$P($G(^XIP(5.13,+XIP(I,"COUNTY POINTER"),0)),"^")
  1. S XIP=I1
  1. Q