hccinfhir 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.
hccinfhir/samples.py ADDED
@@ -0,0 +1,252 @@
1
+ """
2
+ Sample Data Module for HCCInFHIR
3
+
4
+ This module provides easy access to sample data files for testing and demonstration purposes.
5
+ End users can call functions to retrieve sample EOB (Explanation of Benefits) and 837 claim data.
6
+ """
7
+
8
+ import importlib.resources
9
+ import json
10
+ from typing import List, Dict, Any, Union, Optional
11
+ from pathlib import Path
12
+
13
+
14
+ class SampleData:
15
+ """
16
+ A class that provides access to sample data files included with the HCCInFHIR package.
17
+
18
+ This class allows end users to easily retrieve sample EOB and 837 claim data
19
+ for testing, development, and demonstration purposes.
20
+ """
21
+
22
+ @staticmethod
23
+ def get_eob_sample(case_number: int = 1) -> Dict[str, Any]:
24
+ """
25
+ Retrieve a specific EOB sample by case number.
26
+
27
+ Args:
28
+ case_number: The case number (1, 2, or 3). Default is 1.
29
+
30
+ Returns:
31
+ A dictionary containing the EOB data
32
+
33
+ Raises:
34
+ ValueError: If case_number is not 1, 2, or 3
35
+ FileNotFoundError: If the sample file cannot be found
36
+
37
+ Example:
38
+ >>> sample_data = SampleData.get_eob_sample(1)
39
+ >>> print(sample_data['resourceType'])
40
+ 'ExplanationOfBenefit'
41
+ """
42
+ if case_number not in [1, 2, 3]:
43
+ raise ValueError("case_number must be 1, 2, or 3")
44
+
45
+ try:
46
+ with importlib.resources.open_text('hccinfhir.samples', f'sample_eob_{case_number}.json') as f:
47
+ return json.load(f)
48
+ except FileNotFoundError:
49
+ raise FileNotFoundError(f"Sample EOB case {case_number} not found")
50
+
51
+ @staticmethod
52
+ def get_eob_sample_list(limit: Optional[int] = None) -> List[Dict[str, Any]]:
53
+ """
54
+ Retrieve a list of EOB samples from the large sample file.
55
+
56
+ Args:
57
+ limit: Maximum number of samples to return. If None, returns all 200 samples.
58
+
59
+ Returns:
60
+ A list of EOB data dictionaries
61
+
62
+ Raises:
63
+ FileNotFoundError: If the sample file cannot be found
64
+
65
+ Example:
66
+ >>> # Get first 10 samples
67
+ >>> samples = SampleData.get_eob_sample_list(limit=10)
68
+ >>> print(len(samples))
69
+ 10
70
+
71
+ >>> # Get all 200 samples
72
+ >>> all_samples = SampleData.get_eob_sample_list()
73
+ >>> print(len(all_samples))
74
+ 200
75
+ """
76
+ try:
77
+ output = []
78
+ with importlib.resources.open_text('hccinfhir.samples', 'sample_eob_200.ndjson') as f:
79
+ for i, line in enumerate(f):
80
+ if limit is not None and i >= limit:
81
+ break
82
+ eob_data = json.loads(line)
83
+ output.append(eob_data)
84
+ return output
85
+ except FileNotFoundError:
86
+ raise FileNotFoundError("Sample EOB list file not found")
87
+
88
+ @staticmethod
89
+ def get_837_sample(case_number: int = 0) -> str:
90
+ """
91
+ Retrieve a specific 837 claim sample by case number.
92
+
93
+ Args:
94
+ case_number: The case number (0 through 11). Default is 0.
95
+
96
+ Returns:
97
+ A string containing the 837 X12 claim data
98
+
99
+ Raises:
100
+ ValueError: If case_number is not between 0 and 11
101
+ FileNotFoundError: If the sample file cannot be found
102
+
103
+ Example:
104
+ >>> sample_837 = SampleData.get_837_sample(0)
105
+ >>> print("ISA" in sample_837)
106
+ True
107
+ """
108
+ if case_number < 0 or case_number > 11:
109
+ raise ValueError("case_number must be between 0 and 11")
110
+
111
+ try:
112
+ with importlib.resources.open_text('hccinfhir.samples', f'sample_837_{case_number}.txt') as f:
113
+ return f.read()
114
+ except FileNotFoundError:
115
+ raise FileNotFoundError(f"Sample 837 case {case_number} not found")
116
+
117
+ @staticmethod
118
+ def get_837_sample_list(case_numbers: Optional[List[int]] = None) -> List[str]:
119
+ """
120
+ Retrieve multiple 837 claim samples.
121
+
122
+ Args:
123
+ case_numbers: List of case numbers to retrieve. If None, returns all 12 samples.
124
+
125
+ Returns:
126
+ A list of 837 X12 claim data strings
127
+
128
+ Raises:
129
+ ValueError: If any case_number is not between 0 and 11
130
+ FileNotFoundError: If any sample file cannot be found
131
+
132
+ Example:
133
+ >>> # Get specific cases
134
+ >>> samples = SampleData.get_837_sample_list([0, 1, 2])
135
+ >>> print(len(samples))
136
+ 3
137
+
138
+ >>> # Get all samples
139
+ >>> all_samples = SampleData.get_837_sample_list()
140
+ >>> print(len(all_samples))
141
+ 12
142
+ """
143
+ if case_numbers is None:
144
+ case_numbers = list(range(12)) # 0 through 11
145
+
146
+ # Validate case numbers
147
+ for case_num in case_numbers:
148
+ if case_num < 0 or case_num > 11:
149
+ raise ValueError(f"case_number {case_num} must be between 0 and 11")
150
+
151
+ output = []
152
+ for case_num in case_numbers:
153
+ try:
154
+ with importlib.resources.open_text('hccinfhir.samples', f'sample_837_{case_num}.txt') as f:
155
+ output.append(f.read())
156
+ except FileNotFoundError:
157
+ raise FileNotFoundError(f"Sample 837 case {case_num} not found")
158
+
159
+ return output
160
+
161
+ @staticmethod
162
+ def list_available_samples() -> Dict[str, Any]:
163
+ """
164
+ Get information about all available sample data.
165
+
166
+ Returns:
167
+ A dictionary containing information about available samples
168
+
169
+ Example:
170
+ >>> info = SampleData.list_available_samples()
171
+ >>> print(info['eob_samples'])
172
+ ['sample_eob_1.json', 'sample_eob_2.json', 'sample_eob_3.json', 'sample_eob_200.ndjson']
173
+ """
174
+ return {
175
+ "eob_samples": [
176
+ "sample_eob_1.json",
177
+ "sample_eob_2.json",
178
+ "sample_eob_3.json",
179
+ "sample_eob_200.ndjson"
180
+ ],
181
+ "eob_case_numbers": [1, 2, 3],
182
+ "eob_list_size": 200,
183
+ "837_samples": [f"sample_837_{i}.txt" for i in range(12)],
184
+ "837_case_numbers": list(range(12)),
185
+ "description": {
186
+ "eob": "Explanation of Benefits (FHIR resources) for testing HCC calculations",
187
+ "837": "X12 837 claim data for testing claim processing"
188
+ }
189
+ }
190
+
191
+
192
+ # Convenience functions for easy access
193
+ def get_eob_sample(case_number: int = 1) -> Dict[str, Any]:
194
+ """
195
+ Convenience function to get an EOB sample.
196
+
197
+ Args:
198
+ case_number: The case number (1, 2, or 3). Default is 1.
199
+
200
+ Returns:
201
+ A dictionary containing the EOB data
202
+ """
203
+ return SampleData.get_eob_sample(case_number)
204
+
205
+
206
+ def get_eob_sample_list(limit: Optional[int] = None) -> List[Dict[str, Any]]:
207
+ """
208
+ Convenience function to get a list of EOB samples.
209
+
210
+ Args:
211
+ limit: Maximum number of samples to return. If None, returns all 200 samples.
212
+
213
+ Returns:
214
+ A list of EOB data dictionaries
215
+ """
216
+ return SampleData.get_eob_sample_list(limit)
217
+
218
+
219
+ def get_837_sample(case_number: int = 0) -> str:
220
+ """
221
+ Convenience function to get an 837 claim sample.
222
+
223
+ Args:
224
+ case_number: The case number (0 through 11). Default is 0.
225
+
226
+ Returns:
227
+ A string containing the 837 X12 claim data
228
+ """
229
+ return SampleData.get_837_sample(case_number)
230
+
231
+
232
+ def get_837_sample_list(case_numbers: Optional[List[int]] = None) -> List[str]:
233
+ """
234
+ Convenience function to get multiple 837 claim samples.
235
+
236
+ Args:
237
+ case_numbers: List of case numbers to retrieve. If None, returns all 12 samples.
238
+
239
+ Returns:
240
+ A list of 837 X12 claim data strings
241
+ """
242
+ return SampleData.get_837_sample_list(case_numbers)
243
+
244
+
245
+ def list_available_samples() -> Dict[str, Any]:
246
+ """
247
+ Convenience function to get information about available samples.
248
+
249
+ Returns:
250
+ A dictionary containing information about available samples
251
+ """
252
+ return SampleData.list_available_samples()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hccinfhir
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: HCC Algorithm for FHIR Resources
5
5
  Project-URL: Homepage, https://github.com/mimilabs/hccinfhir
