1wp.controller('FetchingRulesCtrl', function($scope, $http, $location, AuthFactory, SearchFactory) { 2 var addAnyModality, i; 3 $scope.auth = AuthFactory; 4 $scope.search = SearchFactory; 5 if (!$scope.item.lookBack) { 6 $scope.item.lookBack = 365; 7 } 8 $scope.modalities = $scope.auth.queryModalities; 9 addAnyModality = false; 10 $($scope.modalities).each(function() { 11 if (this.modality === 'Any') { 12 addAnyModality = false; 13 return false; 14 } else { 15 return addAnyModality = true; 16 } 17 }); 18 if (addAnyModality) { 19 $scope.anyModality = { 20 description: 'Any', 21 modality: 'Any' 22 }; 23 $scope.modalities.unshift($scope.anyModality); 24 } 25 if (!$scope.item.modality) { 26 $scope.item.modality = 'Any'; 27 } 28 $scope.dicomNodes; 29 if ($scope.item.nodes) { 30 for (i in $scope.item.nodes) { 31 $scope.item.nodes[i] = $scope.item.nodes[i].toString(); 32 } 33 } else { 34 $scope.item.nodes = []; 35 } 36 $scope.ruleTriggers = [ 37 { 38 trigger: 'Incoming DICOM' 39 }, { 40 trigger: 'Incoming Order' 41 } 42 ]; 43 $scope.modalities = $.grep($scope.auth.queryModalities, function(modality) { 44 return modality.modality !== 'PR' && modality.modality !== 'SR'; 45 }); 46 $scope.canProceed = function() { 47 if ($scope.isFirstStep() && $scope.modalForm.$error.required) { 48 return false; 49 } else if ($scope.isCurrentStep(1) && ($scope.noNodesAvailable() || $scope.noNodesSelected())) { 50 return false; 51 } else if ($scope.sim && $scope.isLastStep()) { 52 return false; 53 } else { 54 return true; 55 } 56 }; 57 $scope.next = function() { 58 if ($scope.isCurrentStep(1)) { 59 $scope.buildSummary(); 60 } 61 return $scope.handleNext(!$scope.canProceed()); 62 }; 63 $scope.dismiss = function() { 64 return $scope.modalInstance.close(); 65 }; 66 $scope.getDicomNodes = function() { 67 return $http({ 68 method: 'POST', 69 url: 'cgi/get-dicom-nodes.cgi', 70 headers: { 71 'Content-Type': 'application/x-www-form-urlencoded' 72 }, 73 data: $.param({ 74 account_id: $scope.search.group.id 75 }) 76 }).then(function(response) { 77 var msg; 78 msg = response.data; 79 if (msg.status === 'success') { 80 $scope.dicomNodes = msg.data; 81 return $scope.filterQrNodes(); 82 } 83 }); 84 }; 85 $scope.filterQrNodes = function() { 86 return $scope.dicomNodes = $.grep($scope.dicomNodes, function(node) { 87 return node.qrPort !== void 0 && node.qrPort !== null; 88 }); 89 }; 90 $scope.getIcon = function(node) { 91 if (node.type === 'archive') { 92 return 'webpax-icon-archive'; 93 } else if (node.type === 'workstation') { 94 return 'webpax-icon-workstation'; 95 } else if (node.type === 'scanner') { 96 return 'webpax-icon-scanner'; 97 } else { 98 return 'webpax-icon-archive'; 99 } 100 }; 101 $scope.isNodeChecked = function(node) { 102 var index; 103 index = $.inArray(node.id.toString(), $scope.item.nodes); 104 if (index > -1) { 105 return true; 106 } else { 107 return false; 108 } 109 }; 110 $scope.clearSelectedNodes = function() { 111 var index, results; 112 results = []; 113 for (i in $scope.dicomNodes) { 114 index = $.inArray($scope.dicomNodes[i].id.toString(), $scope.item.nodes); 115 if (index > -1) { 116 results.push($scope.item.nodes.splice(index, 1)); 117 } else { 118 results.push(void 0); 119 } 120 } 121 return results; 122 }; 123 $scope.selectAllNodes = function() { 124 var index, results; 125 results = []; 126 for (i in $scope.dicomNodes) { 127 index = $.inArray($scope.dicomNodes[i].id.toString(), $scope.item.nodes); 128 if (index === -1) { 129 results.push($scope.item.nodes.push($scope.dicomNodes[i].id.toString())); 130 } else { 131 results.push(void 0); 132 } 133 } 134 return results; 135 }; 136 $scope.nodeClicked = function(node) { 137 var index; 138 index = $.inArray(node.id.toString(), $scope.item.nodes); 139 if (index === -1) { 140 return $scope.item.nodes.push(node.id.toString()); 141 } else if (index > -1) { 142 return $scope.item.nodes.splice(index, 1); 143 } 144 }; 145 $scope.noNodesAvailable = function() {
146 if ($scope.dicomNodes) { 147 if ($scope.dicomNodes.length === 0) { 148 return true; 149 } 150 } 151 }; 152 $scope.noNodesSelected = function() { 153 if ($scope.item.nodes.length === 0) { 154 return true; 155 } 156 }; 157 $scope.buildSummary = function() { 158 var nodes; 159 $scope.selectedNodes = $.grep($scope.dicomNodes, function(node) { 160 var index; 161 index = $.inArray(node.id.toString(), $scope.item.nodes); 162 return index > -1; 163 }); 164 nodes = $scope.item.nodes.join(); 165 $scope.item.searchTerms = [ 166 { 167 modality: $scope.item.modality 168 }, { 169 lookBack: $scope.item.lookBack 170 } 171 ]; 172 $scope.item.actionDetails = [ 173 { 174 whenToFetch: $scope.item.whenToFetch 175 }, { 176 nodes: nodes 177 } 178 ]; 179 return $scope.item.action = 'fetch'; 180 }; 181 $scope.isOneNode = function(nodeType) { 182 if (nodeType === 'not-selected') { 183 if ($scope.dicomNodes.length === 1) { 184 return true; 185 } 186 } else if (nodeType === 'selected') { 187 if ($scope.selectedNodes.length === 1) { 188 return true; 189 } 190 } 191 }; 192 $scope.isFirstNode = function(node, nodeType) { 193 if (nodeType === 'not-selected') { 194 if (node.name === $scope.dicomNodes[0].name && $scope.dicomNodes.length > 1 && $scope.dicomNodes.length < 3) { 195 return true; 196 } 197 } else if (nodeType === 'selected') { 198 if (node.name === $scope.selectedNodes[0].name && $scope.selectedNodes.length > 1 && $scope.selectedNodes.length < 3) { 199 return true; 200 } 201 } 202 }; 203 $scope.getRuleName = function() { 204 if ($scope.item === void 0) { 205 return ''; 206 } else { 207 return $scope.item.ruleName; 208 } 209 }; 210 $scope.getWhenToFetch = function() { 211 return $scope.item.whenToFetch; 212 }; 213 $scope.getModality = function() { 214 if ($scope.item.modality) { 215 return $scope.item.modality; 216 } else { 217 return 'All Modalities'; 218 } 219 }; 220 $scope.getLookBack = function() { 221 if ($scope.item.lookBack) { 222 return 'Scans up to ' + $scope.item.lookBack + ' Days Old'; 223 } else { 224 return 'Until the beginning'; 225 } 226 }; 227 $scope.isModalitySelected = function(modality) { 228 if ($scope.item.modality === modality.modality) { 229 return true; 230 } 231 }; 232 $scope.isTriggerSelected = function(trigger) { 233 if ($scope.item.whenToFetch === trigger.trigger) { 234 return true; 235 } 236 }; 237 return $scope.getDicomNodes(); 238});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.