diff --git a/FHIR-phd.xml b/FHIR-phd.xml index 537a189..7175fe4 100644 --- a/FHIR-phd.xml +++ b/FHIR-phd.xml @@ -1,7 +1,6 @@ - @@ -79,6 +78,7 @@ + diff --git a/_build.bat b/_build.bat index 99d0e1f..903d207 100644 --- a/_build.bat +++ b/_build.bat @@ -25,38 +25,55 @@ IF EXIST "%input_cache_path%%publisher_jar%" ( ) ELSE ( SET "jar_location=not_found" SET "default_choice=1" + SET "default_reason=publisher not found" ECHO publisher.jar not found in input-cache or parent folder ) ) :: Handle command-line argument to bypass the menu -IF NOT "%~1"=="" ( - IF /I "%~1"=="update" SET "userChoice=1" - IF /I "%~1"=="build" SET "userChoice=2" - IF /I "%~1"=="nosushi" SET "userChoice=3" - IF /I "%~1"=="notx" SET "userChoice=4" - IF /I "%~1"=="jekyll" SET "userChoice=5" - IF /I "%~1"=="clean" SET "userChoice=6" - IF /I "%~1"=="exit" SET "userChoice=0" - GOTO executeChoice -) +:: Known first arguments select a menu option; anything else is passed through to the publisher +SET "extraArgs=" +IF "%~1"=="" GOTO showMenu +IF /I "%~1"=="update" SET "userChoice=1" & GOTO parseExtra +IF /I "%~1"=="build" SET "userChoice=2" & GOTO parseExtra +IF /I "%~1"=="nosushi" SET "userChoice=3" & GOTO parseExtra +IF /I "%~1"=="notx" SET "userChoice=4" & GOTO parseExtra +IF /I "%~1"=="jekyll" SET "userChoice=5" & GOTO parseExtra +IF /I "%~1"=="clean" SET "userChoice=6" & GOTO parseExtra +IF /I "%~1"=="exit" SET "userChoice=0" & GOTO parseExtra +:: Unknown first arg - default to build, pass all args through +SET "userChoice=2" +GOTO collectArgs +:parseExtra +SHIFT +:collectArgs +IF "%~1"=="" GOTO executeChoice +SET "extraArgs=!extraArgs! %1" +SHIFT +GOTO collectArgs +:showMenu echo --------------------------------------------------------------- ECHO Checking internet connection... -PING tx.fhir.org -4 -n 1 -w 4000 >nul 2>&1 && SET "online_status=true" || SET "online_status=false" +powershell -Command "try { $r=[System.Net.WebRequest]::Create('https://tx.fhir.org/r4/metadata'); $r.Timeout=4000; $r.GetResponse().Close(); exit 0 } catch { exit 1 }" +IF %ERRORLEVEL% EQU 0 (SET "online_status=true") ELSE (SET "online_status=false") IF "%online_status%"=="true" ( - ECHO We're online and tx.fhir.org is available. + ECHO We are online and tx.fhir.org is available. FOR /F "tokens=2 delims=:" %%a IN ('curl -s https://api.github.com/repos/HL7/fhir-ig-publisher/releases/latest ^| findstr "tag_name"') DO SET "latest_version=%%a" SET "latest_version=!latest_version:"=!" SET "latest_version=!latest_version: =!" SET "latest_version=!latest_version:~0,-1!" ) ELSE ( - ECHO We're offline or tx.fhir.org is not available, can only run the publisher without TX... + ECHO. + ECHO *** WARNING: Working offline - this is not the normal mode. + ECHO Some features including terminology rendering will not work. + ECHO. SET "txoption=-tx n/a" SET "latest_version=unknown" SET "default_choice=4" + SET "default_reason=working offline" ) echo --------------------------------------------------------------- @@ -74,14 +91,16 @@ IF NOT "%jar_location%"=="not_found" ( ECHO Publisher version: !publisher_version!; Latest is !latest_version! IF NOT "%online_status%"=="true" ( - ECHO We're offline. + ECHO We are offline. ) ELSE ( IF NOT "!publisher_version!"=="!latest_version!" ( ECHO An update is recommended. SET "default_choice=1" + SET "default_reason=newer version available" ) ELSE ( ECHO Publisher is up to date. SET "default_choice=2" + SET "default_reason=publisher is up to date" ) ) @@ -96,12 +115,9 @@ echo 4. Build IG - force no TX server echo 5. Jekyll build echo 6. Clean up temp directories echo 0. Exit -:: echo [Press Enter for default (%default_choice%) or type an option number:] echo. -:: Using CHOICE to handle input with timeout -:: ECHO [Enter=Continue, 1-7=Option, 0=Exit] -choice /C 12345670 /N /CS /D %default_choice% /T 5 /M "Choose an option number or wait 5 seconds for default (%default_choice%):" +choice /C 12345670 /N /CS /D %default_choice% /T 5 /M "Choose an option number or wait 5 seconds for default (%default_choice% - %default_reason%):" SET "userChoice=%ERRORLEVEL%" @@ -115,15 +131,12 @@ IF "%userChoice%"=="4" GOTO publish_notx IF "%userChoice%"=="5" GOTO debugjekyll IF "%userChoice%"=="6" GOTO clean IF "%userChoice%"=="0" EXIT /B - -:end - - +GOTO endscript :debugjekyll echo Running Jekyll build... jekyll build -s temp/pages -d output -GOTO end +GOTO endscript :clean @@ -152,10 +165,7 @@ GOTO end echo Removed: .\template ) -GOTO end - - - +GOTO endscript :downloadpublisher @@ -198,7 +208,7 @@ IF DEFINED FORCE ( GOTO download ) -IF "%skipPrompts%"=="y" ( +IF "%skipPrompts%"=="true" ( SET create=Y ) ELSE ( SET /p create="Download? (Y/N) " @@ -211,7 +221,7 @@ IF /I "%create%"=="Y" ( GOTO done :upgrade -IF "%skipPrompts%"=="y" ( +IF "%skipPrompts%"=="true" ( SET overwrite=Y ) ELSE ( SET /p overwrite="Overwrite %jarlocation%? (Y/N) " @@ -265,7 +275,7 @@ GOTO done ECHO. ECHO Updating scripts -IF "%skipPrompts%"=="y" ( +IF "%skipPrompts%"=="true" ( SET updateScripts=Y ) ELSE ( SET /p updateScripts="Update scripts? (Y/N) " @@ -273,7 +283,7 @@ IF "%skipPrompts%"=="y" ( IF /I "%updateScripts%"=="Y" ( GOTO scripts ) -GOTO end +GOTO endscript :scripts @@ -299,12 +309,12 @@ ECHO Updating _build.bat call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%build_bat_url%\",\"_build.new.bat\") } else { Invoke-WebRequest -Uri "%build_bat_url%" -Outfile "_build.new.bat" } if %ERRORLEVEL% == 0 goto upd_script_2 echo "Errors encountered during download: %errorlevel%" -goto end +goto endscript :upd_script_2 start copy /y "_build.new.bat" "_build.bat" ^&^& del "_build.new.bat" ^&^& exit -GOTO end +GOTO endscript :publish_once @@ -312,14 +322,15 @@ GOTO end SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 :: Debugging statements before running publisher -ECHO 1jar_location is: %jar_location% +ECHO jar_location is: %jar_location% IF NOT "%jar_location%"=="not_found" ( - java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %* + ECHO IG Publisher FOUND, Publishing... + java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %extraArgs% ) ELSE ( - ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting... + ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting... ) -GOTO end +GOTO endscript @@ -328,14 +339,14 @@ GOTO end SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 :: Debugging statements before running publisher -ECHO 3jar_location is: %jar_location% +ECHO jar_location is: %jar_location% IF NOT "%jar_location%"=="not_found" ( - java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% -no-sushi %* + java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% -no-sushi %extraArgs% ) ELSE ( - ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting... + ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting... ) -GOTO end +GOTO endscript :publish_notx @@ -344,43 +355,33 @@ SET txoption=-tx n/a SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 :: Debugging statements before running publisher -ECHO 2jar_location is: %jar_location% +ECHO jar_location is: %jar_location% IF NOT "%jar_location%"=="not_found" ( - java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %* + java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% %extraArgs% ) ELSE ( - ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting... + ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting... ) -GOTO end - - +GOTO endscript :publish_continuous SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8 -:: Debugging statements before running publisher -ECHO Checking %input_cache_path% for publisher.jar -IF EXIST "%input_cache_path%\%publisher_jar%" ( - java %JAVA_OPTS% -jar "%input_cache_path%\%publisher_jar%" -ig . %txoption% -watch %* +ECHO jar_location is: %jar_location% +IF NOT "%jar_location%"=="not_found" ( + java %JAVA_OPTS% -jar "%jar_location%" -ig . %txoption% -watch %extraArgs% ) ELSE ( - ECHO Checking %upper_path% for publisher.jar - IF EXIST "..\%publisher_jar%" ( - java %JAVA_OPTS% -jar "..\%publisher_jar%" -ig . %txoption% -watch %* - ) ELSE ( - ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting... - ) + ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run the script and update the publisher. Aborting... ) -GOTO end +GOTO endscript -:end +:endscript :: Pausing at the end - - IF NOT "%skipPrompts%"=="true" ( PAUSE ) diff --git a/_build.sh b/_build.sh index f11edff..69ac585 100755 --- a/_build.sh +++ b/_build.sh @@ -26,20 +26,44 @@ function check_jar_location() { } function check_internet_connection() { - if ping -c 1 tx.fhir.org &>/dev/null; then + local target="tx.fhir.org" + local reachable=false + + if command -v ping > /dev/null 2>&1; then + if ping -c 1 -W 5 "$target" > /dev/null 2>&1 \ + || ping -c 1 -w 5 "$target" > /dev/null 2>&1; then + reachable=true + fi + elif command -v curl > /dev/null 2>&1; then + if curl --silent --max-time 5 --output /dev/null "https://$target"; then + reachable=true + fi + else + echo "WARNING: Neither ping nor curl available — assuming offline." + fi + + if [ "$reachable" = "true" ]; then online=true - echo "We're online and tx.fhir.org is available." + echo "We're online and $target is available." latest_version=$(curl -s https://api.github.com/repos/HL7/fhir-ig-publisher/releases/latest | grep tag_name | cut -d'"' -f4) else online=false - echo "We're offline or tx.fhir.org is unavailable." + echo "" + echo "⚠️ WARNING: Working offline — this is not the normal mode." + echo " Some features (e.g. terminology rendering) will not work." + echo "" fi } + function update_publisher() { echo "Publisher jar location: ${input_cache_path}${publisher_jar}" - read -p "Download or update publisher.jar? (Y/N): " confirm + if [ "$skipPrompts" = "true" ]; then + confirm="Y" + else + read -p "Download or update publisher.jar? (Y/N): " confirm + fi if [[ "$confirm" =~ ^[Yy]$ ]]; then echo "Downloading latest publisher.jar (~200 MB)..." mkdir -p "$input_cache_path" @@ -53,7 +77,11 @@ function update_publisher() { function update_scripts_prompt() { - read -p "Update scripts (_build.bat and _build.sh)? (Y/N): " update_confirm + if [ "$skipPrompts" = "true" ]; then + update_confirm="Y" + else + read -p "Update scripts (_build.bat and _build.sh)? (Y/N): " update_confirm + fi if [[ "$update_confirm" =~ ^[Yy]$ ]]; then echo "Updating scripts..." curl -L "$build_bat_url" -o "_build.new.bat" && mv "_build.new.bat" "_build.bat" @@ -66,33 +94,35 @@ function update_scripts_prompt() { } -function build_ig() { +function run_publisher() { + local extra_flags=("$@") if [ "$jar_location" != "not_found" ]; then - args=() - if [ "$online" = "false" ]; then - args+=("-tx" "n/a") - fi - java -Dfile.encoding=UTF-8 -jar "$jar_location" -ig . "${args[@]}" "$@" + echo "jar_location is: $jar_location" + export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8" + java $JAVA_OPTS -jar "$jar_location" -ig . "${extra_flags[@]}" else - echo "publisher.jar not found. Please run update." + echo "IG Publisher NOT FOUND in input-cache or parent folder. Please run update. Aborting..." fi } +function build_ig() { + local args=() + if [ "$online" = "false" ]; then + args+=("-tx" "n/a") + fi + run_publisher "${args[@]}" "$@" +} function build_nosushi() { - if [ "$jar_location" != "not_found" ]; then - java -Dfile.encoding=UTF-8 -jar "$jar_location" -ig . -no-sushi "$@" - else - echo "publisher.jar not found. Please run update." - fi + run_publisher -no-sushi "$@" } function build_notx() { - if [ "$jar_location" != "not_found" ]; then - java -Dfile.encoding=UTF-8 -jar "$jar_location" -ig . -tx n/a "$@" - else - echo "publisher.jar not found. Please run update." - fi + run_publisher -tx n/a "$@" +} + +function build_continuous() { + run_publisher -watch "$@" } function jekyll_build() { @@ -113,64 +143,78 @@ function cleanup() { } check_jar_location -check_internet_connection -# Handle command-line argument or menu -case "$1" in - update) update_publisher ;; - build) build_ig ;; - nosushi) build_nosushi ;; - notx) build_notx ;; - jekyll) jekyll_build ;; - clean) cleanup ;; - exit) exit 0 ;; - *) - # Compute default choice - default_choice=2 # Build by default - - if [ "$jar_location" = "not_found" ]; then - default_choice=1 # Download if jar is missing - elif [ "$online" = "false" ]; then - default_choice=4 # Offline build - elif [ -n "$latest_version" ]; then - current_version=$(java -jar "$jar_location" -v 2>/dev/null | tr -d '\r') - if [ "$current_version" != "$latest_version" ]; then - default_choice=1 # Offer update if newer version exists - fi - fi - - echo "---------------------------------------------" - echo "Publisher: ${current_version:-unknown}; Latest: ${latest_version:-unknown}" - echo "Publisher location: $jar_location" - echo "Online: $online" - echo "---------------------------------------------" - echo - echo "Please select an option:" - echo "1) Download or update publisher" - echo "2) Build IG" - echo "3) Build IG without Sushi" - echo "4) Build IG without TX server" - echo "5) Jekyll build" - echo "6) Cleanup temp directories" - echo "0) Exit" - echo - - # Read with timeout, but default if nothing entered - echo -n "Choose an option [default: $default_choice]: " - read -t 5 choice || choice="$default_choice" - choice="${choice:-$default_choice}" - echo "You selected: $choice" - - case "$choice" in - 1) update_publisher ;; - 2) build_ig ;; - 3) build_nosushi ;; - 4) build_notx ;; - 5) jekyll_build ;; - 6) cleanup ;; - 0) exit 0 ;; - *) echo "Invalid option." ;; - esac - ;; +# Handle command-line arguments +# Known first arguments select a menu option; anything else is passed through to the publisher +extraArgs=() +if [ $# -gt 0 ]; then + case "$1" in + update) shift; extraArgs=("$@"); update_publisher; exit 0 ;; + build) shift; extraArgs=("$@"); check_internet_connection; build_ig "${extraArgs[@]}"; exit 0 ;; + nosushi) shift; extraArgs=("$@"); check_internet_connection; build_nosushi "${extraArgs[@]}"; exit 0 ;; + notx) shift; extraArgs=("$@"); build_notx "${extraArgs[@]}"; exit 0 ;; + jekyll) jekyll_build; exit 0 ;; + clean) cleanup; exit 0 ;; + exit) exit 0 ;; + *) + # Unknown first arg - default to build, pass all args through + extraArgs=("$@") + run_publisher "${extraArgs[@]}" + exit 0 + ;; + esac +fi + +# Interactive menu +check_internet_connection +# Compute default choice and reason +default_choice=2 +default_reason="publisher is up to date" + +if [ "$jar_location" = "not_found" ]; then + default_choice=1 + default_reason="publisher not found" +elif [ "$online" = "false" ]; then + default_choice=4 + default_reason="working offline" +elif [ -n "$latest_version" ]; then + current_version=$(java -jar "$jar_location" -v 2>/dev/null | tr -d '\r') + if [ "$current_version" != "$latest_version" ]; then + default_choice=1 + default_reason="newer version available" + fi +fi + +echo "---------------------------------------------" +echo "Publisher: ${current_version:-unknown}; Latest: ${latest_version:-unknown}" +echo "Publisher location: $jar_location" +echo "Online: $online" +echo "---------------------------------------------" +echo +echo "Please select an option:" +echo "1) Download or update publisher" +echo "2) Build IG" +echo "3) Build IG without Sushi" +echo "4) Build IG without TX server" +echo "5) Jekyll build" +echo "6) Cleanup temp directories" +echo "0) Exit" +echo + +# Read with timeout, but default if nothing entered +echo -n "Choose an option [default: $default_choice - $default_reason]: " +read -t 5 choice || choice="$default_choice" +choice="${choice:-$default_choice}" +echo "You selected: $choice" + +case "$choice" in + 1) update_publisher ;; + 2) build_ig ;; + 3) build_nosushi ;; + 4) build_notx ;; + 5) jekyll_build ;; + 6) cleanup ;; + 0) exit 0 ;; + *) echo "Invalid option." ;; esac diff --git a/_genonce.bat b/_genonce.bat index a9864ef..c477ba8 100644 --- a/_genonce.bat +++ b/_genonce.bat @@ -3,7 +3,8 @@ SET publisher_jar=publisher.jar SET input_cache_path=%CD%\input-cache ECHO Checking internet connection... -PING tx.fhir.org -4 -n 1 -w 1000 | FINDSTR TTL && GOTO isonline +powershell -Command "try { $r=[System.Net.WebRequest]::Create('https://tx.fhir.org/r4/metadata'); $r.Timeout=4000; $r.GetResponse().Close(); exit 0 } catch { exit 1 }" +IF %ERRORLEVEL% EQU 0 GOTO isonline ECHO We're offline... SET txoption=-tx n/a GOTO igpublish diff --git a/_updatePublisher.bat b/_updatePublisher.bat index 10fee38..d4e1b7d 100644 --- a/_updatePublisher.bat +++ b/_updatePublisher.bat @@ -22,7 +22,8 @@ IF "%~1"=="/f" SET skipPrompts=y ECHO. ECHO Checking internet connection... -PING tx.fhir.org -4 -n 1 -w 4000 | FINDSTR TTL && GOTO isonline +powershell -Command "try { $r=[System.Net.WebRequest]::Create('https://tx.fhir.org/r4/metadata'); $r.Timeout=4000; $r.GetResponse().Close(); exit 0 } catch { exit 1 }" +IF %ERRORLEVEL% EQU 0 GOTO isonline ECHO We're offline, nothing to do... GOTO end diff --git a/input/fsh/StructureDefinition.PhdCompoundNumericObservation.fsh b/input/fsh/StructureDefinition.PhdCompoundNumericObservation.fsh index d1ecb5c..b057335 100644 --- a/input/fsh/StructureDefinition.PhdCompoundNumericObservation.fsh +++ b/input/fsh/StructureDefinition.PhdCompoundNumericObservation.fsh @@ -33,14 +33,14 @@ Description: "Observations coming from a PHD where the measurement is a set of n * code 1.. * text ^definition = "It is recommended to display at least the reference identifier describing the compound sub-element" * value[x] only Quantity - * valueQuantity + * valueQuantity obeys unit-system-code-coherent * value 1.. * ^definition = "The value of nth element of the compound attribute." * system 1.. - * system = "http://unitsofmeasure.org" - * ^definition = "The unit code shall use the UCUM system" + * obeys system-is-mdc-or-ucum * code 1.. - * ^definition = "The MDC code must be translated to the UCUM code." + * code from PhdUnitCodeVS (required) + * code ^definition = "The UCUM or MDC code for the units of this component measurement." * dataAbsentReason ^short = "Populated when the component reports a special FLOAT value" * ^definition = "Provides a reason why the expected value in the nth element `Observation.compoundComponent.valueQuantity` is missing. This happens when the value sent by the PHD is a special FLOAT value." * coding from http://hl7.org/fhir/ValueSet/data-absent-reason (required) diff --git a/input/fsh/StructureDefinition.PhdCompoundObservation.fsh b/input/fsh/StructureDefinition.PhdCompoundObservation.fsh index 0a5d62d..fabff3f 100644 --- a/input/fsh/StructureDefinition.PhdCompoundObservation.fsh +++ b/input/fsh/StructureDefinition.PhdCompoundObservation.fsh @@ -20,14 +20,14 @@ Description: "Observations from a PHD where the measurement is a set of numbers * ^comment = "A compound measurement is a measurement that requires more than one value to represent it, such as an acceleration which has an x, y, and z components. The Blood pressure is also represented as a compound measurement, containing systolic, diastolic and MAP components. One combines all the compound elements together to describe the measurement." * code from http://hl7.org/fhir/uv/phd/ValueSet/MDCValueSet (required) * value[x] only Quantity or CodeableConcept or string or SampledData - * valueQuantity + * valueQuantity obeys unit-system-code-coherent * value 1.. * ^definition = "The value of the numeric component. The value element is missing if a special FLOAT value is reported." * system 1.. - * system = "http://unitsofmeasure.org" - * ^definition = "The unit code shall use the UCUM system" + * obeys system-is-mdc-or-ucum * code 1.. - * ^definition = "The MDC code must be translated to the UCUM code." + * code from PhdUnitCodeVS (required) + * code ^definition = "The UCUM or MDC code for the units of this component measurement." * valueCodeableConcept * coding 1..1 * ^slicing.discriminator[0].type = #value diff --git a/input/fsh/StructureDefinition.PhdNumericObservation.fsh b/input/fsh/StructureDefinition.PhdNumericObservation.fsh index 6f397e3..7773da2 100644 --- a/input/fsh/StructureDefinition.PhdNumericObservation.fsh +++ b/input/fsh/StructureDefinition.PhdNumericObservation.fsh @@ -14,6 +14,7 @@ Description: "Observations from a PHD where the measurement is number" * ^definition = "The PhdNumericObservation reports PHD measurements that contain one of either a Basic-Nu-Observed-Value, Simple-Nu_observed-Value, or Nu_observed-Value attribute." * ^comment = "Used for non-compound numeric observations from Personal Health Devices." * value[x] only Quantity +* valueQuantity obeys unit-system-code-coherent * value 1.. * ^definition = "The decoded FLOAT or SFLOAT value from a PHD Observation." * ^comment = "The implicit precision in the value shall be honored. The MDER encoding used in the above attributes provides this precision. The translating software shall honor that precision when generating this value.\r\nThis element shall be present unless there is an error reported in the Measurement-Status attribute or the MDER encoding represents one of the special FLOAT values. In that case there is a `dataAbsentReason` element and the `valueQuantity` element is not present. Note that not all measurement status values are errors resulting in no measurement being reported here; for example the preliminary or verified status." @@ -22,6 +23,8 @@ Description: "Observations from a PHD where the measurement is number" * ^comment = "The unit code needs to be translated from the 11073-10101 code from the device. This can be represented as either a UCUM code or an MDC code system. UCUM is preferred but MDC codes are also supported." * obeys system-is-mdc-or-ucum * code 1.. + * code from PhdUnitCodeVS (required) + * code * ^short = "The UCUM or MDC code for the units of this measurement." * ^comment = "The unit code needs to be translated from the 11073-10101 code from the device. This translation means that the reporting of units is not future proof." * dataAbsentReason ^short = "This element is populated for numeric observations when a special FLOAT value is reported that is not a real number." @@ -38,9 +41,13 @@ Target: "https://sagroups.ieee.org/11073/phd-wg" * -> "ACOM" * valueQuantity.value -> "NumericObservation.value" * valueQuantity.unit -> "NumericObservation.unit" -* extension[Accuracy].valueQuantity.value -> "NumericObservation.accuracy" Invariant: system-is-mdc-or-ucum Description: "system SHALL be either the MDC or UCUM URI" -Expression: "$this = 'urn:iso:std:iec:61853:2:2017' or $this = 'http://unitsofmeasure.org'" +Expression: "$this = 'urn:iso:std:iso:11073:10101' or $this = 'http://unitsofmeasure.org'" +Severity: #error + +Invariant: unit-system-code-coherent +Description: "system and code SHALL be coherent: UCUM system uses UCUM code, MDC system uses MDC code" +Expression: "(system = 'http://unitsofmeasure.org' implies code.memberOf('http://hl7.org/fhir/ValueSet/ucum-units')) and (system = 'urn:iso:std:iso:11073:10101' implies code.memberOf('http://hl7.org/fhir/uv/phd/ValueSet/MDCValueSet'))" Severity: #error diff --git a/input/fsh/StructureDefinition.PhdRtsaObservation.fsh b/input/fsh/StructureDefinition.PhdRtsaObservation.fsh index b8cd36f..95a54f5 100644 --- a/input/fsh/StructureDefinition.PhdRtsaObservation.fsh +++ b/input/fsh/StructureDefinition.PhdRtsaObservation.fsh @@ -11,18 +11,17 @@ Description: "Observations from a PHD where the measurement is a sample array." * ^comment = "Used for sample array (waveform) observations from Personal Health Devices" * value[x] only SampledData * ^comment = "The PhdRtsaObservation is typically used for reporting waveform type data such as an ECG trace, spirometer exhalation rates, pulse oximetry pleth (plethysmograph) waves, etc., though it can be used to report any set of numeric measurements that are periodic. The periodicity is important as the timestamps of each individual entry is known from the start time and the period. Since the amount of data to be transmitted can be large, the data is scaled in such a way to minimize the number of bits taken up by each entry (in practice limited to 8, 16 or 32 bits). This scaling information is sent along with the start time and period in order for the receiver to recover the original data and to obtain the timestamp of each data point. In theory, this data could be sent using a large phdNumericObservation type resources at a much greater cost in bandwidth." - * origin + * origin obeys unit-system-code-coherent * ^comment = "The data sent in the ACOM sample array is also scaled. Thus with the proper setting of the `valueSampledData.origin.value` and `valueSampledData.factor`, the data from the IEEE PHD device can be placed into the `data[i]` array without modification." * value 1.. * ^short = "Intercept value (with implicit precision)" * ^definition = "The intercept value with the precision of the data as determined by the device." * system 1.. - * system = "http://unitsofmeasure.org" - * ^short = "The UCUM coding system" - * ^definition = "The identification of the UCUM coding system that provides the coded form of the unit." + * obeys system-is-mdc-or-ucum * code 1.. - * ^definition = "The unit code." - * ^comment = "The UCUM code translated from the MDC Unit Code attribute." + * code from PhdUnitCodeVS (required) + * code ^definition = "The UCUM or MDC code for the units." + * code ^comment = "The UCUM or MDC code translated from the MDC Unit Code attribute." * factor 1.. * ^short = "The scale factor" * dimensions diff --git a/input/fsh/ValueSet.PhdUnitCodeVS.fsh b/input/fsh/ValueSet.PhdUnitCodeVS.fsh new file mode 100644 index 0000000..e2b2ab0 --- /dev/null +++ b/input/fsh/ValueSet.PhdUnitCodeVS.fsh @@ -0,0 +1,12 @@ +Alias: $Mdc = urn:iso:std:iso:11073:10101 +Alias: $Ucum = http://unitsofmeasure.org + +ValueSet: PhdUnitCodeVS +Id: PhdUnitCodeVS +Title: "PHD Unit Codes" +Description: "Unit codes for PHD numeric observations from either MDC or UCUM." +* ^url = "http://hl7.org/fhir/uv/phd/ValueSet/PhdUnitCodeVS" +* ^status = #active +* ^experimental = false +* include codes from system $Mdc +* include codes from valueset http://hl7.org/fhir/ValueSet/ucum-units diff --git a/input/ignoreWarnings.txt b/input/ignoreWarnings.txt index 8883f86..9bfeb99 100644 --- a/input/ignoreWarnings.txt +++ b/input/ignoreWarnings.txt @@ -82,3 +82,6 @@ The link '../StructureDefinition-SimpleAlerting.sch' for "Schematron" cannot be The link '../StructureDefinition-SimpleAlerting.xlsx' for "Excel" cannot be resolved The link '../StructureDefinition-SimpleAlerting.csv' for "CSV" cannot be resolved The