Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker/Development Containers support #1406

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Synthea - synthetic patient data generator",
"build": {
"context": "..",
"dockerfile": "../Dockerfile",
"args": { "BASE_IMAGE": "mcr.microsoft.com/devcontainers/base:ubuntu", "USER": "vscode" }
}
}
54 changes: 54 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/.devcontainer
/.hermit

**/.DS_Store
.classpath
.project
.settings
.gradle
/nbproject/**
/build/**

/.gradle/
/bin/main
/bin/test

/failed_exports/
/output/
/out/

**/*.log

# don't commit the autobuilt version file
src/main/resources/version.txt

# don't commit the code maps
src/main/resources/export/condition_code_map.json
src/main/resources/export/medication_code_map.json
src/main/resources/export/drg_code_map.json
src/main/resources/export/dme_code_map.json
src/main/resources/export/hcpcs_code_map.json
src/main/resources/export/betos_code_map.json
src/main/resources/export/external_codes.csv
src/main/resources/export/snf_pdpm_code_map.json
src/main/resources/export/snf_pps_code_map.json
src/main/resources/export/snf_rev_cntr_code_map.json
src/main/resources/export/hha_rev_cntr_code_map.json
src/main/resources/export/hha_pps_case_mix_codes.csv
src/main/resources/export/hha_pps_pdgm_codes.csv
src/main/resources/export/hospice_rev_cntr_code_map.json
src/main/resources/export/inpatient_rev_cntr_code_map.json
src/main/resources/export/outpatient_rev_cntr_code_map.json

# H2 database files
**/*.mv.db
**/*.trace.db

# VS Code launch settings
.vscode/launch.test.json
.vscode/launch.json
.vscode/settings.json
/build/

# VS Code plugin files
.history
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# EditorConfig is awesome: https://EditorConfig.org
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal source code editor configuration files should not be a part of this PR.

Copy link
Author

@rolandknight rolandknight Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. .editorconfig is intended to ensure any .editorconfig compliant editor (most modern editors/IDEs) comply to the standards used in the repo. otherwise you will spurious indent changes from contributors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synthea uses checkstyle for this purpose.


# Top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Set default charset
charset = utf-8

[Makefile]
indent_style = tab

# 4 space indentation (default)
indent_style = space
indent_size = 4

# 2 space indentation
[*.{bicep,bicepparam,html,js,jsx,ts,tsx,json,sass,yaml,yml}]
indent_size = 2

# Trim trailing whitespace
trim_trailing_whitespace = true

