Mercurial > hg > orthanc
comparison OrthancExplorer/explorer.js @ 1345:c90a4a42a3f2
simplification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 Apr 2015 17:33:07 +0200 |
parents | 72d1c2fc0edb |
children | b8dc2f855a83 |
comparison
equal
deleted
inserted
replaced
1344:c86ad9b58eed | 1345:c90a4a42a3f2 |
---|---|
140 }, isInteger, reverse); | 140 }, isInteger, reverse); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 | 144 |
145 function GetSingleResource(type, uuid, callback) | 145 function GetResource(uri, callback) |
146 { | 146 { |
147 var resource = null; | |
148 $.ajax({ | 147 $.ajax({ |
149 url: '../' + type + '/' + uuid, | 148 url: '..' + uri, |
150 dataType: 'json', | 149 dataType: 'json', |
151 async: false, | 150 async: false, |
152 cache: false, | 151 cache: false, |
153 success: function(s) { | 152 success: function(s) { |
154 callback(s); | 153 callback(s); |
306 }); | 305 }); |
307 | 306 |
308 | 307 |
309 | 308 |
310 $('#find-patients').live('pagebeforeshow', function() { | 309 $('#find-patients').live('pagebeforeshow', function() { |
311 $.ajax({ | 310 GetResource('/patients?expand', function(patients) { |
312 url: '/patients?expand', | |
313 dataType: 'json', | |
314 async: false, | |
315 cache: false, | |
316 success: function(patients) { | |
317 var target = $('#all-patients'); | 311 var target = $('#all-patients'); |
318 $('li', target).remove(); | 312 $('li', target).remove(); |
319 | 313 |
320 SortOnDicomTag(patients, 'PatientName', false, false); | 314 SortOnDicomTag(patients, 'PatientName', false, false); |
321 | 315 |
323 var p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID); | 317 var p = FormatPatient(patients[i], '#patient?uuid=' + patients[i].ID); |
324 target.append(p); | 318 target.append(p); |
325 } | 319 } |
326 | 320 |
327 target.listview('refresh'); | 321 target.listview('refresh'); |
328 } | 322 }); |
329 }); | |
330 }); | 323 }); |
331 | 324 |
332 | 325 |
333 | 326 |
334 function SetupAnonymizedOrModifiedFrom(buttonSelector, resource, resourceType, field) | 327 function SetupAnonymizedOrModifiedFrom(buttonSelector, resource, resourceType, field) |
349 | 342 |
350 | 343 |
351 function RefreshPatient() | 344 function RefreshPatient() |
352 { | 345 { |
353 if ($.mobile.pageData) { | 346 if ($.mobile.pageData) { |
354 GetSingleResource('patients', $.mobile.pageData.uuid, function(patient) { | 347 GetResource('/patients/' + $.mobile.pageData.uuid, function(patient) { |
355 $.ajax({ | 348 GetResource('/patients/' + $.mobile.pageData.uuid + '/studies', function(studies) { |
356 url: '/patients/' + $.mobile.pageData.uuid + '/studies', | 349 SortOnDicomTag(studies, 'StudyDate', false, true); |
357 dataType: 'json', | 350 |
358 async: false, | 351 $('#patient-info li').remove(); |
359 cache: false, | 352 $('#patient-info') |
360 success: function(studies) { | 353 .append('<li data-role="list-divider">Patient</li>') |
361 SortOnDicomTag(studies, 'StudyDate', false, true); | 354 .append(FormatPatient(patient)) |
362 | 355 .listview('refresh'); |
363 $('#patient-info li').remove(); | 356 |
364 $('#patient-info') | 357 var target = $('#list-studies'); |
358 $('li', target).remove(); | |
359 | |
360 for (var i = 0; i < studies.length; i++) { | |
361 if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate) | |
362 { | |
363 target.append('<li data-role="list-divider">{0}</li>'.format | |
364 (FormatDicomDate(studies[i].MainDicomTags.StudyDate))); | |
365 } | |
366 | |
367 target.append(FormatStudy(studies[i], '#study?uuid=' + studies[i].ID)); | |
368 } | |
369 | |
370 SetupAnonymizedOrModifiedFrom('#patient-anonymized-from', patient, 'patient', 'AnonymizedFrom'); | |
371 SetupAnonymizedOrModifiedFrom('#patient-modified-from', patient, 'patient', 'ModifiedFrom'); | |
372 | |
373 target.listview('refresh'); | |
374 | |
375 // Check whether this patient is protected | |
376 $.ajax({ | |
377 url: '../patients/' + $.mobile.pageData.uuid + '/protected', | |
378 type: 'GET', | |
379 dataType: 'text', | |
380 async: false, | |
381 cache: false, | |
382 success: function (s) { | |
383 var v = (s == '1') ? 'on' : 'off'; | |
384 $('#protection').val(v).slider('refresh'); | |
385 } | |
386 }); | |
387 | |
388 currentPage = 'patient'; | |
389 currentUuid = $.mobile.pageData.uuid; | |
390 }); | |
391 }); | |
392 } | |
393 } | |
394 | |
395 | |
396 function RefreshStudy() | |
397 { | |
398 if ($.mobile.pageData) { | |
399 GetResource('/studies/' + $.mobile.pageData.uuid, function(study) { | |
400 GetResource('/patients/' + study.ParentPatient, function(patient) { | |
401 GetResource('/studies/' + $.mobile.pageData.uuid + '/series', function(series) { | |
402 SortOnDicomTag(series, 'SeriesDate', false, true); | |
403 | |
404 $('#study .patient-link').attr('href', '#patient?uuid=' + patient.ID); | |
405 $('#study-info li').remove(); | |
406 $('#study-info') | |
365 .append('<li data-role="list-divider">Patient</li>') | 407 .append('<li data-role="list-divider">Patient</li>') |
366 .append(FormatPatient(patient)) | 408 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) |
409 .append('<li data-role="list-divider">Study</li>') | |
410 .append(FormatStudy(study)) | |
367 .listview('refresh'); | 411 .listview('refresh'); |
368 | 412 |
369 var target = $('#list-studies'); | 413 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', 'AnonymizedFrom'); |
414 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', 'ModifiedFrom'); | |
415 | |
416 var target = $('#list-series'); | |
370 $('li', target).remove(); | 417 $('li', target).remove(); |
371 | 418 for (var i = 0; i < series.length; i++) { |
372 for (var i = 0; i < studies.length; i++) { | 419 if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate) |
373 if (i == 0 || studies[i].MainDicomTags.StudyDate != studies[i - 1].MainDicomTags.StudyDate) | |
374 { | 420 { |
375 target.append('<li data-role="list-divider">{0}</li>'.format | 421 target.append('<li data-role="list-divider">{0}</li>'.format |
376 (FormatDicomDate(studies[i].MainDicomTags.StudyDate))); | 422 (FormatDicomDate(series[i].MainDicomTags.SeriesDate))); |
377 } | 423 } |
378 | 424 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); |
379 target.append(FormatStudy(studies[i], '#study?uuid=' + studies[i].ID)); | |
380 } | 425 } |
381 | |
382 SetupAnonymizedOrModifiedFrom('#patient-anonymized-from', patient, 'patient', 'AnonymizedFrom'); | |
383 SetupAnonymizedOrModifiedFrom('#patient-modified-from', patient, 'patient', 'ModifiedFrom'); | |
384 | |
385 target.listview('refresh'); | 426 target.listview('refresh'); |
386 | 427 |
387 // Check whether this patient is protected | 428 currentPage = 'study'; |
388 $.ajax({ | |
389 url: '../patients/' + $.mobile.pageData.uuid + '/protected', | |
390 type: 'GET', | |
391 dataType: 'text', | |
392 async: false, | |
393 cache: false, | |
394 success: function (s) { | |
395 var v = (s == '1') ? 'on' : 'off'; | |
396 $('#protection').val(v).slider('refresh'); | |
397 } | |
398 }); | |
399 | |
400 currentPage = 'patient'; | |
401 currentUuid = $.mobile.pageData.uuid; | 429 currentUuid = $.mobile.pageData.uuid; |
402 } | 430 }); |
403 }); | 431 }); |
404 }); | 432 }); |
405 } | 433 } |
406 } | 434 } |
407 | 435 |
408 | 436 |
409 function RefreshStudy() | 437 function RefreshSeries() |
410 { | 438 { |
411 if ($.mobile.pageData) { | 439 if ($.mobile.pageData) { |
412 GetSingleResource('studies', $.mobile.pageData.uuid, function(study) { | 440 GetResource('/series/' + $.mobile.pageData.uuid, function(series) { |
413 GetSingleResource('patients', study.ParentPatient, function(patient) { | 441 GetResource('/studies/' + series.ParentStudy, function(study) { |
414 $.ajax({ | 442 GetResource('/patients/' + study.ParentPatient, function(patient) { |
415 url: '/studies/' + $.mobile.pageData.uuid + '/series', | 443 GetResource('/series/' + $.mobile.pageData.uuid + '/instances', function(instances) { |
416 dataType: 'json', | 444 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
417 async: false, | 445 |
418 cache: false, | 446 $('#series .patient-link').attr('href', '#patient?uuid=' + patient.ID); |
419 success: function(series) { | 447 $('#series .study-link').attr('href', '#study?uuid=' + study.ID); |
420 SortOnDicomTag(series, 'SeriesDate', false, true); | 448 |
421 | 449 $('#series-info li').remove(); |
422 $('#study .patient-link').attr('href', '#patient?uuid=' + patient.ID); | 450 $('#series-info') |
423 $('#study-info li').remove(); | |
424 $('#study-info') | |
425 .append('<li data-role="list-divider">Patient</li>') | 451 .append('<li data-role="list-divider">Patient</li>') |
426 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | 452 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) |
427 .append('<li data-role="list-divider">Study</li>') | 453 .append('<li data-role="list-divider">Study</li>') |
428 .append(FormatStudy(study)) | 454 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) |
455 .append('<li data-role="list-divider">Series</li>') | |
456 .append(FormatSeries(series)) | |
429 .listview('refresh'); | 457 .listview('refresh'); |
430 | 458 |
431 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', 'AnonymizedFrom'); | 459 SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', 'AnonymizedFrom'); |
432 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', 'ModifiedFrom'); | 460 SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', 'ModifiedFrom'); |
433 | 461 |
434 var target = $('#list-series'); | 462 var target = $('#list-instances'); |
435 $('li', target).remove(); | 463 $('li', target).remove(); |
436 for (var i = 0; i < series.length; i++) { | 464 for (var i = 0; i < instances.length; i++) { |
437 if (i == 0 || series[i].MainDicomTags.SeriesDate != series[i - 1].MainDicomTags.SeriesDate) | 465 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); |
438 { | |
439 target.append('<li data-role="list-divider">{0}</li>'.format | |
440 (FormatDicomDate(series[i].MainDicomTags.SeriesDate))); | |
441 } | |
442 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); | |
443 } | 466 } |
444 target.listview('refresh'); | 467 target.listview('refresh'); |
445 | 468 |
446 currentPage = 'study'; | 469 currentPage = 'series'; |
447 currentUuid = $.mobile.pageData.uuid; | 470 currentUuid = $.mobile.pageData.uuid; |
448 } | |
449 }); | |
450 }); | |
451 }); | |
452 } | |
453 } | |
454 | |
455 | |
456 function RefreshSeries() | |
457 { | |
458 if ($.mobile.pageData) { | |
459 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { | |
460 GetSingleResource('studies', series.ParentStudy, function(study) { | |
461 GetSingleResource('patients', study.ParentPatient, function(patient) { | |
462 $.ajax({ | |
463 url: '/series/' + $.mobile.pageData.uuid + '/instances', | |
464 dataType: 'json', | |
465 async: false, | |
466 cache: false, | |
467 success: function(instances) { | |
468 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); | |
469 | |
470 $('#series .patient-link').attr('href', '#patient?uuid=' + patient.ID); | |
471 $('#series .study-link').attr('href', '#study?uuid=' + study.ID); | |
472 | |
473 $('#series-info li').remove(); | |
474 $('#series-info') | |
475 .append('<li data-role="list-divider">Patient</li>') | |
476 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | |
477 .append('<li data-role="list-divider">Study</li>') | |
478 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) | |
479 .append('<li data-role="list-divider">Series</li>') | |
480 .append(FormatSeries(series)) | |
481 .listview('refresh'); | |
482 | |
483 SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', 'AnonymizedFrom'); | |
484 SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', 'ModifiedFrom'); | |
485 | |
486 var target = $('#list-instances'); | |
487 $('li', target).remove(); | |
488 for (var i = 0; i < instances.length; i++) { | |
489 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); | |
490 } | |
491 target.listview('refresh'); | |
492 | |
493 currentPage = 'series'; | |
494 currentUuid = $.mobile.pageData.uuid; | |
495 } | |
496 }); | 471 }); |
497 }); | 472 }); |
498 }); | 473 }); |
499 }); | 474 }); |
500 } | 475 } |
554 | 529 |
555 | 530 |
556 function RefreshInstance() | 531 function RefreshInstance() |
557 { | 532 { |
558 if ($.mobile.pageData) { | 533 if ($.mobile.pageData) { |
559 GetSingleResource('instances', $.mobile.pageData.uuid, function(instance) { | 534 GetResource('/instances/' + $.mobile.pageData.uuid, function(instance) { |
560 GetSingleResource('series', instance.ParentSeries, function(series) { | 535 GetResource('/series/' + instance.ParentSeries, function(series) { |
561 GetSingleResource('studies', series.ParentStudy, function(study) { | 536 GetResource('/studies/' + series.ParentStudy, function(study) { |
562 GetSingleResource('patients', study.ParentPatient, function(patient) { | 537 GetResource('/patients/' + study.ParentPatient, function(patient) { |
563 | 538 |
564 $('#instance .patient-link').attr('href', '#patient?uuid=' + patient.ID); | 539 $('#instance .patient-link').attr('href', '#patient?uuid=' + patient.ID); |
565 $('#instance .study-link').attr('href', '#study?uuid=' + study.ID); | 540 $('#instance .study-link').attr('href', '#study?uuid=' + study.ID); |
566 $('#instance .series-link').attr('href', '#series?uuid=' + series.ID); | 541 $('#instance .series-link').attr('href', '#series?uuid=' + series.ID); |
567 | 542 |
575 .append(FormatSeries(series, '#series?uuid=' + series.ID, true)) | 550 .append(FormatSeries(series, '#series?uuid=' + series.ID, true)) |
576 .append('<li data-role="list-divider">Instance</li>') | 551 .append('<li data-role="list-divider">Instance</li>') |
577 .append(FormatInstance(instance)) | 552 .append(FormatInstance(instance)) |
578 .listview('refresh'); | 553 .listview('refresh'); |
579 | 554 |
580 $.ajax({ | 555 GetResource('/instances/' + instance.ID + '/tags', function(s) { |
581 url: '../instances/' + instance.ID + '/tags', | 556 $('#dicom-tree').tree('loadData', ConvertForTree(s)); |
582 cache: false, | |
583 dataType: 'json', | |
584 success: function(s) { | |
585 $('#dicom-tree').tree('loadData', ConvertForTree(s)); | |
586 } | |
587 }); | 557 }); |
588 | 558 |
589 SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', 'AnonymizedFrom'); | 559 SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', 'AnonymizedFrom'); |
590 SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', 'ModifiedFrom'); | 560 SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', 'ModifiedFrom'); |
591 | 561 |
714 | 684 |
715 | 685 |
716 | 686 |
717 $('#instance-preview').live('click', function(e) { | 687 $('#instance-preview').live('click', function(e) { |
718 if ($.mobile.pageData) { | 688 if ($.mobile.pageData) { |
719 GetSingleResource('instances', $.mobile.pageData.uuid + '/frames', function(frames) { | 689 GetResource('/instances/' + $.mobile.pageData.uuid + '/frames', function(frames) { |
720 if (frames.length == 1) | 690 if (frames.length == 1) |
721 { | 691 { |
722 // Viewing a single-frame image | 692 // Viewing a single-frame image |
723 jQuery.slimbox('../instances/' + $.mobile.pageData.uuid + '/preview', '', { | 693 jQuery.slimbox('../instances/' + $.mobile.pageData.uuid + '/preview', '', { |
724 overlayFadeDuration : 1, | 694 overlayFadeDuration : 1, |
746 | 716 |
747 } | 717 } |
748 }); | 718 }); |
749 | 719 |
750 | 720 |
721 | |
751 $('#series-preview').live('click', function(e) { | 722 $('#series-preview').live('click', function(e) { |
752 if ($.mobile.pageData) { | 723 if ($.mobile.pageData) { |
753 GetSingleResource('series', $.mobile.pageData.uuid, function(series) { | 724 GetResource('/series/' + $.mobile.pageData.uuid, function(series) { |
754 $.ajax({ | 725 GetResource('/series/' + $.mobile.pageData.uuid + '/instances', function(instances) { |
755 url: '/series/' + $.mobile.pageData.uuid + '/instances', | 726 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
756 dataType: 'json', | 727 |
757 async: false, | 728 var images = []; |
758 cache: false, | 729 for (var i = 0; i < instances.length; i++) { |
759 success: function(instances) { | 730 images.push([ '../instances/' + instances[i].ID + '/preview', |
760 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); | 731 '{0}/{1}'.format(i + 1, instances.length) ]) |
761 | |
762 var images = []; | |
763 for (var i = 0; i < instances.length; i++) { | |
764 images.push([ '../instances/' + instances[i].ID + '/preview', | |
765 '{0}/{1}'.format(i + 1, instances.length) ]) | |
766 } | |
767 | |
768 jQuery.slimbox(images, 0, { | |
769 overlayFadeDuration : 1, | |
770 resizeDuration : 1, | |
771 imageFadeDuration : 1, | |
772 loop : true | |
773 }); | |
774 } | 732 } |
733 | |
734 jQuery.slimbox(images, 0, { | |
735 overlayFadeDuration : 1, | |
736 resizeDuration : 1, | |
737 imageFadeDuration : 1, | |
738 loop : true | |
739 }); | |
775 }); | 740 }); |
776 }); | 741 }); |
777 } | 742 } |
778 }); | 743 }); |
779 | |
780 | 744 |
781 | 745 |
782 | 746 |
783 | 747 |
784 | 748 |