-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update Location feature for better accuracy #288
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…mapping logic to use exact match
…erties. Remove support for name based export filtering regarding locations since names no longer likely to be unique
…ue to location matches
…ts in the data model, mark it as inactive instead of deleting
… CSV, for updating purposes
…to parallel the formatting in the data
ajbarnes
commented
Mar 20, 2024
va_explorer/va_data_management/management/commands/load_locations.py
Outdated
Show resolved
Hide resolved
va_explorer/va_data_management/management/commands/load_locations.py
Outdated
Show resolved
Hide resolved
va_explorer/va_data_management/management/commands/refresh_locations.py
Outdated
Show resolved
Hide resolved
va_explorer/va_data_management/management/commands/refresh_locations.py
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Users were observing that some VA locations were either not being matched, or worse, being matched to an incorrect location. To investigate, the location logic was pulled into a sandbox and run with test data. With the baseline logic, reporting of these test results (raw province, district, hospital compared against the location assigned to a VA) indicated:
where
Looking into the causes, it was decided that the hospital list used to initialize locations within VA Explorer was outdated, the location matching logic should be updated to use exact match instead of fuzzy match now that processes have matured, and that location ingest needed new features to handle hospitals that previously submitted VAs but now only exist historically. Additionally, a closer look at the underlying data revealed a few data quality issues with historical VAs that prevented proper assignment.
After updating the logic for location matching, re-implementing load_locations to handle new hospital lists (ex. active vs inactive column to provide info on if facility should be providing new VAs or not), re-running the sandbox reporting revealed significant improvements:
further, simulating the proposed fixes to the underlying test data and then using that instead of the raw test data in this sandbox comparison gave an expected 100% match:
At a high level, in this PR:
load_locations
now takes a simple list of hospitals with supporting metadata (i.e["province", "district", "key", "name", "status"]
)load_locations
automatically parses all the hospitals out into a tree datastructure and then performs the logic to turn theanytree
datastructure into thedjango-treebeard
style tree that we store in our database.load_locations
with it adds a new hospital and this creation handles the edge case of duplicate rows by ignoring the duplicateload_locations
againbuild_location_mapper
(and thus 0 fuzzy_match) but use the newLocation.key
property to create a an exact mapping of the hospital XML value to the actual name straight from the database and theLocation.path_string
property to handle duplicates (same hospital name in different geographies; example: 'other' hospital existing in multiple places)