annotate Sphinx/source/users/lua.rst @ 850:989f00cd4dfa

MediaArchiveSize
author Alain Mazy <am@osimis.io>
date Mon, 30 May 2022 09:49:13 +0200
parents 2f8ee0aef0a6
children 035fe50b2e00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _lua:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 Server-side scripting with Lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 ==============================
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 .. contents::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 Since release 0.5.2, Orthanc supports server-side scripting through
25
669ea65ba7fb fix links
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
9 the `Lua <https://en.wikipedia.org/wiki/Lua_(programming_language)>`__
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 scripting language. Thanks to this major feature, Orthanc can be tuned
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 to specific medical workflows without being driven by an external
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 script. This page summarizes the possibilities of Orthanc server-side
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 scripting.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 Many other examples are `available in the source distribution
449
2922fb1bd65e fix links
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 443
diff changeset
16 <https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Resources/Samples/Lua/>`__.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
606
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
18 A more expressive alternative to Lua scripts is provided by
846
2f8ee0aef0a6 added uclouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 836
diff changeset
19 :ref:`Python plugins <python-plugin>`.
606
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
20
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
22 Installing a Lua script
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 -----------------------
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 .. highlight:: bash
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 A custom Lua script can be installed either by the :ref:`configuration
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 file <configuration>`, or by uploading it
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 through the :ref:`REST API <rest-samples>`.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 To install it by the **configuration file** method, you just have to
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 specify the path to the file containing the Lua script in the
357
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
33 ``LuaScripts`` variable. A comma-separated list of paths can be
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
34 specified to install multiple scripts.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 To upload a script stored in the file "``script.lua``" through the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 **REST API**, use the following command::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 $ curl -X POST http://localhost:8042/tools/execute-script --data-binary @script.lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 Pay attention to the fact that, contrarily to the scripts installed
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 from the configuration file, the scripts installed through the REST
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 API are non-persistent: They are discarded after a restart of Orthanc,
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 which makes them useful for script prototyping. You can also interpret
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 a single Lua command through the REST API::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 $ curl -X POST http://localhost:8042/tools/execute-script --data-binary "print(42)"
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 *Note:* The ``--data-binary`` cURL option is used instead of
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 ``--data`` to prevent the interpretation of newlines by cURL, which is
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 `mandatory for the proper evaluation
358
011b01ccf52d fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
52 <https://stackoverflow.com/questions/3872427/how-to-send-line-break-with-curl>`__
011b01ccf52d fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
53 of the possible comments inside the Lua script.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 Lua API
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 -------
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 .. _lua-callbacks:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 Callbacks to react to events
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
355
e4e9cca89c64 clarified mutual exclusion of Lua scripts callbacks.
David Wikler <david.wikler@ulb.ac.be>
parents: 319
diff changeset
64 The Lua engine of Orthanc invokes the following callbacks that
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 are triggered on various events. Here are the **generic events**:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 * ``function Initialize()``: Invoked as soon as the Orthanc server is started.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 * ``function Finalize()``: Invoked just before the Orthanc server is stopped.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 Some **permission-related events** allow to filter incoming requests:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
387
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
72 * ``function ReceivedInstanceFilter(dicom, origin, info)``: Invoked to
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
73 known whether an incoming DICOM instance should be
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 accepted. :ref:`See this section <lua-filter-dicom>`. The ``origin``
387
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
75 parameter is :ref:`documented separately <lua-origin>`. The ``info``
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
76 parameter contains additional information and was added in Orthanc
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
77 1.6.1.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 * ``function IncomingHttpRequestFilter(method, uri, ip, username,
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 httpHeaders)``: Invoked to known whether a REST request should be
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 accepted. :ref:`See this section <lua-filter-rest>`.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
232
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
82 Some **job-related events** allow to react to :ref:`job <jobs>` completion/failure:
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
83
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
84 * ``function OnJobSubmitted(jobId)``:
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
85 Invoked when a new job has been submitted. Note that this does not
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
86 mean the the job execution has started.
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
87 * ``function OnJobFailure(jobId)``:
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
88 Invoked when a job has failed.
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
89 * ``function OnJobSuccess(jobId)``:
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
90 Invoked when a job has completed successfully.
15823481cf8f added Jobs Lua callback
amazy
parents: 191
diff changeset
91
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 Some **DICOM-related events** allow to react to the reception of
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 new medical images:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 * ``function OnStoredInstance(instanceId, tags, metadata, origin)``:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 Invoked whenever a new instance has been stored into Orthanc.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 This is especially useful for :ref:`lua-auto-routing`. The ``origin``
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 parameter is :ref:`documented separately <lua-origin>`.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 * ``function OnStablePatient(patientId, tags, metadata)``: Invoked
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 whenever a patient has not received any new instance for a certain
836
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
101 amount of time (cf. :ref:`stable resources <stable-resources>`
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
102 and the option ``StableAge`` in the
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 :ref:`configuration file <configuration>`). The :ref:`identifier
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 <orthanc-ids>` of the patient is provided, together with her DICOM
78
d6bd1dd820e5 metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
105 tags and her :ref:`metadata <metadata>`.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 * ``function OnStableSeries(seriesId, tags, metadata)``: Invoked
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 whenever a series has not received any new instance for a certain
836
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
108 amount of time (cf. :ref:`stable resources <stable-resources>`
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
109 and the option ``StableAge`` in the
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
110 :ref:`configuration file <configuration>`).
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 * ``function OnStableStudy(studyId, tags, metadata)``: Invoked
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 whenever a study has not received any new instance for a certain
836
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
113 amount of time (cf. :ref:`stable resources <stable-resources>`
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
114 and the option ``StableAge`` in the
a9c35bf108fa stable age ref
Alain Mazy <am@osimis.io>
parents: 804
diff changeset
115 :ref:`configuration file <configuration>`).
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 * ``function IncomingFindRequestFilter(source, origin)``: Invoked
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 whenever Orthanc receives an incoming C-Find query through the DICOM
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 protocol. This allows to inspect the content of the C-Find query,
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 and possibly modify it if a patch is needed for some manufacturer. A
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 `sample script is available
449
2922fb1bd65e fix links
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 443
diff changeset
121 <https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Resources/Samples/Lua/IncomingFindRequestFilter.lua>`__.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
319
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
123 Some other **resource-related events** are available:
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
124
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
125 * ``function OnDeletedPatient(patientId)``: Invoked when a patient has
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
126 been removed from the Orthanc database (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
127 * ``function OnDeletedStudy(studyId)``: Invoked when a study has been
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
128 removed from the Orthanc database (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
129 * ``function OnDeletedSeries(seriesId)``: Invoked when a series has
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
130 been removed from the Orthanc database (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
131 * ``function OnDeletedInstance(instanceId)``: Invoked when a instance
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
132 has been removed from the Orthanc database (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
133 * ``function OnUpdatedPatient(patientId)``: Invoked when some metadata
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
134 or some attachment associated with the given patient has been
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
135 updated (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
136 * ``function OnUpdatedStudy(studyId)``: Invoked when some metadata or
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
137 some attachment associated with the given study has been updated
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
138 (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
139 * ``function OnUpdatedSeries(seriesId)``: Invoked when some metadata
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
140 or some attachment associated with the given series has been updated
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
141 (new in Orthanc 1.6.0).
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
142 * ``function OnUpdatedInstance(instanceId)``: Invoked when some
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
143 metadata or some attachment associated with the given instance has
be69f8c86f56 Lua events for deleted/updated resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 283
diff changeset
144 been updated (new in Orthanc 1.6.0).
606
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
145
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
146 Furthermore, in versions of Orthanc <= 1.8.2, whenever a DICOM
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
147 association is negotiated for C-Store SCP, several callbacks are
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
148 successively invoked to specify which **transfer syntaxes** are
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
149 accepted for the association. These callbacks are listed in `this
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
150 sample script
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
151 <https://hg.orthanc-server.com/orthanc/file/Orthanc-1.8.2/OrthancServer/Resources/Samples/Lua/TransferSyntaxEnable.lua>`__.
2f000ee9b20d removal of Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
152 These callbacks were removed in Orthanc 1.9.0.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 *Note:* All of these callbacks are guaranteed to be **invoked in
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 mutual exclusion**. This implies that Lua scripting in Orthanc does
357
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
156 not support any kind of concurrency.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
157
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
158 If a callback is specified multiple times in separate scripts, the
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
159 event handler of the latest loaded script is used.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 .. _lua-rest:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 Calling the REST API of Orthanc
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 Lua scripts have :ref:`full access to the REST API <rest>` of Orthanc
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 through the following functions:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
252
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
170 * ``RestApiGet(uri, builtin, headers)``
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
171 * ``RestApiPost(uri, body, builtin, headers)``
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
172 * ``RestApiPut(uri, body, builtin, headers)``
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
173 * ``RestApiDelete(uri, builtin, headers)``
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
175 Here is a description of the parameters:
235
17f8eda5fccb Documented some parameter types, expected string formatting and added samples.
Tomas Zubiri <me@tomaszubiri.com>
parents: 191
diff changeset
176
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
177 * ``uri`` specifies the resource being accessed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
178 (e.g. ``/instances``). It must not include the URL schema
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
179 (protocol), hostname or port.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
181 * In the context of a POST or PUT request, ``body`` is a string
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
182 containing the body of the request
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
183 (e.g. ``{"Keep":"StudyDate"}``). This string will often correspond
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
184 to a JSON-formatted version of a `Lua table
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
185 <http://lua-users.org/wiki/TablesTutorial>`__. The ``DumpJson()``
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
186 function (see below) is very useful to achieve this conversion from
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
187 a Lua table to a plain string.
235
17f8eda5fccb Documented some parameter types, expected string formatting and added samples.
Tomas Zubiri <me@tomaszubiri.com>
parents: 191
diff changeset
188
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
189 * ``builtin`` is an optional Boolean that specifies whether the
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
190 request targets only the built-in REST API of Orthanc (if set to
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
191 ``true``), or the full the REST API after being tainted by plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
192 (if set to ``false``).
235
17f8eda5fccb Documented some parameter types, expected string formatting and added samples.
Tomas Zubiri <me@tomaszubiri.com>
parents: 191
diff changeset
193
252
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
194 * ``headers`` is an optional argument and was added in release
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
195 1.5.7. It allows to provide the REST API endpoint with HTTP headers.
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
196
237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
197 .. highlight:: bash
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
198
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
199 For instance::
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
200
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
201 RestApiPost('/instances/5af318ac-78fb-47ff-b0b0-0df18b0588e0/anonymize', '{}')
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 236
diff changeset
202
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
783
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
204 Instance modification/routing
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
205 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
206
804
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
207 The Lua engine offers the following special functions to modify and
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
208 route DICOM instances:
783
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
209
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
210 * ``ModifyInstance(instanceId, replacements, removals, removePrivateTags)``
804
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
211 modifies an instance.
783
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
212 * ``SendToModality(instanceId, modality)`` performs a C-Store to the
804
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
213 target modality.
783
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
214 * ``SendToPeer(instanceId, peer)`` sends the instance to a remote Orthanc peer.
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
215 * ``Delete(instanceId)`` deletes the instance.
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
216
804
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
217 :ref:`See this section <lua-auto-routing>` for examples. As can be
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
218 seen in those examples, these special functions can be chained
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
219 together, although they return no explicit value.
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
220
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
221 Note that these special functions should only be used for basic use
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
222 cases: Calls to the REST API :ref:`should always be favored for
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
223 auto-routing <lua-auto-routing-better>`.
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
224
783
0fbe952b2906 list more lua functions
Alain Mazy <am@osimis.io>
parents: 668
diff changeset
225
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 General-purpose functions
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 ^^^^^^^^^^^^^^^^^^^^^^^^^
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 The Lua engine of Orthanc contain several general-purpose ancillary
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 functions:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 * ``PrintRecursive(v)`` recursively prints the content of a `Lua table
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 <http://www.lua.org/pil/2.5.html>`__ to the log file of Orthanc.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 * ``ParseJson(s)`` converts a string encoded in the `JSON format
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 <https://en.wikipedia.org/wiki/JSON>`__ to a Lua table.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 * ``DumpJson(v, keepStrings)`` encodes a Lua table as a JSON string.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 Setting the optional argument ``keepStrings`` (available from
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 release 0.9.5) to ``true`` prevents the automatic conversion of
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 strings to integers.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 * ``GetOrthancConfiguration()`` returns a Lua table containing the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 content of the :ref:`configuration files <configuration>` of
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 Orthanc.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 Similarly to the functions to :ref:`call the REST API of Orthanc
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 <lua-rest>`, several functions are available to make generic HTTP
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 requests to Web services:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
90
e6a15f619786 added headers in HttpPost/Delete/Get/Put
amazy
parents: 78
diff changeset
249 * ``HttpGet(url, headers)``
e6a15f619786 added headers in HttpPost/Delete/Get/Put
amazy
parents: 78
diff changeset
250 * ``HttpPost(url, body, headers)``
e6a15f619786 added headers in HttpPost/Delete/Get/Put
amazy
parents: 78
diff changeset
251 * ``HttpPut(url, body, headers)``
e6a15f619786 added headers in HttpPost/Delete/Get/Put
amazy
parents: 78
diff changeset
252 * ``HttpDelete(url, headers)``
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 * ``SetHttpCredentials(username, password)`` can be used to setup the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 HTTP credentials.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
252
eaad8233e474 HTTP headers available for the RestApiXXX Lua function
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
256 The ``headers`` argument is optional and was added in release
91
025744919357 additional info
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 90
diff changeset
257 1.2.1. It allows to set the HTTP headers for the HTTP client request.
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
283
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
259 Example::
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
260
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
261 local preview = RestApiGet('/instances/' .. instanceId .. '/preview')
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
262 local headers = {
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
263 ["content-type"] = "image/png",
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
264 }
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
265 HttpPost("http://localhost/my-web-service/instance-preview", preview, headers)
443af82172b0 added a sample of headers for HttpPost lua method
amazy
parents: 252
diff changeset
266
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 .. _lua-origin:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 Origin of the instances
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 ^^^^^^^^^^^^^^^^^^^^^^^
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 Whenever Orthanc decides whether it should should store a new instance
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 (cf. the ``ReceivedInstanceFilter()`` callback), or whenever it has
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 actually stored a new instance (cf. the ``OnStoredInstance``
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 callback), an ``origin`` parameter is provided. This parameter is a
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 `Lua table <http://www.lua.org/pil/2.5.html>`__ that describes from
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 which Orthanc subsystem the new instance comes from.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 There are 4 possible subsystems, that can be distinguished according
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 to the value of ``origin["RequestOrigin"]``:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 * ``RestApi``: The instance originates from some HTTP request to the REST
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 API. In this case, the ``RemoteIp`` and ``Username`` fields are
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 available in ``origin``. They respectively describe the IP address
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 of the HTTP client, and the username that was used for HTTP
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 authentication (as defined in the ``RegisteredUsers``
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 :ref:`configuration variable <configuration>`).
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 * ``DicomProtocol``: The instance originates from a DICOM C-Store.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 The fields ``RemoteIp``, ``RemoteAet`` and ``CalledAet``
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 respectively provide the IP address of the DICOM SCU (client), the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 application entity title of the DICOM SCU client, and the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 application entity title of the Orthanc SCP server. The
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 ``CalledAet`` can be used for :ref:`advanced auto-routing scenarios
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 <lua-auto-routing>`, when a single instance of Orthanc acts as a
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 proxy for several DICOM SCU clients.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 * ``Lua``: The instance originates from a Lua script.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 * ``Plugins``: The instance originates from a plugin.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 .. _lua-filter-dicom:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
302 Filtering incoming DICOM instances
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 ----------------------------------
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 .. highlight:: lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 Each time a DICOM instance is received by Orthanc (either through the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 DICOM protocol or through the REST API), the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 ``ReceivedInstanceFilter()`` Lua function is invoked. If this callback
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 returns ``true``, the instance is accepted for storage. If it returns
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 ``false``, the instance is discarded. This mechanism can be used to
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 filter the incoming DICOM instances. Here is an example of a Lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 filter that only allows incoming instances of MR modality::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
387
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
315 function ReceivedInstanceFilter(dicom, origin, info)
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 -- Only allow incoming MR images
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 if dicom.Modality == 'MR' then
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 return true
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 else
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 return false
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323
387
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
324 The argument ``dicom`` corresponds to a `Lua table
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 <http://www.lua.org/pil/2.5.html>`__ (i.e. an associative array) that
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 contains the DICOM tags of the incoming instance. For debugging
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 purpose, you can print this structure as follows::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
387
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
329 function ReceivedInstanceFilter(dicom, origin, info)
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 PrintRecursive(dicom)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 -- Accept all incoming instances (default behavior)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 return true
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 The argument ``origin`` is :ref:`documented separately <lua-origin>`.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336
387
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
337 The argument ``info`` was introduced in Orthanc 1.6.1. It contains
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
338 some additional information about the received DICOM instance,
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
339 notably:
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
340
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
341 * ``HasPixelData`` is ``true`` iff. the Pixel Data (7FE0,0010) tag is
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
342 present.
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
343 * ``TransferSyntaxUID`` contains the transfer syntax UID of the
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
344 dataset of the instance (if applicable).
1974913fd28a documenting "info" argument in Lua ReceivedInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
345
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 .. _lua-filter-rest:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
349 Filtering incoming REST requests
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 --------------------------------
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 .. highlight:: lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 Lua scripting can be used to control the access to the various URI of
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 the REST API. Each time an incoming HTTP request is received, the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 ``IncomingHttpRequestFilter()`` Lua function is called. The access to
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 the resource is granted if and only if this callback script returns
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 ``true``.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 This mechanism can be used to implement fine-grained `access control
25
669ea65ba7fb fix links
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
361 lists <https://en.wikipedia.org/wiki/Access_control_list>`__. Here is
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 an example of a Lua script that limits POST, PUT and DELETE requests
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 to an user that is called "admin"::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 function IncomingHttpRequestFilter(method, uri, ip, username, httpHeaders)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 -- Only allow GET requests for non-admin users
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 if method == 'GET' then
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 return true
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 elseif username == 'admin' then
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 return true
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 else
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 return false
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 Here is a description of the arguments of this Lua callback:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 * ``method``: The HTTP method (GET, POST, PUT or DELETE).
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 * ``uri``: The path to the resource (e.g. ``/tools/generate-uid``).
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 * ``ip``: The IP address of the host that has issued the HTTP request (e.g. ``127.0.0.1``).
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 * ``username``: If HTTP Basic Authentication is enabled in the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 :ref:`configuration file <configuration>`, the name of the user that
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 has issued the HTTP request (as defined in the ``RegisteredUsers``
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 configuration variable). If the authentication is disabled, this
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 argument is set to the empty string.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 * ``httpHeaders``: The HTTP headers of the incoming request. This
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 argument is available since Orthanc 1.0.1. It is useful if the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 authentication should be achieved through tokens, for instance
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 against a `LDAP
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 <https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol>`__
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 or `OAuth2 <https://en.wikipedia.org/wiki/OAuth>`__ server.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 .. _lua-auto-routing:
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
397 Auto-routing of DICOM images
0
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 ----------------------------
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 .. highlight:: lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 Since release 0.8.0, the routing of DICOM flows can be very easily
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 automated with Orthanc. All you have to do is to declare your
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 destination modality in the :ref:`configuration file <configuration>`
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 (section ``DicomModalities``), then to create and install a Lua
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 script. For instance, here is a sample script::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 function OnStoredInstance(instanceId, tags, metadata)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 Delete(SendToModality(instanceId, 'sample'))
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 If this script is loaded into Orthanc, whenever a new DICOM instance
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 is received by Orthanc, it will be routed to the modality whose
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 symbolic name is ``sample`` (through a Store-SCU command), then it
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 will be removed from Orthanc. In other words, this is a **one-liner
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 script to implement DICOM auto-routing**.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 Very importantly, thanks to this feature, you do not have to use the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 REST API or to create external scripts in order to automate simple
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 imaging flows. The scripting engine is entirely contained inside the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 Orthanc core system.
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 Thanks to Lua expressiveness, you can also implement conditional
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 auto-routing. For instance, if you wish to route only patients whose
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 name contains "David", you would simply write::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 function OnStoredInstance(instanceId, tags, metadata)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 -- Extract the value of the "PatientName" DICOM tag
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 local patientName = string.lower(tags['PatientName'])
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 if string.find(patientName, 'david') ~= nil then
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 -- Only route patients whose name contains "David"
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 Delete(SendToModality(instanceId, 'sample'))
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 else
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 -- Delete the patients that are not called "David"
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 Delete(instanceId)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 Besides ``SendToModality()``, a mostly identical function with the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 same arguments called ``SendToPeer()`` can be used to route instances
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 to :ref:`Orthanc peers <peers>`. It is also possible to modify the
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 received instances before routing them. For instance, here is how you
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 would replace the ``StationName`` DICOM tag::
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 function OnStoredInstance(instanceId, tags, metadata)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 -- Ignore the instances that result from a modification to avoid
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 -- infinite loops
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 if (metadata['ModifiedFrom'] == nil and
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 metadata['AnonymizedFrom'] == nil) then
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 -- The tags to be replaced
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 local replace = {}
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 replace['StationName'] = 'My Medical Device'
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 -- The tags to be removed
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 local remove = { 'MilitaryRank' }
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 -- Modify the instance, send it, then delete the modified instance
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 Delete(SendToModality(ModifyInstance(instanceId, replace, remove, true), 'sample'))
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 -- Delete the original instance
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 Delete(instanceId)
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 end
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467
901e8961f46e initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468
804
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
469 .. _lua-auto-routing-better:
e7de02760b59 fix revision 783, to solve bug #203
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 783
diff changeset
470
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
471 Important remarks about auto-routing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
472 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
473
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
474 The ``SendToModality()``, ``SendToPeer()``, ``ModifyInstance()`` and
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
475 ``Delete()`` functions are for the most basic cases of auto-routing
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
476 (implying a single DICOM instance, and possibly a basic modification
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
477 of this instance). The ``ModifyInstance()`` function `could also lead
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
478 to problems
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
479 <https://groups.google.com/d/msg/orthanc-users/hmv2y-LgKm8/oMAuGJWMBgAJ>`__
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
480 if it deals with tags wrongly interpreted as numbers by Lua.
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
481
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
482 For more evolved auto-routing scenarios, remember that Lua scripts
191
6e0a0b57697b Added missing word
bgo-osimis
parents: 165
diff changeset
483 :ref:`have full access to the REST API of Orthanc <lua-rest>`. This is
19
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
484 illustrated by the ``AutoroutingModification.lua`` sample available in
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
485 the source distribution of Orthanc::
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
486
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
487 function OnStoredInstance(instanceId, tags, metadata, origin)
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
488 -- Ignore the instances that result from the present Lua script to
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
489 -- avoid infinite loops
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
490 if origin['RequestOrigin'] ~= 'Lua' then
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
491
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
492 -- The tags to be replaced
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
493 local replace = {}
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
494 replace['StationName'] = 'My Medical Device'
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
495 replace['0031-1020'] = 'Some private tag'
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
496
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
497 -- The tags to be removed
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
498 local remove = { 'MilitaryRank' }
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
499
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
500 -- Modify the instance
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
501 local command = {}
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
502 command['Replace'] = replace
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
503 command['Remove'] = remove
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
504 local modifiedFile = RestApiPost('/instances/' .. instanceId .. '/modify', DumpJson(command, true))
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
505
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
506 -- Upload the modified instance to the Orthanc database so that
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
507 -- it can be sent by Orthanc to other modalities
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
508 local modifiedId = ParseJson(RestApiPost('/instances/', modifiedFile)) ['ID']
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
509
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
510 -- Send the modified instance to another modality
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
511 RestApiPost('/modalities/sample/store', modifiedId)
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
512
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
513 -- Delete the original and the modified instances
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
514 RestApiDelete('/instances/' .. instanceId)
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
515 RestApiDelete('/instances/' .. modifiedId)
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
516 end
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
517 end
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
518
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
519 Also note that :ref:`other callbacks are available <lua-callbacks>`
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
520 (``OnStablePatient()``, ``OnStableStudy()`` and ``OnStableSeries()``)
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
521 to react to other events than the reception of a single instance
c98317fedf87 note about autorouting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
522 with ``OnStoredInstance()``.
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
523
99
e83da2f99e45 added 'troubleshooting C-Find queries' in the worklist section
amazy
parents: 91
diff changeset
524 .. _lua-fix-cfind:
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
525
77
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
526 Fixing C-Find requests
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
527 ----------------------
75
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
528
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 64
diff changeset
529 :ref:`C-Find requests <dicom-find>` are sometimes interpreted
77
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
530 differently by different DICOM servers (e.g. the ``*`` wildcard, as
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
531 `reported by users
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
532 <https://groups.google.com/d/msg/orthanc-users/3g7V7kqr3g0/IREL88RWAwAJ>`__),
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
533 and sometimes a querying modality might set unexpected DICOM tags
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
534 (cf. `this real-world example
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
535 <https://groups.google.com/d/msg/orthanc-users/PLWKqVVaXLs/n_0x4vKhAgAJ>`__). In
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
536 such situations, it is possible to dynamically fix incoming or
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
537 outgoing C-Find queries using a Lua script.
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
538
165
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
539 Sanitizing incoming C-Find requests can be done by implementing the
77
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
540 ``IncomingFindRequestFilter(query, origin)`` callback that is called
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
541 whenever the Orthanc C-Find SCP is queried by a remote modality. For
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
542 instance, here is Lua script to remove a private tag that is specified
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
543 by some manufacturer::
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
544
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
545 function IncomingFindRequestFilter(query, origin)
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
546 -- First display the content of the C-Find query
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
547 PrintRecursive(query)
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
548 PrintRecursive(origin)
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
549
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
550 -- Remove the "PrivateCreator" tag from the query
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
551 local v = query
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
552 v['5555,0010'] = nil
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
553
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
554 return v
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
555 end
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
556
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
557 The ``origin`` argument contains information about which modality has
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
558 issued the request.
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
559
443
c66d8b7b1a13 more info about IncomingFindRequestFilter
Alain Mazy <alain@mazy.be>
parents: 387
diff changeset
560 Note that this callback allows you to modify the incoming request
c66d8b7b1a13 more info about IncomingFindRequestFilter
Alain Mazy <alain@mazy.be>
parents: 387
diff changeset
561 but will not modify the list of tags that Orthanc will return.
c66d8b7b1a13 more info about IncomingFindRequestFilter
Alain Mazy <alain@mazy.be>
parents: 387
diff changeset
562
c66d8b7b1a13 more info about IncomingFindRequestFilter
Alain Mazy <alain@mazy.be>
parents: 387
diff changeset
563 Also note that the ``IncomingFindRequestFilter`` callback is not applied to
165
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
564 C-Find requests targeting :ref:`modality worklists
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
565 <worklists-plugin>`. Since Orthanc 1.4.2, the corresponding
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
566 ``IncomingWorklistRequestFilter`` callback can be used to sanitize
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
567 C-FIND requests against worklists::
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
568
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
569 function IncomingWorklistRequestFilter(query, origin)
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
570 PrintRecursive(query)
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
571 PrintRecursive(origin)
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
572
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
573 -- Implements the same behavior as the "FilterIssuerAet"
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
574 -- option of the sample worklist plugin
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
575 query['0040,0100'][1]['0040,0001'] = origin['RemoteAet']
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
576
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
577 return query
b879a6274065 IncomingWorklistRequestFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 105
diff changeset
578 end
105
268ec482f051 IncomingFindRequestFilter not applied to worklist plugin
amazy
parents: 99
diff changeset
579
443
c66d8b7b1a13 more info about IncomingFindRequestFilter
Alain Mazy <alain@mazy.be>
parents: 387
diff changeset
580
77
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
581 Similarly, the callback ``OutgoingFindRequestFilter(query, modality)``
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
582 is invoked whenever Orthanc acts as a C-Find SCU, which gives the
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
583 opportunity to dynamically fix outgoing C-Find requests before they
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
584 are actually sent to the queried modality. For instance, here is a
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
585 sample Lua callback that would replace asterisk wildcards (i.e. ``*``)
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
586 by an empty string for any query/retrieve issued by Orthanc (including
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
587 from Orthanc Explorer)::
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
588
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
589 function OutgoingFindRequestFilter(query, modality)
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
590 for key, value in pairs(query) do
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
591 if value == '*' then
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
592 query[key] = ''
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
593 end
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
594 end
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
595
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
596 return query
48c7d2eb98da Fixing C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 75
diff changeset
597 end
668
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
598
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
599
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
600 .. _lua-external-modules:
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
601
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
602 Using external modules
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
603 ----------------------
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
604
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
605 Starting with Orthanc 1.3.2, it is possible to use external Lua
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
606 modules if Orthanc was compiled with the ``-DENABLE_LUA_MODULES=ON``
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
607 while invoking CMake.
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
608
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
609 Importantly, the modules and the Orthanc server must use the same
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
610 version of Lua for external modules to be properly loaded.
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
611
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
612 Check out the Orthanc Users forum for old discussions about this
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
613 topic: `reference 1
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
614 <https://groups.google.com/g/orthanc-users/c/BXfmwU786B0/m/M47slt5GFwAJ>`__,
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
615 `reference 2
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
616 <https://groups.google.com/g/orthanc-users/c/BXfmwU786B0/m/qpVe8UvGAwAJ>`__,
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
617 `reference 3
15a0635eef4b lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 606
diff changeset
618 <https://groups.google.com/g/orthanc-users/c/LDAN5jA0X8M/m/4zrk0_AaBAAJ>`__.