1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
2 | <mx:VBox
|
---|
3 | xmlns:mx="http://www.adobe.com/2006/mxml"
|
---|
4 | xmlns:pt="gov.va.med.edp.pt.demog.view.*"
|
---|
5 | xmlns:log="gov.va.med.edp.view.log.*"
|
---|
6 | width="480" height="100%"
|
---|
7 | creationComplete="initLogArea()" xmlns:widget="gov.va.med.edp.widget.*">
|
---|
8 |
|
---|
9 | <mx:Script>
|
---|
10 | <![CDATA[
|
---|
11 | import gov.va.med.edp.pt.demog.view.SelectPatientEvent;
|
---|
12 | import gov.va.med.edp.pt.demog.model.PatientChecksModel;
|
---|
13 | import gov.va.med.edp.pt.demog.IPatientChecksController;
|
---|
14 | import gov.va.med.edp.widget.OkCancelDialog;
|
---|
15 | import mx.managers.IFocusManagerComponent;
|
---|
16 | import mx.controls.dataGridClasses.DataGridColumn;
|
---|
17 | import mx.events.CloseEvent;
|
---|
18 | import mx.events.DataGridEvent;
|
---|
19 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
20 | import gov.va.med.edp.control.InitLogAreaEvent;
|
---|
21 | import gov.va.med.edp.control.TrackingEvent;
|
---|
22 | import gov.va.med.edp.control.SwitchLogEntryEvent;
|
---|
23 | import gov.va.med.edp.control.SortHeaderEvent;
|
---|
24 | import gov.va.med.edp.control.PatientSelectEvent;
|
---|
25 | import gov.va.med.edp.vo.LogSelectorVO;
|
---|
26 | import gov.va.med.edp.util.AccessibilityTools;
|
---|
27 |
|
---|
28 | [Bindable]
|
---|
29 | public var ptChecksController:IPatientChecksController;
|
---|
30 |
|
---|
31 | [Bindable]
|
---|
32 | public var patientChecksModel:PatientChecksModel;
|
---|
33 |
|
---|
34 | [Bindable]
|
---|
35 | private var model:TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
36 |
|
---|
37 | private var refreshTimer: Timer = new Timer(30000); // every 30 seconds
|
---|
38 |
|
---|
39 | public function initLogArea():void
|
---|
40 | {
|
---|
41 | if (model.session.area < 1) return;
|
---|
42 |
|
---|
43 | var initEvent:InitLogAreaEvent =
|
---|
44 | new InitLogAreaEvent(InitLogAreaEvent.EVENT_INIT_LOG_AREA);
|
---|
45 | initEvent.area = model.session.area; // get the default area
|
---|
46 | initEvent.dispatch();
|
---|
47 |
|
---|
48 | refreshTimer.addEventListener(TimerEvent.TIMER, handleRefreshTimer);
|
---|
49 | startRefreshTimer();
|
---|
50 | }
|
---|
51 |
|
---|
52 | public function startRefreshTimer(): void
|
---|
53 | {
|
---|
54 | if (!refreshTimer.running) {
|
---|
55 | refreshTimer.start();
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | public function stopRefreshTimer(): void
|
---|
60 | {
|
---|
61 | refreshTimer.stop();
|
---|
62 | }
|
---|
63 |
|
---|
64 | private function handleRefreshTimer(event: TimerEvent): void
|
---|
65 | {
|
---|
66 | refreshLogSelector();
|
---|
67 | }
|
---|
68 |
|
---|
69 | public function refreshLogSelector(): void
|
---|
70 | {
|
---|
71 | if (model.appViewState == TrackingModelLocator.VIEW_APP_EDIT_CLOSED) return;
|
---|
72 | if (model.logEntryList.token == "") return; // only refresh after initLogArea called
|
---|
73 | if (model.logEdit.dirty) return; // only refresh no changes pending
|
---|
74 |
|
---|
75 | var refreshEvent: TrackingEvent =
|
---|
76 | new TrackingEvent(TrackingEvent.EVENT_REFRESH_LOG_SELECTOR);
|
---|
77 | refreshEvent.dispatch();
|
---|
78 | }
|
---|
79 |
|
---|
80 | public function confirmSwitch(): void
|
---|
81 | {
|
---|
82 |
|
---|
83 | if (model.logEdit.dirty) {
|
---|
84 | OkCancelDialog.show("Are you sure you want to change patients?\n\n" +
|
---|
85 | "You have unsaved changes.\nIf you continue, you will lose the changes.\n\n" +
|
---|
86 | "Press OK to continue and lose the changes.\n" +
|
---|
87 | "Press Cancel to stay and save the changes.", "Discard Changes?", confirmSwitchHandler, activePtsLbl);
|
---|
88 | } else {
|
---|
89 | switchLogEntry();
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | public function confirmSwitchHandler(event: CloseEvent): void
|
---|
94 | {
|
---|
95 | if (event.detail == OkCancelDialog.OK) {
|
---|
96 | switchLogEntry();
|
---|
97 | } else {
|
---|
98 | model.synchToLastEntry(); // TODO: move this to an event
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | public function switchLogEntry(): void
|
---|
103 | {
|
---|
104 | if (grdLogEntries.selectedItem == null) return;
|
---|
105 |
|
---|
106 | var switchEvent: SwitchLogEntryEvent =
|
---|
107 | new SwitchLogEntryEvent(SwitchLogEntryEvent.EVENT_SWITCH_LOG_ENTRY);
|
---|
108 | switchEvent.logID = LogSelectorVO(grdLogEntries.selectedItem).id;
|
---|
109 | switchEvent.selectedIndex = grdLogEntries.selectedIndex;
|
---|
110 | switchEvent.dispatch();
|
---|
111 | }
|
---|
112 |
|
---|
113 | private function addLogEntry(event: SelectPatientEvent): void
|
---|
114 | {
|
---|
115 | var addEvent: PatientSelectEvent =
|
---|
116 | new PatientSelectEvent(PatientSelectEvent.EVENT_ADD_PATIENT_TO_LOG);
|
---|
117 | addEvent.newPatient = event.patient;
|
---|
118 | addEvent.dispatch();
|
---|
119 | }
|
---|
120 |
|
---|
121 | private function addVisible(appState: int): Boolean
|
---|
122 | {
|
---|
123 | switch (appState) {
|
---|
124 | case TrackingModelLocator.VIEW_APP_SIGN_IN:
|
---|
125 | case TrackingModelLocator.VIEW_APP_TRIAGE:
|
---|
126 | return true;
|
---|
127 | default:
|
---|
128 | return false;
|
---|
129 | }
|
---|
130 | }
|
---|
131 |
|
---|
132 | // scrollIndex doesn't appear to find the correct entry
|
---|
133 | // if the call is not delayed
|
---|
134 | private function delayScroll(index: int): void
|
---|
135 | {
|
---|
136 | grdLogEntries.scrollToIndex(index);
|
---|
137 | }
|
---|
138 |
|
---|
139 | private function scrollIndex(index: int):int
|
---|
140 | {
|
---|
141 | grdLogEntries.selectedIndex = index;
|
---|
142 | if (index < 0) return -1;
|
---|
143 | grdLogEntries.callLater(delayScroll, [index]);
|
---|
144 | return index;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // this must be called later by handleHeader for the sortField to be accurate
|
---|
148 | private function saveSortInfo(col:DataGridColumn): void
|
---|
149 | {
|
---|
150 | var sortEvent:SortHeaderEvent =
|
---|
151 | new SortHeaderEvent(SortHeaderEvent.EVENT_SORT_LOG_SELECTOR);
|
---|
152 | sortEvent.sortDescending = col.sortDescending;
|
---|
153 | sortEvent.sortField = col.dataField;
|
---|
154 | sortEvent.dispatch();
|
---|
155 | }
|
---|
156 |
|
---|
157 | private function handleHeader(event:DataGridEvent): void
|
---|
158 | {
|
---|
159 | var column:DataGridColumn = DataGridColumn(event.currentTarget.columns[event.columnIndex]);
|
---|
160 | callLater(saveSortInfo, [column]);
|
---|
161 | }
|
---|
162 |
|
---|
163 | private function renderPatientName(logSelector: LogSelectorVO,
|
---|
164 | dataField: DataGridColumn): String
|
---|
165 | {
|
---|
166 | var name: String = logSelector.name;
|
---|
167 | if (logSelector.similar) {
|
---|
168 | name = "* " + name;
|
---|
169 | } else {
|
---|
170 | name = " " + name;
|
---|
171 | }
|
---|
172 | return name;
|
---|
173 | }
|
---|
174 |
|
---|
175 | private function keyHandler(e:KeyboardEvent): void
|
---|
176 | {
|
---|
177 | if (e.keyCode == Keyboard.SPACE) {
|
---|
178 | var c:IFocusManagerComponent = focusManager.getNextFocusManagerComponent();
|
---|
179 | if (c != null) focusManager.setFocus(c);
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | ]]>
|
---|
184 | </mx:Script>
|
---|
185 |
|
---|
186 |
|
---|
187 | <mx:Canvas width="100%" height="{addPatient.height + 12}">
|
---|
188 | <pt:SelectPatientButton
|
---|
189 | id="addPatient"
|
---|
190 | label="Add Patient"
|
---|
191 | top="6"
|
---|
192 | visible="{addVisible(model.appViewState)}"
|
---|
193 | enabled="{!model.logEdit.dirty}"
|
---|
194 | selectPatient="addLogEntry(event)" tabIndex="100"
|
---|
195 | ptSelectController="{ptChecksController}"
|
---|
196 | patientChecksModel="{patientChecksModel}"/>
|
---|
197 | <widget:AccessibleLabel
|
---|
198 | tabIndex="101"
|
---|
199 | text="Active Patients"
|
---|
200 | accessibleText="Info Active Patients Selector Area"
|
---|
201 | id="activePtsLbl"
|
---|
202 | horizontalCenter="0"
|
---|
203 | verticalCenter="0"
|
---|
204 | styleName="subTitle"/>
|
---|
205 | </mx:Canvas>
|
---|
206 |
|
---|
207 | <!-- Modified by jtorreno 2008.01.31 to implement accessibility functionality - Start -->
|
---|
208 | <mx:DataGrid
|
---|
209 | id="grdLogEntries"
|
---|
210 | initialize="{AccessibilityTools.accessComponentName(grdLogEntries,'Active Patients')}"
|
---|
211 | width="100%" height="100%"
|
---|
212 | dataProvider="{model.logEntryList.entries}"
|
---|
213 | selectedIndex="{scrollIndex(model.logEntryList.selectedIndex)}"
|
---|
214 | headerRelease="handleHeader(event)"
|
---|
215 | change="confirmSwitch()"
|
---|
216 | useRollOver="false" tabIndex="102"
|
---|
217 | keyUp="keyHandler(event)">
|
---|
218 | <mx:columns>
|
---|
219 | <mx:DataGridColumn dataField="bed" headerText="Bed" width="50"/>
|
---|
220 | <mx:DataGridColumn dataField="name" headerText="Name" width="210"
|
---|
221 | itemRenderer="gov.va.med.edp.widget.PatientNameRenderer"/>
|
---|
222 | <mx:DataGridColumn dataField="ssn" headerText="SSN" width="80"/>
|
---|
223 | </mx:columns>
|
---|
224 | </mx:DataGrid>
|
---|
225 | <!-- Modified by jtorreno 2008.01.31 to implement accessibility functionality - End -->
|
---|
226 |
|
---|
227 | </mx:VBox>
|
---|