From ce00ec245159cbb269051adb693bca3eca07e255 Mon Sep 17 00:00:00 2001 From: Wambere Date: Mon, 26 Feb 2024 13:45:24 +0300 Subject: [PATCH] Update export_resources_function --- importer/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/importer/main.py b/importer/main.py index 9ade2135..81568996 100644 --- a/importer/main.py +++ b/importer/main.py @@ -873,12 +873,16 @@ def write_csv(data, resource_type, fieldnames): csv_writer.writerows(data) +def get_base_url(): + return config.fhir_base_url + + # This function exports resources from the API to a csv file -def export_resources_to_csv(resource_type, parameter, value, batch_size): - resource_type = get_valid_resource_type(resource_type) - resource_url = "/".join([config.fhir_base_url, resource_type]) +def export_resources_to_csv(resource_type, parameter, value, limit): + base_url = get_base_url() + resource_url = "/".join([str(base_url), resource_type]) if len(parameter) > 0: - resource_url = resource_url + "?" + parameter + "=" + value + "&_count=" + str(batch_size) + resource_url = resource_url + "?" + parameter + "=" + value + "&_count=" + str(limit) response = handle_request("GET", "", resource_url) if response[1] == 200: resources = json.loads(response[0])