|
| 1 | +# Cohort360-QueryExecutor Local Helper Repository |
| 2 | + |
| 3 | +This directory contains a refactored and cleaner set of scripts for local development, integrated with the root project's existing Docker configuration. |
| 4 | + |
| 5 | +## Features |
| 6 | +- **Integrated**: Uses the root `Dockerfile` and `docker-compose.yml`. |
| 7 | +- **Colored Output**: Scripts use a utility logger for better readability. |
| 8 | +- **Flexible**: Supports both direct Server Mode (running JAR) and Docker Mode. |
| 9 | +- **Isolated**: Keeps local configurations and temporary files out of the main repository's git history. |
| 10 | + |
| 11 | +## Table of Contents |
| 12 | +1. [Prerequisites](#prerequisites) |
| 13 | +2. [Configuration](#configuration) |
| 14 | +3. [Setup](#setup) |
| 15 | +4. [Running Server Mode (Direct JAR)](#running-server-mode-direct-jar) |
| 16 | +5. [Running Docker Mode](#running-docker-mode) |
| 17 | +6. [API Usage](#api-usage) |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | +- **Java 11 or 17** (for Server Mode) |
| 23 | +- **Docker and Docker Compose** (for Docker Mode) |
| 24 | +- **Maven** (handled via `./mvnw` wrapper) |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Configuration |
| 29 | +Before running anything, initialize your local environment: |
| 30 | + |
| 31 | +```bash |
| 32 | +cp .local/env.example .local/.env |
| 33 | +``` |
| 34 | + |
| 35 | +Edit `.local/.env` to configure your local environment (FHIR URL, PostgreSQL, Solr, etc.). |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Setup |
| 40 | +To build the project and download required dependencies (like the PostgreSQL driver): |
| 41 | + |
| 42 | +```bash |
| 43 | +./.local/scripts/setup.sh |
| 44 | +``` |
| 45 | + |
| 46 | +This script: |
| 47 | +1. Builds the project using Maven. |
| 48 | +2. Downloads the PostgreSQL driver JAR. |
| 49 | +3. Automatically initializes `.local/.env` if it doesn't exist. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Running Server Mode (Direct JAR) |
| 54 | +Runs the application directly on your host machine. This is faster for iterative development. |
| 55 | + |
| 56 | +```bash |
| 57 | +./.local/scripts/run-server.sh |
| 58 | +``` |
| 59 | + |
| 60 | +This script: |
| 61 | +- Loads environment variables from `.local/.env`. |
| 62 | +- Generates `solr_auth.txt` for Solr authentication. |
| 63 | +- Applies the necessary JVM `--add-opens` flags (matching the production `entrypoint.sh`). |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Running Docker Mode |
| 68 | +Runs everything in containers. |
| 69 | + |
| 70 | +```bash |
| 71 | +./.local/docker/run-docker.sh |
| 72 | +``` |
| 73 | + |
| 74 | +This script: |
| 75 | +- Builds the `sjs:latest` image using the root `Dockerfile`. |
| 76 | +- Starts services using the root `docker-compose.yml` with local overrides (`.local/docker/docker-compose.local.yml`). |
| 77 | +- Includes a local PostgreSQL container for testing if needed. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## API Usage |
| 82 | + |
| 83 | +Once the server is running (port `8091` by default): |
| 84 | + |
| 85 | +### Example Query (Count) |
| 86 | +```bash |
| 87 | +curl -X POST http://localhost:8091/jobs -H "Content-Type: application/json" -d '{ |
| 88 | + "input": { |
| 89 | + "cohortDefinitionSyntax": "{\"sourcePopulation\":{\"caresiteCohortList\":[118]},\"_type\":\"request\",\"request\":{\"_type\":\"andGroup\",\"_id\":0,\"isInclusive\":true,\"criteria\":[{\"_type\":\"basicResource\",\"_id\":1,\"isInclusive\":true,\"resourceType\":\"Patient\",\"filterFhir\":\"active=true&gender=female\",\"criteria\":[],\"dateRangeList\":[],\"temporalConstraints\":[]}],\"dateRangeList\":[],\"temporalConstraints\":[]},\"temporalConstraints\":[]}", |
| 90 | + "mode": "count" |
| 91 | + } |
| 92 | +}' |
| 93 | +``` |
| 94 | + |
| 95 | +### Check Job Status |
| 96 | +```bash |
| 97 | +curl http://localhost:8091/jobs |
| 98 | +``` |
| 99 | + |
| 100 | +### Cancel Job |
| 101 | +```bash |
| 102 | +curl -X DELETE http://localhost:8091/jobs/<jobId> |
| 103 | +``` |
0 commit comments