-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate_ui.html
473 lines (432 loc) · 22.8 KB
/
validate_ui.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="{{VALIDATE_API_URL}}static/css/shCore.css">
<link rel="stylesheet" href="{{VALIDATE_API_URL}}static/css/shThemeDefault.css">
<link rel="stylesheet" href="{{VALIDATE_API_URL}}static/css/main.css">
<link rel="stylesheet" href="{{VALIDATE_API_URL}}static/css/angular-block-ui.min.css">
<meta charset="ISO-8859-1">
<title>Reference C-CDA Validator</title>
<style>
#section_2,
#section_3,
#section_4,
#section_5 {
display: none;
}
</style>
</head>
<body ng-app="referenceValidator">
<div class="container">
<form name="validationForm" ng-controller="ValidationController as vCtrl">
<ol>
<li>Select whether your system is a Sender of C-CDA's or Receiver of C-CDA's.
<div class="form-group">
<button class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'sender'" ng-click="vCtrl.toggleMessageType()">Sender</button>
<button class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'reciever'" ng-click="vCtrl.toggleMessageType()">Receiver</button>
</div>
</li>
<li id="section_2">Select ONC 2015 Edition S&CC objective or other C-CDA IG conformance criteria from the list below.
<div class="form-group">
<select id="validation_objectives" name="validation_objectives" class="form-control" tabindex="1" ng-model="validationModel.selectedObjective" ng-options="objective.name for objective in objectives track by objective.url" ng-change="vCtrl.getReferenceFiles()" required></select>
</div>
</li>
<li id="section_3">Select the scenario file that you used to generate the C-CDA, if you are testing a C-CDA generated without using any of the scenario files in the drop down, select "No scenario File".
<div class="form-group">
<select id="CCDAR2_refdocsfordocumenttype" name="CCDAR2_refdocsfordocumenttype" class="form-control" tabindex="1" ng-model="validationModel.selectedReferenceFileName" ng-options="referenceFileName.name for referenceFileName in referenceFileNames track by referenceFileName.url" required></select>
</div>
</li>
<li id="section_4"><strong>Validating... Please wait.</strong></li>
</li>
</ol>
</form>
<div class="modal modal-wide fade" id="resultModal" tabindex="-1" role="dialog" aria-labelledby="resultModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<ul class="nav nav-tabs" id="resultModalTabs">
<li><a href="#tabs-1" data-toggle="tab">Validation Result</a></li>
<li><a href="#tabs-2" data-toggle="tab">Original C-CDA</a></li>
<li class="pull-right"><button type="button" class="btn btn-default closeResultsBtn" data-dismiss="modal">Close Results </button> </li>
</ul>
</div>
<div class="modal-body">
<div id="ValidationResult">
<div class="tab-content" id="resultTabContent">
<div class="tab-pane" id="tabs-1"></div>
<div class="tab-pane" id="tabs-2"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default closeResultsBtn" data-dismiss="modal">Close Results
</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-sanitize.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-cookies.min.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/vendor/ui-bootstrap-tpls-2.1.3.min.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/vendor/ng-file-upload-shim.min.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/vendor/ng-file-upload.min.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/vendor/angular-block-ui.min.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/app.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/validator_service.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="{{VALIDATE_API_URL}}static/js/vendor/shCore.js"></script>
<script src="{{VALIDATE_API_URL}}static/js/vendor/shBrushXml.js"></script>
<script>
angular.module('referenceValidator').controller('ValidationController', function ($scope, $http, Upload, ValidatorService, blockUI) {
var senderGitHubUrl = 'https://api.github.com/repos/siteadmin/2015-Certification-C-CDA-Test-Data/contents/Sender SUT Test Data';
var receiverGitHubUrl = 'https://api.github.com/repos/siteadmin/2015-Certification-C-CDA-Test-Data/contents/Receiver SUT Test Data';
var validationError;
var self = this;
self.validationModel = {
selectedObjective: '',
selectedReferenceFileName: '',
file: ''
};
self.toggleMessageType = toggleMessageType;
self.getReferenceFiles = getReferenceFiles;
window.Upload = Upload;
window.blockUI = blockUI;
window.$scope = $scope;
$scope.radioModel = 'sender';
$scope.objectives = [];
$scope.referenceFileNames = [];
showValidationResults = function(data) {
showValidationResultsModalButtons();
var tabHtml1 = '';
if (data.resultsMetaData.serviceError) {
tabHtml1 = buildValidationResultErrorHtml(data.resultsMetaData.serviceErrorMessage);
} else {
var resultsMap = buildCcdaResultMap(data);
tabHtml1 = buildCcdaValidationResultsHtml(data);
buildCCDAXMLResultsTab(data);
highlightCcdaXMLResults(resultsMap);
}
showResults(tabHtml1);
removeProgressModal();
}
function showResults(resultsHtml) {
$("#ValidationResult .tab-content #tabs-1").html(resultsHtml);
$("#resultModal").modal("show");
$("#resultModalTabs a[href='#tabs-1']").tab("show");
//$("#resultModalTabs a[href='#tabs-2']").tab("show");
$("#resultModalTabs a[href='#tabs-3']").hide();
if (Boolean(validationError)) {
$(".smartCCDAValidationBtn").hide();
$(".saveResultsBtn").hide();
}
}
function removeProgressModal() {
if (typeof window.validationpanel != 'undefined')
window.validationpanel.unblock();
window.setTimeout(function () {
$('#progress').fadeOut(400, function () {
$('#progress .progress-bar').css('width', '0%');
});
}, 1000);
}
function showValidationResultsModalButtons() {
$("#resultModalTabs a[href='#tabs-1']").show();
$("#resultModalTabs a[href='#tabs-2']").show();
$('.saveResultsBtn').show();
$('.smartCCDAValidationBtn').show();
}
function buildValidationResultErrorHtml(errorMessage) {
var errorHtml = ['<title>Validation Results</title>',
'<h1 align="center">Validation Results</h1>',
'<p>An error occurred during validation with the following details:</br>',
'<b>' + errorMessage + '</b></br>',
'If possible, please fix the error and try again. If this error persists, please contact the system administrator',
'</p>'
];
hideValidationResultsModalButtons();
return errorHtml;
}
function hideValidationResultsModalButtons() {
$("#resultModalTabs a[href='#tabs-1']").hide();
$("#resultModalTabs a[href='#tabs-2']").hide();
$('.saveResultsBtn').hide();
$('.smartCCDAValidationBtn').hide();
}
function buildCcdaResultMap(data) {
var ccdaValidationResultsMap = {};
var resultTypeMapValue = '';
$.each(data.ccdaValidationResults, function (ccdaValidationResults, result) {
if (result.expectedValueSet != null) {
resultTypeMapValue = result.description + '<br/>Expected Valueset(s): ' + result.expectedValueSet.replace(/,/g, " or ");
} else {
resultTypeMapValue = result.description;
}
if (ccdaValidationResultsMap[result.documentLineNumber] != undefined) {
var resultTypeMap = ccdaValidationResultsMap[result.documentLineNumber];
if (resultTypeMap[result.type] != undefined) {
resultTypeMap[result.type].push(resultTypeMapValue);
ccdaValidationResultsMap[result.documentLineNumber] = resultTypeMap;
} else {
resultTypeMap[result.type] = [resultTypeMapValue];
ccdaValidationResultsMap[result.documentLineNumber] = resultTypeMap;
}
} else {
var ccdaTypeMap = {};
ccdaTypeMap[result.type] = [resultTypeMapValue];
ccdaValidationResultsMap[result.documentLineNumber] = ccdaTypeMap;
}
});
return ccdaValidationResultsMap;
}
function buildCcdaValidationResultsHtml(data) {
var tabHtml1 = buildCcdaValidationSummary(data);
tabHtml1 += buildCcdaValidationResults(data);
return tabHtml1;
}
function buildCcdaValidationSummary(data) {
var uploadedFileName = data.resultsMetaData.ccdaFileName;
var docTypeSelected = data.resultsMetaData.objectiveProvided;
var numberOfTypesOfErrorsPerGroup = 3; //error, warning, info
var resultTypeCount = 0;
var resultGroup = '';
var resultCountBadgeColorClass = '';
var resultGroupHTMLHeader = '<div class="panel panel-primary col-md-2 col-lg-2"><div><div class="list-group">';
var resultGroupHTMLEnd = '</div></div></div>';
/* if(documentTypeIsNonSpecific(docTypeSelected)){
docTypeSelected = buildValidationHeaderForNonSpecificDocumentType(docTypeSelected);
} */
var tabHtml1 = buildValidationResultsHeader(uploadedFileName, docTypeSelected).join('\n');
tabHtml1 += '<br/><div class="row">';
$.each(data.resultsMetaData.resultMetaData, function (resultMetaData, metaData) {
if (metaData.type.toLowerCase().indexOf("error") >= 0) {
resultCountBadgeColorClass = 'label-danger';
} else if (metaData.type.toLowerCase().indexOf("warn") >= 0) {
resultCountBadgeColorClass = ' label-warning';
} else {
resultCountBadgeColorClass = 'label-info';
}
resultGroup += '<div class="list-group-item"><span class="label label-as-badge ' + resultCountBadgeColorClass + '">' + metaData.count + '</span><a href="#' + metaData.type + '">' + metaData.type + '</a></div>';
resultTypeCount++;
if (resultTypeCount % numberOfTypesOfErrorsPerGroup === 0) {
tabHtml1 += '<div id="' + metaData.type.split(' ').join('_') + '_SUMMARY">' + resultGroupHTMLHeader + resultGroup + resultGroupHTMLEnd + '</div>';
resultGroup = "";
}
});
tabHtml1 += '</div>';
return tabHtml1;
}
function buildCcdaValidationResults(data) {
var resultList = [];
var currentResultType;
$.each(data.ccdaValidationResults, function (ccdaValidationResults, result) {
if (result.type.toLowerCase().indexOf("error") >= 0) {
resultList.push('<font color="red">');
} else if (result.type.toLowerCase().indexOf("warn") >= 0) {
resultList.push('<font color="orange">');
} else {
resultList.push('<font color="#5bc0de">');
}
if (currentResultType != result.type.toLowerCase()) {
resultList.push('<a href="#" name="' + result.type + '"></a>');
}
var errorDescription = ['<li>' + result.type + '<ul class="">',
'<li class="">Description: ' + result.description + '</li>',
'<li class="">xPath: ' + result.xPath + '</li>',
'<li class="">Document Line Number (approximate): ' + result.documentLineNumber + '</li>',
'</ul></li>'
];
resultList = resultList.concat(errorDescription);
if (result.expectedValueSet != null) {
var expectedValueSets = ['<a href=">' + result.expectedValueSet + '</a>'];
resultList = resultList.concat(expectedValueSets);
}
resultList.push('</font>');
resultList.push('<hr/><div class="pull-right"><a href="#validationResults" title="top">^</a></div>');
currentResultType = result.type.toLowerCase();
});
return (resultList.join('\n'));
}
function documentTypeIsNonSpecific(documentType) {
return (documentType.lastIndexOf('Non-specific') !== -1);
}
function buildValidationHeaderForNonSpecificDocumentType(docTypeSelected) {
docTypeSelected = docTypeSelected.replace("Non-specific", "");
if (docTypeSelected.lastIndexOf('R2') === -1) {
docTypeSelected = docTypeSelected.trim();
docTypeSelected = docTypeSelected.slice(5);
docTypeSelected = 'CCDA R1.1 ' + docTypeSelected;
}
return docTypeSelected;
}
function buildValidationResultsHeader(uploadedFileName) {
var header = ['<title>Validation Results</title>',
'<a name="validationResults"/>',
'<div class="row">',
'<b>Upload Results:</b> ' + uploadedFileName + ' was uploaded successfully.'
];
header.push(['</div>']);
return header;
}
function createResultListPopoverHtml(results) {
var htmlList = '<ul>';
for (var i = 0; i < results.length; i++) {
htmlList += '<li>' + results[i] + '</li>'
}
htmlList += '</ul>';
return htmlList;
}
function buildCCDAXMLResultsTab(data) {
jQuery("#ccdaXML").remove();
jQuery("#tabs-2").empty();
var uploadedFileName = data.resultsMetaData.ccdaFileName;
//var docTypeSelected = getSelectedDocumentType(data);
var resultsHeader = buildValidationResultsHeader(uploadedFileName);
if (data.resultsMetaData.ccdaFileContents.match(/\n/gm) == null || data.resultsMetaData.ccdaFileContents.match(/\n/gm).length < 10) {
jQuery('#tabs-2').html(resultsHeader.join(" ") + "<div class='row alert alert-warning'><b>WARNING!</b> Detected an XML document that may not be formatted for this validation display. For example, the XML may be on a single line.</div>");
} else {
//$('#tabs-2').html(resultsHeader.join(" "));
jQuery('<pre/>', {
id: 'ccdaXML',
class: 'brush: xml; toolbar: false',
text: data.resultsMetaData.ccdaFileContents
}).appendTo('#tabs-2');
SyntaxHighlighter.defaults['auto-links'] = false;
SyntaxHighlighter.highlight();
}
}
function highlightCcdaXMLResults(resultsMap) {
if ($.map(resultsMap, function (n, i) {
return i;
}).length > 0) {
for (var resultLineNumber in resultsMap) {
var lineNum = resultLineNumber;
var resultTypesMap = resultsMap[resultLineNumber];
for (var resultType in resultTypesMap) {
var type = resultType;
var descriptions = resultTypesMap[resultType];
var descriptionsLength = descriptions.length;
var popoverTemplate = '<span class="popover resultpopover"><div class="clearfix"><span>Line Number: ' + lineNum + '</span><span aria-hidden="true" class="glyphicon glyphicon-arrow-up" style="float:right !important; cursor:pointer" title="go to previous result"></span></div><span class="arrow"></span><h3 class="popover-title result-title"></h3><div class="popover-content"></div><div class="clearfix"><span aria-hidden="true" class="glyphicon glyphicon-arrow-down" style="float:right !important; cursor:pointer" title="go to next result"></span></div></span>';
var popOverContent = createResultListPopoverHtml(descriptions);
if (typeof jQuery(".code .container .line.number" + lineNum).data('bs.popover') !== "undefined") {
var title;
if (type.toLowerCase().indexOf("error") >= 0) {
jQuery(".code .container .line.number" + lineNum).prepend("<span class='glyphicon glyphicon-exclamation-sign alert-danger' aria-hidden='true' style='font-size: .8em;'></span>");
title = "<span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span> " + descriptionsLength + " " + type + "(s)";
} else if (type.toLowerCase().indexOf("warn") >= 0) {
jQuery(".code .container .line.number" + lineNum).prepend("<span class='glyphicon glyphicon-warning-sign alert-warning' aria-hidden='true' style='font-size: .8em;'></span>");
title = "<span class='glyphicon glyphicon-warning-sign' aria-hidden='true'></span> " + descriptionsLength + " " + type + "(s)";
} else {
jQuery(".code .container .line.number" + lineNum).prepend("<span class='glyphicon glyphicon-info-sign alert-info' aria-hidden='true' style='font-size: .8em;'></span>");
title = "<span class='glyphicon glyphicon-info-sign' aria-hidden='true'></span> " + descriptionsLength + " " + type + "(s)";
}
jQuery(".code .container .line.number" + lineNum).data('bs.popover').options.content += "<h3 class='popover-title result-title'>" + title + "</h3>" + popOverContent;
} else {
if (type.toLowerCase().indexOf("error") >= 0) {
jQuery(".code .container .line.number" + lineNum).prepend("<span class='glyphicon glyphicon-exclamation-sign alert-danger' aria-hidden='true' style='font-size: .8em;'></span>");
jQuery(".code .container .line.number" + lineNum).addClass("ccdaErrorHighlight").popover({
title: "<span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span> " + descriptionsLength + " " + type + "(s)",
html: true,
content: popOverContent,
trigger: "focus",
placement: "auto",
template: popoverTemplate
});
} else if (type.toLowerCase().indexOf("warn") >= 0) {
jQuery(".code .container .line.number" + lineNum).prepend("<span class='glyphicon glyphicon-warning-sign alert-warning' aria-hidden='true' style='font-size: .8em;'></span>");
jQuery(".code .container .line.number" + lineNum).addClass("ccdaWarningHighlight").popover({
title: "<span class='glyphicon glyphicon-warning-sign' aria-hidden='true'></span> " + descriptionsLength + " " + type + "(s)",
html: true,
content: popOverContent,
trigger: "focus",
placement: "auto",
template: popoverTemplate
});
} else {
jQuery(".code .container .line.number" + lineNum).prepend("<span class='glyphicon glyphicon-info-sign alert-info' aria-hidden='true' style='font-size: .8em;'></span>");
jQuery(".code .container .line.number" + lineNum).addClass("ccdaInfoHighlight").popover({
title: "<span class='glyphicon glyphicon-info-sign' aria-hidden='true'></span> " + descriptionsLength + " " + type + "(s)",
html: true,
content: popOverContent,
trigger: "focus",
placement: "auto",
template: popoverTemplate
});
}
}
}
}
}
addTitleAttributeToHighlightedDivs();
}
function addTitleAttributeToHighlightedDivs() {
$("div[class$='Highlight']").attr('title', 'Show validation result details for this line.');
$("div[class$='Highlight']").attr('tabindex', '0');
}
$('#resultModal').on('click', '.glyphicon-arrow-down', function () {
var $elem = jQuery(this).parent().parent().nextAll('.ccdaErrorHighlight, .ccdaWarningHighlight, .ccdaInfoHighlight').first();
$('#resultModal').animate({
scrollTop: $elem.position().top
}, 2000, function () {
$elem.focus();
});
});
$('#resultModal').on('click', '.glyphicon-arrow-up', function () {
var $elem = jQuery(this).parent().parent().prevAll('.ccdaErrorHighlight, .ccdaWarningHighlight, .ccdaInfoHighlight')[1];
$('#resultModal').animate({
scrollTop: $($elem).position().top
}, 2000, function () {
$elem.focus();
});
});
$('#resultModalTabs a').on('click', function () {
var href = $(this).attr('href');
if (href == '#tabs-2') {
$('.saveResultsBtn').hide();
} else {
$('.saveResultsBtn').show();
}
});
function toggleMessageType() {
$scope.objectives = [];
$scope.referenceFileNames = [];
if ($scope.radioModel == 'sender') {
getTestDocuments(senderGitHubUrl);
} else {
getTestDocuments(receiverGitHubUrl);
}
}
function getTestDocuments(endpointToDocuments) {
$scope.objectives = [];
$scope.referenceFileNames = [];
$http.get(endpointToDocuments).then(function (data) {
angular.forEach(data.data, function (item) {
var objective = new Object();
objective.name = item.name;
objective.url = item.url;
$scope.objectives.push(objective);
});
});
}
function getReferenceFiles() {
$scope.referenceFileNames = [];
if ($scope.validationModel.selectedObjective != undefined) {
$http.get($scope.validationModel.selectedObjective.url).then(function (data) {
angular.forEach(data.data, function (item) {
var referenceFileName = new Object();
referenceFileName.name = item.name;
referenceFileName.url = item.url;
$scope.referenceFileNames.push(referenceFileName);
});
});
}
}
});
</script>
</body>
</html>