Compare commits

...

4 Commits

Author SHA1 Message Date
11e8569c56 patch 2025-05-13 14:03:29 +10:00
f150e7baaf path patch 2025-05-13 14:00:48 +10:00
f91af1148d patch 2025-05-13 13:43:23 +10:00
179982dedc Dynamic Hostname fix
Patch for dynamic host names
2025-05-13 12:37:04 +10:00
5 changed files with 15 additions and 7 deletions

View File

@ -156,7 +156,9 @@ echo Updating docker-compose.yml with APP_MODE=%APP_MODE%...
echo - FLASK_APP=app.py
echo - FLASK_ENV=development
echo - NODE_PATH=/usr/lib/node_modules
echo - APP_MODE=%APP_MODE%
echo - APP_MODE=%APP_MODE%
echo - APP_BASE_URL=http://localhost:5000
echo - HAPI_FHIR_URL=http://localhost:8080/fhir
echo command: supervisord -c /etc/supervisord.conf
) > docker-compose.yml.tmp

8
app.py
View File

@ -55,6 +55,8 @@ app.config['API_KEY'] = os.environ.get('API_KEY', 'your-fallback-api-key-here')
app.config['VALIDATE_IMPOSED_PROFILES'] = True
app.config['DISPLAY_PROFILE_RELATIONSHIPS'] = True
app.config['UPLOAD_FOLDER'] = '/app/static/uploads' # For GoFSH output
app.config['APP_BASE_URL'] = os.environ.get('APP_BASE_URL', 'http://localhost:5000')
app.config['HAPI_FHIR_URL'] = os.environ.get('HAPI_FHIR_URL', 'http://localhost:8080/fhir')
CONFIG_PATH = '/usr/local/tomcat/conf/application.yaml'
# Register blueprints immediately after app setup
@ -1317,10 +1319,10 @@ def proxy_hapi(subpath):
logger.info(f"Proxy target identified from header: {final_base_url}")
except ValueError as e:
logger.warning(f"Invalid URL in X-Target-FHIR-Server header: '{target_server_header}'. Falling back. Error: {e}")
final_base_url = "http://localhost:8080/fhir"
final_base_url = current_app.config['HAPI_FHIR_URL'].rstrip('/')
logger.debug(f"Falling back to default local HAPI due to invalid header: {final_base_url}")
else:
final_base_url = "http://localhost:8080/fhir"
final_base_url = current_app.config['HAPI_FHIR_URL'].rstrip('/')
logger.debug(f"No target header found, proxying to default local HAPI: {final_base_url}")
# Construct the final URL for the target server request
@ -1424,7 +1426,7 @@ def load_ig_to_hapi():
resource_id = resource.get('id')
if resource_type and resource_id:
response = requests.put(
f"http://localhost:8080/fhir/{resource_type}/{resource_id}",
f"{current_app.config['HAPI_FHIR_URL'].rstrip('/')}/{resource_type}/{resource_id}",
json=resource,
headers={'Content-Type': 'application/fhir+json'}
)

View File

@ -16,5 +16,7 @@ services:
- FLASK_APP=app.py
- FLASK_ENV=development
- NODE_PATH=/usr/lib/node_modules
- APP_MODE=lite
- APP_MODE=lite
- APP_BASE_URL=http://localhost:5000
- HAPI_FHIR_URL=http://localhost:8080/fhir
command: supervisord -c /etc/supervisord.conf

View File

@ -1616,7 +1616,7 @@ def validate_resource_against_profile(package_name, version, resource, include_d
# Attempt HAPI validation if a profile is specified
if result['profile']:
try:
hapi_url = f"http://localhost:8080/fhir/{resource['resourceType']}/$validate?profile={result['profile']}"
hapi_url = f"{current_app.config['HAPI_FHIR_URL'].rstrip('/')}/{resource['resourceType']}/$validate?profile={result['profile']}"
response = requests.post(
hapi_url,
json=resource,
@ -3766,7 +3766,7 @@ def retrieve_bundles(fhir_server_url, resources, output_zip, validate_references
# --- Determine Base URL and Headers for Proxy ---
base_proxy_url = 'http://localhost:5000/fhir' # Always target the proxy endpoint
base_proxy_url = f"{current_app.config['APP_BASE_URL'].rstrip('/')}/fhir"
headers = {'Accept': 'application/fhir+json, application/fhir+xml;q=0.9, */*;q=0.8'}
is_custom_url = fhir_server_url != '/fhir' and fhir_server_url is not None and fhir_server_url.startswith('http')
if is_custom_url:

View File

@ -195,6 +195,8 @@ services:
- FLASK_ENV=development
- NODE_PATH=/usr/lib/node_modules
- APP_MODE=${APP_MODE}
- APP_BASE_URL=http://localhost:5000
- HAPI_FHIR_URL=http://localhost:8080/fhir
command: supervisord -c /etc/supervisord.conf
EOF