Skip to content

Commit

Permalink
add read and delete methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiagoTrabach committed Aug 1, 2023
1 parent 24466b2 commit 31f7c2f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions fhir_utils/healthcare_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,30 @@ def update(self, resource: str, resource_id: str, body: dict):
body = body)

request.headers["content-type"] = self.header

response = request.execute()

print(f"Updated {resource} resource with ID {resource_id}:\n {json.dumps(response, indent=2)}")

return response


def read(self):
return None
def read(self, resource: str, resource_id: str):
fhir_resource_path = f"{self.fhir_store_name}/fhir/{resource}/{resource_id}"

request = self.client.projects().locations().datasets().fhirStores().fhir().read(name = fhir_resource_path)

response = request.execute()
print(f"Got contents of {resource} resource with ID {resource_id}:\n", json.dumps(response, indent=2),)

return response


def delete(self):
return None
def delete(self, resource: str, resource_id: str):
fhir_resource_path = f"{self.fhir_store_name}/fhir/{resource}/{resource_id}"

request = self.client.projects().locations().datasets().fhirStores().fhir().delete(name = fhir_resource_path)

response = request.execute()
print(f"Deleted {resource} resource with ID {resource_id}.")

return response

0 comments on commit 31f7c2f

Please sign in to comment.