source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SDWLRSRS.m@ 1203

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

initial load of FOIAVistA 6/30/08 version

File size: 5.2 KB
Line 
1SDWLRSRS ;;IOFO BAY PINES/OG/WAIT LIST STAT REPORT - SORT ; Compiled September 22, 2005 10:32:25
2 ;;5.3;scheduling;**415,469,446**;AUG 13 1993;Build 77
3 ;
4 ; Original routine SDWLRSR exceeded SACC maximum size of 10000.
5 ; This new routine added to do the Sort portion of the report.
6 ;
7 ;
8SORT(SDWLBD,SDWLED,SDWLINS,SDWL) ;SORT AND CALCULATE STAT REPORT ;SD*5.3*415
9 N SDWLAD,SDWLC,SDWLCC,SDWLD,SDWLDA,SDWLDFDT,SDWLDFN,SDWLDIS,SDWLDP,SDWLER,SDWLERR,SDWLFLD,SDWLFLG,SDWLINSN,SDWLNC,SDWLNN,SDWLNR,SDWLOFDT
10 N SDWLOK1,SDWLOK3,SDWLPR,SDWLPRI,SDWLRDT,SDWLRE,SDWLSA,SDWLTR,SDWLTYNM,SDWLTYP,SDWLTYPN,SDWLX,SDWLX1,SDWLY1,SDWLCL ;SD*5.3*446
11 K ^TMP("SDWLRSR1",$J),^TMP("SDWLRSR2",$J) S (SDWLERR,SDWLPR,SDWLC,SDWLD,SDWLNC,SDWLSA,SDWLCC,SDWLNN,SDWLER,SDWLTR,SDWLCL,SDWLAD,SDWLRE,SDWLNR)=0 ;SD*5.3*446
12 S SDWLDA=0 F S SDWLDA=$O(^SDWL(409.3,SDWLDA)) Q:SDWLDA="" D
13 .I $D(DUOUT) Q
14 .S SDWLX=$G(^SDWL(409.3,SDWLDA,0)) Q:SDWLX="" S SDWLINSN=+$P(SDWLX,U,3) I 'SDWLINSN Q
15 .S SDWLPRI=$P(SDWLX,U,11) I SDWLPRI="" S SDWLPRI="U"
16 .S SDWLDFN=+SDWLX I 'SDWLDFN Q
17 .S SDWLTYP=$P(SDWLX,U,5),SDWLTYPN=$S(SDWLTYP=1:$P(SDWLX,U,6),SDWLTYP=2:$P(SDWLX,U,7),SDWLTYP=3:$P(SDWLX,U,8),SDWLTYP=4:$P(SDWLX,U,9),1:"")
18 .I SDWLTYPN="" Q
19 .S SDWLFLD=$S(SDWLTYP=1:5,SDWLTYP=2:6,SDWLTYP=3:7,SDWLTYP=4:8)
20 .S SDWLTYNM=$$EXTERNAL^DILFD(409.3,SDWLFLD,,SDWLTYPN) I SDWLTYNM="" S SDWLTYNM="UNKNOWN"
21 .I 'SDWLINSN Q
22 .I $D(SDWL("INS")) D
23 ..;CHECK FOR SPECIFIC INSTITUTIONAL SORT
24 ..S SDWLINS=$P(SDWLX,U,3),SDWLERR=0 I SDWLINS'="ALL",'$D(SDWL("INS",SDWLINS)) S SDWLERR=1 Q
25 ..S SDWLPRI=$P(SDWLX,U,11) I SDWLPRI="" S SDWLPRI="N"
26 .I SDWLERR Q
27 .;CHECK DATE RANGE
28 .S SDWLOFDT=$P(SDWLX,U,2),SDWLOK1=1 I SDWLOFDT>SDWLBD!(SDWLOFDT=SDWLBD) D
29 ..I SDWLOFDT<SDWLED!(SDWLOFDT=SDWLED) S SDWLOK1=0
30 .S SDWLX1=$P(^DIC(4,+$P(SDWLX,U,3),0),U,1),SDWLY1=SDWLTYP
31 .S:'$D(^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"AD")) ^("AD")=0
32 .S:'$D(^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"AD")) ^("AD")=0
33 .I 'SDWLOK1 D S1
34 .S:'$D(^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"NR")) ^("NR")=0
35 .S:'$D(^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"NR")) ^("NR")=0
36 .S SDWLDFDT=0,SDWL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DWLX,U,14) D
53 ..S SDWLRDT=$P(SDWLX,U,14)
54 ..Q:SDWLRDT<SDWLBD Q:SDWLRDT>SDWLED D
55 ...S:'$D(^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"NR")) ^("NR")=0
56 ...S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"NR")=^("NR")+1
57 ...S:'$D(^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"NR")) ^("NR")=0
58 ...S ^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"NR")=^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"NR")+1
59 .D S2
60 .I $$S^%ZTLOAD S DUOUT=""
61 Q
62S1 ;ORIGINATING DATE MEETS CRITERIA
63 ;
64 S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"AD")=^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"AD")+1
65 S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"AD")=^("AD")+1
66 Q
67S2 ;DO NOT REMOVE DATE MEETS CRITERIA
68 ;
69 N X1,X2,X3,X4
70 S X1=^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"PR"),X2=$G(^("AD")),X3=$G(^("CL")) S X4=X1+X2-X3
71 S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"RR")=($G(^("PR"))+($G(^("AD"))))-$G(^("CL"))
72 S ^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"NR")=^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"NR")+1
73 Q
74S3 S SDWLDIS=^SDWL(409.3,SDWLDA,"DIS") D
75 .N X
76 .S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"CL")=^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,"CL")+1
77 .S ^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"CL")=^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,"CL")+1
78 .S SDWLDP=$P(SDWLDIS,U,3),X="SDWL"_SDWLDP,@X=@X+1 S:'$D(^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,X)) ^(X)=0
79 .S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,X)=^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,X)+1
80 .S:'$D(^TMP("SDWLRSR2",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,X)) ^(X)=0
81 .S ^TMP("SDWLRSR1",$J,SDWLX1,SDWLY1,SDWLTYPN,SDWLTYNM,SDWLPRI,SDWLDFN,X)=^(X)+1
82 Q
Note: See TracBrowser for help on using the repository browser.