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.
This commit is contained in:
2026-07-05 20:28:46 -05:00
parent 1a249c3caa
commit 3105150341
+24 -7
View File
@@ -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) {
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) {
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"
}