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

PRSARC06.m

Go to the documentation of this file.
  1. PRSARC06 ;WOIFO/JAH - Recess Tracking ListManger Inteface ;10/16/06
  1. ;;4.0;PAID;**112**;Sep 21, 1995;Build 54
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. Q
  1. MAIN(LSTART,LISTI,LINE,PRSDT,PRSFYRNG) ; BUILD LIST OF CALENDER FROM PP WITH PRSDT
  1. ; THROUGH PP CONTAINING SEPTEMBER 30
  1. ;
  1. ; PRSNMDT - date for new month
  1. ;
  1. ; Q:$G(PRSOUT)=1
  1. N FIRSTPP,PRSNMDT,FFPPE,LFPPE,EOFYDT,OUT,PRSDY,PRSMO,PRSNXTMO,PRSYR
  1. ;
  1. ; Get PP with PRSDT and convert PRSDT to the 1st day of that pp
  1. ;
  1. S FIRSTPP=$$GETPPDY^PRSARC04(PRSDT)
  1. S FFPPE=$P(FIRSTPP,U,2)
  1. S (PRSDT,PRSNMDT)=$P(FIRSTPP,U,1)
  1. ;
  1. ; lookup which week of the fiscal year the schedule begins
  1. ; this week # will be the first selectable item in the list
  1. ;
  1. S (LSTART,LISTI)=$G(FMWKS(PRSDT))
  1. ;
  1. ; Get the last PP of the fiscal year and it's last day.
  1. S LFPPE=$P(PRSFYRNG,U,4)
  1. S EOFYDT=$P(PRSFYRNG,U,2)
  1. ;
  1. ; if the first week in the AWS schedule is not both the 1st day
  1. ; of a PP and the first day of the month, then we need
  1. ; special code for that month, so that a partial month is used
  1. ; including only the pps that are part of the schedule.
  1. ;
  1. S (OUT,LINE,MONTHCNT)=0
  1. I $E(PRSDT,6,7)'="01" D
  1. . S STARTDAY=$E(PRSDT,6,7)
  1. . D ARAYMO(.LISTI,.LINE,PRSDT,MONTHCNT,STARTDAY,0)
  1. . S PRSMO=$E(PRSDT,4,5),PRSYR=$E(PRSDT,1,3),PRSDY=$E(PRSDT,6,7)
  1. . S PRSNXTMO=PRSMO+1 I $L(PRSNXTMO)=1 S PRSNXTMO="0"_PRSNXTMO
  1. . S PRSNMDT=$S(PRSMO=12:PRSYR+1_"01"_PRSDY,1:PRSYR_PRSNXTMO_"01")
  1. ;
  1. ; loop through the calendar building list items for every week in
  1. ; the year until we reach october. All agreements are through
  1. ; the end of the fiscal year.
  1. ;
  1. S OUT=0
  1. F D Q:OUT
  1. . S MONTHCNT=MONTHCNT+1
  1. . D ARAYMO(.LISTI,.LINE,PRSNMDT,MONTHCNT,1,0)
  1. . S PRSMO=$E(PRSNMDT,4,5),PRSYR=$E(PRSNMDT,1,3),PRSDY=$E(PRSNMDT,6,7)
  1. . S PRSNXTMO=PRSMO+1 I $L(PRSNXTMO)=1 S PRSNXTMO="0"_PRSNXTMO
  1. . S PRSNMDT=$S(PRSMO=12:PRSYR+1_"01"_PRSDY,1:PRSYR_PRSNXTMO_"01")
  1. . ;if we hit september 30 or october quit
  1. . I PRSNXTMO=10!(PRSNMDT>EOFYDT) S OUT=1
  1. ;
  1. ; Include any weeks in October that are part of the PP
  1. ; with September 30, thus the fiscal year spills into october by
  1. ; no more than 13 days
  1. ;
  1. I PRSNXTMO=10&(PRSNMDT'>EOFYDT) D
  1. . S MONTHCNT=MONTHCNT+1
  1. . D ARAYMO(.LISTI,.LINE,PRSNMDT,MONTHCNT,1,+$E(EOFYDT,6,7))
  1. Q
  1. ;= = = = = = = = = = = = = = = = = = = = = = = = = = =
  1. ;
  1. ARAYMO(LISTI,LINE,PRSDT,MONTHCNT,STARTDAY,SHORT) ;SILENT CALL TO PLACE MONTH IN ARRAY
  1. ; INPUT: PRSDT - must be fileman date
  1. ; SHORT - set to # of days to show if a short month
  1. ; is desired. i.e. to stop listing after the
  1. ; first PP then specify the # of
  1. ; days to that date from the 1st of the month
  1. ;
  1. N X,Y,%DT,DAY1,Y,MONTH,DAYS,YEAR,FIRSTDAY,LASTDAY,COUNT,HDR
  1. S X=PRSDT D ^%DT Q:Y<0
  1. S MONTH=$E(PRSDT,4,5),YEAR=$E(PRSDT,1,3)+1700
  1. I SHORT D
  1. . S DAYS=SHORT
  1. E D
  1. . S DAYS=$$DAYSINMO(YEAR,MONTH)
  1. S FIRSTDAY=$E(PRSDT,1,5)_"01",LASTDAY=$E(PRSDT,1,5)_DAYS
  1. ;
  1. ;Get day #s of pps in month
  1. N PPS
  1. I FIRSTDAY<3130000 D GETPPS(FIRSTDAY,LASTDAY)
  1. S DAY1=$$WEEKDAY1(PRSDT)
  1. S HDR=$$GETHEAD(Y)
  1. S LINE=LINE+1
  1. S ^TMP("PRSARC",$J,LINE,0)=" ============="_HDR_"============"
  1. ;
  1. D DISPMO(.LISTI,.LINE,DAY1,DAYS,1,STARTDAY)
  1. ;S LINE=LINE+1
  1. ;D HOLIDAY
  1. Q
  1. ;
  1. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  1. DISPMO(LISTI,LINE,DAYNO,NODAYS,SKPW1,STRTDY) ;store a month into an array
  1. ;SAMPLE CALL: D DISPMO(4,30,.L,0) Produces a 30 day month with day 1
  1. ; beginning on Wednesday.
  1. ;SAMPLE CALL: D DISPMO(4,30,.L,1) Produces a 30 day month starting
  1. ; in week 2 Sunday--day 5
  1. ;
  1. ;INPUT:
  1. ; DAYNO : integer value of weekday (0=sun,1=mon,2=tues,...,6=sat)
  1. ; NODAYS: integer value of days in month, i.e. 30 days has sept...
  1. ; SKIPW1: set to true if you want to skip partial 1st week
  1. ; STRTDY: set to day of month to start calendar.
  1. ;
  1. N DAYS,DAYPOS,I,PPOFFSET,CNTDWN,BLNKS,LEADBLNK,WRTAB
  1. S PPOFFSET=" ",CNTDWN=NODAYS
  1. ;
  1. ; keep track of selectable items in the list (LISTI) and
  1. ; lines in the list
  1. ;
  1. ; start with second week when SKPW1 is true and the first week
  1. ; of the month isn't a full week.
  1. ; also I STARTDAY is > 1 then use it (we only want a partial month)
  1. I (STRTDY=1)&SKPW1&(DAYNO'=0) S STRTDY=8-DAYNO
  1. F I=STRTDY:1:NODAYS D
  1. . S DAYPOS=(DAYNO+I-1)#7
  1. . I DAYPOS=0 D
  1. .. S LINE=LINE+1
  1. .. S LEADBLNK=$E(" ",1,(3-$L(LISTI)))
  1. .. S BLNKS=" "
  1. .. I $G(PPS(I))'="" D
  1. ... ; index of items that are selectable (weeks only, no month heads)
  1. ... S ^TMP("PRSLI",$J,LISTI)=LINE
  1. ... ; ListManager's items
  1. ... S ^TMP("PRSARC",$J,LINE,0)=LEADBLNK_LISTI_BLNKS_PPS(I)
  1. .. E D
  1. ... S ^TMP("PRSLI",$J,LISTI)=LINE
  1. ... S ^TMP("PRSARC",$J,LINE,0)=LEADBLNK_LISTI_BLNKS_PPOFFSET
  1. .. S LISTI=LISTI+1
  1. . I ($G(CNTDWN)>0) D
  1. .. S WRTAB=$S($L(I)=2:" ",1:" ")
  1. .. S ^TMP("PRSARC",$J,LINE,0)=$G(^TMP("PRSARC",$J,LINE,0))_WRTAB_I
  1. .. S CNTDWN=CNTDWN-1
  1. ;
  1. ; add first days of next month to the last week
  1. ;
  1. I DAYPOS'=6 D
  1. . F I=1:1:7-(DAYPOS+1) S ^TMP("PRSARC",$J,LINE,0)=$G(^TMP("PRSARC",$J,LINE,0))_" "_I
  1. Q
  1. ;
  1. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  1. ;
  1. GETPPS(FIRSTDAY,LASTDAY) ;
  1. N D1,PPE,PPDAY,PPI,PP4Y
  1. S D1=FIRSTDAY D PP^PRSAPPU
  1. D NX^PRSAPPU
  1. I D1<FIRSTDAY S PPE=$E($$NXTPP^PRSAPPU(PPE),3,7) D NX^PRSAPPU
  1. S PPDAY=+$E(D1,6,7)
  1. S PPS(PPDAY)=PPE
  1. F D Q:D1>LASTDAY
  1. . S PPE=$E($$NXTPP^PRSAPPU(PPE),3,7) D NX^PRSAPPU
  1. . Q:D1>LASTDAY
  1. . S PPDAY=+$E(D1,6,7)
  1. . S PPS(PPDAY)=PPE
  1. Q
  1. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  1. ;
  1. GETHEAD(Y) ;
  1. N YEAR,MONTH,HDR,LENOFDT
  1. S HDR=$$FMTE^XLFDT(Y,"1D")
  1. S MONTH=$P(HDR," ")
  1. S LENOFDT=$L(HDR," ")
  1. S YEAR=$P(HDR," ",LENOFDT)
  1. Q MONTH_" "_YEAR
  1. ;
  1. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  1. ;
  1. WEEKDAY1(ZDATE) ;get the weekday of the 1st day of the month
  1. ; INPUT: ZDATE - FileMan date, used as the month to display
  1. ; OUTPUT: return - Integer corresponding to day of week
  1. ; (i.e. Sunday[1], Monday[2]) for the 1st day of
  1. ; the month
  1. S ZDATE=$E(ZDATE,1,5)_"01"
  1. Q $$DOW^XLFDT(ZDATE,1)
  1. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  1. ;
  1. DAYSINMO(Y,M) ; Return # of days in month based on year and month
  1. ; Input: Y = year in 4 digit format between 1700 and 3000
  1. ; M = month expressed as an integer from 1 to 12 (Jan - Dec)
  1. ;
  1. N GOODY,GOODM S (GOODY,GOODM)=0
  1. I Y<2700,Y>1700 S GOODY=1
  1. I M>0,M<13 S GOODM=1
  1. Q:'(GOODM&GOODY) 0
  1. Q $P("31^"_(28+$$LEAPYR^PRSLIB00(YEAR))_"^31^30^31^30^31^31^30^31^30^31",U,MONTH)