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

ACRFPD06.m

Go to the documentation of this file.
ACRFPD06 ;IHS/OIRM/DSD/AEF - UPDATE ARMS PER DIEM CITY FILE [ 9/30/2005  10:01 AM ]
 ;;2.1;ADMIN RESOURCE MGMT SYSTEM;**18**;JAN 01, 2003
 ;
 ;     ROUTINE FOR PATCH ACR*2.1*18
 ;
 ;     This routine will take the perdiem data from the temporary
 ;     updates file and move it into the ARMS PER DIEM CITY file.
 ;
 ;     This routine searches for missing STATE fields and Military
 ;     installations and 'deactivates' the CITY field with "XX"
 ;     
 ;
 ;     The routine checks for and deletes old "D" cross-reference
 ;     that points to cities that have been set to "XX"
 ;
EN ;EP -- MAIN ENTRY POINT
 ;
 D ^XBKVAR
 D MSG(3,">>>Installing ARMS patch ACR*2.1*18...")
 H 2
 N CNT,UPDATE
 S UPDATE=3051001                    ;CHANGE THIS EVERY YEAR
 S INSTALL=DT
 W !!,"BEGINNING CLEAN UP OF MISSING STATE/MILLITARY INSTALLATION ENTRIES" H 3
 D LOOP1                             ;CLEAN OUT MISSING STATES & MILITARY
 ; NOW BEGIN UPDATES
 W !!,"BEGINNING UPDATES"
 D BLD
 D UPDATE
 W !!,"BEGINNING CROSS-REFERENCES CLEAN UP" H 2
 D MULT                              ;CLEAN OUT IDENTICAL ENTRIES
 D CLEAN                             ;CLEAN "D" X-REF
 D CLEANB                            ;CLEAN "B" X-REF
 D CLEANC                            ;CLEAN "C" X-REF
 D CLEANX                            ;CLEAN INTERNAL "B" X-REF
 K ^TMP("ACRZ",$J,"CITY")
 K ^TMP("ACRZ",$J,"ADDCITY")
 K ^TMP("ACRZ",$J,"UPDATE")
 D MSG(3,CNT_" CITIES UPDATED")
 ;D DELETE                              ;COMMENT OUT/IN FOR TESTING
 K ^ACRZPDC(9002199.9)                  ;COMMENT OUT/IN FOR TESTING
 D MSG(3,"DONE!")
 Q
 ;
LOOP1 ;----- BUILD GLOBAL CONTAINING CITY DATA FOR BAD DATA CLEANUP
 ;
 K ^TMP("ACRZ",$J)
 N CITY,DATA,IEN,STATE
 S IEN=0
 F  S IEN=$O(^ACRPD(IEN)) Q:'IEN  D
 . S DATA=$G(^ACRPD(IEN,0))
 . Q:DATA=""
 . S CITY=$P(DATA,U)
 . Q:CITY=""
 . I $E(CITY,1,2)="XX" D  Q
 . .K ^ACRPD(IEN,1)                      ;REMOVE MULTIPLE CITY NODES
 . S STATE=$P(DATA,U,2)
 . I $$MIL(CITY) D  Q
 . .S ^TMP("ACRZ",$J,"CITY",CITY,IEN)=""
 . .D DEACT(CITY,IEN)
 . I STATE=""  D                 ;ONLY WANT MISSING STATES
 . .S ^TMP("ACRZ",$J,"CITY",CITY,IEN)=""
 . .D DEACT(CITY,IEN)
 K ^TMP("ACRZ",$J)
 Q
 ;
UPDATE ;----- BEGIN UPDATE PROCESS
 ;
 N ACRZD0
 S (ACRZD0,CNT)=0
 F  S ACRZD0=$O(^ACRZPDC(9002199.9,ACRZD0)) Q:'ACRZD0   D
 . D UP(ACRZD0)
 D LEFT
 D LOOP
 Q
 ;
UP(ACRZD0)         ;----- UPDATE ONE ENTRY
 ;
 N BEGIN,CITY,COUNTY,EFFECT,END,IEN,LODGE,MEALS,OLDIEN,STATE
 D DATA(ACRZD0)
 Q:CITY=""!(STATE="")
 S (IEN,OLDIEN)=$O(^TMP("ACRZ",$J,"CITY",CITY_" "_STATE,0))
 I 'IEN D ADD(.IEN,CITY,STATE)
 Q:IEN'>0
 D EDIT(IEN,CITY,STATE,LODGE,MEALS,EFFECT,BEGIN,END,COUNTY)
 Q:IEN'=OLDIEN
 K ^TMP("ACRZ",$J,"CITY",CITY_" "_STATE,IEN)
 Q
 ;
