Files
doczyai-pipelines/fieldExtraction/crosswalk
Katon Minhas 60c3104119 Merged in field/tin-npi-breakout (pull request #435)
field/tin npi breakout

* additional comments added

* pipeline error fixed

* final bug fixes during testing

* Merge branch 'main' into field/tin-npi-breakout

* formatting change - no error otherwise

* Merge branch 'field/tin-npi-breakout' of https://bitbucket.org/aarete/doczy.ai into field/tin-npi-breakout
pulled latest changes

* Streamline tin_npi_funcs

* Prompt changes

* remove punctuation

* Remove duplicates after cleaning

* Prompt mods

* Update values

* Prompt mods - allow for N/A

* Prompt for ALL NPIs

* Change clean function

* Allow multiple group TIN/NPI

* Prompt update

* Merged main into field/tin-npi-breakout

* remove test file

* Fix return type

* Restore testbed

* Merged main into field/tin-npi-breakout

* tin_npi_funcs.py edited online with Bitbucket
* Removed commented function

* Remove regex fields from one-to-one


Approved-by: Alex Galarce
2025-03-06 20:50:36 +00:00
..

This framework allows flexible serialization and application of crosswalk tables.

Features

  • Create crosswalks from Excel files or dictionaries
  • Save crosswalks as JSON for easy reuse
  • Apply crosswalks with customizable default behavior
  • Metadata tracking for column mappings

Creating a Crosswalk

from crosswalk_utils import CrosswalkBuilder

# From Excel
builder = CrosswalkBuilder()
builder.from_excel(
    path="CROSSWALK_PROVIDER_TYPE.20220106.xlsx",
    sheet_name='Prac',
    from_col="Practitioner Specialty",
    to_col="Taxonomy"
).save('crosswalk_provider_type.json')

# You can also create from a dictionary
builder.from_dict(
    mapping={'Acupuncturist': '171100000X'},
    from_col='Specialty',
    to_col='Taxonomy'
)

Applying a Crosswalk

import json
from crosswalk_utils import apply_crosswalk

# Load the mapping
with open('crosswalk_provider_type.json') as f:
    data = json.load(f)
    
# Apply the crosswalk
result = apply_crosswalk(
    val="Acupuncturist",
    mapping=data['mapping'],
    default=None  # Optional: specify default for unmapped values
)
# Result: '171100000X'

Reversing a Crosswalk

from crosswalk_utils import CrosswalkBuilder
builder = CrosswalkBuilder()
builder.from_json("mappings/crosswalk_program_lob.json").create_reverse_mapping()

# Result: 
# {'Commercial-Group': 'Administrative Services Only (ASO), Third-Party '
#                      'Administrator (TPA), Self-Funded, Employer Funded',
#  'Marketplace-Exchange-Individual & Family': 'Platinum, Gold, Silver, Bronze',
#  'Medicaid': 'Aged, Blind, Disabled (ABD), Childrens Health Insurance Program '
#              '(CHIP), Childrens Health Insurance Program Perinate '
#              '(CHIP-Perinate), Foster Care, Intellectual and Developmental '
#              'Disability (IDD), Temporary Assistance Needy Families (TANF)',
#  'Medicare': 'Medicare Advantage, Supplemental',
#  'Medicare-Medicaid': 'Chronic Condition Special Needs Plan (C-SNP), Dual '
#                       'Eligible Special Needs Plan (D-SNP), Institutional '
#                       'Special Needs Plan (I-SNP), Long-Term Services and '
#                       'Supports (LTSS), Program of All-Inclusive Care for the '
#                       'Elderly (PACE), Special Needs Plan (SNP)'}