Fix drug recommandation drug code and padding. #1138
Merged
jhnwu3 merged 4 commits intosunlabuiuc:masterfrom Apr 25, 2026
Merged
Fix drug recommandation drug code and padding. #1138jhnwu3 merged 4 commits intosunlabuiuc:masterfrom
jhnwu3 merged 4 commits intosunlabuiuc:masterfrom
Conversation
jhnwu3
requested changes
Apr 25, 2026
Collaborator
jhnwu3
left a comment
There was a problem hiding this comment.
tldr; Would be good to just delete the .codex file.
I'm curious about the logic wit the test casing with the FakeLegacyPatient class here, but not too concerned at the moment.
| _NDC_TO_ATC3_CACHE: Dict[str, List[str]] = {} | ||
|
|
||
|
|
||
| def _get_ndc_to_atc3_mapper(): |
Collaborator
There was a problem hiding this comment.
I forgot to mention, sequence processor can also handle the code mappings now too. Don't think it matters that much here, but worth sharing.
class SequenceProcessor(FeatureProcessor, TokenProcessorInterface):
"""Feature processor for encoding categorical sequences.
Encodes medical codes (e.g., diagnoses, procedures) into numerical
indices. Supports single or multiple tokens and can build vocabulary
on the fly if not provided.
Args:
code_mapping: optional tuple of (source_vocabulary, target_vocabulary)
to map raw codes to a grouped vocabulary before tokenizing.
Uses ``pyhealth.medcode.CrossMap`` internally. For example,
``("ICD9CM", "CCSCM")`` maps ~128K ICD-9 diagnosis codes to
~280 CCS categories, and ``("NDC", "ATC")`` maps ~940K drug
codes to ~5K ATC categories. When None (default), codes are
used as-is with no change to existing behavior.
Examples:
>>> proc = SequenceProcessor() # no mapping, same as before
>>> proc = SequenceProcessor(code_mapping=("ICD9CM", "CCSCM"))
"""
Collaborator
Author
There was a problem hiding this comment.
This is a bit tricky because NestedSequence & MultiLabel does not yet support this. May be better to left this into a future PR.
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.
Fix #1137