DGV53PTB ;ALB/SCK - POST INIT CONVERSION ROUTINE FOR DISTANCE FILE; 2/2/93 4/19/93
;;5.3;Registration;**1015**;Aug 13, 1993;Build 21
Q
EN ;
S (ZCNT,RCNT,MCNT,TOT)=0,U="^"
K ^TMP("DGBT",$J,"ZIP")
W !!!,">>> Beginning conversion of BENEFICIARY TRAVEL DISTANCE file, (#392.1)"
I '$D(^DGBT(392.1,0)) W !!,*7,">>> The BENEFICIARY TRAVEL DISTANCE file, (#392.1), is not properly set-up.",!,"Please re-run the init to set it up." G EXIT
I '$O(^DGBT(392.1,0)) W !!,">>> There is no data in the BENEFICIARY TRAVEL DISTANCE file (#392.1) to convert",!?4,"Exiting post-init conversion of BENEFICIARY TRAVEL." G EXIT
L +^DGBT(392.1):3 I '$T W !!,*7,">>> File is not available at the present time!",!?4,"Please try again later." G EXIT
S PRIDIV=+$P($G(^DG(43,1,"GL")),U,3) I 'PRIDIV D ERR1 G EXIT
W !! D WAIT^DICD
W !,">>> Beginning check and conversion",!?4,"of BENEFICIARY TRAVEL DISTANCE file, (#392.1)",!
S GLREC=0 F S GLREC=$O(^DGBT(392.1,GLREC)) Q:'GLREC D LOOP
L -^DGBT(392.1)
ENDLOOP ; end of loop to rebuild distance file
W !!,">>> BENEFICIARY TRAVEL DISTANCE file (#392.1) conversion complete.",!?4,TOT," Cities in the BENEFICIARY TRAVEL DISTANCE file (#392.1) have been converted.",! D WAIT^DICD
W !,">>> Re-Indexing BENEFICIARY TRAVEL DISTANCE file (#392.1). This could take awhile."
S DIK="^DGBT(392.1,",DA(1)=392.1 D IXALL^DIK W !!,">>> Re-Indexing complete."
D RMK^DGV53PTC,ZIP^DGV53PTC,MILES^DGV53PTC
I MCNT!(ZCNT)!(RCNT) D
. W !!!,"INCOMPLETE INFORMATION FOUND DURING THE POST-INIT CONVERSION OF THE",!,"BENEFICIARY TRAVEL DISTANCE FILE, (#392.1)",!!
. D:MCNT>0 MSGS D:ZCNT>0 ZIPMSG D:RCNT>0 RMKMSG
EXIT ;
K ^TMP("DGBT",$J,"ZIP"),^TMP("DGBT",$J,"MILES"),^TMP("DGBT",$J,"ADD")
K ADDINF,MCNT,MEC,MILES,PRIDIV,RCNT,ZCNT,ZIP,GLREC,TOT,DIK,ZIP,DGBTVAR,STATE
Q
LOOP ; begin loop for converting distance file
S TOT=TOT+1,DGBTVAR=^DGBT(392.1,GLREC,0)
CHKMILE ; check default mileage, if null pass 0 to subnode
S MILES=+$P(DGBTVAR,U,3) D:MILES'>0 MARRAY
ADDINF ; check for additional information flag
S ADDINF=$P(DGBTVAR,U,5) D:ADDINF ADARRAY
MECOST ;
S MEC=$P($G(^DGBT(392.1,GLREC,0)),U,6)
STUFF ; build subnode from variables set above
W:'(TOT#10) "."
I '$D(^DGBT(392.1,GLREC,1,0)) D
. S ^DGBT(392.1,GLREC,1,0)="^392.1001PA"_"^"_1_"^"_1
. S ^DGBT(392.1,GLREC,1,1,0)=PRIDIV_"^"_MILES_"^"_$S(MEC'>0:"^"_ADDINF,1:MEC_"^"_ADDINF)
ZIP ; check for zipcode, make sure there is a number value entered in piece 4.
D:$P(DGBTVAR,U,4)']"" ZARRAY
Q
MSGS ; list out incomplete data found during conversion
W !!,*7,">>> WARNING! ",!?4,MCNT," CITIES WITH INCOMPLETE MILEAGE INFORMATION",!?4,"WERE FOUND, A LISTING HAS BEEN SENT TO THE MAS ADPAC."
Q
ZIPMSG ;
W !!,*7,">>> WARNING!",!?4,ZCNT," CITIES WITH INCOMPLETE ZIP CODE INFORMATION",!?4,"WERE FOUND, A LISTING HAS BEEN SENT TO THE MAS ADPAC."
Q
RMKMSG ;
W !!,*7,">>> WARNING!",!?4,RCNT," CITIES HAD THE ADDITIONAL INFORMATION FIELD SET THAT",!?4,"WILL NEED THE REMARKS COMPLETED. A LISTING HAS BEEN SENT TO",!?4,"THE MAS ADPAC"
Q
ERR1 ;
W !!,*7,">>> The primary division is missing or incorrect.",!,"I'm stopping the Beneficiary Travel portion",!,"of the post-init. Please check the value of the primary",!,"division in the MAS parameter file DG(43)"
Q
ZARRAY ; build array for message on missing zipcodes
S ZCNT=ZCNT+1,STATE=$$GSTATE,^TMP("DGBT",$J,"ZIP",ZCNT)=$P(DGBTVAR,U,1)_", "_STATE
Q
MARRAY ; build array for message on 0 default mileages
S MCNT=MCNT+1,STATE=$$GSTATE,^TMP("DGBT",$J,"MILES",MCNT)=$P(DGBTVAR,U,1)_", "_STATE
Q
ADARRAY ; build array for cities with additional information field set
S RCNT=RCNT+1,STATE=$$GSTATE,^TMP("DGBT",$J,"ADD",RCNT)=$P(DGBTVAR,U,1)_", "_STATE
Q
GSTATE() ;
N STATE
S STATE=$S($P(DGBTVAR,U,2)]"":$P($G(^DIC(5,$P(DGBTVAR,U,2),0)),U,1),1:"** MISSING STATE **")
Q STATE
DGV53PTB ;ALB/SCK - POST INIT CONVERSION ROUTINE FOR DISTANCE FILE; 2/2/93 4/19/93
+1 ;;5.3;Registration;**1015**;Aug 13, 1993;Build 21
+2 QUIT
EN ;
+1 SET (ZCNT,RCNT,MCNT,TOT)=0
SET U="^"
+2 KILL ^TMP("DGBT",$JOB,"ZIP")
+3 WRITE !!!,">>> Beginning conversion of BENEFICIARY TRAVEL DISTANCE file, (#392.1)"
+4 IF '$DATA(^DGBT(392.1,0))
WRITE !!,*7,">>> The BENEFICIARY TRAVEL DISTANCE file, (#392.1), is not properly set-up.",!,"Please re-run the init to set it up."
GOTO EXIT
+5 IF '$ORDER(^DGBT(392.1,0))
WRITE !!,">>> There is no data in the BENEFICIARY TRAVEL DISTANCE file (#392.1) to convert",!?4,"Exiting post-init conversion of BENEFICIARY TRAVEL."
GOTO EXIT
+6 LOCK +^DGBT(392.1):3
IF '$TEST
WRITE !!,*7,">>> File is not available at the present time!",!?4,"Please try again later."
GOTO EXIT
+7 SET PRIDIV=+$PIECE($GET(^DG(43,1,"GL")),U,3)
IF 'PRIDIV
DO ERR1
GOTO EXIT
+8 WRITE !!
DO WAIT^DICD
+9 WRITE !,">>> Beginning check and conversion",!?4,"of BENEFICIARY TRAVEL DISTANCE file, (#392.1)",!
+10 SET GLREC=0
FOR
SET GLREC=$ORDER(^DGBT(392.1,GLREC))
IF 'GLREC
QUIT
DO LOOP
+11 LOCK -^DGBT(392.1)
ENDLOOP ; end of loop to rebuild distance file
+1 WRITE !!,">>> BENEFICIARY TRAVEL DISTANCE file (#392.1) conversion complete.",!?4,TOT," Cities in the BENEFICIARY TRAVEL DISTANCE file (#392.1) have been converted.",!
DO WAIT^DICD
+2 WRITE !,">>> Re-Indexing BENEFICIARY TRAVEL DISTANCE file (#392.1). This could take awhile."
+3 SET DIK="^DGBT(392.1,"
SET DA(1)=392.1
DO IXALL^DIK
WRITE !!,">>> Re-Indexing complete."
+4 DO RMK^DGV53PTC
DO ZIP^DGV53PTC
DO MILES^DGV53PTC
+5 IF MCNT!(ZCNT)!(RCNT)
Begin DoDot:1
+6 WRITE !!!,"INCOMPLETE INFORMATION FOUND DURING THE POST-INIT CONVERSION OF THE",!,"BENEFICIARY TRAVEL DISTANCE FILE, (#392.1)",!!
+7 IF MCNT>0
DO MSGS
IF ZCNT>0
DO ZIPMSG
IF RCNT>0
DO RMKMSG
End DoDot:1
EXIT ;
+1 KILL ^TMP("DGBT",$JOB,"ZIP"),^TMP("DGBT",$JOB,"MILES"),^TMP("DGBT",$JOB,"ADD")
+2 KILL ADDINF,MCNT,MEC,MILES,PRIDIV,RCNT,ZCNT,ZIP,GLREC,TOT,DIK,ZIP,DGBTVAR,STATE
+3 QUIT
LOOP ; begin loop for converting distance file
+1 SET TOT=TOT+1
SET DGBTVAR=^DGBT(392.1,GLREC,0)
CHKMILE ; check default mileage, if null pass 0 to subnode
+1 SET MILES=+$PIECE(DGBTVAR,U,3)
IF MILES'>0
DO MARRAY
ADDINF ; check for additional information flag
+1 SET ADDINF=$PIECE(DGBTVAR,U,5)
IF ADDINF
DO ADARRAY
MECOST ;
+1 SET MEC=$PIECE($GET(^DGBT(392.1,GLREC,0)),U,6)
STUFF ; build subnode from variables set above
+1 IF '(TOT#10)
WRITE "."
+2 IF '$DATA(^DGBT(392.1,GLREC,1,0))
Begin DoDot:1
+3 SET ^DGBT(392.1,GLREC,1,0)="^392.1001PA"_"^"_1_"^"_1
+4 SET ^DGBT(392.1,GLREC,1,1,0)=PRIDIV_"^"_MILES_"^"_$SELECT(MEC'>0:"^"_ADDINF,1:MEC_"^"_ADDINF)
End DoDot:1
ZIP ; check for zipcode, make sure there is a number value entered in piece 4.
+1 IF $PIECE(DGBTVAR,U,4)']""
DO ZARRAY
+2 QUIT
MSGS ; list out incomplete data found during conversion
+1 WRITE !!,*7,">>> WARNING! ",!?4,MCNT," CITIES WITH INCOMPLETE MILEAGE INFORMATION",!?4,"WERE FOUND, A LISTING HAS BEEN SENT TO THE MAS ADPAC."
+2 QUIT
ZIPMSG ;
+1 WRITE !!,*7,">>> WARNING!",!?4,ZCNT," CITIES WITH INCOMPLETE ZIP CODE INFORMATION",!?4,"WERE FOUND, A LISTING HAS BEEN SENT TO THE MAS ADPAC."
+2 QUIT
RMKMSG ;
+1 WRITE !!,*7,">>> WARNING!",!?4,RCNT," CITIES HAD THE ADDITIONAL INFORMATION FIELD SET THAT",!?4,"WILL NEED THE REMARKS COMPLETED. A LISTING HAS BEEN SENT TO",!?4,"THE MAS ADPAC"
+2 QUIT
ERR1 ;
+1 WRITE !!,*7,">>> The primary division is missing or incorrect.",!,"I'm stopping the Beneficiary Travel portion",!,"of the post-init. Please check the value of the primary",!,"division in the MAS parameter file DG(43)"
+2 QUIT
ZARRAY ; build array for message on missing zipcodes
+1 SET ZCNT=ZCNT+1
SET STATE=$$GSTATE
SET ^TMP("DGBT",$JOB,"ZIP",ZCNT)=$PIECE(DGBTVAR,U,1)_", "_STATE
+2 QUIT
MARRAY ; build array for message on 0 default mileages
+1 SET MCNT=MCNT+1
SET STATE=$$GSTATE
SET ^TMP("DGBT",$JOB,"MILES",MCNT)=$PIECE(DGBTVAR,U,1)_", "_STATE
+2 QUIT
ADARRAY ; build array for cities with additional information field set
+1 SET RCNT=RCNT+1
SET STATE=$$GSTATE
SET ^TMP("DGBT",$JOB,"ADD",RCNT)=$PIECE(DGBTVAR,U,1)_", "_STATE
+2 QUIT
GSTATE() ;
+1 NEW STATE
+2 SET STATE=$SELECT($PIECE(DGBTVAR,U,2)]"":$PIECE($GET(^DIC(5,$PIECE(DGBTVAR,U,2),0)),U,1),1:"** MISSING STATE **")
+3 QUIT STATE