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

ACRZPD4.m

Go to the documentation of this file.
ACRZPD4 ;IHS/OIRM/DSD/AEF - UPDATE ARMS PER DIEM CITY FILE [ 09/26/2002  10:19 AM ]
 ;;2.1;ADMIN RESOURCE MGMT SYSTEM;**4**;JAN 01, 2000
 ;
 ;     ROUTINE FOR PATCH ACR*2.1*4
 ;
 ;     This routine will take the perdiem data from the temporary
 ;     updates file and move it into the ARMS PER DIEM CITY file.
 ;
 ;     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
 ;
 N CNT,INSTALL,UPDATE
 S UPDATE=3021001                       ;CHANGE THIS EVERY YEAR
 S INSTALL=DT
 D ^XBKVAR
 D MSG(3,">>>Installing ARMS patch ACR*2.1*4...")
 H 2
 D BLD
 D UPDATE
 D CLEAN
 K ^TMP("ACRZ",$J,"CITY")
 K ^TMP("ACRZ",$J,"ADDCITY")
 K ^TMP("ACRZ",$J,"UPDATE")
 D MSG(3,CNT_" CITIES UPDATED")
 D DELETE
 D MSG(3,"DONE!")
 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(UPDATE,INSTALL)
 D LOOP(UPDATE,INSTALL)
 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)
 D EDIT(IEN,CITY,STATE,LODGE,MEALS,EFFECT,BEGIN,END,COUNTY,UPDATE)
 Q:IEN'=OLDIEN
 K ^TMP("ACRZ",$J,"CITY",CITY_" "_STATE,IEN)
 Q
 ;
EDIT(IEN,CITY,STATE,LODGE,MEALS,EFFECT,BEGIN,END,COUNTY,UPDATE)    ;
 ;----- 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///^S X=LODGE"
 S DR=DR_";.04///^S X=MEALS"
 S DR=DR_";.05///^S X=EFFECT"
 S DR=DR_";.06///^S X=BEGIN"
 S DR=DR_";.07///^S X=END"
 S DR=DR_";.08///^S X=COUNTY"
 S DR=DR_";99.1///^S X=UPDATE"
 S DR=DR_";99.2///^S X=INSTALL"
 S DR=DR_";99.3///^S X=""N"""  ; New field for local entry flag
 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_", "_$P($G(^DIC(5,STATE,0)),U)
 I N=1 D
 .S STR=STR_"  "_$E(BEGIN,1,2)_"/"_$E(BEGIN,3,4)
 .S STR=STR_"-"_$E(END,1,2)_"/"_$E(END,3,4)
 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")=".04////^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(UPDATE,INSTALL) ;----- 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,UPDATE,INSTALL)
 Q
 ;
DEACT(CITY,IEN,UPDATE,INSTALL)    ;----- DEACTIVATE DUPLICATE CITY
 ;
 N DA,DATA,DIE,DR,NAME,STATE
 S DATA=$G(^ACRPD(IEN,0))
 Q:DATA=""
 S NAME=$P(DATA,U)
 Q:$E(NAME,1,2)="XX"              ; ALREADY DEACTIVATED
 S LOCAL=$P($G(^ACRPD(IEN,99)),U,3)
 Q:LOCAL="Y"                      ; LOCAL CITY ENTRY, DO NOT DEACTIVATE
 S NAME="XX"_NAME
 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////^S X=INSTALL"
 D ^DIE
 I DA<0 D MSG(2," - **NOT** DEACTIVATED") Q
 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 BEGIN=$E(BEGIN,4,7)
 I BEGIN="" S BEGIN="0101"
 S END=$P(DATA,U,7)
 S END=$E(END,4,7)
 I END="" S END=1231
 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=""
 . 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 ARMS PER DIEM CITY UPDATE file <DELETED>")
 Q
 ;
LOOP(UPDATE,INSTALL) ;-- 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
 .. I STATE=2 S DR=".03////80;.04////54"   ;ALASKA STANDARD RATE
 .. I STATE'=2 S DR=".03////55;.04////30"  ;CONUS STANDARD RATE
 . S DR=DR_";99.1///^S X=UPDATE;99.2///^S X=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,DATA
 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 DATA=$G(^ACRPD(P,0))
 ..Q:$E(DATA,1,2)'="XX"
 ..K ^ACRPD("D",N,P)
 Q