This is a typescript module used to test HL7 FHIR resources using IOPS-FHIR-Validation-Service
Current status of IOPS-FHIR-Validation-Service
The following software are required but are preinstalled on the GitHub ubuntu runner:
Running instance of the IOPS-FHIR-Validation-Service
Create a directory for your tests.
Create a folder for you tests called Examples
.
Clone this repo git clone [email protected]:NHSDigital/IOPS-FHIR-Test-Scripts.git
Run the tests via npm test
The test folder can be changed via the examples
parameter, e.g.
npm test -- --examples=../ExamplesTest
The tests can also be run against a series of folders laid out in a set way. This uses the source
parameter, e.g.
npm test -- --source='../NHSDigital-FHIR-ImplementationGuide/
This parameter with search for the following sub folders in the supplied path.
- CapabilityStatement - Note: To test against specific profiles, e.g. UK Core, this needs to be present. See UK Core for the Asset
- CodeSystem
- ConceptMap
- Examples
- MessageDefinition
- NamingSystem
- ObservationDefinition
- OperationDefinition
- Questionnaire
- SearchParameter
- StructureDefinition
- ValueSet
The validation-service-fhir-r4 can also be configured using this project. At present this is designed to be used in the testing of NHS Digital HL7 FHIR Implementation Guides using github workflows. This is done via
cd validation && npm start
Examples of use within a workflow can be found:
- https://github.com/NHSDigital/NHSDigital-FHIR-ImplementationGuide/blob/master/.github/workflows/FHIRValidation.yml
- https://github.com/NHSDigital/NHSDigital-FHIR-Medicines-ImplementationGuide/blob/master/.github/workflows/integration.yml
It is possible to set the following options within your FHIR repository:
strict-validation - Boolean (default:false): set to true for all warnings to be promoted to errors, false to allow validation to pass with warnings present.
igonore-folders - list (default:[]): a list of all folders to ignore that do not contain FHIR resources. All folders starting with .
will be automatically ignored.
igonore-files - list (default:[]): a list of all json or xml files to be ignored. fhirpkg.lock.json
, package.json
, options.json
will be automatically ignored.
error-if-metaProfile-present - Boolean (default:true): IG best practice states "Avoid declaring meta.profile in your examples unless there’s an expectation...". Setting this attribute to true will cause the validator to error if meta.profile is found within an example.
The file created will need to be named options.json
and contain the following:
{
"strict-validation": false,
"ignore-folders": [],
"ignore-files": [],
"error-if-metaProfile-present": true
}
Important: The options.json
will need to be excluded within the Simplifier project. See Simplifier GitHub Integration for more details.
This action checks a Simplifier implementation guide for spelling, http errors and invalid links. More information can be found within the IGPageContentValidator folder.
The action checks the quality of FHIR assets as per the UK Core / NHSE Design and Development approach. More infomration can be found within the [QualityControlChecker]https://github.com/NHSDigital/IOPS-FHIR-Test-Scripts/tree/main/QualityControlChecker) folder.
Package-Test-Runner
Checks NHSE assets for conformance to specific UKCore packages. Useful to find breaking changes when new UKCore packages are created. Works on manual workflow run. Change packagename
& packageversion
within the action.
masterfhirvalidation
Validates FHIR assets to ensure conformance to FHIR and checks examples are valid and all codes within them are correct as per the ontoserver. Works on push from FHIR Repo.
testingbranch
used to test the latest validator against a test suite (currently in progress)
validator-test
errorChecker - Checks for html errors in Simplifier IGs. Works on push to this repo
linkChecker - Checks for url errors in Simplifier IGs. Works on push to this repo
spellChecker - Checks for spelling errors in Simplifier IGs. Works on push to this repo
QualityControlChecker - Checks for spelling and conformance of FHIR assets. Works on push to external FHIR repos
The testingbranch.yml creates an action to test the updated validator. These use the folder Examples which are split into examples that should either pass or fail. These examples are tested within the /src/vaidator.test.ts file.
This holds the code for converting xml into json, testing assets, and creating or ignoring custom errors.
These are the workflows for the validator actions in a human readble format.
Runs on:
Push from FHIR repo e.g. FHIR-R4-UKCORE-STAGING-MAIN with ontoserver credentials
Check out IOPS-Validation
Adds IOPS-FHIR-Test-Scripts as folder inside FHIR-R4-UKCORE-STAGING-MAIN folder in the local ubuntu machine.
Check out validation-service-fhir-r4
Adds IOPS-FHIR-Validation-Service as folder inside FHIR-R4-UKCORE-STAGING-MAIN folder in the local ubuntu machine.
Install npm
Install npm in IOPS-FHIR-Test-Scripts folder
Configure FHIR Validator
npm start
in IOPS-FHIR-Test-Scripts folder (configures FHIR validator using ontoserver credentials). The start
is defined in package.json as "ts-node src/configureValidator.ts"
Build FHIR Validator
Runs mvn clean install
inside IOPS-FHIR-Test-Scripts
Clean: remove target folder
Package: Follows the lifecycle phase validate >> compile >> test (optional) >> package
(for reference install
: validate >> compile >> test (optional) >> package >> verify >> install
)
Run FHIR Validator
nohup java -jar validation-service-fhir-r4/target/fhir-validator.jar --<params>
nohup
: no hang up is a command in Linux systems that keep processes running even after exiting the shell or terminal
java -jar
: run the jar file passing the parameters listed after each --
Run Test
Run npm test
inside IOPS-FHIR-Test-Scripts folder. The test
is defined in package.json as jest --runInBand src/validate.test.ts