Skip to content

Commit dbf13c4

Browse files
MWLServer now supports C-ECHO (#122)
`MWLServer`: registers a C-ECHO handler and adds `Verification` to its supported presentation contexts. `PACSServer`: adds `Verification` to its supported presentation contexts. A C-ECHO handler was already registered, but without the Verification context the association would be rejected before reaching it. pynetdicom's [Verification Service Examples](https://pydicom.github.io/pynetdicom/stable/examples/verification.html) shows that an SCP must explicitly call `ae.add_supported_context(Verification)`.
1 parent 802cd28 commit dbf13c4

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
DigitalMammographyXRayImageStorageForProcessing, # type: ignore[attr-defined]
1515
ModalityPerformedProcedureStep, # type: ignore[attr-defined]
1616
ModalityWorklistInformationFind, # type: ignore[attr-defined]
17+
Verification, # type: ignore[attr-defined]
1718
)
1819

1920
from services.dicom.c_echo import CEcho
@@ -68,6 +69,7 @@ def start(self):
6869
dicom_uid.JPEG2000Lossless,
6970
]
7071
self.ae = AE(ae_title=self.ae_title)
72+
self.ae.add_supported_context(Verification)
7173
self.ae.add_supported_context(DigitalMammographyXRayImageStorageForPresentation, transfer_syntaxes)
7274
self.ae.add_supported_context(DigitalMammographyXRayImageStorageForProcessing, transfer_syntaxes)
7375

@@ -120,10 +122,12 @@ def start(self):
120122
logger.info(f"Starting MWL server: {self.ae_title} on port {self.port}")
121123

122124
self.ae = AE(ae_title=self.ae_title)
125+
self.ae.add_supported_context(Verification)
123126
self.ae.add_supported_context(ModalityWorklistInformationFind)
124127
self.ae.add_supported_context(ModalityPerformedProcedureStep)
125128

126129
handlers = [
130+
(evt.EVT_C_ECHO, CEcho().call),
127131
(evt.EVT_C_FIND, CFind(self.storage).call),
128132
(evt.EVT_N_CREATE, NCreate(self.storage).call),
129133
(evt.EVT_N_SET, NSet(self.storage).call),

tests/test_server.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
DigitalMammographyXRayImageStorageForProcessing,
88
ModalityPerformedProcedureStep,
99
ModalityWorklistInformationFind,
10+
Verification,
1011
)
1112

1213
from server import MWLServer, PACSServer
@@ -54,6 +55,7 @@ def test_start(self, mock_c_store, mock_c_echo, mock_ae, _mock_pacs_storage, _mo
5455

5556
mock_ae.assert_called_once_with(ae_title="SCREENING_PACS")
5657
add_context_calls = [call.args[0] for call in mock_ae.return_value.add_supported_context.call_args_list]
58+
assert Verification in add_context_calls
5759
assert DigitalMammographyXRayImageStorageForPresentation in add_context_calls
5860
assert DigitalMammographyXRayImageStorageForProcessing in add_context_calls
5961
mock_ae.return_value.start_server.assert_called_once_with(
@@ -100,7 +102,8 @@ def test_init_defaults(self, mock_storage):
100102
mock_storage.assert_called_once_with("/var/lib/pacs/worklist.db")
101103

102104
@patch(f"{MWLServer.__module__}.AE")
103-
def test_start(self, mock_ae, _):
105+
@patch(f"{MWLServer.__module__}.CEcho")
106+
def test_start(self, mock_c_echo, mock_ae, _):
104107
subject = MWLServer()
105108
mock_ae_instance = MagicMock()
106109
mock_ae.return_value = mock_ae_instance
@@ -110,6 +113,7 @@ def test_start(self, mock_ae, _):
110113
assert subject.ae == mock_ae_instance
111114

112115
mock_ae.assert_called_once_with(ae_title="MWL_SCP")
116+
mock_ae_instance.add_supported_context.assert_any_call(Verification)
113117
mock_ae_instance.add_supported_context.assert_any_call(
114118
ModalityWorklistInformationFind,
115119
)
@@ -121,7 +125,8 @@ def test_start(self, mock_ae, _):
121125
assert args[0] == ("0.0.0.0", 4243)
122126
assert kwargs["block"] is True
123127
assert "evt_handlers" in kwargs
124-
assert len(kwargs["evt_handlers"]) == 3
128+
assert (evt.EVT_C_ECHO, mock_c_echo.return_value.call) in kwargs["evt_handlers"]
129+
assert len(kwargs["evt_handlers"]) == 4
125130

126131
@patch(f"{MWLServer.__module__}.AE")
127132
def test_stop(self, *_):

0 commit comments

Comments
 (0)