fhir-sheets 2.1.10__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.
- fhir_sheets-2.1.10/LICENSE +21 -0
- fhir_sheets-2.1.10/PKG-INFO +77 -0
- fhir_sheets-2.1.10/README.md +57 -0
- fhir_sheets-2.1.10/pyproject.toml +25 -0
- fhir_sheets-2.1.10/src/fhir_sheets/__init__.py +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/__init__.pyi +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/cli/__init__.py +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/cli/__init__.pyi +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/cli/main.py +69 -0
- fhir_sheets-2.1.10/src/fhir_sheets/cli/main.pyi +6 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/__init__.py +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/__init__.pyi +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/config/FhirSheetsConfiguration.py +14 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/conversion.py +403 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/conversion.pyi +22 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/fhir_formatting.py +292 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/fhir_formatting.pyi +14 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/__init__.py +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/__init__.pyi +0 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/cohort_data_entity.py +45 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/cohort_data_entity.pyi +26 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/common.py +12 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/common.pyi +3 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/resource_definition_entity.py +30 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/resource_definition_entity.pyi +13 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/resource_link_entity.py +32 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/model/resource_link_entity.pyi +13 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/read_input.py +102 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/read_input.pyi +8 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/special_values.py +361 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/special_values.pyi +52 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/util.py +1 -0
- fhir_sheets-2.1.10/src/fhir_sheets/core/util.pyi +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [fullname]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fhir-sheets
|
|
3
|
+
Version: 2.1.10
|
|
4
|
+
Summary: FhirSheets is a command-line tool that reads an Excel file in FHIR cohort format and generates FHIR bundle JSON files from it. Each row in the template Excel file is used to create an individual JSON file, outputting them to a specified folder.
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Author: Michael Riley
|
|
7
|
+
Author-email: Michael.Riley@gtri.gatech.edu
|
|
8
|
+
Requires-Python: >=3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Requires-Dist: et-xmlfile (==1.1.0)
|
|
13
|
+
Requires-Dist: jsonpath-ng (==1.6.1)
|
|
14
|
+
Requires-Dist: openpyxl (==3.1.5)
|
|
15
|
+
Requires-Dist: orjson (==3.10.7)
|
|
16
|
+
Requires-Dist: ply (==3.11)
|
|
17
|
+
Requires-Dist: pytest (==8.4.2)
|
|
18
|
+
Requires-Dist: pytest_cov (==7.0.0)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# FHIRSheets
|
|
22
|
+
|
|
23
|
+
FhirSheets is a command-line tool that reads an Excel file in FHIR cohort format and generates FHIR bundle JSON files from it. Each row in the template Excel file is used to create an individual JSON file, outputting them to a specified folder.
|
|
24
|
+
|
|
25
|
+
## Table of Contents
|
|
26
|
+
- [FHIRSheets](#fhirsheets)
|
|
27
|
+
- [Table of Contents](#table-of-contents)
|
|
28
|
+
- [Features](#features)
|
|
29
|
+
- [Requirements](#requirements)
|
|
30
|
+
- [Installation](#installation)
|
|
31
|
+
- [Usage](#Usage)
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
- Reads an Excel file following the FHIR cohort import template.
|
|
35
|
+
- Converts each row in the Excel file to a FHIR bundle JSON file.
|
|
36
|
+
- Exports generated JSON files to a specified output folder.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
- Python 3.x
|
|
40
|
+
- Required Python packages (see `requirements.txt`)
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
1. Clone this repository:
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/CDCgov/synthetic-data.git
|
|
46
|
+
cd fhir-python-cohort-generation
|
|
47
|
+
2. Install the required packages:
|
|
48
|
+
```bash
|
|
49
|
+
pip install -r requirements.txt
|
|
50
|
+
```
|
|
51
|
+
Or use poetry
|
|
52
|
+
```bash
|
|
53
|
+
poetry build
|
|
54
|
+
```
|
|
55
|
+
## Usage
|
|
56
|
+
1. **Fill Out the Template:**
|
|
57
|
+
- Open the template file `src/resources/Fhir_Cohort_Import_Template.xlsx`.
|
|
58
|
+
- Fill out each row with the relevant data.
|
|
59
|
+
|
|
60
|
+
2. **Run the Tool:**
|
|
61
|
+
- Use the `python -m src.cli.fhirsheets` module script with the required arguments:
|
|
62
|
+
- `--input-file`: The path to the input Excel file.
|
|
63
|
+
- `--output-folder`: The path to the output folder where the JSON files will be saved.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m src.fhir_sheets.cli.main --input_file src/resources/Fhir_Cohort_Import_Template.xlsx --output_folder /path/to/output/folder
|
|
67
|
+
3. The tool will generate one FHIR bundle JSON file for each row defined in the template.
|
|
68
|
+
|
|
69
|
+
## Example
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python -m src.fhir_sheets.cli.main --input_file src/resources/Fhir_Cohort_Import_Template.xlsx --output_folder ./output_bundles
|
|
73
|
+
In this example, each row in the `Fhir_Cohort_Import_Template.xlsx` file will be processed, and a corresponding JSON file will be generated in the `output_bundles` folder.
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
This project is licensed under the MIT License. See the `LICENSE` file for more information.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# FHIRSheets
|
|
2
|
+
|
|
3
|
+
FhirSheets is a command-line tool that reads an Excel file in FHIR cohort format and generates FHIR bundle JSON files from it. Each row in the template Excel file is used to create an individual JSON file, outputting them to a specified folder.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [FHIRSheets](#fhirsheets)
|
|
7
|
+
- [Table of Contents](#table-of-contents)
|
|
8
|
+
- [Features](#features)
|
|
9
|
+
- [Requirements](#requirements)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Usage](#Usage)
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
- Reads an Excel file following the FHIR cohort import template.
|
|
15
|
+
- Converts each row in the Excel file to a FHIR bundle JSON file.
|
|
16
|
+
- Exports generated JSON files to a specified output folder.
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
- Python 3.x
|
|
20
|
+
- Required Python packages (see `requirements.txt`)
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
1. Clone this repository:
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/CDCgov/synthetic-data.git
|
|
26
|
+
cd fhir-python-cohort-generation
|
|
27
|
+
2. Install the required packages:
|
|
28
|
+
```bash
|
|
29
|
+
pip install -r requirements.txt
|
|
30
|
+
```
|
|
31
|
+
Or use poetry
|
|
32
|
+
```bash
|
|
33
|
+
poetry build
|
|
34
|
+
```
|
|
35
|
+
## Usage
|
|
36
|
+
1. **Fill Out the Template:**
|
|
37
|
+
- Open the template file `src/resources/Fhir_Cohort_Import_Template.xlsx`.
|
|
38
|
+
- Fill out each row with the relevant data.
|
|
39
|
+
|
|
40
|
+
2. **Run the Tool:**
|
|
41
|
+
- Use the `python -m src.cli.fhirsheets` module script with the required arguments:
|
|
42
|
+
- `--input-file`: The path to the input Excel file.
|
|
43
|
+
- `--output-folder`: The path to the output folder where the JSON files will be saved.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python -m src.fhir_sheets.cli.main --input_file src/resources/Fhir_Cohort_Import_Template.xlsx --output_folder /path/to/output/folder
|
|
47
|
+
3. The tool will generate one FHIR bundle JSON file for each row defined in the template.
|
|
48
|
+
|
|
49
|
+
## Example
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python -m src.fhir_sheets.cli.main --input_file src/resources/Fhir_Cohort_Import_Template.xlsx --output_folder ./output_bundles
|
|
53
|
+
In this example, each row in the `Fhir_Cohort_Import_Template.xlsx` file will be processed, and a corresponding JSON file will be generated in the `output_bundles` folder.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
This project is licensed under the MIT License. See the `LICENSE` file for more information.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "fhir-sheets"
|
|
3
|
+
version = "2.1.10"
|
|
4
|
+
description = "FhirSheets is a command-line tool that reads an Excel file in FHIR cohort format and generates FHIR bundle JSON files from it. Each row in the template Excel file is used to create an individual JSON file, outputting them to a specified folder."
|
|
5
|
+
authors = ["Michael Riley <Michael.Riley@gtri.gatech.edu>"]
|
|
6
|
+
packages = [{include = "fhir_sheets", from = "src"}]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
long-description-content-type = "text/markdown"
|
|
9
|
+
|
|
10
|
+
[tool.poetry.dependencies]
|
|
11
|
+
python = ">=3.13" # Specify the compatible Python version here
|
|
12
|
+
et-xmlfile = "1.1.0"
|
|
13
|
+
jsonpath-ng = "1.6.1"
|
|
14
|
+
openpyxl = "3.1.5"
|
|
15
|
+
orjson = "3.10.7"
|
|
16
|
+
ply = "3.11"
|
|
17
|
+
pytest = "8.4.2"
|
|
18
|
+
pytest_cov = "7.0.0"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["poetry-core"]
|
|
22
|
+
build-backend = "poetry.core.masonry.api"
|
|
23
|
+
|
|
24
|
+
[pytest]
|
|
25
|
+
testpaths = ["tests"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from ..core.config.FhirSheetsConfiguration import FhirSheetsConfiguration
|
|
2
|
+
from ..core import read_input
|
|
3
|
+
from ..core import conversion
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import orjson
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from pprint import pprint
|
|
10
|
+
|
|
11
|
+
def find_sets(d, path=""):
|
|
12
|
+
if isinstance(d, dict):
|
|
13
|
+
for key, value in d.items():
|
|
14
|
+
new_path = f"{path}.{key}" if path else str(key)
|
|
15
|
+
find_sets(value, new_path)
|
|
16
|
+
elif isinstance(d, list): # Handle lists of dictionaries
|
|
17
|
+
for idx, item in enumerate(d):
|
|
18
|
+
find_sets(item, f"{path}[{idx}]")
|
|
19
|
+
elif isinstance(d, set):
|
|
20
|
+
print(f"Set found at path: {path}")
|
|
21
|
+
|
|
22
|
+
def main(input_file, output_folder, config=FhirSheetsConfiguration({})):
|
|
23
|
+
# Step 1: Read the input file using read_input module
|
|
24
|
+
|
|
25
|
+
# Check if the output folder exists, and create it if not
|
|
26
|
+
|
|
27
|
+
output_folder_path = Path(output_folder)
|
|
28
|
+
if not output_folder_path.is_absolute():
|
|
29
|
+
output_folder_path = Path().cwd() / Path(output_folder)
|
|
30
|
+
if not output_folder_path.exists():
|
|
31
|
+
output_folder_path.mkdir(parents=True, exist_ok=True) # Create the folder if it doesn't exist
|
|
32
|
+
resource_definition_entities, resource_link_entities, cohort_data = read_input.read_xlsx_and_process(input_file)
|
|
33
|
+
#For each index of patients
|
|
34
|
+
for i in range(0,cohort_data.get_num_patients()):
|
|
35
|
+
# Construct the file path for each JSON file
|
|
36
|
+
file_path = output_folder_path / f"{i}.json"
|
|
37
|
+
#Create a bundle
|
|
38
|
+
fhir_bundle = conversion.create_transaction_bundle(resource_definition_entities, resource_link_entities, cohort_data, i, config)
|
|
39
|
+
# Step 3: Write the processed data to the output file
|
|
40
|
+
find_sets(fhir_bundle)
|
|
41
|
+
json_string = orjson.dumps(fhir_bundle)
|
|
42
|
+
with open(file_path, 'wb') as json_file:
|
|
43
|
+
json_file.write(json_string)
|
|
44
|
+
with open(file_path, 'r') as json_file:
|
|
45
|
+
json_string = json.load(json_file)
|
|
46
|
+
with open(file_path, 'w') as json_file:
|
|
47
|
+
json.dump(json_string, json_file, indent = 4)
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
# Create the argparse CLI
|
|
51
|
+
parser = argparse.ArgumentParser(description="Process input, convert data, and write output.")
|
|
52
|
+
|
|
53
|
+
# Define the input file argument
|
|
54
|
+
parser.add_argument('--input_file', type=str, help="Path to the input xlsx ", default="src/resources/Synthetic_Input_Baseline.xlsx")
|
|
55
|
+
|
|
56
|
+
# Define the output file argument
|
|
57
|
+
parser.add_argument('--output_folder', type=str, help="Path to save the output files", default="output/")
|
|
58
|
+
|
|
59
|
+
# Config object arguments
|
|
60
|
+
parser.add_argument('--preview_mode', type=str, help="Configuration option to generate resources as 'preview mode' references will reference the entity name. Will primarily be used to render a singular resource for preview.", default=False)
|
|
61
|
+
|
|
62
|
+
# Define the output file argument
|
|
63
|
+
parser.add_argument('--medications_as_reference', type=str, help="Configuration option to create medication references. You may still provide medicationCodeableConcept, but a post process will convert the codeableconcepts to medication resources", default=False)
|
|
64
|
+
# Parse the arguments
|
|
65
|
+
args = parser.parse_args()
|
|
66
|
+
|
|
67
|
+
# Call the main function with the provided arguments
|
|
68
|
+
config = FhirSheetsConfiguration(vars(args))
|
|
69
|
+
main(args.input_file, args.output_folder, config)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from ..core import conversion as conversion, read_input as read_input
|
|
2
|
+
from ..core.config.FhirSheetsConfiguration import FhirSheetsConfiguration as FhirSheetsConfiguration
|
|
3
|
+
from pprint import pprint as pprint
|
|
4
|
+
|
|
5
|
+
def find_sets(d, path: str = '') -> None: ...
|
|
6
|
+
def main(input_file, output_folder, config=...) -> None: ...
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class FhirSheetsConfiguration():
|
|
5
|
+
def __init__(self, data: Dict[str, Any]):
|
|
6
|
+
self.preview_mode = data.get('preview_mode', False)
|
|
7
|
+
self.medications_as_reference = data.get('medications_as_reference', False)
|
|
8
|
+
self.random_seed = data.get('random_seed', False)
|
|
9
|
+
|
|
10
|
+
def __repr__(self) -> str:
|
|
11
|
+
return (f"FhirSheetsConfiguration("
|
|
12
|
+
f"preview_mode={self.preview_mode}, "
|
|
13
|
+
f"medications_as_reference={self.medications_as_reference}, "
|
|
14
|
+
f"random_seed={self.random_seed})")
|