Skip to main content

LinuxForHealth x12 streams ASC 5010 X12 health care transactions into Pydantic Models for a pleasant pythonic parsing experience! Integration options include REST endpoints, CLI (command line), or direct access using the Python SDK

Project description

LinuxForHealth x12

GitHub License Supported Versions
Template CI
GitHub Issues GitHub Forks GitHub Stars

LinuxForHealth x12 streams ASC 5010 X12 health care transactions into Pydantic Models for a pleasant pythonic parsing experience! Integration options include REST endpoints, CLI (command line), or direct access using the Python SDK.

Implemented formats include:

  • 005010X212 Claim Status
  • 005010X221 Claim Payment
  • 005010X222 Professional Claim
  • 05010X223 Institutional Claim
  • 005010X279 Eligibility

Future formats include:

  • 005010X217 Services Review
  • 005010X218 Premium Payment
  • 005010X220 Enrollment and Maintenance
  • 005010X224 Dental Claim

This project is currently under construction. Please refer to the LinuxForHealth X12 Issue Board to review current issues and progress.

Quickstart

Pre-requisites

The LinuxForHealth X12 development environment relies on the following software packages:

Project Setup and Validation

pip install --upgrade pip setuptools

git clone https://github.com/LinuxForHealth/x12
cd x12

python3 -m venv venv && source venv/bin/activate && pip install --upgrade pip setuptools 
pip install -e .[dev]
pytest

SDK

The X12 SDK provides an io package which supports streaming X12 segments or transaction models. Segment streaming parses each segment into a list containing the fields. Model streaming validates the X12 payload, and returns one or transaction models from the X12 message.

To stream segments, create a X12SegmentReader instance:

from x12.io import X12SegmentReader

with X12SegmentReader("/home/edi/270.x12") as r:
    # return the segment name and field list
    for segment_name, segment_fields in r.segments():
        print(segment_name)
        print(segment_fields)

To stream models, create a X12ModelReader instance:

from x12.io import X12ModelReader

with X12ModelReader("/home/edi/270.x12") as r:
    for model in r.models():
        # common model attributes include "header" and "footer"
        print(model.header)
        print(model.footer)
        
        # to convert back to X12
        model.x12()

CLI

The X12 CLI parses a X12 input file and returns either a list of X12 segments, or a list of X12 models based on the provided options.

To view help information

user@mbp x12 % source venv/bin/activate
(venv) user@mbp x12 % cli --help
usage: LinuxForHealth X12 [-h] [-s | -m] [-x] [-p] file

The LinuxForHealth X12 CLI parses and validates X12 messages.
Messages are returned in JSON format in either a segment or transactional format.

positional arguments:
  file           The path to a ASC X12 file

optional arguments:
  -h, --help     show this help message and exit
  -s, --segment  Returns X12 segments
  -m, --model    Returns X12 models
  -x, --exclude  Exclude fields set to None in model output
  -p, --pretty   Pretty print output

To parse a X12 message into segments with pretty printing enabled

(venv) user@mbp x12 % cli -s -p demo-file/demo.270
[
    {
        "ISA00": "ISA",
        "ISA01": "03",
        "ISA02": "9876543210",
<etc, etc>

To parse a X12 message into models with pretty printing enabled

(venv) user@mbp x12 % cli -m -p demo-file/demo.270
[
    {
        "header": {
            "st_segment": {
                "delimiters": {
                    "element_separator": "*",
                    "repetition_separator": "^",
                    "segment_terminator": "~",
                    "component_separator": ":"
                },
                "segment_name": "ST",
                "transaction_set_identifier_code": "270",
                "transaction_set_control_number": "0001",
                "implementation_convention_reference": "005010X279A1"
            },
            "bht_segment": {
              <etc, etc>

In "model" mode, the -x option excludes None values from output.

Code Formatting

LinuxForHealth X12 adheres to the Black Code Style and Convention

The following command executes the black formatter with default options

user@mbp x12 % source venv/bin/activate
(venv) user@mbp x12 % black ./src

Use the --help flag to view all available options for the black code formatter

(venv) user@mbp x12 % black --help

REST API

Under Development

Building The Project

LinuxForHealth X12 is aligned, to a degree, with the PEP-517 standard. setup.cfg stores build metadata/configuration. pyproject.toml contains the build toolchain specification and black formatter configurations.

The commands below creates a source and wheel distribution within a clean build environment.

python3 -m venv build-venv && source build-venv/bin/activate && pip install --upgrade pip setuptools build wheel twine
python3 -m build --no-isolation

Additional Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linuxforhealth-x12-0.53.0.tar.gz (105.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linuxforhealth_x12-0.53.0-py3-none-any.whl (127.8 kB view details)

Uploaded Python 3

File details

Details for the file linuxforhealth-x12-0.53.0.tar.gz.

File metadata

  • Download URL: linuxforhealth-x12-0.53.0.tar.gz
  • Upload date:
  • Size: 105.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for linuxforhealth-x12-0.53.0.tar.gz
Algorithm Hash digest
SHA256 766a07ea840fc3f3090ff4d231a08c166907201b2f3511b54c83db1f62188c81
MD5 73ec9e4dfb733ff1a8d174cd94c69c81
BLAKE2b-256 0a5f8ec68e1602f57a9fd2d2cabfe13b7130812cf165f61f8dca2c75ab444968

See more details on using hashes here.

File details

Details for the file linuxforhealth_x12-0.53.0-py3-none-any.whl.

File metadata

  • Download URL: linuxforhealth_x12-0.53.0-py3-none-any.whl
  • Upload date:
  • Size: 127.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for linuxforhealth_x12-0.53.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31faa1c7b01afae565f76e52aeda6487923458ce2a8b49d89e6d8823417de8b7
MD5 4e32fd50e05cb700f09c783e9addd07b
BLAKE2b-256 c3f1c150e026d09a5b9d74bded3ed29258a3d16924c0fa90af9a73ae35747d17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page