From 3105150341a3a6493e6325a270953421463a6492 Mon Sep 17 00:00:00 2001 From: Brad Lance Date: Sun, 5 Jul 2026 20:28:46 -0500 Subject: [PATCH] Require each remote path only when files of that kind exist pdf_path being null blocked ALL insurance uploads even when the date folder had no PT STMT files at all - CAMBS's first partners send only TIFs, so tiff_path is filled and pdf_path intentionally stays null. Validation is now per-category: connection fields (host/username/password) are needed whenever anything would upload, tiff_path only when non-PT-STMT files exist, pdf_path only when PT STMT files exist. If some files upload but others were ignored via a null path, the date folder is NOT archived (so ignored files are never buried in the archive unsent) with an explicit NOT-archived notice. --- engine.ps1 | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/engine.ps1 b/engine.ps1 index 853d4c1..c8f707c 100644 --- a/engine.ps1 +++ b/engine.ps1 @@ -300,31 +300,48 @@ foreach ($practice in $practices) { $pdfPath = Expand-Path $config.ftps.pdf_path $pracName $insResult = @{ Ok = 0; Fail = 0 } - $missing = Get-MissingFields $config.ftps "ftps" @("host", "username", "password", "tiff_path", "pdf_path") - if (($insFiles.Count -gt 0 -or $ptStmts.Count -gt 0) -and $missing.Count -gt 0) { - Write-Host " Insurance upload not configured ($($missing -join ', ') is null/blank) - $($insFiles.Count + $ptStmts.Count) file(s) ignored, left in place." -ForegroundColor Yellow - Write-Info "IGNORE entity=$entityName practice=$pracName reason=unconfigured fields=$($missing -join ',')" + $connMissing = Get-MissingFields $config.ftps "ftps" @("host", "username", "password") + if (($insFiles.Count -gt 0 -or $ptStmts.Count -gt 0) -and $connMissing.Count -gt 0) { + Write-Host " FTPS not configured ($($connMissing -join ', ') is null/blank) - $($insFiles.Count + $ptStmts.Count) file(s) ignored, left in place." -ForegroundColor Yellow + Write-Info "IGNORE entity=$entityName practice=$pracName reason=unconfigured fields=$($connMissing -join ',')" } else { + $ignored = 0 + if ($insFiles.Count -gt 0) { - Write-Host " Insurance ($($insFiles.Count)) -> $insPath" -ForegroundColor White - $r = Invoke-FTPSUpload $config.ftps $insFiles $insPath $entityName $pracName - $insResult.Ok += $r.Ok; $insResult.Fail += $r.Fail + if ([string]::IsNullOrWhiteSpace([string]$config.ftps.tiff_path)) { + Write-Host " ftps.tiff_path is null/blank - $($insFiles.Count) insurance file(s) ignored, left in place." -ForegroundColor Yellow + Write-Info "IGNORE entity=$entityName practice=$pracName reason=tiff_path null count=$($insFiles.Count)" + $ignored += $insFiles.Count + } else { + Write-Host " Insurance ($($insFiles.Count)) -> $insPath" -ForegroundColor White + $r = Invoke-FTPSUpload $config.ftps $insFiles $insPath $entityName $pracName + $insResult.Ok += $r.Ok; $insResult.Fail += $r.Fail + } } if ($ptStmts.Count -gt 0) { - Write-Host " PT STMT ($($ptStmts.Count)) -> $pdfPath" -ForegroundColor White - $r = Invoke-FTPSUpload $config.ftps $ptStmts $pdfPath $entityName $pracName - $insResult.Ok += $r.Ok; $insResult.Fail += $r.Fail + if ([string]::IsNullOrWhiteSpace([string]$config.ftps.pdf_path)) { + Write-Host " ftps.pdf_path is null/blank - $($ptStmts.Count) PT STMT file(s) ignored, left in place." -ForegroundColor Yellow + Write-Info "IGNORE entity=$entityName practice=$pracName reason=pdf_path null count=$($ptStmts.Count)" + $ignored += $ptStmts.Count + } else { + Write-Host " PT STMT ($($ptStmts.Count)) -> $pdfPath" -ForegroundColor White + $r = Invoke-FTPSUpload $config.ftps $ptStmts $pdfPath $entityName $pracName + $insResult.Ok += $r.Ok; $insResult.Fail += $r.Fail + } } - $totalUploaded = $insFiles.Count + $ptStmts.Count - if ($insResult.Fail -eq 0 -and $totalUploaded -gt 0) { + $totalUploaded = $insFiles.Count + $ptStmts.Count - $ignored + if ($insResult.Fail -eq 0 -and $totalUploaded -gt 0 -and $ignored -eq 0) { $archive = Get-ArchiveDir $practice.FullName "Archive sent to FTP" Move-Item -Path $dateDir -Destination (Join-Path $archive $today) -Force Write-Host " $today\ archived." -ForegroundColor Green Write-Info "ARCHIVE entity=$entityName practice=$pracName folder=$today" } elseif ($insResult.Fail -gt 0) { Write-Host " $($insResult.Fail) failed - $today\ left for retry." -ForegroundColor Yellow - } elseif ($totalUploaded -eq 0) { + } elseif ($totalUploaded -gt 0 -and $ignored -gt 0) { + Write-Host " $today\ NOT archived - $ignored file(s) were ignored (unconfigured path)." -ForegroundColor Yellow + Write-Info "NOARCHIVE entity=$entityName practice=$pracName reason=$ignored ignored files" + } elseif ($insFiles.Count + $ptStmts.Count -eq 0) { Write-Host " No .$insuranceExt files in $today\." -ForegroundColor Gray Write-Info "SKIP entity=$entityName practice=$pracName reason=no .$insuranceExt files in date folder" }