1 | FSCEVENP ;SLC/STAFF-NOIS Events Processing ;1/13/98 11:27
|
---|
2 | ;;1.1;NOIS;;Sep 06, 1998
|
---|
3 | EVENT(MODE,D0,FROM,TO) ; from FSCEVENT
|
---|
4 | N CNT,DATE,DESC,DOW,NEWDATE,NEXTDATE,NEXTDAY,NUM,OCC,OK,START,TYPE,ZERO K DESC
|
---|
5 | S ZERO=^FSC("REVENT",D0,0)
|
---|
6 | M DESC=^FSC("REVENT",D0,1)
|
---|
7 | S NUM=0 F S NUM=$O(^FSC("REVENT",D0,.5,NUM)) Q:NUM<1 S TYPE=+$G(^(NUM,0)) I TYPE D
|
---|
8 | TEST .;S FROM=2941201,TO=2951201,ZERO=1,DESC(0)=""
|
---|
9 | .;S TYPE=19 F S TYPE=$O(^FSC("ETYPE",TYPE)) Q:TYPE<1 W !,^(TYPE,0) D
|
---|
10 | .I TYPE=1 D DAILY Q
|
---|
11 | .I TYPE<20 D DOW Q
|
---|
12 | .I TYPE<70 D NUMDOW Q
|
---|
13 | .I TYPE<80 D ODD Q
|
---|
14 | .I TYPE<90 D EVEN Q
|
---|
15 | .I TYPE<100 D LAST Q
|
---|
16 | Q
|
---|
17 | ;
|
---|
18 | DAILY ;
|
---|
19 | S DATE=FROM F D Q:DATE>TO
|
---|
20 | .S DOW=$$DOW^XLFDT(DATE,1)
|
---|
21 | .I '(DOW=0!(DOW=6)) D TRANSFER(DATE,ZERO,.DESC)
|
---|
22 | .S DATE=$$FMADD^XLFDT(DATE,1)
|
---|
23 | Q
|
---|
24 | ;
|
---|
25 | DOW ;
|
---|
26 | S DOW=TYPE#10,START=0,DATE=FROM F D Q:START Q:DATE>TO
|
---|
27 | .I $$DOW^XLFDT(DATE,1)=DOW S START=DATE Q
|
---|
28 | .S DATE=$$FMADD^XLFDT(DATE,1)
|
---|
29 | I 'START Q
|
---|
30 | I DATE>TO Q
|
---|
31 | S DATE=START F D Q:DATE>TO
|
---|
32 | .D TRANSFER(DATE,ZERO,.DESC)
|
---|
33 | .S DATE=$$FMADD^XLFDT(DATE,7)
|
---|
34 | Q
|
---|
35 | ;
|
---|
36 | NUMDOW ;
|
---|
37 | S DOW=TYPE#10,OCC=$E(TYPE)-1,DATE=$E(FROM,1,5)_$S(OCC=1:"01",OCC=2:"08",1:(OCC-1)*7+1)
|
---|
38 | D LEAPCHK(.DATE)
|
---|
39 | I DATE>TO Q
|
---|
40 | S CNT=0 F D Q:DATE>TO
|
---|
41 | .I OCC=5,$E(DATE,6,7)'>28 S CNT=0 S DATE=$E(DATE,1,5)_"29" D LEAPCHK(.DATE) Q
|
---|
42 | .S CNT=CNT+1 I CNT>7 S CNT=0 D NEWDATE(.DATE) Q
|
---|
43 | .I DOW=$$DOW^XLFDT(DATE,1),DATE'<FROM S CNT=0 D TRANSFER(DATE,ZERO,.DESC),NEWDATE(.DATE) Q
|
---|
44 | .S DATE=$$FMADD^XLFDT(DATE,1)
|
---|
45 | Q
|
---|
46 | ;
|
---|
47 | NEWDATE(DATE) ;
|
---|
48 | S NEWDATE=$E(DATE,1,5)
|
---|
49 | I $E(NEWDATE,4,5)="12" S NEWDATE=$E(NEWDATE,1,3)+1_"01"
|
---|
50 | E S NEWDATE=NEWDATE+1
|
---|
51 | S DATE=NEWDATE_$S(OCC=1:"01",OCC=2:"08",1:(OCC-1)*7+1)
|
---|
52 | D LEAPCHK(.DATE)
|
---|
53 | Q
|
---|
54 | ;
|
---|
55 | LEAPCHK(DATE) ;
|
---|
56 | I $E(DATE,4,7)="0229" S DATE=$E(DATE,1,3)_"0228" S DATE=$$FMADD^XLFDT(DATE,1) I $E(DATE,4,5)="03" S DATE=$E(DATE,1,5)_$S(OCC=1:"01",OCC=2:"08",1:(OCC-1)*7+1)
|
---|
57 | Q
|
---|
58 | ;
|
---|
59 | EVEN ;
|
---|
60 | S DOW=TYPE#10,START=0,DATE=FROM F D Q:START Q:DATE>TO
|
---|
61 | .I $$DOW^XLFDT(DATE,1)=DOW S OK=1 D I 'OK Q
|
---|
62 | ..I '($$DOW^XLFDT(DATE,1)#2),$$FMDIFF^XLFDT(DATE,2950101)+1#2 S START=DATE,OK=0 Q
|
---|
63 | ..I $$DOW^XLFDT(DATE,1)#2,'($$FMDIFF^XLFDT(DATE,2950101)+1#2) S START=DATE,OK=0 Q
|
---|
64 | .S DATE=$$FMADD^XLFDT(DATE,1)
|
---|
65 | I 'START Q
|
---|
66 | I DATE>TO Q
|
---|
67 | S DATE=START F D Q:DATE>TO
|
---|
68 | .D TRANSFER(DATE,ZERO,.DESC)
|
---|
69 | .S DATE=$$FMADD^XLFDT(DATE,14)
|
---|
70 | Q
|
---|
71 | ;
|
---|
72 | ODD ;
|
---|
73 | S DOW=TYPE#10,START=0,DATE=FROM F D Q:START Q:DATE>TO
|
---|
74 | .I $$DOW^XLFDT(DATE,1)=DOW S OK=1 D I 'OK Q
|
---|
75 | ..I '($$DOW^XLFDT(DATE,1)#2),'($$FMDIFF^XLFDT(DATE,2950101)+1#2) S START=DATE,OK=0 Q
|
---|
76 | ..I $$DOW^XLFDT(DATE,1)#2,$$FMDIFF^XLFDT(DATE,2950101)+1#2 S START=DATE,OK=0 Q
|
---|
77 | .S DATE=$$FMADD^XLFDT(DATE,1)
|
---|
78 | I 'START Q
|
---|
79 | I DATE>TO Q
|
---|
80 | S DATE=START F D Q:DATE>TO
|
---|
81 | .D TRANSFER(DATE,ZERO,.DESC)
|
---|
82 | .S DATE=$$FMADD^XLFDT(DATE,14)
|
---|
83 | Q
|
---|
84 | ;
|
---|
85 | LAST ;
|
---|
86 | S DOW=TYPE#10,DATE=$$GETSTART(FROM)
|
---|
87 | I DATE>TO Q
|
---|
88 | F D Q:DATE>TO
|
---|
89 | .I DOW=$$DOW^XLFDT(DATE,1),DATE'<FROM D GETLAST(.DATE,.NEXTDATE),TRANSFER(DATE,ZERO,.DESC) S DATE=NEXTDATE Q
|
---|
90 | .I DATE>TO Q
|
---|
91 | .S DATE=$$FMADD^XLFDT(DATE,1)
|
---|
92 | Q
|
---|
93 | ;
|
---|
94 | GETLAST(DATE,NEXTDAY) ;
|
---|
95 | N NEWDATE
|
---|
96 | S NEWDATE=$$FMADD^XLFDT(DATE,7)
|
---|
97 | I $E(NEWDATE,4,5)=$E(DATE,4,5) S DATE=NEWDATE
|
---|
98 | I $E(DATE,4,5)="12" S NEXTDAY=$E(DATE,1,3)+1_"0122"
|
---|
99 | E S NEXTDAY=$E(DATE,1,3)_$E(DATE,4,5)+1_"22"
|
---|
100 | Q
|
---|
101 | ;
|
---|
102 | GETSTART(DATE) ; $$(date) -> next start date
|
---|
103 | I $E(DATE,6,7)<23 Q $E(DATE,1,5)_"22"
|
---|
104 | I $E(DATE,4,5)="01" Q $E(DATE,1,3)-1_"1222"
|
---|
105 | Q $E(DATE,1,3)_$E(DATE,4,5)-1_"22"
|
---|
106 | ;
|
---|
107 | TRANSFER(DATE,ZERO,DESC) ;
|
---|
108 | I MODE="DELETE" D Q
|
---|
109 | .N DA,DIK
|
---|
110 | .S DA=$$DUP(DATE,ZERO),DIK="^FSCD(""EVENTS"","
|
---|
111 | .I 'DA Q
|
---|
112 | .D ^DIK
|
---|
113 | .D DISPLAY
|
---|
114 | I $D(^FSCD("EVENTS","B",DATE)),$D(^FSCD("EVENTS","C",$P(ZERO,U))) I $$DUP(DATE,ZERO) Q
|
---|
115 | N DA,DIK,NUM
|
---|
116 | S NUM=1+$P(^FSCD("EVENTS",0),U,3)
|
---|
117 | L +^FSCD("EVENTS",0):30 I '$T Q ; *** needs ok
|
---|
118 | F Q:'$D(^FSCD("EVENTS",NUM,0)) S NUM=NUM+1
|
---|
119 | S ^FSCD("EVENTS",NUM,0)=DATE_U_ZERO
|
---|
120 | S $P(^FSCD("EVENTS",0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1
|
---|
121 | L -^FSCD("EVENTS",0)
|
---|
122 | M ^FSCD("EVENTS",NUM,1)=DESC
|
---|
123 | S DIK="^FSCD(""EVENTS"",",DA=NUM D IX1^DIK
|
---|
124 | D DISPLAY
|
---|
125 | Q
|
---|
126 | ;
|
---|
127 | DISPLAY W !,+$E(DATE,4,5),"/",+$E(DATE,6,7),"/",$E(DATE,2,3),?17,$P(ZERO,U)
|
---|
128 | Q
|
---|
129 | ;
|
---|
130 | DUP(DATE,ZERO) ; $$(date,zero node) -> # if duplicate, else ""
|
---|
131 | N NODE,NUM,OK
|
---|
132 | S OK=0,NODE=DATE_U_ZERO
|
---|
133 | S NUM=0 F S NUM=$O(^FSCD("EVENTS","B",DATE,NUM)) Q:NUM<1 D Q:OK
|
---|
134 | .I $G(^FSCD("EVENTS",NUM,0))=NODE S OK=1 Q
|
---|
135 | Q NUM
|
---|