Skip to content

Commit dafcfd0

Browse files
committed
cleaning log output
1 parent 659600e commit dafcfd0

1 file changed

Lines changed: 55 additions & 8 deletions

File tree

Tests/BackendE2ETests/ApiRequests/SubmissionZipReader.cs

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ private void ValidateSinglePatientFile(
445445
var bundleIdsByType = BundleIdsByType(lines);
446446

447447
var (evalCounts, evalIdsByType, crossTypeRefs) =
448-
ParseEvaluatedResource(lines, bundleIdsByType);
448+
ParseEvaluatedResource(lines, bundleIdsByType, excludedTypes);
449+
var rawEvalTypes = GetEvaluatedTypesRaw(lines);
450+
449451

450452
foreach (var kv in expectedBundleCounts)
451453
{
@@ -510,8 +512,12 @@ private void ValidateSinglePatientFile(
510512
}
511513

512514
var expectedEvalKeys = new HashSet<string>(expectedEvalCounts.Keys, StringComparer.OrdinalIgnoreCase);
515+
513516
foreach (var extraKey in evalCounts.Keys.Where(k => !expectedEvalKeys.Contains(k)))
514517
{
518+
if (excludedTypes.Contains(extraKey))
519+
continue;
520+
515521
ReportIssue(
516522
fileName,
517523
resourceType: extraKey,
@@ -523,7 +529,7 @@ private void ValidateSinglePatientFile(
523529
foreach (var exType in excludedTypes)
524530
{
525531
var bundleHas = bundleCounts.TryGetValue(exType, out var c) && c > 0;
526-
var evalHas = evalCounts.TryGetValue(exType, out var c2) && c2 > 0;
532+
var evalHas = rawEvalTypes.Contains(exType);
527533

528534
if (!bundleHas)
529535
{
@@ -690,17 +696,19 @@ private static Dictionary<string, HashSet<string>> BundleIdsByType(IEnumerable<J
690696
}
691697

692698
private static (Dictionary<string, int> counts,
693-
Dictionary<string, HashSet<string>> idsByType,
694-
List<(string EvaluatedType, string Id, string ActualType)> crossType)
695-
ParseEvaluatedResource(
696-
IEnumerable<JsonElement> lines,
697-
Dictionary<string, HashSet<string>> bundleIdsByType)
699+
Dictionary<string, HashSet<string>> idsByType,
700+
List<(string EvaluatedType, string Id, string ActualType)> crossType)
701+
ParseEvaluatedResource(
702+
IEnumerable<JsonElement> lines,
703+
Dictionary<string, HashSet<string>> bundleIdsByType,
704+
ISet<string> excludedTypes)
698705
{
699706
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
700707
var idsByType = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
701708
var crossType = new List<(string EvaluatedType, string Id, string ActualType)>();
702709
var total = 0;
703710

711+
// Build id -> type index from bundle so we can detect cross-type refs
704712
var idToType = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
705713
foreach (var kv in bundleIdsByType)
706714
{
@@ -737,6 +745,11 @@ private static (Dictionary<string, int> counts,
737745
if (type.Length == 0 || id.Length == 0)
738746
continue;
739747

748+
// ✅ Option A: exclude types do NOT contribute to counts/ids/total
749+
if (excludedTypes != null && excludedTypes.Contains(type))
750+
continue;
751+
752+
// Only non-excluded types count toward totals
740753
total++;
741754
counts[type] = counts.TryGetValue(type, out var n) ? n + 1 : 1;
742755

@@ -758,7 +771,8 @@ private static (Dictionary<string, int> counts,
758771
counts["__TOTAL__"] = total;
759772
return (counts, idsByType, crossType);
760773
}
761-
774+
775+
762776
public void ValidateSingleMeasureAdHocAggregateACHMFile()
763777
{
764778
string fileName = "manifest.ndjson";
@@ -1081,6 +1095,39 @@ private static string Truncate(string? value, int maxLength)
10811095
// leave space for "..."
10821096
return value.Substring(0, maxLength - 3) + "...";
10831097
}
1098+
private static HashSet<string> GetEvaluatedTypesRaw(IEnumerable<JsonElement> lines)
1099+
{
1100+
var types = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
1101+
1102+
foreach (var el in lines)
1103+
{
1104+
if (!el.TryGetProperty("resourceType", out var rt) || rt.ValueKind != JsonValueKind.String)
1105+
continue;
1106+
1107+
if (!string.Equals(rt.GetString(), "MeasureReport", StringComparison.OrdinalIgnoreCase))
1108+
continue;
1109+
1110+
if (!el.TryGetProperty("evaluatedResource", out var eval) || eval.ValueKind != JsonValueKind.Array)
1111+
continue;
1112+
1113+
foreach (var item in eval.EnumerateArray())
1114+
{
1115+
if (!item.TryGetProperty("reference", out var r) || r.ValueKind != JsonValueKind.String)
1116+
continue;
1117+
1118+
var reference = r.GetString() ?? string.Empty;
1119+
var slash = reference.IndexOf('/');
1120+
if (slash <= 0)
1121+
continue;
1122+
1123+
var type = reference.Substring(0, slash).Trim();
1124+
if (!string.IsNullOrWhiteSpace(type))
1125+
types.Add(type);
1126+
}
1127+
}
1128+
1129+
return types;
1130+
}
10841131

10851132
private void ReportIssue(
10861133
string fileName,

0 commit comments

Comments
 (0)