From 74a99c665c27b8e4dae8223df49e80f14d71b9f2 Mon Sep 17 00:00:00 2001 From: Nicolas Roduit Date: Mon, 17 Jun 2024 08:12:40 +0200 Subject: [PATCH] Command: add close a specific patient from its patient ID #562 --- .../org/weasis/dicom/explorer/DicomModel.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomModel.java b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomModel.java index 645ded3b0..bf3a70d95 100755 --- a/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomModel.java +++ b/weasis-dicom/weasis-dicom-explorer/src/main/java/org/weasis/dicom/explorer/DicomModel.java @@ -1237,15 +1237,21 @@ public void close(String[] argv) throws IOException { "Close DICOM files", // NON-NLS "Usage: dicom:close (-a | ([-y UID]... [-s UID]...))", // NON-NLS " -a --all close all the patients", // NON-NLS + " -p --patient=ID close a patient from its patient ID", // NON-NLS " -y --study=UID close a study, UID is Study Instance UID", // NON-NLS " -s --series=UID close a series, UID is Series Instance UID", // NON-NLS " -? --help show help" // NON-NLS }; final Option opt = Options.compile(usage).parse(argv); + final List pargs = opt.getList("patient"); // NON-NLS final List yargs = opt.getList("study"); // NON-NLS final List sargs = opt.getList("series"); // NON-NLS - if (opt.isSet("help") || (yargs.isEmpty() && sargs.isEmpty() && !opt.isSet("all"))) { // NON-NLS + if (opt.isSet("help") + || (pargs.isEmpty() + && yargs.isEmpty() + && sargs.isEmpty() + && !opt.isSet("all"))) { // NON-NLS opt.usage(); return; } @@ -1255,16 +1261,25 @@ public void close(String[] argv) throws IOException { firePropertyChange( new ObservableEvent( ObservableEvent.BasicAction.SELECT, DicomModel.this, null, DicomModel.this)); - closeCommand(opt, yargs, sargs); + closeCommand(opt, pargs, yargs, sargs); }); } - private void closeCommand(Option opt, List yargs, List sargs) { + private void closeCommand( + Option opt, List pargs, List yargs, List sargs) { if (opt.isSet("all")) { // NON-NLS for (MediaSeriesGroup patientGroup : model.getSuccessors(MediaSeriesGroupNode.rootNode)) { removePatient(patientGroup); } } else { + if (opt.isSet("patient")) { // NON-NLS + for (MediaSeriesGroup patientGroup : model.getSuccessors(MediaSeriesGroupNode.rootNode)) { + String patientID = TagD.getTagValue(patientGroup, Tag.PatientID, String.class); + if (pargs.contains(patientID)) { + removePatient(patientGroup); + } + } + } if (opt.isSet("study")) { // NON-NLS for (String studyUID : yargs) { removeStudy(getStudyNode(studyUID));