-
Notifications
You must be signed in to change notification settings - Fork 57
/
app.js
136 lines (118 loc) · 4.86 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
'use strict';
var myApp = angular.module('myApp', ['ui.bootstrap']).config(function($rootScopeProvider) {
// Set recursive digest limit higher to handle very deep trees.
$rootScopeProvider.digestTtl(17);
});
// Declare top level URL vars
var baseUrl = "https://browser.ihtsdotools.org/snowstorm/snomed-ct";
var edition = "MAIN";
var version = "2019-07-31";
// Initialization of myApp
myApp.run(['$rootScope', '$http', '$window', function($rootScope, $http, $window) {
// n/a
}]);
// Controller for the page
myApp.controller('SimpleCtrl', function($scope, $http) {
// Scope variables
$scope.errorMsg = null;
$scope.findByQueryResult = null;
$scope.findByQueryUrl = null;
$scope.findByQueryCt = 0;
$scope.findByDescriptionIdResult = null;
$scope.findByDescriptionIdUrl = null;
$scope.findByConceptIdResult = null;
$scope.findByConceptIdUrl = null;
$scope.findByQueryWithFitlerResult = null;
$scope.findByQueryWithFilterUrl = null;
// Clear error
$scope.clearError = function() {
$scope.errorMsg = null;
}
// Clear all scope vars
$scope.clear = function() {
$scope.errorMsg = null;
$scope.findByQueryResult = null;
$scope.findByQueryUrl = null;
$scope.findByQueryCt = 0;
$scope.findByDescriptionIdResult = null;
$scope.findByDescriptionIdUrl = null;
$scope.findByConceptIdResult = null;
$scope.findByConceptIdUrl = null;
$scope.findByQueryWithFitlerResult = null;
$scope.findByQueryWithFilterUrl = null;
}
// Find by query and set the scrollable raw json result
$scope.findByQuery = function(query) {
console.debug('findByQuery', query);
// Make the HTTP Call
$scope.findByQueryUrl = baseUrl + '/' + edition + '/' + version + '/concepts?term=' +
encodeURIComponent(query) + '&activeFilter=true&offset=0&limit=50';
$http.get($scope.findByQueryUrl).then(
// success
function(response) {
console.debug(' matches = ', response.data);
$scope.findByQueryResult = JSON.stringify(response.data, null, 2);
$scope.findByQueryCt = response.data.total;
},
// error
function(response) {
$scope.errorMsg = response;
});
}
// Find by description id and set the scrollable raw json result
$scope.findByDescriptionId = function(query) {
console.debug('findByDescriptionId', query);
// Make the HTTP Call
$scope.findByDescriptionIdUrl = baseUrl + '/' + edition + '/' + version + '/descriptions/' +
query;
$http.get($scope.findByDescriptionIdUrl).then(
// success
function(response) {
console.debug(' matches = ', response.data);
$scope.findByDescriptionIdResult = JSON.stringify(response.data, null, 2);
//$scope.findByDescriptionIdCt = response.data.details.total;
},
// error
function(response) {
$scope.errorMsg = response;
});
}
// Find by concept id and set the scrollable raw json result
$scope.findByConceptId = function(query) {
console.debug('findByConceptId', query);
// Make the HTTP Call
$scope.findByConceptIdUrl = baseUrl + '/browser/' + edition + '/' + version + '/concepts/' + query;
$http.get($scope.findByConceptIdUrl).then(
// success
function(response) {
console.debug(' matches = ', response.data);
$scope.findByConceptIdResult = JSON.stringify(response.data, null, 2);
// $scope.findByConceptIdCt = response.data.details.total;
},
// error
function(response) {
$scope.errorMsg = response;
});
}
// Find by query with filter and set the scrollable raw json result
$scope.findByQueryWithFilter = function(query, filter) {
console.debug('findByQueryWithFilter', query, filter);
// Make the HTTP Call
$scope.findByQueryWithFilterUrl = baseUrl + '/browser/' + edition + '/' + version +
'/descriptions?term=' + encodeURIComponent(query) +
'&conceptActive=true&semanticTag=' + encodeURIComponent(filter) +
'&groupByConcept=false&searchMode=STANDARD&offset=0&limit=50';
$http.get($scope.findByQueryWithFilterUrl).then(
// success
function(response) {
console.debug(' matches = ', response.data);
$scope.findByQueryWithFilterResult = JSON.stringify(response.data, null, 2);
$scope.findByQueryWithFilterCt = response.data.totalElements;
},
// error
function(response) {
$scope.errorMsg = response;
});
}
// end
});