source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCRPW3.m@ 1582

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

initial load of WorldVistAEHR

File size: 7.3 KB
Line 
1SCRPW3 ;RENO/KEITH - Clinic Utilization Statistical Summary (cont.) ; 14 May 99 10:45 PM
2 ;;5.3;Scheduling;**139,144,184,194**;AUG 13, 1993
3START ;Print statistics
4 F S SDCLN=$O(^TMP("SCRPW",$J,SDIV,1,SDCLN)) Q:SDCLN=""!SDOUT S SDCL=0 F S SDCL=$O(^TMP("SCRPW",$J,SDIV,1,SDCLN,SDCL)) Q:'SDCL!SDOUT D CLINE
5 Q:SDOUT D:$Y>(IOSL-12) FOOT^SCRPW2,HDR^SCRPW2 Q:SDOUT W ! F SDI=1:1:8 W ?(22+(SDI*10)),"--------"
6 W ?112,"--------- ---------",!,"*** CLINIC TOTALS ***" S SDCT=SDTAP_U_SDTOB_U_SDTSL_U_SDTNS_U_SDTVSL_U_SDTNSVS_U_SDTOS
7 D F1 D FOOT^SCRPW2 Q:'$D(^TMP("SCRPW",$J,SDIV,2))
8 D HDR^SCRPW2 Q:SDOUT W !!,"*** PROVIDER SUMMARY (based on clinic default provider definition) ***"
9 S SDPRN="" F S SDPRN=$O(^TMP("SCRPW",$J,SDIV,2,SDPRN)) Q:SDPRN=""!SDOUT S SDPR=0 F S SDPR=$O(^TMP("SCRPW",$J,SDIV,2,SDPRN,SDPR)) Q:'SDPR!SDOUT D PLINE
10 Q:SDOUT D FOOT^SCRPW2
11 Q
12 ;
13STOP ;Check for stop task request
14 S:$G(ZTQUEUED) (SDOUT,ZTSTOP)=$S($$S^%ZTLOAD:1,1:0)
15 Q
16 ;
17AC ;Evaluate all clinics
18 S SDCL=0 F S SDCL=$O(^SC(SDCL)) Q:'SDCL S SDCL0=^SC(SDCL,0),SDIV=$P(SDCL0,U,15),SDAC=0 I $$DIV() D STOP Q:SDOUT D A1 D:SDAC CNT,SET
19 Q
20 ;
21A1 Q:$P(SDCL0,U,3)'="C" S SDCLI=$G(^SC(SDCL,"I")) Q:(($P(SDCLI,U)>0)&($P(SDCLI,U)<SDBDAY)&($P(SDCLI,U,2)=""!($P(SDCLI,U,2)>SDEDAY))) S SDAC=1
22 Q
23 ;
24SC ;Evaluate selected clinics
25 S SDCL=0 F S SDCL=$O(SDCL(SDCL)) Q:'SDCL S SDCL0=^SC(SDCL,0),SDIV=$P(SDCL0,U,15),SDAC=0 I $$DIV() D STOP Q:SDOUT D A1 D:SDAC CNT,SET
26 Q
27 ;
28RC ;Evaluate a range of clinics
29 S SDCLN=$O(SDCL("")),SDECL=$O(SDCL(SDCLN)),SDCL=SDCL(SDCLN),SDCL0=^SC(SDCL,0),SDIV=$P(SDCL0,U,15),SDAC=0 I $$DIV() D STOP Q:SDOUT D A1 D:SDAC CNT,SET
30 F S SDCLN=$O(^SC("B",SDCLN)) Q:(SDCLN=""!(SDCLN]SDECL)) S SDCL=0 F S SDCL=$O(^SC("B",SDCLN,SDCL)) Q:'SDCL S SDCL0=^SC(SDCL,0),SDIV=$P(SDCL0,U,15),SDAC=0 I $$DIV() D STOP Q:SDOUT D A1 D:SDAC CNT,SET
31 Q
32 ;
33RS ;Evaluate a range of stop codes
34 S SDBCS=$O(SDCL("")),SDECS=$O(SDCL(SDBCS)),SDCL=0 S:'SDECS SDECS=SDBCS F S SDCL=$O(^SC(SDCL)) Q:'SDCL S SDCL0=^SC(SDCL,0),SDIV=$P(SDCL0,U,15),SDAC=0 I $$DIV() D STOP Q:SDOUT D A1 D:SDAC RC1
35 Q
36 ;
37RC1 S SDCSC=$P(SDCL0,U,7),SDCSC=$P($G(^DIC(40.7,+SDCSC,0)),U,2) Q:('SDCSC!(SDCSC<SDBCS!(SDCSC>SDECS))) D CNT,SET
38 Q
39 ;
40CG ;Evaluate by clinic group
41 S SDCG=$O(SDCL(0)),SDCL=0 F S SDCL=$O(^SC("ASCRPW",SDCG,SDCL)) Q:'SDCL S SDCL0=^SC(SDCL,0),SDIV=$P(SDCL0,U,15),SDAC=0 I $$DIV() D STOP Q:SDOUT D A1 D:SDAC CNT,SET
42 Q
43 ;
44DIV() ;Check division
45 S:'$L(SDIV) SDIV=$$PRIM^VASITE()
46 Q:'SDDIV 1 Q $D(SDDIV(+SDIV))
47 ;
48CNT ;Evaluate a clinic
49 S SDDAY=SDBDAY-1,(SDVSL,SDAP,SDF1,SDOB,SDSL,SDNS,SDNSVS,SDOS)=0,SDLAP=$P($G(^SC(SDCL,"SL")),U)
50 D SPAT(SDCL,SDBDAY,SDMAX),CCPAT S SDOB=SDAP-SDSL S:SDOB<0 SDOB=0
51 Q
52 ;
53CCPAT ;Count clinic patterns and patients
54 F S SDDAY=$O(^TMP(SDSUB,$J,SDCL,"ST",SDDAY)) Q:('SDDAY!(SDDAY>SDEDAY)) D CTPAT(SDDAY)
55 S SDDAY=SDBDAY F S SDDAY=$O(^SC(SDCL,"S",SDDAY)) Q:('SDDAY!(SDDAY>SDEDAY)) S SDI=0 F S SDI=$O(^SC(SDCL,"S",SDDAY,1,SDI)) Q:'SDI S SDCP0=$G(^SC(SDCL,"S",SDDAY,1,SDI,0)) D:$L(SDCP0) ACT
56 Q
57 ;
58CTPAT(SDDAY) ;Count slots in availability pattern and master pattern
59 ;Input: SDDAY=date to evaluate
60 N SDPATT,SDPCT
61 S SDPATT=$E($G(^TMP(SDSUB,$J,SDCL,"ST",SDDAY,1)),6,999) Q:SDPATT'["["
62 S SDF1=1,SDOS=SDOS+$$PCT(SDPATT)
63 S SDPATT=$E($G(^SC(SDCL,"OST",SDDAY,1)),6,999) I $L(SDPATT) S SDSL=SDSL+$$PCT(SDPATT) Q
64 N X,%H,%T,%Y,SDDW,SDMPDT
65 S X=SDDAY D H^%DTC S SDDW="T"_%Y,SDMPDT=$O(^SC(SDCL,SDDW,SDDAY))
66 I SDMPDT S SDPATT=$G(^SC(SDCL,SDDW,SDMPDT,1)),SDPCT=$$PCT(SDPATT) I SDPCT S SDSL=SDSL+SDPCT
67 Q
68 ;
69PCT(SDPATT) ;Pattern count
70 ;Input: SDPATT=pattern to evaluate
71 N X,I S X=0
72 S SDPATT=$TR(SDPATT," |[]","")
73 F I=1:1:$L(SDPATT) S X=X+$G(SD($E(SDPATT,I)))
74 Q X
75 ;
76SET ;Set stats into ^TMP global
77 S SDPR=0 I SDF1 S SDPR=$O(^SC("ADPR",SDCL,SDPR)),SDPR=$P($G(^SC(SDCL,"PR",+SDPR,0)),U) I SDPR S SDPRN=$P($G(^VA(200,SDPR,0)),U) S:'$L(SDPRN) SDPR=0
78 D SET1(SDIV) D:SDMD SET1(0)
79 Q
80 ;
81SET1(SDIV) S ^TMP("SCRPW",$J,SDIV,1,$P(SDCL0,U),SDCL)=$S('SDF1:"",1:SDAP_U_SDOB_U_SDSL_U_SDNS_U_SDVSL_U_SDNSVS_U_SDOS)
82 Q:'SDPR S SDPCT=$G(^TMP("SCRPW",$J,SDIV,2,SDPRN,SDPR))
83 S ^TMP("SCRPW",$J,SDIV,2,SDPRN,SDPR)=($P(SDPCT,U)+SDAP)_U_($P(SDPCT,U,2)+SDOB)_U_($P(SDPCT,U,3)+SDSL)_U_($P(SDPCT,U,4)+SDNS)_U_($P(SDPCT,U,5)+SDVSL)_U_($P(SDPCT,U,6)+SDNSVS)_U_($P(SDPCT,U,7)+SDOS)
84 Q
85 ;
86CLINE ;Print a clinic statistics line
87 D:$Y>(IOSL-12) FOOT^SCRPW2,HDR^SCRPW2 Q:SDOUT S SDCT=^TMP("SCRPW",$J,SDIV,1,SDCLN,SDCL) W !!,SDCLN I '$L(SDCT) W " (No ava. found)" Q
88 D F1 S SDTAP=SDTAP+SDAP,SDTOB=SDTOB+SDOB,SDTSL=SDTSL+SDSL,SDTNS=SDTNS+SDNS,SDTVSL=SDTVSL+SDVSL,SDTNSVS=SDTNSVS+SDNSVS,SDTOS=SDTOS+SDOS
89 Q
90 ;
91F1 S SDAP=$P(SDCT,U),SDOB=$P(SDCT,U,2),SDSL=$P(SDCT,U,3),SDNS=$P(SDCT,U,4),SDVSL=$P(SDCT,U,5),SDNSVS=$P(SDCT,U,6),SDOS=$P(SDCT,U,7)
92 W ?32,$J(SDAP,8),?42,$J(SDVSL,8),?52,$J(SDNS,8),?62,$J(SDNSVS,8),?72,$J(SDOB,8),?82,$J(SDOS,8),?92,$J((SDSL-SDAP-SDVSL),8)
93 S SDCAP=SDSL W ?102,$J(SDCAP,8),?112,$J($S(SDCAP=0:0,1:(SDAP+SDVSL*100)/SDCAP),8,2),"%"
94 W ?123,$J($S(SDCAP=0:0,1:((SDAP+SDVSL-SDNS-SDNSVS)*100)/SDCAP),8,2),"%"
95 Q
96 ;
97PLINE ;Print a provider statistics line
98 D:$Y>(IOSL-12) FOOT^SCRPW2,HDR^SCRPW2 Q:SDOUT S SDCT=^TMP("SCRPW",$J,SDIV,2,SDPRN,SDPR) W !!,SDPRN," (",SDPR,")" D F1
99 Q
100 ;
101ACT ;Count appointments, addl. variable appt. slots and no-shows
102 Q:$P(SDCP0,U,9)="C" ;Quit if cancelled
103 S SDPLAP=$P(SDCP0,U,2),SDPESL=0 I SDLAP,SDPLAP>SDLAP S SDPESL=SDPLAP\SDLAP-1,SDVSL=SDVSL+SDPESL
104 S SDAP=SDAP+1,SDF1=1
105 S SDPAS=^DPT($P(SDCP0,U),"S",SDDAY,0),SDPAS=$P(SDPAS,U,2) Q:SDPAS="" S:"NA"[SDPAS SDNS=SDNS+1,SDNSVS=SDNSVS+SDPESL
106 Q
107 ;
108SPAT(SC,SDSTRTDT,MAX,SDS) ;Set patterns into ^TMP (modified clone of OVR^SDAUT1)
109 ;Input: SC=clinic ifn
110 ;Input: SDSTRTDT=start date for gathering patterns
111 ;Input: MAX=number of days beyond start date to gather patterns
112 ;Input: SDS=array namespace subscript value (optional)
113 ;Output: array of clinic current availability patterns in
114 ; ^TMP(SDS,$J,clinic_ifn,"ST",date,1)
115 ;
116 S SDS=$G(SDS) S:'$L(SDS) SDS="SDTMP" K ^TMP(SDS,$J)
117 N SI,SDIN,SDRE,SDSOH,ENDATE,X,X1,X2,SM,I,D,J,Y,SS,DAY
118 S SDIN=$G(^SC(SC,"I")),SDRE=$P(SDIN,U,2),SDIN=$P(SDIN,U)
119 S DAY="SU^MO^TU^WE^TH^FR^SA"
120 S SI=$P($G(^SC(SC,"SL")),U,6),SI=$S(SI<3:4,1:SI)
121 S SDSOH=$S('$D(^SC(SC,"SL")):0,$P(^SC(SC,"SL"),"^",8)']"":0,1:1)
122 S X1=SDSTRTDT,X2=MAX,SDIN=$G(SDIN) D C^%DTC S ENDATE=X,X=SDSTRTDT
123EN1 S:$O(^SC(SC,"T",0))>X X=$O(^SC(SC,"T",0))
124 S Y=$$DOW^XLFDT(X,1),I=Y+32,SM=X,D=Y D WM
125 K J F Y=0:1:6 I $D(^SC(+SC,"T"_Y)) S J(Y)=""
126 I '$D(J) D Q
127 .S D=SDSTRTDT-1 F S D=$O(^SC(SC,"ST",D)) Q:'D!(D>ENDATE) D
128 ..S X=$G(^SC(SC,"ST",D,1)) S:$L(X) ^TMP(SDS,$J,SC,"ST",D,1)=X Q
129 .Q
130X1 Q:X>ENDATE S X1=X\100_28
131 I '$$ACTIVE(X,SDIN,SDRE) S X1=X,X2=1 D C^%DTC G X1
132W S X=X\1
133 I $D(^SC(+SC,"ST",X,1)) S ^TMP(SDS,$J,SC,"ST",X,1)=^SC(+SC,"ST",X,1) G W1
134 I '$D(^SC(SC,"ST",X,1)) S Y=D#7 G L:'$D(J(Y)),H:$D(^HOLIDAY(X))&('SDSOH) S SS=$O(^SC(SC,"T"_Y,X)) G L:SS<1,L:^SC(SC,"T"_Y,SS,1)="" D
135 .S ^TMP(SDS,$J,SC,"ST",X\1,1)=$P(DAY,U,Y+1)_" "_$E(X,6,7)_$J("",SI+SI-6)_^SC(SC,"T"_Y,SS,1) Q
136W1 D WM:X>SM
137L Q:X>ENDATE S X=X+1,D=D+1 G W:X'>X1 S X2=X-X1 D C^%DTC G X1
138 ;
139H S ^TMP(SDS,$J,SC,"ST",X,1)=" "_$E(X,6,7)_" "_$P(^(X,0),U,2) G W1
140 ;
141WM S SM=$S($E(X,4,5)[12:$E(X,1,3)+1_"01",1:$E(X,1,3)_$E(X,4,5)+1)_"00" Q
142 ;
143ACTIVE(X,SDIN,SDRE) ;Determine if the clinic is active on a given date
144 ;Input: X=date to be examined
145 ;Input: SDIN=clinic inactive date
146 ;Input: SDRE=clinic reactivate date
147 ;Output: '1'=active, '0'=inactive
148 Q:'SDIN 1 Q:X<SDIN 1 Q:'SDRE 0 Q:X<SDRE 0 Q 1
Note: See TracBrowser for help on using the repository browser.