-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.html
515 lines (485 loc) · 14.7 KB
/
routes.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
<div class="contents">
<div class="main-column ui-layout-west">
<form action="#">
<div class="search messageParam">
<Label>Source</Label><br>
<select id="ddsource" name="SourceOID"><option value="">Any</option></select><br>
<Label>Destination</Label><br>
<select id="dddestination" name="Destination"><option value="">Any</option></select><br>
<Label>Result Type (Ctr + click)</Label><br>
<select id="resultTypeInput" name="ResultType" multiple size='7'>
<option value="">Any</option>
<option value="LAB">LAB</option>
<option value="LAB-MB">LAB-MB</option>
<option value="LAB-BB">LAB-BB</option>
<option value="LAB-PATH">LAB-PATH</option>
<option value="RAD">RAD</option>
<option value="TRANS">TRANS</option>
</select><br>
<Label>EMR</Label><br>
<select id="ddemr" name="">
<option value="">Any</option>
</select><br>
<button type="button" id="refreshRoutes" class="settings button-primary">Refresh</button>
</div>
</form>
</div>
<div class="main-column ui-layout-center">
<div id="resize_wrapper">
<table id="dataTable" class="display compact wrap" cellspacing="0" width="100%">
</table>
</div>
</div>
<div class="detailColumn" id="detailColumnPopupRoute">
<div class="detailsContents">
<h3 class="button-primary maximize">Drag to Move</h3>
<button class="button-primary closeDetail">Close</button>
<br>
<h2>Organization Information</h2>
<br>
<table class="detailTable">
<tr id="conDetailsBlock">
<th>
<label>Route Details</label>
</th>
<td>
<table id="breakoutDetailsTable">
<tr>
<td>Name: </td>
<td id="OrgInfoName"></td>
</tr>
<tr>
<td>Type: </td>
<td id="OrgInfoType"></td>
</tr>
<tr>
<td>Contact: </td>
<td id="OrgInfoContact"></td>
</tr>
<tr>
<td>Email: </td>
<td id="OrgInfoEmail"></td>
</tr>
<tr>
<td>Phone: </td>
<td id="OrgInfoPhone"></td>
</tr>
<tr>
<td>EMR: </td>
<td id="OrgInfoEMR"></td>
</tr>
</table>
</td>
</tr>
</table>
<h2 class="miniDataTableHeader">Providers</h2>
<table id="providerTable" class="miniDataTable display compact wrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>NPI</th>
<th>Last Name</th>
<th>First Name</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
var table;
var footers = [];
var dynamicColumns = {
"Active":0,
"OrganizationName":[0,"Organization Name"],
"SourceOID":[0,"Source OID"],
"ResultType":[0,"Result Type"],
"PatientClass":[0,"Patient Class"],
"ResultStatus":[0,"Result Status"],
"ProviderRole":[0,"Provider Role"],
"EMR":0,
"SendTo":[0,"Delivery Operation"],
"MSH3":[1],
"MSH4":[1],
"MSH5":[1],
"MSH6":[1],
"Aggregate":[1],
"CreateTS":[1,"Create TS"],
"Delay":[1],
"PV13Location":[1,"PV13 Location"],
"PreserveProviders":[1,"Preserve Providers"],
"sourceorganization":[1,"Source Organization"],
"Transformations":[1],
"Username":[1]
}
/* Formatting function for row details - modify as you need */
function format ( d ) {
// `d` is the original data object for the row
return '<div class="slider">' +
'<table cellpadding="5" cellspacing="0" border="0" style="float:left;padding-left:5px;">'+
'<tr>'+
'<td>MSH-3:</td>'+
'<td>'+d.MSH3+'</td>'+
'</tr>'+
'<tr>'+
'<td>MSH-4:</td>'+
'<td>'+d.MSH4+'</td>'+
'</tr>'+
'<tr>'+
'<td>MSH-5:</td>'+
'<td>'+d.MSH5+'</td>'+
'</tr>'+
'<tr>'+
'<td>MSH-6:</td>'+
'<td>'+d.MSH6+'</td>'+
'</tr>'+
'<tr>'+
'<td>Aggregate:</td>'+
'<td>'+d.Aggregate+'</td>'+
'</tr>'+
'<tr>'+
'<td>Create TS:</td>'+
'<td>'+d.CreateTS+'</td>'+
'</tr>'+
'<tr>'+
'<td>Delay:</td>'+
'<td>'+d.Delay+'</td>'+
'</tr>'+
'<tr>'+
'<td>PV13 Location:</td>'+
'<td>'+d.PV13Location+'</td>'+
'</tr>'+
'<tr>'+
'<td>Preserve Providers:</td>'+
'<td>'+d.PreserveProviders+'</td>'+
'</tr>'+
'<tr>'+
'<td>Source Organization:</td>'+
'<td>'+d.sourceorganization+'</td>'+
'</tr>'+
'<tr>'+
'<td>Transformations:</td>'+
'<td>'+d.Transformations+'</td>'+
'</tr>'+
/*
'<tr>'+
'<td>Username:</td>'+
'<td>'+d.Username+'</td>'+
'</tr>'+
*/
'</table>' +
'</div>';
}
// Highlights all the appropriate cells in a given row
function highlightSelected(td) {
td.parent('tr').find('td:not(.details-control)').each (function() {
$(this).addClass('selected_row')
});
}
function populateProviderTable(destination) {
// Attempt to destroy table so that if you're reloading instead of initially instantiating, it won't error
try {
table.destroy();
table, columns, a, b, result = "";
// We don't care if it fails
} catch (e){}
$('#resize_wrapper_search').show("normal");
var data = {}
var payload = {
"destination":destination,
};
data.token = {"token":getCookie("token")};
data.payload = payload;
data = JSON.stringify(data);
// Datatable definition
table = $('#providerTable').DataTable( {
paging: false,
orderCellsTop: true,
"oLanguage": {
"sSearch": "",
"sEmptyTable": "No Data found based on parameters"
},
"sDom": 'ift',
//"sDom": '<"top"lpif>t<"bottom"><"clear">',
"ajax": {
"url":serverURL+"providers/" + data,
"dataSrc": ""
},
"columns": [
{ data: "NPI" },
{ data: "LastName" },
{ data: "FirstName" },
],
//"order": [[0, 'dec']],
"order": [[1, 'asc'],[2, 'asc']],
//"aDataSort": [ 1, 2 ],
"initComplete": function( settings, json ) {
$('#OrgInfoName').text(json[0].OrganizationName)
$('#OrgInfoType').text(json[0].Type)
$('#OrgInfoContact').text(json[0].Contact)
$('#OrgInfoEmail').text(json[0].Email)
$('#OrgInfoPhone').text(json[0].Phone)
$('#OrgInfoEMR').text(json[0].EMR)
}
});
$('.dataTables_wrapper .dataTables_filter input').attr("placeholder", '\uD83D\uDD0E Search All Columns');
}
// When the page loads we populate the table with the routes data
(function ($) {
// Removes duplicate wrappers
$('#detailColumnPopupRoute').each(function (i) {
$('[id="' + this.id + '"]').slice(1).remove();
});
// Details popup init
$("#detailColumnPopupRoute").iziModal({
width: "25%",
top: 55,
transitionIn: "fadeInUp",
transitionOut: "fadeOutUp",
overlay: false,
openFullscreen: false,
});
$("#detailColumnPopupRoute").draggable({
grid: [10,57],
handle: 'h3',
});
$('.closeDetail').click(function() {
$('#detailColumnPopupRoute').iziModal('close');
$('tr td').removeClass('selected_row')
});
$("#ddsource").change(function () {
getDestinations($(this).val())
});
// Column sorting, stops footer from triggering as well
var asc = true
$('#dataTable').on("click", 'th:not(tfoot tr th)', function(event) {
var parent = $(event.target).parent()
var myIndex = $(parent).prevAll().length;
if(asc) table.order([myIndex, "asc"]).draw()
else table.order([myIndex, "dec"]).draw()
asc = !asc
})
$('#dataTable').on('click', 'td:not(.details-control)', function (e) {
e.preventDefault();
e.stopPropagation();
var destination = $(this).parent().find('td').eq(2).html()
// Check the css if it's selected, if it is then the user is deselecting, and we close the dialog and end the function
if ( $(this).hasClass('selected_row')) {
$('tr td').removeClass('selected_row')
// Close dialog
$('#detailColumnPopupRoute').iziModal('close');
return;
}
// Otherwise remove styling from whatever is selected and make this the new selection, and continue with the query
else {
$('tr td').removeClass('selected_row')
highlightSelected($(this))
// Open dialog
//$('#detailColumnPopupRoute').iziModal('open');
}
$('#detailColumnPopupRoute').iziModal('open');
populateProviderTable(destination);
});
$("#refreshRoutes").on("click",function() {
location.reload();
});
var data = {}
var payload = {
};
data.payload = payload;
data = JSON.stringify(data);
function getDestinations(source) {
var data = {}
if(source == "Any") {
data.source = ""
} else { data.source = source }
data = JSON.stringify(data);
// Destination
$.ajax({
url:serverURL+"destinationroute/" + data,
type: "GET",
contentType: "application/json",
dataType: "text",
error: function(response) {
console.log(response);
},
success: function(response) {
$('#dddestination').empty()
$('#dddestination').append('<option>Any</option>')
response = JSON.parse(response);
response.forEach(function(value) {
var option=$('<option></option>').text(value.OrganizationName);
$('#dddestination').append(option);
})
}
});
}
// Source
$.ajax({
url:serverURL+"source/" + data,
type: "GET",
contentType: "application/json",
dataType: "text",
error: function(response) {
console.log(response);
},
success: function(response) {
$('#ddsource').empty()
$('#ddsource').append('<option>Any</option>')
response = JSON.parse(response);
response.forEach(function(value) {
var option=$('<option></option>').text(value.sourceorganization);
$('#ddsource').append(option);
})
getDestinations($('#ddsource').val())
}
});
// EMR
$.ajax({
url:serverURL+"emr/" + data,
type: "GET",
contentType: "application/json",
dataType: "text",
error: function(response) {
console.log(response);
},
success: function(response) {
response = JSON.parse(response);
response.forEach(function(value) {
var option=$('<option></option>').text(value.EMR);
$('#ddemr').append(option);
})
}
});
$('#resize_wrapper').show("normal");
var data = {}
data = JSON.stringify(data);
columns = $('.contents').layout({
west: {
resizable: false,
slidable: false,
togglerLength_closed: 200, //toggler height (length)
togglerLength_open: 200,
spacing_closed: 10, //toggler width
spacing_open: 5,
},
center: {
},
});
var pageLength = localStorage.getItem('dataTable_length') || 10;
var table = $('#dataTable').DataTable( {
paging: true,
orderCellsTop: true,
pageLength:parseInt(pageLength),
"oLanguage": {
"sSearch": "",
"sEmptyTable": "No Data found based on parameters"
},
"sDom": '<"top"lpif>t<"bottom"><"clear">',
"ajax": {
"url":serverURL+"routes/"+data,
"dataSrc": "" },
// This section defines what data is being grabbed. The first element is the hidden section that is activated onclick.
"columns": buildDynamicDataTable($('#dataTable'), dynamicColumns),
"order": [[2, 'asc']],
// Conditional formatting for inactive routes to look grayed out
rowCallback: function(row, data, index) {
if (data['Active'] == '0') {
$(row).find('td:not(.details-control)').each (function() {
$(this).addClass('inactive')
});
}
}
});
hideColumns(table, dynamicColumns)
// Individual column search DOM definition. We add the headers to an array for future use. This is because when the
// datatable is refreshed, the header values are undefined for some reason. My hotfix is saving their values in an unmutable array
$('#dataTable tfoot th').each( function (i) {
var headerTitle;
var title = "🔎"
// Check if the array is full
if (footers.length != 11) {
headerTitle = $(this).closest('tr').find('th').eq(i).text();
footers.push(headerTitle)
}
// If not then keep adding to it
else {
headerTitle = footers[i]
}
// Format for each search box
$(this).html( '<input type="text" placeholder="'+title+' '+headerTitle+'" data-index="'+i+'" />' );
});
// Disallow future changes to the array
Object.freeze(footers);
// Event handling for search columns
$( table.table().container() ).on( 'keyup', 'tfoot input', function () {
table
.column( $(this).data('index') )
.search( this.value )
.draw();
});
$.fn.dataTable.ext.errMode = function ( settings, helpPage, message ) {
alert("Search timed out, please try again.")
};
// Save the page length on change
$('#dataTable_length').on("change", 'select', function(){
// for persistant data
localStorage.setItem('dataTable_length',$(this).val());
// just for the session
sessionStorage.setItem('dataTable_length',$(this).val());
});
$('.dataTables_wrapper .dataTables_filter input').attr("placeholder", '\uD83D\uDD0E Search All Columns');
// Left column search filtering
$('#resultTypeInput').on('change', function(){
var search = [];
$.each($('#resultTypeInput option:selected'), function(){
search.push($(this).val());
});
search = search.join('|');
table.column(4).search(search, true, false).draw();
})
$('#ddsource').on('change', function(){
table.column(3).search($(this).val(), true, false).draw();
})
$('#dddestination').on('change', function(){
table.column(2).search($(this).val(), true, false).draw();
})
$('#ddemr').on('change', function(){
table.column(8).search($(this).val(), true, false).draw();
})
$('.dataTables_scrollBody').css('height', ($(window).height() - 229));
// Add event listener for opening and closing details
$('#dataTable').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
var $hamburger = tr.find('.hamburger');
if ( row.child.isShown() ) {
$hamburger.toggleClass("is-active");
$('div.slider', row.child()).slideUp( "fast", function () {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
});
}
else {
// Open this row
row.child( format(row.data()) ).show();
$('div.slider', row.child()).slideDown("fast");
tr.addClass('shown');
$hamburger.toggleClass("is-active");
}
});
})(jQuery);
</script>
<style>
#providerTable_info {
color: black !important;
margin: 0 0 0 5px;
}
</style>