library(DatabaseConnector)
library(Achilles)

# Database connection details for the target OMOP database
# Assuming this runs in a Docker network where the host is 'target-omop'
connectionDetails <- createConnectionDetails(
  dbms = "postgresql",
  server = "target-omop/postgres",
  user = "postgres",
  password = "postgres",
  port = 5432
)

cdmDatabaseSchema <- "public"
resultsDatabaseSchema <- "public"
vocabDatabaseSchema <- "public"

# Run Achilles
print("Starting OHDSI Achilles Profiling...")
achilles(
  connectionDetails = connectionDetails,
  cdmDatabaseSchema = cdmDatabaseSchema,
  resultsDatabaseSchema = resultsDatabaseSchema,
  vocabDatabaseSchema = vocabDatabaseSchema,
  sourceName = "Medikal OMOP Database",
  cdmVersion = "5.4"
)

print("Achilles Profiling Completed Successfully!")
