[1240] | 1 | package gov.va.med.edp.util
|
---|
| 2 | {
|
---|
| 3 | import gov.va.med.edp.factory.SessionFactory;
|
---|
| 4 | import gov.va.med.edp.factory.TrackingFactory;
|
---|
| 5 | import gov.va.med.edp.model.Config;
|
---|
| 6 | import gov.va.med.edp.vo.ColorMapVO;
|
---|
| 7 | import gov.va.med.edp.vo.ColorMatchVO;
|
---|
| 8 | import gov.va.med.edp.vo.ColumnSpecVO;
|
---|
| 9 | import gov.va.med.edp.widget.ColorCellRenderer;
|
---|
| 10 |
|
---|
| 11 | import mx.collections.ArrayCollection;
|
---|
| 12 | import mx.controls.DataGrid;
|
---|
| 13 | import mx.controls.dataGridClasses.DataGridColumn;
|
---|
| 14 | import mx.core.ClassFactory;
|
---|
| 15 |
|
---|
| 16 | public class BoardTools
|
---|
| 17 | {
|
---|
| 18 | static public function renderPatientName(item:Object, col: DataGridColumn): String
|
---|
| 19 | {
|
---|
| 20 | var name: String = "";
|
---|
| 21 | if (col.dataField == "@last4") {
|
---|
| 22 | name = item.@last4;
|
---|
| 23 | }
|
---|
| 24 | if (col.dataField == "@ptNm") {
|
---|
| 25 | name = item.@ptNm;
|
---|
| 26 | }
|
---|
| 27 | if (item.@similar == "1") {
|
---|
| 28 | name = "* " + name;
|
---|
| 29 | } else {
|
---|
| 30 | name = " " + name;
|
---|
| 31 | }
|
---|
| 32 | return name;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | static public function buildColumns(spec: ArrayCollection, destGrid: DataGrid): void
|
---|
| 36 | {
|
---|
| 37 | var newCols:Array = new Array();
|
---|
| 38 | var newCol: DataGridColumn;
|
---|
| 39 | for each (var colInfo: ColumnSpecVO in spec) {
|
---|
| 40 | newCol = new DataGridColumn(colInfo.attribute);
|
---|
| 41 | newCol.headerText = colInfo.header;
|
---|
| 42 | newCol.dataField = colInfo.attribute;
|
---|
| 43 | //newCol.width = colInfo.width;
|
---|
| 44 | newCol.itemRenderer = new ClassFactory(gov.va.med.edp.widget.ColorCellRenderer);
|
---|
| 45 | if ((colInfo.attribute == "@last4") || (colInfo.attribute == "@ptNm")) {
|
---|
| 46 | newCol.labelFunction = renderPatientName;
|
---|
| 47 | }
|
---|
| 48 | newCols.push(newCol);
|
---|
| 49 | }
|
---|
| 50 | destGrid.columns = newCols;
|
---|
| 51 | destGrid.invalidateDisplayList();
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | public static function locateColorMap(id: String, colorMaps: ArrayCollection): ColorMapVO
|
---|
| 56 | {
|
---|
| 57 | for each (var colorMap: ColorMapVO in colorMaps) {
|
---|
| 58 | if (colorMap.id == id) return colorMap;
|
---|
| 59 | }
|
---|
| 60 | return null;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | public static function applyColorSpec(nodeList: XMLList, colorMaps: ArrayCollection): void
|
---|
| 65 | {
|
---|
| 66 | for each (var item: XML in nodeList) {
|
---|
| 67 | var colorMap: ColorMapVO = locateColorMap(item.@id, colorMaps);
|
---|
| 68 | if (colorMap == null) continue;
|
---|
| 69 |
|
---|
| 70 | var colorSpecMatches: ArrayCollection = TrackingFactory.buildColorMatchListFromXML(item.map);
|
---|
| 71 | if (colorMap.type == "rng") {
|
---|
| 72 | colorMap.matches = colorSpecMatches;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | insertActiveColors(colorMap.matches, colorSpecMatches);
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | private static function insertActiveColors(baseColors: ArrayCollection, activeColors: ArrayCollection): void
|
---|
| 80 | {
|
---|
| 81 | for each (var match: ColorMatchVO in activeColors) {
|
---|
| 82 | var baseIndex: int = indexOfMatch(match.attribute, match.value, baseColors);
|
---|
| 83 | if (baseIndex > -1) {
|
---|
| 84 | var baseColor: ColorMatchVO = baseColors[baseIndex] as ColorMatchVO;
|
---|
| 85 | baseColor.color = match.color;
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | private static function indexOfMatch(att: String, val: String, matches: ArrayCollection): int
|
---|
| 91 | {
|
---|
| 92 | for (var i: int = 0; i < matches.length; i++) {
|
---|
| 93 | var match: ColorMatchVO = matches[i] as ColorMatchVO;
|
---|
| 94 | if ((match.attribute == att) && (match.value == val)) {
|
---|
| 95 | return i;
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 | return -1;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | public static function applyBoardSpec(config: Config, xml: XML): void
|
---|
| 102 | {
|
---|
| 103 | // load list of boards
|
---|
| 104 | config.boards = SessionFactory.buildLookupListFromXML(xml.boards.board);
|
---|
| 105 | config.boardIndex = Vista.locateIndex(config.boards, xml.spec.@boardID);
|
---|
| 106 | // load color info for row
|
---|
| 107 | config.rowColorMap = locateColorMap(xml.spec.row.@color, config.colorMaps);
|
---|
| 108 | config.rowColorMapIndex = config.colorMaps.getItemIndex(config.rowColorMap);
|
---|
| 109 | // load actual columns info
|
---|
| 110 | config.columns = TrackingFactory.buildColumnSpecListFromXML(xml.spec.col, config.colorMaps);
|
---|
| 111 | //load screen displayProperties
|
---|
| 112 | config.displayBoardProperties =
|
---|
| 113 | TrackingFactory.buildDisplayBoardPropertiesFromXML(xml.spec.displayProperties);
|
---|
| 114 |
|
---|
| 115 | config.boardToken = xml.boardToken;
|
---|
| 116 | config.boardMods = false;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | public static function applyStaffLists(config: Config, xml: XML): void
|
---|
| 120 | {
|
---|
| 121 | config.providers = TrackingFactory.buildStaffListFromXML(xml.providers.staff);
|
---|
| 122 | config.residents = TrackingFactory.buildStaffListFromXML(xml.residents.staff);
|
---|
| 123 | config.nurses = TrackingFactory.buildStaffListFromXML(xml.nurses.staff);
|
---|
| 124 |
|
---|
| 125 | config.providers.filterFunction = hideInactive;
|
---|
| 126 | config.providers.refresh();
|
---|
| 127 | config.residents.filterFunction = hideInactive;
|
---|
| 128 | config.residents.refresh();
|
---|
| 129 | config.nurses.filterFunction = hideInactive;
|
---|
| 130 | config.nurses.refresh();
|
---|
| 131 |
|
---|
| 132 | config.staffToken = xml.staffToken;
|
---|
| 133 | config.staffMods = false;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | public static function hideInactive(item: Object): Boolean
|
---|
| 137 | {
|
---|
| 138 | return (item.inactive == false);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | public static function applySelectionLists(config: Config, xml: XML): void
|
---|
| 142 | {
|
---|
| 143 | config.acuities =
|
---|
| 144 | TrackingFactory.buildCodeSelectionListFromXML(xml.acuity.code);
|
---|
| 145 | config.statuses =
|
---|
| 146 | TrackingFactory.buildCodeSelectionListFromXML(xml.status.code);
|
---|
| 147 | config.arrivals =
|
---|
| 148 | TrackingFactory.buildCodeSelectionListFromXML(xml.arrival.code);
|
---|
| 149 | config.dispositions =
|
---|
| 150 | TrackingFactory.buildCodeSelectionListFromXML(xml.disposition.code);
|
---|
| 151 | config.delays =
|
---|
| 152 | TrackingFactory.buildCodeSelectionListFromXML(xml.delay.code);
|
---|
| 153 |
|
---|
| 154 | config.selectionMods = false;
|
---|
| 155 | config.selectionToken = xml.selectionToken;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | public static function displayTimeAsHrsAndMins(item: Object, column: DataGridColumn): String{
|
---|
| 159 | var dataField:String = column.dataField;
|
---|
| 160 | if ((item != null) && (item[dataField] != null)) {
|
---|
| 161 | var time:Number = parseInt(item[dataField]);
|
---|
| 162 | var hours:int = (time/60);
|
---|
| 163 | var minutes:int = ((time%60) * 60)/60;
|
---|
| 164 |
|
---|
| 165 | var hrString:String = hours.toString();
|
---|
| 166 | var minString:String = minutes.toString();
|
---|
| 167 |
|
---|
| 168 | if (minutes < 10){
|
---|
| 169 | minString = "0" + minutes.toString();
|
---|
| 170 | }
|
---|
| 171 | var retString:String = hrString + ":" + minString;
|
---|
| 172 | if (hrString == "0" && minString == "00") {
|
---|
| 173 | return "";
|
---|
| 174 | }
|
---|
| 175 | return hrString + ":" + minString;
|
---|
| 176 | } else {
|
---|
| 177 | return "";
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | /* public static function locateColorMapIndex(id: String, colorMaps: ArrayCollection): int
|
---|
| 182 | {
|
---|
| 183 | for (var i: int = 0; i < colorMaps.length; i++) {
|
---|
| 184 | if ((colorMaps[i] as ColorMapVO).id == id) return i;
|
---|
| 185 | }
|
---|
| 186 | return -1;
|
---|
| 187 | }
|
---|
| 188 | */ }
|
---|
| 189 | }
|
---|