forked from lexevs/lexevscts2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexCTS2CS.html
621 lines (606 loc) · 33.4 KB
/
lexCTS2CS.html
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!--<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">-->
<title>CTS2 Code Systems</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="bootstrap3/css/jumbotron.css" rel="stylesheet">
<link href="cts2/css/typeahead.js-bootstrap.css" rel="stylesheet" >
<link href="cts2/css/cts2.css" rel="stylesheet">
<link href="cts2/css/tree.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">LexEVS CTS2</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="HowTo.html">How To</a></li>
<li class="active" ><a href="#">Code Systems</a></li>
<li><a href="lexCTS2VS.html">Value Sets</a></li>
<li><a href="lexCTS2Map.html">Maps</a></li>
<li><a href="lexCTS2Paginate.html">Paginate</a></li>
</ul>
</div>
</div>
</div>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>CTS2 Code Systems in LexEVS</h1>
<p>Try out the examples below or learn more about CTS2 and LexEVS</p>
<p><a class="btn btn-primary btn-lg" href="index.html" role="button">Learn more »</a></p>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-8 ">
<div class="row">
<div class="col-md-6">
<div class="well">
<div class="example example-codesystems">
<h2 class="example-name">Code Systems</h2>
<p class="example-description">Providing an auto-completion function for code system designations.
Start typing a word and a list of matching code systems will appear. Example: Start typing "ncit"</p>
<div class="demo">
<input class="typeahead" type="text" placeholder="code system">
</div>
</div>
<div style="padding-top: 75px">
<p><a class="btn btn-info" href="#" role="button" data-toggle="modal" data-target="#csAutoModal">
View details »</a></p>
</div>
</div>
<div class="modal fade" id="csAutoModal" tabindex="-1" role="dialog" aria-labelledby="csAutoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-wide">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="csAutoModalLabel">How to Implement Coding Scheme Auto-complete</h4>
</div>
<div class="modal-body">
<p>This function is based on a JavaScript framework called BootStrap and a Bootstrap Plugin called Typeahead.</p>
<h4> HTML Required</h4>
<p>Import the css files by adding these lines to the head tag of the html</p>
<pre>
<code>
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
<link href="cts2/css/typeahead.js-bootstrap.css" rel="stylesheet" >
</code>
</pre>
<p>Insert this code into the html body</p>
<pre>
<code>
<div class="example example-codesystems">
<h2 class="example-name">Code Systems</h2>
<p class="example-description">Auto Complete</p>
<div class="demo">
<input class="typeahead" type="text" placeholder="code system">
</div>
</div>
</code>
</pre>
<p>Placed at the end of the html document before the closing body tag so the pages load faster</p>
<pre>
<code>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bootstrap3/js/bootstrap.min.js"></script>
<script src="cts2/js/typeahead.js"></script>
<script src="cts2/js/codeSystemTypeahead.js"></script>
</code>
</pre>
<h4>JavaScript</h4>
<pre>
<code>
$('.example-codesystems .typeahead').typeahead({
name: 'codesystems',
valueKey: 'codeSystemVersionName',
remote: {
url : 'http://bmidev4:5555/cts2/codesystemversions?matchvalue=%QUERY
&filtercomponent=resourceName&format=json&callback=?',
filter: function (data) {
var codeSystems = data.codeSystemVersionCatalogEntryDirectory.entryList;
return codeSystems;
}
},
limit: 3
});
</code>
</pre>
<p>The selector keys into the html div class "example-codesystems" and the input
class "typeahead." The "valueKey" attribute matches the name of the property returned
from the REST call.</p>
<h4>Resources</h4>
<p>All source and files are available at this
<a href="https://github.com/lexevs/lexevscts2">github repository</a></p>
<p>Files required for this implementation are the <span class="r">bootstrap3 folder</span>,
<span class="r">codeSystemTypeahead.js</span>,
<span class="r">typeahead.js-bootstrap.css</span>, and <span class="r">typeahead.js</span></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
<div class="col-md-6">
<div class="well tree">
<h2>Code System</h2>
<p>Code system metadata tooltip displays code system metadata on cursor hover</p>
<a href="#" data-toggle="tooltip" id="tooltip" data-cts="NCI_Thesaurus-10.07e">NCI Thesaurus</a>
<div style="padding-top: 75px">
<p><a class="btn btn-info" href="#" role="button" data-toggle="modal" data-target="#csToolTipModal">Get Code »</a></p>
</div>
</div>
<div class="modal fade" id="csToolTipModal" tabindex="-1" role="dialog" aria-labelledby="csttModalLabel" aria-hidden="true">
<div class="modal-dialog modal-wide">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="csttModalLabel">How to Implement a CTS2 Coding Scheme ToolTip</h4>
</div>
<div class="modal-body">
<p>This function is based on BootStrap, a JavaScript Framework</p>
<h4> HTML Required</h4>
<p>Import the css files by adding these lines to the head tag of the html</p>
<pre>
<code>
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
<link href="cts2/css/cts2.css" rel="stylesheet">;
</code>
</pre>
<p>Insert this code into the html body</p>
<pre>
<code>
<div class="col-lg-6">
<a href="#" data-placement="bottom" data-toggle="tooltip" id="tooltip"
data-cts="NCI_Thesaurus-10.07e">NCI Thesaurus</a>
</div>
</code>
</pre>
<p>Placed at the end of the html document before the closing body tag so the pages load faster</p>
<pre>
<code>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bootstrap3/js/bootstrap.min.js"></script>
<script src="cts2/js/codeSystemTooltip.js"></script>
</code>
</pre>
<h4>JavaScript</h4>
<pre><code>
var url = "http://bmidev4:5555/cts2/codesystemversions?matchvalue=${codeSystemName}&filtercomponent=resourceName&format=json&callback=?";
var csID = $("#tooltip").attr("data-cts");
$.getJSON(url.replace("${codeSystemName}", csID), function(cts2JSON) {
var html = getCodeSystemTableInfo(cts2JSON)
$('#tooltip').tooltip({title: html, html: true });
});
function getCodeSystemTableInfo(codeSystemJson) {
// get the description, current version, and code system name
var entryList = codeSystemJson.codeSystemVersionCatalogEntryDirectory.entryList;
for(i in entryList){
var entry = codeSystemJson.codeSystemVersionCatalogEntryDirectory.entryList[i];
var codeSystemName = entry.codeSystemVersionName;
var currentVersion = entry.officialResourceVersionId;
var description = entry.resourceSynopsis.value;
}
var html =
"<table class="table table-striped table-bordered table-condensed">" +
"<th colspan="2" > Code System </th>" +
"<tr><td >Name:</td><td>" + codeSystemName + "</td></tr>" +
"<tr><td >Current Version:</td><td>" + currentVersion + "</td></tr>" +
"<tr><td >Description:</td><td>" + description + "</td></tr>" +
"</table>"
return html;
}
</code></pre>
<p>
The REST URL for the code system is completed by a hidden data input named "data-cts"
The <i>getJson()</i> method returns JSON formatted text from the service which is parsed
automatically into jsonp. The resulting objects can be referenced for code system
metadata values after which some html is formatted around them as a table and passed
back to the tooltip where it is shown on mouse hover.
</p>
<h4>Resources</h4>
<p>All source and files are available at this
<a href="https://github.com/lexevs/lexevscts2">github repository</a></p>
<p>
Required files include the <span class="r">bootstrap3 folder</span>,
<span class="r">codeSystemToolTip.js</span>, and <span class="r">cts2.css</span>.
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="well">
<div class="example example-entities">
<h2 class="example-name">Entity Search</h2>
<p class="example-description">Auto Complete search on entities from the NCI Thesaurus. Example:
Start typing "swelling"</p>
<div class="demo">
<input class="typeahead" type="text" placeholder="Type some text">
</div>
</div>
<div style="padding-top: 75px">
<p><a class="btn btn-info" href="#" role="button" data-toggle="modal" data-target="#csEntityModal">Get Code »</a></p>
</div>
</div>
<div class="modal fade" id="csEntityModal" tabindex="-1" role="dialog" aria-labelledby="csEntityModalLabel" aria-hidden="true">
<div class="modal-dialog modal-wide">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="cdEntityModalLabel">How to Implement an Entity AutoComplete</h4>
</div>
<div class="modal-body">
<p>This function is based on a JavaScript framework called BootStrap and a Bootstrap Plugin called Typeahead</p>
<h4> HTML Required</h4>
<p>Import the css files by adding these lines to the head tag of the html</p>
<pre>
<code>
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
<link href="cts2/css/typeahead.js-bootstrap.css" rel="stylesheet" >
<link href="cts2/css/cts2.css" rel="stylesheet">
</code>
</pre>
<p>Insert this code into the html body</p>
<pre>
<code>
<div class="example example-entities">
<h2 class="example-name">Entity Search</h2>
<p class="example-description">Auto Complete search on entities from the NCI Thesaurus</p>
<div class="demo">
<input class="typeahead" type="text" placeholder="Type some text">
</div>
</div>
</code>
</pre>
<p>Placed at the end of the html document before the closing body tag so the pages load faster</p>
<pre>
<code>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bootstrap3/js/bootstrap.min.js"></script>
<script src="cts2/js/typeahead.js"></script>
<script src="cts2/js/entityTypeAhead.js"></script>
</code>
</pre>
<h4>JavaScript</h4>
<pre><code>
$('.example-entities .typeahead').typeahead({
name: 'entities',
valueKey: 'designation',
remote: {
url : 'http://bmidev4:5555/cts2/codesystem/NCI_Thesaurus/version/10.10a/entities?matchvalue=%QUERY&format=json&callback=?',
filter: function (data) {
var entryList = data.entityDirectory.entryList;
var entities = [];
for(i in entryList){
//Only shows the first entity description
entities.push(entryList[i].knownEntityDescriptionList[0].designation);
}
return entities;
},
rateLimitWait : 600
},
limit: 3
});
</code></pre>
<p>Here the selector keys into the html div class "example-entities" and the input
class "typeahead." The "valueKey" attribute matches the name of the property returned
from the REST call.</p>
<h4>Resources</h4>
<p>All source and files are available at this
<a href="https://github.com/lexevs/lexevscts2">github repository</a></p>
<p>Files required for this implementation are the <span class="r">bootstrap3 folder</span>, <span class="r">entityTypeahead.js</span>,
<span class="r">typeahead.js-bootstrap.css</span>, and <span class="r">typeahead.js</span></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
<div class="col-md-6">
<div class="well">
<h2>Code Systems</h2>
<p>A dropdown list of all code systems in this service</p>
<div class="btn-group">
<a class="btn btn-primary" href="#"><i class="icon-user icon-white"></i>All Code Systems</a>
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
<ul class="dropdown-menu" id="codesystems">
<li><a href="#"><b>Code Systems</b></a></li>
<li class="divider"></li>
</ul>
</div>
<div style="padding-top: 75px">
<p><a class="btn btn-info" href="#" role="button" data-toggle="modal" data-target="#csDDModal">Get Code »</a></p>
</div>
</div>
<div class="modal fade" id="csDDModal" tabindex="-1" role="dialog" aria-labelledby="csDDModalLabel" aria-hidden="true">
<div class="modal-dialog modal-wide">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="cdDDModalLabel">Implement a CTS2 Code Systems Drop Down List</h4>
</div>
<div class="modal-body">
<p>This function is based on a JavaScript framework called BootStrap</p>
<h4> HTML Required</h4>
<p>Import the css files by adding these lines to the head tag of the html</p>
<pre>
<code>
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
<link href="cts2/css/cts2.css" rel="stylesheet">
</code>
</pre>
<p>Insert this code into the html body</p>
<pre>
<code>
<div class="btn-group">
<a class="btn btn-primary" href="#">
<i class="icon-user icon-white"></i>All Code Systems</a>
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
<span class="caret"></span></a>
<ul class="dropdown-menu" id="codesystems">
<li><a href="#">Code Systems</a></li>
<li class="divider"></li>
</ul>
</div>
</code>
</pre>
<p>Placed at the end of the html document before the closing body tag so the pages load faster</p>
<pre>
<code>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bootstrap3/js/bootstrap.min.js"></script>
<script src="cts2/js/codeSystemDropDown.js"></script>
</code>
</pre>
<h4>JavaScript</h4>
<pre>
<code>
var CodeSystemListConfig = {
serviceUrl: "http://bmidev4:5555/cts2/codesystemversions?format=json"
};
$(document).ready(
function() {
var url = CodeSystemListConfig.serviceUrl;
$.getJSON(url + "&callback=?", function (data) {
for (var i in data.codeSystemVersionCatalogEntryDirectory.entryList) {
var entry = data.codeSystemVersionCatalogEntryDirectory.entryList[i];
var name = entry.formalName;
var designation = entry.documentURI;
var uri = entry.href;
$("ul.dropdown-menu").append("<li><a href="#">" + name + "</a></li>");
}
});
});
</code>
</pre>
<p>
Here the class attribute "dropdown-menu" is a selector value allowing the list of
JSON derived objects to be processed into a set of html list items which are appended to
an html list created by bootstrap functions. Drop down scrolling is controlled in the
cts.css with an overflow designation. In this code example we define more values than what
is displayed to the end user to show some of the available objects.
</p>
<h4>Resources</h4>
<p>All source and files are available at this
<a href="https://github.com/lexevs/lexevscts2">github repository</a></p>
<p>Files required for this implementation are the <span class="r">bootstrap3 folder</span>,
<span class="r">cts2.css</span>, and <span class="r">codeSystemDropDown.js</span></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
</div>
<div class="col-md-4">
<div class="well">
<h2>Entity Heirarchy Tree</h2>
<p>Displays the children of an entity on a mouse click</p>
<div id="tree-replace">
<ul id="rootul" class="nav">
<li id ="root">
<a id="label-root" data-cts2ref="" label-default="" ><span><i class="glyphicon glyphicon-plus-sign"></i></span></a>
</li>
</ul>
</div>
<div style="padding-top: 75px">
<p><a class="btn btn-info" href="#" role="button" data-toggle="modal" data-target="#csTreeModal">Get Code »</a></p>
</div>
</div>
<div class="modal fade" id="csTreeModal" tabindex="-1" role="dialog" aria-labelledby="csTreeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-wide">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="csTreeModalLabel">How to Implement a CTS2 Generated Tree</h4>
</div>
<div class="modal-body">
<p>This function is based on BootStrap, a JavaScript Framework</p>
<h4>HTML Required</h4>
<p>Import the css files by adding these lines to the head tag of the html</p>
<pre>
<code>
<link href="bootstrap3/css/bootstrap.css" rel="stylesheet">
<link href="cts2/css/cts2.css" rel="stylesheet">
<link href="cts2/css/tree.css" rel="stylesheet">
</code>
</pre>
<p>Insert this code into the html body</p>
<pre>
<code>
<div id="tree-replace">
<ul id="rootul" class="nav">
<li id ="root">
<a id="label-root" data-cts2ref="" label-default="" >
<span><i class="glyphicon glyphicon-plus-sign"></i></span>
</a>
</li>
</ul>
</div>
</code>
</pre>
<p>Placed at the end of the html document before the closing body tag so the pages load faster</p>
<pre>
<code>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bootstrap3/js/bootstrap.min.js"></script>
<script src="cts2/js/entityTreeToggle.js"></script>
</code>
</pre>
<h4>JavaScript</h4>
<p>
<i>
<b>
This highly dynamic implementation in entityTreeToggle.js is too lengthy to reproduce
in its entirety here. Essentially it consists of a set of nested lists, each
dynamically generated from REST calls to a LexEVS CTS2 Service.
</b>
</i>
</p>
<pre>
<code>
function buildTreeInit(genURL){
$.getJSON(genURL + "?format=json&callback=?", function(data){
var rootName = data.entityDescriptionMsg.entityDescription.namedEntity.designationList[0].value;
var childUrl = data.entityDescriptionMsg.entityDescription.namedEntity.children;
populateRoot(rootName);
$.when(addChildData(childUrl,"a#label-root")).then(buildLevelOne());
});
}
</code>
</pre>
<p>
This widget keys off the "a" tag id reference "label-root" to make an immediate call to the
REST service to populate the root based on a hard coded URL. It appends html to this "a" tag
and has an event handler bound to it once it completes its processing of the JSON and stores
a reference to the URL link for the children of this term. Reference methods here are
<i>buildTreeInit()</i>, which calls <i>populateRoot()</i> adding the html. <i>addChildData()</i>
appends the invisible URL to the html. When this completes an event handler is added with
the method <i>buildLevelOne()</i>. All other events wait for the next click on the root
element.
</p>
<pre>
<code>
function getChildren(dataRef){
$.getJSON(dataRef + "?format=json&callback=?", function(childData){
var childList = childData.entityDirectory.entryList;
var html = "<ul id="level1" >";
for (var i in childList) {
var name = childList[i].knownEntityDescriptionList[0].designation;
var ref = childList[i].knownEntityDescriptionList[0].href;
var icon = "<span>" +
"<i class="glyphicon glyphicon-plus-sign"></i></span>";
html = html +"<li>" +
"<a id=\"level1\" data-index='" + i + "' data-cts2ref='" + ref +
"' label-default="" class="tree-toggle nav-header" ><span>" +
icon + name + "</a></li>";
}
$("li#root").append(html + "</ul>");
});
}
</code>
</pre>
<p>
On clicking the root element the <i>getChildren()</i> method is called and the hidden
child URL is accessed, the response is processed and formatted into html list items, which
are attached to the line item containing the root's "a" tag.
</p>
<pre>
<code>
function buildTree(dataRef, id, index){
$.getJSON(dataRef + "?format=json&callback=?", function(data){
var childUrl = data.entityDescriptionMsg.entityDescription.namedEntity.children;
$.getJSON(childUrl + "?format=json&callback=?", function(childData){
var childList = childData.entityDirectory.entryList;
var html= "<ul id="level2" data-li_index='" + index + "' class="tree" >";
for (var i in childList) {
var name = childList[i].knownEntityDescriptionList[0].designation;
var ref = childList[i].knownEntityDescriptionList[0].href;
html= html + "<li><a id="level2" data-cts2ref='" + ref +
"' label-default="" >"
+ name + "</a></li>";
}
var select = "a[id=" + id + "][data-index=" + index + "]";
$(select).append(html + "</ul>");
});
});
}
</code>
</pre>
<p>
The <i>buildLevelTwo()</i> method attaches event handlers to any existing children elements
any time they are created. On click the next level of children is created dynamically with
the method <i>buildTree().</i> Some adjustments will need to be made to adapt this method
for further hierarchy extension. All child elements can be toggled to appear and
disappear.
</p>
<h4>Resources</h4>
<p>All source and files are available at this
<a href="https://github.com/lexevs/lexevscts2">github repository</a></p>
<p>
Required files include the <span class="r">bootstrap3 folder</span>, <span class="r">
entityTreeToggle.js</span>, and <span class="r">tree.css</span>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
<hr>
<footer>
<p>© Mayo Clinic 2013</p>
</footer>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="cts2/js/jquery-1.10.2.js"></script>
<script src="bootstrap3/js/bootstrap.min.js"></script>
<script src="cts2/js/typeahead.js"></script>
<script src="cts2/js/codeSystemTypeahead.js"></script>
<script src="cts2/js/codeSystemTooltip.js"></script>
<script src="cts2/js/codeSystemDropDown.js"></script>
<script src="cts2/js/entityTypeAhead.js"></script>
<script src="cts2/js/entityTreeToggle.js"></script>
</body>
</html>