Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawalonoski committed Jun 17, 2020
1 parent bf7e239 commit 5cf72df
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
Thumbs.db
/SUSHI-GENERATED-FILES.md
/ig.ini
/input-cache
/input
/output
/temp
/template
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# synthea-fhir-ig
Synthea FHIR Implementation Guide
# Synthea<sup>TM</sup> FHIR Implementation Guide

This repository contains the artifacts required to generate the Synthea<sup>TM</sup> 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.
33 changes: 33 additions & 0 deletions _genonce.bat
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions _genonce.sh
Original file line number Diff line number Diff line change
@@ -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
95 changes: 95 additions & 0 deletions _updatePublisher.bat
Original file line number Diff line number Diff line change
@@ -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
71 changes: 71 additions & 0 deletions _updatePublisher.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions fsh/config.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions fsh/ig-data/input/pagecontent/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Synthea<sup>TM</sup> Implementation Guide

Welcome to the Synthea<sup>TM</sup> 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).
22 changes: 22 additions & 0 deletions fsh/patient.fsh
Original file line number Diff line number Diff line change
@@ -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 <a href=\"https://en.wikipedia.org/wiki/Quality-adjusted_life_year\"/>."
* 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 <a href=\"https://en.wikipedia.org/wiki/Disability-adjusted_life_year\"/>."
* value[x] only decimal

0 comments on commit 5cf72df

Please sign in to comment.