Keep the result of stripping the SE prefix from a decision code - #223
Open
arpitjain099 wants to merge 1 commit into
Open
Keep the result of stripping the SE prefix from a decision code#223arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
get_description() calls data.replace('SE', '') without assigning it, so the
prefix is never removed and every composite decision code except SESE falls
through to 'Unknown'. SESK returns 'Unknown' while SK returns 'Substantially
Equivalent - Kit'.
decision_codes.csv contains only two-character codes, so any longer value is
the SE prefix plus a real code, which is what the length check was testing
for.
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This file contains hidden or 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
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.
get_description()inopenfda/device_clearance/transform.pydrops the return value ofstr.replace:The line above it assigns, this one does not, so the SE prefix is never actually removed and the lookup runs against the original string.
decision_codes.csvonly holds two-character codes, so a value longer than two characters is the SE prefix plus a real code, which is exactly what the length check is testing for. The effect is that every composite code other thanSESEresolves toUnknown:SESKandSKare the same clearance decision, so the description is being lost for the prefixed form. That value lands indecision_descriptionon the device clearance records.The change assigns the result.
SESEstill collapses on the line above and is unaffected, and a two-character code never enters the branch.Added
openfda/device_clearance/tests/transform_test.pycovering the plain, doubled, prefixed and unknown cases. The prefixed case fails on master:With the fix,
python3 -m pytest openfda/device_clearance/tests/transform_test.pyis 4 passed, andopenfda/tests/common_test.pystill passes.