Skip to content

Commit

Permalink
Use join to build the resource_url
Browse files Browse the repository at this point in the history
  • Loading branch information
Wambere committed Feb 5, 2024
1 parent 5c176cb commit 4c8d615
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions importer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,18 +461,16 @@ def build_org_affiliation(resources, resource_list):
# This function is used to Capitalize the 'resource_type'
# and remove the 's' at the end, a version suitable with the API
def get_valid_resource_type(resource_type):
logging.info("Modify the string resource_type")
logging.debug("Modify the string resource_type")
modified_resource_type = resource_type[0].upper() + resource_type[1:-1]
return modified_resource_type


# This function gets the current resource version from the API
def get_resource_version(resource_id, resource_type):
logging.info("Getting resource version")
logging.debug("Getting resource version")
modified_resource_type = get_valid_resource_type(resource_type)
resource_url = (
config.fhir_base_url + "/" + modified_resource_type + "/" + resource_id
)
resource_url = "/".join([config.fhir_base_url, modified_resource_type, resource_id])
response = handle_request("GET", "", resource_url)
json_response = json.loads(response[0])
return json_response["meta"]["versionId"]
Expand Down Expand Up @@ -768,11 +766,10 @@ def delete_resource(resource_type, resource_id, cascade):
else:
cascade = ""

r = handle_request(
"DELETE",
"",
config.fhir_base_url + "/" + resource_type + "/" + resource_id + cascade,
resource_url = "/".join(
[config.fhir_base_url, resource_type, resource_id + cascade]
)
r = handle_request("DELETE", "", resource_url)
logging.info(r.text)


Expand Down

0 comments on commit 4c8d615

Please sign in to comment.