[1227] | 1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
| 2 | <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
|
---|
| 3 | <mx:Script>
|
---|
| 4 | <![CDATA[
|
---|
| 5 | import gov.va.med.edp.widget.InfoDialog;
|
---|
| 6 | import mx.collections.ICollectionView;
|
---|
| 7 | import gov.va.med.edp.vo.PCECodedValueVO;
|
---|
| 8 | import gov.va.med.edp.model.TrackingModelLocator;
|
---|
| 9 | import gov.va.med.edp.control.ChangeLogEntryFieldEvent;
|
---|
| 10 | import gov.va.med.edp.util.AccessibilityTools;
|
---|
| 11 | import gov.va.med.edp.util.KeyUtils;
|
---|
| 12 |
|
---|
| 13 | [Bindable]
|
---|
| 14 | private var model: TrackingModelLocator = TrackingModelLocator.getInstance();
|
---|
| 15 |
|
---|
| 16 | private function setPrimaryDiagnosis():void {
|
---|
| 17 |
|
---|
| 18 | var selectedDiagnosis:PCECodedValueVO = selectedDiagnosisGrid.selectedItem as PCECodedValueVO;
|
---|
| 19 | if (selectedDiagnosis == null) return;
|
---|
| 20 |
|
---|
| 21 | model.logEdit.entry.diagnoses.filterFunction = null;
|
---|
| 22 |
|
---|
| 23 | for each (var enteredDiagnosis: PCECodedValueVO in model.logEdit.entry.diagnoses) {
|
---|
| 24 | enteredDiagnosis.updated = true;
|
---|
| 25 | if (enteredDiagnosis.label == selectedDiagnosis.label){
|
---|
| 26 | enteredDiagnosis.primary = true;
|
---|
| 27 | } else {
|
---|
| 28 | enteredDiagnosis.primary = false;
|
---|
| 29 | }
|
---|
| 30 | var updateEvent:ChangeLogEntryFieldEvent =
|
---|
| 31 | new ChangeLogEntryFieldEvent(ChangeLogEntryFieldEvent.EVENT_CHANGE_LOG_ENTRY_FIELD);
|
---|
| 32 | updateEvent.clear = false;
|
---|
| 33 | updateEvent.field = "diagnoses";
|
---|
| 34 | updateEvent.value = enteredDiagnosis;
|
---|
| 35 | updateEvent.dispatch();
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | private function addDiagnosis(): void
|
---|
| 41 | {
|
---|
| 42 | if (txtDiagnosis.text.length == 0 || isDuplicateDiagnosis(txtDiagnosis.text)) return;
|
---|
| 43 |
|
---|
| 44 | var codedValue: PCECodedValueVO = new PCECodedValueVO();
|
---|
| 45 | codedValue.code = "";
|
---|
| 46 | codedValue.label = txtDiagnosis.text;
|
---|
| 47 | txtDiagnosis.text = "";
|
---|
| 48 |
|
---|
| 49 | if (model.logEdit.entry.diagnoses.length == 0)
|
---|
| 50 | codedValue.primary = true;
|
---|
| 51 | codedValue.added = true;
|
---|
| 52 | var addEvent:ChangeLogEntryFieldEvent =
|
---|
| 53 | new ChangeLogEntryFieldEvent(ChangeLogEntryFieldEvent.EVENT_CHANGE_LOG_ENTRY_FIELD);
|
---|
| 54 | addEvent.clear = false;
|
---|
| 55 | addEvent.field = "diagnoses";
|
---|
| 56 | addEvent.value = codedValue;
|
---|
| 57 | addEvent.dispatch();
|
---|
| 58 |
|
---|
| 59 | if (AccessibilityTools.isAccessibilityActive())InfoDialog.show("added successfully", "Message", true, txtDiagnosis);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | private function isDuplicateDiagnosis(diagnosis: String): Boolean
|
---|
| 63 | {
|
---|
| 64 | var enteredDiagnoses:ICollectionView = model.logEdit.entry.diagnoses;
|
---|
| 65 | for each (var enteredDiagnosis: PCECodedValueVO in enteredDiagnoses) {
|
---|
| 66 | if (diagnosis == enteredDiagnosis.label) return true;
|
---|
| 67 | }
|
---|
| 68 | return false;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | private function set setPrimaryBtnState(codedValue: PCECodedValueVO): void
|
---|
| 72 | {
|
---|
| 73 | if (codedValue){
|
---|
| 74 | primaryDiagnosisBtn.enabled = true;
|
---|
| 75 | } else {
|
---|
| 76 | primaryDiagnosisBtn.enabled = false;
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | private function removeDiagnosis(): void
|
---|
| 81 | {
|
---|
| 82 | if (selectedDiagnosisGrid.selectedIndex < 0) return;
|
---|
| 83 |
|
---|
| 84 | model.logEdit.entry.diagnoses.filterFunction = activeDiagnosisFilter;
|
---|
| 85 | model.logEdit.entry.diagnoses.refresh();
|
---|
| 86 |
|
---|
| 87 | var codedValue: PCECodedValueVO = selectedDiagnosisGrid.selectedItem as PCECodedValueVO;
|
---|
| 88 | var removeEvent:ChangeLogEntryFieldEvent =
|
---|
| 89 | new ChangeLogEntryFieldEvent(ChangeLogEntryFieldEvent.EVENT_CHANGE_LOG_ENTRY_FIELD);
|
---|
| 90 | removeEvent.clear = true;
|
---|
| 91 | removeEvent.field = "diagnoses";
|
---|
| 92 | removeEvent.value = codedValue;
|
---|
| 93 | removeEvent.dispatch();
|
---|
| 94 | if (AccessibilityTools.isAccessibilityActive())InfoDialog.show("removed successfully", "Message", true, addBtn);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | public static function activeDiagnosisFilter(item:Object): Boolean
|
---|
| 98 | {
|
---|
| 99 | var pceItem: PCECodedValueVO = item as PCECodedValueVO;
|
---|
| 100 | return !pceItem.remove;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | private function removeDiagnosisOnDelete(event:KeyboardEvent):void
|
---|
| 104 | {
|
---|
| 105 | if (KeyUtils.isRemoveKey(event)){
|
---|
| 106 | removeDiagnosis();
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | /*
|
---|
| 111 | Calls to validateData were removed because the diagnosis is NOT required before
|
---|
| 112 | saving the record. It is only required when removing the patient from the
|
---|
| 113 | board and closing the visit. The call to validateData was previously at the
|
---|
| 114 | end of addDiagnosis() and in the valueCommit property of selectedDiagnosisGrid.
|
---|
| 115 |
|
---|
| 116 | private function validateData():void
|
---|
| 117 | {
|
---|
| 118 | if ( model.logEdit.entry != null && model.logEdit.entry.requireDiagnosis){
|
---|
| 119 | if (selectedDiagnosisGrid.dataProvider.length > 0){
|
---|
| 120 | selectedDiagnosisGrid.errorString = "";
|
---|
| 121 | } else {
|
---|
| 122 | selectedDiagnosisGrid.errorString = "At least one diagnosis must be provided.";
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | */
|
---|
| 127 |
|
---|
| 128 | ]]>
|
---|
| 129 | </mx:Script>
|
---|
| 130 | <mx:VBox width="100%" verticalGap="0">
|
---|
| 131 | <mx:Label text="Diagnosis" styleName="controlLabel" />
|
---|
| 132 | <mx:TextInput
|
---|
| 133 | id="txtDiagnosis"
|
---|
| 134 | initialize="{AccessibilityTools.accessComponentName(txtDiagnosis,'Diagnosis')}"
|
---|
| 135 | width="100%"
|
---|
| 136 | enter="addDiagnosis()"
|
---|
| 137 | tabIndex="1201"/>
|
---|
| 138 | </mx:VBox>
|
---|
| 139 |
|
---|
| 140 | <mx:Canvas>
|
---|
| 141 | <mx:Button
|
---|
| 142 | label="Add >"
|
---|
| 143 | top="18"
|
---|
| 144 | id="addBtn"
|
---|
| 145 | horizontalCenter="0"
|
---|
| 146 | click="addDiagnosis()"
|
---|
| 147 | tabIndex="1202"/>
|
---|
| 148 | <mx:Button
|
---|
| 149 | label="Remove"
|
---|
| 150 | top="56"
|
---|
| 151 | horizontalCenter="0"
|
---|
| 152 | click="removeDiagnosis()"
|
---|
| 153 | visible="{selectedDiagnosisGrid.selectedIndex > -1}"
|
---|
| 154 | tabIndex="1203"/>
|
---|
| 155 | </mx:Canvas>
|
---|
| 156 |
|
---|
| 157 | <mx:VBox width="100%" verticalGap="0">
|
---|
| 158 | <mx:Label text="Selected Diagnoses" styleName="controlLabel" />
|
---|
| 159 | <mx:DataGrid
|
---|
| 160 | id="selectedDiagnosisGrid"
|
---|
| 161 | initialize="{AccessibilityTools.accessComponentName(selectedDiagnosisGrid,'Selected Diagnoses')}"
|
---|
| 162 | rowCount="5"
|
---|
| 163 | width="100%"
|
---|
| 164 | editable="false"
|
---|
| 165 | sortableColumns="false"
|
---|
| 166 | keyDown="removeDiagnosisOnDelete(event)"
|
---|
| 167 | dataProvider="{model.logEdit.entry.diagnoses}"
|
---|
| 168 | tabIndex="1204">
|
---|
| 169 | <mx:columns>
|
---|
| 170 | <mx:DataGridColumn
|
---|
| 171 | headerText="Diagnosis"
|
---|
| 172 | showDataTips="true"
|
---|
| 173 | editable="false"
|
---|
| 174 | dataField="label"/>
|
---|
| 175 | <mx:DataGridColumn
|
---|
| 176 | headerText="Primary?"
|
---|
| 177 | width="65"
|
---|
| 178 | dataField="primary"
|
---|
| 179 | textAlign="center"
|
---|
| 180 | itemRenderer="gov.va.med.edp.widget.YesNoRenderer"/>
|
---|
| 181 | </mx:columns>
|
---|
| 182 | </mx:DataGrid>
|
---|
| 183 | <mx:HBox width="100%" horizontalAlign="center" paddingTop="4">
|
---|
| 184 | <mx:Button id="primaryDiagnosisBtn" label="Set as Primary Diagnosis"
|
---|
| 185 | click="setPrimaryDiagnosis()" enabled="false" tabIndex="1205"/>
|
---|
| 186 | </mx:HBox>
|
---|
| 187 | </mx:VBox>
|
---|
| 188 | <mx:Binding source="PCECodedValueVO(selectedDiagnosisGrid.selectedItem)" destination="setPrimaryBtnState" />
|
---|
| 189 | </mx:HBox>
|
---|