EDIT(IEN,CITY,STATE,LODGE,MEALS,EFFECT,BEGIN,END,COUNTY)    ;
 ;----- EDIT ARMS PER DIEM CITY ENTRY
 ;
 N DA,DIE,DR,X,Y,STR
 S CNT=$G(CNT)+1
 I COUNTY="",$P(^ACRPD(IEN,0),U,8)]"" S COUNTY=$P(^ACRPD(IEN,0),U,8)
 S DIE="^ACRPD("
 S DA=IEN
 S DR=".03///"_LODGE
 S DR=DR_";.04///"_MEALS
 S DR=DR_";.05///"_EFFECT
 S DR=DR_";.06///"_BEGIN
 S DR=DR_";.07///"_END
 S DR=DR_";.08///"_COUNTY
 S DR=DR_";99.1///"_UPDATE
 S DR=DR_";99.2///"_INSTALL
 D ^DIE
 D OTH(IEN,CITY,STATE)
 D MSG(1," - UPDATED")
 Q
MSG(N,SUFX) ;LOCAL ENTRY
 I N=3 D BMES^XPDUTL(SUFX) Q
 S STR=IEN_" "_CITY_", "
 I STATE]"" S STR=STR_$P($G(^DIC(5,STATE,0)),U)
 I N=1 D
 .S STR=STR_"  "_$E(BEGIN,4,5)_"/"_$E(BEGIN,6,7)
 .S STR=STR_"-"_$E(END,4,5)_"/"_$E(END,6,7)
 D BMES^XPDUTL(STR_SUFX)
 Q
 ;
OTH(IEN,CITY,STATE)    ;----- ADD ADDITIONAL CITIES
 ;
 N ADDCITY,DA,DD,DIC,DLAYGO,DO,X,Y
 Q:'$D(^TMP("ACRZ",$J,"ADDCITY",CITY_" "_STATE))
 S ADDCITY=""
 F  S ADDCITY=$O(^TMP("ACRZ",$J,"ADDCITY",CITY_" "_STATE,ADDCITY)) Q:ADDCITY']""  D
 . Q:$D(^ACRPD(IEN,1,"B",ADDCITY))
 . S DA(1)=IEN
 . S DIC="^ACRPD("_DA(1)_","_1_","
 . S DIC(0)="L"
 . S DIC("P")=$P(^DD(9002199.9,1,0),U,2)
 . S DLAYGO=9002199.91
 . S X=ADDCITY
 . K DD,DO
 . D FILE^DICN
 . I Y<0 D MSG(1," - NOT UPDATED")
 Q
 ;
ADD(IEN,CITY,STATE)          ;----- ADD NEW CITY TO ARMS PER DIEM CITY FILE
 ;
 N DIC,DIADD,DLAYGO,X,Y
 S DIC="^ACRPD("
 S DIC(0)="L"
 S DIC("DR")=".02////^S X=STATE"
 S DLAYGO=9002193.9
 S DIADD=1
 S X=CITY
 D ^DIC
 I Y<0 S IEN=Y D MSG(2," - **NOT** ADDED") Q
 S IEN=+Y
 D MSG(2," - ADDED")
 Q
 ;
LEFT ;----- PROCESS LEFTOVERS ("XX" DUPLICATES)
 ;
 N CITY,IEN
 S CITY=""
 F  S CITY=$O(^TMP("ACRZ",$J,"UPDATE",CITY)) Q:CITY']""  D
 . S IEN=0
 . F  S IEN=$O(^TMP("ACRZ",$J,"CITY",CITY,IEN)) Q:'IEN  D
 . . D DEACT(CITY,IEN)
 Q
 ;
DEACT(CITY,IEN)    ;----- DEACTIVATE DUPLICATE CITY
 ;
 N DA,DATA,DIE,DR,NAME,STATE
 S DATA=$G(^ACRPD(IEN,0))
 Q:DATA=""
 S NAME=$P(DATA,U)
 I $E(NAME,1,2)="XX" D  Q             ; ALREADY DEACTIVATED
 .Q:'$D(^ACRPD(N,1))
 .K ^ACRPD(N,1) W !,N,?7,NAME_"  Node 1 KILLED"
 S LOCAL=$P($G(^ACRPD(IEN,99)),U,3)
 Q:LOCAL="Y"                      ; LOCAL CITY ENTRY, DO NOT DEACTIVATE
 S NAME="XX"_$E(NAME,1,28)
 S STATE=$P(DATA,U,2)
 S DIE="^ACRPD("
 S DA=IEN
 S DR=".01///^S X=NAME;99.1///^S X=UPDATE;99.2////"_INSTALL
 D ^DIE
 I DA<0 D MSG(2," - **NOT** DEACTIVATED") Q
 K ^ACRPD(IEN,1)                    ;REMOVE "B" MULTIPLE COMPLETELY
 D MSG(2," - DEACTIVATED")
 Q
 ;
