Skip to content

Commit 30d6951

Browse files
authored
Merge branch 'dev' into clinical-reasoning-dep-update
2 parents 60b0b2e + 18ffff3 commit 30d6951

63 files changed

Lines changed: 295 additions & 181 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
# CS8603: Possible null reference return.
44
dotnet_diagnostic.CS8603.severity = silent
5+
6+
# CA2254: Template should be a static expression
7+
dotnet_diagnostic.CA2254.severity = error
8+
dotnet_diagnostic.CA2253.severity = error

DotNet/Admin.BFF/Application/Commands/Integration/KafkaConsumerManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public async Task StopAllConsumers(string reportTrackingId)
209209

210210
if (consumer.Item1.Name.Contains(reportTrackingId))
211211
{
212-
_logger.LogInformation($"Type of Item2: {consumer.Item2.GetType()}");
212+
_logger.LogInformation("Type of Item2: {ItemType}", consumer.Item2.GetType());
213213
if (consumer.Item2 != null && consumer.Item2 is CancellationTokenSource cts && !cts.IsCancellationRequested)
214214
{
215215
try
@@ -218,7 +218,7 @@ public async Task StopAllConsumers(string reportTrackingId)
218218
}
219219
catch (Exception ex)
220220
{
221-
_logger.LogInformation($"Error during cancellation: {ex.Message}");
221+
_logger.LogError(ex, "Error during cancellation");
222222

223223
}
224224
}

DotNet/Census/Application/Jobs/SchedulePatientListRetrieval.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task Execute(IJobExecutionContext context)
2222
{
2323
//get facility
2424
var facility = (CensusConfigEntity)context.JobDetail.JobDataMap.Get(CensusConstants.Scheduler.Facility);
25-
_logger.LogInformation($"Triggering {KafkaTopic.PatientCensusScheduled.ToString()} for facility: {facility.FacilityID} ");
25+
_logger.LogInformation("Triggering {Topic} for facility: {FacilityId}", KafkaTopic.PatientCensusScheduled.ToString(), facility.FacilityID);
2626

2727
await _kafkaProducer.ProduceAsync(KafkaTopic.PatientCensusScheduled.ToString(), new Message<string, Null>
2828
{

DotNet/Census/Application/Services/ScheduleService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public override async Task StartAsync(CancellationToken cancellationToken)
5959
}
6060
catch (Exception ex)
6161
{
62-
_logger.LogError(ex, "Something went wrong scheduling a Census job for facility: {1}.", facility.FacilityID);
62+
_logger.LogError(ex, "Something went wrong scheduling a Census job for facility: {FacilityId}.", facility.FacilityID);
6363
}
6464
}
6565

@@ -68,7 +68,7 @@ public override async Task StartAsync(CancellationToken cancellationToken)
6868
}
6969
catch (Exception ex)
7070
{
71-
_logger.LogError(ex, "Something went wrong scheduling a Census job: {1}.", ex.Message);
71+
_logger.LogError(ex, "Something went wrong scheduling a Census job: {Message}.", ex.Message);
7272
}
7373
}
7474

