source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SCRPW73.m@ 1071

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

initial load of FOIAVistA 6/30/08 version

File size: 9.5 KB
Line 
1SCRPW73 ;BP-CIOFO/KEITH,ESW - Clinic appointment availability extract (cont.) ; 5/28/03 2:27pm
2 ;;5.3;Scheduling;**192,206,223,249,291**;AUG 13, 1993
3 ;
4PRT(SDXM,SDREPORT) ;Print report
5 ;Input: SDXM='1' for output to mail message text, '0' otherwise
6 ;Input: SDREPORT=report element to print
7 ;
8 N SDX,SDY,SDI,SDP,SDPCT,SDMD,SCNA,SDT,SDFLEN
9 S SDOUT=0,SDFLEN=$S('SDPAST:5,SDREPORT#1:12,1:11)
10 S SDMD=$O(^TMP("SD",$J,"")),SDMD=$O(^TMP("SD",$J,SDMD)),SDMD=$L(SDMD)
11 I '$D(^TMP("SD",$J)),$G(SDREPORT)'=5 D Q
12 .D HDR^SCRPW76(0,SDREPORT) S SDX="No data found within the report parameters selected."
13 .W !!?(SDIOM-$L(SDX)\2),SDX Q
14 I '$D(^TMP("SDIPLST",$J)),$G(SDREPORT)=5 D Q
15 .D HDR^SCRPW76(0,SDREPORT) S SDX="No data found within the report parameters selected."
16 .W !!?(SDIOM-$L(SDX)\2),SDX Q
17 I SDREPORT=5 D PRT5^SCRPW78 Q
18 S SDIV=9999999 F S SDIV=$O(^TMP("SD",$J,SDIV)) Q:SDIV=""!SDOUT D
19 .I SDFMT="D" D
20 ..S SDCP="" F S SDCP=$O(^TMP("SD",$J,SDIV,SDCP)) Q:SDCP=""!SDOUT D
21 ...S SCNA="" F S SCNA=$O(^TMP("SDS",$J,SDCP,SCNA)) Q:SCNA=""!SDOUT D
22 ....S SC=0 F S SC=$O(^TMP("SDS",$J,SDCP,SCNA,SC)) Q:'SC!SDOUT D
23 .....Q:'$D(^TMP("SD",$J,SDIV,SDCP,SC))
24 .....D HDR^SCRPW76(1,SDREPORT,SDIV,SDCP,SC) Q:SDOUT
25 .....I SDREPORT=4 D OUT4^SCRPW77 Q
26 .....S SDX=^TMP("SD",$J,SDIV,SDCP,SC)
27 .....I $P(SDX,U)+$P(SDX,U,2)+$P(SDX,U,3)'>0,'$D(^TMP("SDNAVA",$J,SDIV,SDCP,SC)) D Q
28 ......S SDY="No availability found"_$S($L($P(SDX,U,4)):": "_$P(SDX,U,4)_".",1:".")
29 ......W !!?(SDIOM-$L(SDY)\2),SDY Q
30 .....S SDI="" F S SDI=$O(^TMP("SD",$J,SDIV,SDCP,SC,SDI)) Q:SDI=""!SDOUT D
31 ......S SDX=^TMP("SD",$J,SDIV,SDCP,SC,SDI)
32 ......F SDP=1:1 S SDY=$P(SDX,U,SDP) Q:'$L(SDY)!SDOUT D
33 .......S SDY=$TR(SDY,"~","^"),SDT=$$DAY(SDI,SDP,SDBDT)
34 .......S SDY=$$TRX(SDREPORT,SDY,SDIV,SDCP,SC,$P(SDT,U,2))
35 .......I 'SDXM,$Y>(IOSL-SDFLEN) D
36 ........D:SDPAST FOOTER^SCRPW77(SDREPORT) D HDR^SCRPW76(1,SDREPORT,SDIV,SDCP,SC)
37 ........Q
38 .......Q:SDOUT
39 .......D OUTPUT(SDREPORT,$P(SDT,U),SDY,SDCOL,4,0,SDPAST,.SDXM)
40 .......Q
41 ......Q
42 .....Q:SDOUT
43 .....S SDX=^TMP("SD",$J,SDIV,SDCP,SC),SDX=$$TRX(SDREPORT,SDX,SDIV,SDCP,SC)
44 .....D OUTPUT(SDREPORT," Clinic Total:",SDX,SDCOL,0,1,SDPAST,.SDXM)
45 .....D:SDPAST FOOTER^SCRPW77(SDREPORT)
46 .....Q
47 ....Q
48 ...Q
49 ..Q
50 .Q:SDOUT D SUM(SDIV,SDREPORT) Q
51 Q:SDOUT
52 ;
53 I SDMD D SUM(0,SDREPORT)
54 Q
55 ;
56TRX(SDREPORT,SDX,SDIV,SDCP,SC,SDT) ;Transform string for output
57 ;Input: SDREPORT=report element to print
58 ;Input: SDX=output numbers to transform
59 ;Input: SDIV=medical center division
60 ;Input: SDCP=credit pair (optional)
61 ;Input: SC=clinic ien (optional)
62 ;Input: SDT=date for detail by day (optional)
63 ;Output: string of output values for specified SDREPORT type
64 ;
65 N SDY
66 I SDREPORT=1 S SDY=$$TRX1()
67 I SDREPORT=2 S SDY=$$TRX2()
68 I SDREPORT=3 S SDY=$$TRX3()
69 Q SDY
70 ;
71TRX1() N SDZ S SDZ=""
72 S SDY=$P(SDX,U,2)_U_$P(SDX,U)_U
73 S SDY=SDY_$S(+$P(SDX,U,2)=0:0,1:$P(SDX,U)*100\$P(SDX,U,2))
74 S SDY=SDY_U_$P(SDX,U,3) D
75 .I '$G(SDCP) S SDZ=$G(^TMP("SDNAVA",$J,SDIV)) Q
76 .I '$G(SC) S SDZ=$G(^TMP("SDNAVA",$J,SDIV,SDCP)) Q
77 .I '$G(SDT) S SDZ=$G(^TMP("SDNAVA",$J,SDIV,SDCP,SC)) Q
78 .S SDZ=$G(^TMP("SDNAVA",$J,SDIV,SDCP,SC,SDT)) Q
79 S SDY=SDY_U_$P(SDZ,U,1,8)_U_$P(SDZ,U,38,39)
80 Q SDY
81 ;
82TRX2() I '$G(SDCP) S SDY=$P($G(^TMP("SDNAVA",$J,SDIV)),U,9,20) Q SDY
83 I '$G(SC) S SDY=$P($G(^TMP("SDNAVA",$J,SDIV,SDCP)),U,9,20) Q SDY
84 I '$G(SDT) S SDY=$P($G(^TMP("SDNAVA",$J,SDIV,SDCP,SC)),U,9,20) Q SDY
85 S SDY=$P($G(^TMP("SDNAVA",$J,SDIV,SDCP,SC,SDT)),U,9,20)
86 Q SDY
87 ;
88TRX3() I '$G(SDCP) S SDY=$P($G(^TMP("SDNAVA",$J,SDIV)),U,21,37) Q SDY
89 I '$G(SC) S SDY=$P($G(^TMP("SDNAVA",$J,SDIV,SDCP)),U,21,37) Q SDY
90 I '$G(SDT) S SDY=$P($G(^TMP("SDNAVA",$J,SDIV,SDCP,SC)),U,21,37) Q SDY
91 S SDY=$P($G(^TMP("SDNAVA",$J,SDIV,SDCP,SC,SDT)),U,21,37)
92 Q SDY
93 ;
94DAY(SDI,SDP,SDBDT) ;Produce date/day value
95 ;Input: SDI=array subscript incrementor
96 ;Input: SDP=$PIECE of string containing related date data
97 ;Input: SDBDT=report start date
98 N X1,X2,X,%H,Y,SDT,SDAY
99 S X1=SDBDT,X2=-1 D C^%DTC
100 S X1=X,X2=SDI*12+SDP D C^%DTC S SDT=X
101 D DW^%DTC S SDAY=X,Y=SDT X ^DD("DD")
102 Q Y_" "_$S($E(SDT,6)=0:"-",1:"")_"- "_SDAY_U_SDT
103 ;
104SUM(SDIV,SDREPORT) ;Print division/facility summary
105 ;Input: SDDIV=division name^number (or '0' for facility total)
106 ;Input: SDREPORT=report element to print
107 ;
108 I SDREPORT=4!(SDREPORT=5) Q
109 N SDY,SCNA,SDI
110 S SDCP="",SDHD=$S(SDIV=0:3,1:2) D HDR^SCRPW76(SDHD,SDREPORT,SDIV)
111 F S SDCP=$O(^TMP("SD",$J,SDIV,SDCP)) Q:SDCP=""!SDOUT D
112 .S SDX=^TMP("SD",$J,SDIV,SDCP),SDY=$G(^TMP("SD",$J,SDIV))
113 .F SDI=1:1:3 S $P(SDY,U,SDI)=$P(SDY,U,SDI)+$P(SDX,U,SDI)
114 .S ^TMP("SD",$J,SDIV)=SDY
115 .Q:'$$DATA(1) ;Quit if no data
116 .I SDMD S SDY=$G(^TMP("SD",$J,0,SDCP)) D
117 ..F SDI=1:1:3 S $P(SDY,U,SDI)=$P(SDY,U,SDI)+$P(SDX,U,SDI)
118 ..S ^TMP("SD",$J,0,SDCP)=SDY
119 .S SDY=$$OTX("CP"),SDX=$$TRX(SDREPORT,SDX,SDIV,SDCP)
120 .D OUTPUT(SDREPORT,SDY,SDX,SDCOL,0,1,SDPAST,.SDXM)
121 .S SCNA="" F S SCNA=$O(^TMP("SDS",$J,SDCP,SCNA)) Q:SCNA=""!SDOUT D
122 ..S SC=0 F S SC=$O(^TMP("SDS",$J,SDCP,SCNA,SC)) Q:'SC!SDOUT D
123 ...S SDX=$G(^TMP("SD",$J,SDIV,SDCP,SC))
124 ...Q:'$$DATA(2) ;Quit if no data
125 ...I 'SDXM,$Y>(IOSL-SDFLEN) D
126 ....D:SDPAST FOOTER^SCRPW77(SDREPORT) D HDR^SCRPW76(SDHD,SDREPORT,SDIV)
127 ....Q
128 ...Q:SDOUT
129 ...I SDMD S SDY=$G(^TMP("SD",$J,0,SDCP,SC)) D
130 ....F SDI=1:1:3 S $P(SDY,U,SDI)=$P(SDY,U,SDI)+$P(SDX,U,SDI)
131 ....S ^TMP("SD",$J,0,SDCP,SC)=SDY
132 ....Q
133 ...S SDY=$$OTX("CL"),SDX=$$TRX(SDREPORT,SDX,SDIV,SDCP,SC)
134 ...D OUTPUT(SDREPORT,SDY,SDX,SDCOL,4,0,SDPAST,.SDXM)
135 ...Q
136 ..Q
137 .Q
138 Q:SDOUT S SDX=$G(^TMP("SD",$J,SDIV)),SDX=$$TRX(SDREPORT,SDX,SDIV)
139 I $G(SDFMT)="S"&($G(SDFMTS)="CP") D:SDPAST FOOTER^SCRPW77(SDREPORT) Q
140 S SDY=$S(SDIV=0:"Facility",1:"Division")_" total:" D OUTPUT(SDREPORT,SDY,SDX,SDCOL,0,1,SDPAST,.SDXM,1)
141 D:SDPAST FOOTER^SCRPW77(SDREPORT)
142 Q
143 ;
144DATA(SDS) ;Check for data to print
145 ;Input: SDS=subscript level
146 ;Output: '1' if data, '0' otherwise
147 N SDCK,SDNODE,SDI,SDCT S (SDCT,SDCK)=0
148 Q:SDFMT'="S" 1
149 I 'SDPAST S SDCK=($P(SDX,U)+$P(SDX,U,2)+$P(SDX,U,3)>0) Q SDCK
150 I $P(SDX,U)+$P(SDX,U,2)+$P(SDX,U,3)>0 Q 1
151 I SDS=1 S SDNODE=$G(^TMP("SDNAVA",$J,SDIV,SDCP))
152 I SDS=2 S SDNODE=$G(^TMP("SDNAVA",$J,SDIV,SDCP,SC))
153 F SDI=1:1:39 S SDCT=SDCT+$P(SDNODE,U,SDI)
154 S SDCK=SDCT>0
155 Q SDCK
156 ;
157OUTPUT(SDREPORT,SDTX,SDX,SDCOL,SDC,SDL,SDPAST,SDXM,SDTL) ;Write output or load summary message
158 ;Input: SDREPORT=report element to print
159 ;Input: SDTX=category text value
160 ;Input: SDX=output count values
161 ;Input: SDCOL=margin adjusted column control
162 ;Input: SDC=column to start line
163 ;Input: SDL=number of additional linefeeds
164 ;Input: SDPAST='0' if dates > TODAY, '1' otherwise
165 ;Input: SDXM=mail message line number message text (optional)
166 ;Input: SDTL='1' if this is a totals line
167 ;
168 N SDI,SDPCT
169 G:$G(SDXM) OUTXM F SDI=1:1:SDL W !
170 D:SDREPORT=1 OUT1 D:SDREPORT=2 OUT2 D:SDREPORT=3 OUT3
171 Q
172 ;
173OUT1 N SDL1,SDL2,SDL3
174 W !?(SDCOL+SDC),SDTX
175 F SDI=1:1:$S(SDPAST:12,1:3) D MANI(SDX,SDI,$G(SDTL)) D
176 .W ?(SDCOL+34+SDL1+(SDI-1*7)),$J(+$P(SDX,U,SDI),$S(((SDI<3)&(SDL3>7)):SDL3,SDI=3:(6-SDL1),1:7),$$OPD())_$S(SDI=3:"%",1:"")
177 .Q
178 I SDPAST F SDI=0,1 D
179 .W ?(SDCOL+118+(SDI*7)),$J(+$P(SDX,U,13+SDI),6,0)_"%"
180 .Q
181 Q
182 ;
183MANI(SDX,SDI,SDTL) ;Manipulate column position for large totals
184 ;
185 S (SDL1,SDL2)=0,SDL3=$L($P(SDX,U,SDI))
186 I $G(SDTL) D
187 .I SDI=1,SDL3>7 S SDL1=(7-SDL3)
188 .I SDI=2,SDL3>6 S SDL1=1
189 .I SDI=3 S SDL1=3
190 .Q
191 Q
192 ;
193OUT2 W !?(SDCOL+SDC),SDTX
194 F SDI=0:1:5 D
195 .W ?(36+(SDI*16)),$J(+$P(SDX,U,(1+(SDI*2))),8,0)
196 .W ?(44+(SDI*16)),$J(+$P(SDX,U,(2+(SDI*2))),8,1)
197 .Q
198 Q
199 ;
200OUT3 W !?(SDCOL+SDC),SDTX
201 W ?30,$J(+$P(SDX,U),6,0),?36,$J(+$P(SDX,U,2),6,1)
202 F SDI=0:1:4 D
203 .W ?(42+(SDI*18)),$J(+$P(SDX,U,(3+(SDI*3))),6,0)
204 .W ?(48+(SDI*18)),$J(+$P(SDX,U,(4+(SDI*3))),6,1)
205 .W ?(54+(SDI*18)),$J(+$P(SDX,U,(5+(SDI*3))),6,1)
206 .Q
207 Q
208 ;
209OPD() ;Output decimal places
210 Q $S(SDI<6:0,SDI#2:0,1:1)
211 ;
212OUTXM ;Load bulletin message text
213 ;Output: ^TMP("SDXM",$J,SDXM)=mail message text line
214 N SDZ S:SDC<1 SDC=1
215 F SDI=1:1:SDL D XMTX("")
216 D:SDREPORT=1 OUTXM1 D:SDREPORT=2 OUTXM2 D:SDREPORT=3 OUTXM3
217 Q
218 ;
219OUTXM1 N SDL1,SDL2,SDL3
220 S SDZ="",$E(SDZ,SDC)=SDTX
221 F SDI=1:1:$S(SDPAST:12,1:3) D MANI(SDX,SDI,$G(SDTL)) D
222 .S $E(SDZ,(35+SDL1+(SDI-1*7)))=$J(+$P(SDX,U,SDI),$S(((SDI<3)&(SDL3>7)):SDL3,SDI=3:(6-SDL1),1:7),$$OPD())_$S(SDI=3:"%",1:"")
223 I SDPAST F SDI=0,1 D
224 .S $E(SDZ,(119+(SDI*7)))=$J(+$P(SDX,U,13+SDI),6,0)_"%"
225 D XMTX(SDZ)
226 Q
227 ;
228OUTXM2 S SDZ="",$E(SDZ,SDC)=SDTX
229 F SDI=0:1:5 D
230 .S $E(SDZ,(37+(SDI*16)))=$J(+$P(SDX,U,(1+(SDI*2))),8,0)
231 .S $E(SDZ,(45+(SDI*16)))=$J(+$P(SDX,U,(2+(SDI*2))),8,1)
232 .Q
233 D XMTX(SDZ)
234 Q
235 ;
236OUTXM3 S SDZ="",$E(SDZ,SDC)=SDTX
237 S $E(SDZ,31)=$J(+$P(SDX,U),6,0),$E(SDZ,37)=$J(+$P(SDX,U,2),6,1)
238 F SDI=0:1:4 D
239 .S $E(SDZ,(43+(SDI*18)))=$J(+$P(SDX,U,(3+(SDI*3))),6,0)
240 .S $E(SDZ,(49+(SDI*18)))=$J(+$P(SDX,U,(4+(SDI*3))),6,1)
241 .S $E(SDZ,(55+(SDI*18)))=$J(+$P(SDX,U,(5+(SDI*3))),6,1)
242 .Q
243 D XMTX(SDZ)
244 Q
245 ;
246XMTX(SDX) ;Set mail message text line
247 ;Input: SDX=text value
248 S ^TMP("SDXM",$J,SDXM)=SDX,SDXM=SDXM+1 Q
249 ;
250OTX(SDSORT) ;Produce output text for clinic or credit pair
251 ;Input: SDSORT='CL' for clinic name, 'CP' for credit pair
252 N SDZ,SDSC1,SDSC2
253 I SDSORT="CL" D Q SDZ
254 .S SDZ=$P($G(^SC(+SC,0)),U) S:'$L(SDZ) SDZ="UNKNOWN"
255 .I SDREPORT=3 S SDZ=$E(SDZ,1,26)
256 .Q
257 S SDSC1=$O(^DIC(40.7,"C",$E(SDCP,1,3),""))
258 S SDSC1=$P($G(^DIC(40.7,+SDSC1,0)),U),SDSC1=$TR(SDSC1,"/","-")
259 S:'$L(SDSC1) SDSC1="UNKNOWN"
260 I $E(SDCP,4,6)="000" S SDSC2="(NONE)" G CPO1
261 S SDSC2=$O(^DIC(40.7,"C",$E(SDCP,4,6),""))
262 S SDSC2=$P($G(^DIC(40.7,+SDSC2,0)),U),SDSC2=$TR(SDSC2,"/","-")
263 S:'$L(SDSC2) SDSC2="UNKNOWN"
264CPO1 I $L(SDSC1)<13 S SDZ=SDSC1_"/"_$E(SDSC2,1,(13+(13-$L(SDSC1)))) G CPOTQ
265 I $L(SDSC2)<13 S SDZ=$E(SDSC1,1,(13+(13-$L(SDSC2))))_"/"_SDSC2 G CPOTQ
266 S SDZ=$E(SDSC1,1,13)_"/"_$E(SDSC2,1,13)
267CPOTQ S SDZ=SDCP_" "_SDZ I SDREPORT=3 S SDZ=$E(SDZ,1,30)
268 Q SDZ
Note: See TracBrowser for help on using the repository browser.