Make validator URL configurable, so we can use a external Validator / API instead of the internal Docker service / HAPI instance

This commit is contained in:
2026-05-18 16:00:03 +02:00
parent 79579ec82a
commit 3f37961a85
+10 -3
View File
@@ -9,8 +9,12 @@ from tqdm.auto import tqdm
class Validator(): class Validator():
def __init__(self, fhir_base_url=None): def __init__(self, fhir_base_url=None):
self.fhir_base_url = fhir_base_url
self.validator_api_url = 'http://fhir-validation-server:8080/fhir/{{resource_type}}/$validate'
if (os.environ.get('FHIR_VALIDATION_VALIDATOR_API_URL')):
self.validator_api_url = os.environ.get('FHIR_VALIDATION_VALIDATOR_API_URL')
self.fhir_base_url = fhir_base_url
if not self.fhir_base_url: if not self.fhir_base_url:
self.fhir_base_url = os.environ.get('FHIR_VALIDATION_DATASOURCE_BASEURL') self.fhir_base_url = os.environ.get('FHIR_VALIDATION_DATASOURCE_BASEURL')
@@ -37,8 +41,11 @@ class Validator():
else: else:
data = json.dumps(resource) data = json.dumps(resource)
# todo: use environment variable and set it in docker-compose validator_api_url = self.validator_api_url
r = requests.post('http://fhir-validation-server:8080/fhir/' + resource_type + '/$validate', headers=headers, validator_api_url = validator_api_url.replace('{{resource_type}}', resource_type)
validator_api_url = validator_api_url.replace('{{ resource_type }}', resource_type)
r = requests.post(validator_api_url, headers=headers,
data=data) data=data)
outcome = r.json() outcome = r.json()
return outcome return outcome