@@ -344,6 +344,76 @@ def test_find_worklist_items_with_open_ended_date_range(self, mock_db, tmp_dir):
344344 ["20240101" ],
345345 )
346346
347+ def test_find_worklist_items_with_time_range (self , mock_db , tmp_dir ):
348+ mock_cursor = MagicMock ()
349+ mock_cursor .fetchall .return_value = []
350+ mock_connection = MagicMock ()
351+ mock_connection .execute .return_value = mock_cursor
352+ mock_db .connect .return_value = mock_connection
353+
354+ subject = MWLStorage (tmp_dir )
355+ mock_connection .reset_mock ()
356+
357+ subject .find_worklist_items (scheduled_time = "090000 - 170000" )
358+
359+ mock_connection .execute .assert_called_once_with (
360+ (
361+ "SELECT accession_number, modality, patient_birth_date, patient_id, "
362+ "patient_name, patient_sex, procedure_code, scheduled_date, scheduled_time, "
363+ "source_message_id, study_description, study_instance_uid, status, mpps_instance_uid "
364+ "FROM worklist_items WHERE scheduled_time >= ? AND scheduled_time <= ? "
365+ "ORDER BY scheduled_date, scheduled_time"
366+ ),
367+ ["090000" , "170000" ],
368+ )
369+
370+ def test_find_worklist_items_with_open_ended_time_range (self , mock_db , tmp_dir ):
371+ mock_cursor = MagicMock ()
372+ mock_cursor .fetchall .return_value = []
373+ mock_connection = MagicMock ()
374+ mock_connection .execute .return_value = mock_cursor
375+ mock_db .connect .return_value = mock_connection
376+
377+ subject = MWLStorage (tmp_dir )
378+ mock_connection .reset_mock ()
379+
380+ subject .find_worklist_items (scheduled_time = "090000 -" )
381+
382+ mock_connection .execute .assert_called_once_with (
383+ (
384+ "SELECT accession_number, modality, patient_birth_date, patient_id, "
385+ "patient_name, patient_sex, procedure_code, scheduled_date, scheduled_time, "
386+ "source_message_id, study_description, study_instance_uid, status, mpps_instance_uid "
387+ "FROM worklist_items WHERE scheduled_time >= ? "
388+ "ORDER BY scheduled_date, scheduled_time"
389+ ),
390+ ["090000" ],
391+ )
392+
393+ def test_find_worklist_items_with_date_and_time_range (self , mock_db , tmp_dir ):
394+ mock_cursor = MagicMock ()
395+ mock_cursor .fetchall .return_value = []
396+ mock_connection = MagicMock ()
397+ mock_connection .execute .return_value = mock_cursor
398+ mock_db .connect .return_value = mock_connection
399+
400+ subject = MWLStorage (tmp_dir )
401+ mock_connection .reset_mock ()
402+
403+ subject .find_worklist_items (scheduled_date = "20240101 - 20240131" , scheduled_time = "090000 - 170000" )
404+
405+ mock_connection .execute .assert_called_once_with (
406+ (
407+ "SELECT accession_number, modality, patient_birth_date, patient_id, "
408+ "patient_name, patient_sex, procedure_code, scheduled_date, scheduled_time, "
409+ "source_message_id, study_description, study_instance_uid, status, mpps_instance_uid "
410+ "FROM worklist_items WHERE scheduled_date >= ? AND scheduled_date <= ? "
411+ "AND scheduled_time >= ? AND scheduled_time <= ? "
412+ "ORDER BY scheduled_date, scheduled_time"
413+ ),
414+ ["20240101" , "20240131" , "090000" , "170000" ],
415+ )
416+
347417 def test_get_worklist_item (self , mock_db , tmp_dir , result ):
348418 mock_cursor = MagicMock ()
349419 mock_cursor .fetchone .return_value = result
0 commit comments