DotNet/Census/Listeners/CensusListener.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ await kafkaConsumer.ConsumeWithInstrumentation((Func<ConsumeResult<string, Patie
147147
}
148148
catch (Exception ex)
149149
{
150-
_logger.LogError(ex, $"Failed to process Patient Event.");
150+
_logger.LogError(ex, "Failed to process Patient Event");
151151

152152
_nonTransientExceptionHandler.HandleException(rawmessage, ex, rawmessage.Message.Key);
153153

@@ -158,7 +158,7 @@ await kafkaConsumer.ConsumeWithInstrumentation((Func<ConsumeResult<string, Patie
158158
}
159159
catch (ConsumeException ex)
160160
{
161-
_logger.LogError(ex, "Error consuming message for topics: [{1}] at {2}", string.Join(", ", kafkaConsumer.Subscription), DateTime.UtcNow);
161+
_logger.LogError(ex, "Error consuming message for topics: [{Topics}] at {Timestamp}", string.Join(", ", kafkaConsumer.Subscription), DateTime.UtcNow);
162162

163163
if (ex.Error.Code == ErrorCode.UnknownTopicOrPart)
164164
{
@@ -174,14 +174,14 @@ await kafkaConsumer.ConsumeWithInstrumentation((Func<ConsumeResult<string, Patie
174174
}
175175
catch (Exception ex)
176176
{
177-
_logger.LogError(ex, "Error consuming message for topics: [{1}] at {2}", string.Join(", ", kafkaConsumer.Subscription), DateTime.UtcNow);
177+
_logger.LogError(ex, "Error consuming message for topics: [{Topics}] at {Timestamp}", string.Join(", ", kafkaConsumer.Subscription), DateTime.UtcNow);
178178
kafkaConsumer.Commit();
179179
}
180180
}
181181
}
182182
catch (OperationCanceledException ex)
183183
{
184-
_logger.LogInformation($"Stopped census consumer for topic '{KafkaTopic.PatientIDsAcquired}' at {DateTime.UtcNow}");
184+
_logger.LogInformation("Stopped census consumer for topic '{Topic}' at {DateTime}", KafkaTopic.PatientIDsAcquired, DateTime.UtcNow);
185185
kafkaConsumer.Close();
186186
kafkaConsumer.Dispose();
187187
}

DotNet/DataAcquisition.AcquisitionWorker/Listeners/ReadyToAcquireListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected override async Task ExecuteListenerAsync(ConsumeResult<long, ReadyToAc
8181
}
8282
catch (Exception ex)
8383
{
84-
_logger.LogError(ex, $"PatientDataService.ExecuteLogRequest: [{DateTime.UtcNow}] Error encountered");
84+
_logger.LogError(ex, "PatientDataService.ExecuteLogRequest: [{Time}] Error encountered", DateTime.UtcNow);
8585

8686
if (log != null)
8787
{

DotNet/DataAcquisition.Domain/Application/Services/PatientCensusService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public async Task<PatientIDsAcquired> Get(string facilityId, CancellationToken c
117117
}
118118
catch (Exception ex)
119119
{
120-
_logger.LogError(ex, "Error retrieving patient list id {1} for facility {2} with base url of {3}.", listId.Sanitize(), facilityConfig.FacilityId.Sanitize(), facilityConfig.FhirBaseServerUrl.Sanitize());
120+
_logger.LogError(ex, "Error retrieving patient list id {ListId} for facility {FacilityId} with base url of {BaseUrl}.", listId.Sanitize(), facilityConfig.FacilityId.Sanitize(), facilityConfig.FhirBaseServerUrl.Sanitize());
121121
throw new FhirApiFetchFailureException($"Error retrieving patient list id {listId} for facility {facilityConfig.FacilityId}.", ex);
122122
}
123123
}

DotNet/DataAcquisition.Domain/Application/Services/PatientDataService.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,12 @@ public async Task CreateLogEntries(GetPatientDataRequest request, CancellationTo
175175
}
176176
catch (MissingFacilityConfigurationException ex)
177177
{
178-
var message =
179-
$"Error retrieving configuration for facility {request.FacilityId}\n{ex.Message}\n{ex.InnerException}";
180-
_logger.LogError(message);
178+
_logger.LogError(ex, "Error retrieving configuration for facility {FacilityId}", request.FacilityId);
181179
throw;
182180
}
183181
catch (Exception ex)
184182
{
185-
var message =
186-
$"Error retrieving configuration for facility {request.FacilityId}\n{ex.Message}\n{ex.InnerException}";
187-
_logger.LogError(message);
183+
_logger.LogError(ex, "Error retrieving configuration for facility {FacilityId}", request.FacilityId);
188184
throw;
189185
}
190186

@@ -255,7 +251,7 @@ await _dataAcquisitionLogManager.CreateAsync(
255251
}
256252
catch (Exception ex)
257253
{
258-
_logger.LogError(ex, "Error creating log entry for facility {facilityId} and patient {patientId}", request.FacilityId.Sanitize(), dataAcqRequested.PatientId);
254+
_logger.LogError(ex, "Error creating log entry for facility {FacilityId} and patient {PatientId}", request.FacilityId.Sanitize(), dataAcqRequested.PatientId);
259255

260256
throw;
261257
}
@@ -276,9 +272,7 @@ await _queryListProcessor.Process(
276272
}
277273
catch (Exception ex)
278274
{
279-
var message =
280-
$"Error retrieving data from EHR for facility: {request.FacilityId}\n{ex.Message}\n{ex.InnerException}";
281-
_logger.LogError(message);
275+
_logger.LogError(ex, "Error retrieving data from EHR for facility: {FacilityId}", request.FacilityId);
282276
throw;
283277
}
284278

@@ -330,7 +324,7 @@ public async Task ExecuteLogRequest(AcquisitionRequest request, CancellationToke
330324
}
331325
catch (Exception ex)
332326
{
333-
_logger.LogError(ex, "Error setting Activity.Current for log ID {logId} with TraceId {traceId}", log.Id, log.TraceId.Sanitize());
327+
_logger.LogError(ex, "Error setting Activity.Current for log ID {LogId} with TraceId {TraceId}", log.Id, log.TraceId.Sanitize());
334328
if (!string.IsNullOrWhiteSpace(Activity.Current?.Id))
335329
{
336330
activity.SetParentId(Activity.Current.Id);
@@ -451,7 +445,7 @@ public async Task ExecuteLogRequest(AcquisitionRequest request, CancellationToke
451445
}
452446
catch (Exception ex)
453447
{
454-
_logger.LogError(ex, $"PatientDataService.ExecuteLogRequest: [{DateTime.UtcNow}] Error encountered");
448+
_logger.LogError(ex, "PatientDataService.ExecuteLogRequest error");
455449

456450
log.Notes ??= new List<string>();
457451

DotNet/DataAcquisition/Controllers/QueryConfigController.cs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ public async Task<ActionResult<FhirQueryConfiguration>> GetFhirConfiguration(str
6666
}
6767
catch (BadRequestException ex)
6868
{
69-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
69+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
7070
return Problem(title: "Bad Request", detail: ex.Message, statusCode: (int)HttpStatusCode.BadRequest);
7171
}
7272
catch (NotFoundException ex)
7373
{
74-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
74+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
7575
return Problem(title: "Not Found", detail: ex.Message, statusCode: (int)HttpStatusCode.NotFound);
7676
}
7777
catch (Exception ex)
@@ -135,30 +135,28 @@ public async Task<ActionResult<FhirQueryConfiguration>> CreateFhirConfiguration(
135135
}
136136
catch (EntityAlreadyExistsException ex)
137137
{
138-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
138+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
139139
return Problem(title: "Entity Already Exists", detail: ex.Message, statusCode: (int)HttpStatusCode.Conflict);
140140
}
141141
catch (BadRequestException ex)
142142
{
143-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
143+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
144144
return Problem(title: "Bad Request", detail: ex.Message, statusCode: (int)HttpStatusCode.BadRequest);
145145
}
146146
catch (NotFoundException ex)
147147
{
148-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
148+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
149149
return Problem(title: "Not Found", detail: ex.Message, statusCode: (int)HttpStatusCode.NotFound);
150150
}
151151
catch (MissingFacilityConfigurationException ex)
152152
{
153-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
153+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
154154
return Problem(title: "Not Found", detail: ex.Message, statusCode: (int)HttpStatusCode.NotFound);
155155
}
156156
catch (Exception ex)
157157
{
158-
string message =
159-
$"An exception occurred while attempting to get a FhirQueryConfiguration with a facility id of {facilityId}. " + Environment.NewLine + ex.Message;
160-
_logger.LogError(new EventId(LoggingIds.InsertItem, "CreateFhirConfiguration"), ex, message, facilityId);
161-
return Problem(title: "Internal Server Error", detail: message, statusCode: (int)HttpStatusCode.InternalServerError);
158+
_logger.LogError(new EventId(LoggingIds.InsertItem, "CreateFhirConfiguration"), ex, "An exception occurred while attempting to get a FhirQueryConfiguration with a facility id of {FacilityId}.\n{ExceptionMessage}", facilityId, ex.Message);
159+
return Problem(title: "Internal Server Error", detail: ex.Message, statusCode: (int)HttpStatusCode.InternalServerError);
162160
}
163161
}
164162

@@ -224,25 +222,23 @@ public async Task<ActionResult> UpdateFhirConfiguration(FhirQueryConfiguration?
224222
}
225223
catch (MissingFacilityConfigurationException ex)
226224
{
227-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
225+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
228226
return BadRequest(ex.Message);
229227
}
230228
catch (BadRequestException ex)
231229
{
232-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
230+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
233231
return Problem(title: "Bad Request", detail: ex.Message, statusCode: (int)HttpStatusCode.BadRequest);
234232
}
235233
catch (NotFoundException ex)
236234
{
237-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
235+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
238236
return Problem(title: "Not Found", detail: ex.Message, statusCode: (int)HttpStatusCode.NotFound);
239237
}
240238
catch (Exception ex)
241239
{
242-
string message =
243-
$"An exception occurred while attempting to update a fhir query configuration with a facility id of {facilityId}. " + Environment.NewLine + ex.Message;
244-
_logger.LogError(new EventId(LoggingIds.UpdateItem, "UpdateFhirConfiguration"), ex, message, facilityId);
245-
return Problem(title: "Internal Server Error", detail: message, statusCode: (int)HttpStatusCode.InternalServerError);
240+
_logger.LogError(new EventId(LoggingIds.UpdateItem, "UpdateFhirConfiguration"), ex, "An exception occurred while attempting to update a fhir query configuration with a facility id of {FacilityId}.\n{ExceptionMessage}", facilityId, ex.Message);
241+
return Problem(title: "Internal Server Error", detail: ex.Message, statusCode: (int)HttpStatusCode.InternalServerError);
246242
}
247243
}
248244

@@ -278,20 +274,18 @@ public async Task<ActionResult> DeleteFhirConfiguration(string facilityId, Cance
278274
}
279275
catch (BadRequestException ex)
280276
{
281-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
277+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
282278
return Problem(title: "Bad Request", detail: ex.Message, statusCode: (int)HttpStatusCode.BadRequest);
283279
}
284280
catch (NotFoundException ex)
285281
{
286-
_logger.LogWarning(ex.Message + Environment.NewLine + ex.StackTrace);
282+
_logger.LogWarning("Exception occurred: {ExceptionMessage}\n{StackTrace}", ex.Message, ex.StackTrace);
287283
return Problem(title: "Not Found", detail: ex.Message, statusCode: (int)HttpStatusCode.NotFound);
288284
}
289285
catch (Exception ex)
290286
{
291-
string message =
292-
$"An exception occurred while attempting to delete a fhir query configuration with a facility id of {facilityId}. " + Environment.NewLine + ex.Message;
293-
_logger.LogError(new EventId(LoggingIds.DeleteItem, "DeleteFhirConfiguration"), ex, message, facilityId);
294-
return Problem(title: "Internal Server Error", detail: message, statusCode: (int)HttpStatusCode.InternalServerError);
287+
_logger.LogError(new EventId(LoggingIds.DeleteItem, "DeleteFhirConfiguration"), ex, "An exception occurred while attempting to delete a fhir query configuration with a facility id of {FacilityId}.\n{ExceptionMessage}", facilityId, ex.Message);
288+
return Problem(title: "Internal Server Error", detail: ex.Message, statusCode: (int)HttpStatusCode.InternalServerError);
295289
}
296290
}
297291
}

DotNet/Normalization/Listeners/ResourceAcquiredListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ await kafkaConsumer.ConsumeWithInstrumentation(async (result, CancellationToken)
204204
}
205205
else
206206
{
207-
_logger.LogWarning($@"Normalization Operation Failed ({messageMetaData.facilityId}, {messageMetaData.correlationId}, {operation.OperationType}): {operationResult?.ErrorMessage ?? "No Operation Result Error Message"}");
207+
_logger.LogWarning("Normalization Operation Failed ({FacilityId}, {CorrelationId}, {OperationType}): {ErrorMessage}", messageMetaData.facilityId, messageMetaData.correlationId, operation.OperationType, operationResult?.ErrorMessage ?? "No Operation Result Error Message");
208208
}
209209
}
210210
}

0 commit comments

Comments
 (0)