Skip to content

Commit

Permalink
FI-2701: Migrate to HL7 validator wrapper (#4)
Browse files Browse the repository at this point in the history
* FI-2701: migrate to HL7 validator wrapper

* missed a couple things

* Update profile/version logic

* rubocop fixes

* Update resources to remove relative links

* update lockfile and dockerfile fix

* update lockfile again after rebase
  • Loading branch information
dehall authored Jul 2, 2024
1 parent 3b764ae commit ca8357b
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 75 deletions.
5 changes: 3 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VALIDATOR_URL=http://localhost/validatorapi
REDIS_URL=redis://localhost:6379/0
FHIR_RESOURCE_VALIDATOR_URL=http://localhost/hl7validatorapi
REDIS_URL=redis://localhost:6379/0
FHIRPATH_URL=http://localhost/fhirpath
5 changes: 3 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REDIS_URL=redis://redis:6379/0
VALIDATOR_URL=http://validator_service:4567
INFERNO_HOST=http://localhost
FHIR_RESOURCE_VALIDATOR_URL=http://hl7_validator_service:3500
INFERNO_HOST=http://localhost
FHIRPATH_URL=http://fhirpath:6789
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VALIDATOR_URL=https://example.com/validatorapi
FHIR_RESOURCE_VALIDATOR_URL=https://example.com/validatorapi
FHIRPATH_URL=https://example.com/fhirpath
ASYNC_JOBS=false
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WORKDIR $INSTALL_PATH
ADD *.gemspec $INSTALL_PATH
ADD Gemfile* $INSTALL_PATH
ADD lib/davinci_pas_test_kit/version.rb $INSTALL_PATH/lib/davinci_pas_test_kit/version.rb
RUN gem update --system
RUN gem install bundler
# The below RUN line is commented out for development purposes, because any change to the
# required gems will break the dockerfile build process.
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
davinci_pas_test_kit (0.9.3)
inferno_core (~> 0.4.34)
inferno_core (~> 0.4.37)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -134,7 +134,7 @@ GEM
domain_name (~> 0.5)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
inferno_core (0.4.38)
inferno_core (0.4.39)
activesupport (~> 6.1.7.5)
base62-rb (= 0.3.1)
blueprinter (= 0.25.2)
Expand Down Expand Up @@ -165,7 +165,7 @@ GEM
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
jwt (2.8.1)
jwt (2.8.2)
base64
kramdown (2.4.0)
rexml
Expand All @@ -187,14 +187,14 @@ GEM
mustermann (= 1.1.2)
netrc (0.11.0)
nio4r (2.7.3)
nokogiri (1.16.5)
nokogiri (1.16.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.5-arm64-darwin)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-darwin)
nokogiri (1.16.6-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
oauth2 (1.4.11)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -238,7 +238,7 @@ GEM
netrc (~> 0.8)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (4.2.1)
rouge (4.3.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand Down
4 changes: 2 additions & 2 deletions config/PAS Test Kit Client Test Demo.postman_collection.json

Large diffs are not rendered by default.

40 changes: 36 additions & 4 deletions config/nginx.background.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,38 @@ http {
# the server will close connections after this time
keepalive_timeout 600;

location /validator {
# location /validator {
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Port $server_port;
# proxy_redirect off;
# proxy_set_header Connection '';
# proxy_http_version 1.1;
# chunked_transfer_encoding off;
# proxy_buffering off;
# proxy_cache off;
#
# proxy_pass http://fhir_validator_app;
# }

# location /validatorapi/ {
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Port $server_port;
# proxy_redirect off;
# proxy_set_header Connection '';
# proxy_http_version 1.1;
# chunked_transfer_encoding off;
# proxy_buffering off;
# proxy_cache off;
#
# proxy_pass http://validator_service:4567/;
# }
# }

location /hl7validatorapi/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
Expand All @@ -64,11 +95,12 @@ http {
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 600s;

proxy_pass http://fhir_validator_app;
proxy_pass http://hl7_validator_service:3500/;
}

location /validatorapi/ {
location /fhirpath/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
Expand All @@ -80,7 +112,7 @@ http {
proxy_buffering off;
proxy_cache off;

proxy_pass http://validator_service:4567/;
proxy_pass http://fhirpath:6789/;
}
}
}
50 changes: 33 additions & 17 deletions config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,37 @@ http {
proxy_pass http://inferno:4567;
}

location /validator {
# location /validator {
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Port $server_port;
# proxy_redirect off;
# proxy_set_header Connection '';
# proxy_http_version 1.1;
# chunked_transfer_encoding off;
# proxy_buffering off;
# proxy_cache off;
#
# proxy_pass http://fhir_validator_app;
# }

# location /validatorapi/ {
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Port $server_port;
# proxy_redirect off;
# proxy_set_header Connection '';
# proxy_http_version 1.1;
# chunked_transfer_encoding off;
# proxy_buffering off;
# proxy_cache off;
#
# proxy_pass http://validator_service:4567/;
# }

location /hl7validatorapi/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
Expand All @@ -79,23 +109,9 @@ http {
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 600s;

proxy_pass http://fhir_validator_app;
}

location /validatorapi/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_redirect off;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;

proxy_pass http://validator_service:4567/;
proxy_pass http://hl7_validator_service:3500/;
}
}
}
12 changes: 6 additions & 6 deletions config/presets/pas_ri.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion davinci_pas_test_kit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.description = 'Inferno Test Kit for the Da Vinci Prior Authorization Support IG'
spec.homepage = 'https://github.com/inferno-framework/davinci-pas-test-kit'
spec.license = 'Apache-2.0'
spec.add_runtime_dependency 'inferno_core', '~> 0.4.34'
spec.add_runtime_dependency 'inferno_core', '~> 0.4.37'
spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8'
spec.add_development_dependency 'factory_bot', '~> 6.1'
spec.add_development_dependency 'rspec', '~> 3.10'
Expand Down
40 changes: 28 additions & 12 deletions docker-compose.background.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
version: '3'
services:
validator_service:
image: infernocommunity/fhir-validator-service
# Update this path to match your directory structure
volumes:
- ./lib/davinci_pas_test_kit/igs:/home/igs
fhir_validator_app:
image: infernocommunity/fhir-validator-app
depends_on:
- validator_service
hl7_validator_service:
image: infernocommunity/inferno-resource-validator
environment:
EXTERNAL_VALIDATOR_URL: http://localhost/validatorapi
VALIDATOR_BASE_PATH: /validator
# Defines how long validator sessions last if unused, in minutes:
# Negative values mean sessions never expire, 0 means sessions immediately expire
SESSION_CACHE_DURATION: -1
volumes:
- ./lib/davinci_pas_test_kit/igs:/app/igs
# To let the service share your local FHIR package cache,
# uncomment the below line
# - ~/.fhir:/home/ktor/.fhir
# validator_service:
# image: infernocommunity/fhir-validator-service
# # Update this path to match your directory structure
# volumes:
# - ./lib/davinci_pas_test_kit/igs:/home/igs
# fhir_validator_app:
# image: infernocommunity/fhir-validator-app
# depends_on:
# - validator_service
# environment:
# EXTERNAL_VALIDATOR_URL: http://localhost/validatorapi
# VALIDATOR_BASE_PATH: /validator
fhirpath:
image: infernocommunity/fhirpath-service
ports:
- "6789:6789"
nginx:
image: nginx
volumes:
Expand All @@ -20,7 +35,8 @@ services:
- "80:80"
command: [nginx, '-g', 'daemon off;']
depends_on:
- fhir_validator_app
- hl7_validator_service
- fhirpath
redis:
image: redis
ports:
Expand Down
18 changes: 13 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
volumes:
- ./data:/opt/inferno/data
depends_on:
- validator_service
- hl7_validator_service
worker:
build:
context: ./
Expand All @@ -15,14 +15,22 @@ services:
command: bundle exec sidekiq -r ./worker.rb
depends_on:
- redis
validator_service:
hl7_validator_service:
extends:
file: docker-compose.background.yml
service: validator_service
fhir_validator_app:
service: hl7_validator_service
# validator_service:
# extends:
# file: docker-compose.background.yml
# service: validator_service
# fhir_validator_app:
# extends:
# file: docker-compose.background.yml
# service: fhir_validator_app
fhirpath:
extends:
file: docker-compose.background.yml
service: fhir_validator_app
service: fhirpath
nginx:
extends:
file: docker-compose.background.yml
Expand Down
4 changes: 2 additions & 2 deletions lib/davinci_pas_test_kit/client_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def self.test_resumes?(test)
!test.config.options[:accepts_multiple_requests]
end

validator do
url ENV.fetch('VALIDATOR_URL')
fhir_resource_validator do
igs 'hl7.fhir.us.davinci-pas#2.0.1'

exclude_message do |message|
# Messages expected of the form `<ResourceType>: <FHIRPath>: <message>`
Expand Down
4 changes: 2 additions & 2 deletions lib/davinci_pas_test_kit/generated/v2.0.1/server_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class ServerSuite < Inferno::TestSuite
request.query_parameters['use_case']
end

validator do
url ENV.fetch('VALIDATOR_URL')
fhir_resource_validator do
igs 'hl7.fhir.us.davinci-pas#2.0.1'

exclude_message do |message|
# Messages expected of the form `<ResourceType>: <FHIRPath>: <message>`
Expand Down
5 changes: 5 additions & 0 deletions lib/davinci_pas_test_kit/generator/suite_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def title
"Da Vinci PAS Server Suite #{ig_metadata.ig_version}"
end

def ig_identifier
version = ig_metadata.ig_version[1..] # Remove leading 'v'
"hl7.fhir.us.davinci-pas##{version}"
end

def ig_link
case ig_metadata.ig_version
when 'v2.0.1'
Expand Down
4 changes: 2 additions & 2 deletions lib/davinci_pas_test_kit/generator/templates/suite.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module DaVinciPASTestKit
request.query_parameters['use_case']
end

validator do
url ENV.fetch('VALIDATOR_URL')
fhir_resource_validator do
igs '<%= ig_identifier %>'

exclude_message do |message|
# Messages expected of the form `<ResourceType>: <FHIRPath>: <message>`
Expand Down
21 changes: 21 additions & 0 deletions lib/davinci_pas_test_kit/igs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Note on this IGs folder

There are three reasons why it would be necessary to put an IG package.tgz in this folder. If none of these apply, you do not need to put any files here, or can consider removing any existing files to make it clear they are unused.

## 1. Generated Test Suites
Some test kits use a "generator" to automatically generate the contents of a test suite for an IG. The IG files are required every time the test suites need to be regenerated. Examples of test kits that use this approach are the US Core Test Kit and CARIN IG for Blue Button® Test Kit.


## 2. Non-published IG
If your IG, or the specific version of the IG you want to test against, is not published, then the validator service needs to load the IG from file in order to be able to validate resources with it. The IG must be referenced in the `fhir_resource_validator` block in the test suite definition by filename, ie:

```ruby
fhir_resource_validator do
igs 'igs/filename.tgz'

...
end
```

## 3. Inferno Validator UI
The Inferno Validator UI is configured to auto-load any IGs present in the igs folder and include them in all validations. The Inferno Validator UI is currently disabled by default, so this is only relevant if you choose to re-enable it. In general, the Inferno team is currently leaving IGs in this folder even if not otherwise necessary to make it easy to re-enable the validator UI.
Loading

0 comments on commit ca8357b

Please sign in to comment.