Package: linuxforhealth-x12
LinuxForHealth x12LinuxForHealth x12 streams ASC 5010 X12 health care transactions intoPydantic Modelsfor a pleasant pythonic parsing experience! Integration options include REST endpoints, CLI (command line), or direct access using the Python SDK.Supported formats include:005010X212 Claim Status005010X221 Claim Payment005010X222 Professional Claim05010X223 Institutional Claim005010X279 Eligibility005010X220 Enrollment and MaintenanceQuickstartPre-requisitesThe LinuxForHealth X12 development environment relies on the following software packages:gitfor project version controlPython 3.8 or higherfor runtime/coding supportProject Setup and Validationpipinstall--upgradepipsetuptools

gitclonehttps://github.com/LinuxForHealth/x12cdx12

python3-mvenvvenv&&sourcevenv/bin/activate&&pipinstall--upgradepipsetuptoolspipinstall-e.[dev,api]# installs dev packages and optional API endpointpytestSDKThe X12 SDK provides aniopackage 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:fromlinuxforhealth.x12.ioimportX12SegmentReaderwithX12SegmentReader("/home/edi/270.x12")asr:# return the segment name and field listforsegment_name,segment_fieldsinr.segments():print(segment_name)print(segment_fields)To stream models, create a X12ModelReader instance:fromlinuxforhealth.x12.ioimportX12ModelReaderwithX12ModelReader("/home/edi/270.x12")asr:formodelinr.models():# common model attributes include "header" and "footer"print(model.header)print(model.footer)# to convert back to X12model.x12()CLIThe 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 informationuser@mbpx12%sourcevenv/bin/activate(venv)user@mbpx12%lfhx12--help
usage:LinuxForHealthX12[-h][-s|-m][-x][-p]file

TheLinuxForHealthX12CLIparsesandvalidatesX12messages.
MessagesarereturnedinJSONformatineitherasegmentortransactionalformat.

positionalarguments:fileThepathtoaASCX12file

optionalarguments:-h,--helpshowthishelpmessageandexit-s,--segmentReturnsX12segments-m,--modelReturnsX12models-x,--excludeExcludefieldssettoNoneinmodeloutput-p,--prettyPrettyprintoutputTo parse a X12 message into segments with pretty printing enabled(venv)user@mbpx12%lfhx12-s-pdemo-file/demo.270[{"ISA00":"ISA","ISA01":"03","ISA02":"9876543210",
<etc,etc>To parse a X12 message into models with pretty printing enabled(venv)user@mbpx12%lfhx12-m-pdemo-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-xoption excludesNonevalues from output.APILinuxForHealth X12 includes an experimental "api" setup "extra" which activates aFast APIendpoint used to submit X12 payloads.user@mbpx12%sourcevenv/bin/activate(venv)user@mbpx12%pipinstall-e".[api]"(venv)user@mbpx12%lfhx12-apiBrowse tohttp://localhost:5000/docsto view the Open API UI.API server configurations are located in theconfig module. TheX12ApiConfigmodel
is aPydantic Settings Modelwhich can be configured using environment
variables.user@mbpx12%sourcevenv/bin/activate(venv)user@mbpx12%exportX12_UVICORN_PORT=5002(venv)user@mbpx12%lfhx12-apiCode FormattingLinuxForHealth X12 adheres to theBlack Code Style and ConventionThe following command executes the black formatter with default optionsuser@mbpx12%sourcevenv/bin/activate(venv)user@mbpx12%black./srcUse the--helpflag to view all available options for the black code formatter(venv)user@mbpx12%black--helpBuilding The ProjectLinuxForHealth X12 is aligned, to a degree, with the PEP-517 standard.setup.cfgstores build metadata/configuration.pyproject.tomlcontains the build toolchain specification and black formatter configurations.The commands below creates a source and wheel distribution within a clean build environment.python3-mvenvbuild-venv&&sourcebuild-venv/bin/activate&&pipinstall--upgradepipsetuptoolsbuildwheeltwine
python3-mbuild--no-isolationAdditional ResourcesDesign OverviewNew Transaction SupportContainer Support