source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SDCLAV1.m@ 1608

Last change on this file since 1608 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 7.5 KB
Line 
1SDCLAV1 ;ALB/LDB - OUTPUT PATTERNS (cont.) ; 9/1/00 10:57am
2 ;;5.3;Scheduling;**140,167,168,76,383,463,490,517**;Aug 13, 1993;Build 4
3 ;
4 ;PATCH 383 STOPPED REPORT FROM CREATING AVAILIBILTY-TEH
5 ;
6S2 N I1,SC,SDAV,SDMED,SI,SL,SM,SS,STARTDAY,SDDD,YCNT,SDFRST
7 S P=0 F D=0:0 S D=$O(^UTILITY($J,"SDNMS",D)) Q:D'>0!(SDUP) S SDV="",SDZ2=SDBD F X5=0:0 S SDV=$O(^UTILITY($J,"SDNMS",D,SDV)) Q:SDV=""!SDUP S SDC=$P(^UTILITY($J,"SDNMS",D,SDV),"^",3) D S ;Q:SDUP ;D WR ;,SS
8 Q
9S1 S SD=^SC(SDC,0),D=$S($P(SD,"^",15):$P(SD,"^",15),1:$P(^DG(43,1,"GL"),"^",3)),SD5=0,SDNM=$P(SD,"^")
10 S $P(^UTILITY($J,"SDNMS",D,SDNM),"^",3)=SDC Q
11S I '$D(^SC(SDC,"SL")) D SDM,HDR W !!,"THIS CLINIC DOES NOT HAVE APPT. LENGTH" Q
12 S (SDZ,SDZ2)=SDBD D SDM,HDR,TIME S SDZ=SDBD-1,SD0=0,SDMED=SDED+.9
13 N X,SDSOH S SC=+SDC,SL=^SC(SC,"SL"),X=$P(SL,U,3),STARTDAY=$S($L(X):X,1:8),X=$P(SL,U,6),SI=$S(X="":4,X<3:4,X:X,1:4),X=SDBD,SDSOH=$P(SL,"^",8),SM=$S($E(X,4,5)[12:$E(X,1,3)+1_"01",1:$E(X,1,3)_$E(X,4,5)+1)_"00",SDZ=SDBD
14 N POP S POP=0 ;SD/517
15LOOP D SDM D:0&$E(SDZ,2,5)=$E(SDZ1,2,5) MON I $E(SDZ,2,5)'=$E(SDZ1,2,5) I 'SDUP D X1 I 'SDUP D A I 'SDUP D:SD0!($E(IOST,1,2)="C-") 3 I 'SDUP D WR I 'SDUP,$E(IOST,1,2)="C-" D 3
16 D:POP MSG ;SD/517
17 I 'SDUP I X<SDED S (X,SDZ2)=$S($E(X,4,5)=12:$E(X,1,3)+1_"01",1:$E(X,1,5)+1)_"01",SDZ=X D SDM,HDR,TIME G LOOP
18 D:POP MSG ;SD/517
19 Q
20 ;
21MSG ;Added SD/517
22 D WARN
23 Q
24 ;
25SS Q:SDUP S SDZ=SDZ1,SD5=1
26 D A Q:SDUP D 3 Q:SDUP D WR Q:SDUP D:$E(IOST,1,2)="C-" 3 Q
27MON Q:'$D(^SC(+SDC,"ST",SDZ,1)) S SDPT=^SC(+SDC,"ST",SDZ,1) D SDPT1
28 Q
29SDPT1 I YCNT+6>IOSL D:$E(IOST,1,2)="C-" 3 Q:SDUP D HDR,TIME
30 W !,SDPT S SDAP=SDZ-1 F Z=1:1 S SDAP=$O(^SC(SDC,"S",SDAP)) Q:SDAP'>0!(SDAP>(SDZ+.9999))!SDUP D NM^SDCLAV0
31 D YCNT
32 Q
33TIME S Z5=$P(^SC(+SDC,"SL"),U,3),SDT=$S(Z5:Z5,1:8),Z5=$P(^("SL"),U,6),SDI=$S(Z5="":4,Z5<3:4,Z5:Z5,1:4)
34 W !!," TIME",?SDI+SDI-1 F Z6=SDT:1:65\(SDI+SDI)+SDT W $E("|"_$S('Z6:0,1:(Z6-1#12+1))_" ",1,SDI+SDI)
35 W !," DATE",?SDI+SDI-1,"|" K J F Z7=0:1:6 I $D(^SC(+SDC,"T"_Z7)) S J(Z7)=""
36 S YCNT=YCNT+3
37 F Z8=1:1:65\(SDI+SDI) W $J("|",SDI+SDI)
38 Q
39WR N X S (Y3,X1,SDC1,SD0)=0,C=SDZ2
40 F S8=C:0 S SDC1=SDC1+1,C=$O(^UTILITY($J,"SDNMS",D,SDV,C)) Q:C'>0!(C>SDMED&('SD5))!SDUP S SD0=1 D:SDC1=1 HDR1 S X=C D DW^%DTC S Y=C X ^DD("DD") S Y1=$P(Y,"@"),Y2=$P(Y,"@",2),X9=X W:Y1'=Y3 !!,?1,X9,?11,Y1 D WR1 Q:SDUP
41 Q:SDUP I 'SD0 D HDR1 W !!,"No appointments scheduled"
42 D:SD0 WR2 S SDZ2=SDZ Q ;SD/517
43WR1 S X4="" F X1=0:0 S X4=$O(^UTILITY($J,"SDNMS",D,SDV,C,X4)) Q:X4=""!SDUP S X6="" F X2=0:0 S X6=$O(^UTILITY($J,"SDNMS",D,SDV,C,X4,X6)) Q:X6="" D W1
44 Q
45 ;
46WR2 ;Added SD/517
47 D 3 W @IOF D HDR1,DAT
48 D A1^SDCLAV
49 Q
50 ;
51HDR N X D NOW^%DTC S Y=$E(%,1,12) X ^DD("DD") S YCNT=1 W @IOF,!?52,Y D:$E(IOST,1,2)="P-" PG^SDCLAV
52 I $D(^DG(43,1,"GL")),$P(^("GL"),"^",2) W !?30,$P(^DG(40.8,D,0),"^")
53 W !?30,SDV,!?30,SDM," ",($E(SDZ,1,3)+1700) S YCNT=4 Q
54HDR1 S SDZ2=$S(SDZ2=0:SDBD,SDZ2>SDED:SDED,1:SDZ2) W !!,?30,SDV,!,?30,$P(SDM1,"^",+$E(SDZ2,4,5))," ",($E(SDZ2,1,3)+1700) S YCNT=YCNT+3 Q
55SDM S SDM1="JANUARY^FEBRUARY^MARCH^APRIL^MAY^JUNE^JULY^AUGUST^SEPTEMBER^OCTOBER^NOVEMBER^DECEMBER",SDM=$P(SDM1,"^",+($E(SDZ,4,5))) Q
56W S SDUT=^UTILITY($J,"SDNMS",D,SDV,C,X4,X6) S D1="" F D8=2,3 S D1=$S($P(SDUT,"^",D8)]"":$P(SDUT,"^",D8),1:"")_D1
57 W D1 Q
58W1 ;added next 2 lines and changed 3rd line SD/517
59 S X=C X ^DD("FUNC",2,1)
60 I +^UTILITY($J,"SDNMS",D,SDV,C,X4,X6)=0 S X="**WARNING** "_X D W2 Q
61 D TAB W:T ?10 W:'T ?11 W X,?20,X4,?51,X6 D MIN W ?61,"("_M1_") MINUTES" D W S Y3=Y1,X1=X9 I YCNT+6>IOSL D 3 Q:SDUP D HDR1,DAT
62 Q
63 ;
64W2 ;added SD/517
65 S POP=1
66 D TAB W:T ?1 W:'T ?2 W X,?23,X4,?51,X6 D MIN W ?61,"("_M1_") MINUTES" D W S Y3=Y1,X1=X9 I YCNT+6>IOSL D 3 Q:SDUP D HDR1,DAT
67 Q
68WARN ;added SD/517
69 W @IOF,! D:$E(IOST,1,2)="P-" PG^SDCLAV
70 D HDR1,DAT
71 W !!,"*************************************************************************"
72 W !,"* WARNING: There is a data inconsistency or data corruption problem *"
73 W !,"* with one or more of the above appointments. These appointments will *"
74 W !,"* have WARNING displayed to the left of the time. Corrective action *"
75 W !,"* needs to be taken. Please cancel any of the appointments above, which *"
76 W !,"* have the WARNING display. If any of them are valid appointments, they *"
77 W !,"* will have to be re-entered via Appointment Management. *"
78 W !,"**************************************************************************"
79 D 3
80 S POP=0
81 Q
82 ;
833 N X I $E(IOST,1,2)="C-" F X=$Y:1:IOSL-6 W ! D YCNT
84 I R !!,"PRESS RETURN TO CONTINUE OR ^ TO QUIT ",SDU:DTIME S:SDU="^"!('$T) SDUP=1
85 I YCNT+6'<IOSL,'SDUP W @IOF,! S YCNT=1 D:$E(IOST,1,2)="P-" PG^SDCLAV Q
86 Q
87A N X D:YCNT+13>IOSL 3 Q:SDUP D INAC^SDCLAV W !!!,"FOR CLINIC AVAILABILITY PATTERNS:"
88 W !!?4,"0-9 and j-z",?15," --denote available slots where j=10,k=11...z=26",!?12,"A-W",?15," --denote overbooks with A being the first slot to be overbooked",!?18,"and B being the second for that same time, etc."
89 W !?6,"*,$,!,@,#",?15," --denote overbooks or appts. that fall outside of a clinic's",!?18,"regular hours" S YCNT=YCNT+8 Q
90TAB W ! S:$L(X)>7 T=1 S:$L(X)<8 T=0 D YCNT Q
91MIN S M1=+^UTILITY($J,"SDNMS",D,SDV,C,X4,X6) Q
92DAT I $E($O(^UTILITY($J,"SDNMS",D,SDV,C)),2,7)=$E(C,2,7) W !,?1,X1,?11,Y1 D YCNT
93 Q
94X1 S X1=X\100_$P("31^28^31^30^31^30^31^31^30^31^30^31",U,$E(X,4,5))
95 S X1=$$LEAP(X1) I X1>SDED S X1=SDED
96 S SDMED=X1+.9,SDAP=X-.01 F S SDAP=$O(^SC(SDC,"S",SDAP)) Q:SDAP'>0!(SDAP>(X1+.9999))!SDUP D NM^SDCLAV0
97 D DOW S SDDD=Y
98WW ;
99 I '$D(^SC(+SC,"ST",X,1)),$$CHKDT() S Y=SDDD#7 G L:'$D(J(Y)),H:$D(^HOLIDAY(X))&('SDSOH) S SS=+$O(^SC(+SC,"T"_Y,X)) G L:SS'>0,L:^(SS,1)="" D
100 .S ^SC(+SC,"ST",$P(X,"."),1)=$E($P($T(DAY),U,Y+2),1,2)_" "_$E(X,6,7)_$J("",SI+SI-6)_^(1),^(0)=$P(X,".")
101 ;SD*5.3*490 added GOTO command so dates prior to clinic start date no
102 ;longer display on grid
103 S SDAV=1 D:X>SM WM I $D(^SC(+SC,"ST",X,1)),^(1)["["!(^(1)["CANCELLED")!($D(^HOLIDAY(X))) G:X<$O(^SC(+SC,"T",0)) L W !,$E(^SC(+SC,"ST",X,1),1,80) D YCNT S:'$D(^HOLIDAY(X))&('SDAV) SDAV=1
104 I YCNT+6>IOSL D 3 Q:SDUP D HDR
105L S X=X+1,SDDD=SDDD+1
106 G WW:X'>X1 Q
107 ;
108WM W !?36 S Y=$E(X,1,5)_"00",SM=$S($E(X,4,5)[12:$E(X,1,3)+1_"01",1:$E(X,1,3)_$E(X,4,5)+1)_"00" D YCNT
109DT W $$FMTE^XLFDT(Y) Q
110 ;
111DOW S Y=$$DOW^XLFDT(X,1) Q
112YCNT S YCNT=YCNT+1 Q
113 ;
114DAY ;;^SUN^MON^TUES^WEDNES^THURS^FRI^SATUR
115DIFF S X1=SDRE,X2=X D ^%DTC S SDDD=SDDD+X,X=SDRE,X1=X\100_28 Q
116H S ^SC(+SC,"ST",X,1)=" "_$E(X,6,7)_" "_$P(^(X,0),U,2),^(0)=X G WW
117 ;
118LEAP(SDEOM) ;Check for leap year, adjust if indicated
119 ;Input: SDEOM=end of month date to adjust for leap year
120 Q:$E(SDEOM,4,5)'="02" SDEOM ; only adjust February
121 N SDLEAP
122 S SDLEAP=$$FMADD^XLFDT(SDEOM,1)
123 Q $S($E(SDLEAP,4,5)="02":SDLEAP,1:SDEOM)
124CHKDT() ;
125 N Y,RET,SDFA
126 I '$D(SDFRST(D,+SC)) D
127 .; Create array of days that have a current template.
128 .N %H,X,SDFMTDAY,SDAYCNT,SDAYI,SDST,SDAYCHK,SDAYNAM,SDAYNUM
129 .S %H=$H
130 .D YX^%DTC S SDFMTDAY=X
131 .S SDAYCNT=0
132 .F SDAYI=0:1:6 D
133 ..Q:'$D(^SC(+SC,"T"_SDAYI))
134 ..I $O(^SC(+SC,"T"_SDAYI,""),-1)'<SDFMTDAY S SDFRST(D,+SC,SDAYI)="",SDAYCNT=SDAYCNT+1
135 .; Calculate first available date for each day that has current template.
136 .S SDST=0,SDAYCHK=0
137 .F S SDST=$O(^SC(+SC,"ST",SDST)) Q:SDST=""!(SDAYCHK=SDAYCNT) D
138 ..S SDAYNAM=$E($G(^SC(+SC,"ST",SDST,1)),1,2)
139 ..S SDAYNUM=$S(SDAYNAM="MO":1,SDAYNAM="TU":2,SDAYNAM="WE":3,SDAYNAM="TH":4,SDAYNAM="FR":5,SDAYNAM="SA":6,SDAYNAM="SU":0,1:"")
140 ..Q:SDAYNUM=""
141 ..Q:$G(SDFRST(D,+SC,SDAYNUM))'=""
142 ..Q:'$D(^SC(+SC,"T"_SDAYNUM))
143 ..S SDFRST(D,+SC,SDAYNUM)=SDST,SDAYCHK=SDAYCHK+1
144 ; Get first avail date from array for particular day of week
145 S Y=SDDD#7,RET=0
146 S SDFA=$G(SDFRST(D,+SC,Y))
147 I SDFA'="" D
148 .S SDFA=$S(+$H>SDFA:+$H,1:SDFA)
149 .I X'<SDFA S RET=1
150 Q RET
Note: See TracBrowser for help on using the repository browser.