---
title: "Getting Started with Achilles"
date: "`r Sys.Date()`"
output:
  pdf_document:
    number_sections: yes
    toc: yes
  html_document:
    number_sections: yes
    toc: yes
vignette: >
  %\VignetteIndexEntry{Getting Started with Achilles}
  %\VignetteEncoding{UTF-8}
  %\VignetteEngine{knitr::rmarkdown}
---

## Installation

1. Achilles currently supports version 5.3 and 5.4 of the OMOP CDM.
    (https://github.com/OHDSI/CommonDataModel).

1. This package makes use of rJava. Make sure that you have Java installed. If you don't have Java already installed on your computer (on most computers it already is installed), go to [java.com](https://java.com) to get the latest version. If you are having trouble with rJava, [this Stack Overflow post](https://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r) may assist you when you begin troubleshooting.

1. In R, use the following commands to install Achilles.

    ```r
    if (!require("remotes")) install.packages("remotes")
    
    # To install the master branch
    remotes::install_github("OHDSI/Achilles")
    
    # To install latest release (if master branch contains a bug for you)
    # remotes::install_github("OHDSI/Achilles@*release")  
    
    # To avoid Java 32 vs 64 issues 
    # remotes::install_github("OHDSI/Achilles", args="--no-multiarch")  
    ```

## Running Achilles
    
    The analyses are run in one SQL session and all intermediate results are written to temp tables before finally being combined into the final results tables. Temp tables are dropped once the package is finished running. 
    
    See the [DatabaseConnector](https://github.com/OHDSI/DatabaseConnector) package for details on settings the connection details for your database:
    
    ```r
    library(Achilles)
    connectionDetails <- createConnectionDetails(
      dbms="redshift", 
      server="server.com", 
      user="secret", 
      password='secret', 
      port="5439")
    ```
    
    ```r
  	Achilles::achilles(
  		cdmVersion = "5.4", 
  		connectionDetails = connectionDetails,
  		cdmDatabaseSchema = "yourCdmSchema",
  		resultsDatabaseSchema = "yourResultsSchema"
  	)
    ```
    The cdmDatabaseSchema parameter, and resultsDatabaseSchema parameter, are the fully qualified names of the schemas holding the CDM data, and targeted for result writing,  respectively. 

    The SQL platforms supported by [DatabaseConnector](https://github.com/OHDSI/DatabaseConnector) and [SqlRender](https://github.com/OHDSI/SqlRender) are the **only** ones supported here in Achilles as `dbms`.  

## Developers: How to Add or Modify Analyses

Please refer to the [README-developers.md file](README-developers.md).

## License

Achilles is licensed under Apache License 2.0
