Skip to content

Commit 92c88c0

Browse files
201 202 203 misc fixes (#221)
* misc fixes Signed-off-by: Jack Schofield <[email protected]>
1 parent 91c129a commit 92c88c0

File tree

18 files changed

+114
-40
lines changed

18 files changed

+114
-40
lines changed

src/ConditionsResolver/Parser/ConditionalParameterParser.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public bool TryParse(string conditions, WorkflowInstance workflowInstance)
9090
}
9191
catch (Exception ex)
9292
{
93-
_logger.LogWarning("Failure attemping to parse condition", conditions, ex.Message);
93+
_logger.LogWarning($"Failure attemping to parse condition - {conditions}", ex);
9494
return false;
9595
}
9696
}
@@ -137,7 +137,7 @@ public string ResolveParameters(string conditions, string workflowInstanceId)
137137
{
138138
_logger.LogError(e.Message);
139139
ClearWorkflowParser();
140-
throw e;
140+
throw;
141141
}
142142
}
143143

@@ -323,6 +323,12 @@ private void ClearWorkflowParser()
323323
case "dob":
324324
resultStr = patientValue.PatientDob?.ToString("dd/MM/yyyy");
325325
break;
326+
case "age":
327+
resultStr = patientValue.PatientAge;
328+
break;
329+
case "hospital_id":
330+
resultStr = patientValue.PatientHospitalId;
331+
break;
326332
default:
327333
break;
328334
}

src/Contracts/Models/PatientDetails.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ public class PatientDetails
1616

1717
[JsonProperty(PropertyName = "patient_dob")]
1818
public DateTime? PatientDob { get; set; }
19+
20+
[JsonProperty(PropertyName = "patient_age")]
21+
public string PatientAge { get; set; }
22+
23+
[JsonProperty(PropertyName = "patient_hospital_id")]
24+
public string PatientHospitalId { get; set; }
1925
}
2026
}

src/Contracts/Models/TaskExecution.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ public class TaskExecution
2828
[JsonProperty(PropertyName = "task_id")]
2929
public string TaskId { get; set; }
3030

31+
[JsonProperty(PropertyName = "previous_task_id")]
32+
public string PreviousTaskId { get; set; }
33+
3134
[JsonProperty(PropertyName = "status")]
3235
public TaskExecutionStatus Status { get; set; }
3336

37+
[JsonProperty(PropertyName = "reason")]
38+
public FailureReason Reason { get; set; }
39+
3440
[JsonProperty(PropertyName = "input_artifacts")]
3541
public Dictionary<string, string> InputArtifacts { get; set; }
3642

src/Database/WorkflowInstanceRepository.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ public async Task<bool> UpdateWorkflowInstanceStatusAsync(string workflowInstanc
157157

158158
try
159159
{
160-
var result = await _workflowInstanceCollection.FindOneAndUpdateAsync(
160+
await _workflowInstanceCollection.FindOneAndUpdateAsync(
161161
i => i.Id == workflowInstanceId,
162162
Builders<WorkflowInstance>.Update.Set(w => w.Status, status));
163+
163164
return true;
164165
}
165166
catch (Exception e)
@@ -197,9 +198,10 @@ public async Task<bool> UpdateTasksAsync(string workflowInstanceId, List<TaskExe
197198

198199
try
199200
{
200-
var result = await _workflowInstanceCollection.FindOneAndUpdateAsync(
201+
await _workflowInstanceCollection.FindOneAndUpdateAsync(
201202
i => i.Id == workflowInstanceId,
202203
Builders<WorkflowInstance>.Update.Set(w => w.Tasks, tasks));
204+
203205
return true;
204206
}
205207
catch (Exception e)

src/Logging/Logging/Log.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ public static partial class Log
7676
[LoggerMessage(EventId = 22, Level = LogLevel.Error, Message = "The task execution status for task {taskId} cannot be updated from {oldStatus} to {newStatus}. Payload: {payloadId}")]
7777
public static partial void TaskStatusUpdateNotValid(this ILogger logger, string payloadId, string taskId, string oldStatus, string newStatus);
7878

79-
[LoggerMessage(EventId = 23, Level = LogLevel.Error, Message = "The task {taskId} metadata store update failed. Payload: {payloadId}")]
79+
[LoggerMessage(EventId = 23, Level = LogLevel.Error, Message = "The task {taskId} metadata store update failed. Payload: {payloadId} - Metadata: {metadata}")]
8080
public static partial void TaskMetaDataUpdateFailed(this ILogger logger, string payloadId, string taskId, Dictionary<string, object> metadata);
8181

8282
[LoggerMessage(EventId = 24, Level = LogLevel.Debug, Message = "No files to export for task {taskId} within workflow instance {workflowInstanceId}.")]
8383
public static partial void ExportFilesNotFound(this ILogger logger, string taskId, string workflowInstanceId);
8484

85-
[LoggerMessage(EventId = 24, Level = LogLevel.Error, Message = "Failed to get dicom tag {keyId} in bucket {bucketId}. Payload: {payloadId}")]
85+
[LoggerMessage(EventId = 25, Level = LogLevel.Error, Message = "Failed to get dicom tag {keyId} in bucket {bucketId}. Payload: {payloadId}")]
8686
public static partial void FailedToGetDicomTag(this ILogger logger, string payloadId, string keyId, string bucketId, Exception ex);
8787

88-
[LoggerMessage(EventId = 25, Level = LogLevel.Error, Message = "Failed to get patient details in bucket {bucketId}. Payload: {payloadId}")]
88+
[LoggerMessage(EventId = 26, Level = LogLevel.Error, Message = "Failed to get patient details in bucket {bucketId}. Payload: {payloadId}")]
8989
public static partial void FailedToGetPatientDetails(this ILogger logger, string payloadId, string bucketId, Exception ex);
9090

9191
public static void TaskComplete(this ILogger logger, TaskExecution task, WorkflowInstance workflowInstance, PatientDetails patientDetails, string correlationId, string taskStatus)
@@ -98,7 +98,7 @@ public static void TaskComplete(this ILogger logger, TaskExecution task, Workflo
9898

9999
var jsonString = JsonConvert.SerializeObject(objectLog);
100100

101-
logger.LogInformation(26, message: jsonString);
101+
logger.LogInformation(27, message: jsonString);
102102
}
103103
}
104104
}

src/Logging/Monai.Deploy.WorkflowManager.Logging.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ SPDX-License-Identifier: Apache License 2.0
88
<PropertyGroup>
99
<TargetFramework>net6.0</TargetFramework>
1010
<ImplicitUsings>enable</ImplicitUsings>
11-
<Nullable>enable</Nullable>
1211
</PropertyGroup>
1312

1413
<ItemGroup>

src/Monai.Deploy.WorkflowManager.Storage/Constants/DicomTagConstants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ public static class DicomTagConstants
1212
public const string PatientSexTag = "00100040";
1313

1414
public const string PatientDateOfBirthTag = "00100030";
15+
16+
public const string PatientAgeTag = "00101010";
17+
18+
public const string PatientHospitalIdTag = "00100021";
1519
}
1620
}

