Skip to content

3. ChRIS plugin PACS query workflow

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

ChRIS plugin PACS query

Abstract

This page describes interacting with the ChRIS Ultron Back End (CUBE) using pfurl and running an FS type plugin called pl-pacsquery. Essentially, pl-pacsquery searches a PACS for some meta information based on a pattern of command line terms, and returns results of this query in several small text/JSON files. These result files can be consumed by downstream processing for other purposes (such as instantiating a pl-pacsretrieve plugin.

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

Call

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

Look through the list for pl-pacsquery. For example, let's say that this is located at

http://10.17.24.163:8000/api/v1/plugins/3/

we can call

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

Receive

{
    "collection": {
        "href": "http://192.168.1.189:8000/api/v1/plugins/3/",
        "items": [
            {
                "href": "http://192.168.1.189:8000/api/v1/plugins/3/",
                "data": [
                    {
                        "name": "name",
                        "value": "pacsquery"
                    },
                    {
                        "name": "dock_image",
                        "value": "fnndsc/pl-pacsquery"
                    },
                    {
                        "name": "type",
                        "value": "fs"
                    }
                ],
                "links": [
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/parameters/",
                        "rel": "parameters"
                    },
                    {
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/instances/",
                        "rel": "instances"
                    }
                ]
            }
        ],
        "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/3/parameters/ \
    --quiet --jsonpprintindent 4

Receive

{
    "collection": {
        "links": [
            {
                "rel": "plugin",
                "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
            },
            {
                "rel": "next",
                "href": "http://192.168.1.189:8000/api/v1/plugins/3/parameters/?limit=10&offset=10"
            }
        ],
        "items": [
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_pfdcm"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "The PACS Q/R intermediary service IP:port."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/4/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_msg"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "The actual complete JSON message to send to the Q/R intermediary service."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/5/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_patientID"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "The PatientID to query."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/6/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_PACSservice"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": "orthanc"
                    },
                    {
                        "name": "help",
                        "value": "The PACS service to use. Note this a key to a lookup in \"pfdcm\"."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/7/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_summaryKeys"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "If specified, generate a summary report based on a comma separated key list."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/8/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_summaryFile"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "If specified, save (overwrite) a summary report to passed file (in outputdir)."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/9/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_numberOfHitsFile"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "If specified, save (overwrite) the number of hits (in outputdir)."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/10/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_resultFile"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "If specified, save (overwrite) all the hits to the passed file (in outputdir)."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/11/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "str_man"
                    },
                    {
                        "name": "type",
                        "value": "string"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": ""
                    },
                    {
                        "name": "help",
                        "value": "If specified, print help on the passed key entry. Use \"entries\" for all key list"
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/12/"
            },
            {
                "links": [
                    {
                        "rel": "plugin",
                        "href": "http://192.168.1.189:8000/api/v1/plugins/3/"
                    }
                ],
                "data": [
                    {
                        "name": "name",
                        "value": "b_pfurlQuiet"
                    },
                    {
                        "name": "type",
                        "value": "boolean"
                    },
                    {
                        "name": "optional",
                        "value": true
                    },
                    {
                        "name": "default",
                        "value": "False"
                    },
                    {
                        "name": "help",
                        "value": "Silence pfurl noise."
                    }
                ],
                "href": "http://192.168.1.189:8000/api/v1/plugins/parameters/13/"
            }
        ],
        "href": "http://192.168.1.189:8000/api/v1/plugins/3/parameters/",
        "version": "1.0"
    }
}

Run an instance of the plugin

Call

Using pfurl

NB: MAKE SURE THE str_pfdcm IP is correct below!

pfurl --auth chris:chris1234 --verb POST                 \
      --http ${HOST_IP}:8000/api/v1/plugins/3/instances/ \
      --content-type application/vnd.collection+json     \
      --jsonwrapper 'template' --msg '
{"data":
    [{"name": "str_pfdcm",            "value": "10.17.24.163:5015"},
     {"name": "str_patientID",        "value": "LILLA-9731"},
     {"name": "str_PACSservice",      "value": "orthanc"},
     {"name": "b_pfurlQuiet",         "value": true},
     {"name": "str_summaryKeys",  "value":"PatientID,PatientAge,StudyDescription,StudyInstanceUID,SeriesDescription,SeriesInstanceUID,NumberOfSeriesRelatedInstances"},
     {"name": "str_summaryFile",      "value": "summary.txt"},
     {"name": "str_resultFile",       "value": "results.json"},
     {"name": "str_numberOfHitsFile", "value": "hits.txt"}
    ]
}' --quiet --jsonpprintindent 4

Receive

{
    "stdout": {
        "collection": {
            "version": "1.0",
            "href": "http://10.17.24.163:8000/api/v1/plugins/3/instances/",
            "links": [],
            "items": [
                {
                    "href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
                    "links": [
                        {
                            "href": "http://10.17.24.163:8000/api/v1/1/",
                            "rel": "feed"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/3/",
                            "rel": "plugin"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/1/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/2/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/3/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/4/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/5/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/6/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/7/",
                            "rel": "string_param"
                        },
                        {
                            "href": "http://10.17.24.163:8000/api/v1/plugins/bool-parameter/1/",
                            "rel": "bool_param"
                        }
                    ],
                    "data": [
                        {
                            "name": "id",
                            "value": 1
                        },
                        {
                            "name": "previous_id",
                            "value": null
                        },
                        {
                            "name": "plugin_name",
                            "value": "pacsquery"
                        },
                        {
                            "name": "start_date",
                            "value": "2017-11-10T16:14:18.006375Z"
                        },
                        {
                            "name": "end_date",
                            "value": "2017-11-10T16:14:18.006430Z"
                        },
                        {
                            "name": "status",
                            "value": "started"
                        },
                        {
                            "name": "owner",
                            "value": "chris"
                        }
                    ]
                }
            ]
        }
    },
    "msg": "push OK."
}

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": {
            "version": "1.0",
            "href": "http://10.17.24.163:8000/api/v1/plugins/3/instances/",
            "links": [],
            "items": [
                {
                    "href": "http://10.17.24.163: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": {
        "version": "1.0",
        "href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
        "links": [],
        "items": [
            {
                "href": "http://10.17.24.163:8000/api/v1/plugins/instances/1/",
                "links": [
                    {
                        "href": "http://10.17.24.163:8000/api/v1/1/",
                        "rel": "feed"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/3/",
                        "rel": "plugin"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/1/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/2/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/3/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/4/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/5/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/6/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/string-parameter/7/",
                        "rel": "string_param"
                    },
                    {
                        "href": "http://10.17.24.163:8000/api/v1/plugins/bool-parameter/1/",
                        "rel": "bool_param"
                    }
                ],
                "data": [
                    {
                        "name": "id",
                        "value": 1
                    },
                    {
                        "name": "previous_id",
                        "value": null
                    },
                    {
                        "name": "plugin_name",
                        "value": "pacsquery"
                    },
                    {
                        "name": "start_date",
                        "value": "2017-11-10T16:14:18.006375Z"
                    },
                    {
                        "name": "end_date",
                        "value": "2017-11-10T16:18:00.931493Z"
                    },
                    {
                        "name": "status",
                        "value": "finishedSuccessfully"
                    },
                    {
                        "name": "owner",
                        "value": "chris"
                    }
                ]
            }
        ]
    }
}

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