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

DGV53PTA.m

Go to the documentation of this file.
DGV53PTA ;ALB/REW - ALASKA COUNTY UPDATES ;11 JUN 93
 ;;5.3;Registration;**1015**;Aug 13, 1993;Build 21
 ;
EN ;
 ; This will update the ALASKA County codes.  The EN tag may be re-run
 N DGPRINT
 S DGPRINT=$S($D(ZTQUEUED):0,1:1)
 W:DGPRINT !!,">>> Updating STATE File (#5) Alaska County data ..."
 I '$$UPSTATE(2) W:$G(DGPRINT) !,"Problem with Alaska County Update.  Please Review File."
 E  W:$G(DGPRINT) !!,"...STATE File update completed."
 Q
UPSTATE(DGST) ;UPDATE COUNTY MULTIPLE OF STATE FILE
 ; DGST    = TAG FOR STATE (also state code)
 ; DGOK    = 1: COUNTIES UPDATED 0 = NO  [RETURNED]
 ; DGNUMST = NUMBER OF OCCURENCES OF STATE NAME^IFN OF STATE
 ; DGSTNM  = STATE NAME
 ; DGSTNODE=STATECODE^STATENAME
 ;
 N DGOK,DGSTNODE,DGSTIFN,DGNUMST,DGSTNM
 S (DGSTIFN,DGOK)=0
 S DGSTNODE=$P($T(@DGST),";;",2)
 S DGNUMST=$$NUMSTATE(DGST,DGSTNODE,.DGSTIFN)
 I 'DGNUMST!('$D(^DIC(5,DGSTIFN,0))) W:$G(DGPRINT) !,$P(DGSTNODE,U,2)," COUNTY UPDATE ABORTED - NO ENTRY FOR STATE FOUND!" G QTUPC
 I +DGNUMST>1 W:$G(DGPRINT) !,$P(DGSTNODE,U,2)," COUNTY UPDATE ABORTED - DUPLICATE STATES FOUND!" G QTUPC
 S DGOK=1
 D STCOUNTY(DGST,DGSTIFN,.DGOK)
 W:('DGOK)&($G(DGPRINT)) !,"PROBLEMS FOUND DURING UPDATE OF COUNTIES FOR ",$P(DGSTNODE,U,2)
QTUPC Q DGOK
STCOUNTY(DGST,DGSTIFN,DGOK) ;UPDATES THE COUNTIES FOR A STATE
 ;REQUIRED: DGSTIFN,DGPRIN  T - ALREADY DEFINED
 ;REQUIRED: DGST,DGSTIFN,DGOK - PASSED IN
 Q:'$D(DGSTIFN)!('$D(DGPRINT))!('$D(DGST))!('$D(DGSTIFN))!('$D(DGOK))
 ;
 N DGCTLINE,DGCTNODE
 F DGCTLINE=1:1 S DGCTNODE=$P($T(@DGST+DGCTLINE),";;",2) Q:DGCTNODE']""  D UPCOUNTY(DGCTNODE,DGSTIFN,.DGOK)
 Q
UPCOUNTY(DGCTNODE,DGSTIFN,DGOK) ;UPDATES A COUNTY
 N B4NAME,B4CODE,NOWNAME,NOWCODE,DGCOUNTY,DGCTIFN
 S B4NAME=$P(DGCTNODE,U,1)
 S B4CODE=$P(DGCTNODE,U,2)
 S NOWNAME=$P(DGCTNODE,U,3)
 S NOWCODE=$P(DGCTNODE,U,4)
 ;Check for existing counties of same before-name
 W:$G(DGPRINT) !
 S DGCTIFN=0 F  S DGCTIFN=$O(^DIC(5,DGSTIFN,1,"B",B4NAME,DGCTIFN)) Q:'DGCTIFN  D
 .S DGCOUNTY(DGCTIFN)=""
 .W:$G(DGPRINT) !,"FOUND MATCH ON NAME.  IEN= ",DGCTIFN," FOR ",B4NAME,"-",B4CODE
 .D CHGCOUNT(DGCTIFN,.DGOK)
 ;Check for existing counties of same before-code
 S DGCTIFN=0 F  S DGCTIFN=$O(^DIC(5,DGSTIFN,1,"C",B4CODE,DGCTIFN)) Q:'DGCTIFN  D
 .Q:$D(DGCOUNTY(DGCTIFN))  ;don't re-do update done based on name
 .S DGCOUNTY(DGCTIFN)=""
 .W:$G(DGPRINT) !,"FOUND MATCH ON CODE.  IEN= ",DGCTIFN," FOR ",B4NAME,"-",B4CODE
 .D CHGCOUNT(DGCTIFN,.DGOK)
 ;If no existing entires by name or county add a new one
 I '$D(DGCOUNTY) D
 .W:$G(DGPRINT) !,"FOUND NO ",B4NAME,"-",B4CODE," (OLD COUNTY NAME-CODE)"
 .D NEWCOUNT
 Q
NEWCOUNT ;ADDS A NEW COUNTY ENTRY
 I ('$L($G(NOWCODE)))!('$L($G(NOWNAME))) W:$G(DGPRINT) !,"MISSING INPUT" G QTNC
 ;Q
 N DIC,DIE,DA,DR,X,Y,DGCTIFN
 S DA(1)=DGSTIFN
 S:'$D(^DIC(5,DGSTIFN,1,0)) ^(0)="^5.01I^^"
 S DIC(0)="L",DIC="^DIC(5,"_DA(1)_",1,"
 S X=NOWNAME
 D ^DIC
 S DA=+Y
 I DA'>0 D  G QTNC
 .S DGCTIFN=0
 .W:$G(DGPRINT) !,"No county added"
 .F  S DGCTIFN=$O(^DIC(5,DGSTIFN,1,"B",NOWNAME,DGCTIFN)) Q:'DGCTIFN  D
 ..W:$G(DGPRINT) !,"....IEN= ",DGCTIFN," NAME= ",NOWNAME," CODE= ",NOWCODE," ALREADY EXISTS."
 I Y W !,"...NEW COUNTY ",NOWNAME,"-",NOWCODE,$S((+$P(Y,U,3)):" ADDED",1:" ALREADY EXISTS")
 S DR="2///^S X=NOWCODE"
 S DIE=DIC
 D ^DIE
QTNC Q
CHGCOUNT(DGCTIFN,DGOK) ;
 N DA,DIC,DIE,DGOLDNM,DGOLDCD,DR,X
 ;Q
 S DA=DGCTIFN,DA(1)=DGSTIFN,DIE="^DIC(5,"_DA(1)_",1,"
 S DGOLDNM=$P($G(^DIC(5,+DA(1),1,+DGCTIFN,0)),U,1)
 S DGOLDCD=$P($G(^DIC(5,+DA(1),1,+DGCTIFN,0)),U,3)
 W !,"...CHANGING COUNTY ",DGOLDNM,"-",DGOLDCD," TO ",NOWNAME,"-",NOWCODE
 S DR=".01///^S X=NOWNAME;2///^S X=NOWCODE"
 D ^DIE
 Q
NUMSTATE(DGST,DGSTNODE,DGSTIFN) ;RETURN DGCNT
 ; DGCNT   = NUMBER OF OCCURENCES OF STATE NAME OR -1 IF ERROR
 ; DGSTIFN = IFN OF STATE IN FILE 5 - INPUT=0 OUT=STATE IEN
 ; DGSTNM  = NAME OF STATE
 N DGCNT,X
 S DGCNT=0
 S X=""
 I '$L($G(DGST)) S DGCNT=-1 G QTNMST
 S:'$L($G(DGSTNODE)) DGSTNODE=$P($T(@DGST),";;",2)
 S DGSTNM=$P(DGSTNODE,U,2)
 I '$L(DGSTNM) S DGCNT=-1 G QTNMST
 F  S DGSTIFN=$O(^DIC(5,"B",DGSTNM,DGSTIFN)) Q:'DGSTIFN  S DGCNT=DGCNT+1,X=DGSTIFN
 S DGSTIFN=X
QTNMST Q DGCNT
 ;Counties Format:B4NAME^B4CODE^NOWNAME^NOWCODE
2 ;;02^ALASKA
 ;;SKAGWAY-YAKUTAT-ANGOON^231^SKAGWAY-HOONAH-ANGOON^232
 ;;ALEUTIAN WEST^010^ALEUTIANS WEST^016
 ;;DENALI BOROUGH^068^DENALI BOROUGH^068
 ;;YAKUTAT^282^YAKUTAT^282
 ;;