Skip to content
Merged
61 changes: 24 additions & 37 deletions Tests/BackendE2ETests/AdhocReportingSmokeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task ExecuteSmokeTest()
[Fact]
[Trait("Category", "AdHocSingleMeasureSmokeTest")]
public async Task SmokeTest_GenerateSingleMeasureAdHocReport()
{
{
TestConfig.AdhocReportingSmokeTestConfig.RemoveFacilityConfig = true;
AdHocReportApiRequests apiE2E = new AdHocReportApiRequests(output);
SubmissionZipReader submissionReportZip = new SubmissionZipReader(output);
Expand All @@ -106,46 +106,38 @@ public async Task SmokeTest_GenerateSingleMeasureAdHocReport()

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
output.WriteLine($"Stopwatch start {DateTime.UtcNow.ToString()}");

await measureLoader.LoadAsync();
apiE2E.Create_SingleMeasureAdHocTestFacility();
apiE2E.Create_SingleMeasureCensusConfiguration_AdHoc();
apiE2E.Create_SingleMeasureQueryDispatchConfig_AdHoc();
apiE2E.Create_SingleMeasure_FHIRQueryConfigByFacility_AdHoc();
apiE2E.Create_SingleMeasure_MontlhyQueryPlanByFacility_AdHoc();
apiE2E.Create_SingleMeasure_DischargeQueryPlanByFacility_AdHoc();
apiE2E.Create_SingleMeasureFHIRQueryListByFacility_AdHoc();
apiE2E.GenerateSingleMeasureAdHocReport_ACH();
output.WriteLine($"Stopwatch start {DateTime.UtcNow}");

await measureLoader.LoadAsync();
apiE2E.Create_SingleMeasureAdHocTestFacility();
apiE2E.Create_SingleMeasureCensusConfiguration_AdHoc();
apiE2E.Create_SingleMeasureQueryDispatchConfig_AdHoc();
apiE2E.Create_SingleMeasure_FHIRQueryConfigByFacility_AdHoc();
apiE2E.Create_SingleMeasure_MontlhyQueryPlanByFacility_AdHoc();
apiE2E.Create_SingleMeasure_DischargeQueryPlanByFacility_AdHoc();
apiE2E.Create_SingleMeasureFHIRQueryListByFacility_AdHoc();
apiE2E.GenerateSingleMeasureAdHocReport_ACH();

await submissionReportZip.WaitForSingleMeasureZipContentsAsync();
var failures = new List<string>();
try
{
await submissionReportZip.DownloadAndExtractSingleMeasureZipAsync(true);
TestConfig.ValidationHelper.TryRunValidation(submissionReportZip.SingleMeasureAdHocValidateFilesAppear, failures);
TestConfig.ValidationHelper.TryRunValidation(submissionReportZip.SingleMeasureAdHocValidateFilesDoNotAppear, failures);
TestConfig.ValidationHelper.TryRunValidation(() => submissionReportZip.ValidateSpecificPatientFileContents(3, 2000), failures);
TestConfig.ValidationHelper.TryRunValidation(submissionReportZip.ValidateSingleMeasureAdHocAggregateACHMFile, failures);
await submissionReportZip.WaitForSingleMeasureZipContentsAsync();
await submissionReportZip.DownloadAndExtractSingleMeasureZipAsync(save: true);

submissionReportZip.SingleMeasureAdHocValidateFilesAppear();
submissionReportZip.SingleMeasureAdHocValidateFilesDoNotAppear();
submissionReportZip.ValidateSingleMeasureAdHocAggregateACHMFile();
submissionReportZip.ValidateAllPatientsWithConfigurableSeverity();

apiE2E.GETSingleMeasureAdHocFacilityValidationResultsForReport();

output.WriteLine("[PASS] Smoke test completed with all verifications passing.");
}
finally
{
if (failures.Any())
{
output.WriteLine("🔴 ================= TEST RESULT SUMMARY =================🔴 ");
foreach (var fail in failures)
output.WriteLine(fail);
Xunit.Assert.Fail($"{failures.Count} verification(s) failed. See console output below.");
}
else
output.WriteLine("[PASS] Smoke test completed with all verifications passing.");

stopwatch.Stop();
output.WriteLine($"Stopwatch stop {DateTime.UtcNow.ToString()} - Total Time: {stopwatch.Elapsed}");
}
output.WriteLine($"Stopwatch stop {DateTime.UtcNow} - Total Time: {stopwatch.Elapsed}");
}
}

private async Task GenerateReport(string? measureId)
{
if (measureId == null)
Expand Down Expand Up @@ -181,15 +173,11 @@ private async Task GenerateReport(string? measureId)

var downloadedResources = await this.DownloadReport(reportId);

// Confirm that there is a file called "manifest.ndjson"
Assert.True(downloadedResources.ContainsKey("manifest.ndjson"), $"Expected report to include manifest.ndjson but it was not");
// TODO: Validate that it is correct

// Confirm that there is a file called "patient-{patientId}.ndjson"
foreach (var patientId in TestConfig.AdhocReportingSmokeTestConfig.PatientIds)
{
Assert.True(downloadedResources.ContainsKey($"patient-{patientId}.ndjson"), $"Expected report to include patient-{patientId}.ndjson but it was not");
// TODO: Validate that it is correct
}

output.WriteLine("Done generating and validating report.");
Expand Down Expand Up @@ -296,7 +284,6 @@ private async Task CreateNormalizationConfig()
output.WriteLine("Creating normalization config...");
var request = new RestRequest("normalization/Operations", Method.Post);

// Construct the request body with dynamic facilityId
var body = new
{
ResourceTypes = new[] { "Location" },
Expand Down
Loading
Loading