Skip to content

4. ChRIS plugin PACS retrieve workflow

Rudolph Pienaar edited this page Nov 9, 2017 · 10 revisions

ChRIS plugin PACS retrieve workflow

Abstract

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

Preconditions

HOST_IP env variable

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}')

Backend user

At least one user with name/password combination as

  • chris/chris1234

Containerized data/processing services:

  • pfcon
  • pfioh
  • pman

Instantiated CUBE

Start CUBE from the repository source directory, running

*make*

PACS server

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.

GET list of plugins from CUBE and check for pl-pacsretrieve plugin

Call

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

Receive

{
    "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"
    }
}

GET parameter info for plugin

Follow the links provided to get information on the parameters for the plugin

Call

pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/4/parameters/ \
    --quiet --jsonpprintindent 4

Receive

{
    "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"
    }
}

Run an instance of the plugin

Call

Using pfurl

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": "192.168.1.189:5015"},
     {"name": "str_PACSservice",      "value": "orthanc"},
     {"name": "b_pfurlQuiet",         "value": true},
     {"name": "priorHitsTable",       "value": "results.json"},
     {"name": "indexList",            "value": "1,2,3"},
     {"name":"previous_id",           "value":"1"}    ]
}' --quiet --jsonpprintindent 4

Receive

Query job state (and also trigger a file registration in CUBE)

Examine the return JSON for the instance ID returned. In the above, we note that this is

    "stdout": {
        "collection": {
            "href": "http://192.168.1.189:8000/api/v1/plugins/3/instances/",
            "items": [
                {
                    "href": "http://192.168.1.189:8000/api/v1/plugins/instances/1/",

In other words, instance 1.

Call

Using pfurl

pfurl --auth chris:chris1234                               \
      --verb GET                                           \
      --http ${HOST_IP}:8000/api/v1/plugins/instances/1/   \
      --content-type application/vnd.collection+json       \
      --quiet --jsonpprintindent 4

Receive

{
    "collection": {
        "href": "http://192.168.1.189:8000/api/v1/plugins/instances/1/",
        "items": [
            {
                "href": "http://192.168.1.189:8000/api/v1/plugins/instances/1/",
                "data": [
                    {
                        "name": "id",
                        "value": 1
                    },
                    {
                        "name": "previous_id",
                        "value": null
                    },
                    {
                        "name": "plugin_name",
                        "value": "pacsquery"
                    },
                    {
                        "name": "start_date",
                        "value": "2017-10-25T03:43:26.156506Z"
                    },
                    {
                        "name": "end_date",
                        "value": "2017-10-25T03:46:11.205590Z"
                    },
                    {
                        "name": "status",
                        "value": "finishedSuccessfully"
                    },
                    {
                        "name": "owner",
                        "value": "chris"
                    }
                ],
                "links": [
                    {
                        "href": "http://192.168.1.189:8000/api/v1/1/",
                        "rel": "feed"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/",
                        "rel": "plugin"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/1/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/2/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/3/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/4/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/5/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/6/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/string-parameter/7/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/bool-parameter/1/",
                        "rel": "bool_param"
                    }
                ]
            }
        ],
        "links": [],
        "version": "1.0"
    }
}

In which we see that the status is finishedSuccessfully.

Examine the CUBE FS for the files

Finally, we can check the CUBE container space for the files returned from the query

dke chris_dev_backend
root@00bb9aaa4659:/usr/src/chris_backend# cd /usr/users/chris/feed_1/pacsquery_1/data/
root@00bb9aaa4659:/usr/users/chris/feed_1/pacsquery_1/data# ls
hits.txt  input.meta.json  output.meta.json  results.json  summary.txt
root@00bb9aaa4659:/usr/users/chris/feed_1/pacsquery_1/data# 

where

dke ()
{
    NAME=$1;
    ID=$(dkl | grep $NAME | head -n 1 | awk '{print $1}');
    docker exec -ti $ID /bin/bash
}

Access files from a client

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"
            }
        ]
    }
}

Download an actual file

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--

Clone this wiki locally