src/Monai.Deploy.WorkflowManager.Storage/Services/DicomService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public async Task<PatientDetails> GetPayloadPatientDetailsAsync(string payloadId
3434
{
3535
PatientName = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientNameTag),
3636
PatientId = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientIdTag),
37-
PatientSex = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientSexTag)
37+
PatientSex = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientSexTag),
38+
PatientAge = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientAgeTag),
39+
PatientHospitalId = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientHospitalIdTag)
3840
};
3941

4042
var dob = await GetFirstValueAsync(items, payloadId, bucketName, DicomTagConstants.PatientDateOfBirthTag);
@@ -187,6 +189,12 @@ public async Task<string> GetDcmJsonFileValueAtIndexAsync(int index,
187189
var jsonStr = Encoding.UTF8.GetString(((MemoryStream)stream).ToArray());
188190

189191
var dict = JsonConvert.DeserializeObject<Dictionary<string, DicomValue>>(jsonStr);
192+
193+
if (dict is null)
194+
{
195+
return string.Empty;
196+
}
197+
190198
dict.TryGetValue(keyId, out var value);
191199

192200
if (value is not null && value.Value is not null)

src/Monai.Deploy.WorkflowManager.Storage/Services/IDicomService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public interface IDicomService
1414
/// <param name="bucketName">Name of the bucket.</param>
1515
Task<IEnumerable<string>> GetDicomPathsForTaskAsync(string outputDirectory, string bucketName);
1616

17+
/// <summary>
18+
/// Gets patient details from the dicom metadata.
19+
/// </summary>
20+
/// <param name="payloadId">Payload id.</param>
21+
/// <param name="bucketName">Name of the bucket.</param>
1722
Task<PatientDetails> GetPayloadPatientDetailsAsync(string payloadId, string bucketName);
1823

1924
/// <summary>

src/TaskManager/Plug-ins/AideClinicalReview/AideClinicalReviewPlugin.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class AideClinicalReviewPlugin : TaskPluginBase, IAsyncDisposable
2222
private string _patientName;
2323
private string _patientSex;
2424
private string _patientDob;
25+
private string _patientAge;
26+
private string _patientHospitalId;
2527
private string _queueName;
2628
private string _workflowName;
2729

@@ -65,6 +67,16 @@ private void Initialize()
6567
_patientDob = Event.TaskPluginArguments[Keys.PatientDob];
6668
}
6769

70+
if (Event.TaskPluginArguments.ContainsKey(Keys.PatientAge))
71+
{
72+
_patientAge = Event.TaskPluginArguments[Keys.PatientAge];
73+
}
74+
75+
if (Event.TaskPluginArguments.ContainsKey(Keys.PatientHospitalId))
76+
{
77+
_patientHospitalId = Event.TaskPluginArguments[Keys.PatientHospitalId];
78+
}
79+
6880
if (Event.TaskPluginArguments.ContainsKey(Keys.QueueName))
6981
{
7082
_queueName = Event.TaskPluginArguments[Keys.QueueName];
@@ -123,7 +135,9 @@ private JsonMessage<ClinicalReviewRequestEvent> GenerateClinicalReviewRequestEve
123135
PatientId = _patientId,
124136
PatientSex = _patientSex,
125137
PatientName = _patientName,
126-
PatientDob = _patientDob
138+
PatientDob = _patientDob,
139+
PatientAge = _patientAge,
140+
PatientHospitalId = _patientHospitalId
127141
}
128142
}, TaskManagerApplicationId, Event.CorrelationId);
129143
}
@@ -139,7 +153,7 @@ private async Task SendClinicalReviewRequestEvent(JsonMessage<ClinicalReviewRequ
139153

140154
public override async Task<ExecutionStatus> GetStatus(string identity, CancellationToken cancellationToken = default)
141155
{
142-
return new ExecutionStatus { Status = TaskExecutionStatus.Succeeded };
156+
return await Task.Run(() => new ExecutionStatus { Status = TaskExecutionStatus.Succeeded });
143157
}
144158

145159
~AideClinicalReviewPlugin() => Dispose(disposing: false);

0 commit comments

Comments
 (0)