@@ -18,7 +18,6 @@ var input7 = document.querySelector("input[id=correlates_with]");
18
18
var input7_tag = new Tagify ( input7 ) ;
19
19
20
20
// HPO Terms Field Handler
21
-
22
21
// Load previous terms annotated to the report from DB as a list (whitelist for tagify)
23
22
var term_previous_list = [ ] ;
24
23
if ( $ ( "input[id=pheno_terms]" ) . val ( ) !== "" ) {
@@ -35,20 +34,18 @@ var pheno_terms = document.querySelector("input[id=pheno_terms]");
35
34
var pheno_terms_tag = new Tagify ( pheno_terms , {
36
35
enforceWhitelist : true ,
37
36
whitelist : term_previous_list ,
38
- dropdown : {
39
- enabled : 0 ,
40
- } ,
41
37
} ) ; // for aborting the call
42
38
43
- pheno_terms_tag . on ( "input" , onInput ) ;
39
+ pheno_terms_tag . on ( "input" , onInputHPO ) ;
44
40
45
41
// Tagify AJAX Function to get a list of HPO terms
46
42
var delayTimer ;
47
- function onInput ( e ) {
43
+ function onInputHPO ( e ) {
48
44
pheno_terms_tag . whitelist = null ; // reset the whitelist
49
45
// show loading animation and hide the suggestions dropdown
50
46
pheno_terms_tag . loading ( true ) . dropdown . hide ( ) ;
51
47
clearTimeout ( delayTimer ) ;
48
+
52
49
delayTimer = setTimeout ( function ( ) {
53
50
var value = e . detail . value ;
54
51
fetch (
@@ -71,6 +68,125 @@ function onInput(e) {
71
68
} , 700 ) ;
72
69
}
73
70
71
+ // HNC Genes Names Field Handler
72
+ // Tagify Field handler with whitelist and HPO ajax
73
+ var previous_gene = $ ( "input[id=gene_diag]" ) . val ( ) ;
74
+ var previous_gene_list = [ ] ;
75
+ if ( $ ( "input[id=gene_diag]" ) . val ( ) !== "" ) {
76
+ var previous_gene_json = JSON . parse ( $ ( "input[id=gene_diag]" ) . val ( ) ) ;
77
+ var previous_gene_list = [ ] ;
78
+
79
+ for ( var i = 0 ; i < previous_gene_json . length ; i ++ ) {
80
+ previous_gene_list . push ( previous_gene_json [ i ] [ "value" ] ) ;
81
+ }
82
+ }
83
+
84
+ var gene_diag_tag = new Tagify ( gene_diag , {
85
+ enforceWhitelist : true ,
86
+ whitelist : previous_gene_list ,
87
+ mode : "select" ,
88
+ } ) ;
89
+
90
+ gene_diag_tag . on ( "input" , onInputGene ) ;
91
+
92
+ // Tagify AJAX Function to get a list of HPO terms
93
+ var delayTimer ;
94
+ function onInputGene ( e ) {
95
+ gene_diag_tag . whitelist = null ; // reset the whitelist
96
+ // show loading animation and hide the suggestions dropdown
97
+ gene_diag_tag . loading ( true ) . dropdown . hide ( ) ;
98
+ clearTimeout ( delayTimer ) ;
99
+ var myHeaders = new Headers ( {
100
+ "content-type" : "application/json" ,
101
+ "Access-Control-Allow-Origin" : "*" ,
102
+ } ) ;
103
+ var options = {
104
+ method : "GET" ,
105
+ headers : myHeaders ,
106
+ mode : "cors" ,
107
+ } ;
108
+ delayTimer = setTimeout ( function ( ) {
109
+ var value = e . detail . value ;
110
+ fetch (
111
+ "https://rest.genenames.org/search/symbol/" +
112
+ value +
113
+ "*+AND+status:Approved" ,
114
+ options
115
+ )
116
+ . then ( ( RES ) => RES . json ( ) )
117
+ . then ( function ( newWhitelist ) {
118
+ var terms_list = [ ] ;
119
+ for ( var i = 0 ; i < 5 ; i ++ ) {
120
+ terms_list . push (
121
+ newWhitelist . terms [ i ] [ "id" ] + " " + newWhitelist . terms [ i ] [ "name" ]
122
+ ) ;
123
+ }
124
+ gene_diag_tag . whitelist = terms_list ;
125
+ gene_diag_tag . loading ( false ) ;
126
+ gene_diag_tag . dropdown . show ( ) ; // render the suggestions dropdown
127
+ } ) ;
128
+ } , 700 ) ;
129
+ }
130
+
131
+ // Orphanet Disease Names Field Handler
132
+ // Tagify Field handler with whitelist and Orphanet ajax
133
+ var previous_conclusion = $ ( "input[id=conclusion]" ) . val ( ) ;
134
+ var previous_conclusion_list = [ ] ;
135
+ if ( $ ( "input[id=conclusion]" ) . val ( ) !== "" ) {
136
+ var previous_conclusion_json = JSON . parse ( $ ( "input[id=conclusion]" ) . val ( ) ) ;
137
+ var previous_conclusion_list = [ ] ;
138
+
139
+ for ( var i = 0 ; i < previous_conclusion_json . length ; i ++ ) {
140
+ previous_conclusion_list . push ( previous_conclusion_json [ i ] [ "value" ] ) ;
141
+ }
142
+ }
143
+ var conclusion = document . querySelector ( "input[id=conclusion]" ) ;
144
+ var conclusion_tag = new Tagify ( conclusion , {
145
+ enforceWhitelist : true ,
146
+ whitelist : previous_conclusion_list ,
147
+ mode : "select" ,
148
+ } ) ;
149
+
150
+ conclusion_tag . on ( "input" , onInputConclusion ) ;
151
+
152
+ // Tagify AJAX Function to get a list of Orphanet names
153
+ var myHeaders_orpha = new Headers ( {
154
+ apiKey : "ehroes" ,
155
+ } ) ;
156
+ var options_orpha = {
157
+ headers : myHeaders_orpha ,
158
+ } ;
159
+
160
+ var delayTimer ;
161
+ function onInputConclusion ( e ) {
162
+ conclusion_tag . whitelist = null ; // reset the whitelist
163
+ // show loading animation and hide the suggestions dropdown
164
+ conclusion_tag . loading ( true ) . dropdown . hide ( ) ;
165
+ clearTimeout ( delayTimer ) ;
166
+ delayTimer = setTimeout ( function ( ) {
167
+ var value = e . detail . value ;
168
+
169
+ fetch (
170
+ "https://api.orphacode.org/EN/ClinicalEntity/ApproximateName/" + value ,
171
+ options_orpha
172
+ )
173
+ . then ( ( RES ) => RES . json ( ) )
174
+ . then ( function ( newWhitelist ) {
175
+ var terms_list = [ ] ;
176
+ for ( var i = 0 ; i < newWhitelist . length ; i ++ ) {
177
+ terms_list . push (
178
+ newWhitelist [ i ] [ "ORPHAcode" ] +
179
+ " " +
180
+ newWhitelist [ i ] [ "Preferred term" ]
181
+ ) ;
182
+ }
183
+ conclusion_tag . whitelist = terms_list ;
184
+ conclusion_tag . loading ( false ) ;
185
+ conclusion_tag . dropdown . show ( ) ; // render the suggestions dropdown
186
+ } ) ;
187
+ } , 700 ) ;
188
+ }
189
+
74
190
// Get the JSON of the JSTree (stored in hidden form input) as a variable.
75
191
var json_tree = $ ( "input[id=ontology_tree]" ) . val ( ) ;
76
192
0 commit comments