comparison OrthancServer/OrthancExplorer/explorer.js @ 5243:f00811d14348 db-protobuf

added labels at patient/series/instance levels in orthanc explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Apr 2023 16:04:23 +0200
parents c60a7fc95f04
children 72dfa0ac84eb
comparison
equal deleted inserted replaced
5242:c60a7fc95f04 5243:f00811d14348
743 } 743 }
744 }); 744 });
745 } 745 }
746 746
747 747
748 function ConfigureLabels(nodeLabels, addLabelButton, resourceLevel, resourceId) 748 function ConfigureLabels(target, system, resourceLevel, resourceId)
749 { 749 {
750 RefreshLabels(nodeLabels, resourceLevel, resourceId); 750 if (system.HasLabels === true) {
751 751 var nodeLabels = $('<li>').append($('<div>'));
752 addLabelButton.click(function(s) { 752 var addLabelButton = $('<a>').text('Add label');
753 $('#dialog').simpledialog2({ 753
754 mode: 'button', 754 RefreshLabels(nodeLabels, resourceLevel, resourceId);
755 animate: false, 755
756 headerText: 'Add label', 756 addLabelButton.click(function(s) {
757 headerClose: true, 757 $('#dialog').simpledialog2({
758 buttonPrommpt: 'Enter the new label', 758 mode: 'button',
759 buttonInput: true, 759 animate: false,
760 width: '100%', 760 headerText: 'Add label',
761 buttons : { 761 headerClose: true,
762 'OK': { 762 buttonPrommpt: 'Enter the new label',
763 click: function () { 763 buttonInput: true,
764 var label = $.mobile.sdLastInput; 764 width: '100%',
765 if (label.length > 0) { 765 buttons : {
766 if (IsAlphanumeric(label)) { 766 'OK': {
767 $.ajax({ 767 click: function () {
768 url: '../' + resourceLevel + '/' + resourceId + '/labels/' + label, 768 var label = $.mobile.sdLastInput;
769 dataType: 'json', 769 if (label.length > 0) {
770 type: 'PUT', 770 if (IsAlphanumeric(label)) {
771 data: '', 771 $.ajax({
772 success: function(ss) { 772 url: '../' + resourceLevel + '/' + resourceId + '/labels/' + label,
773 RefreshLabels(nodeLabels, resourceLevel, resourceId); 773 dataType: 'json',
774 } 774 type: 'PUT',
775 }); 775 data: '',
776 } else { 776 success: function(ss) {
777 alert('Error: Labels can only contain alphanumeric characters'); 777 RefreshLabels(nodeLabels, resourceLevel, resourceId);
778 }
779 });
780 } else {
781 alert('Error: Labels can only contain alphanumeric characters');
782 }
778 } 783 }
779 } 784 }
780 } 785 },
781 }, 786 }
782 } 787 });
783 }); 788 });
784 }); 789
790 target
791 .append('<li data-role="list-divider">Labels</li>')
792 .append(nodeLabels)
793 .append($('<li>').attr('data-icon', 'plus').append(addLabelButton));
794 }
785 } 795 }
786 796
787 797
788 function RefreshPatient() 798 function RefreshPatient()
789 { 799 {
790 var pageData, target, v; 800 var pageData, target, v;
791 801
792 if ($.mobile.pageData) { 802 if ($.mobile.pageData) {
793 pageData = DeepCopy($.mobile.pageData); 803 pageData = DeepCopy($.mobile.pageData);
794 804
795 GetResource('/patients/' + pageData.uuid + '?full', function(patient) { 805 GetResource('/system', function(system) {
796 GetResource('/patients/' + pageData.uuid + '/studies?full', function(studies) { 806 GetResource('/patients/' + pageData.uuid + '?full', function(patient) {
797 SortOnDicomTag(studies, STUDY_DATE, false, true); 807 GetResource('/patients/' + pageData.uuid + '/studies?full', function(studies) {
798 808 SortOnDicomTag(studies, STUDY_DATE, false, true);
799 $('#patient-info li').remove(); 809
800 $('#patient-info') 810 $('#patient-info li').remove();
801 .append('<li data-role="list-divider">Patient</li>') 811
802 .append(FormatPatient(patient)) 812 var info = $('#patient-info')
803 .listview('refresh'); 813 .append('<li data-role="list-divider">Patient</li>')
804 814 .append(FormatPatient(patient));
805 target = $('#list-studies'); 815 ConfigureLabels(info, system, 'patients', patient.ID);
806 $('li', target).remove(); 816 info.listview('refresh');
807 817
808 for (var i = 0; i < studies.length; i++) { 818 target = $('#list-studies');
809 if (i == 0 || 819 $('li', target).remove();
810 GetMainDicomTag(studies[i].MainDicomTags, STUDY_DATE) != 820
811 GetMainDicomTag(studies[i - 1].MainDicomTags, STUDY_DATE)) 821 for (var i = 0; i < studies.length; i++) {
812 { 822 if (i == 0 ||
813 target.append($('<li>') 823 GetMainDicomTag(studies[i].MainDicomTags, STUDY_DATE) !=
814 .attr('data-role', 'list-divider') 824 GetMainDicomTag(studies[i - 1].MainDicomTags, STUDY_DATE))
815 .text(FormatDicomDate(GetMainDicomTag(studies[i].MainDicomTags, STUDY_DATE)))); 825 {
826 target.append($('<li>')
827 .attr('data-role', 'list-divider')
828 .text(FormatDicomDate(GetMainDicomTag(studies[i].MainDicomTags, STUDY_DATE))));
829 }
830
831 target.append(FormatStudy(studies[i], '#study?uuid=' + studies[i].ID));
816 } 832 }
817 833
818 target.append(FormatStudy(studies[i], '#study?uuid=' + studies[i].ID)); 834 SetupAnonymizedOrModifiedFrom('#patient-anonymized-from', patient, 'patient', ANONYMIZED_FROM);
819 } 835 SetupAnonymizedOrModifiedFrom('#patient-modified-from', patient, 'patient', MODIFIED_FROM);
820 836 SetupAttachments('#patient-access', 'patient-attachment', pageData.uuid, 'patients');
821 SetupAnonymizedOrModifiedFrom('#patient-anonymized-from', patient, 'patient', ANONYMIZED_FROM); 837
822 SetupAnonymizedOrModifiedFrom('#patient-modified-from', patient, 'patient', MODIFIED_FROM); 838 target.listview('refresh');
823 SetupAttachments('#patient-access', 'patient-attachment', pageData.uuid, 'patients'); 839
824 840 // Check whether this patient is protected
825 target.listview('refresh'); 841 $.ajax({
826 842 url: '../patients/' + pageData.uuid + '/protected',
827 // Check whether this patient is protected 843 type: 'GET',
828 $.ajax({ 844 dataType: 'text',
829 url: '../patients/' + pageData.uuid + '/protected', 845 async: false,
830 type: 'GET', 846 cache: false,
831 dataType: 'text', 847 success: function (s) {
832 async: false, 848 v = (s == '1') ? 'on' : 'off';
833 cache: false, 849 $('#protection').val(v).slider('refresh');
834 success: function (s) { 850 }
835 v = (s == '1') ? 'on' : 'off'; 851 });
836 $('#protection').val(v).slider('refresh'); 852
837 } 853 currentPage = 'patient';
854 currentUuid = pageData.uuid;
838 }); 855 });
839
840 currentPage = 'patient';
841 currentUuid = pageData.uuid;
842 }); 856 });
843 }); 857 });
844 } 858 }
845 } 859 }
846 860
864 var info = $('#study-info') 878 var info = $('#study-info')
865 .append('<li data-role="list-divider">Patient</li>') 879 .append('<li data-role="list-divider">Patient</li>')
866 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) 880 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true))
867 .append('<li data-role="list-divider">Study</li>') 881 .append('<li data-role="list-divider">Study</li>')
868 .append(FormatStudy(study)); 882 .append(FormatStudy(study));
869 883 ConfigureLabels(info, system, 'studies', study.ID);
870 if (system.HasLabels === true) {
871 var nodeLabels = $('<li>').append($('<div>'));
872 var addLabelButton = $('<a>').text('Add label');
873 ConfigureLabels(nodeLabels, addLabelButton, 'studies', study.ID)
874
875 info
876 .append('<li data-role="list-divider">Labels</li>')
877 .append(nodeLabels)
878 .append($('<li>').attr('data-icon', 'plus').append(addLabelButton));
879 }
880
881 info.listview('refresh'); 884 info.listview('refresh');
882 885
883 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', ANONYMIZED_FROM); 886 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', ANONYMIZED_FROM);
884 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', MODIFIED_FROM); 887 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', MODIFIED_FROM);
885 SetupAttachments('#study-access', 'study-attachment', pageData.uuid, 'studies'); 888 SetupAttachments('#study-access', 'study-attachment', pageData.uuid, 'studies');
916 var pageData, target; 919 var pageData, target;
917 920
918 if ($.mobile.pageData) { 921 if ($.mobile.pageData) {
919 pageData = DeepCopy($.mobile.pageData); 922 pageData = DeepCopy($.mobile.pageData);
920 923
921 GetResource('/series/' + pageData.uuid + '?full', function(series) { 924 GetResource('/system', function(system) {
922 GetResource('/studies/' + series.ParentStudy + '?full', function(study) { 925 GetResource('/series/' + pageData.uuid + '?full', function(series) {
923 GetResource('/patients/' + study.ParentPatient + '?full', function(patient) { 926 GetResource('/studies/' + series.ParentStudy + '?full', function(study) {
924 GetResource('/series/' + pageData.uuid + '/instances?full', function(instances) { 927 GetResource('/patients/' + study.ParentPatient + '?full', function(patient) {
925 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); 928 GetResource('/series/' + pageData.uuid + '/instances?full', function(instances) {
926 929 Sort(instances, function(x) { return x.IndexInSeries; }, true, false);
927 $('#series .patient-link').attr('href', '#patient?uuid=' + patient.ID); 930
928 $('#series .study-link').attr('href', '#study?uuid=' + study.ID); 931 $('#series .patient-link').attr('href', '#patient?uuid=' + patient.ID);
929 932 $('#series .study-link').attr('href', '#study?uuid=' + study.ID);
930 $('#series-info li').remove(); 933
931 $('#series-info') 934 $('#series-info li').remove();
932 .append('<li data-role="list-divider">Patient</li>') 935 var info = $('#series-info')
933 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) 936 .append('<li data-role="list-divider">Patient</li>')
934 .append('<li data-role="list-divider">Study</li>') 937 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true))
935 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) 938 .append('<li data-role="list-divider">Study</li>')
936 .append('<li data-role="list-divider">Series</li>') 939 .append(FormatStudy(study, '#study?uuid=' + study.ID, true))
937 .append(FormatSeries(series)) 940 .append('<li data-role="list-divider">Series</li>')
938 .listview('refresh'); 941 .append(FormatSeries(series));
939 942 ConfigureLabels(info, system, 'series', series.ID);
940 SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', ANONYMIZED_FROM); 943 info.listview('refresh');
941 SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', MODIFIED_FROM); 944
942 SetupAttachments('#series-access', 'series-attachment', pageData.uuid, 'series'); 945 SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', ANONYMIZED_FROM);
943 946 SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', MODIFIED_FROM);
944 target = $('#list-instances'); 947 SetupAttachments('#series-access', 'series-attachment', pageData.uuid, 'series');
945 $('li', target).remove(); 948
946 for (var i = 0; i < instances.length; i++) { 949 target = $('#list-instances');
947 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); 950 $('li', target).remove();
948 } 951 for (var i = 0; i < instances.length; i++) {
949 target.listview('refresh'); 952 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID));
950 953 }
951 currentPage = 'series'; 954 target.listview('refresh');
952 currentUuid = pageData.uuid; 955
956 currentPage = 'series';
957 currentUuid = pageData.uuid;
958 });
953 }); 959 });
954 }); 960 });
955 }); 961 });
956 }); 962 });
957 } 963 }
1029 var pageData; 1035 var pageData;
1030 1036
1031 if ($.mobile.pageData) { 1037 if ($.mobile.pageData) {
1032 pageData = DeepCopy($.mobile.pageData); 1038 pageData = DeepCopy($.mobile.pageData);
1033 1039
1034 GetResource('/instances/' + pageData.uuid + '?full', function(instance) { 1040 GetResource('/system', function(system) {
1035 GetResource('/series/' + instance.ParentSeries + '?full', function(series) { 1041 GetResource('/instances/' + pageData.uuid + '?full', function(instance) {
1036 GetResource('/studies/' + series.ParentStudy + '?full', function(study) { 1042 GetResource('/series/' + instance.ParentSeries + '?full', function(series) {
1037 GetResource('/patients/' + study.ParentPatient + '?full', function(patient) { 1043 GetResource('/studies/' + series.ParentStudy + '?full', function(study) {
1038 1044 GetResource('/patients/' + study.ParentPatient + '?full', function(patient) {
1039 $('#instance .patient-link').attr('href', '#patient?uuid=' + patient.ID); 1045
1040 $('#instance .study-link').attr('href', '#study?uuid=' + study.ID); 1046 $('#instance .patient-link').attr('href', '#patient?uuid=' + patient.ID);
1041 $('#instance .series-link').attr('href', '#series?uuid=' + series.ID); 1047 $('#instance .study-link').attr('href', '#study?uuid=' + study.ID);
1042 1048 $('#instance .series-link').attr('href', '#series?uuid=' + series.ID);
1043 $('#instance-info li').remove(); 1049
1044 $('#instance-info') 1050 $('#instance-info li').remove();
1045 .append('<li data-role="list-divider">Patient</li>') 1051 var info = $('#instance-info')
1046 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) 1052 .append('<li data-role="list-divider">Patient</li>')
1047 .append('<li data-role="list-divider">Study</li>') 1053 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true))
1048 .append(FormatStudy(study, '#study?uuid=' + study.ID, true)) 1054 .append('<li data-role="list-divider">Study</li>')
1049 .append('<li data-role="list-divider">Series</li>') 1055 .append(FormatStudy(study, '#study?uuid=' + study.ID, true))
1050 .append(FormatSeries(series, '#series?uuid=' + series.ID, true)) 1056 .append('<li data-role="list-divider">Series</li>')
1051 .append('<li data-role="list-divider">Instance</li>') 1057 .append(FormatSeries(series, '#series?uuid=' + series.ID, true))
1052 .append(FormatInstance(instance)) 1058 .append('<li data-role="list-divider">Instance</li>')
1053 .listview('refresh'); 1059 .append(FormatInstance(instance));
1054 1060 ConfigureLabels(info, system, 'instances', instance.ID);
1055 GetResource('/instances/' + instance.ID + '/tags', function(s) { 1061 info.listview('refresh');
1056 $('#dicom-tree').tree('loadData', ConvertForTree(s)); 1062
1063 GetResource('/instances/' + instance.ID + '/tags', function(s) {
1064 $('#dicom-tree').tree('loadData', ConvertForTree(s));
1065 });
1066
1067 GetResource('/instances/' + instance.ID + '/header', function(s) {
1068 $('#dicom-metaheader').tree('loadData', ConvertForTree(s));
1069 });
1070
1071 $('#transfer-syntax').hide();
1072 GetResource('/instances/' + instance.ID + '/metadata?expand', function(s) {
1073 transferSyntax = s['TransferSyntax'];
1074 if (transferSyntax !== undefined) {
1075 $('#transfer-syntax').show();
1076 $('#transfer-syntax-text').text(transferSyntax);
1077 }
1078 });
1079
1080 SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', ANONYMIZED_FROM);
1081 SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', MODIFIED_FROM);
1082
1083 SetupAttachments('#instance-access', 'instance-attachment', pageData.uuid, 'instances');
1084
1085 currentPage = 'instance';
1086 currentUuid = pageData.uuid;
1057 }); 1087 });
1058
1059 GetResource('/instances/' + instance.ID + '/header', function(s) {
1060 $('#dicom-metaheader').tree('loadData', ConvertForTree(s));
1061 });
1062
1063 $('#transfer-syntax').hide();
1064 GetResource('/instances/' + instance.ID + '/metadata?expand', function(s) {
1065 transferSyntax = s['TransferSyntax'];
1066 if (transferSyntax !== undefined) {
1067 $('#transfer-syntax').show();
1068 $('#transfer-syntax-text').text(transferSyntax);
1069 }
1070 });
1071
1072 SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', ANONYMIZED_FROM);
1073 SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', MODIFIED_FROM);
1074
1075 SetupAttachments('#instance-access', 'instance-attachment', pageData.uuid, 'instances');
1076
1077 currentPage = 'instance';
1078 currentUuid = pageData.uuid;
1079 }); 1088 });
1080 }); 1089 });
1081 }); 1090 });
1082 }); 1091 });
1083 } 1092 }