Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix #695 SeriesInstanceUID Modality Block #697

Merged
merged 6 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/695-bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes #695. Removes the checks preventing modality being specified with other extraction keys
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private static CommandLine ParseOptions(String[] args) throws ParseException {
Option
.builder("m")
.argName("modality")
.desc("Extraction modality. Should only be specified if extracting at the Study level")
.desc("Extraction modality")
.hasArg()
.longOpt("modality")
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public ExtractMessagesCsvHandler(UUID extractionJobID, String projectID, String
_extractionModality = extractionModality;
_isIdentifiableExtraction = isIdentifiableExtraction;
_isNoFilterExtraction = isNoFilterExtraction;

// TODO(rkm 2020-01-30) Properly handle parsing of the supported modalities
if (_extractionModality != null && (!_extractionModality.equals("CT") && !_extractionModality.equals("MR"))) {
throw new IllegalArgumentException("Invalid value " + _extractionModality + " for extractionModality. Supported values are: CT, MR");
}
}

@Override
Expand All @@ -92,8 +87,6 @@ public void processHeader(String[] header) throws LineProcessingException, Illeg

if (_extractionKey == ExtractionKey.StudyInstanceUID && _extractionModality == null)
throw new IllegalArgumentException("Extracting by StudyInstanceUID, but extraction modality not set");
if (_extractionKey != ExtractionKey.StudyInstanceUID && _extractionModality != null)
throw new IllegalArgumentException("Extraction modality set, but extraction identifier is " + _extractionKey);

_logger.debug("extractionKey: " + _extractionKey);
}
Expand Down Expand Up @@ -177,8 +170,7 @@ public void sendMessages(boolean autoRun, int maxIdentifiersPerMessage) throws I
sb.append(" ExtractionKey: " + _extractionKey + System.lineSeparator());
sb.append(" IsIdentifiableExtraction: " + _isIdentifiableExtraction + System.lineSeparator());
sb.append(" IsNoFilterExtraction: " + _isNoFilterExtraction + System.lineSeparator());
if (_extractionKey == ExtractionKey.StudyInstanceUID)
sb.append(" ExtractionModality: " + _extractionModality + System.lineSeparator());
sb.append(" ExtractionModality: " + _extractionModality + System.lineSeparator());
sb.append(" KeyValueCount: " + _identifierSet.size() + System.lineSeparator());
sb.append(" Number of ExtractionRequestMessage(s): " + split.size() + System.lineSeparator());
System.out.println(sb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,6 @@ public void testModalityRequirement() throws LineProcessingException {
// Yes, I know there's probably some way to do this with JUnit
boolean thrown = false;

try {
handler = new ExtractMessagesCsvHandler(uuid, "MyProjectID", "MyProjectFolder", "aaaaa",false,false,
extractRequestMessageProducerModel, extractRequestInfoMessageProducerModel);
} catch (IllegalArgumentException e) {
thrown = true;
}
assertTrue(thrown);

handler = new ExtractMessagesCsvHandler(uuid, "MyProjectID", "MyProjectFolder", null,false,false,
extractRequestMessageProducerModel, extractRequestInfoMessageProducerModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public void PersistMessageToStore(
{
Logger.Info($"Received new job info {message}");

// If KeyTag is StudyInstanceUID then ExtractionModality must be specified, otherwise must be null
if (message.KeyTag == "StudyInstanceUID" ^ !string.IsNullOrWhiteSpace(message.ExtractionModality))
throw new ApplicationException($"Invalid combination of KeyTag and ExtractionModality (KeyTag={message.KeyTag}, ExtractionModality={message.ExtractionModality}");
// If KeyTag is StudyInstanceUID then ExtractionModality must be specified
if (message.KeyTag == "StudyInstanceUID" && string.IsNullOrWhiteSpace(message.ExtractionModality))
throw new ApplicationException($"ExtractionModality must be specified when the extraction key is StudyInstanceUID");

PersistMessageToStoreImpl(message, header);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public void TestPersistMessageToStore_ExtractionRequestInfoMessage()
message.KeyTag = "StudyInstanceUID";
message.ExtractionModality = null;
Assert.Throws<ApplicationException>(() => testExtractJobStore.PersistMessageToStore(message, mockHeader));

message.KeyTag = "SeriesInstanceUID";
message.ExtractionModality = "MR";
Assert.Throws<ApplicationException>(() => testExtractJobStore.PersistMessageToStore(message, mockHeader));
}

[Test]
Expand Down