@echo off
setlocal EnableExtensions
cd /d "%~dp0\.."
set "ROOT=%CD%"
set "PY=%ROOT%\Runtime\Python\python.exe"
if not exist "%PY%" for /r "%ROOT%\Runtime\Python" %%F in (python.exe) do if not defined PYFOUND set "PYFOUND=%%~fF"
if defined PYFOUND set "PY=%PYFOUND%"
if not exist "%PY%" set "PY=python.exe"
set "PYTHONPATH=%ROOT%\ClinicalReasoningDatabase;%ROOT%\ClinicalReasoningDatabase\research"
echo Testing Python...
"%PY%" --version
echo Testing package import...
"%PY%" -c "from research.research_engine import ResearchEngine; from pathlib import Path; e=ResearchEngine(Path(r'%ROOT%\ClinicalReasoningDatabase')); print('ResearchEngine OK'); print('Cache:',e.cache_dir); print('Exports:',e.export_dir)"
echo Testing server module import...
"%PY%" -c "import research.server; print('Server module OK')"
pause