DATA(ACRZD0)       ;----- GATHER PER DIEM DATA FROM UPDATE FILE
 ;
 N DATA
 S DATA=$G(^ACRZPDC(9002199.9,ACRZD0,0))
 S CITY=$P(DATA,U)
 S STATE=$P(DATA,U,2)
 S COUNTY=$P(DATA,U,8)
 S BEGIN=$P(DATA,U,6)
 S END=$P(DATA,U,7)
 S LODGE=$P(DATA,U,3)
 S MEALS=$P(DATA,U,4)
 S EFFECT=$P(DATA,U,5)
 Q
 ;
BLD ;----- BUILD ^TMP GLOBAL ARRAYS CONTAINING PER DIEM CITY DATA
 ;
 D BLDC,BLDU
 Q
 ;
BLDC ;----- BUILD GLOBAL CONTAINING CITY DATA
 ;
 N CITY,DATA,IEN,STATE
 K ^TMP("ACRZ",$J,"CITY")
 K ^TMP("ACRZ",$J,"ADDCITY")
 S IEN=0
 F  S IEN=$O(^ACRPD(IEN)) Q:'IEN  D
 . S DATA=$G(^ACRPD(IEN,0))
 . Q:DATA=""
 . S CITY=$P(DATA,U)
 . Q:CITY=""
 . S STATE=$P(DATA,U,2)
 . Q:STATE=""
 . S ^TMP("ACRZ",$J,"CITY",CITY_" "_STATE,IEN)=""
 . D BLDA(IEN,CITY,STATE)
 Q
 ;
BLDA(IEN,CITY,STATE)         ;---- BUILD GLOBAL CONTAINING ADDITIONAL CITY DATA
 ;
 N ADDCITY,D1
 S D1=0
 F  S D1=$O(^ACRPD(IEN,1,D1)) Q:'D1  D
 . S ADDCITY=$G(^ACRPD(IEN,1,D1,0))
 . Q:ADDCITY=""
 . I ADDCITY=CITY D  Q
 . .K ^ACRPD(IEN,1,D1,0)
 . .K ^ACRPD(IEN,1,"B",ADDCITY)
 . S ^TMP("ACRZ",$J,"ADDCITY",CITY_" "_STATE,ADDCITY)=""
 Q
 ;
BLDU ;----- BUILD GLOBAL CONTAINING UPDATE DATA
 ;
 N CITY,DATA,IEN,STATE
 K ^TMP("ACRZ",$J,"UPDATE")
 S IEN=0
 F  S IEN=$O(^ACRZPDC(9002199.9,IEN)) Q:'IEN  D
 . S DATA=$G(^ACRZPDC(9002199.9,IEN,0))
 . Q:DATA=""
 . S CITY=$P(DATA,U)
 . Q:CITY=""
 . S STATE=$P(DATA,U,2)
 . Q:STATE=""
 . S ^TMP("ACRZ",$J,"UPDATE",CITY_" "_STATE)=""
 Q
 ;
DELETE ;----- DELETE ACRZ ARMS PER DIEM CITY UPDATE FILE
 ;
 N DIU
 S DIU="^ACRZPDC(9002199.9,"
 S DIU(0)="DT"
 D EN^DIU2
 D MSG(3,"ACRZ PER DIEM CITY UPDATE file <DELETED>")
 Q
 ;
LOOP ;-- LOOP THROUGH ALL CITIES NOT UPDATED AND SET TO STANDARD RATE
 ;
 N DA,DATA,DIE,DR,LAST,LOCAL,OLDATE,PD,STATE
 S PD=0
 F  S PD=$O(^ACRPD(PD)) Q:'PD  D
 . S DATA=^ACRPD(PD,0)
 . Q:$E($P(DATA,U),1,2)="XX"
 . S STATE=$P(DATA,U,2)
 . S DATA=$G(^ACRPD(PD,99))
 . S OLDATE=$P(DATA,U)
 . Q:UPDATE=OLDATE
 . S LOCAL=$P(DATA,U,3)
 . I LOCAL="Y" S DR=""
 . I LOCAL'="Y" D      ;CHECK EVERY YEAR
 ..;I STATE=2 S DR=".03////80;.04////54"   ;ALASKA STAND RATE FY03
 .. I STATE=2 S DR=".03////80;.04////55"   ;ALASKA STAND RATE FY04,FY05,FY06
 ..;I STATE'=2 S DR=".03////55;.04////30"  ;CONUS STAND RATE FY03
 .. I STATE=12 S DR=".03////72;.04////61"  ;HAWAII STAND RATE FY04,FY05,FY06
 .. I STATE'=2,STATE'=12 D
 ...;S DR=".03////55;.04////31"  ;CONUS STAND RATE FY04
 ...;S DR=".03////60;.04////31"  ;CONUS STAND RATE FY05
 ...S DR=".03////60;.04////39"  ;CONUS STAND RATE FY06
 . S DR=DR_";99.1///"_UPDATE
 . S DR=DR_";99.2///"_INSTALL
 . S DIE="^ACRPD("
 . S DA=PD
 . D ^DIE
 Q
 ;
