ediconvert-sdk 2.15.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,236 @@
1
+ Metadata-Version: 2.4
2
+ Name: ediconvert-sdk
3
+ Version: 2.15.1
4
+ Summary: Python SDK for the Healthcare Data Insight EDI Converter and EDI Generator API
5
+ Author-email: Healthcare Data Insight <ediconvert@datainsight.health>
6
+ License-Expression: LicenseRef-Healthcare-Data-Insight-Commercial
7
+ Project-URL: Homepage, https://datainsight.health/
8
+ Project-URL: Documentation, https://datainsight.health/docs/ediconvert-api/
9
+ Project-URL: Source, https://github.com/Healthcare-Data-Insight/api-examples
10
+ Keywords: edi,x12,healthcare,835,837,api,sdk
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: pydantic>=2
20
+ Requires-Dist: requests>=2.31
21
+
22
+ # Python API Examples
23
+
24
+ This directory contains Python examples for working with the EDI Converter API and the Viewer-style search/upload endpoints exposed by a local API instance.
25
+
26
+ The scripts are intentionally simple. They show how to:
27
+
28
+ - post EDI files directly to conversion endpoints
29
+ - upload multiple files with multipart requests
30
+ - stream large JSON or CSV responses
31
+ - inspect parsed claims, payments, eligibility, claim status, and enrollment data
32
+ - work with generated Python object model classes instead of raw JSON dictionaries
33
+ - generate EDI from object model instances
34
+ - validate EDI and inspect both structured JSON and text validation reports
35
+
36
+ ## Project Layout
37
+
38
+ - `src/ediconvert_sdk/`: reusable SDK client package for conversion, generation, validation, and application-info endpoints.
39
+ - `env.py`: local API base URL configuration.
40
+ - `convert_*.py`: object model examples for converting or parsing EDI files.
41
+ - `convert_*_dict.py`: raw JSON dictionary versions of selected conversion examples.
42
+ - `src/edi_model/`: generated Pydantic object model classes used by the model-based examples.
43
+ - `out/`: output directory used by CSV streaming examples.
44
+
45
+ ## Prerequisites
46
+
47
+ These examples assume:
48
+
49
+ - Python 3.10+.
50
+ - A local EDI Converter API is running and reachable at `http://localhost:5080/api`.
51
+ - Sample EDI files from this repository are available under `../../edi_files` relative to this folder.
52
+
53
+ The code imports these packages:
54
+
55
+ - `requests`
56
+ - `pandas`
57
+ - `requests-toolbelt`
58
+ - `pydantic`
59
+
60
+ Create a virtual environment and install them:
61
+
62
+ ```bash
63
+ python -m venv .venv
64
+ source .venv/bin/activate
65
+ pip install requests pandas requests-toolbelt pydantic
66
+ ```
67
+
68
+ ## Configuration
69
+
70
+ The API URL is defined in `env.py`:
71
+
72
+ ```python
73
+ api_url = 'http://localhost:5080/api'
74
+ ```
75
+
76
+ Update that value if your API is running elsewhere.
77
+
78
+ New code should create an SDK client explicitly:
79
+
80
+ ```python
81
+ from ediconvert_sdk import EdiConverterClient
82
+
83
+ client = EdiConverterClient(base_url="http://localhost:5080/api")
84
+ response = client.conversion.to_json_files(["../../edi_files/837/837P-all-fields.dat"], ndjson=True)
85
+ edi_text = client.generation.generate_835(payment_request)
86
+ ```
87
+
88
+ ## Important Runtime Assumptions
89
+
90
+ Most scripts use relative paths such as `../../edi_files/837/...`, so run them from `python/api`:
91
+
92
+ ```bash
93
+ python convert_837.py
94
+ ```
95
+
96
+ If you run a script from a different working directory, the sample file paths will likely fail.
97
+
98
+ ## Object Model vs Raw JSON Dictionaries
99
+
100
+ The main conversion examples use generated Pydantic classes from `src/edi_model/`.
101
+ They still receive JSON from the API, but immediately validate it into typed objects such as `ProfClaim`, `InstClaim`, `Payment`, and `MemberCoverage`.
102
+
103
+ Examples without a suffix use the object model:
104
+
105
+ - `convert_837.py`
106
+ - `convert_837_single_file.py`
107
+ - `convert_835.py`
108
+ - `convert_834.py`
109
+ - `generate_837p_edi.py`
110
+ - `transform_837p.py`
111
+
112
+ Some examples also have a raw JSON dictionary variant with a `_dict` suffix:
113
+
114
+ - `convert_837_dict.py`
115
+ - `convert_837_dict_single_file.py`
116
+ - `convert_835_dict.py`
117
+ - `convert_834_dict.py`
118
+
119
+ Use the object model examples first. Use the `_dict` examples only when you specifically want to inspect the API response as plain Python dictionaries or build your own mapping layer.
120
+
121
+ ## Example Categories
122
+
123
+ ### Object Model JSON Conversion
124
+
125
+ - `convert_837.py`: converts multiple 837P/837I files to NDJSON and validates claims as `ProfClaim` or `InstClaim` objects.
126
+ - `convert_837_single_file.py`: converts one 837 file and validates the response as a `ProfClaim` object.
127
+ - `convert_835.py`: converts 835 files to NDJSON and validates claim payments and provider-level adjustments as object model classes.
128
+ - `convert_834.py`: converts 834 enrollment files and validates member coverage objects.
129
+ - `generate_837p_edi.py`: builds an `EdiGenClaimRequest` with object model classes and generates 837P EDI.
130
+ - `validate_835.py`: validates an 835 file with known issues and prints both JSON-model and text reports.
131
+ - `transform_837p.py`: converts an existing 837P claim into an object model request and posts it back to the generator endpoint.
132
+
133
+ These scripts use `/edi/json`, `/edi/gen/837`, `/edi/gen/835`, `/edi/validate`, and `/edi/validate/text` endpoints and demonstrate:
134
+
135
+ - multipart upload for multiple files
136
+ - direct streaming of a single file
137
+ - NDJSON processing with `response.iter_lines()`
138
+ - object model validation with generated Pydantic classes
139
+ - parser warning/error handling via `objectType`
140
+ - validation issue handling through `ValidationIssue` objects and text output
141
+
142
+ ### Raw JSON Dictionary Conversion
143
+
144
+ - `convert_837_dict.py`: raw dictionary version of `convert_837.py`.
145
+ - `convert_837_dict_single_file.py`: raw dictionary version of `convert_837_single_file.py`.
146
+ - `convert_835_dict.py`: raw dictionary version of `convert_835.py`.
147
+ - `convert_834_dict.py`: raw dictionary version of `convert_834.py`.
148
+
149
+ These scripts use the same API endpoints as the object model examples, but leave the response as plain dictionaries from `json.loads(...)`.
150
+
151
+ ### CSV Conversion
152
+
153
+ - `convert_835_csv.py`: converts 835 files to CSV, reads them with `csv` and `pandas`, and shows how to stream large responses to disk.
154
+ - `convert_835_csv_error.py`: a troubleshooting-oriented example for reading CSV output that contains parsing errors.
155
+
156
+ These scripts use `/edi/csv` and demonstrate:
157
+
158
+ - all-fields conversion
159
+ - named schema selection such as `key-fields`
160
+ - streaming response bodies to `./out/*.csv`
161
+ - row-level error/warning inspection
162
+
163
+ ### Raw Parse Examples
164
+
165
+ - `convert_271.py`: parses a 271 eligibility response into hierarchical segment JSON.
166
+ - `convert_277.py`: parses a 277 claim status response and walks payer/provider/patient status loops.
167
+ - `parse_in_mem_837.py`: calls the deprecated `/edi/parse` endpoint for a small 837 file.
168
+ - `parse_edi_277_from_users.py`: older `/edi/parse` example against a user-supplied 277 sample.
169
+
170
+ Use these as segment-tree traversal examples. For large files, the conversion endpoints are the better fit.
171
+
172
+ ### Claim Insight/EDI Viewer API Examples
173
+
174
+ The `viewer/` directory shows how to work with stored data after files have been ingested:
175
+
176
+ - `upload_delete_files.py`: uploads files to `/files`, triggers analytics rebuild, fetches claims, then deletes the files.
177
+ - `get_files.py`: lists recently loaded files and fetches claims for each file.
178
+ - `search_claims.py`: paginated claim search using `/claims`.
179
+ - `get_claim.py`: fetches a claim by business keys and then by internal ID.
180
+ - `search_payments.py`: paginated payment search using `/payments`.
181
+ - `get_payment.py`: fetches payments by payer control number or patient control number plus payee ID.
182
+ - `analytics_top_codes.py`: retrieves top procedure and diagnosis codes by charge amount.
183
+
184
+ These examples assume the API has indexed data available, typically after files were uploaded through the `/files` endpoint.
185
+
186
+ ## Typical Usage
187
+
188
+ Run a conversion example:
189
+
190
+ ```bash
191
+ python convert_837.py
192
+ python convert_835.py
193
+ python convert_834.py
194
+ ```
195
+
196
+ Run a CSV example:
197
+
198
+ ```bash
199
+ python convert_835_csv.py
200
+ ```
201
+
202
+ Validate an 835 file with known issues:
203
+
204
+ ```bash
205
+ python validate_835.py
206
+ ```
207
+
208
+ Generate 837P EDI from object model classes:
209
+
210
+ ```bash
211
+ python generate_837p_edi.py
212
+ ```
213
+
214
+ Build, install, and test the SDK locally:
215
+
216
+ ```bash
217
+ ./build_and_test_sdk.sh
218
+ ```
219
+
220
+ ## Notes and Caveats
221
+
222
+ - `env.py` is a hardcoded local configuration file for examples. The SDK client also accepts a `base_url` argument and the `EDICONVERT_BASE_URL` environment variable.
223
+ - Public API calls can pass `api_key` to `EdiConverterClient` or set the `EDICONVERT_API_KEY` environment variable. Local API calls do not require an API key.
224
+ - Several scripts print results directly and are meant as examples, not reusable library code.
225
+ - `parse_in_mem_837.py` and `parse_edi_277_from_users.py` use the deprecated `/edi/parse` endpoint.
226
+ - `convert_835_csv_error.py` includes a hardcoded file path outside this project and is best treated as a reference/debug script.
227
+ - `_dict` examples intentionally use raw Python dictionaries; the same examples without `_dict` are the preferred object model versions.
228
+ - Some viewer scripts use fixed search parameters or IDs that may not match your local dataset.
229
+
230
+ ## Recommended Starting Points
231
+
232
+ If you are new to this folder, start with:
233
+
234
+ 1. `convert_837.py` for streamed NDJSON claim conversion with object model classes.
235
+ 2. `convert_835_csv.py` for CSV export and streaming-to-disk patterns.
236
+ 3. `generate_837p_edi.py` if you want to generate 837P EDI from object model classes.
@@ -0,0 +1,215 @@
1
+ # Python API Examples
2
+
3
+ This directory contains Python examples for working with the EDI Converter API and the Viewer-style search/upload endpoints exposed by a local API instance.
4
+
5
+ The scripts are intentionally simple. They show how to:
6
+
7
+ - post EDI files directly to conversion endpoints
8
+ - upload multiple files with multipart requests
9
+ - stream large JSON or CSV responses
10
+ - inspect parsed claims, payments, eligibility, claim status, and enrollment data
11
+ - work with generated Python object model classes instead of raw JSON dictionaries
12
+ - generate EDI from object model instances
13
+ - validate EDI and inspect both structured JSON and text validation reports
14
+
15
+ ## Project Layout
16
+
17
+ - `src/ediconvert_sdk/`: reusable SDK client package for conversion, generation, validation, and application-info endpoints.
18
+ - `env.py`: local API base URL configuration.
19
+ - `convert_*.py`: object model examples for converting or parsing EDI files.
20
+ - `convert_*_dict.py`: raw JSON dictionary versions of selected conversion examples.
21
+ - `src/edi_model/`: generated Pydantic object model classes used by the model-based examples.
22
+ - `out/`: output directory used by CSV streaming examples.
23
+
24
+ ## Prerequisites
25
+
26
+ These examples assume:
27
+
28
+ - Python 3.10+.
29
+ - A local EDI Converter API is running and reachable at `http://localhost:5080/api`.
30
+ - Sample EDI files from this repository are available under `../../edi_files` relative to this folder.
31
+
32
+ The code imports these packages:
33
+
34
+ - `requests`
35
+ - `pandas`
36
+ - `requests-toolbelt`
37
+ - `pydantic`
38
+
39
+ Create a virtual environment and install them:
40
+
41
+ ```bash
42
+ python -m venv .venv
43
+ source .venv/bin/activate
44
+ pip install requests pandas requests-toolbelt pydantic
45
+ ```
46
+
47
+ ## Configuration
48
+
49
+ The API URL is defined in `env.py`:
50
+
51
+ ```python
52
+ api_url = 'http://localhost:5080/api'
53
+ ```
54
+
55
+ Update that value if your API is running elsewhere.
56
+
57
+ New code should create an SDK client explicitly:
58
+
59
+ ```python
60
+ from ediconvert_sdk import EdiConverterClient
61
+
62
+ client = EdiConverterClient(base_url="http://localhost:5080/api")
63
+ response = client.conversion.to_json_files(["../../edi_files/837/837P-all-fields.dat"], ndjson=True)
64
+ edi_text = client.generation.generate_835(payment_request)
65
+ ```
66
+
67
+ ## Important Runtime Assumptions
68
+
69
+ Most scripts use relative paths such as `../../edi_files/837/...`, so run them from `python/api`:
70
+
71
+ ```bash
72
+ python convert_837.py
73
+ ```
74
+
75
+ If you run a script from a different working directory, the sample file paths will likely fail.
76
+
77
+ ## Object Model vs Raw JSON Dictionaries
78
+
79
+ The main conversion examples use generated Pydantic classes from `src/edi_model/`.
80
+ They still receive JSON from the API, but immediately validate it into typed objects such as `ProfClaim`, `InstClaim`, `Payment`, and `MemberCoverage`.
81
+
82
+ Examples without a suffix use the object model:
83
+
84
+ - `convert_837.py`
85
+ - `convert_837_single_file.py`
86
+ - `convert_835.py`
87
+ - `convert_834.py`
88
+ - `generate_837p_edi.py`
89
+ - `transform_837p.py`
90
+
91
+ Some examples also have a raw JSON dictionary variant with a `_dict` suffix:
92
+
93
+ - `convert_837_dict.py`
94
+ - `convert_837_dict_single_file.py`
95
+ - `convert_835_dict.py`
96
+ - `convert_834_dict.py`
97
+
98
+ Use the object model examples first. Use the `_dict` examples only when you specifically want to inspect the API response as plain Python dictionaries or build your own mapping layer.
99
+
100
+ ## Example Categories
101
+
102
+ ### Object Model JSON Conversion
103
+
104
+ - `convert_837.py`: converts multiple 837P/837I files to NDJSON and validates claims as `ProfClaim` or `InstClaim` objects.
105
+ - `convert_837_single_file.py`: converts one 837 file and validates the response as a `ProfClaim` object.
106
+ - `convert_835.py`: converts 835 files to NDJSON and validates claim payments and provider-level adjustments as object model classes.
107
+ - `convert_834.py`: converts 834 enrollment files and validates member coverage objects.
108
+ - `generate_837p_edi.py`: builds an `EdiGenClaimRequest` with object model classes and generates 837P EDI.
109
+ - `validate_835.py`: validates an 835 file with known issues and prints both JSON-model and text reports.
110
+ - `transform_837p.py`: converts an existing 837P claim into an object model request and posts it back to the generator endpoint.
111
+
112
+ These scripts use `/edi/json`, `/edi/gen/837`, `/edi/gen/835`, `/edi/validate`, and `/edi/validate/text` endpoints and demonstrate:
113
+
114
+ - multipart upload for multiple files
115
+ - direct streaming of a single file
116
+ - NDJSON processing with `response.iter_lines()`
117
+ - object model validation with generated Pydantic classes
118
+ - parser warning/error handling via `objectType`
119
+ - validation issue handling through `ValidationIssue` objects and text output
120
+
121
+ ### Raw JSON Dictionary Conversion
122
+
123
+ - `convert_837_dict.py`: raw dictionary version of `convert_837.py`.
124
+ - `convert_837_dict_single_file.py`: raw dictionary version of `convert_837_single_file.py`.
125
+ - `convert_835_dict.py`: raw dictionary version of `convert_835.py`.
126
+ - `convert_834_dict.py`: raw dictionary version of `convert_834.py`.
127
+
128
+ These scripts use the same API endpoints as the object model examples, but leave the response as plain dictionaries from `json.loads(...)`.
129
+
130
+ ### CSV Conversion
131
+
132
+ - `convert_835_csv.py`: converts 835 files to CSV, reads them with `csv` and `pandas`, and shows how to stream large responses to disk.
133
+ - `convert_835_csv_error.py`: a troubleshooting-oriented example for reading CSV output that contains parsing errors.
134
+
135
+ These scripts use `/edi/csv` and demonstrate:
136
+
137
+ - all-fields conversion
138
+ - named schema selection such as `key-fields`
139
+ - streaming response bodies to `./out/*.csv`
140
+ - row-level error/warning inspection
141
+
142
+ ### Raw Parse Examples
143
+
144
+ - `convert_271.py`: parses a 271 eligibility response into hierarchical segment JSON.
145
+ - `convert_277.py`: parses a 277 claim status response and walks payer/provider/patient status loops.
146
+ - `parse_in_mem_837.py`: calls the deprecated `/edi/parse` endpoint for a small 837 file.
147
+ - `parse_edi_277_from_users.py`: older `/edi/parse` example against a user-supplied 277 sample.
148
+
149
+ Use these as segment-tree traversal examples. For large files, the conversion endpoints are the better fit.
150
+
151
+ ### Claim Insight/EDI Viewer API Examples
152
+
153
+ The `viewer/` directory shows how to work with stored data after files have been ingested:
154
+
155
+ - `upload_delete_files.py`: uploads files to `/files`, triggers analytics rebuild, fetches claims, then deletes the files.
156
+ - `get_files.py`: lists recently loaded files and fetches claims for each file.
157
+ - `search_claims.py`: paginated claim search using `/claims`.
158
+ - `get_claim.py`: fetches a claim by business keys and then by internal ID.
159
+ - `search_payments.py`: paginated payment search using `/payments`.
160
+ - `get_payment.py`: fetches payments by payer control number or patient control number plus payee ID.
161
+ - `analytics_top_codes.py`: retrieves top procedure and diagnosis codes by charge amount.
162
+
163
+ These examples assume the API has indexed data available, typically after files were uploaded through the `/files` endpoint.
164
+
165
+ ## Typical Usage
166
+
167
+ Run a conversion example:
168
+
169
+ ```bash
170
+ python convert_837.py
171
+ python convert_835.py
172
+ python convert_834.py
173
+ ```
174
+
175
+ Run a CSV example:
176
+
177
+ ```bash
178
+ python convert_835_csv.py
179
+ ```
180
+
181
+ Validate an 835 file with known issues:
182
+
183
+ ```bash
184
+ python validate_835.py
185
+ ```
186
+
187
+ Generate 837P EDI from object model classes:
188
+
189
+ ```bash
190
+ python generate_837p_edi.py
191
+ ```
192
+
193
+ Build, install, and test the SDK locally:
194
+
195
+ ```bash
196
+ ./build_and_test_sdk.sh
197
+ ```
198
+
199
+ ## Notes and Caveats
200
+
201
+ - `env.py` is a hardcoded local configuration file for examples. The SDK client also accepts a `base_url` argument and the `EDICONVERT_BASE_URL` environment variable.
202
+ - Public API calls can pass `api_key` to `EdiConverterClient` or set the `EDICONVERT_API_KEY` environment variable. Local API calls do not require an API key.
203
+ - Several scripts print results directly and are meant as examples, not reusable library code.
204
+ - `parse_in_mem_837.py` and `parse_edi_277_from_users.py` use the deprecated `/edi/parse` endpoint.
205
+ - `convert_835_csv_error.py` includes a hardcoded file path outside this project and is best treated as a reference/debug script.
206
+ - `_dict` examples intentionally use raw Python dictionaries; the same examples without `_dict` are the preferred object model versions.
207
+ - Some viewer scripts use fixed search parameters or IDs that may not match your local dataset.
208
+
209
+ ## Recommended Starting Points
210
+
211
+ If you are new to this folder, start with:
212
+
213
+ 1. `convert_837.py` for streamed NDJSON claim conversion with object model classes.
214
+ 2. `convert_835_csv.py` for CSV export and streaming-to-disk patterns.
215
+ 3. `generate_837p_edi.py` if you want to generate 837P EDI from object model classes.
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ediconvert-sdk"
7
+ version = "2.15.1"
8
+ description = "Python SDK for the Healthcare Data Insight EDI Converter and EDI Generator API"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "LicenseRef-Healthcare-Data-Insight-Commercial"
12
+ authors = [
13
+ { name = "Healthcare Data Insight", email = "ediconvert@datainsight.health" },
14
+ ]
15
+ keywords = ["edi", "x12", "healthcare", "835", "837", "api", "sdk"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ ]
24
+ dependencies = [
25
+ "pydantic>=2",
26
+ "requests>=2.31",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://datainsight.health/"
31
+ Documentation = "https://datainsight.health/docs/ediconvert-api/"
32
+ Source = "https://github.com/Healthcare-Data-Insight/api-examples"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
36
+ include = ["ediconvert_sdk*", "edi_model*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes