From 5cf72dfb91ca3fa4f7c73a0d69d0ab6f5da3eeb1 Mon Sep 17 00:00:00 2001 From: Jason Walonoski Date: Wed, 17 Jun 2020 10:13:16 -0400 Subject: [PATCH] Initial commit. --- .gitignore | 9 +++ README.md | 44 +++++++++++- _genonce.bat | 33 +++++++++ _genonce.sh | 36 ++++++++++ _updatePublisher.bat | 95 ++++++++++++++++++++++++++ _updatePublisher.sh | 71 +++++++++++++++++++ fsh/config.yaml | 21 ++++++ fsh/ig-data/input/pagecontent/index.md | 7 ++ fsh/patient.fsh | 22 ++++++ 9 files changed, 336 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 _genonce.bat create mode 100755 _genonce.sh create mode 100644 _updatePublisher.bat create mode 100755 _updatePublisher.sh create mode 100644 fsh/config.yaml create mode 100644 fsh/ig-data/input/pagecontent/index.md create mode 100644 fsh/patient.fsh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7489d2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +Thumbs.db +/SUSHI-GENERATED-FILES.md +/ig.ini +/input-cache +/input +/output +/temp +/template \ No newline at end of file diff --git a/README.md b/README.md index 54d4091..882b9a9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,42 @@ -# synthea-fhir-ig -Synthea FHIR Implementation Guide +# SyntheaTM FHIR Implementation Guide + +This repository contains the artifacts required to generate the SyntheaTM FHIR Implementation Guide (IG) using [SUSHI](http://hl7.org/fhir/uv/shorthand/2020May/sushi.html#step-2-install-sushi) and the HL7 FHIR IG Publisher. + +This repository was based on the [FSH Let’s Build Starter Project](https://github.com/standardhealth/fsh-devdays-exercise/releases/tag/v0.0.1). + +## Requirements + +- [Node.js LTS](https://nodejs.org/en/download/) – needed to install and run SUSHI +- [SUSHI](http://hl7.org/fhir/uv/shorthand/2020May/sushi.html#step-2-install-sushi) – needed to + compile FSH into valid FHIR definitions +- [OpenJDK 8](https://adoptopenjdk.net/?variant=openjdk8&jvmVariant=hotspot) (or licensed + [Oracle JDK](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html)) – needed + to run HL7 IG Publisher +- [Ruby and Jekyll](https://jekyllrb.com/docs/installation/) – needed to run HL7 IG Publisher + +## Build the IG + +The first time you run this code, you'll need to execute the `_updatePublisher` script. + +``` +sushi +./_genonce.sh +``` + +The final IG will be written to the `./output` folder. + +# License + +Copyright 2020+ The MITRE Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/_genonce.bat b/_genonce.bat new file mode 100644 index 0000000..c060696 --- /dev/null +++ b/_genonce.bat @@ -0,0 +1,33 @@ +@ECHO OFF +REM *********************************************************************************************** +REM * WARNING: DO NOT EDIT THIS FILE * +REM * * +REM * This file is generated by SUSHI. Any edits you make to this file will be overwritten. * +REM *********************************************************************************************** + +SET publisher_jar=org.hl7.fhir.publisher.jar +SET input_cache_path=%CD%\input-cache + +ECHO Checking internet connection... +PING tx.fhir.org -n 1 -w 1000 | FINDSTR TTL && GOTO isonline +ECHO We're offline... +SET txoption=-tx n/a +GOTO igpublish + +:isonline +ECHO We're online +SET txoption= + +:igpublish + +SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 + +IF EXIST "%input_cache_path%\%publisher_jar%" ( + JAVA -jar "%input_cache_path%\%publisher_jar%" -ig ig.ini %txoption% %* +) ELSE If exist "..\%publisher_jar%" ( + JAVA -jar "..\%publisher_jar%" -ig ig.ini %txoption% %* +) ELSE ( + ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting... +) + +PAUSE \ No newline at end of file diff --git a/_genonce.sh b/_genonce.sh new file mode 100755 index 0000000..d86bcdf --- /dev/null +++ b/_genonce.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# ************************************************************************************************* +# * WARNING: DO NOT EDIT THIS FILE * +# * * +# * This file is generated by SUSHI. Any edits you make to this file will be overwritten. * +# ************************************************************************************************* + +publisher_jar=org.hl7.fhir.publisher.jar +input_cache_path=./input-cache/ +set -e +echo Checking internet connection... +curl -sSf tx.fhir.org > /dev/null + +if [ $? -eq 0 ]; then + echo "Online" + txoption="" +else + echo "Offline" + txoption="-tx n/a" +fi + +echo "$txoption" + +publisher=$input_cache_path/$publisher_jar +if test -f "$publisher"; then + java -jar $publisher -ig ig.ini $txoption $* + +else + publisher=../$publisher_jar + if test -f "$publisher"; then + java -jar $publisher -ig ig.ini $txoption $* + else + echo IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting... + fi +fi \ No newline at end of file diff --git a/_updatePublisher.bat b/_updatePublisher.bat new file mode 100644 index 0000000..c225305 --- /dev/null +++ b/_updatePublisher.bat @@ -0,0 +1,95 @@ +@ECHO OFF +REM *********************************************************************************************** +REM * WARNING: DO NOT EDIT THIS FILE * +REM * * +REM * This file is generated by SUSHI. Any edits you make to this file will be overwritten. * +REM *********************************************************************************************** + +SETLOCAL + +SET dlurl=https://storage.googleapis.com/ig-build/org.hl7.fhir.publisher.jar +SET publisher_jar=org.hl7.fhir.publisher.jar +SET input_cache_path=%CD%\input-cache\ + +:processflags +SET ARG=%1 +IF DEFINED ARG ( + IF "%ARG%"=="-f" SET FORCE=true + IF "%ARG%"=="--force" SET FORCE=true + SHIFT + GOTO processflags +) + +FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx + +IF NOT EXIST "%input_cache_path%%publisher_jar%" ( + IF NOT EXIST "%upper_path%%publisher_jar%" ( + SET jarlocation="%input_cache_path%%publisher_jar%" + SET jarlocationname=Input Cache + ECHO IG Publisher is not yet in input-cache or parent folder. + REM we don't use jarlocation below because it will be empty because we're in a bracketed if statement + GOTO create + ) ELSE ( + ECHO IG Publisher FOUND in parent folder + SET jarlocation="%upper_path%%publisher_jar%" + SET jarlocationname=Parent folder + GOTO:upgrade + ) +) ELSE ( + ECHO IG Publisher FOUND in input-cache + SET jarlocation="%input_cache_path%%publisher_jar%" + SET jarlocationname=Input Cache + GOTO:upgrade +) + +:create +IF DEFINED FORCE ( + MKDIR "%input_cache_path%" 2> NUL + GOTO:download +) +ECHO Will place publisher jar here: %input_cache_path%%publisher_jar% +SET /p create="Ok? (Y/N) " +IF /I "%create%"=="Y" ( + MKDIR "%input_cache_path%" 2> NUL + GOTO:download +) +GOTO:done + +:upgrade +IF DEFINED FORCE GOTO:download +SET /p overwrite="Overwrite %jarlocation%? (Y/N) " +IF /I "%overwrite%"=="Y" ( + GOTO:download +) +GOTO:done + +:download +ECHO Downloading most recent publisher to %jarlocationname% - it's ~100 MB, so this may take a bit + +FOR /f "tokens=4-5 delims=. " %%i IN ('ver') DO SET VERSION=%%i.%%j +IF "%version%" == "10.0" GOTO win10 +IF "%version%" == "6.3" GOTO win8.1 +IF "%version%" == "6.2" GOTO win8 +IF "%version%" == "6.1" GOTO win7 +IF "%version%" == "6.0" GOTO vista + +ECHO Unrecognized version: %version% +GOTO done + +:win10 +CALL POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%dlurl%\",\"%jarlocation%\") } else { Invoke-WebRequest -Uri "%dlurl%" -Outfile "%jarlocation%" } + +GOTO done + +:win7 +CALL bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%" +GOTO done + +:win8.1 +:win8 +:vista +ECHO This script does not yet support Windows %winver%. Please ask for help on http://chat.fhir.org +GOTO done + +:done +IF NOT DEFINED FORCE PAUSE \ No newline at end of file diff --git a/_updatePublisher.sh b/_updatePublisher.sh new file mode 100755 index 0000000..e42fb87 --- /dev/null +++ b/_updatePublisher.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# ************************************************************************************************* +# * WARNING: DO NOT EDIT THIS FILE * +# * * +# * This file is generated by SUSHI. Any edits you make to this file will be overwritten. * +# ************************************************************************************************* + +dlurl=https://storage.googleapis.com/ig-build/org.hl7.fhir.publisher.jar +publisher_jar=org.hl7.fhir.publisher.jar +input_cache_path=./input-cache/ + +set -e +if ! type "curl" > /dev/null; then + echo "ERROR: Script needs curl to download latest IG Publisher. Please install curl." + exit 1 +fi + +FORCE=false + +while :; do + case $1 in + -f|--force) FORCE=true ;; + --) + shift + break + ;; + *) break + esac + shift +done + +publisher="$input_cache_path$publisher_jar" +if test -f "$publisher"; then + echo "IG Publisher FOUND in input-cache" + jarlocation="$publisher" + jarlocationname="Input Cache" + upgrade=true +else + publisher="../$publisher_jar" + upgrade=true + if test -f "$publisher"; then + echo "IG Publisher FOUND in parent folder" + jarlocation="$publisher" + jarlocationname="Parent Folder" + upgrade=true + else + echo IG Publisher NOT FOUND in input-cache or parent folder... + jarlocation=$input_cache_path$publisher_jar + jarlocationname="Input Cache" + upgrade=false + fi +fi + +if [[ "$FORCE" != true ]]; then + if "$upgrade"; then + message="Overwrite $jarlocation? (Y/N) " + else + echo Will place publisher jar here: "$jarlocation" + message="Ok? (Y/N) " + fi + read -r -p "$message" response +fi + +if [[ "$FORCE" == true ]] || [[ "$response" =~ ^([yY])$ ]]; then + echo "Downloading most recent publisher to $jarlocationname - it's ~100 MB, so this may take a bit" +# wget "https://fhir.github.io/latest-ig-publisher/org.hl7.fhir.publisher.jar" -O "$jarlocation" + curl $dlurl -o "$jarlocation" --create-dirs +else + echo cancel... +fi diff --git a/fsh/config.yaml b/fsh/config.yaml new file mode 100644 index 0000000..adc8887 --- /dev/null +++ b/fsh/config.yaml @@ -0,0 +1,21 @@ +id: synthea.fhir +canonical: http://synthetichealth.github.io/synthea +name: Synthea +status: active +version: 1.0.0 +fhirVersion: 4.0.1 +copyrightYear: 2020+ +releaseLabel: Build CI +publisher: + name: The MITRE Corporation + url: http://synthea.mitre.org +template: fhir.base.template#0.1.0 + +menu: + Home: index.html + Artifacts: artifacts.html + +parameters: + apply-contact: true + apply-jurisdiction: false + apply-publisher: true \ No newline at end of file diff --git a/fsh/ig-data/input/pagecontent/index.md b/fsh/ig-data/input/pagecontent/index.md new file mode 100644 index 0000000..fd76de7 --- /dev/null +++ b/fsh/ig-data/input/pagecontent/index.md @@ -0,0 +1,7 @@ +# SyntheaTM Implementation Guide + +Welcome to the SyntheaTM Implementation Guide (IG). + +[Synthea](https://github.com/synthetichealth/synthea) is an open-source 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, including HL7 FHIR. + +This simple FHIR IG defines a small set of optional [artifacts](artifacts.html). \ No newline at end of file diff --git a/fsh/patient.fsh b/fsh/patient.fsh new file mode 100644 index 0000000..684a03f --- /dev/null +++ b/fsh/patient.fsh @@ -0,0 +1,22 @@ +// Synthea Patient profile. +Profile: SyntheaPatient +Parent: Patient +Id: synthea-patient +Title: "Synthea Patient Profile" +Description: "Synthea outputs additional extensions on Patient resources, notably `quality-adjusted-life-years` and `disability-adjusted-life-years`." +* extension contains QALY named quality-adjusted-life-years 0..1 +* extension contains DALY named disability-adjusted-life-years 0..1 + +// QALY Extension +Extension: QALY +Id: quality-adjusted-life-years +Title: "Quality Adjusted Life Years" +Description: "Quality Adjusted Life Years as defined in the literature and summarized at ." +* value[x] only decimal + +// DALY Extension +Extension: DALY +Id: disability-adjusted-life-years +Title: "Disability Adjusted Life Years" +Description: "Disability Adjusted Life Years as defined in the literature and summarized at ." +* value[x] only decimal