source: EDIS/trunk/java/tracking-ui-core/src/main/flex/gov/va/med/edp/view/log/DiagnosesCoded.mxml@ 1227

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

initial load of EDIS 1.0

File size: 8.5 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:widget="gov.va.med.edp.widget.*">
3 <mx:Script>
4 <![CDATA[
5 import gov.va.med.edp.widget.InfoDialog;
6 import mx.events.CollectionEvent;
7 import gov.va.med.edp.model.LogEdit;
8 import mx.controls.ComboBox;
9 import mx.controls.CheckBox;
10 import gov.va.med.edp.vo.PCECodedValueVO;
11 import gov.va.med.edp.model.TrackingModelLocator;
12 import mx.collections.ICollectionView;
13 import gov.va.med.edp.control.MatchItemsEvent;
14 import gov.va.med.edp.control.ChangeLogEntryFieldEvent;
15 import gov.va.med.edp.util.AccessibilityTools;
16 import gov.va.med.edp.util.KeyUtils;
17
18 [Bindable]
19 private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
20
21 private function set selectFirstDiagnosisMatch(value: Boolean): void
22 {
23 if (value && model.matchingDiagnoses.length > 0){
24 diagnosisMatches.selectedIndex = 0;
25 diagnosisMatches.setFocus();
26 }
27 }
28
29 private function set setPrimaryBtnState(codedValue: PCECodedValueVO): void
30 {
31 if (codedValue){
32 primaryDiagnosisBtn.enabled = true;
33 } else {
34 primaryDiagnosisBtn.enabled = false;
35 }
36 }
37
38 private function setPrimaryDiagnosis():void {
39 var selectedDiagnosis:PCECodedValueVO = selectedDiagnosisGrid.selectedItem as PCECodedValueVO;
40 if (selectedDiagnosis == null) return;
41
42 model.logEdit.entry.diagnoses.filterFunction = null;
43
44 for each (var enteredDiagnosis: PCECodedValueVO in model.logEdit.entry.diagnoses) {
45 enteredDiagnosis.updated = true;
46 if (enteredDiagnosis.code == selectedDiagnosis.code){
47 enteredDiagnosis.primary = true;
48 } else {
49 enteredDiagnosis.primary = false;
50 }
51 var updateEvent:ChangeLogEntryFieldEvent =
52 new ChangeLogEntryFieldEvent(ChangeLogEntryFieldEvent.EVENT_CHANGE_LOG_ENTRY_FIELD);
53 updateEvent.clear = false;
54 updateEvent.field = "diagnoses";
55 updateEvent.value = enteredDiagnosis;
56 updateEvent.dispatch();
57 }
58 }
59
60
61
62 private function addDiagnosis(): void
63 {
64 var pceItem: PCECodedValueVO = diagnosisMatches.selectedItem as PCECodedValueVO;
65
66 if (pceItem== null || isDuplicateCode(pceItem) || isEmptyCode(pceItem)) return;
67
68 if (model.logEdit.entry.diagnoses.length == 0)
69 pceItem.primary = true;
70
71 pceItem.added = true;
72 var addEvent:ChangeLogEntryFieldEvent =
73 new ChangeLogEntryFieldEvent(ChangeLogEntryFieldEvent.EVENT_CHANGE_LOG_ENTRY_FIELD);
74 addEvent.clear = false;
75 addEvent.field = "diagnoses";
76 addEvent.value = pceItem;
77 addEvent.dispatch();
78
79 if (AccessibilityTools.isAccessibilityActive())
80
81 InfoDialog.show("added successfully", "Message", true, searchBtn);
82
83 txtDiagnosis.text = "";
84 diagnosisMatches.selectedIndex = -1;
85 txtDiagnosis.setFocus();
86 }
87
88 private function isEmptyCode(selectedDiagnosis: PCECodedValueVO): Boolean
89 {
90 if (selectedDiagnosis.code == "" || selectedDiagnosis.code == null){
91 return true;
92 } else {
93 return false;
94 }
95 }
96
97 private function isDuplicateCode(selectedDiagnosis: PCECodedValueVO): Boolean
98 {
99 var enteredDiagnoses:ICollectionView = model.logEdit.entry.diagnoses;
100 for each (var enteredDiagnosis: PCECodedValueVO in enteredDiagnoses) {
101 if (selectedDiagnosis.code == enteredDiagnosis.code) return true;
102 }
103 return false;
104 }
105
106 public static function activeDiagnosisFilter(item:Object): Boolean
107 {
108 var pceItem: PCECodedValueVO = item as PCECodedValueVO;
109 return !pceItem.remove;
110 }
111
112 private function removeDiagnosis(): void
113 {
114 if (selectedDiagnosisGrid.selectedIndex < 0) return;
115
116 model.logEdit.entry.diagnoses.filterFunction = activeDiagnosisFilter;
117 model.logEdit.entry.diagnoses.refresh();
118
119 var codedValue: PCECodedValueVO = selectedDiagnosisGrid.selectedItem as PCECodedValueVO;
120 var removeEvent:ChangeLogEntryFieldEvent =
121 new ChangeLogEntryFieldEvent(ChangeLogEntryFieldEvent.EVENT_CHANGE_LOG_ENTRY_FIELD);
122 removeEvent.clear = true;
123 removeEvent.field = "diagnoses";
124 removeEvent.value = codedValue;
125 removeEvent.dispatch();
126
127 if (AccessibilityTools.isAccessibilityActive())
128 InfoDialog.show("removed successfully", "Message", true, addBtn);
129 selectedDiagnosisGrid.setFocus();
130 }
131
132 private function matchDiagnoses():void
133 {
134 diagnosisMatches.dataProvider = null;
135 var matchEvent: MatchItemsEvent =
136 new MatchItemsEvent(MatchItemsEvent.EVENT_MATCH_DIAGNOSES);
137 matchEvent.partial = txtDiagnosis.text;
138 matchEvent.dispatch();
139 }
140
141 private function addDiagnosisOnEnter(event:KeyboardEvent):void
142 {
143 if (event.keyCode == Keyboard.ENTER){
144 addDiagnosis();
145 }
146 }
147
148 private function removeDiagnosisOnDelete(event:KeyboardEvent):void
149 {
150 if (KeyUtils.isRemoveKey(event)){
151 removeDiagnosis();
152 }
153 }
154
155/*
156 Calls to validateData were removed because the diagnosis is NOT required before
157 saving the record. It is only required when removing the patient from the
158 board and closing the visit. The call to validateData was previously at the
159 end of addDiagnosis() and in the valueCommit property of selectedDiagnosisGrid.
160
161 private function validateData():void
162 {
163 if (model.logEdit.entry != null && model.logEdit.entry.requireDiagnosis){
164 if (model.logEdit.entry.diagnoses.length > 0){
165 selectedDiagnosisGrid.errorString = "";
166 } else {
167 selectedDiagnosisGrid.errorString = "At least one diagnosis must be provided.";
168 }
169 }
170 }
171*/
172
173 ]]>
174 </mx:Script>
175
176 <mx:VBox id="dxSearchBox" width="100%" verticalGap="0">
177 <mx:Label text="Diagnosis" styleName="controlLabel" />
178 <mx:HBox width="100%" id="diagnosesSearchHBox" horizontalGap="4">
179 <mx:TextInput
180 id="txtDiagnosis"
181 initialize="{AccessibilityTools.accessComponentName(txtDiagnosis,'Diagnosis search box')}"
182 width="100%"
183 enter="matchDiagnoses()"
184 paddingRight="0"
185 tabIndex="1200"/>
186 <mx:Button label="Search" id="searchBtn" tabIndex="1201" click="{matchDiagnoses()}" paddingLeft="4" paddingRight="4"/>
187 </mx:HBox>
188 <mx:Spacer height="4"/>
189 <mx:List
190 id="diagnosisMatches"
191 initialize="{AccessibilityTools.accessComponentName(diagnosisMatches, 'Diagnosis Matches List')}"
192 useRollOver="false"
193 doubleClickEnabled="true" doubleClick="{addDiagnosis()}"
194 keyDown="addDiagnosisOnEnter(event)"
195 allowMultipleSelection="false"
196 showDataTips="true"
197 dataProvider="{model.matchingDiagnoses}"
198 width="100%"
199 tabIndex="1202"/>
200 </mx:VBox>
201
202 <mx:Canvas>
203 <mx:Button
204 label="Add &gt;"
205 id="addBtn"
206 top="18"
207 horizontalCenter="0"
208 click="addDiagnosis()" tabIndex="1203"/>
209 <mx:Button
210 label="Remove"
211 top="56"
212 horizontalCenter="0"
213 click="removeDiagnosis()"
214 visible="{selectedDiagnosisGrid.selectedIndex > -1}" tabIndex="1204"/>
215 </mx:Canvas>
216
217 <mx:VBox width="100%" verticalGap="0" id="selectedBox">
218 <mx:Label text="Selected Diagnoses" styleName="controlLabel" />
219 <mx:DataGrid
220 id="selectedDiagnosisGrid"
221 dataProvider="{model.logEdit.entry.diagnoses}"
222 initialize="{AccessibilityTools.accessComponentName(selectedDiagnosisGrid,'Selected Diagnoses')}"
223 width="100%"
224 keyDown="removeDiagnosisOnDelete(event)"
225 sortableColumns="false"
226 editable="false"
227 height="{diagnosisMatches.height + txtDiagnosis.height}"
228 tabIndex="1205">
229 <mx:columns>
230 <mx:DataGridColumn
231 headerText="Diagnosis"
232 editable="false"
233 showDataTips="true"
234 dataField="label"/>
235 <mx:DataGridColumn
236 headerText="Primary?"
237 width="65"
238 dataField="primary"
239 textAlign="center"
240 itemRenderer="gov.va.med.edp.widget.YesNoRenderer"/>
241 </mx:columns>
242 </mx:DataGrid>
243 <mx:HBox width="100%" horizontalAlign="center" paddingTop="4">
244 <mx:Button id="primaryDiagnosisBtn"
245 label="Set as Primary Diagnosis"
246 click="setPrimaryDiagnosis()"
247 enabled="false" tabIndex="1206"/>
248 </mx:HBox>
249
250
251 </mx:VBox>
252
253 <mx:Binding source="model.matchingDiagnosesLoaded" destination="selectFirstDiagnosisMatch" />
254 <mx:Binding source="PCECodedValueVO(selectedDiagnosisGrid.selectedItem)" destination="setPrimaryBtnState" />
255
256</mx:HBox>
Note: See TracBrowser for help on using the repository browser.