Skip to content

Commit

Permalink
Update export_resources_function
Browse files Browse the repository at this point in the history
  • Loading branch information
Wambere committed Feb 26, 2024
1 parent d02e178 commit ce00ec2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions importer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit ce00ec2

Please sign in to comment.