source: EDIS/tags/ed/tracking-ui-core/src/main/flex/gov/va/med/edp/view/log/LogEntryEditor.mxml@ 1240

Last change on this file since 1240 was 1240, checked in by George Lilly, 13 years ago

new version from the VA

File size: 18.8 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!-- LogEntryEditor.mxml -->
3
4<mx:VBox
5 xmlns:mx="http://www.adobe.com/2006/mxml"
6 xmlns:widget="gov.va.med.edp.widget.*"
7 xmlns:log="gov.va.med.edp.view.log.*"
8 xmlns:accessibility="flash.accessibility.*"
9 currentState="{model.logEntryViewState}"
10 keyDown="keyHandler(event)" >
11
12 <mx:states>
13 <mx:State name="Message" enterState="initMessageState()" >
14 <mx:RemoveChild target="{patientBar}" />
15 <mx:RemoveChild target="{entryForm}" />
16 <mx:RemoveChild target="{btnArea}" />
17 <mx:AddChild>
18 <mx:Canvas id="msgArea" width="100%" height="100%" >
19 <mx:TextArea
20 id="txtMsg"
21 accessibilityProperties="{accMsg}"
22 text="{model.logEdit.message}"
23 tabIndex="99"
24 restrict="*~_"
25 horizontalCenter="0" verticalCenter="0" textAlign="center"
26 styleName="accessibleControlLabel" />
27 </mx:Canvas>
28 </mx:AddChild>
29 </mx:State>
30 <mx:State name="EditClosed" enterState="initEditState()" >
31 <mx:AddChild relativeTo="{entryForm}" position="after">
32 <log:DiagnosesFreeText width="100%" paddingBottom="18" />
33 </mx:AddChild>
34 </mx:State>
35 <mx:State name="EditClosedCoded" enterState="initEditState()" >
36 <mx:AddChild relativeTo="{entryForm}" position="after">
37 <log:DiagnosesCoded width="100%" paddingBottom="18" />
38 </mx:AddChild>
39 </mx:State>
40 <mx:State name="SignIn" enterState="initEditState()" >
41 <mx:RemoveChild target="{longComplaintItem}" />
42 <mx:RemoveChild target="{acuityItem}" />
43 <mx:RemoveChild target="{clinicItem}" />
44 <mx:RemoveChild target="{statusItem}" />
45 <mx:RemoveChild target="{providerItem}" />
46 <mx:RemoveChild target="{residentItem}" />
47 <mx:RemoveChild target="{nurseItem}" />
48 <mx:RemoveChild target="{commentItem}" />
49 <mx:RemoveChild target="{dispositionItem}" />
50 <mx:RemoveChild target="{delayItem}" />
51 <mx:RemoveChild target="{timeInItem}" />
52 <mx:RemoveChild target="{timeOutItem}" />
53 </mx:State>
54 <mx:State name="Triage" enterState="initEditState()">
55 <mx:RemoveChild target="{commentItem}" />
56 <mx:RemoveChild target="{dispositionItem}" />
57 <mx:RemoveChild target="{delayItem}" />
58 <mx:RemoveChild target="{timeInItem}" />
59 <mx:RemoveChild target="{timeOutItem}" />
60 </mx:State>
61 <mx:State name="Update" enterState="initEditState()" >
62 <mx:RemoveChild target="{complaintItem}" />
63 <mx:RemoveChild target="{longComplaintItem}" />
64 <mx:RemoveChild target="{acuityItem}" />
65 <mx:RemoveChild target="{clinicItem}" />
66 <mx:RemoveChild target="{arrivalItem}" />
67 <mx:RemoveChild target="{dispositionItem}" />
68 <mx:RemoveChild target="{delayItem}" />
69 <mx:RemoveChild target="{timeInItem}" />
70 <mx:RemoveChild target="{timeOutItem}" />
71 </mx:State>
72 <mx:State name="UpdateNoRes" basedOn="Update" enterState="initEditState()" >
73 <mx:RemoveChild target="{residentItem}" />
74 </mx:State>
75 <mx:State name="DispDelay" enterState="initEditState()" >
76 <mx:RemoveChild target="{complaintItem}" />
77 <mx:RemoveChild target="{longComplaintItem}" />
78 <mx:RemoveChild target="{acuityItem}" />
79 <mx:RemoveChild target="{clinicItem}" />
80 <mx:RemoveChild target="{arrivalItem}" />
81 <mx:RemoveChild target="{nurseItem}" />
82 <mx:RemoveChild target="{commentItem}" />
83 <mx:RemoveChild target="{timeInItem}" />
84 <mx:RemoveChild target="{timeOutItem}" />
85 <mx:AddChild relativeTo="{entryForm}" position="after" creationPolicy="all">
86 <log:DiagnosesFreeText id="diagnosesFreeText" width="100%" paddingBottom="18" />
87 </mx:AddChild>
88 <mx:AddChild relativeTo="{btnArea}" position="firstChild" >
89 <mx:Button
90 label="Save &amp; Remove from Board"
91 enabled="{model.logEdit.entry.removeReady}"
92 click="removeEntry()" tabIndex="1899"/>
93 </mx:AddChild>
94 </mx:State>
95 <mx:State name="DispDelayCoded" basedOn="DispDelay" enterState="initEditState()" >
96 <mx:RemoveChild target="{diagnosesFreeText}" />
97 <mx:AddChild relativeTo="{entryForm}" position="after" creationPolicy="all">
98 <log:DiagnosesCoded id="diagnosesCoded" width="100%" paddingBottom="18" />
99 </mx:AddChild>
100 </mx:State>
101 </mx:states>
102
103 <mx:Script>
104 <![CDATA[
105 import gov.va.med.edp.util.AccessibilityTools;
106 import gov.va.med.edp.pt.demog.model.MatchingPatientsModel;
107 import gov.va.med.edp.pt.demog.model.PatientChecksModel;
108 import gov.va.med.edp.pt.demog.IPatientChecksController;
109 import gov.va.med.edp.widget.InfoDialog;
110 import mx.controls.TextArea;
111 import gov.va.med.edp.control.RemoveLogEntryEvent;
112 import gov.va.med.edp.vo.LogEntryVO;
113 import mx.validators.Validator;
114
115 import gov.va.med.edp.control.TrackingEvent;
116 import gov.va.med.edp.model.TrackingModelLocator;
117 import gov.va.med.edp.util.ChangeWatcher;
118
119 [Bindable]
120 public var ptChecksController:IPatientChecksController;
121
122 [Bindable]
123 public var patientChecksModel:PatientChecksModel;
124
125 [Bindable]
126 private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
127
128 [Bindable]
129 private var _showDelay: Boolean = false; // shows delay if edit closed or server rejects due to delay missing
130
131 private var _validators: Array;
132 private var _txtMsg: TextArea;
133
134 private function initMessageState(): void
135 {
136 if (AccessibilityTools.isAccessibilityActive()) {
137 callLater(txtMsg.setFocus);
138 } else {
139 txtMsg.editable = false;
140 }
141 }
142
143 private function initEditState(): void
144 {
145 // reCalc Widths
146 var item: FormItem;
147 var minWidth: int = 30;
148 var newWidth: int;
149
150 for (var i: int = 0; i < entryForm.numChildren; i++) {
151 item = entryForm.getChildAt(i) as FormItem;
152 newWidth = item.measureText(item.label + "M").width;
153 if (newWidth > minWidth) {
154 minWidth = newWidth;
155 }
156 }
157 entryForm.setStyle("labelWidth", minWidth);
158
159 // set up validators
160 switch (model.appViewState) {
161 case TrackingModelLocator.VIEW_APP_SIGN_IN:
162 _validators = [complaintValid, bedValid];
163 break;
164 case TrackingModelLocator.VIEW_APP_TRIAGE:
165 _validators = [complaintValid, bedValid, acuityValid, clinicValid];
166 break;
167 case TrackingModelLocator.VIEW_APP_EDIT_CLOSED:
168 _validators = [complaintValid, bedValid, acuityValid, providerValid];
169 if (model.logEditParams.requireDisposition) {
170 _validators.push(dispositionValid)
171 };
172 if (model.logEditParams.requireDelay) {
173 _validators.push(delayValid)
174 };
175 _showDelay = true; // always show delay prompt for edit closed
176 break;
177 default:
178 _validators = [];
179 break;
180 }
181 if (model.logEdit.entry != null) {
182 // must call later to give a chance for the bound controls to get set
183 this.callLater(validateOnLoad);
184 }
185 }
186
187 private function saveIfValid(): void
188 {
189 var results: Array = Validator.validateAll(_validators);
190
191 if (results.length == 0) {
192 // save record if validators passed
193 var e: TrackingEvent = new TrackingEvent(TrackingEvent.EVENT_SAVE_LOG_ENTRY);
194 e.dispatch();
195 } else {
196 var msg: String = "The following must be satisfied before saving:\n";
197 for (var i: int = 0; i < results.length; i++) {
198 msg += results[i].target.source.id + "\n";
199 }
200 InfoDialog.show(msg);
201 if (msg.indexOf("delay") > -1) {
202 _showDelay = true;
203 }
204 }
205 }
206
207 public function cancelEdit(): void
208 {
209 if (model.logEdit.entry.isStub) {
210 var eDelete: TrackingEvent = new TrackingEvent(TrackingEvent.EVENT_DELETE_STUB_ENTRY);
211 eDelete.dispatch();
212 } else {
213 var eCancel: TrackingEvent = new TrackingEvent(TrackingEvent.EVENT_CANCEL_EDIT);
214 eCancel.dispatch();
215 }
216 }
217
218 private function removeEntry(): void
219 {
220 var removeEvent: RemoveLogEntryEvent =
221 new RemoveLogEntryEvent(RemoveLogEntryEvent.EVENT_REMOVE_LOG_ENTRY);
222 removeEvent.dispatch();
223 }
224
225 private function set currentEntry(entry: LogEntryVO): void
226 {
227 if (entry == null) return;
228
229 //make sure that outTS is disabled for the patients that are still active.
230 //This could potentially mess up data for the active listed patients on the board
231 //if someone assigned them an outTS while they still haven't been discharged..
232 if (!entry.closed) {
233 outTS.selectedDate = null;
234 outTS.enabled = false;
235 outTS.toolTip = "The patient needs to be discharged first to make this field active."
236 } else {
237 outTS.enabled = true;
238 outTS.toolTip = "";
239 }
240 // init _showDelay to false unless we're in edit closed
241 // (usually the model will say whether we need delay reason
242 _showDelay = (model.appViewState == TrackingModelLocator.VIEW_APP_EDIT_CLOSED);
243
244 if (model.logEditParams.promptClinics && (entry.visit == 0)) {
245 clinicItem.visible = true;
246 clinicItem.includeInLayout = true;
247 } else {
248 clinicItem.visible = false;
249 clinicItem.includeInLayout = false;
250 }
251 }
252
253 private function set patientSelectionComplete(isDone: Boolean): void
254 {
255 if (isDone) {
256 // get JAWS to the first prompt after adding a new patient
257 //this.callLater(complaint.setFocus);
258 this.callLater(complaint.setFocus);
259 //var fi: FormItem = entryForm.getChildAt(0) as FormItem;
260 //trace("first child", fi.tabChildren);
261 }
262 }
263
264 private function validateOnLoad(): void
265 {
266 // must set the errorString to null to get the red border to reset
267 complaint.errorString = "";
268 longComplaint.errorString = "";
269 comment.errorString = "";
270 bed.errorString = "";
271 acuity.errorString = ""
272 provider.errorString = "";
273 disposition.errorString = "";
274 delay.errorString = "";
275 clinic.errorString = "";
276 Validator.validateAll(_validators);
277 }
278
279 private function keyHandler(e:KeyboardEvent): void
280 {
281 if (e.keyCode == Keyboard.ESCAPE) {
282 cancelEdit();
283 }
284 }
285 ]]>
286 </mx:Script>
287
288 <log:PatientHeaderBar id="patientBar" width="100%" ptChecksController="{ptChecksController}"
289 patientChecksModel="{patientChecksModel}"/>
290
291 <mx:Form id="entryForm" width="100%">
292
293 <mx:FormItem
294 id="complaintItem"
295 label="Complaint for Display Board"
296 width="100%" >
297 <mx:Canvas width="100%">
298 <mx:TextInput
299 id="complaint"
300 text="{model.logEdit.entry.complaint}"
301 change="ChangeWatcher.changeField(event)"
302 left="0" right="0"
303 styleName="formField" tabIndex="1100"/>
304 </mx:Canvas>
305 </mx:FormItem>
306
307 <mx:FormItem
308 id="longComplaintItem"
309 label="Long Complaint (optional)"
310 width="100%" >
311 <mx:Canvas width="100%" >
312 <mx:TextInput
313 id="longComplaint"
314 text="{model.logEdit.entry.longComplaint}"
315 change="ChangeWatcher.changeField(event)"
316 left="0" right="0"
317 styleName="formField" tabIndex="1101"/>
318 </mx:Canvas>
319 </mx:FormItem>
320
321 <mx:FormItem
322 id="bedItem" width="100%"
323 label="Room / Area" >
324 <widget:ValueComboBox
325 id="bed"
326 dataProvider="{model.logEdit.beds}"
327 value="{model.logEdit.entry.bed}"
328 change="ChangeWatcher.changeField(event)"
329 rowCount="20"
330 styleName="formField" tabIndex="1102"/>
331 </mx:FormItem>
332
333 <mx:FormItem
334 id="acuityItem" width="100%"
335 label="Acuity" >
336 <widget:ValueComboBox
337 id="acuity"
338 dataProvider="{model.logEdit.acuities}"
339 value="{model.logEdit.entry.acuity}"
340 change="ChangeWatcher.changeField(event)"
341 rowCount="{model.logEdit.acuities.length}"
342 styleName="formField" tabIndex="1103"/>
343 </mx:FormItem>
344
345 <mx:FormItem
346 id="statusItem" width="100%"
347 label="Status" >
348 <widget:ValueComboBox
349 id="status"
350 dataProvider="{model.logEdit.statuses}"
351 value="{model.logEdit.entry.status}"
352 change="ChangeWatcher.changeField(event)"
353 rowCount="{model.logEdit.statuses.length}"
354 styleName="formField" tabIndex="1104"/>
355 </mx:FormItem>
356
357 <mx:FormItem
358 id="providerItem" width="100%"
359 label="Provider" >
360 <widget:ValueComboBox
361 id="provider"
362 dataProvider="{model.logEdit.providers}"
363 value="{model.logEdit.entry.provider}"
364 change="ChangeWatcher.changeField(event)"
365 rowCount="12"
366 styleName="formField" tabIndex="1105"/>
367 </mx:FormItem>
368
369 <mx:FormItem
370 id="residentItem" width="100%"
371 label="Resident" >
372 <widget:ValueComboBox
373 id="resident"
374 dataProvider="{model.logEdit.residents}"
375 value="{model.logEdit.entry.resident}"
376 change="ChangeWatcher.changeField(event)"
377 rowCount="12"
378 styleName="formField" tabIndex="1106"/>
379 </mx:FormItem>
380
381 <mx:FormItem
382 id="nurseItem" width="100%"
383 label="Nurse" >
384 <widget:ValueComboBox
385 id="nurse"
386 dataProvider="{model.logEdit.nurses}"
387 value="{model.logEdit.entry.nurse}"
388 change="ChangeWatcher.changeField(event)"
389 rowCount="12"
390 styleName="formField" tabIndex="1107"/>
391 </mx:FormItem>
392
393 <mx:FormItem
394 id="commentItem"
395 label="Comments"
396 width="100%" >
397 <mx:Canvas width="100%">
398 <mx:TextInput
399 id="comment"
400 text="{model.logEdit.entry.comment}"
401 change="ChangeWatcher.changeField(event)"
402 right="0" left="0"
403 styleName="formField" tabIndex="1108"/>
404 </mx:Canvas>
405 </mx:FormItem>
406
407 <mx:FormItem
408 id="arrivalItem" width="100%"
409 label="Source" >
410 <widget:ValueComboBox
411 id="arrival"
412 dataProvider="{model.logEdit.arrivals}"
413 value="{model.logEdit.entry.arrival}"
414 change="ChangeWatcher.changeField(event)"
415 rowCount="{model.logEdit.arrivals.length}"
416 styleName="formField" tabIndex="1109"/>
417 </mx:FormItem>
418
419 <mx:FormItem
420 id="clinicItem" width="100%"
421 label="Clinic" >
422 <widget:ValueComboBox
423 id="clinic"
424 dataProvider="{model.logEdit.clinics}"
425 value="{model.logEdit.entry.clinic}"
426 change="ChangeWatcher.changeField(event)"
427 rowCount="{model.logEdit.clinics.length}"
428 styleName="formField" tabIndex="1110"/>
429 </mx:FormItem>
430
431 <mx:FormItem
432 id="dispositionItem" width="100%"
433 label="Disposition" >
434 <widget:ValueComboBox
435 id="disposition"
436 dataProvider="{model.logEdit.dispositions}"
437 value="{model.logEdit.entry.disposition}"
438 change="ChangeWatcher.changeField(event)"
439 rowCount="{model.logEdit.dispositions.length}"
440 styleName="formField" tabIndex="1111"/>
441 </mx:FormItem>
442
443 <mx:FormItem
444 id="delayItem" width="100%"
445 visible="{(_showDelay || model.logEdit.entry.requireDelay)}"
446 label="Delay Reason">
447 <widget:ValueComboBox
448 id="delay"
449 dataProvider="{model.logEdit.delays}"
450 value="{model.logEdit.entry.delay}"
451 change="ChangeWatcher.changeField(event)"
452 rowCount="{model.logEdit.delays.length}"
453 styleName="formField" tabIndex="1112"/>
454 </mx:FormItem>
455
456 <mx:FormItem
457 id="timeInItem" width="100%"
458 label="Time In">
459 <widget:DateTimeChooser
460 id="inTS"
461 tabEnabled="true"
462 dateType="Time In"
463 selectedDate="{model.logEdit.entry.inTS}"
464 change="ChangeWatcher.changeField(event)"
465 styleName="formField" tabIndexBase="1113"/>
466 </mx:FormItem>
467
468 <mx:FormItem
469 id="timeOutItem" width="100%"
470 label="Time Out">
471 <widget:DateTimeChooser
472 id="outTS"
473 tabEnabled="true"
474 dateType="Time Out"
475 selectedDate="{model.logEdit.entry.outTS}"
476 change="ChangeWatcher.changeField(event)"
477 styleName="formField" tabIndexBase="1114"/>
478 </mx:FormItem>
479
480 </mx:Form>
481
482 <mx:Canvas id="btnArea" width="100%" >
483 <mx:Button
484 id="cancel"
485 label="Cancel"
486 enabled="{model.logEdit.dirty}"
487 click="cancelEdit()"
488 right="{save.width + 12}" tabIndex="1900"/>
489 <mx:Button
490 id="save"
491 label="Save"
492 enabled="{model.logEdit.dirty}"
493 click="saveIfValid()"
494 right="6" tabIndex="1901"/>
495 </mx:Canvas>
496
497 <mx:StringValidator
498 id="complaintValid"
499 source="{complaint}" property="text"
500 maxLength="50" required="true" />
501 <mx:StringValidator
502 id="longCompValid"
503 source="{longComplaint}" property="text"
504 maxLength="220" required="false" />
505 <mx:StringValidator
506 id="commentValid"
507 source="{comment}" property="text"
508 maxLength="80" required="false" />
509 <mx:NumberValidator
510 id="bedValid"
511 source="{bed}" property="selectedIndex"
512 minValue="1" required="true" lowerThanMinError="A room must be selected." />
513 <mx:NumberValidator
514 id="acuityValid"
515 source="{acuity}" property="selectedIndex"
516 minValue="1" required="true" lowerThanMinError="An acuity must be selected." />
517 <mx:NumberValidator
518 id="providerValid"
519 source="{provider}" property="selectedIndex"
520 minValue="1" required="true" lowerThanMinError="A provider must be selected." />
521 <mx:NumberValidator
522 id="clinicValid"
523 source="{clinic}" property="selectedIndex"
524 minValue="1"
525 required="{(model.logEditParams.promptClinics &amp;&amp; (model.logEdit.entry.visit == 0))}"
526 lowerThanMinError="A clinic must be selected." />
527 <mx:NumberValidator
528 id="dispositionValid"
529 source="{disposition}" property="selectedIndex"
530 minValue="1" required="{model.logEdit.entry.requireDisposition}" lowerThanMinError="A disposition must be selected." />
531 <mx:NumberValidator
532 id="delayValid"
533 source="{delay}" property="selectedIndex"
534 minValue="1" required="{model.logEdit.entry.requireDelay}" lowerThanMinError="A delay reason must be selected." />
535
536 <accessibility:AccessibilityProperties id="accMsg" name="Info Status Message" />
537
538 <!-- bind to this so we know when the entry changes -->
539 <mx:Binding source="model.logEdit.entry" destination="currentEntry" />
540 <mx:Binding source="model.logEdit.patientSelected" destination="patientSelectionComplete" />
541</mx:VBox>
Note: See TracBrowser for help on using the repository browser.