Mercurial > hg > orthanc-book
comparison Sphinx/source/users/lua.rst @ 77:48c7d2eb98da
Fixing C-Find requests
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Dec 2016 11:04:32 +0100 |
parents | 16d516fdc642 |
children | d6bd1dd820e5 |
comparison
equal
deleted
inserted
replaced
76:c2f2202f54f2 | 77:48c7d2eb98da |
---|---|
408 (``OnStablePatient()``, ``OnStableStudy()`` and ``OnStableSeries()``) | 408 (``OnStablePatient()``, ``OnStableStudy()`` and ``OnStableSeries()``) |
409 to react to other events than the reception of a single instance | 409 to react to other events than the reception of a single instance |
410 with ``OnStoredInstance()``. | 410 with ``OnStoredInstance()``. |
411 | 411 |
412 | 412 |
413 Fixing C-Find | 413 Fixing C-Find requests |
414 ------------- | 414 ---------------------- |
415 | 415 |
416 :ref:`C-Find requests <dicom-find>` are sometimes interpreted | 416 :ref:`C-Find requests <dicom-find>` are sometimes interpreted |
417 differently by different manufacturers (e.g. the ``*`` wildcard), and | 417 differently by different DICOM servers (e.g. the ``*`` wildcard, as |
418 sometimes a querying modality sets | 418 `reported by users |
419 <https://groups.google.com/d/msg/orthanc-users/3g7V7kqr3g0/IREL88RWAwAJ>`__), | |
420 and sometimes a querying modality might set unexpected DICOM tags | |
421 (cf. `this real-world example | |
422 <https://groups.google.com/d/msg/orthanc-users/PLWKqVVaXLs/n_0x4vKhAgAJ>`__). In | |
423 such situations, it is possible to dynamically fix incoming or | |
424 outgoing C-Find queries using a Lua script. | |
425 | |
426 Fixing incoming C-Find requests can be done by implementing the | |
427 ``IncomingFindRequestFilter(query, origin)`` callback that is called | |
428 whenever the Orthanc C-Find SCP is queried by a remote modality. For | |
429 instance, here is Lua script to remove a private tag that is specified | |
430 by some manufacturer:: | |
431 | |
432 function IncomingFindRequestFilter(query, origin) | |
433 -- First display the content of the C-Find query | |
434 PrintRecursive(query) | |
435 PrintRecursive(origin) | |
436 | |
437 -- Remove the "PrivateCreator" tag from the query | |
438 local v = query | |
439 v['5555,0010'] = nil | |
440 | |
441 return v | |
442 end | |
443 | |
444 The ``origin`` argument contains information about which modality has | |
445 issued the request. | |
446 | |
447 Similarly, the callback ``OutgoingFindRequestFilter(query, modality)`` | |
448 is invoked whenever Orthanc acts as a C-Find SCU, which gives the | |
449 opportunity to dynamically fix outgoing C-Find requests before they | |
450 are actually sent to the queried modality. For instance, here is a | |
451 sample Lua callback that would replace asterisk wildcards (i.e. ``*``) | |
452 by an empty string for any query/retrieve issued by Orthanc (including | |
453 from Orthanc Explorer):: | |
454 | |
455 function OutgoingFindRequestFilter(query, modality) | |
456 for key, value in pairs(query) do | |
457 if value == '*' then | |
458 query[key] = '' | |
459 end | |
460 end | |
461 | |
462 return query | |
463 end |