Skip to content

Commit

Permalink
Merge pull request #828 from Project-MONAI/AC-2259
Browse files Browse the repository at this point in the history
fix to return multiple vaules in metadata
  • Loading branch information
neildsouth authored Jun 5, 2023
2 parents d819b68 + 1477e4e commit 2045f5e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/TaskManager/Plug-ins/Email/EmailPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override async Task<ExecutionStatus> ExecuteTask(CancellationToken cancel

try
{
var metadata = new Dictionary<string, string>();
var metadata = new Dictionary<string, List<string>>();
if (Event.Inputs.Any())
{
foreach (var input in Event.Inputs)
Expand All @@ -132,7 +132,7 @@ public override async Task<ExecutionStatus> ExecuteTask(CancellationToken cancel
}
}

var emailRequest = GenerateEmailRequestEventMessage(metadata);
var emailRequest = GenerateEmailRequestEventMessage(FlattenMeta(metadata));
await SendEmailRequestEvent(emailRequest).ConfigureAwait(false);

return new ExecutionStatus { Status = TaskExecutionStatus.Accepted, FailureReason = FailureReason.None, Stats = new Dictionary<string, string> { { "IdentityKey", emailRequest.Body.Id.ToString() } } };
Expand All @@ -145,7 +145,17 @@ public override async Task<ExecutionStatus> ExecuteTask(CancellationToken cancel
}
}

private async Task<Dictionary<string, string>> AddRawMetaFromFile(Dictionary<string, string> metadata, string path, string bucketName)
private static Dictionary<string, string> FlattenMeta(Dictionary<string, List<string>> input)
{
var values = new Dictionary<string, string>();
foreach (var key in input.Keys)
{
values.Add(key, string.Join(",", input[key].Distinct()));
}
return values;
}

private async Task<Dictionary<string, List<string>>> AddRawMetaFromFile(Dictionary<string, List<string>> metadata, string path, string bucketName)
{
if (_includeMetadata is null || _includeMetadata.Count() == 0)
{
Expand All @@ -168,7 +178,8 @@ private async Task<Dictionary<string, string>> AddRawMetaFromFile(Dictionary<str

foreach (var item in _includeMetadata)
{
if (metadata.ContainsKey(item)) continue;
var values = new List<string>();
if (metadata.ContainsKey(item)) values = metadata[item];

DicomTag tag;
try
Expand All @@ -181,7 +192,8 @@ private async Task<Dictionary<string, string>> AddRawMetaFromFile(Dictionary<str
}
if (tag is not null)
{
metadata.Add(item, dcmFile.Dataset.GetString(tag));
values.Add(dcmFile.Dataset.GetString(tag).Trim());
metadata.Add(item, values);
}
}
}
Expand Down

0 comments on commit 2045f5e

Please sign in to comment.