pylantir 0.1.3__py3-none-any.whl → 0.2.1__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.
- pylantir/__init__.py +1 -1
- pylantir/api_server.py +769 -0
- pylantir/auth_db_setup.py +188 -0
- pylantir/auth_models.py +80 -0
- pylantir/auth_utils.py +210 -0
- pylantir/cli/run.py +322 -16
- pylantir/config/config_example_with_cors.json +108 -0
- pylantir/config/mwl_config.json +18 -0
- pylantir/db_concurrency.py +180 -0
- pylantir/db_setup.py +78 -3
- pylantir/redcap_to_db.py +225 -91
- pylantir-0.2.1.dist-info/METADATA +584 -0
- pylantir-0.2.1.dist-info/RECORD +20 -0
- pylantir-0.1.3.dist-info/METADATA +0 -193
- pylantir-0.1.3.dist-info/RECORD +0 -14
- {pylantir-0.1.3.dist-info → pylantir-0.2.1.dist-info}/WHEEL +0 -0
- {pylantir-0.1.3.dist-info → pylantir-0.2.1.dist-info}/entry_points.txt +0 -0
- {pylantir-0.1.3.dist-info → pylantir-0.2.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pylantir
|
|
3
|
-
Version: 0.1.3
|
|
4
|
-
Summary: Python - DICOM Modality WorkList
|
|
5
|
-
Author-email: Milton Camacho <miltoncamachoicc@gmail.com>
|
|
6
|
-
Requires-Python: >=3.11.1
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Classifier: Development Status :: 3 - Alpha
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Requires-Dist: pynetdicom
|
|
18
|
-
Requires-Dist: sqlalchemy
|
|
19
|
-
Requires-Dist: PyCap
|
|
20
|
-
Requires-Dist: uuid
|
|
21
|
-
Requires-Dist: coloredlogs
|
|
22
|
-
Requires-Dist: python-dotenv
|
|
23
|
-
Requires-Dist: pandas
|
|
24
|
-
Requires-Dist: pyspark>=3.0.0 ; extra == "spark"
|
|
25
|
-
Requires-Dist: bandit[toml]==1.7.5 ; extra == "test"
|
|
26
|
-
Requires-Dist: black==23.3.0 ; extra == "test"
|
|
27
|
-
Requires-Dist: check-manifest==0.49 ; extra == "test"
|
|
28
|
-
Requires-Dist: flake8-bugbear==23.5.9 ; extra == "test"
|
|
29
|
-
Requires-Dist: flake8-docstrings ; extra == "test"
|
|
30
|
-
Requires-Dist: flake8-formatter_junit_xml ; extra == "test"
|
|
31
|
-
Requires-Dist: flake8 ; extra == "test"
|
|
32
|
-
Requires-Dist: flake8-pyproject ; extra == "test"
|
|
33
|
-
Requires-Dist: pre-commit==3.3.1 ; extra == "test"
|
|
34
|
-
Requires-Dist: pylint==3.3.6 ; extra == "test"
|
|
35
|
-
Requires-Dist: pylint_junit ; extra == "test"
|
|
36
|
-
Requires-Dist: pytest-cov==4.0.0 ; extra == "test"
|
|
37
|
-
Requires-Dist: pytest-mock<3.10.1 ; extra == "test"
|
|
38
|
-
Requires-Dist: pytest-runner ; extra == "test"
|
|
39
|
-
Requires-Dist: pytest==7.3.1 ; extra == "test"
|
|
40
|
-
Requires-Dist: pytest-github-actions-annotate-failures ; extra == "test"
|
|
41
|
-
Requires-Dist: shellcheck-py==0.9.0.2 ; extra == "test"
|
|
42
|
-
Project-URL: Documentation, https://github.com/miltoncamacho/pylantir/tree/main#readme
|
|
43
|
-
Project-URL: Source, https://github.com/miltoncamacho/pylantir
|
|
44
|
-
Project-URL: Tracker, https://github.com/miltoncamacho/pylantir/issues
|
|
45
|
-
Provides-Extra: spark
|
|
46
|
-
Provides-Extra: test
|
|
47
|
-
|
|
48
|
-
<div style="text-align: center;">
|
|
49
|
-
<h1>Pylantir</h1>
|
|
50
|
-
</div>
|
|
51
|
-
<div style="text-align: center;">
|
|
52
|
-
<img src="pylantir.png" alt="Pylantir" width="50%">
|
|
53
|
-
</div>
|
|
54
|
-
|
|
55
|
-
This project's goal is to significantly reduce the number of human-related errors when manualy registering participants for medical imaging procedures.
|
|
56
|
-
|
|
57
|
-
It effectively provides a python based DICOM Modality Worklist Server (SCP) and Modality Performed Procedure Step (SCP) able to receive requests from medical imaging equipemnt based on DICOM network comunication (e.g., a C-FIND, N-CREATE, N-SET requests).
|
|
58
|
-
|
|
59
|
-
It will build/update a database based on the information entered in the study-related REDCap database using a REDCap API (You will require to have API access to the study).
|
|
60
|
-
|
|
61
|
-
## Getting Started
|
|
62
|
-
|
|
63
|
-
To get started simply install using:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
pip install pylantir
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
You need to provide your REDCap API URL and API token before starting the server.
|
|
70
|
-
Set up environmental variables before starting the server:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
export REDCAP_API_URL=<your API url>
|
|
74
|
-
export REDCAP_API_TOKEN=<your API token>
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Start a server called with AEtitle MWL_SERVER.
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
pylantir start --ip 127.0.0.1 --port 4242 --AEtitle MWL_SERVER --pylantir_config Path/to/your/config.json
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Tests
|
|
84
|
-
|
|
85
|
-
If you want to run the tests make sure to clone the repository and run them from there.
|
|
86
|
-
|
|
87
|
-
Git clone the repository:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
git clone https://github.com/miltoncamacho/pylantir
|
|
91
|
-
cd pylantir/tests
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Query the worklist database to check that you have some entries using:
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
python query-db.py
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Then, you can get a StudyUID from one of the entries to test the MPPS workflow. For example: 1.2.840.10008.3.1.2.3.4.55635351412689303463019139483773956632
|
|
101
|
-
|
|
102
|
-
Take this and run a create action to mark the worklist Procedure Step Status as IN_PROGRESS
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
python test-mpps.py --AEtitle MWL_SERVER --mpps_action create --callingAEtitle MWL_TESTER --ip 127.0.0.1 --port 4242 --study_uid 1.2.840.10008.3.1.2.3.4.55635351412689303463019139483773956632
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
You can verify that this in fact modified your database re-running:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
python query-db.py
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Finally, you can also simulate the pocedure completion efectively updating the Procedure Step Status to COMPLETED or DISCONTINUED:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
python test-mpps.py --AEtitle MWL_SERVER --mpps_action set --mpps_status COMPLETED --callingAEtitle MWL_TESTER --ip 127.0.0.1 --port 4242 --study_uid 1.2.840.10008.3.1.2.3.4.55635351412689303463019139483773956632 --sop_uid 1.2.840.10008.3.1.2.3.4.187176383255263644225774937658729238426
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Usage
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
usage: pylantir [-h] [--AEtitle AETITLE] [--ip IP] [--port PORT] [--pylantir_config PYLANTIR_CONFIG] [--mpps_action {create,set}] [--mpps_status {COMPLETED,DISCONTINUED}] [--callingAEtitle CALLINGAETITLE] [--study_uid STUDY_UID] [--sop_uid SOP_UID] {start,query-db,test-client,test-mpps}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**pylantir** - Python DICOM Modality WorkList and Modality Performed Procedure Step compliance
|
|
127
|
-
|
|
128
|
-
### Positional Arguments:
|
|
129
|
-
|
|
130
|
-
- **{start,query-db,test-client,test-mpps}**: Command to run:
|
|
131
|
-
- **start**: Start the MWL server
|
|
132
|
-
- **query-db**: Query the MWL database
|
|
133
|
-
- **test-client**: Run tests for MWL
|
|
134
|
-
- **test-mpps**: Run tests for MPPS
|
|
135
|
-
|
|
136
|
-
### Options:
|
|
137
|
-
|
|
138
|
-
- **-h, --help**: Show this help message and exit
|
|
139
|
-
- **--AEtitle AETITLE**: AE Title for the server
|
|
140
|
-
- **--ip IP**: IP/host address for the server
|
|
141
|
-
- **--port PORT**: Port for the server
|
|
142
|
-
- **--pylantir_config PYLANTIR_CONFIG**: Path to the configuration JSON file containing pylantir configs:
|
|
143
|
-
- **allowed_aet**: List of allowed AE titles e.g. `["MRI_SCANNER", "MRI_SCANNER_2"]`
|
|
144
|
-
- **site**: Site ID:string
|
|
145
|
-
- **protocol**: `{"site": "protocol_name", "mapping": "HIS/RIS mapping"}`
|
|
146
|
-
- **redcap2wl**: Dictionary of REDCap fields to worklist fields mapping e.g., `{"redcap_field": "worklist_field"}`
|
|
147
|
-
- **db_update_interval**: How often to reload the database e
|
|
148
|
-
- **operation_interval**: What is the time range in a day in which the database will be updated e.g., `{"start_time":[hours,minutes],"end_time":[hours,minutes]}`
|
|
149
|
-
- **--mpps_action {create,set}**: Action to perform for MPPS either create or set
|
|
150
|
-
- **--mpps_status {COMPLETED,DISCONTINUED}**: Status to set for MPPS either COMPLETED or DISCONTINUED
|
|
151
|
-
- **--callingAEtitle CALLINGAETITLE**: Calling AE Title for MPPS, it helps when the MWL is limited to only accept certain AE titles
|
|
152
|
-
- **--study_uid STUDY_UID**: StudyInstanceUID to test MPPS
|
|
153
|
-
- **--sop_uid SOP_UID**: SOPInstanceUID to test MPPS
|
|
154
|
-
|
|
155
|
-
## Configuration JSON file
|
|
156
|
-
|
|
157
|
-
As a default pylantir will try to read a JSON structured file with the following structure:
|
|
158
|
-
|
|
159
|
-
```json
|
|
160
|
-
{
|
|
161
|
-
"db_path": "/path/to/worklist.db",
|
|
162
|
-
"db_echo": "False",
|
|
163
|
-
"db_update_interval": 60,
|
|
164
|
-
"operation_interval": {"start_time": [0,0],"end_time": [23,59]},
|
|
165
|
-
"allowed_aet": [],
|
|
166
|
-
"site": "792",
|
|
167
|
-
"redcap2wl": {
|
|
168
|
-
"study_id": "study_id",
|
|
169
|
-
"instrument": "redcap_repeat_instrument",
|
|
170
|
-
"session_id" : "mri_instance",
|
|
171
|
-
"family_id": "family_id",
|
|
172
|
-
"youth_dob_y": "youth_dob_y",
|
|
173
|
-
"t1_date": "t1_date",
|
|
174
|
-
"demo_sex": "demo_sex",
|
|
175
|
-
"scheduled_date": "mri_date",
|
|
176
|
-
"scheduled_time": "mri_time",
|
|
177
|
-
"mri_wt_lbs": "patient_weight_lb",
|
|
178
|
-
"referring_physician": "referring_physician_name",
|
|
179
|
-
"performing_physician": "performing_physician",
|
|
180
|
-
"station_name": "station_name",
|
|
181
|
-
"status": "performed_procedure_step_status"
|
|
182
|
-
},
|
|
183
|
-
"protocol": {
|
|
184
|
-
"792": "BRAIN_MRI_3T",
|
|
185
|
-
"mapping": "GEHC"
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Clean Stop of the MWL and Database Sync
|
|
191
|
-
|
|
192
|
-
To cleanly stop the MWL server and ensure the database syncronization properly, press `Ctrl + C` (you might need to press it twice).
|
|
193
|
-
|
pylantir-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
pylantir/__init__.py,sha256=TGv-yvPCGOMmwppvQkaAlcSt-InvOfdq0v0xYV0S8fg,374
|
|
2
|
-
pylantir/db_setup.py,sha256=KTILsRrH7V5EaPqbCfOYYECM9mUB-AvOdjqjMM2H1n0,1333
|
|
3
|
-
pylantir/models.py,sha256=bKgI0EN1VSYanPTOvEhEY2Zzqa0gDYLpVnE_KNQ6PEc,1780
|
|
4
|
-
pylantir/mwl_server.py,sha256=GMJDcK0u_KM3oa6UqQ87NxMVye2pvG2cdkcI9k_iExg,10338
|
|
5
|
-
pylantir/populate_db.py,sha256=KIbkVA-EAuTlDArXMFOHkjMmVfjlsTApj7S1wpUu1bM,2207
|
|
6
|
-
pylantir/redcap_to_db.py,sha256=0LG8iJkidKFoGa0p5ruPpxj63lqnDt130MrZnHpkHXU,13508
|
|
7
|
-
pylantir/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
pylantir/cli/run.py,sha256=ZE-CIBTn3vp4APqs0U7wKW70RFM4ph-AuKkOrGbruu8,10321
|
|
9
|
-
pylantir/config/mwl_config.json,sha256=v14HXu1ft1mwFyjsowHe3H1LXZGD6sAoYuGb9_4w2kA,1008
|
|
10
|
-
pylantir-0.1.3.dist-info/entry_points.txt,sha256=vxaxvfGppLqRt9_4sqNDdP6b2jlgpcHIwP7UQfrM1T0,50
|
|
11
|
-
pylantir-0.1.3.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
|
|
12
|
-
pylantir-0.1.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
13
|
-
pylantir-0.1.3.dist-info/METADATA,sha256=PIuZiLf-idLkLvL1PcevA44fHsheFcQ9upG8dqMsyuE,7585
|
|
14
|
-
pylantir-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|