diff --git a/app.py b/app.py index 5347cb8..6aff9f0 100644 --- a/app.py +++ b/app.py @@ -1907,22 +1907,22 @@ def proxy_hapi(subpath): return jsonify({'resourceType': 'OperationOutcome', 'issue': [{'severity': 'error', 'code': 'exception', 'diagnostics': 'An unexpected error occurred within the FHIR proxy.', 'details': {'text': str(e)}}]}), 500 -@app.route('/api/stream-retrieve', methods=['POST']) +@app.route('/api/stream-retrieve', methods=['GET']) def stream_retrieve_bundles(): """ Handles streaming FHIR bundle retrieval. This endpoint directly calls the service function, bypassing the proxy to avoid conflicts. It receives the target URL, - resources, and other parameters from the front-end via a JSON body. + resources, and other parameters from the front-end via URL query parameters. """ def generate_stream(): with app.app_context(): - # Extract parameters from JSON body - data = request.json - fhir_server_url = data.get('fhir_server_url') - resources = data.get('resources') - validate_references = data.get('validate_references', False) - fetch_reference_bundles = data.get('fetch_reference_bundles', False) + # Extract parameters from query string + fhir_server_url = request.args.get('fhir_server_url') + resources = request.args.getlist('resources') + validate_references = request.args.get('validate_references', 'false').lower() == 'true' + fetch_reference_bundles = request.args.get('fetch_reference_bundles', 'false').lower() == 'true' + # Extract authentication headers auth_token = request.headers.get('Authorization') auth_type = 'bearer' if auth_token and auth_token.lower().startswith('bearer') else 'basic' if auth_token and auth_token.lower().startswith('basic') else 'none' diff --git a/services.py b/services.py index 4361b4e..87818cf 100644 --- a/services.py +++ b/services.py @@ -4584,7 +4584,8 @@ def retrieve_bundles(fhir_server_url, resources, output_zip, validate_references yield json.dumps({"type": "info", "message": "Reference fetching OFF"}) + "\n" # Determine the final base URL for requests. - final_base_url = fhir_server_url.rstrip('/') if fhir_server_url and fhir_server_url != '/fhir' else app.config.get('HAPI_FHIR_URL', 'http://localhost:8080/fhir') + from flask import current_app + final_base_url = fhir_server_url.rstrip('/') if fhir_server_url and fhir_server_url != '/fhir' else current_app.config.get('HAPI_FHIR_URL', 'http://localhost:8080/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') diff --git a/templates/retrieve_split_data.html b/templates/retrieve_split_data.html index c930322..3fe7ff4 100644 --- a/templates/retrieve_split_data.html +++ b/templates/retrieve_split_data.html @@ -27,7 +27,7 @@ {% endif %} -