-
Notifications
You must be signed in to change notification settings - Fork 101
4. ChRIS plugin PACS retrieve workflow
This page describes interacting with the ChRIS Ultron Back End (CUBE) using pfurl
and running a DS
type plugin called pl-pacsretrieve
. Essentially, pl-pacsretrieve
instructs a remote PACS to push data to a predefined destination, after which the data itself is pulled into the container.
Covered in this page are:
- Formulating a client-side request to run an instance of the plugin
- Checking on the result/status
- Checking on registered files
- Pulling a generated file to the client
You should set an environment variable, HOST_IP
to the IP of the actual host you are using. In Linux, this is
export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}')
At least one user with name/password combination as
-
chris
/chris1234
pfcon
pfioh
pman
Start CUBE from the repository source directory, running
*make*
A PACS server should be accessible via IP:port to this plugin, i.e. a network path must exist between the plugin (and the host/container where it runs) and a PACS server.
In the CUBE system, we use an Orthanc container to simulate a PACS. Starting this server is out of scope of this document. See elsewhere for more information.
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/ \
--quiet --jsonpprintindent 4
Look through the list for pl-pacsretrieve
. For example, let's say that this is located at
http://10.17.24.163:8000/api/v1/plugins/4/
we can call
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/4/ \
--quiet --jsonpprintindent 4
{
"collection": {
"items": [
{
"data": [
{
"value": "pacsretrieve",
"name": "name"
},
{
"value": "fnndsc/pl-pacsretrieve",
"name": "dock_image"
},
{
"value": "ds",
"name": "type"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/parameters/",
"rel": "parameters"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/instances/",
"rel": "instances"
}
]
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"links": [],
"version": "1.0"
}
}
Follow the links provided to get information on the parameters for the plugin
pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/4/parameters/ \
--quiet --jsonpprintindent 4
{
"collection": {
"items": [
{
"data": [
{
"value": "str_pfdcm",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "The PACS Q/R intermediary service IP:port.",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/15/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_msg",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "The actual complete JSON message to send to the Q/R intermediary service.",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/16/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_indexList",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "A comma separated list of indices into the priorHitsTable.",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/17/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_priorHitsTable",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "A JSON formatted file returned by a prior call to pacsquery.",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/18/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_patientID",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "The PatientID to query.",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/19/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_PACSservice",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "orthanc",
"name": "default"
},
{
"value": "The PACS service to use. Note this a key to a lookup in \"pfdcm\".",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/20/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_summaryKeys",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "If specified, generate a summary report based on a comma separated key list.",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/21/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_summaryFile",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "If specified, save (overwrite) a summary report to passed file (in outputdir).",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/22/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_numberOfHitsFile",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "If specified, save (overwrite) the number of hits (in outputdir).",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/23/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
},
{
"data": [
{
"value": "str_resultFile",
"name": "name"
},
{
"value": "string",
"name": "type"
},
{
"value": true,
"name": "optional"
},
{
"value": "",
"name": "default"
},
{
"value": "If specified, save (overwrite) all the hits to the passed file (in outputdir).",
"name": "help"
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/parameters/24/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
}
]
}
],
"href": "http://10.17.24.163:8000/api/v1/plugins/4/parameters/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/parameters/?limit=10&offset=10",
"rel": "next"
}
],
"version": "1.0"
}
}
pfurl --auth chris:chris1234 --verb POST \
--http ${HOST_IP}:8000/api/v1/plugins/4/instances/ \
--content-type application/vnd.collection+json \
--jsonwrapper 'template' --msg '
{"data":
[{"name": "str_pfdcm", "value": "10.17.24.163:5015"},
{"name": "str_PACSservice", "value": "orthanc"},
{"name": "b_pfurlQuiet", "value": true},
{"name": "str_priorHitsTable", "value": "results.json"},
{"name": "str_indexList", "value": "1,2,3,4,5,6"},
{"name":"previous_id", "value":"1"} ]
}' --quiet --jsonpprintindent 4
{
"stdout": {
"collection": {
"version": "1.0",
"href": "http://10.17.24.163:8000/api/v1/plugins/4/instances/",
"links": [],
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "previous"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/8/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/9/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/10/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/11/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/bool-parameter/2/",
"rel": "bool_param"
}
],
"data": [
{
"name": "id",
"value": 2
},
{
"name": "previous_id",
"value": 1
},
{
"name": "plugin_name",
"value": "pacsretrieve"
},
{
"name": "start_date",
"value": "2017-11-10T16:20:23.332518Z"
},
{
"name": "end_date",
"value": "2017-11-10T16:20:23.332590Z"
},
{
"name": "status",
"value": "started"
},
{
"name": "owner",
"value": "chris"
}
]
}
]
}
},
"msg": "push OK."
}
Examine the return JSON for the instance ID returned. In the above, we note that this is
{
"stdout": {
"collection": {
"version": "1.0",
"href": "http://10.17.24.163:8000/api/v1/plugins/4/instances/",
"links": [],
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
...
In other words, instance 2.
pfurl --auth chris:chris1234 \
--verb GET \
--http ${HOST_IP}:8000/api/v1/plugins/instances/2/ \
--content-type application/vnd.collection+json \
--quiet --jsonpprintindent 4
If the job is still running, we will receive a payload:
{
"collection": {
"version": "1.0",
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
"links": [],
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "previous"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/8/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/9/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/10/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/11/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/bool-parameter/2/",
"rel": "bool_param"
}
],
"data": [
{
"name": "id",
"value": 2
},
{
"name": "previous_id",
"value": 1
},
{
"name": "plugin_name",
"value": "pacsretrieve"
},
{
"name": "start_date",
"value": "2017-11-10T16:20:23.332518Z"
},
{
"name": "end_date",
"value": "2017-11-10T16:20:23.332590Z"
},
{
"name": "status",
"value": "started"
},
{
"name": "owner",
"value": "chris"
}
]
}
]
}
}
where we note that the status
is reported as started
, i.e. the job has started and is still running. After a suitable amount of time, the job will end, and if successful, we will receive:
{
"collection": {
"version": "1.0",
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
"links": [],
"items": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/2/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "previous"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/4/",
"rel": "plugin"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/8/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/9/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/10/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/11/",
"rel": "string_param"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/bool-parameter/2/",
"rel": "bool_param"
}
],
"data": [
{
"name": "id",
"value": 2
},
{
"name": "previous_id",
"value": 1
},
{
"name": "plugin_name",
"value": "pacsretrieve"
},
{
"name": "start_date",
"value": "2017-11-10T16:20:23.332518Z"
},
{
"name": "end_date",
"value": "2017-11-10T16:22:04.890615Z"
},
{
"name": "status",
"value": "finishedSuccessfully"
},
{
"name": "owner",
"value": "chris"
}
]
}
]
}
}
In which we see that the status is finishedSuccessfully.
Finally, we can check the CUBE container space for the files returned from the query
dke chris_dev_backend
root@2dcae6af8e92:/usr/src/chris_backend# cd /usr/users/chris/feed_1/pacsquery_1/
data/ pacsretrieve_2/
root@2dcae6af8e92:/usr/src/chris_backend# cd /usr/users/chris/feed_1/pacsquery_1/pacsretrieve_2/data/
root@2dcae6af8e92:/usr/users/chris/feed_1/pacsquery_1/pacsretrieve_2/data# ls
1.3.12.2.1107.5.2.32.35235.2011120607520430331505768.0.0.0 1.3.12.2.1107.5.2.32.35235.30000011120415032007800029729
1.3.12.2.1107.5.2.32.35235.2011120607550721381806658.0.0.0 1.3.12.2.1107.5.2.32.35235.30000011120415032007800030559
1.3.12.2.1107.5.2.32.35235.2011120608041225195630230.0.0.0 input.meta.json
1.3.12.2.1107.5.2.32.35235.2011120608060183769230384.0.0.0 output.meta.json
root@2dcae6af8e92:/usr/users/chris/feed_1/pacsquery_1/pacsretrieve_2/data#
where
dke ()
{
NAME=$1;
ID=$(dkl | grep $NAME | head -n 1 | awk '{print $1}');
docker exec -ti $ID /bin/bash
}
To access files from a client, determine the feed ID by performing a GET on the instance as above. Note in the links return
{
"rel": "feed",
"href": "http://10.17.24.163:8000/api/v1/1/"
}
which denotes the feed ID as 1.
Access the references to registered files by calling http://10.17.24.163:8000/api/v1/1/, ie
pfurl --auth chris:chris1234 \
--verb GET \
--http ${HOST_IP}:8000/api/v1/1/files/ \
--content-type application/vnd.collection+json \
--quiet --jsonpprintindent 4
which should return
"collection": {
"items": [
{
"data": [
{
"value": "/summary.txt",
"name": "path"
},
{
"value": 1,
"name": "feed_id"
},
{
"value": 1,
"name": "plugin_inst_id"
}
],
"href": "http://10.17.24.163:8000/api/v1/files/1/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/files/1/summary.txt",
"rel": "file_resource"
},
{
"href": "http://10.17.24.163:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
]
},
{
"data": [
{
"value": "/output.meta.json",
"name": "path"
},
{
"value": 1,
"name": "feed_id"
},
{
"value": 1,
"name": "plugin_inst_id"
}
],
"href": "http://10.17.24.163:8000/api/v1/files/2/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/files/2/output.meta.json",
"rel": "file_resource"
},
{
"href": "http://10.17.24.163:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
]
},
{
"data": [
{
"value": "/results.json",
"name": "path"
},
{
"value": 1,
"name": "feed_id"
},
{
"value": 1,
"name": "plugin_inst_id"
}
],
"href": "http://10.17.24.163:8000/api/v1/files/3/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/files/3/results.json",
"rel": "file_resource"
},
{
"href": "http://10.17.24.163:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
]
},
{
"data": [
{
"value": "/hits.txt",
"name": "path"
},
{
"value": 1,
"name": "feed_id"
},
{
"value": 1,
"name": "plugin_inst_id"
}
],
"href": "http://10.17.24.163:8000/api/v1/files/4/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/files/4/hits.txt",
"rel": "file_resource"
},
{
"href": "http://10.17.24.163:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
]
},
{
"data": [
{
"value": "/input.meta.json",
"name": "path"
},
{
"value": 1,
"name": "feed_id"
},
{
"value": 1,
"name": "plugin_inst_id"
}
],
"href": "http://10.17.24.163:8000/api/v1/files/5/",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/files/5/input.meta.json",
"rel": "file_resource"
},
{
"href": "http://10.17.24.163:8000/api/v1/1/",
"rel": "feed"
},
{
"href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
"rel": "plugin_inst"
}
]
}
],
"href": "http://10.17.24.163:8000/api/v1/1/files/",
"version": "1.0",
"links": [
{
"href": "http://10.17.24.163:8000/api/v1/1/",
"rel": "feed"
}
]
}
}
Use httpie to pull an actual file, using an href from the above return:
http -a chris:chris1234 --download http://10.17.24.163:8000/api/v1/files/4/hits.txt
--30--