Skip to content

Commit

Permalink
Option for sorting studies #369
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Apr 17, 2023
1 parent 569f175 commit c133f8b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,48 @@
import org.weasis.core.api.media.data.MediaElement;
import org.weasis.core.api.media.data.MediaSeries;
import org.weasis.core.api.media.data.MediaSeriesGroup;
import org.weasis.core.api.service.BundleTools;
import org.weasis.dicom.codec.TagD;
import org.weasis.dicom.explorer.DicomExplorer.SeriesPane;
import org.weasis.dicom.explorer.DicomExplorer.StudyPane;
import org.weasis.dicom.explorer.pref.download.SeriesDownloadPrefView;

public class DicomSorter {
public enum SortingTime {
CHRONOLOGICAL(0, "Chronological order"),
INVERSE_CHRONOLOGICAL(1, "Reverse chronological order");

private final int id;
private final String title;

SortingTime(int id, String title) {
this.id = id;
this.title = title;
}

public int getId() {
return id;
}

@Override
public String toString() {
return title;
}

public String getTitle() {
return title;
}

public static SortingTime valueOf(int id) {
for (SortingTime s : SortingTime.values()) {
if (s.id == id) {
return s;
}
}
return CHRONOLOGICAL;
}
}

private static final Collator collator = Collator.getInstance(Locale.getDefault());
public static final Comparator<Object> PATIENT_COMPARATOR =
(o1, o2) -> collator.compare(o1.toString(), o2.toString());
Expand All @@ -41,11 +78,14 @@ public class DicomSorter {
if (o1 instanceof MediaSeriesGroup st1 && o2 instanceof MediaSeriesGroup st2) {
LocalDateTime date1 = TagD.dateTime(Tag.StudyDate, Tag.StudyTime, st1);
LocalDateTime date2 = TagD.dateTime(Tag.StudyDate, Tag.StudyTime, st2);
// LOGGER.debug("date1: {} date2: {}", date1, date2);
int c = -1;
if (date1 != null && date2 != null) {
// Reverse chronological order.
c = date2.compareTo(date1);
if (DicomSorter.getStudyDateSorting() == SortingTime.CHRONOLOGICAL) {
c = date1.compareTo(date2);
} else {
c = date2.compareTo(date1);
}

if (c != 0) {
return c;
}
Expand Down Expand Up @@ -230,13 +270,22 @@ public class DicomSorter {
return Objects.equals(o1, o2) ? 0 : -1;
};

private DicomSorter() {}

private static boolean isDoseReport(MediaSeriesGroup series) {
String s1 = TagD.getTagValue(series, Tag.SOPClassUID, String.class);
if (s1 == null || !s1.startsWith("1.2.840.10008.5.1.4.1.1.88")) {
return false;
}
return "1.2.840.10008.5.1.4.1.1.88.67".equals(s1)
|| "1.2.840.10008.5.1.4.1.1.88.68".equals(s1) // NON-NLS
|| "1.2.840.10008.5.1.4.1.1.88.68".equals(s1)
|| "1.2.840.10008.5.1.4.1.1.88.73".equals(s1);
}

public static SortingTime getStudyDateSorting() {
int key =
BundleTools.SYSTEM_PREFERENCES.getIntProperty(
SeriesDownloadPrefView.STUDY_DATE_SORTING, SortingTime.INVERSE_CHRONOLOGICAL.getId());
return SortingTime.valueOf(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@
import org.weasis.core.ui.pref.PreferenceDialog;
import org.weasis.core.util.StringUtil;
import org.weasis.dicom.explorer.DicomExplorer;
import org.weasis.dicom.explorer.DicomSorter;
import org.weasis.dicom.explorer.DicomSorter.SortingTime;
import org.weasis.dicom.explorer.HangingProtocols.OpeningViewer;
import org.weasis.dicom.explorer.Messages;

public class SeriesDownloadPrefView extends AbstractItemDialogPage {
public static final String DOWNLOAD_IMMEDIATELY = "weasis.download.immediately";
public static final String DOWNLOAD__OPEN_MODE = "weasis.download.open.view.mode";

public static final String DOWNLOAD_OPEN_MODE = "weasis.download.open.view.mode";
public static final String STUDY_DATE_SORTING = "weasis.sorting.study.date";
private final JCheckBox downloadImmediatelyCheckbox =
new JCheckBox(Messages.getString("SeriesDownloadPrefView.downloadImmediatelyCheckbox"));
private final JSpinner spinner;

private final JComboBox<OpeningViewer> openingViewerJComboBox =
new JComboBox<>(OpeningViewer.values());

private final JComboBox<SortingTime> studyDateSortingComboBox =
new JComboBox<>(SortingTime.values());

public SeriesDownloadPrefView() {
super(Messages.getString("DicomExplorer.title"), 607);

Expand All @@ -60,6 +65,12 @@ public SeriesDownloadPrefView() {
model.setValue(thumbnailSize);
add(GuiUtils.getFlowLayoutPanel(ITEM_SEPARATOR_SMALL, ITEM_SEPARATOR, thumbSize, spinner));

JLabel labelStudyDate = new JLabel("Study date sorting" + StringUtil.COLON);
studyDateSortingComboBox.setSelectedItem(DicomSorter.getStudyDateSorting());
add(
GuiUtils.getFlowLayoutPanel(
ITEM_SEPARATOR_SMALL, ITEM_SEPARATOR, labelStudyDate, studyDateSortingComboBox));

JLabel labelOpenPatient =
new JLabel(Messages.getString("DicomExplorer.open_win") + StringUtil.COLON);
openingViewerJComboBox.setSelectedItem(getOpeningViewer());
Expand All @@ -80,7 +91,7 @@ public SeriesDownloadPrefView() {
}

private OpeningViewer getOpeningViewer() {
String key = BundleTools.SYSTEM_PREFERENCES.getProperty(DOWNLOAD__OPEN_MODE);
String key = BundleTools.SYSTEM_PREFERENCES.getProperty(DOWNLOAD_OPEN_MODE);
return OpeningViewer.getOpeningViewer(key, OpeningViewer.ALL_PATIENTS);
}

Expand All @@ -91,7 +102,11 @@ public void resetToDefaultValues() {
BundleTools.SYSTEM_PREFERENCES.getBooleanProperty(DOWNLOAD_IMMEDIATELY, true));

BundleTools.SYSTEM_PREFERENCES.resetProperty(
DOWNLOAD__OPEN_MODE, OpeningViewer.ALL_PATIENTS.name());
STUDY_DATE_SORTING, String.valueOf(SortingTime.CHRONOLOGICAL.getId()));
studyDateSortingComboBox.setSelectedItem(DicomSorter.getStudyDateSorting());

BundleTools.SYSTEM_PREFERENCES.resetProperty(
DOWNLOAD_OPEN_MODE, OpeningViewer.ALL_PATIENTS.name());
openingViewerJComboBox.setSelectedItem(getOpeningViewer());

spinner.setValue(Thumbnail.DEFAULT_SIZE);
Expand All @@ -102,9 +117,14 @@ public void closeAdditionalWindow() {
BundleTools.SYSTEM_PREFERENCES.putBooleanProperty(
DOWNLOAD_IMMEDIATELY, downloadImmediatelyCheckbox.isSelected());

SortingTime sortingTime = (SortingTime) studyDateSortingComboBox.getSelectedItem();
if (sortingTime != null) {
BundleTools.SYSTEM_PREFERENCES.putIntProperty(STUDY_DATE_SORTING, sortingTime.getId());
}

OpeningViewer openingViewer = (OpeningViewer) openingViewerJComboBox.getSelectedItem();
if (openingViewer != null) {
BundleTools.SYSTEM_PREFERENCES.put(DOWNLOAD__OPEN_MODE, openingViewer.name());
BundleTools.SYSTEM_PREFERENCES.put(DOWNLOAD_OPEN_MODE, openingViewer.name());
}

DataExplorerView dicomView = UIManager.getExplorerPlugin(DicomExplorer.NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private DownloadManager() {}

public static OpeningViewer getOpeningViewer() {
String key =
BundleTools.SYSTEM_PREFERENCES.getProperty(SeriesDownloadPrefView.DOWNLOAD__OPEN_MODE);
BundleTools.SYSTEM_PREFERENCES.getProperty(SeriesDownloadPrefView.DOWNLOAD_OPEN_MODE);
return OpeningViewer.getOpeningViewer(key, OpeningViewer.ALL_PATIENTS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.weasis.core.api.image.ZoomOp;
import org.weasis.core.api.image.ZoomOp.Interpolation;
import org.weasis.core.api.service.BundleTools;
import org.weasis.core.api.service.WProperties;
import org.weasis.core.api.util.ResourceUtil;
import org.weasis.core.api.util.ResourceUtil.ActionIcon;
import org.weasis.core.ui.docking.UIManager;
Expand Down Expand Up @@ -224,15 +225,12 @@ public void resetToDefaultValues() {
comboBoxInterpolation.setSelectedItem(Interpolation.BILINEAR);

// Get the default server configuration and if no value take the default value in parameter.
EventManager eventManager = EventManager.getInstance();
eventManager.getOptions().resetProperty(WindowOp.P_APPLY_WL_COLOR, Boolean.TRUE.toString());

checkBoxWLcolor.setSelected(
eventManager.getOptions().getBooleanProperty(WindowOp.P_APPLY_WL_COLOR, true));
checkBoxLevelInverse.setSelected(
eventManager.getOptions().getBooleanProperty(WindowOp.P_INVERSE_LEVEL, true));
checkBoxApplyPR.setSelected(
eventManager.getOptions().getBooleanProperty(PRManager.PR_APPLY, false));
WProperties properties = EventManager.getInstance().getOptions();
properties.resetProperty(WindowOp.P_APPLY_WL_COLOR, Boolean.TRUE.toString());

checkBoxWLcolor.setSelected(properties.getBooleanProperty(WindowOp.P_APPLY_WL_COLOR, true));
checkBoxLevelInverse.setSelected(properties.getBooleanProperty(WindowOp.P_INVERSE_LEVEL, true));
checkBoxApplyPR.setSelected(properties.getBooleanProperty(PRManager.PR_APPLY, false));
BundleTools.SYSTEM_PREFERENCES.putColorProperty(OverlayOp.OVERLAY_COLOR_KEY, Color.WHITE);
}

Expand Down

0 comments on commit c133f8b

Please sign in to comment.