Skip to content

Commit b37d684

Browse files
committed
added is_stable prop for study
1 parent b7dc5c0 commit b37d684

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

orthanc_api_client/study.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ def series(self): # lazy creation of series objects
7878

7979
@property
8080
def last_update(self):
81-
return from_orthanc_datetime(self.info.last_update)
81+
return from_orthanc_datetime(self._api_client.studies.get_json(self.orthanc_id).get('LastUpdate'))
8282

8383
@property
8484
def labels(self):
85-
return self.info.labels
85+
return self.info.labels
86+
87+
@property
88+
def is_stable(self):
89+
return bool(self._api_client.studies.get_json(self.orthanc_id).get('IsStable'))
90+

tests/docker-setup/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
VERBOSE_ENABLED: "true"
99
ORTHANC__DICOM_AET: ORTHANCA
1010
ORTHANC__NAME: orthanc-a-for-python-api-client-tests
11+
ORTHANC__STABLE_AGE: "2"
1112
ORTHANC__REGISTERED_USERS: |
1213
{"test": "test"}
1314
ORTHANC__DICOM_MODALITIES: |

tests/test_api_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ def test_study(self):
137137
study_id = self.oa.instances.get_parent_study_id(instances_ids[0])
138138

139139
study = self.oa.studies.get(study_id)
140+
self.assertFalse(study.is_stable)
141+
last_update_1 = study.last_update
142+
time.sleep(4) # wait the study to be stable
143+
self.assertTrue(study.is_stable)
144+
145+
self.oa.upload_file(here / "stimuli/CT_small.dcm")
146+
last_update_2 = study.last_update
147+
self.assertNotEqual(last_update_1, last_update_2)
148+
140149
self.assertEqual("1CT1", study.patient_main_dicom_tags.get('PatientID'))
141150
self.assertEqual("e+1", study.main_dicom_tags.get('StudyDescription'))
142151
self.assertEqual('1.3.6.1.4.1.5962.1.2.1.20040119072730.12322', study.dicom_id)
@@ -158,6 +167,8 @@ def test_study(self):
158167
self.assertTrue(os.path.exists(file.name))
159168
self.assertTrue(os.path.getsize(file.name) > 0)
160169

170+
171+
161172
def test_series(self):
162173
self.oa.delete_all_content()
163174
instances_ids = self.oa.upload_file(here / "stimuli/CT_small.dcm")

0 commit comments

Comments
 (0)