source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCRPO.m@ 776

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

initial load of WorldVistAEHR

File size: 8.6 KB
Line 
1SCRPO ;BP-CIOFO/KEITH - Report prompting utilities ; 20 Aug 99 7:46 AM
2 ;;5.3;Scheduling;**177,297**;AUG 13, 1993
3 ;
4DTR(SC,SCDTB,SCDTE) ;Date range prompts
5 ;Input: SC=name of array to return values
6 ; @SC@("DTR","BDT")=begin date (internal^external)
7 ; @SC@("DTR","EDT")=end date (internal^external)
8 ;Input: SCDTB=array to manipulate %DT begin date values (optional)
9 ;Input: SCDTE=array to manipulate %DT end date values (optional)
10 ;Output: '1' for success, '0' otherwise
11 N %DT M %DT=SCDTB W !
12 S:'$L($G(%DT)) %DT="AEPX"
13 I %DT["A" S:'$L($G(%DT("A"))) %DT("A")="Select beginning date: "
14 D ^%DT I Y<1 Q 0
15 S @SC@("DTR","BEGIN")=Y X ^DD("DD") S @SC@("DTR","PBDT")=Y
16EDT K %DT M %DT=SCDTE W !
17 S:'$L($G(%DT)) %DT="AEPX"
18 I %DT["A" S:'$L($G(%DT("A"))) %DT("A")=" Select ending date: "
19 D ^%DT I Y<1 K SC Q 0
20 I Y<@SC@("DTR","BEGIN") W !!,$C(7),"End date cannot be before begin date!",! G EDT
21 S @SC@("DTR","END")=Y X ^DD("DD") S @SC@("DTR","PEDT")=Y
22 S @SC@("DTR","INCL")=0
23 D XR(.SC,"DTR","Date Range") Q 1
24 ;
25ATYPE(SC) ;Prompt for assignment types
26 ;Input: SC=array to return values (pass by reference)
27 ; @SC@("ATYPE")=assignment types (internal^external)
28 ;Output: '1' for success, '0' otherwise
29 N DIR,DTOUT,DUOUT
30 S DIR(0)="S^P:PRIMARY CARE ASSIGNMENTS;N:NON-PRIMARY CARE ASSIGNMENTS;B:BOTH PC AND NON-PC"
31 S DIR("A")="Specify the type of assignments to include",DIR("B")="BOTH"
32 W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) 0
33 S @SC@("ATYPE")=Y_U_Y(0)
34 D XR(.SC,"ATYPE","Type of Assignments") Q 1
35 ;
36DSUM(SC) ;Prompt for detail or summary
37 ;Input SC=array to return values (pass by reference)
38 ; @SC@("FMT")=format (internal^external)
39 ;Output: '1' for success, '0' otherwise
40 N DIR,DTOUT,DUOUT
41 K DIR S DIR(0)="S^D:DETAIL + SUMMARY;S:SUMMARY ONLY"
42 S DIR("A")="Specify output format",DIR("B")="DETAIL + SUMMARY"
43 W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) 0
44 S @SC@("FMT")=Y_U_Y(0)
45 D XR(.SC,"FMT","Report Format") Q 1
46 ;
47LIST(SC,WHAT,SUBH,LIMIT) ;Get list of entries from a file
48 ;Input: SC=array to return values (pass by reference)
49 ; @SC@(WHAT)="ALL" for all entries, or,
50 ; @SC@(WHAT,ifn)=name of record
51 ; @SC@(WHAT,name,ifn)=""
52 ;Input: WHAT=type of selection
53 ; "DIV" for division
54 ; "TEAM" for TEAM
55 ; "ROLE" for STANDARD POSITION
56 ; "POS" for TEAM POSITION
57 ; "PCP" for PC provider (NEW PERSON)
58 ; "ASPR" for assigned provider (NEW PERSON)
59 ; "APR" for associate provider (NEW PERSON)
60 ; "CLINIC" for enrolled clinic (HOSPITAL LOCATION)
61 ;Input: SUBH='1' to display category subheader (optional)
62 ;Input: LIMIT=maximum selections (optional, default 20)
63 ;Output: '1' for success, '0' otherwise
64 ;
65 N SCW,SCI,SCOUT,DIC,X,Y,SCA,SCB,SCQUIT,SCS,DTOUT,DUOUT
66 Q:'$L(WHAT) 0 S:'$G(LIMIT) LIMIT=20 S (SCOUT,SCQUIT)=0
67 F SCI="DIV","TEAM","ROLE","POS","PCP","ASPR","APR","CLINIC" S SCW(SCI)=""
68 Q:'$D(SCW(WHAT)) 0
69 D @WHAT S DIC(0)="AEMQ"
70 I $G(SUBH) D SUBT^SCRPW50("**** "_SCA_" Selection ****")
71 S SCB=$J("Select "_SCA_": ",29),DIC("A")=SCB_"ALL// "
72 I $L($G(SCS)) S DIC("S")=SCS
73 F SCI=1:1:LIMIT D Q:SCOUT!SCQUIT
74 .W ! D ^DIC I $D(DTOUT)!$D(DUOUT) S SCQUIT=1 Q
75 .I SCI=1,X="" W " (ALL)" S @SC@(WHAT)="ALL",SCOUT=1 Q
76 .I X="" S SCOUT=1 Q
77 .I Y>0 S @SC@(WHAT,+Y)=$P(Y,U,2),@SC@(WHAT,$P(Y,U,2),+Y)=""
78 .S DIC("A")=SCB
79 .Q
80 D XR(.SC,WHAT,SCA) Q 'SCQUIT
81 ;
82DIV S DIC="^DIC(4,",SCA="Institution",SCS="I $D(^SCTM(404.51,""AINST"",+Y))" Q
83TEAM S DIC="^SCTM(404.51,",SCA="Team" Q
84ROLE S DIC="^SD(403.46,",SCA="Role" Q
85POS S DIC="^SCTM(404.57,",SCA="Team Position" Q
86PCP S DIC="^VA(200,",SCA="PC Provider" Q
87ASPR S DIC="^VA(200,",SCA="Assigned Provider" Q
88APR S DIC="^VA(200,",SCA="Associate Provider" Q
89CLINIC S DIC="^SC(",SCA="Associated Clinic",DIC("S")="I $P(^(0),U,3)=""C""" Q
90 ;
91SORT(SC,SCEL,SCSP) ;Prompt for optional sort elements
92 ;Input: SC=array to return sort order (pass by reference)
93 ;Input: SCX=comma delimited string of element acronyms where
94 ; 'IN' = INSTITUTION
95 ; 'TM' = TEAM
96 ; 'RO' = ROLE
97 ; 'TP' = TEAM POSITION
98 ; 'PR' = PROVIDER
99 ; 'AC' = ASSOCIATED CLINIC
100 ; 'EC' = ENROLLED CLINIC
101 ; 'PT' = PATIENT
102 ; 'PA' = PATIENT
103 ;Input: SCSP=acronym of last sort to add if not selected (optional)
104 ;Output: '0' for abnormal exit, '1' otherwise
105 ; @SC@("SORT",1,elementacronym)=element
106 ; @SC@("SORT",2,elementacronym)=element, etc.
107 ;
108 N DIR,SCI,SCX,SCY,SCQUIT,SCZ
109 Q:'$L(SCEL)
110 S SCQUIT=0
111 F SCI=1:1:$L(SCEL,",") D
112 .S SCX=$P(SCEL,",",SCI),SCX=$S(SCX="PA":"PT",SCX="DV":"IN",1:SCX),SCY(SCX)=SCI,SCZ=$P($T(@SCX),";;",2)
113 .S SCZ(SCX)=$P(SCZ,U,2),SCX=$P(SCZ,U)
114 .I $L(SCX) S SCX(SCI)=";"_SCX
115 .Q
116 Q:'$O(SCX(""))
117 S SCI=0 D QSORT("Sort output by")
118 I $L($G(SCSP)),$D(SCY(SCSP)) D
119 .S SCI=SCI+1,SCZ=$P($T(@SCSP),";;",2),@SC@("SORT",SCI)=$P(SCZ,":")_U_$P(SCZ,":",2)
120 .Q
121 D XR(.SC,"SORT","Output will be sorted by") Q 'SCQUIT
122 ;
123QSORT(DIRA) ;Prompt for sort
124 N DTOUT,DUOUT
125 S DIR("A")=DIRA
126 S DIR(0)=$$DIR0() Q:DIR(0)=""
127 D ^DIR I $D(DTOUT)!$D(DUOUT) S SCQUIT=1 Q
128 Q:X=""
129 S SCI=SCI+1,@SC@("SORT",SCI)=$S(Y="IN":"DV",Y="PT":"PA",1:Y)_U_Y(0)_U_SCZ(Y)
130 K SCX(SCY(Y)),SCY(Y) D QSORT("Within "_Y(0)_", sort by")
131 Q
132 ;
133DIR0() ;Return value for DIR(0)
134 N SCI
135 S SCX="",SCI=0
136 F S SCI=$O(SCX(SCI)) Q:'SCI S SCX=SCX_SCX(SCI)
137 S SCX=$E(SCX,2,999) S:$L(SCX) SCX="SO^"_SCX
138 Q SCX
139 ;
140DV ;;IN:INSTITUTION^SCDIV
141IN ;;IN:INSTITUTION^SCDIV
142TM ;;TM:TEAM^SCTEAM
143RO ;;RO:ROLE^SCROLE
144TP ;;TP:TEAM POSITION^SCPOS
145PR ;;PR:PROVIDER^SCPROV
146EC ;;EC:ENROLLED CLINIC^SCLINIC
147AC ;;AC:ASSOCIATED CLINIC^SCLINIC
148PA ;;PA:PATIENT^SCPAT
149PT ;;PT:PATIENT^SCPAT
150 ;
151XR(SC,SUB,VAL) ;Create x-ref for printing parameters
152 ;Input: SC=array to return parameters
153 ;Input: SUB=name of subscript holding parameters being x-ref'd
154 ;Input: VAL=value for item subtitle (optional)
155 ;
156 S @SC@("XR")=$G(@SC@("XR"))+1,@SC@("XR",@SC@("XR"),SUB)=$G(VAL) Q
157 ;
158PPAR(SC,OK,SCT) ;Print report parameters
159 ;Input: SC=array of report parameters
160 ;Input: OK='1' to prompt for parameter ok (optional)
161 ;Input: SCT=report title
162 ;Output: '1' if ok, '0' otherwise
163 ;
164 N SCL,SCI,SCX,SCOUT,SCLAB,SCF,SCVAL,COL,DTOUT,DUOUT
165 S COL=$S($E(IOST)="C":12,1:38)
166 S (SCI,SCOUT)=0,SCLAB="",SCL=1
167 F S SCI=$O(@SC@("XR",SCI)) Q:'SCI!SCOUT D
168 .S SCX=$O(@SC@("XR",SCI,"")),SCLAB=@SC@("XR",SCI,SCX)
169 .I $E(IOST)="C",SCL>18 D WAIT Q:SCOUT S SCL=0
170 .I $E(IOST)="P",$Y>(IOSL-4) D HDR(.SCT) Q:SCOUT
171 .S SCL=SCL+1 W ! Q:SCX="SPACE"
172 .S SCL=SCL+1 W !?(COL),$J(SCLAB,24),": "
173 .I SCX="DTR" W @SC@("DTR","PBDT")," to ",@SC@("DTR","PEDT") Q
174 .I $G(@SC@(SCX))="ALL" W "ALL" Q
175 .I $D(@SC@(SCX))=1 W $P(@SC@(SCX),U,2) Q
176 .I SCX="SORT" S SCF=0,SCVAL=0 D Q
177 ..F S SCVAL=$O(@SC@(SCX,SCVAL)) Q:'SCVAL!SCOUT D
178 ...I SCF,$E(IOST)="C",SCL>18 D WAIT Q:SCOUT S SCL=0
179 ...I SCF,$E(IOST)="P",$Y>(IOSL-4) D HDR(.SCT) Q:SCOUT
180 ...I SCF W ! S SCL=SCL+1
181 ...W ?(COL+26+$S(SCX="SORT":(SCF*2),1:0)),$P(@SC@(SCX,SCVAL),U,2)
182 ...S SCF=SCF+1
183 ...Q
184 ..Q
185 .S SCF=0,SCVAL=999999999999
186 .F S SCVAL=$O(@SC@(SCX,SCVAL)) Q:SCVAL=""!SCOUT D
187 ..I $E(IOST)="C",SCL>18 D WAIT Q:SCOUT S SCL=0
188 ..I $E(IOST)="P",$Y>(IOSL-4) D HDR(.SCT) Q:SCOUT
189 ..I SCF W ! S SCL=SCL+1
190 ..W ?(COL+26+$S(SCX="SORT":(SCF*2),1:0)),SCVAL
191 ..S SCF=SCF+1
192 ..Q
193 .Q
194 S SCX=1 I $G(OK) N DIR S DIR(0)="Y",DIR("B")="YES",DIR("A")="OK" D
195 .W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SCX=0 Q
196 .S SCX=Y
197 .Q
198 Q SCX
199 ;
200WAIT N DIR S DIR(0)="E" W ! D ^DIR S SCOUT=Y'=1 W @IOF Q
201 ;
202HDR(SCT,SCIOM) ;Print report header
203 ;Input: SCT=array of header lines
204 ;Input: SCIOM=right margin (optional)
205 ;
206 N SCI
207 S:'$G(SCIOM) SCIOM=IOM
208 I $E(IOST)="C",SCFF N DIR S DIR(0)="E" W ! D ^DIR S SCOUT=Y'=1 Q:SCOUT
209 D STOP Q:SCOUT
210 I SCFF!($E(IOST)="C") W $$XY^SCRPW50(IOF,1,0)
211 I $X W $$XY^SCRPW50("",0,0)
212 W SCLINE
213 S SCI=0 F S SCI=$O(SCT(SCI)) Q:'SCI D
214 .W !?(SCIOM-$L(SCT(SCI))\2),SCT(SCI)
215 .Q
216 W !,SCLINE,!,"Date printed: ",SCPNOW,?(SCIOM-6-$L(SCPAGE)),"Page: ",SCPAGE
217 W !,SCLINE S SCFF=1,SCPAGE=SCPAGE+1
218 Q
219 ;
220STOP ;Check for stop task request
221 S:$D(ZTQUEUED) (SCOUT,ZTSTOP)=$S($$S^%ZTLOAD:1,1:0) Q
222 ;
223ELIG(DFN) ;Get Primary Eligibility
224 ;Input: DFN=patient ifn
225 N PRIM,PRIM1
226 S PRIM=$P($G(^DPT(DFN,.36)),U) Q:PRIM<1 "[unknown]"
227 S PRIM=$P($G(^DIC(8,PRIM,0)),U,9) Q:PRIM<1 "[unknown]"
228 ;MAS Primary Eligibility Code
229 S PRIM=$P($G(^DIC(8.1,PRIM,0)),U) Q:PRIM="" "[unknown]"
230 S PRIM1=PRIM
231 ;
232 S PRIM=$TR(PRIM,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
233 I PRIM="NON-SERVICE CONNECTED" S PRIM="NSC"
234 I PRIM["SERVICE CONNECTED" S PRIM=$P(PRIM,"SERVICE CONNECTED")_"SC"_$P(PRIM,"SERVICE CONNECTED",2,999)
235 I PRIM["LESS THAN" S PRIM=$P(PRIM,"LESS THAN")_"<"_$P(PRIM,"LESS THAN",2,999)
236 I PRIM[" TO " S PRIM=$P(PRIM," TO ")_"-"_$P(PRIM," TO ",2,999)
237 I PRIM["%" S PRIM=$TR(PRIM,"%","")
238 S PRIM=$E(PRIM,1,9)
239 Q PRIM1_U_PRIM
Note: See TracBrowser for help on using the repository browser.