pylantir 0.0.6__py3-none-any.whl → 0.0.7__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/mwl_server.py +58 -32
- {pylantir-0.0.6.dist-info → pylantir-0.0.7.dist-info}/METADATA +2 -2
- {pylantir-0.0.6.dist-info → pylantir-0.0.7.dist-info}/RECORD +5 -5
- {pylantir-0.0.6.dist-info → pylantir-0.0.7.dist-info}/WHEEL +1 -1
- {pylantir-0.0.6.dist-info → pylantir-0.0.7.dist-info}/entry_points.txt +0 -0
pylantir/mwl_server.py
CHANGED
|
@@ -45,38 +45,58 @@ def row_to_mwl_dataset(row: WorklistItem) -> Dataset:
|
|
|
45
45
|
ds = Dataset()
|
|
46
46
|
|
|
47
47
|
# Standard Patient Attributes
|
|
48
|
-
ds.PatientName = row.patient_name
|
|
49
|
-
ds.PatientID = row.patient_id
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
ds.PatientName = row.patient_name or "UNKNOWN"
|
|
49
|
+
ds.PatientID = row.patient_id or "UNKNOWN"
|
|
50
|
+
# ds.IssuerOfPatientID = row.issuer_of_patient_id
|
|
51
|
+
ds.PatientBirthDate = row.patient_birth_date or ""
|
|
52
|
+
ds.PatientSex = row.patient_sex or ""
|
|
53
|
+
# ds.OtherPatientIDs = row.other_patient_ids or ""
|
|
54
|
+
# ds.PatientAge = row.patient_age or ""
|
|
55
|
+
# ds.PatientSize = row.patient_size or "0"
|
|
56
|
+
ds.PatientWeight = row.patient_weight_lb or "100"
|
|
57
|
+
# ds.MedicalAlerts = row.medical_alerts or ""
|
|
58
|
+
# ds.Allergies = row.allergies or ""
|
|
59
|
+
# ds.AdditionalPatientHistory = row.additional_patient_history or ""
|
|
60
|
+
# ds.PregnancyStatus = row.pregnancy_status or "0"
|
|
61
|
+
|
|
62
|
+
# Study-Level Attributes
|
|
63
|
+
ds.StudyInstanceUID = row.study_instance_uid or ""
|
|
64
|
+
# ds.StudyDate = row.study_date or ""
|
|
65
|
+
# ds.StudyTime = row.study_time or ""
|
|
66
|
+
# ds.AccessionNumber = row.accession_number or ""
|
|
67
|
+
ds.ReferringPhysicianName = row.referring_physician_name or ""
|
|
68
|
+
ds.StudyDescription = row.study_description or ""
|
|
69
|
+
# ds.NameOfPhysiciansReadingStudy = row.reading_physicians or ""
|
|
70
|
+
# ds.OperatorsName = row.operators_name or ""
|
|
71
|
+
|
|
72
|
+
# Requested Procedure Attributes
|
|
73
|
+
# ds.RequestingPhysician = row.requesting_physician or ""
|
|
74
|
+
# ds.RequestedProcedureDescription = row.requested_procedure_description or "111"
|
|
75
|
+
ds.RequestedProcedureDescription = "111"
|
|
76
|
+
# ds.RequestedProcedureID = row.requested_procedure_id or ""
|
|
77
|
+
ds.RequestedProcedureID = "111"
|
|
78
|
+
# Admission & Patient State
|
|
79
|
+
# ds.AdmissionID = row.admission_id or ""
|
|
80
|
+
# ds.IssuerOfAdmissionID = row.issuer_of_admission_id or ""
|
|
81
|
+
# ds.SpecialNeeds = row.special_needs or ""
|
|
82
|
+
# ds.CurrentPatientLocation = row.current_patient_location or ""
|
|
83
|
+
# ds.PatientState = row.patient_state or ""
|
|
64
84
|
|
|
65
85
|
# Scheduled Procedure Step Sequence
|
|
66
86
|
sps = Dataset()
|
|
67
87
|
sps.Modality = row.modality or "MR"
|
|
68
|
-
sps.ScheduledStationAETitle = row.scheduled_station_aetitle or ""
|
|
88
|
+
# sps.ScheduledStationAETitle = row.scheduled_station_aetitle or ""
|
|
69
89
|
sps.ScheduledProcedureStepStartDate = row.scheduled_start_date or ""
|
|
70
90
|
sps.ScheduledProcedureStepStartTime = row.scheduled_start_time or ""
|
|
71
|
-
sps.ScheduledPerformingPhysicianName = row.performing_physician or ""
|
|
72
|
-
sps.ScheduledProcedureStepDescription = row.
|
|
91
|
+
# sps.ScheduledPerformingPhysicianName = row.performing_physician or ""
|
|
92
|
+
sps.ScheduledProcedureStepDescription = row.protocol_name or "DEFAULT_PROCEDURE"
|
|
73
93
|
sps.ScheduledStationName = row.station_name or ""
|
|
94
|
+
sps.ScheduledProcedureStepStatus = row.performed_procedure_step_status or "SCHEDULED"
|
|
74
95
|
|
|
75
|
-
#
|
|
76
|
-
# TODO: improve the protocol name handling
|
|
96
|
+
# Protocol Code Sequence
|
|
77
97
|
if row.protocol_name:
|
|
78
98
|
protocol_seq = Dataset()
|
|
79
|
-
protocol_seq.CodeValue = row.protocol_name[:16]
|
|
99
|
+
protocol_seq.CodeValue = row.protocol_name[:16]
|
|
80
100
|
protocol_seq.CodingSchemeDesignator = "LOCAL"
|
|
81
101
|
protocol_seq.CodeMeaning = row.protocol_name
|
|
82
102
|
sps.ScheduledProtocolCodeSequence = [protocol_seq]
|
|
@@ -103,7 +123,11 @@ def handle_mwl_find(event):
|
|
|
103
123
|
|
|
104
124
|
# Only return worklist entries that are still scheduled
|
|
105
125
|
query = query.filter(
|
|
106
|
-
or_(
|
|
126
|
+
or_(
|
|
127
|
+
WorklistItem.performed_procedure_step_status == "SCHEDULED",
|
|
128
|
+
WorklistItem.performed_procedure_step_status == "IN_PROGRESS",
|
|
129
|
+
WorklistItem.performed_procedure_step_status == "DISCONTINUED"
|
|
130
|
+
)
|
|
107
131
|
)
|
|
108
132
|
|
|
109
133
|
results = query.all()
|
|
@@ -154,14 +178,16 @@ def handle_mpps_n_create(event):
|
|
|
154
178
|
managed_instances[ds.SOPInstanceUID] = ds
|
|
155
179
|
|
|
156
180
|
# Update database: Set status to IN_PROGRESS
|
|
157
|
-
|
|
181
|
+
patient_id = ds.get("PatientID", None)
|
|
158
182
|
session = Session()
|
|
159
|
-
if
|
|
160
|
-
entry = session.query(WorklistItem).filter_by(
|
|
183
|
+
if patient_id:
|
|
184
|
+
entry = session.query(WorklistItem).filter_by(patient_id=patient_id).first()
|
|
161
185
|
if entry:
|
|
162
186
|
entry.performed_procedure_step_status = "IN_PROGRESS"
|
|
163
187
|
session.commit()
|
|
164
|
-
lgr.info(f"DB updated:
|
|
188
|
+
lgr.info(f"DB updated: PatientID {patient_id} set to IN_PROGRESS")
|
|
189
|
+
else:
|
|
190
|
+
lgr.warning("MPPS N-SET received without StudyInstanceUID. Database update skipped.")
|
|
165
191
|
session.close()
|
|
166
192
|
|
|
167
193
|
lgr.info(f"MPPS N-CREATE success: {ds.SOPInstanceUID} set to IN PROGRESS")
|
|
@@ -184,21 +210,21 @@ def handle_mpps_n_set(event):
|
|
|
184
210
|
|
|
185
211
|
# Log status update
|
|
186
212
|
new_status = ds.get("PerformedProcedureStepStatus", None)
|
|
187
|
-
|
|
213
|
+
patient_id = ds.get("PatientID", None)
|
|
188
214
|
|
|
189
215
|
# Update database
|
|
190
216
|
session = Session()
|
|
191
|
-
if
|
|
192
|
-
entry = session.query(WorklistItem).filter_by(
|
|
217
|
+
if patient_id and new_status:
|
|
218
|
+
entry = session.query(WorklistItem).filter_by(patient_id=patient_id).first()
|
|
193
219
|
if entry:
|
|
194
220
|
if new_status.upper() == "COMPLETED":
|
|
195
221
|
entry.performed_procedure_step_status = "COMPLETED"
|
|
196
222
|
session.commit()
|
|
197
|
-
lgr.info(f"DB updated:
|
|
223
|
+
lgr.info(f"DB updated: PatientID {patient_id} set to COMPLETED")
|
|
198
224
|
elif new_status.upper() == "DISCONTINUED":
|
|
199
225
|
entry.performed_procedure_step_status = "DISCONTINUED"
|
|
200
226
|
session.commit()
|
|
201
|
-
lgr.info(f"DB updated:
|
|
227
|
+
lgr.info(f"DB updated: PatientID {patient_id} set to DISCONTINUED")
|
|
202
228
|
session.close()
|
|
203
229
|
|
|
204
230
|
lgr.info(f"MPPS N-SET success: {req.RequestedSOPInstanceUID} updated to {new_status}")
|
|
@@ -2,13 +2,13 @@ pylantir/.env,sha256=qU4xxA3iOy2DQGT78CQG05ljTsFwKzgF2wXdnBpg8xQ,56
|
|
|
2
2
|
pylantir/__init__.py,sha256=kl2Et644PvUIvziU4BTxiTD1W4_g7E0xBYCHgPE6RZc,363
|
|
3
3
|
pylantir/db_setup.py,sha256=KTILsRrH7V5EaPqbCfOYYECM9mUB-AvOdjqjMM2H1n0,1333
|
|
4
4
|
pylantir/models.py,sha256=FURRE7lRd8UBGTmLD9ozcNVW8kJV-M9Pz9bovSRKlh8,1625
|
|
5
|
-
pylantir/mwl_server.py,sha256=
|
|
5
|
+
pylantir/mwl_server.py,sha256=GZzeocz_WhnDWjjdPK9DAiRN-NoCvMxK77qjjl58mRM,9942
|
|
6
6
|
pylantir/populate_db.py,sha256=KIbkVA-EAuTlDArXMFOHkjMmVfjlsTApj7S1wpUu1bM,2207
|
|
7
7
|
pylantir/redcap_to_db.py,sha256=ITiMAY-XB7B_-_8jUSAjdNqTngULjXBbWYjY4_Byh1U,8465
|
|
8
8
|
pylantir/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
pylantir/cli/run.py,sha256=aF_koq7zGo1q7pU68Bw776hWz_eNBvVkcm-nG_-vwIo,10293
|
|
10
10
|
pylantir/config/mwl_config.json,sha256=1Ma2guYAEAXQh1z7959aZadAn3ORjBqnDDibSLcwv_g,851
|
|
11
|
-
pylantir-0.0.
|
|
12
|
-
pylantir-0.0.
|
|
13
|
-
pylantir-0.0.
|
|
14
|
-
pylantir-0.0.
|
|
11
|
+
pylantir-0.0.7.dist-info/entry_points.txt,sha256=vxaxvfGppLqRt9_4sqNDdP6b2jlgpcHIwP7UQfrM1T0,50
|
|
12
|
+
pylantir-0.0.7.dist-info/WHEEL,sha256=_2ozNFCLWc93bK4WKHCO-eDUENDlo-dgc9cU3qokYO4,82
|
|
13
|
+
pylantir-0.0.7.dist-info/METADATA,sha256=5jHgpbRFJ8n7dvIBvFYrirZoflaw6hvTNa-Csc0Gzk0,7176
|
|
14
|
+
pylantir-0.0.7.dist-info/RECORD,,
|
|
File without changes
|