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

PRS8HD.m

Go to the documentation of this file.
  1. PRS8HD ;HISC/MGD-DECOMPOSITION, DETERMINE HOLIDAYS ;12/17/2008
  1. ;;4.0;PAID;**4,33,72,88,94,98,113,118,122,123,139,144**;Sep 21, 1995;Build 12
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;This routine is used to determine legal holidays. One calls
  1. ;^PRS8HD with nothing defined if one wants all holidays in the
  1. ;next year. Tag EN can be called with PRS8D defined as a VA
  1. ;FileManager format date from which to calculate holidays. See
  1. ;later documentation in this routine regarding further processing
  1. ;instructions.
  1. ;
  1. K PRS8D
  1. ;
  1. EN ;--- entry point
  1. ; pass PRS8D as date you want in VA FileMan format
  1. ; - where only year, i.e., 92 is passed, the first day is presumed
  1. ; pass PRS8D(0) containing a holiday code if specific one wanted
  1. ; if neither PRS8D or PRS8D(0) passed DT is assumed and all
  1. ; holidays for next year are returned
  1. ;
  1. N CT,D,DD,DDQ,DN,DX,NY,%Y,PRSDT1 ;new variables used
  1. K HD,HO,PRS8D(1) ;remove existing array if there
  1. I '($D(DT)#2) D DT^DICRW ;get DT if none
  1. S X=$G(PRS8D) I X']"" S X=DT ;use DT if no X
  1. K %DT D ^%DT S X=Y I Y'>0 S PRS8D(1)=-1 G END ;bad date
  1. I '+$E(X,4,5) S X=$E(X,1,3)_"01"_$S(+$E(X,6,7):$E(X,6,7),1:"01")
  1. S PRSDT1=X
  1. ;
  1. ; Build sorted list (by month) of recurring holidays in array H()
  1. ; If specific holiday code passed just get it, else get all.
  1. ; Note that holiday code "E" is not a recurring holiday so it is
  1. ; handled in another section after the recurring holidays are done.
  1. S (CT,NY)=0,X1=$G(PRS8D(0)),X2="^K^P^M^I^L^C^V^T^X^N^"
  1. I X1]"",X2[("^"_X1_"^") S X1=$F(X2,X1)-1\2+1,J=$P($T(H+(X1+6)),";;",2),H($P(J,"^",2),$P(J,"^",1))=$P(J,"^",3,5)
  1. E I X1'="E" F I=1:1 S J=$P($T(H+(I+7)),";;",2) Q:J="" S H($P(J,"^",2),$P(J,"^",1))=$P(J,"^",3,5) ;get dates by month
  1. ;
  1. ; build output arrays for the recurring holidays
  1. PASS ;--- come back here for a second pass if necessary
  1. S DN=X,D(1)=+$E(X,1,3),D(2)=0 F S D(2)=$O(H(D(2))),D(3)="" Q:'D(2) F S D(3)=$O(H(D(2),D(3))) Q:D(3)="" D
  1. .S DD=H(D(2),D(3))
  1. .S D=D(1)+($S(D(2)<(+$E(DN,4,5)):1,1:0))_$E("00",0,2-$L(D(2)))_D(2)_$E(DN,6,7)
  1. .I '$P(DD,"^",2) D
  1. ..S (DX,X)=$E(D,1,5)_$E("00",0,2-$L(+$P(DD,"^",1)))_+$P(DD,"^",1)
  1. ..D DW^%DTC S Y=%Y,X=DX
  1. ..Q ;I Y,Y'=6 Q
  1. ..S X2=$S('Y:"",1:"-")_1,X1=X D C^%DTC
  1. .E D
  1. ..S (DX,X)=$E(D,1,5)_"01"
  1. ..D DW^%DTC S Y=%Y,X=DX
  1. ..I Y'=+DD D
  1. ...I +Y<+DD S X2=DD-Y
  1. ...E S X2=7-(+Y)+DD
  1. ...S X1=X D C^%DTC
  1. ..I +$P(DD,"^",2)=1 S DX=X Q
  1. ..S DD(1)=X,(DD(2),DD(3),DDQ)=0 F Q:DD(2)&(DDQ) D
  1. ...S X2=7,X1=DD(1) D C^%DTC
  1. ...S DD(2)=X,DDQ=1
  1. ...I $E(DD(1),1,5)=$E(X,1,5) S DD(1)=X,DDQ=0
  1. ...S DD(3)=DD(3)+1 I DD(3)=2,+$P(DD,"^",2)=3 S DDQ=1
  1. ...I DD(3)=1,+$P(DD,"^",2)=4 S DDQ=1
  1. ...I DD(3)=3,+$P(DD,"^",2)=5 S DDQ=1
  1. ..S (DX,X)=DD(1)
  1. .D DW^%DTC S Y=%Y,X=DX
  1. .Q:X<DN
  1. .D SET
  1. .I +DD=+D(2)=+$E(DN,4,5),$P(DD,"^",3)="N" D
  1. ..S NY=NY+1 Q:NY>1
  1. ..S X=$E(DN,1,3)+1,(DX,X)=X_"0101"
  1. ..D DW^%DTC S Y=%Y,X=DX
  1. ..Q ;Q:Y'=6
  1. ..S X2=-1,X1=X D C^%DTC S DX=X
  1. ..D DW^%DTC S Y=%Y,X=DX
  1. ..D SET
  1. .K H(D(2),D(3))
  1. I $O(H(0))>0 D
  1. .S X=+$E(DN,4,5)
  1. .S X=$S(X=12:1,1:(X+1))
  1. .S X1=$E(DN,1,3)+$S(X=1:1,1:0),X=X1_$E("00",0,2-$L(X))_X_"01"
  1. .D PASS
  1. ;
  1. ;new section to add applicable extra (non-recurring) holidays
  1. I $G(PRS8D(0))=""!($G(PRS8D(0))="E") D
  1. . N PRSDT2,PRSI,PRSX
  1. . S PRSDT2=$$FMADD^XLFDT(PRSDT1,364)
  1. . ;
  1. . ; loop thru the extra holiday list
  1. . F PRSI=1:1 S PRSX=$P($T(EHOL+PRSI),";;",2) Q:PRSX="" D
  1. . . Q:$P(PRSX,U)<PRSDT1 ; skip if before input date
  1. . . Q:$P(PRSX,U)>PRSDT2 ; skip if not within the next year
  1. . . ; need to add this extra holiday to list
  1. . . S HD($P(PRSX,U))=$P(PRSX,U,2,3)
  1. . . S HO("E",$P(PRSX,U))=""
  1. . . S CT=CT+1
  1. . ;
  1. . ; quit if site is not in the Washington DC area
  1. . Q:"^101^688^"'[(U_$E($$STA^XUAF4(+$$KSP^XUPARAM("INST")),1,3)_U)
  1. . ;
  1. . ; loop thru additional DC location extra holiday list
  1. . F PRSI=1:1 S PRSX=$P($T(EHOLDC+PRSI),";;",2) Q:PRSX="" D
  1. . . Q:$P(PRSX,U)<PRSDT1 ; skip if before input date
  1. . . Q:$P(PRSX,U)>PRSDT2 ; skip if not within the next year
  1. . . ; need to add this extra holiday to list
  1. . . S HD($P(PRSX,U))=$P(PRSX,U,2,3)
  1. . . S HO("E",$P(PRSX,U))=""
  1. . . S CT=CT+1
  1. ;
  1. S PRS8D(1)=$S(CT:+CT,1:-1)
  1. ;
  1. END ;--- That's all folks
  1. K %DT,H,I,J,X,X1,X2,Y Q
  1. ;
  1. SET ;--- set nodes
  1. S HD(X)=D(3)_"^"_$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR","^",Y+1)_"DAY",HO($P(DD,"^",3),X)="",CT=CT+1 Q
  1. ;
  1. H ;--- Actual Holidays
  1. ; PIECE1 PIECE2 PIECE3 PIECE4 PIECE5 PIECE6
  1. ; actual month exact day 0=exact holiday how
  1. ; holiday day-of-week 1=1st wk code deter-
  1. ; 2=last wk mined
  1. ; - pc3 and 4 are used in concert 3=3rd wk
  1. ; 4=2nd wk,5=4th wk
  1. ;
  1. ;;M.L. King's Birthday^1^1^3^K^3rd Monday in January
  1. ;;President's Day^2^1^3^P^3rd Monday in February
  1. ;;Memorial Day^5^1^2^M^Last Monday in May
  1. ;;Independence Day^7^4^0^I^July 4
  1. ;;Labor Day^9^1^1^L^First Monday in September
  1. ;;Columbus Day^10^1^4^C^Second Monday in October
  1. ;;Veterans Day^11^11^0^V^November 11
  1. ;;Thanksgiving Day^11^4^5^T^Fourth Thursday in November
  1. ;;Christmas Day^12^25^0^X^December 25
  1. ;;New Year's Day^1^1^0^N^January 1
  1. ;
  1. ;-Holiday Codes
  1. ; - K = M.L. King P = President's Day M = Memorial Day
  1. ; - I = Independence L = Labor Day C = Columbus Day
  1. ; - V = Veterans Day T = Thanksgiving X = Christmas
  1. ; - E = Extra Holiday (non-recurring) N = New Year's
  1. ;
  1. ;HD(HOLIDAY) is returned by routine equal to "literal^Dow"
  1. ;HO("HOLIDAY CODE",HOLIDAY) is returned equal to null
  1. ;PRS8D* is returned in value passed
  1. ;PRS8D(1) is returned equal to # holidays found or -1 if none
  1. ;
  1. ;---------------------------------------------------------------------
  1. ;New Section Added for Extra Non-Recurring Holidays (holiday code E)
  1. ;
  1. ; format is
  1. ; FM date of the declared holiday^text^day of week^patch number
  1. ;
  1. ; The following list will need to be updated for years that have an
  1. ; extra Christmas Holiday declared or and declared memorial day for
  1. ; past presidents.
  1. ;
  1. EHOL ;
  1. ;;2940427^President Nixon Funeral^WEDNESDAY^PRS*3.1*2
  1. ;;2971226^Extra Christmas Day^FRIDAY^PRS*4*33
  1. ;;3011224^Extra Christmas Day^MONDAY^PRS*4*72
  1. ;;3031226^Extra Christmas Day^FRIDAY^PRS*4*88
  1. ;;3040611^President Reagan Funeral^FRIDAY^PRS*4*94
  1. ;;3070102^President Ford Funeral^TUESDAY^PRS*4*113
  1. ;;3071224^Extra Christmas Day^MONDAY^PRS*4*118
  1. ;;3081226^Extra Christmas Day^FRIDAY^PRS*4*122
  1. ;;3121224^Extra Christmas Day^MONDAY^PRS*4*139
  1. ;;3141226^Extra Christmas Day^FRIDAY^PRS*4*144
  1. ;
  1. ;---------------------------------------------------------------------
  1. ;New Section Added for Extra Non-Recurring Holidays (holiday code E)
  1. ;that are location specifc to the DC area
  1. ;
  1. ; format is
  1. ; FM date of the declared holiday^text^day of week^patch number
  1. ;
  1. ; The following list will need to be updated when additional specific
  1. ; holidays are declared that only apply to the DC area
  1. ;
  1. EHOLDC ;
  1. ;;3050120^Presidential Inauguration Day^THURSDAY^PRS*4*98
  1. ;;3090120^Presidential Inauguration Day^TUESDAY^PRS*4*123
  1. ;
  1. ;PRS8HD