Skip to content

Commit d3e507a

Browse files
authored
LNK-4635: Submission bundle getting not reportable patients as submitted with zero count (#1346)
* Skip submission of non-reportable patients * Deduplicate `OperationOutcome` in submission Use a single `OperationOutcome` (i.e., one with the same ID) across all measures of a multi-measure report. This prevents duplicates in the submission. * Prefer `error` severity over `fatal` Use `error` to indicate invalid content, rather than `fatal`, which could indicate "hard failure" of the validation process itself.
1 parent 7008f31 commit d3e507a

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

DotNet/Report/Domain/Queries/SubmissionEntryQueries.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,11 @@ public async Task<bool> PatientAllReadyForValidation(
246246
string patientId,
247247
CancellationToken cancellationToken = default)
248248
{
249-
return await (from entry in _context.PatientSubmissionEntries
250-
where entry.ReportScheduleId == reportScheduleId && entry.FacilityId == facilityId && entry.PatientId == patientId
251-
select entry.Status).AllAsync(s => s == PatientSubmissionStatus.ReadyForValidation || s == PatientSubmissionStatus.NotReportable);
249+
List<PatientSubmissionStatus> statuses = await (from entry in _context.PatientSubmissionEntries
250+
where entry.ReportScheduleId == reportScheduleId && entry.FacilityId == facilityId && entry.PatientId == patientId
251+
select entry.Status).ToListAsync(cancellationToken);
252+
return statuses.All(s => s == PatientSubmissionStatus.ReadyForValidation || s == PatientSubmissionStatus.NotReportable) &&
253+
statuses.Any(s => s == PatientSubmissionStatus.ReadyForValidation);
252254
}
253255

254256
public async Task<PagedConfigModel<ResourceSummary>> GetResourceSummary(string facilityId, string reportScheduleId, ResourceType? resourceType, int pageSize, int pageNumber,

DotNet/Report/KafkaProducers/ReportManifestProducer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private OperationOutcome CreateOperationOutcome(List<PatientSubmissionEntry> fai
235235
// Assuming PatientSubmissionEntry has a ValidationMessage property; adjust as per actual model
236236
operationOutcome.Issue.Add(new OperationOutcome.IssueComponent
237237
{
238-
Severity = OperationOutcome.IssueSeverity.Fatal,
238+
Severity = OperationOutcome.IssueSeverity.Error,
239239
Code = OperationOutcome.IssueType.Invalid,
240240
Diagnostics = $"Validation failed for patient {entry.PatientId}"
241241
});

DotNet/Report/Listeners/ValidationCompleteListener.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Text;
2020
using LantanaGroup.Link.Shared.Application.Services.Security;
2121
using Task = System.Threading.Tasks.Task;
22+
using Hl7.Fhir.Support;
2223

2324
namespace LantanaGroup.Link.Report.Listeners
2425
{
@@ -190,18 +191,12 @@ public async Task ProcessMessageAsync(ConsumeResult<string, ValidationCompleteVa
190191
throw new DeadLetterException($"No Patient Submission Entries were found for schedule ID {schedule.Id}, patient ID {value.PatientId}, in status {PatientSubmissionStatus.ValidationRequested}");
191192
}
192193

194+
var operationOutcome = GetOperationOutcome();
195+
193196
foreach (var entry in submissionEntries)
194197
{
195198
if (!value.IsValid)
196199
{
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 };
205200
await submissionEntryManager.AddResourceAsync(entry, operationOutcome, ResourceCategoryType.Patient, cancellationToken);
206201
}
207202

@@ -269,6 +264,21 @@ await submissionEntryManager.UpdateAsync(new PatientSubmissionEntryUpdateModel
269264
await _reportManifestProducer.Produce(schedule, correlationIdStr);
270265
}
271266

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+
272282
private static string GetFacilityIdFromHeader(Headers headers)
273283
{
274284
string facilityId = string.Empty;

0 commit comments

Comments
 (0)