6
6
  Project-URL: Issues, https://github.com/mimilabs/hccinfhir/issues
@@ -69,6 +69,34 @@ result = calculate_raf(
69
69
 
70
70
  For more details on the SLD format, see the `datamodels.py` file.
71
71
 
72
+ ## Sample Data
73
+
74
+ The package includes comprehensive sample data for testing and demonstration purposes:
75
+
76
+ ```python
77
+ from hccinfhir import (
78
+ get_eob_sample,
79
+ get_eob_sample_list,
80
+ get_837_sample,
81
+ get_837_sample_list,
82
+ list_available_samples
83
+ )
84
+
85
+ # Get individual EOB samples (cases 1, 2, or 3)
86
+ eob_data = get_eob_sample(1)
87
+
88
+ # Get multiple EOB samples (up to 200 available)
89
+ eob_list = get_eob_sample_list(limit=10)
90
+
91
+ # Get 837 claim samples (cases 0 through 11)
92
+ claim_data = get_837_sample(0)
93
+
94
+ # Get information about available samples
95
+ info = list_available_samples()
96
+ ```
97
+
98
+ For detailed usage examples, see the `examples/sample_data_usage.py` file.
99
+
72
100
  ## Core Components
73
101
 
74
102
  ### 1. Extractor Module
@@ -352,9 +380,10 @@ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2025;
352
380
  Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
353
381
 
354
382
  ## Publishing (only for those maintainers...)
383
+ Inside the hatch
355
384
  ```bash
356
- $ python3 -m hatch build
357
- $ python3 -m hatch publish
385
+ $ hatch build
386
+ $ hatch publish
358
387
  ```
359
388
 
360
389
  ## License
@@ -1,16 +1,18 @@
1
- hccinfhir/__init__.py,sha256=OCyYCv4jTOlYHZbTw2DTks3e6_YT1N2JXAOuyR03KNE,43
1
+ hccinfhir/__init__.py,sha256=UBTJCLzkCGNCMpG38vkpu3DeMM_RV_7o5JjOWL7ps9c,1048
2
2
  hccinfhir/datamodels.py,sha256=lMLGSuWTlpzoWenKsfhF8qQF3RZJV2NNGyIm_rBkd0o,5038
3
- hccinfhir/extractor.py,sha256=-jHVCIJqFAqvrI9GxkkXZVDQjKDa-7vF7v3PGMGAMnA,1801
4
- hccinfhir/extractor_837.py,sha256=vkTBCd0WBaJoTrUd-Z-zCIaoLk7KV2n4AGqIORhONIk,7147
3
+ hccinfhir/extractor.py,sha256=xL9c2VT-e2I7_c8N8j4Og42UEgVuCzyn9WFp3ntM5Ro,1822
4
+ hccinfhir/extractor_837.py,sha256=VWBZdMZpHwDhSAotx7uuYiCIHsRlpsDmOi5E3v8mgBU,10866
5
5
  hccinfhir/extractor_fhir.py,sha256=Rg_L0Vg5tz_L2VJ_jvZwWz6RMlPAkHwj4LiK-OWQvrQ,8458
6
- hccinfhir/filter.py,sha256=8uYThN0-AqwVAKyti29WGiFwQKDiremMhYd_m6QcXhM,2193
7
- hccinfhir/hccinfhir.py,sha256=gVdQ6e1rJRVwIEcSw2cAUjnXH5WsCqaeDudn1Ol2_0w,6837
6
+ hccinfhir/filter.py,sha256=j_yD2g6RBXVUV9trKkWzsQ35x3fRvfKUPvEXKUefI64,2007
7
+ hccinfhir/hccinfhir.py,sha256=KzEPwZQn5qcG8e44I8EahzhWXP9fYR18U4SHTA1DGcI,6855
8
8
  hccinfhir/model_calculate.py,sha256=3lKpNSdTNFn3OREw8yjlOhoNcDhs7LpQj7TIHQ1HvxQ,5519
9
9
  hccinfhir/model_coefficients.py,sha256=ZsVY0S_X_BzDvcCmzCEf31v8uixbGmPAsR6nVEyCbIA,5530
10
10
  hccinfhir/model_demographics.py,sha256=7W5NLW7aAjpn25BJzqfP8iSouD9uA6epGguJJ6BPuC0,7043
11
11
  hccinfhir/model_dx_to_cc.py,sha256=guJny2Mb9z8YRNWCXGSIE3APbE06zwnA2NRkjAeUs60,1765
12
12
  hccinfhir/model_hierarchies.py,sha256=0kdBmF_8e_ikMHBDhlw2I7jT3DupHfUn6o5mWj7v3Yo,2910
13
13
  hccinfhir/model_interactions.py,sha256=ZLiKJepPjPkYceKDf7dLXoYE0p44I7t9y2sTOlrxojo,20264
14
+ hccinfhir/sample_utils.py,sha256=yXTa0UGLiNxOeHBOGQQwLyTHVMhp52kWqxzTNDUsm8E,8426
15
+ hccinfhir/samples.py,sha256=yXTa0UGLiNxOeHBOGQQwLyTHVMhp52kWqxzTNDUsm8E,8426
14
16
  hccinfhir/utils.py,sha256=AAHwzMSW8O9VZp1KLcdlN3OeBbxQtqQRtbTTdrKf7M0,2784
15
17
  hccinfhir/data/__init__.py,sha256=SGiSkpGrnxbvtEFMMlk82NFHOE50hFXcgKwKUSuVZUg,45
16
18
  hccinfhir/data/hcc_is_chronic.csv,sha256=eVVI4_8mQNkiBiNO3kattfT_zfcV18XgmiltdzZEXSo,17720
@@ -21,9 +23,9 @@ hccinfhir/data/ra_dx_to_cc_2026.csv,sha256=YT9HwQFUddL_bxuE9nxHWsBtZzojINL0DzABB
21
23
  hccinfhir/data/ra_eligible_cpt_hcpcs_2023.csv,sha256=VVoA4s0hsFmcRIugyFdbvSoeLcn7M7z0DITT6l4YqL8,39885
22
24
  hccinfhir/data/ra_eligible_cpt_hcpcs_2024.csv,sha256=CawKImfCb8fFMDbWwqvNLRyRAda_u9N8Q3ne8QAAe54,40191
23
25
  hccinfhir/data/ra_eligible_cpt_hcpcs_2025.csv,sha256=-tMvv2su5tsSbGUh6fZZCMUEkXInBpcTtbUCi2o_UwI,40359
24
- hccinfhir/data/ra_eligible_cpt_hcpcs_2026.csv,sha256=1oXFcLJQPF_fbGd1sLZU6IPolKCXOculovqIUAoMgLc,40359
26
+ hccinfhir/data/ra_eligible_cpt_hcpcs_2026.csv,sha256=EYGN7k_rgCpJe59lL_yNInUcCkdETDWGSFTXII3LZ0Y,40497
25
27
  hccinfhir/data/ra_hierarchies_2025.csv,sha256=HQSPNloe6mvvwMgv8ZwYAfWKkT2b2eUvm4JQy6S_mVQ,13045
26
- hccinfhir/data/ra_hierarchies_2026.csv,sha256=Q7xi5PpgJ4LETadup4vKoKud9ZWeu2OZVpwgr4VLpMw,19248
28
+ hccinfhir/data/ra_hierarchies_2026.csv,sha256=A6ZQZb0rpRWrySBB_KA5S4PGtMxWuzB2guU3aBE09v0,19596
27
29
  hccinfhir/samples/__init__.py,sha256=SGiSkpGrnxbvtEFMMlk82NFHOE50hFXcgKwKUSuVZUg,45
28
30
  hccinfhir/samples/sample_837_0.txt,sha256=eggrD259uHa05z2dfxWBpUDseSDp_AQcLyN_adpHyTw,5295
29
31
  hccinfhir/samples/sample_837_1.txt,sha256=E155MdemSDYoXokuTXUZ6Br_RGGedYv5t5dh-eMRmuk,1322
@@ -41,7 +43,7 @@ hccinfhir/samples/sample_eob_1.json,sha256=_NGSVR2ysFpx-DcTvyga6dFCzhQ8Vi9fNzQEM
41
43
  hccinfhir/samples/sample_eob_2.json,sha256=FcnJcx0ApOczxjJ_uxVLzCep9THfNf4xs9Yf7hxk8e4,1769
42
44
  hccinfhir/samples/sample_eob_200.ndjson,sha256=CxpjeQ1DCMUzZILaM68UEhfxO0p45YGhDDoCZeq8PxU,1917986
43
45
  hccinfhir/samples/sample_eob_3.json,sha256=4BW4wOMBEEU9RDfJR15rBEvk0KNHyuMEh3e055y87Hc,2306
44
- hccinfhir-0.1.1.dist-info/METADATA,sha256=t5eApNi_1F-OCQiB16B2W6AUxS-mPpRTni6swrLqbRg,12881
45
- hccinfhir-0.1.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
46
- hccinfhir-0.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
47
- hccinfhir-0.1.1.dist-info/RECORD,,
46
+ hccinfhir-0.1.3.dist-info/METADATA,sha256=VuJalbxDC35qPO0YOr-a4DEyKwXo_YlyrKvb5Trh5oY,13535
47
+ hccinfhir-0.1.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
48
+ hccinfhir-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
+ hccinfhir-0.1.3.dist-info/RECORD,,