#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
API_DIR="${ROOT_DIR}/VigilCareClinicalAPI"

echo "=== Phase 27 verification ==="

echo "1. SIRS files removed"
test ! -f "${API_DIR}/Sepsis/SirsDetector.cs"
test ! -f "${API_DIR}/Sepsis/SirsEvaluator.cs"

echo "2. Sepsis refactor integration tests"
dotnet test "${ROOT_DIR}/VigilCareClinicalAPI.Tests" \
  --filter "FullyQualifiedName~SepsisRefactor" \
  --no-restore

echo "3. Full regression suite"
dotnet test "${ROOT_DIR}/VigilCareClinicalAPI.Tests" --no-restore

echo "4. Manual checks (requires running stack)"
BASE_URL="${BASE_URL:-http://localhost:5270}"
echo "   - Replay uti-sepsis-elderly-01 → expect QSOFA_SCREEN, not SEPSIS_WARNING"
echo "   - Ingest SOFA labs with delta ≥ 2 → expect SOFA_SEPSIS + bundle"
echo "   - GET ${BASE_URL}/api/v1/alerts?alertType=SEPSIS_WARNING → legacy rows still returned"

echo "Phase 27 verification complete."
