source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SCRPW70.m@ 1446

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

initial load of FOIAVistA 6/30/08 version

File size: 9.6 KB
Line 
1SCRPW70 ;BP-CIOFO/KEITH,ESW - Clinic appointment availability extract ; 7/8/03 2:23pm
2 ;;5.3;Scheduling;**192,206,223,241,249,291**;AUG 13, 1993
3 N SDEX,SDDIV,DIR,SDFMT,SDFMTS,SDMAX,SDSORT,SDOUT,X,Y,DTOUT,DUOUT
4 N SDREPORT,SDEDT,SDBDT,SDPEDT,SDPBDT,SDPAT,SDPT,SDJN
5 S SDJN=$J
6 S (SDEX,SDOUT)=0
7 D TITL^SCRPW50("Clinic Appointment Availability Report")
8 I '$$DIVA^SCRPW17(.SDDIV) S SDOUT=1 G EXIT^SCRPW74
9 D SUBT^SCRPW50("**** Date Range Selection ****")
10 W ! S %DT="AEX",%DT("A")="Beginning date: " D ^%DT I Y<1 S SDOUT=1 G EXIT^SCRPW74
11 S SDBDT=Y X ^DD("DD") S SDPBDT=Y
12EDT S %DT("A")=" Ending date: " W ! D ^%DT I Y<1 S SDOUT=1 G EXIT^SCRPW74
13 I Y<SDBDT W !!,$C(7),"End date cannot be before begin date!",! G EDT
14 S SDEDT=Y_.999999 X ^DD("DD") S SDPEDT=Y
15 S SDMAX=Y D SUBT^SCRPW50("**** Report Format Selection ***")
16 S DIR(0)="S^S:SUMMARY FOR DATE RANGE;D:DETAIL BY DAY",DIR("A")="Select report format"
17 W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 G EXIT^SCRPW74
18 S SDFMT=Y G:SDFMT="S" REN
19 ;clarification that you may skip entry for a patient
20 W !!?3,"To generate a detailed report by stop code pair or clinic,"
21 W !?3,"press 'enter' without inputting a patient name.",!
22 S SDPAT=0
23 K ^TMP("SDPAT",SDJN)
24 D SELECT^SCRPW78(SDJN,.SDPAT) ;select patient(s)
25 S DIR("B")="CLINIC NAME"
26 S DIR(0)="S^CL:CLINIC NAME;CP:CREDIT PAIR",DIR("A")="Specify limiting category for detail"
27 I $G(SDPAT) S DIR("B")="CLINIC ALL",DIR(0)="S^CA:CLINIC ALL;CL:CLINIC NAME;CP:CREDIT PAIR"
28 S DIR("?")="Indicate if availability should be limited by clinic name or DSS credit pair."
29 W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 G EXIT^SCRPW74
30 S SDSORT=Y I '$$SORT^SCRPW72(.SDSORT) S SDOUT=1 G EXIT^SCRPW74
31 G:SDOUT EXIT^SCRPW74
32 I SDBDT>DT S SDREPORT(1)=1 G QUE
33 G RENS
34REN I SDBDT>DT S SDREPORT(1)=1 G QUE
35 S DIR(0)="S^CL:ALL CLINICS;CP:CREDIT PAIR SELECTION",DIR("A")="Specify if all clinics or selected clinics by credit pair"
36 S DIR("?")="Indicate if availability should include All clinics or clinics selected by DSS credit pair only."
37 W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 G EXIT^SCRPW74
38 S SDFMTS=Y I SDFMTS="CP" D G:SDOUT EXIT^SCRPW74
39 .S SDSORT=Y I '$$SORT^SCRPW72(.SDSORT) S SDOUT=1
40 G:SDOUT EXIT^SCRPW74
41RENS D SUBT^SCRPW50("**** Report Output Section Selection ****")
42ROSS S DIR(0)="Y",DIR("B")="YES"
43 N II F II=1:1:5 S SDREPORT(II)=0
44 I '$G(SDPAT) D
45 .S DIR("A")="Include 'next available' appointment statistics"
46 .W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 D EXIT^SCRPW74 Q
47 .S SDREPORT(1)=Y
48 .S DIR("A")="Include 'follow up' appointment statistics"
49 .W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 D EXIT^SCRPW74 Q
50 .S SDREPORT(2)=Y
51 .S DIR("A")="Include 'non-follow up' appointment statistics"
52 .W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 D EXIT^SCRPW74 Q
53 .S SDREPORT(3)=Y
54 .I SDFMT="D" D
55 ..S DIR("A")="Include list of patient appointments"
56 ..W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 D EXIT^SCRPW74 Q
57 ..S SDREPORT(4)=Y
58 I $G(SDPAT) D
59 .S DIR("?")="Accept to print report for selected patient(s) or exit"
60 .S DIR("A")="Print individual patient report" D
61 .W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SDOUT=1 D EXIT^SCRPW74 Q
62 .S SDREPORT(5)=Y
63 I '$D(SDREPORT) S SDOUT=1 D EXIT^SCRPW74 Q
64 I 'SDREPORT(1),'SDREPORT(2),'SDREPORT(3),'SDREPORT(4),'SDREPORT(5) D G ROSS
65 .W $C(7),!!,"No output elements selected--at least one must be selected to continue..."
66QUE I SDBDT'>DT W !!,"This report requires 132 column output!"
67 N ZTSAVE F X="SDREPORT(","SDEX","SDBDT","SDPBDT","SDEDT","SDPEDT","SDDIV","SDDIV(","SDFMT","SDFMTS","SDSORT","SDSORT(","SDPAT","SDJN","^TMP(""SDPAT""," S ZTSAVE(X)=""
68 W ! D EN^XUTMDEVQ("START^SCRPW72","Clinic Appointment Availability Report",.ZTSAVE) S SDOUT=1 G EXIT^SCRPW74
69 ;
70RESEND ;Entry point for manually initiating extracts for the current month
71 N DIR,SDXTMP,SDMON,SDI,SDT,DTOUT,DUOUT
72 W !!,$C(7),"NOTE: Use of this utility will result in the transmission of extract data to"
73 W !,"Austin. It should only be used if automatically queued extracts failed to run."
74 M SDXTMP=^XTMP("SD53P192") D QDIS^SCRPW74(.SDXTMP)
75 F SDI=1,2 I $G(SDXTMP("EXTRACT",SDI,"DATE"))<DT D Q:$D(DTOUT)!$D(DUOUT)
76 .W !!,"Extract ",SDI," doesn't appear to be tasked to run repetitively in the future."
77 .S DIR(0)="Y",DIR("A")="Do you wish to schedule it now",DIR("B")="YES"
78 .W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) D:Y RQUE(SDI)
79 Q:$D(DTOUT)!$D(DUOUT)
80 S DIR(0)="Y",DIR("B")="NO"
81 F SDI=1,2 D Q:$D(DTOUT)!$D(DUOUT)
82 .S SDT=DT S:SDI=1 SDT=$S($E(SDT,4,5)="01":$E(SDT,1,3)-1_12_$E(SDT,6,7),1:$E(SDT,1,5)-1_$E(SDT,6,7))
83 .S DIR("A")="Do you want transmit Extract "_SDI_" for "_$P($$MON^SCRPW74(SDI,SDT,.SDMON),U)_" to Austin"
84 .W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) D:Y QUEUE(.SDMON)
85 Q
86REQUE ;Entry point for initiating repetitive tasking of extracts
87 N DIR,SDXTMP,DTOUT,DUOUT
88 M SDXTMP=^XTMP("SD53P192") D QDIS^SCRPW74(.SDXTMP)
89 I '$D(SDXTMP) D W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) I Y D RQUE("B") Q
90 .S DIR(0)="Y",DIR("A")="Do you want to schedule both extracts now"
91 .S DIR("B")="YES"
92 Q:$D(DTOUT)!$D(DUOUT) K DIR
93 S DIR(0)="S^1:EXTRACT 1 (PROSPECTIVE);2:EXTRACT 2 (RETROSPECTIVE);B:BOTH EXTRACTS"
94 S DIR("?",1)="Extract 1 returns future clinic availability, extract 2 returns previous",DIR("?")="clinic availability and utilization."
95 S DIR("A")="Specify which extract you wish to schedule"
96 W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) D RQUE(Y)
97 Q
98RQUE(SDEX) ;Schedule extract for repetitive run
99 ;Input: SDEX=extract type, '1', '2' or 'B' for both
100 I SDEX="B" D RQUE(1) Q:$D(DTOUT)!$D(DUOUT) D RQUE(2) Q
101 N SDMON,SDNOW,SDOUT,DIR,Y,SDT
102 S SDNOW=$$NOW^XLFDT(),SDOUT=0,Y=$G(SDXTMP("EXTRACT",SDEX,"DATE"))
103 I Y>SDNOW D Q:$D(DTOUT)!$D(DUOUT) Q:SDOUT
104 .W !!,"Extract ",SDEX," appears to be queued for the future--"
105 .X ^DD("DD") W !!,"Scheduled for: ",Y,", task number: ",$G(SDXTMP("EXTRACT",SDEX,"TASK"))
106 .S DIR(0)="Y",DIR("B")="NO"
107 .S DIR("A")="Do you want to delete this task and re-schedule extract "_SDEX
108 .W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) S SDOUT='Y
109 .Q:'Y S ZTSK=$G(SDXTMP("EXTRACT",SDEX,"TASK")) D KILL^%ZTLOAD
110 .K ^XTMP("SD53P192","EXTRACT",SDEX) Q
111 S SDT=$$WHEN^SCRPW74(SDEX),SDRPT=$$MON^SCRPW74(SDEX,SDT,.SDMON)
112 D SCHED^SCRPW74(SDEX,SDT,SDRPT,.SDMON) Q
113QUEUE(SDMON) ;Queue extraction for re-run
114 ;Input: SDMON=array of input parameters (as described in MON^SCRPW74)
115 N %DT,SDI,Y,ZTSK,ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSAVE
116 S Y=DT_.22 X ^DD("DD") S %DT("B")=Y,%DT("A")="Queue to run: "
117 S %DT="AEFXR" W ! D ^%DT I Y<1 G QQ
118 S ZTDTH=Y,ZTSAVE("SDMON(")="",ZTRTN="RUN^SCRPW74(0)",ZTIO=""
119 S ZTDESC="Clinic Appointment Wait Time Extract ("_SDMON("SDEX")_")"
120 F SDI=1:1:20 D ^%ZTLOAD Q:$G(ZTSK)
121QQ I '$G(ZTSK) W !!,"Extract not queued!!!",! Q
122 W !!,"Task number: ",ZTSK,! Q
123TXXM ;Transmit extract data
124 N SDFAC,SDL,SDIV,SDCP,SC,SDI,SDX,SDEX,SDY,SDZ,SDP,SDSIZE,SDMG,SDMGM
125 S SDFAC=$P($$SITE^VASITE(),U,3),SDXM=1,SDL=0,SDIV="",SDSIZE=0
126 S SDEX=$S(SDPAST:2,1:1)
127 S SDMG=$P($G(^SD(404.91,1,"PATCH192")),U,(6+SDEX))
128 S:SDMG="" SDMG="G.SC CLINIC WAIT TIME"
129 ;Set up monitoring mail group
130 S SDMGM="SC CWT EXTRACT MONITOR"
131 S:'$$GOTLOCAL^XMXAPIG(SDMGM) SDMGM=""
132 F S SDIV=$O(^TMP("SD",$J,SDIV)) Q:SDIV="" S SDCP=0 D
133 .F S SDCP=$O(^TMP("SD",$J,SDIV,SDCP)) Q:'SDCP S SC=0 D
134 ..F S SC=$O(^TMP("SD",$J,SDIV,SDCP,SC)) Q:'SC D
135 ...I SDSIZE>29000 D EXXM(SDMG,SDMGM) ;Transmit message if >29K
136 ...;Build record leader string
137 ...;Reporting facility, extract date, extract type
138 ...S SDX="#"_SDFAC_U_SDEXDT_U_SDEX
139 ...;Format version--NOTE: THIS NUMBER MUST INCREMENTED IF THE EXTRACT
140 ...;FORMAT IS MODIFIED (e.g. existing number + 1). Refer to patch
141 ...;SD*5.3*249 documentation for additional information.
142 ...S SDX=SDX_"~5"
143 ...;Report begin date, division, credit pair
144 ...S SDX=SDX_U_SDBDT_U_$P(SDIV,U,2)_U_SDCP_U
145 ...;Clinic ifn and name
146 ...S SDX=SDX_SC_"~"_$$CNAME^SCRPW72(SC)_"~"
147 ...;Maximum days for future booking
148 ...S SDX=SDX_+$P($G(^SC(SC,"SDP")),U,2)_U
149 ...;Build clinic statistics string
150 ...S SDI="" F S SDI=$O(^TMP("SD",$J,SDIV,SDCP,SC,SDI)) Q:SDI="" D
151 ....S SDY=^TMP("SD",$J,SDIV,SDCP,SC,SDI) Q:'$L(SDY)
152 ....F SDP=1:1 S SDZ=$P(SDY,U,SDP) Q:SDZ="" D
153 .....I $L(SDX)>220 D XMTX(SDX) S SDX=""
154 .....S SDX=SDX_$S($E(SDX,$L(SDX))=U:"",1:"|")_SDZ
155 ...I SDEX=1 S SDX=SDX_"$" D XMTX(SDX) Q
156 ...S SDY=$G(^TMP("SDNAVA",$J,SDIV,SDCP,SC)) ;get next ava. info.
157 ...S SDZ=$G(^TMP("SDNAVB",$J,SDIV,SDCP,SC)) ;get additional data
158 ...S SDY=$$NAVA(SDY) D S SDX=SDX_SDY,SDY=$$ADDL^SCRPW72(SDZ) D
159 ....I $L(SDX)+$L(SDY)>240 D
160 .....S SDI=$L(SDX),SDX=SDX_$E(SDY,1,(240-SDI)),SDY=$E(SDY,(241-SDI),999)
161 .....D XMTX(SDX) S SDX=""
162 ...S SDX=SDX_SDY_"$" D XMTX(SDX)
163 D:$D(^TMP("SDXM",$J)) EXXM(SDMG,SDMGM)
164 Q
165EXXM(XMG,SDMGM) ;Send extract mail message
166 ;Input: XMG=mail group to receive message
167 ;Input: SDMGM=extract monitoring mail group (optional)
168 N XMSUB,XMDUZ,XMDUN,XMTEXT,XMY,XMZ
169 S XMSUB="Clinic Appointment Waiting Time Extract ("_SDEX_")"
170 S (XMDUZ,XMDUN)="Patch SD*5.3*192/Task "_$G(ZTSK)
171 S XMTEXT="^TMP(""SDXM"",$J,"
172 S XMY(XMG)="" S:$L($G(SDMGM)) XMY("G."_SDMGM)=""
173 D ^XMD
174 K ^TMP("SDXM",$J) S SDXM=1,SDSIZE=0
175 Q
176XMTX(SDX) ;Set mail message line
177 ;Input: SDX=text value
178 S ^TMP("SDXM",$J,SDXM)=SDX,SDXM=SDXM+1,SDSIZE=SDSIZE+$L(SDX)
179 Q
180NAVA(SDY) ;Format next available appointment information
181 ;Input: SDY=next ava. numbers from ^TMP("SDNAVA",$J,SDCP,SC)
182 N SDI,SDX
183 ;Format 'next available' data
184 S SDX="^" F SDI=0:1:3 D
185 .S:SDI SDX=SDX_"|"
186 .S SDX=SDX_SDI_"~"_+$P(SDY,U,(SDI+SDI+1))_"~"_+$P(SDY,U,(SDI+SDI+2))
187 ;Format 'follow up'/'non-follow up' appointment data
188 S SDX=SDX_U F SDI=9:2:19 D
189 .S:SDI>9 SDX=SDX_"|"
190 .S SDX=SDX_+$P(SDY,U,SDI)_"~"_+$P(SDY,U,(SDI+1))
191 S SDX=SDX_U_+$P(SDY,U,21)_"~"_+$P(SDY,U,22)
192 F SDI=23:3:35 D
193 .S SDX=SDX_"|"_+$P(SDY,U,SDI)_"~"_+$P(SDY,U,(SDI+1))
194 .S SDX=SDX_"~"_+$P(SDY,U,(SDI+2))
195 ;Format 'appts. w/in 30 days' data
196 S SDX=SDX_U_+$P(SDY,U,38)_"~"_+$P(SDY,U,39)
197 Q SDX
Note: See TracBrowser for help on using the repository browser.