Skip to content

Keep the result of stripping the SE prefix from a decision code - #223

Open
arpitjain099 wants to merge 1 commit into
FDA:masterfrom
arpitjain099:fix/device-clearance-decision-code
Open

Keep the result of stripping the SE prefix from a decision code#223
arpitjain099 wants to merge 1 commit into
FDA:masterfrom
arpitjain099:fix/device-clearance-decision-code

Conversation

@arpitjain099

Copy link
Copy Markdown

get_description() in openfda/device_clearance/transform.py drops the return value of str.replace:

def get_description(data):
  data = data.replace('SESE', 'SE')
  if len(data) > 2:
    data.replace('SE', '')

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.csv only 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 than SESE resolves to Unknown:

SESE   -> Substantially Equivalent
SESK   -> Unknown
SESD   -> Unknown
SK     -> Substantially Equivalent - Kit
SD     -> Substantially Equivalent with Drug

SESK and SK are the same clearance decision, so the description is being lost for the prefixed form. That value lands in decision_description on the device clearance records.

The change assigns the result. SESE still collapses on the line above and is unaffected, and a two-character code never enters the branch.

Added openfda/device_clearance/tests/transform_test.py covering the plain, doubled, prefixed and unknown cases. The prefixed case fails on master:

openfda/device_clearance/tests/transform_test.py:20: AssertionError
1 failed, 3 passed

With the fix, python3 -m pytest openfda/device_clearance/tests/transform_test.py is 4 passed, and openfda/tests/common_test.py still passes.

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>
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.

1 participant