source: cprs/branches/tmg-cprs/CPRS-Chart/JAWS Support Files/CPRSChart.JSS@ 1582

Last change on this file since 1582 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

File size: 16.5 KB
Line 
1Include "HjGlobal.jsh" ; default HJ global variables
2Include "hjconst.jsh" ; default HJ constants
3
4globals
5 int CoverVitalsID,
6 int ODProcReasonForRequestID,
7 int ODProcInpatientID,
8 int ODProcOutpatientID,
9 int ODCsltReasonForCsltID,
10 int ODCsltInpatientID,
11 int ODCsltOutpatientID,
12 int PtCWADAllergiesID,
13 int PtSelNotificationsID,
14 int TemplateEditorBlankLinesID,
15 int MedsInpatientID,
16 int MedsOutPatientID,
17 int ODMedsCommentsID,
18 int ODMedsPriorityID,
19 int NotesViewMenuID,
20 int ConsultsByStatusStatusID,
21 int ConsultActionCommentsID,
22 int ConsultActionAlertID,
23 int CurrentMenuContext
24
25Const
26 NoMenuContext = 0,
27 NotesActionMenuContext = 1,
28 NotesViewMenuContext = 2,
29 ConsultsActionMenuContext = 3,
30 ConsultsTrackingMenuContext = 4,
31 ConsultsViewMenuContext = 5
32
33
34;The component ID's vary from compile to compile, so constants aren't much help for identifying the components.
35;Instead, we use the component's hierarchical position as an address to locate it as a descendant of the form.
36;Finding addresses can be tricky. Uncomment the SayString line below to test an address by tracing through the address resolution.
37;If there are a lot of panels to wade through, it's easier to run CPRS with the Inspector that comes with MSAA developers kit.
38;Get the focus on the control you want, and work with the parent/child/siblings buttons to see where they fit in the order.
39;Note that MSAA Inspector treats "window" objects as parents of the corresponding "client" objects,
40;while the "GetFirstChild" JAWS script routine considers them to be part of the ame object. So, the addresses used here will be half as long
41;as what you will find in MSAA land.
42handle function GetHandleFromAddress(handle Parent, string Address)
43 var
44 int AddressIndex,
45 string AddressPart,
46 int TabsLeft,
47 handle ControlAtAddress
48 let AddressIndex = 1
49 let AddressPart = StringSegment(Address, " ", AddressIndex)
50 let ControlAtAddress = Parent
51 while AddressPart != "" && ControlAtAddress != 0
52 let TabsLeft = StringToInt(AddressPart) - 1
53 let ControlAtAddress = GetFirstChild(ControlAtAddress)
54 ;SayString( "Control is " + GetWindowClass(ControlAtAddress) + GetWindowName(ControlAtAddress) + IntToString(TabsLeft) + " tabs left to go.")
55 while TabsLeft > 0
56 let TabsLeft = TabsLeft - 1
57 let ControlAtAddress = GetNextWindow(ControlAtAddress)
58 ;SayString( "Control is " + GetWindowClass(ControlAtAddress) + GetWindowName(ControlAtAddress) + IntToString(TabsLeft) + " tabs left to go.")
59 endwhile
60 let AddressIndex = AddressIndex+1
61 let AddressPart = StringSegment(Address, " ", AddressIndex)
62 endwhile
63 return ControlAtAddress
64endFunction
65
66handle function GetCurrentPageHandle()
67 var
68 handle ContainingWindow
69 let ContainingWindow = GetRealWindow(GetFocus())
70 if GetWindowClass(ContainingWindow) == "TfrmFrame" then
71 return GetHandleFromAddress(ContainingWindow, "1 1 1"); pnlPatientSelected, pnlPage, frmPage
72 else
73 return 0
74 endif
75endFunction
76
77string function YankString(string S, string Except, int ByRef Yanked)
78 let Yanked = SubString(S, 1, StringLength(Except)) == Except
79 if Yanked then
80 return SubString(S, StringLength(Except)+1, StringLength(S)-StringLength(Except))
81 else
82 return S
83 endif
84endFunction
85
86string function StripControls( string KeyName, int ByRef Shifted, int ByRef Controlled, int ByRef Alted)
87 var
88 string S
89 let S = KeyName
90 let S = YankString(S, "LeftAlt+", Alted)
91 if not Alted then
92 let S = YankString(S, "RightAlt+", Alted)
93 endif
94 let S = YankString(S, "LeftControl+", Controlled)
95 if not Controlled then
96 let S = YankString(S, "RightControl+", Controlled)
97 endif
98 let S = YankString(S, "LeftShift+", Shifted)
99 if not Shifted then
100 let S = YankString(S, "RightShift+", Shifted)
101 endif
102 return S
103endFunction
104
105Void Function NewTextEvent (handle hwnd, string buffer, int nAttributes,
106int nTextColor, int nBackgroundColor, int nEcho, string sFrameName)
107 var
108 string sClass
109 Let sClass = GetWindowClass (hWnd)
110 if sClass != "TORComboEdit" then
111 NewTextEvent(hwnd,buffer,nAttributes,nTextColor,nBackgroundColor,nEcho,sFrameName)
112 endif
113EndFunction
114
115
116Void Function FocusChangedEvent (handle FocusWindow, handle PrevWindow)
117 var
118 string Class,
119 int ID,
120 handle ContainingWindow,
121 handle CurrentPage,
122 handle FormHandle
123 ;Populate component ID's
124 Let ContainingWindow = GetRealWindow(FocusWindow)
125 Let CurrentPage = GetCurrentPageHandle();
126 if GetWindowClass(CurrentPage) == "TfrmCover" then
127 if CoverVitalsID == 0 then
128 let FormHandle = GetHandleFromAddress(CurrentPage, "1 1 2 1 2");pnlBase, pnlBottom, pnl_Not8, pnl_7, lst_7
129 let CoverVitalsID = GetControlID(FormHandle)
130 endif
131 elif GetWindowClass(CurrentPage) == "TfrmMeds" then
132 if MedsInPatientID == 0 then
133 let MedsInPatientID = GetControlID(GetHandleFromAddress(CurrentPage, "2 3")); pnlMedIn, lstMedsIn
134 endif
135 if MedsOutPatientID == 0 then
136 let MedsOutPatientID = GetControlID(GetHandleFromAddress(CurrentPage, "1 2")); pnlMedOut, lstMedsOut
137 endif
138 elif GetWindowClass(ContainingWindow) == "TfrmODProc" then
139 if ODProcReasonForRequestID == 0 then
140 let FormHandle = GetHandleFromAddress(ContainingWindow, "16 1"); pnlReason, memReason
141 let ODProcReasonForRequestID = GetControlID(FormHandle)
142 endif
143 if ODProcInpatientID == 0 then
144 let FormHandle = GetHandleFromAddress(ContainingWindow, "12"); radInpatient
145 let ODProcInpatientID = GetControlID(FormHandle)
146 endif
147 if ODProcOutpatientID == 0 then
148 let FormHandle = GetHandleFromAddress(ContainingWindow, "11"); radOtpatient
149 let ODProcOutpatientID = GetControlID(FormHandle)
150 endif
151 elif GetWindowClass(ContainingWindow) == "TfrmODCslt" then
152 if ODCsltReasonForCsltID == 0 then
153 let FormHandle = GetHandleFromAddress(ContainingWindow, "21 1"); pnlReason, memReason
154 let ODCsltReasonForCsltID= GetControlID(FormHandle)
155 endif
156 if ODCsltOutpatientID == 0 then
157 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 2"); gbInptOpt, radOutpatient
158 let ODCsltOutpatientID = GetControlID(FormHandle)
159 endif
160 if ODCsltInpatientID == 0 then
161 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 1"); gbInptOpt, radInpatient
162 let ODCsltInpatientID = GetControlID(FormHandle)
163 endif
164 elif GetWindowClass(ContainingWindow) == "TfrmPtCWAD" then
165 if PtCWADAllergiesID == 0 then
166 let FormHandle = GetHandleFromAddress(ContainingWindow, "5"); allergies
167 let PtCWADAllergiesID = GetControlID(FormHandle)
168 endif
169 elif GetWindowClass(ContainingWindow) == "TfrmPtSel" then
170 if PtSelNotificationsID == 0 then
171 let FormHandle = GetHandleFromAddress(ContainingWindow, "1"); notification
172 let PtSelNotificationsID = GetControlID(FormHandle)
173 endif
174 elif GetWindowClass(ContainingWindow) == "TfrmTemplateEditor" then
175 if TemplateEditorBlankLinesID == 0 then
176 let FormHandle = GetHandleFromAddress(ContainingWindow, "4 3 1 1 11"); pnlTop, pnlRightTop, pnlProperties, gbProperties,edtGap
177 let TemplateEditorBlankLinesID = GetControlID(FormHandle)
178 endif
179 elif GetWindowClass(ContainingWindow) == "TfrmODMeds" then
180 if ODMedsCommentsID == 0 then
181 if GetHandleFromAddress(ContainingWindow, "1 1 9") == 0 then; make sure we are in Inpatient
182 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 1 7"); pnlFields, pnlBottom, memComment
183 let ODMedsCommentsID = GetControlID(FormHandle)
184 endif
185 endif
186 if ODMedsPriorityID == 0 then
187 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 1 2 2"); pnlFields, pnlBottom, cboPriority, [Combo Edit]
188 let ODMedsPriorityID = GetControlID(FormHandle)
189 endif
190 elif GetWindowClass(ContainingWindow) == "TfrmConsultsByStatus" then
191 if ConsultsByStatusStatusID == 0 then
192 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 4"); pnlBase,lstStatus
193 let ConsultsByStatusStatusID = GetControlID(FormHandle)
194 endif
195 elif GetWindowClass(ContainingWindow) == "TfrmConsultAction" then
196 if ConsultActionCommentsID == 0 then
197 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 1 2 3"); pnlBase,pnlOther,pnlComments,memComments
198 let ConsultActionCommentsID = GetControlID(FormHandle)
199 endif
200 if ConsultActionAlertID == 0 then
201 let FormHandle = GetHandleFromAddress(ContainingWindow, "1 1 2 1 1"); pnlBase,pnlOther,pnlComments,pnlAlert,ckAlert
202 let ConsultActionAlertID = GetControlID(FormHandle)
203 endif
204 endif
205 Let Class = GetWindowClass (FocusWindow)
206 if Class == "TORListBox" then
207 Let ID = GetControlID(FocusWindow)
208 if ID == CoverVitalsID then ;Vitals list box on cover sheet
209 SayString("Vitals")
210 elif ID == PtCWADAllergiesID then; Allergies list box on patient postings
211 SayString("Allergies")
212 elif ID == ConsultsByStatusStatusID then; Status list box on consults by status dialog
213 SayString("Status")
214 SayString(GetWindowType(FocusWindow)); JAWS occasionally finds the label, so don't speak it again!
215 SayString(GetWindowText(FocusWindow, 0))
216 return
217 endif
218 elif Class == "TCaptionRichEdit" then
219 Let ID = GetControlID(FocusWindow)
220 if ID == ODProcReasonForRequestID then ;Reason for request on OD Procs
221 SayString("Reason for Request")
222 endif
223 elif Class == "TRichEdit" then
224 Let ID = GetControlID(FocusWindow)
225 if ID == ODCsltReasonForCsltID then ;Reason for request on OD Consult
226 SayString("Reason for Request")
227 endif
228 elif Class == "TRadioButton" then
229 Let ID = GetControlID(FocusWindow)
230 if ID == ID == ODCsltOutpatientID || ODProcInpatientID || ID == ODProcOutpatientID || ID == ODCsltInpatientID then ;Radio buttons on OD Procs
231 SayString("Patient will be seen as an ")
232 endif
233 elif Class == "TCaptionListView" then
234 Let ID = GetControlID(FocusWindow)
235 if ID == PtSelNotificationsID then ;Notification list on Patient select
236 SayString("Notifications")
237 endif
238 elif Class == "TCaptionEdit" then
239 Let ID = GetControlID(FocusWindow)
240 if ID == TemplateEditorBlankLinesID then ;Number of blank lines on Template Editor
241 SayString("Number of blank lines to insert between items")
242 SayString(GetWindowType(FocusWindow))
243 SayString(GetWindowText(FocusWindow, 0))
244 return
245 endif
246 elif Class == "TCaptionListBox" then
247 Let ID = GetControlID(FocusWindow)
248 if ID == MedsInPatientID then ;Inpatient Medications on Meds tab
249 SayString("Inpatient Medications")
250 elif ID == MedsOutPatientID then ;Outpatient Medications on Meds tab
251 SayString("Outpatient Medications")
252 endif
253 elif Class == "TCaptionMemo" then
254 Let ID = GetControlID(FocusWindow)
255 if ID == ODMedsCommentsID then ;Comment box on Meds order
256 SayString("Comments")
257 elif ID == ConsultActionCommentsID then ;Comment Box on consult action
258 SayString("Comments")
259 endif
260 elif Class == "TORComboEdit" then
261 Let ID = GetControlID(FocusWindow)
262 if ID == ODMedsPriorityID then ;Priority combo box on Meds order
263 SayString("Priority")
264 SayString(GetWindowType(FocusWindow))
265 SayString(GetWindowText(FocusWindow, 0))
266 return
267 endif
268 elif Class == "TCheckBox" then
269 Let ID = GetControlID(FocusWindow)
270 if ID == ConsultActionAlertID then ;Alert check box on consult action tab
271 SayString(GetWindowName(GetNextWindow(FocusWindow))) ;Auto-alert message
272 endif
273 endif
274 FocusChangedEvent(FocusWindow, PrevWindow)
275EndFunction
276
277
278Void Function AutoStartEvent ()
279 let CoverVitalsID = 0
280 let ODProcReasonForRequestID = 0
281 let ODProcInpatientID = 0
282 let ODProcOutpatientID = 0
283 let ODCsltReasonForCsltID = 0
284 let ODCsltInpatientID = 0
285 let ODCsltOutpatientID = 0
286 let PtCWADAllergiesID = 0
287 let PtSelNotificationsID = 0
288 let TemplateEditorBlankLinesID = 0
289 let MedsInPatientID = 0
290 let MedsOutPatientID = 0
291 let ODMedsCommentsID = 0
292 let ODMedsPriorityID = 0
293 let NotesViewMenuID = 0
294 let ConsultsByStatusStatusID = 0
295 let ConsultActionCommentsID = 0
296 let ConsultActionAlertID = 0
297 let CurrentMenuContext = NoMenuContext
298 AutoStartEvent ()
299EndFunction
300
301Void Function MenuBarToMenuContext(string PlainKeyName)
302 var
303 string PageName
304 let PageName = GetWindowClass(GetCurrentPageHandle())
305 if PageName == "TfrmNotes" then
306 if PlainKeyName == "A" then
307 let CurrentMenuContext = NotesActionMenuContext
308 elif PlainKeyName == "V" then
309 let CurrentMenuContext = NotesViewMenuContext
310 endif
311 elif PageName == "TfrmConsults" then
312 if PlainKeyName == "A" then
313 let CurrentMenuContext = ConsultsActionMenuContext
314 elif PlainKeyName == "V" then
315 let CurrentMenuContext = ConsultsViewMenuContext
316 endif
317 endif
318EndFunction
319
320Void Function KeyPressedEvent (int nKey, string strKeyName, int nIsBrailleKey, int nIsScriptKey)
321 var
322 string PlainKeyName,
323 int Shifted,
324 int Controlled,
325 int Alted,
326 string PageName,
327 int DoMenuBar
328 let PlainKeyName = StripControls(strKeyName, Shifted, Controlled, Alted)
329 let PageName = GetWindowClass(GetCurrentPageHandle())
330
331 ;Handle shortcut keys first
332 if PageName == "TfrmNotes" && PlainKeyName == "A" && Shifted && Controlled && not Alted then
333 SayString("Saving note without signature")
334 else
335 let DoMenuBar = GlobalMenuMode == MENUBAR_ACTIVE || (GlobalMenuMode == MENU_INACTIVE && Alted)
336 if DoMenuBar then
337 MenuBarToMenuContext(PlainKeyName)
338 elif CurrentMenuContext == NotesActionMenuContext then
339 if PlainKeyName == "A" then
340 SayString("Saving note without signature")
341 let CurrentMenuContext = NoMenuContext
342 else
343 MenuBarToMenuContext(PlainKeyName)
344 endif
345 elif CurrentMenuContext == NotesViewMenuContext then
346 if PlainKeyName == "D" then
347 SayString("Toggling note details")
348 let CurrentMenuContext = NoMenuContext
349 else
350 MenuBarToMenuContext(PlainKeyName)
351 endif
352 elif CurrentMenuContext == ConsultsActionMenuContext then
353 if PlainKeyName == "C" then
354 let CurrentMenuContext = ConsultsTrackingMenuContext
355 else
356 MenuBarToMenuContext(PlainKeyName)
357 endif
358 elif CurrentMenuContext == ConsultsTrackingMenuContext then
359 if PlainKeyName == "T" then
360 SayString("Displaying consult details")
361 let CurrentMenuContext = NoMenuContext
362 elif PlainKeyName == "U" then
363 SayString("Displaying consult results")
364 let CurrentMenuContext = NoMenuContext
365 else
366 MenuBarToMenuContext(PlainKeyName)
367 endif
368 elif CurrentMenuContext == ConsultsViewMenuContext then
369 if PlainKeyName == "F" then
370 SayString("Returning to default view")
371 let CurrentMenuContext = NoMenuContext
372 else
373 MenuBarToMenuContext(PlainKeyName)
374 endif
375 endif
376 endif
377 KeyPressedEvent (nKey, strKeyName, nIsBrailleKey, nIsScriptKey)
378EndFunction
379
380Void Function MenuModeEvent (handle WinHandle, int mode)
381 if mode == MENU_INACTIVE then
382 let CurrentMenuContext = NoMenuContext
383 endif
384 MenuModeEvent(WinHandle,mode)
385EndFunction
386
387/* Event chasing code below. Uncomment bits of this to trace the firing of events
388Void Function FocusChangedEvent (handle FocusWindow, handle PrevWindow)
389 SayString( "Focus Changed Event")
390 FocusChangedEvent(FocusWindow, PrevWindow)
391EndFunction
392
393Void Function ActiveItemChangedEvent (handle curHwnd, int curObjectId, int curChildId,
394 handle prevHwnd, int prevObjectId, int prevChildId)
395 SayString( "Active Item Changed Event")
396 ActiveItemChangedEvent (curHwnd, curObjectId, curChildId, prevHwnd, prevObjectId, prevChildId)
397EndFunction
398
399Void Function AutoFinishEvent ()
400 SayString( "Auto Finish Event")
401 AutoFinishEvent ()
402EndFunction
403
404Void Function KeyPressedEvent (int nKey, string strKeyName, int nIsBrailleKey, int nIsScriptKey)
405 SayString( "Key Pressed Event")
406 KeyPressedEvent (nKey, strKeyName, nIsBrailleKey, nIsScriptKey)
407EndFunction
408
409void function ObjStateChangedEvent (handle hObj)
410 SayString( "Object State Changed Event")
411 ObjStateChangedEvent (hObj)
412EndFunction
413
414Void Function FocusPointMovedEvent (int nX, int nY, int nOldX, int nOldY, int nUnit, int nDir, int nTimeElapsed)
415 SayString( "Focus Point Moved Event")
416 FocusPointMovedEvent (nX, nY, nOldX, nOldY, nUnit, nDir, nTimeElapsed)
417EndFunction
418
419Void Function ValueChangedEvent (handle hwnd, int objId, int childId, int nObjType, string sObjName, string sObjValue)
420 SayString( "Value Changed Event")
421 ValueChangedEvent (hwnd, objId, childId, nObjType, sObjName, sObjValue)
422EndFunction
423
424Void Function DocumentLoadedEvent ()
425 SayString( "Dcoument Loaded Event")
426 DocumentLoadedEvent ()
427EndFunction
428
429void function FormsModeEvent(int bEntering)
430 SayString( "Forms Mode Event")
431 FormsModeEvent(bEntering)
432EndFunction
433
434void function TextSelectedEvent(string strText, int bUnSelecting)
435 SayString( "Text Selected Event")
436 TextSelectedEvent(strText, bUnSelecting)
437EndFunction
438/* End of event chasing */
439
440
Note: See TracBrowser for help on using the repository browser.