FHIR Shorthand Validator Documentation Release 0.2.2 Gregor Lichtner Dec 10, 2021
FHIR Shorthand ValidatorDocumentation
Release 0.2.2
Gregor Lichtner
Dec 10, 2021
CONTENTS:
1 FHIR Shorthand Validator 11.1 Quickstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.5 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Installation 52.1 Stable release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 From sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 fsh_validator 73.1 fsh_validator package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 Contributing 94.1 Types of Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2 Get Started! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.3 Pull Request Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.4 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.5 Deploying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 Credits 135.1 Development Lead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.2 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6 History 156.1 0.2.2 (2021-11-10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.2 0.2.1 (2021-11-11) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.3 0.2.0 (2021-11-11) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.4 0.1.9 (2021-11-09) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.5 0.1.8 (2021-11-08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156.6 0.1.7 (2021-11-05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.7 0.1.6 (2021-11-05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.8 0.1.5 (2021-11-03) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.9 0.1.4 (2021-11-02) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.10 0.1.3 (2021-10-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.11 0.1.2 (2021-10-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.12 0.1.1 (2021-10-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.13 0.1.0 (2021-10-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
7 Indices and tables 17
i
Python Module Index 19
Index 21
ii
CHAPTER
ONE
FHIR SHORTHAND VALIDATOR
FHIR Shorthand Validator (fsh-validator) unshortens fsh input and validates all defined instances against their profiles.
fsh-validator is an interface to SUSHI and the HL7 FHIR Validator running the following workflow:
1. Run SUSHI to unshorten fsh files to structure definitions, instances, value sets etc.
2. Detect all defined profiles, valuesets and instances.
3. Validate all defined instances using the official HL7 FHIR Validator against their profiles.
For the full documentation see https://fsh-validator.readthedocs.io.
1.1 Quickstart
Install the latest fsh-validator:
pip install -U fsh-validator
Or directly from github repository:
pip install -U git+https://github.com/glichtner/fsh-validator
Run fsh-validator in your fsh project path:
$ fsh-validator --all
1
FHIR Shorthand Validator Documentation, Release 0.2.2
1.2 Parameters
usage: fsh-validator [-h] [--all] [--subdir SUBDIR] [--validator-path PATH_VALIDATOR] [--→˓verbose] [--no-sushi] [--log-path LOG_PATH] [filename [filename ...]]
positional arguments:filename fsh file names (basename only - no path)
optional arguments:-h, --help show this help message and exit--all if set, all detected profiles will be validated--subdir SUBDIR Specifies the subdirectory (relative to input/fsh/) in which to␣
→˓search for profiles if --all is set--validator-path PATH_VALIDATOR
path to validator--verbose Be verbose--no-sushi Do not run sushi before validating--log-path LOG_PATH log file path - if supplied, log files will be written
1.3 Configuration
fsh-validator reads an optional configuration file .fsh-validator.yml in the base directory of the sushi project. Theconfiguration file currently supports the following parameters:
exclude_code_systems: A list of code systems to exclude from validation. If an instance contains a codefrom a code system in this list, the instance will be skipped. This is useful to exclude code systemsthat are not yet supported by the validator or that may cause problems when validating (e.g. ICD-10-gm) The code systems are specified by their canonical URI. The default is to not exclude any codesystems.
exclude_resource_types: A list of resource types to exclude from validation. If an instance implements aresource of a type in this list, the instance will be skipped. This is useful to exclude resources that arenot yet supported by the validator or that may cause problems when validating. The resource typesare specified by their canonical name (e.g. “Bundle”). The default is to not exclude any resourcetypes.
Example configuration file:
exclude_code_systems:- http://hl7.org/fhir/sid/icd-10-cm- http://fhir.de/CodeSystem/bfarm/icd-10-gm
exclude_resource_types:- Bundle- OperationOutcome
2 Chapter 1. FHIR Shorthand Validator
FHIR Shorthand Validator Documentation, Release 0.2.2
1.4 Examples
Example call to validate a *single* profile
$ cd ExampleIG/$ fsh-validator input/fsh/p-thoracic-drainage.fsh
Example call to validate *all* profiles
The following call validates all profiles in the subdirectory “vaccination/” and writes the results of the validation logfiles in the directory logs/.
$ cd ExampleIG/$ fsh-validator --all --subdir vaccination/ --log-path logs/
This is equivalent to calling:
$ fsh-validator input/fsh/vaccination/*.fsh --log-path logs/
1.5 Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
1.4. Examples 3
FHIR Shorthand Validator Documentation, Release 0.2.2
4 Chapter 1. FHIR Shorthand Validator
CHAPTER
TWO
INSTALLATION
2.1 Stable release
To install FHIR Shorthand Validator, run this command in your terminal:
$ pip install fsh-validator
This is the preferred method to install FHIR Shorthand Validator, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
2.2 From sources
The sources for FHIR Shorthand Validator can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/glichtner/fsh-validator
Or download the tarball:
$ curl -OJL https://github.com/glichtner/fsh-validator/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
5
FHIR Shorthand Validator Documentation, Release 0.2.2
6 Chapter 2. Installation
CHAPTER
THREE
FSH_VALIDATOR
3.1 fsh_validator package
3.1.1 Submodules
3.1.2 fsh_validator.cli module
3.1.3 fsh_validator.fsh_validator module
3.1.4 fsh_validator.fshpath module
FSH file paths representations.
class fsh_validator.fshpath.FshPath(filename)Bases: object
FSH file paths representations.
absolute()Resolve relative to absolute path.
Return type Path
Returns Absolute filename
exists()Return whether the file represented by this class exists.
Return type bool
Returns True if file exists, False otherwise
fsh_base_path()Get the FSH base path (without input/fsh/).
Return type Path
Returns FSH base path (without input/fsh/)
fsh_name()Get the FSH filename (relative to input/fsh/).
Return type Optional[Path]
Returns FSH filename (relative to input/fsh/)
fsh_parts()Process a filename into the fsh base path (without input/fsh/) and the fsh filename relative to input/fsh/.
7
FHIR Shorthand Validator Documentation, Release 0.2.2
Return type Tuple[Path, Optional[Path]]
Returns Tuple of base path (without input/fsh/) and filename (relative to input/fsh/ folder)
3.1.5 Module contents
Top-level package for FHIR Shorthand Validator.
8 Chapter 3. fsh_validator
CHAPTER
FOUR
CONTRIBUTING
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
4.1 Types of Contributions
4.1.1 Report Bugs
Report bugs at https://github.com/glichtner/fsh-validator/issues.
If you are reporting a bug, please include:
• Your operating system name and version.
• Any details about your local setup that might be helpful in troubleshooting.
• Detailed steps to reproduce the bug.
4.1.2 Fix Bugs
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants toimplement it.
4.1.3 Implement Features
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open towhoever wants to implement it.
4.1.4 Write Documentation
FHIR Shorthand Validator could always use more documentation, whether as part of the official FHIR ShorthandValidator docs, in docstrings, or even on the web in blog posts, articles, and such.
9
FHIR Shorthand Validator Documentation, Release 0.2.2
4.1.5 Submit Feedback
The best way to send feedback is to file an issue at https://github.com/glichtner/fsh-validator/issues.
If you are proposing a feature:
• Explain in detail how it would work.
• Keep the scope as narrow as possible, to make it easier to implement.
• Remember that this is a volunteer-driven project, and that contributions are welcome :)
4.2 Get Started!
Ready to contribute? Here’s how to set up fsh-validator for local development.
1. Fork the fsh-validator repo on GitHub.
2. Clone your fork locally:
$ git clone [email protected]:your_name_here/fsh-validator.git
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set upyour fork for local development:
$ mkvirtualenv fsh-validator$ cd fsh-validator/$ python setup.py develop
4. Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing otherPython versions with tox:
$ flake8 fsh-validator tests$ python setup.py test or pytest$ tox
To get flake8 and tox, just pip install them into your virtualenv.
6. Commit your changes and push your branch to GitHub:
$ git add .$ git commit -m "Your detailed description of your changes."$ git push origin name-of-your-bugfix-or-feature
7. Submit a pull request through the GitHub website.
10 Chapter 4. Contributing
FHIR Shorthand Validator Documentation, Release 0.2.2
4.3 Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function witha docstring, and add the feature to the list in README.rst.
3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check https://travis-ci.com/glichtner/fsh-validator/pull_requests and make sure that the tests pass for all supported Python versions.
4.4 Tips
To run a subset of tests:
$ python -m unittest tests.test_fsh-validator
4.5 Deploying
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry inHISTORY.rst). Then run:
$ bump2version patch # possible: major / minor / patch$ git push$ git push --tags
Travis will then deploy to PyPI if tests pass.
4.3. Pull Request Guidelines 11
FHIR Shorthand Validator Documentation, Release 0.2.2
12 Chapter 4. Contributing
CHAPTER
FIVE
CREDITS
5.1 Development Lead
• Gregor Lichtner @glichtner
5.2 Contributors
None yet. Why not be the first?
13
FHIR Shorthand Validator Documentation, Release 0.2.2
14 Chapter 5. Credits
CHAPTER
SIX
HISTORY
6.1 0.2.2 (2021-11-10)
• Fixed processing of bundle resources
• Fixed processing of profiles that have parent profiles defined in the same project
• Added possibility to exclude certain types of resources from validation (via .fsh-validator.yml file)
• Added exclusion of abstract profiles from validation
6.2 0.2.1 (2021-11-11)
• Improved output messages
6.3 0.2.0 (2021-11-11)
• Added possibility to excluding specific code systems from validation
6.4 0.1.9 (2021-11-09)
• Added workaround function for invalid SUSHI outputs (duplicated codings in MII Laboratory Observation Pro-file)
6.5 0.1.8 (2021-11-08)
• Added support for extensions
15
FHIR Shorthand Validator Documentation, Release 0.2.2
6.6 0.1.7 (2021-11-05)
• Added requirements to setup.py
6.7 0.1.6 (2021-11-05)
• Reading FHIR version to use in validator from sushi-config.yaml
6.8 0.1.5 (2021-11-03)
• Fixed validation of questionnaires
6.9 0.1.4 (2021-11-02)
• Fixed instances/profiles regex for aliases
6.10 0.1.3 (2021-10-25)
• Fixed FshPath
6.11 0.1.2 (2021-10-25)
• Added requirements to setup.py
6.12 0.1.1 (2021-10-25)
• Fix python package
6.13 0.1.0 (2021-10-25)
• First release on PyPI.
16 Chapter 6. History
CHAPTER
SEVEN
INDICES AND TABLES
• genindex
• modindex
• search
17
FHIR Shorthand Validator Documentation, Release 0.2.2
18 Chapter 7. Indices and tables
PYTHON MODULE INDEX
ffsh_validator, 8fsh_validator.fshpath, 7
19
FHIR Shorthand Validator Documentation, Release 0.2.2
20 Python Module Index
INDEX
Aabsolute() (fsh_validator.fshpath.FshPath method), 7
Eexists() (fsh_validator.fshpath.FshPath method), 7
Ffsh_base_path() (fsh_validator.fshpath.FshPath
method), 7fsh_name() (fsh_validator.fshpath.FshPath method), 7fsh_parts() (fsh_validator.fshpath.FshPath method), 7fsh_validator
module, 8fsh_validator.fshpath
module, 7FshPath (class in fsh_validator.fshpath), 7
Mmodule
fsh_validator, 8fsh_validator.fshpath, 7
21