-
Notifications
You must be signed in to change notification settings - Fork 29
Closed as not planned
Labels
Issue: Refactor 🏗️Refactor neededRefactor neededResolution: StaleStale or out of scope issueStale or out of scope issue
Description
Code generation logic is duplicated across multiple generator files. This creates maintenance issues and inconsistent behavior.
Files affected:
healthchain/data_generators/conditiongenerators.py- Other generator files with similar patterns
Current TODO:
# TODO: Factor out the code generation logic to a central placeProblem:
Code generation for FHIR coding systems (creating code/system/display objects) is repeated in multiple generators. This leads to:
- Code duplication
- Inconsistent coding patterns
- Harder to maintain and extend
Goal:
Create centralized code generation utilities that can be reused across all generators.
Acceptance Criteria:
- Identify all places where code generation logic is duplicated
- Create shared utility functions (suggest:
healthchain/data_generators/coding_utils.py) - Refactor existing generators to use shared utilities
- Ensure all existing tests still pass
- Code should support common coding systems (ICD-10, SNOMED CT, LOINC, etc.)
Suggested approach:
# healthchain/data_generators/coding_utils.py
def create_coding(
code: str,
system: str,
display: Optional[str] = None,
version: Optional[str] = None
) -> dict:
"""Create a standardized FHIR Coding object."""
coding = {
"system": system,
"code": code,
}
if display:
coding["display"] = display
if version:
coding["version"] = version
return coding
# Common system URIs as constants
SNOMED_CT_URI = "http://snomed.info/sct"
ICD10_URI = "http://hl7.org/fhir/sid/icd-10"
LOINC_URI = "http://loinc.org"Resources:
- Review
healthchain/data_generators/basegenerators.pyfor existing patterns - FHIR Coding data type
- Search codebase for repeated code generation patterns
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue: Refactor 🏗️Refactor neededRefactor neededResolution: StaleStale or out of scope issueStale or out of scope issue
Type
Projects
Status
Done