Files
synthea-alldiseases/main.nf
Olamide Isreal 67bd6692b0 Clean up pipeline files
- Remove unused variable and redundant comments/echo statements in main.nf
- Remove obsolete files: simple.nf, test.nf, generate_patients.sh,
  test_synthea.sh, trace.txt, docker-compose.yml
  (all referenced local-only synthea-module-generator image)
2026-03-25 15:09:07 +01:00

66 lines
1.5 KiB
Plaintext

#!/usr/bin/env nextflow
nextflow.enable.dsl=2
params.disease_name = null
params.outdir = null
params.population = 10
params.gender = 0.5
params.min_age = 0
params.max_age = 90
params.seed = null
if (!params.disease_name) {
error "Disease name is required. Please specify with --disease_name"
}
if (!params.outdir) {
error "Output directory is required. Please specify with --outdir"
}
process generatePatients {
container 'harbor.cluster.omic.ai/omic/synthea-alldiseases:v3'
publishDir params.outdir, mode: 'copy'
input:
val diseaseName
output:
path "fhir/*.json", optional: true, emit: fhir_output
path "run.log", emit: log_file
script:
def genderArg = params.gender < 0.5 ? "-g M" : (params.gender > 0.5 ? "-g F" : "")
def seedArg = params.seed ? "-s ${params.seed}" : ""
"""
set +e
WORKDIR=\$(pwd)
# Run Synthea via pre-built jar (Gradle is not writable in K8s)
cd /app
java -jar /app/build/libs/synthea-with-dependencies.jar \
-p ${params.population} \
${genderArg} \
-a ${params.min_age}-${params.max_age} \
${seedArg} 2>&1 | tee \${WORKDIR}/run.log
JAVA_EXIT=\${PIPESTATUS[0]}
cd \${WORKDIR}
mkdir -p fhir
if [ -d /app/output/fhir ]; then
cp /app/output/fhir/*.json fhir/ 2>/dev/null || true
fi
# Succeed if FHIR output was produced
if [ -n "\$(ls fhir/*.json 2>/dev/null)" ]; then
exit 0
else
exit \${JAVA_EXIT}
fi
"""
}
workflow {
generatePatients(params.disease_name)
}