# Max line length
max_line_length = 80
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
.gradle
/nbproject/**
/build/**
bin/**

/.gradle/
/bin/
/bin/main
/bin/test

/failed_exports/
/output/
Expand Down
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ARG BASE_IMAGE=ubuntu:22.04
FROM ${BASE_IMAGE}

ARG USER=dev

WORKDIR /work
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]

# setup timezone
RUN apt-get update;\
apt-get install -yq tzdata;\
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime;\
dpkg-reconfigure -f noninteractive tzdata;

# Set the locale
RUN apt-get install -yq locales;
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# install OS deps
RUN set -eux;\
apt-get install -y --no-install-recommends ca-certificates curl git jq make unzip zip;
RUN set -eux;\
apt-get install -y --no-install-recommends libfreetype-dev libfreetype6 fontconfig fonts-dejavu;\
rm -rf /var/lib/apt/lists/*;

# run as non-root user
RUN id -u ${USER} &>/dev/null || useradd -ms /bin/bash ${USER}
USER ${USER}
WORKDIR /home/${USER}/work

COPY --chown=${USER}:${USER} ./ ./synthea

# install hermit and binary deps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear to me why you would want to use hermit in a Docker environment. I understand that hermit allows you to specify the exact version of tools that you want to use for development, such as the JDK. That said, you can do the same thing with plain Docker.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can, but we've used hermit in Dockerfiles for years with great success. hermit provides a simple way to ensure local environment binary tools exactly match docker container tools. and it simplifies installation (no need to look up the exact installation URL and procedure for each tool

COPY --chown=${USER}:${USER} bin/ bin/
ENV PATH=/home/${USER}/work/bin:${PATH}
RUN set -eux;\
hermit shell-hooks;\
hermit install

COPY --chown=${USER}:${USER} ./ ./synthea
RUN set -eux;\
cd synthea;\
make install;\
make build;

# Synthea repo: https://github.com/synthetichealth/synthea
# ./synthea/run_synthea -m congestive_heart_failure -c settings-chf.yml -p 10000
# ./synthea/run_synthea -c settings-chf.yml -p 10000
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: build install visualize
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synthea uses gradle for its build system. Adding a Makefile replicates gradle functionality and will likely lead to confusion for users.

The project does not incorporate any tool management systems such as hermit, SDKMAN or jabba. Doing so would likely cause issues for users who may not be able to install these types of tools.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Makefile is a minor convenience mostly for installation. I could replace with an install.sh script


SHELL := /bin/bash

export PATH := ./bin:${PATH}

all: install build test visualize

install:
hermit shell-hooks
hermit install

build:
./gradlew build

test:
./gradlew check test

visualize:
gradle graphviz
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Synthea<sup>TM</sup> Patient Generator ![Build Status](https://github.com/synthetichealth/synthea/workflows/.github/workflows/ci-build-test.yml/badge.svg?branch=master) [![codecov](https://codecov.io/gh/synthetichealth/synthea/branch/master/graph/badge.svg)](https://codecov.io/gh/synthetichealth/synthea)
# Synthea<sup>TM</sup> Patient Generator

![Build Status](https://github.com/synthetichealth/synthea/workflows/.github/workflows/ci-build-test.yml/badge.svg?branch=master) [![codecov](https://codecov.io/gh/synthetichealth/synthea/branch/master/graph/badge.svg)](https://codecov.io/gh/synthetichealth/synthea) [![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/InnovaSolutions/synthea.git)

Synthea<sup>TM</sup> is a Synthetic Patient Population Simulator. The goal is to output synthetic, realistic (but not real), patient data and associated health records in a variety of formats.

Read our [wiki](https://github.com/synthetichealth/synthea/wiki) and [Frequently Asked Questions](https://github.com/synthetichealth/synthea/wiki/Frequently-Asked-Questions) for more information.

Currently, Synthea<sup>TM</sup> features include:

- Birth to Death Lifecycle
- Configuration-based statistics and demographics (defaults with Massachusetts Census data)
- Modular Rule System
Expand All @@ -30,6 +33,7 @@ These instructions are intended for those wishing to examine the Synthea source
Synthea<sup>TM</sup> requires Java JDK 11 or newer. We strongly recommend using a Long-Term Support (LTS) release of Java, 11 or 17, as issues may occur with more recent non-LTS versions.

To clone the Synthea<sup>TM</sup> repo, then build and run the test suite:

```
git clone https://github.com/synthetichealth/synthea.git
cd synthea
Expand All @@ -38,28 +42,29 @@ cd synthea

### Changing the default properties


The default properties file values can be found at `src/main/resources/synthea.properties`.
By default, synthea does not generate CCDA, CPCDA, CSV, or Bulk FHIR (ndjson). You'll need to
adjust this file to activate these features. See the [wiki](https://github.com/synthetichealth/synthea/wiki)
adjust this file to activate these features. See the [wiki](https://github.com/synthetichealth/synthea/wiki)
for more details, or use our [guided customizer tool](https://synthetichealth.github.io/spt/#/customizer).



### Generate Synthetic Patients

Generating the population one at a time...

```
./run_synthea
```

Command-line arguments may be provided to specify a state, city, population size, or seed for randomization.

```
run_synthea [-s seed] [-p populationSize] [state [city]]
```

Full usage info can be printed by passing the `-h` option.

```
$ ./run_synthea -h
$ ./run_synthea -h

> Task :run
Usage: run_synthea [options] [state [city]]
Expand Down Expand Up @@ -97,13 +102,17 @@ Some settings can be changed in `./src/main/resources/synthea.properties`.
Synthea<sup>TM</sup> will output patient records in C-CDA and FHIR formats in `./output`.

### Synthea<sup>TM</sup> GraphViz

Generate graphical visualizations of Synthea<sup>TM</sup> rules and modules.

```
./gradlew graphviz
```

### Concepts and Attributes

Generate a list of concepts (used in the records) or attributes (variables on each patient).

```
./gradlew concepts
./gradlew attributes
Expand Down
1 change: 1 addition & 0 deletions bin/.gradle-8.3.pkg
1 change: 1 addition & 0 deletions bin/.openjdk@17.pkg
7 changes: 7 additions & 0 deletions bin/README.hermit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hermit environment

This is a [Hermit](https://github.com/cashapp/hermit) bin directory.

The symlinks in this directory are managed by Hermit and will automatically
download and install Hermit itself as well as packages. These packages are
local to this environment.
21 changes: 21 additions & 0 deletions bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly
#
# THIS FILE IS GENERATED; DO NOT MODIFY

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")"
if "${BIN_DIR}/hermit" noop > /dev/null; then
eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")"

if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then
hash -r 2>/dev/null
fi

echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated"
fi
1 change: 1 addition & 0 deletions bin/gradle
43 changes: 43 additions & 0 deletions bin/hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# THIS FILE IS GENERATED; DO NOT MODIFY

set -eo pipefail

export HERMIT_USER_HOME=~

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
;;
esac
fi

export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}"
HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")"
export HERMIT_CHANNEL
export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
INSTALL_SCRIPT="$(mktemp)"
# This value must match that of the install script
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
else
# Install script is versioned by its sha256sum value
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
# Verify install script's sha256sum
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
fi
/bin/bash "${INSTALL_SCRIPT}" 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
Empty file added bin/hermit.hcl
Empty file.
1 change: 1 addition & 0 deletions bin/jar
1 change: 1 addition & 0 deletions bin/jarsigner
1 change: 1 addition & 0 deletions bin/java
1 change: 1 addition & 0 deletions bin/javac
1 change: 1 addition & 0 deletions bin/javadoc
1 change: 1 addition & 0 deletions bin/javap
1 change: 1 addition & 0 deletions bin/jcmd
1 change: 1 addition & 0 deletions bin/jconsole
1 change: 1 addition & 0 deletions bin/jdb
1 change: 1 addition & 0 deletions bin/jdeprscan
1 change: 1 addition & 0 deletions bin/jdeps
1 change: 1 addition & 0 deletions bin/jfr
1 change: 1 addition & 0 deletions bin/jhsdb
1 change: 1 addition & 0 deletions bin/jimage
1 change: 1 addition & 0 deletions bin/jinfo
1 change: 1 addition & 0 deletions bin/jlink
1 change: 1 addition & 0 deletions bin/jmap
1 change: 1 addition & 0 deletions bin/jmod
1 change: 1 addition & 0 deletions bin/jpackage
1 change: 1 addition & 0 deletions bin/jps
Loading