Skip to content

Conversation

debangshu919
Copy link

@debangshu919 debangshu919 commented Oct 3, 2025

Description

This PR centralizes duplicated FHIR Coding/CodeableConcept construction logic into a shared utility and refactors generator modules to use it. This reduces duplication, improves consistency, and makes future updates to coding behavior easier.

Related Issue

Refactor code generation logic into shared utilities #141

closes #141

Changes Made

  • Added healthchain/data_generators/coding_utils.py with:
    • create_coding(code: str, system: str, display: Optional[str] = None, version: Optional[str] = None) -> dict
    • Common system URIs: SNOMED, ICD-10, LOINC
  • Refactored generators to use the shared utility:
    • healthchain/data_generators/basegenerators.py
    • healthchain/data_generators/patientgenerators.py
    • healthchain/data_generators/practitionergenerators.py
  • Ensured behavior remains identical and minimized surface changes

Testing

  • Created Python 3.11 uv virtual environment and installed dependencies
  • Ran full test suite: 460 passed, 13 skipped, 2 failed. The 2 failures are unrelated to this refactor:
    • Missing template: fhir_cda/section during CDA generation
    • Windows path normalization (forward vs backslash) assertion in test_from_local_model_spacy

Checklist

  • I have read the contributing guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (except unrelated known failures listed above)

Additional Notes

  • This PR focuses on refactoring duplicated coding construction as requested.

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.

Refactor code generation logic into shared utilities
1 participant