CLEAN ; CLEAN OUT OLD "D" CROSS-REFERENCES THAT POINT TO "XX" CITIES
 N N,P,CITY
 S N=0
 F  S N=$O(^ACRPD("D",N)) Q:N=""  D
 .S P=0 F  S P=$O(^ACRPD("D",N,P)) Q:P=""  D
 ..S CITY=$P($G(^ACRPD(P,0)),U)
 ..I $E(CITY,1,2)="XX"!($$MIL(CITY)) D
 ...K ^ACRPD("D",N,P)
 Q
CLEANB ; CLEAN OUT OLD "B" CROSS-REFERENCES THAT POINT TO "XX" CITIES
 N N,P,CITY
 S N=0
 F  S N=$O(^ACRPD("B",N)) Q:N=""  D
 .S P=0 F  S P=$O(^ACRPD("B",N,P)) Q:P=""  D
 ..S CITY=$P($G(^ACRPD(P,0)),U)
 ..I $E(CITY,1,2)="XX"!($$MIL(CITY)) D
 ...K ^ACRPD("B",N,P)
 Q
CLEANC ; CLEAN OUT OLD "C" CROSS-REFERENCES THAT POINT TO "XX" CITIES
 N N,P,CITY
 S N=0
 F  S N=$O(^ACRPD("C",N)) Q:N=""  D
 .S P=0 F  S P=$O(^ACRPD("C",N,P)) Q:P=""  D
 ..S CITY=$P($G(^ACRPD(P,0)),U)
 ..I $E(CITY,1,2)="XX"!($$MIL(CITY)) D
 ...K ^ACRPD("C",N,P)
 Q
CLEANX ; CLEAN OUT OLD INTERNAL "B" CROSS-REFERENCES THAT ARE NOT IN "B" X-REF
 N N,P,Q,CITY
 S N=0
 F  S N=$O(^ACRPD(N)) Q:N=""  D
 .Q:'$D(^ACRPD(N,1))
 .S P=0
 .F  S P=$O(^ACRPD(N,1,P)) Q:P=""  D
 ..S CITY=$G(^ACRPD(N,1,P,0))
 ..S Q=""
 ..F  S Q=$O(^ACRPD(N,1,P,Q)) Q:Q=""  D
 ...I CITY]"",$E(^ACRPD(N,0),1,2)="XX"!($$MIL(CITY)) D
 ....K ^ACRPD(N,1,"B",CITY)
 ....K ^ACRPD(N,1,P)
 Q
MIL(CITY) ;EXTRINSIC FUNCTION TO DETERMINE IF MILITARY ENTRY
 I $E(CITY,1,2)="XX" Q 0
 I CITY["[INCL "!(CITY["(INCL ") Q 0
 I CITY="ANCHORAGE" Q 1                ;TMP FIX REMOVE NEXT YEAR (2006)
 I CITY["NAVAL "!(CITY["ARMY ")!(CITY["NAVY ")!(CITY["USMC") Q 1
 I CITY["AIR FORCE"!(CITY[" AFB")!(CITY[" CG ")!(CITY["COAST GUAR") Q 1
 I CITY["SOLDIER'S H"!(CITY[" NS")!(CITY[" RES RC") Q 1
 I CITY["CTR"!(CITY["MC RES")!(CITY[" AGS")!(CITY["PROVING GR") Q 1
 I CITY["MC LOGIS"!(CITY[" CMD")!(CITY[" CRTC") Q 1
 I CITY["NAV NUC"!(CITY["SHIPBUILD")!(CITY["AIR TERM") Q 1
 I CITY[" RES C"!(CITY[" FLT ")!(CITY[" DEPOT")!(CITY["CAMP ") Q 1
 I CITY[" NAS" Q 1
 Q 0
MULT ; LOOK AT IDENTICAL DUPLICATES
 K ^TMP("ACRZ",$J,"DUPS")
 N N,P,Q,DATA,CITY,STATE,CITST
 S N=0
 F  S N=$O(^ACRPD(N)) Q:'N  D
 .S DATA=$G(^ACRPD(N,0))
 .S CITY=$P(DATA,U)
 .Q:$E(CITY,1,2)="XX"
 .S STATE=$P(DATA,U,2)
 .S CITST=CITY_" "_STATE
 .I $G(^TMP("ACRZ",$J,"DUPS",CITST))=DATA D  Q
 ..D DEACT(CITY,N)
 .S ^TMP("ACRZ",$J,"DUPS",CITST)=DATA
 Q