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:
+10
-3
@@ -9,8 +9,12 @@ from tqdm.auto import tqdm
|
||||
|
||||
class Validator():
|
||||
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:
|
||||
self.fhir_base_url = os.environ.get('FHIR_VALIDATION_DATASOURCE_BASEURL')
|
||||
|
||||
@@ -37,8 +41,11 @@ class Validator():
|
||||
else:
|
||||
data = json.dumps(resource)
|
||||
|
||||
# todo: use environment variable and set it in docker-compose
|
||||
r = requests.post('http://fhir-validation-server:8080/fhir/' + resource_type + '/$validate', headers=headers,
|
||||
validator_api_url = self.validator_api_url
|
||||
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)
|
||||
outcome = r.json()
|
||||
return outcome
|
||||
|
||||
Reference in New Issue
Block a user