Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to process tract without address in FHIR ETL #331

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

sallybg
Copy link
Contributor

@sallybg sallybg commented Nov 28, 2023

Previously, the process_location function, called as part of the etl fhir function, assumed that the encounter location was an address with a tract as a parent location. Sample metadata received as part of KP2023 do not contain addresses, only census tracts, so process_location now handles encounter locations that are just tracts with no address and no parent location.

@sallybg sallybg requested a review from a team as a code owner November 28, 2023 22:06
tract = get_tract(location)
tract_hierarchy = tract.hierarchy
tract_id = tract.id
except:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should generally try to avoid blanket except statements. Are we trying to catch the AssertionError here in the case that the tract is unknown? Maybe we are also trying to catch the AttributeError in the case of tract.hierarchy not being defined?

@@ -860,7 +869,8 @@ def process_address(location: Location, tract_hierarchy: str) -> Optional[Any]:
upsert_encounter_location(db,
encounter_id = encounter_id,
relation = relation,
location_id = address.id)
location_id = address.id if address else tract_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just use tract.id directly here instead of creating a new tract_id variable.

@sallybg sallybg merged commit 6c3c1a9 into master Dec 4, 2023
4 checks passed
@sallybg sallybg deleted the process_tract_only branch December 6, 2023 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants