@@ -32,6 +32,8 @@ public static class FhirGenerationPipeline
3232{
3333 private const int MaxEntriesPerBundle = 500 ;
3434 private const int DefaultMaxConcurrentPatients = 4 ;
35+ private const int VerbosePatientLogHeadCount = 5 ;
36+ private const int VerbosePatientLogInterval = 250 ;
3537 private const string TemplateRunTag = "template-run" ;
3638 private static readonly Lazy < string > GeneratorDependencyFingerprint = new ( ComputeGeneratorDependencyFingerprint ) ;
3739
@@ -363,7 +365,8 @@ public static async Task<PipelineResult> GenerateAndUploadAsync(
363365 {
364366 var templateBundles = bundles . Select ( b => ReplaceRunTag ( b . Json , ids . RunTag , TemplateRunTag ) ) . ToList ( ) ;
365367 await generatedTemplateCache . StoreAsync ( templateCacheKey , new GeneratedPatientTemplate ( TemplateRunTag , templateBundles ) ) ;
366- output . WriteLine ( $ " [cache] Miss for { patientId } ; stored template key={ templateCacheKey } .") ;
368+ if ( ShouldEmitDetailedPatientLog ( patientIndex ) )
369+ output . WriteLine ( $ " [cache] Miss for { patientId } ; stored template key={ templateCacheKey } .") ;
367370 }
368371 }
369372 else
@@ -377,7 +380,8 @@ public static async Task<PipelineResult> GenerateAndUploadAsync(
377380 . ToList ( ) ;
378381
379382 entries = ParseBundleEntriesFromJson ( materialized ) ;
380- output . WriteLine ( $ " [cache] Hit for { patientId } ; reused template key={ templateCacheKey } .") ;
383+ if ( ShouldEmitDetailedPatientLog ( patientIndex ) )
384+ output . WriteLine ( $ " [cache] Hit for { patientId } ; reused template key={ templateCacheKey } .") ;
381385 }
382386
383387 var scenario = FhirGenerationCodes . GetScenarioById ( profile . ClinicalScenarioId )
@@ -433,8 +437,11 @@ public static async Task<PipelineResult> GenerateAndUploadAsync(
433437 return $ "{ shortName } ={ eligible } ";
434438 } ) ) ;
435439
436- output . WriteLine ( $ " Patient { patientId } : { entries . Count } entries [{ measureEligibilityLabel } ] | scenario={ scenario . PrimaryDxDisplay } | " +
437- $ "encounter={ encounterId } ({ encStart : yyyy-MM-dd} ? { encEnd : yyyy-MM-dd} )") ;
440+ if ( ShouldEmitDetailedPatientLog ( patientIndex ) )
441+ {
442+ output . WriteLine ( $ " Patient { patientId } : { entries . Count } entries [{ measureEligibilityLabel } ] | scenario={ scenario . PrimaryDxDisplay } | " +
443+ $ "encounter={ encounterId } ({ encStart : yyyy-MM-dd} ? { encEnd : yyyy-MM-dd} )") ;
444+ }
438445
439446 // Record patient in manifest builder
440447 manifestBuilder . AddPatient ( patientId , effectiveProfile ) ;
@@ -466,7 +473,7 @@ public static async Task<PipelineResult> GenerateAndUploadAsync(
466473 entries . Clear ( ) ;
467474
468475 var progress = $ "[{ patientId } ] ";
469- await fhirDataLoader . UploadBundlesSequentiallyAsync ( output , bundles , progress ) ;
476+ await fhirDataLoader . UploadBundlesSequentiallyAsync ( output , bundles , progress , logSuccessfulPosts : false ) ;
470477
471478 var bundleCount = bundles . Count ;
472479
@@ -620,7 +627,7 @@ public static async Task<PipelineResult> GenerateAndUploadAsync(
620627 {
621628 var bundles = ChunkEntries ( entries , patientId , 0 ) ;
622629 entries . Clear ( ) ;
623- var ok = await fhirDataLoader . UploadBundlesSequentiallyAsync ( output , bundles , $ "[imported:{ patientId } ] ") ;
630+ var ok = await fhirDataLoader . UploadBundlesSequentiallyAsync ( output , bundles , $ "[imported:{ patientId } ] ", logSuccessfulPosts : false ) ;
624631 if ( ! ok )
625632 throw new InvalidOperationException ( $ "Failed to upload imported bundle for patient '{ patientId } '.") ;
626633 bundleCount = bundles . Count ;
@@ -1075,4 +1082,13 @@ private static (DateTime Start, DateTime End) DeriveScheduledPatternInpatientWin
10751082
10761083 return result ;
10771084 }
1085+
1086+ private static bool ShouldEmitDetailedPatientLog ( int patientIndex )
1087+ {
1088+ if ( patientIndex < VerbosePatientLogHeadCount )
1089+ return true ;
1090+
1091+ var ordinal = patientIndex + 1 ;
1092+ return ordinal % VerbosePatientLogInterval == 0 ;
1093+ }
10781094}
0 commit comments