|
19 | 19 | using System.Text; |
20 | 20 | using LantanaGroup.Link.Shared.Application.Services.Security; |
21 | 21 | using Task = System.Threading.Tasks.Task; |
| 22 | +using Hl7.Fhir.Support; |
22 | 23 |
|
23 | 24 | namespace LantanaGroup.Link.Report.Listeners |
24 | 25 | { |
@@ -190,18 +191,12 @@ public async Task ProcessMessageAsync(ConsumeResult<string, ValidationCompleteVa |
190 | 191 | throw new DeadLetterException($"No Patient Submission Entries were found for schedule ID {schedule.Id}, patient ID {value.PatientId}, in status {PatientSubmissionStatus.ValidationRequested}"); |
191 | 192 | } |
192 | 193 |
|
| 194 | + var operationOutcome = GetOperationOutcome(); |
| 195 | + |
193 | 196 | foreach (var entry in submissionEntries) |
194 | 197 | { |
195 | 198 | if (!value.IsValid) |
196 | 199 | { |
197 | | - var operationOutcome = new OperationOutcome(); |
198 | | - var issue = new OperationOutcome.IssueComponent |
199 | | - { |
200 | | - Severity = OperationOutcome.IssueSeverity.Fatal, |
201 | | - Code = OperationOutcome.IssueType.Invalid, |
202 | | - Diagnostics = "Patient has failed Validation" |
203 | | - }; |
204 | | - operationOutcome.Issue = new List<OperationOutcome.IssueComponent> { issue }; |
205 | 200 | await submissionEntryManager.AddResourceAsync(entry, operationOutcome, ResourceCategoryType.Patient, cancellationToken); |
206 | 201 | } |
207 | 202 |
|
@@ -269,6 +264,21 @@ await submissionEntryManager.UpdateAsync(new PatientSubmissionEntryUpdateModel |
269 | 264 | await _reportManifestProducer.Produce(schedule, correlationIdStr); |
270 | 265 | } |
271 | 266 |
|
| 267 | + private static OperationOutcome GetOperationOutcome() |
| 268 | + { |
| 269 | + OperationOutcome operationOutcome = new() |
| 270 | + { |
| 271 | + Id = Guid.NewGuid().ToString() |
| 272 | + }; |
| 273 | + operationOutcome.AddIssue(new OperationOutcome.IssueComponent |
| 274 | + { |
| 275 | + Severity = OperationOutcome.IssueSeverity.Error, |
| 276 | + Code = OperationOutcome.IssueType.Invalid, |
| 277 | + Diagnostics = "Patient has failed Validation" |
| 278 | + }); |
| 279 | + return operationOutcome; |
| 280 | + } |
| 281 | + |
272 | 282 | private static string GetFacilityIdFromHeader(Headers headers) |
273 | 283 | { |
274 | 284 | string facilityId = string.Empty; |
|
0 commit comments