Skip to content

QIDO-RS — Search for Instances

Query based on ID for DICOM Objects (QIDO-RS) enables searching for studies and series by attributes (PS3.18 §10.6).

Method Path Description
GET | QUERY /studies Search for studies
GET | QUERY /studies/{study}/series Search for series in a study

The Accept header must allow application/dicom+json (application/*, */*, or no Accept header at all are accepted). Anything else is rejected with 406 (Not Acceptable).

Both methods are answered by the same handler. See The QUERY method below for how a QUERY request carries its search parameters and why it exists.

Authorization

When viewer-JWT verification is enabled for the deployment, every request to this interface must carry Authorization: Bearer <jwt>, and results are restricted to the studies named in the token's scope. See JWT Authorization for the token format, scope semantics, and status codes.

The QUERY method

Every search transaction on this interface answers on both GET and the HTTP QUERY method — the safe HTTP method whose request parameters travel in the request body rather than in the URL query string. The handler is the same; only the location of the parameters changes.

Method Parameters live in Example
GET The URL query string GET /studies?PatientID=PATIENT001
QUERY The request body QUERY /studies with body PatientID=PATIENT001

A QUERY request carries the same parameters a GET would place on the URL, as application/x-www-form-urlencoded or application/json, with the same attribute-key form described under Attribute IDs. An empty body is an unfiltered search, the same as a bare GET /studies. Everything else about the request — Authorization, Accept, the response payload and headers, the status codes on this page — is unchanged.

A QUERY request whose parameters cannot be read is refused, rather than run as a search with no filters:

Request Response
Non-empty body of any other Content-Type, or with no Content-Type 415 (Unsupported Media Type) with Accept-Query: application/x-www-form-urlencoded, application/json
Parameters on the URL query string 400 (Bad Request); for a QUERY request only the body is read, so move the parameters there or use GET
A JSON array body 400 (Bad Request)
A body with no usable parameter names (typically a JSON document sent as application/x-www-form-urlencoded) 400 (Bad Request)

Why it exists. Search parameters such as PatientID, PatientName and AccessionNumber can carry PHI. Placed on the URL they end up in the access and proxy logs of every hop between the client and this service, and in browser history when the caller is a browser-side client. Placed in a QUERY body they do not. Nothing about the response changes — the reason to use QUERY is what it stops leaking, not what it returns.

Deployment option: QUERY-only. A deployment can disable GET and HEAD on the QIDO-RS and WADO-RS read endpoints, so that caller-supplied search parameters never travel in a URL at all (q.v., kastoria-health image page). With that configuration, a GET is answered:

HTTP/1.1 405 Method Not Allowed
Allow: QUERY
Content-Type: application/json

{ "error": "Method Not Allowed",
  "message": "GET is disabled on this server; use the QUERY method instead" }

An Allow header naming only QUERY is safe to make because every read route on this service has a QUERY mirror. HEAD is refused alongside GET because it carries the same URL and therefore the same PHI-bearing query string. The 405 is returned only after the request has been authenticated when viewer-JWT verification is enabled, so the response does not disclose the configuration to unauthenticated callers.

Searchability: stored is not searchable

Search queries are served from search indexes maintained automatically by a background study-processing stage after instances are stored.

Newly stored studies become searchable once this processing has completed. After studies have been stored, they are asynchronously processed by the kastoria-health platform. Queries for studies that have not yet been processed return an empty array. A client that stores a study and immediately searches for it must expect this and retry after the processing stage has caught up.

Search parameters

Study level

Parameter Support Description
StudyInstanceUID Direct lookup Unique study identifier
PatientID Exact or starts-with, case-insensitive Patient identifier. A single trailing * matches every value starting with what precedes it; * alone matches every study
StudyDate Single date or range Study date in YYYYMMDD format. Single date (20240101) or range (20240101-20240131, 20240101-, -20240131)
PatientName Leading components, case-insensitive Patient's name in DICOM PN form. The value names leading components and each matches whole: DOE matches DOE^JOHN, DOE^JOHN matches DOE^JOHN^Q but not DOE^JOHNSON. A single * as the last character of the whole value makes everything before it a prefix of the stored name, spanning the ^ separator: DOE* matches DOESMORE^ANN, and ^JOH* matches only a name with no family that begins JOH. Matched against the alphabetic component group
StudyTime Single time or range Study time in DICOM TM format, HH[MM[SS[.FFFFFF]]]. Single time (143000) or range (080000-170000, 080000-, -170000)
AccessionNumber Exact or starts-with, case-insensitive Accession number. A single trailing * matches every value starting with what precedes it; * alone matches every study
StudyDescription Exact or starts-with, case-insensitive Study description. A single trailing * matches every value starting with what precedes it; * alone matches every study
ModalitiesInStudy List; matches any one modality, ignoring case Modality (e.g. CT, MR). A list separated by \ or , is an IN clause — the study matches when any of its modalities equals any listed value
limit Supported (default 100, maximum 1000) Maximum number of matches returned in one response
offset Supported (default 0, maximum 1000) Number of matches skipped before the first returned one. A value above the maximum is rejected with 400, not capped

Series level

Parameter Support Description
Modality List; matches any one, ignoring case Filter by modality. A list separated by \ or , is an IN clause
SeriesInstanceUID Exact match Filter by series UID (a UID has no case to ignore)
SeriesNumber Exact match Filter by series number
limit Supported (default 100, maximum 1000) Maximum number of matches returned in one response
offset Supported (default 0, maximum 1000) Number of matches skipped before the first returned one. A value above the maximum is rejected with 400, not capped

Attribute IDs

Query parameter keys may be encoded as either of the following (PS3.18 §8.3.4.1):

Value Example
{group}{element} 0020000D
{dicomKeyword} StudyInstanceUID

Matching semantics

Search type Supported attributes Example
Range query StudyDate, StudyTime StudyDate=20240101-20240131 — inclusive range. Either bound may be omitted (e.g. StudyDate=20240101- or StudyDate=-20240131)
Exact match StudyInstanceUID, PatientID, AccessionNumber, StudyDescription, ModalitiesInStudy PatientID=PATIENT001
Leading components PatientName PatientName=DOE matches DOE^JOHN — the value names leading PN components and each matches whole, so this is not an exact match on the full name. An empty component means empty: ^DOE names a study with no family
Universal match PatientName, PatientID, AccessionNumber, StudyDescription PatientID=* — the value * drops the predicate and matches every study, as does an empty value (PS3.4 §C.2.2.2.1, §C.2.2.2.4)
Starts-with wildcard PatientName, PatientID, AccessionNumber, StudyDescription PatientName=DOE^JOH*, PatientID=AAA* — one * as the last character of the value (PS3.18 §10.6.3.1); see the wildcard rules below

Notes:

  • Wildcard matching (PS3.18 §10.6.3.1) is supported in restricted form for PatientName, PatientID, AccessionNumber and StudyDescription:
  • A single * as the last character of the value is a starts-with match over the whole value: PatientID=AAA* matches every value that begins with AAA, ignoring case. On PatientName the value is the text a stored name begins with and the * spans the ^ component separator as PS3.4's wildcard does: DOE* matches DOESMORE^ANN, DOE^JOH* matches DOE^JOHN^Q, and ^JOH* matches a family-less ^JOHNNY.
  • The value * alone is universal matching (PS3.4 §C.2.2.2.4): the predicate is dropped and every study matches.
  • Any other wildcard construct is rejected. A leading or embedded * (*DOE, DOE*SMITH, DOE*^JOH*, *^DOE), more than one *, or any ? returns 400 (Bad Request) naming the offending parameter. On PatientName a value naming a component group with = is rejected too.
  • Why: a widened or narrowed result set would not be the one the query asked for.
  • A * or ? in any other matching attribute (for example ModalitiesInStudy=C*) is not a wildcard; it is compared literally.
  • A PatientName with no wildcard names leading whole components, and an empty component means empty.
  • DOE matches DOE^JOHN^Q. ^DOE names a study with no family whose given name is DOE, so it does not match SMITH^DOE. DOE^^Q requires a name with no given name.
  • This is not first-name-only search.
  • Trailing separators carry no significance (PS3.5 §6.2): DOE^^^ is DOE, and DOE^ asks what DOE asks.
  • On a PatientName with a trailing *, padding is trimmed from every component but the last. DOE^ JOHN^* is DOE^JOHN^*.
  • Why: the last component is text the caller cut short, so it loses only its leading spaces. DOE^JO * asks for given names beginning JO and does not match DOE^JOHN.
  • Trailing empty components carry no significance, so a stored name ^DAVE does not match ^DAVE^^*.
  • A zero-length value is universal matching (PS3.4 §C.2.2.2.1) on all four wildcard attributes as on the others: PatientID= places no constraint and every study matches. It is neither an error nor an ignored parameter, so it carries no Warning header field. PatientName= is the empty name, and a value spelling the empty name with separators (^, ^^, spaces) is the same empty name.
  • An attribute named twice, once by keyword and once by tag number (PatientName=DOE&00100010=*) is rejected with 400 (Bad Request) naming the attribute and both spellings, in study, series and instance searches alike.
  • Why: PS3.18 §8.3.4.1 allows either spelling, but only one value can take effect and which one would depend on the order the keys arrive in.
  • Matching ignores case for every attribute except StudyInstanceUID, which is a UID: aa-1234 and AA-1234 are one identifier, and chris and CHRIS are one person.
  • StudyTime values are compared by the instant they denote, so a query and a stored value written to different precision (090000 and 090000.000000) match.
  • The upper bound of a StudyTime range runs to the end of the unit it names, matching the way a StudyDate upper bound runs to the end of its day. -235959 includes a study acquired at 235959.500, and -0900 includes one at 090030. An explicit fraction names an instant instead, so -090030.000 ends exactly there.
  • A StudyTime naming the whole day — 000000-235959, 000000-, -235959, or a bare - — narrows nothing and is treated as absent rather than searched for.
  • A StudyDate or StudyTime range whose end precedes its start is refused with 400 (Bad Request). A StudyTime range does not wrap past midnight.
  • Each query parameter must be supplied at most once. A repeated parameter — PatientID=A&PatientID=B — is rejected with 400 (Bad Request) naming the parameter.
  • Wildcard matching beyond starts-with is not supported on PatientName, PatientID, AccessionNumber and StudyDescription: a * anywhere but as the single last character of the value, ?, and the contains form (* on both ends) are rejected with 400 (Bad Request).
  • Fuzzy matching is not supported. A search with fuzzymatching=true is answered with literal matching and a Warning header field:
Warning: 299 {service}: The fuzzymatching parameter is not supported. Only literal matching has been performed.

fuzzymatching=false asks for what the service does anyway and is answered silently. Any other value is reported as an unsupported query parameter.

Pagination

Both search transactions implement response pagination per PS3.18 §8.3.4.4.

Parameter Default Behavior
offset 0 Number of matches skipped before the first returned match; an explicit value above 1000 is rejected with 400
limit 100 Maximum matches returned in one response; an explicit value above 1000 is capped

maxResults (PS3.18 §8.3.4.4.1) is 1000 — the ceiling on an explicit limit, so no single response returns more than 1000 matches. A request that supplies no limit receives 100.

When matches remain beyond those returned, the response carries a Warning header field:

Warning: 299 {service}: There are more additional results that can be requested

The header announces that a further page can be requested. It does not carry a count of the matches not returned.

Both parameters must be non-negative integers. A malformed value is rejected with 400 (Bad Request) rather than ignored — silently dropping a limit would return the full result set to a caller that asked for one page.

offset may not exceed 1000 — the same ceiling as limit, so a request may skip no more than it may retrieve — and a larger one is rejected with 400 (Bad Request) rather than capped. Paging is offset-based with no cursor, so reaching a match means loading every match in front of it. A caller needing to go deeper should narrow the query rather than page further into an unnarrowed one.

Search depth

A search is limited in how far back it reaches, but only where it has to be. Naming anything selective — a patient identifier, an accession number — settles the search almost at once, and it is then answered in full however old the matches are. The limit is reached only when what the query names is broad: several broad attributes searched together, a single broad starts-with value (PatientID=A*, StudyDescription=CT*) that covers much of the archive, or a broad search whose StudyTime rules out most of the studies it reaches.

Where a search is limited, the response is 200 (OK) and carries a Warning header field naming the earliest study date covered:

Warning: 299 {service}: Searched studies from 20241216 onward; earlier matches may exist

Results from that date onward are complete. Nothing is claimed about studies before it.

  • A PatientName search and any starts-with search name no date. A PatientName filter matches leading components and a starts-with filter matches every value sharing its base. Each is answered from a range covering several distinct values, ordered by value before date, so a limited search of this kind cannot name a date before which its answer is complete. Where such a search is limited, the warning states the limit without dating it:
Warning: 299 {service}: The search was limited before every matching study was examined; further matches may exist

Both spellings mean the same thing to a caller: the result set is not known to be complete. Only the first tells you from when it is.

  • A search on a single exact-match attribute, or on none, normally fills its page long before the limit matters, and is then answered in full however old the matches are. It is limited only when most of what it reads is rejected afterwards, as with a broad value behind a StudyTime. A starts-with search is bounded in the same way: the cost of a prefix is the number of studies sharing it, so a deliberately broad prefix with nothing else to narrow it stops after a bounded number of index entries and answers with what it read, carrying the undated warning above rather than presenting itself as complete. A StudyDate supplied alongside a starts-with value keeps the search proportional to that date window rather than to every study sharing the prefix.

  • An empty result set carries the warning too, when the search was limited. 200 (OK) with an empty array and no Warning header means no study matches. 200 (OK) with an empty array and this warning means no study matches within the range searched. These are different answers, and they are distinguished by the header rather than by the payload.

  • An explicit StudyDate narrows the search but does not remove the limit. It is the most effective thing a caller can supply: it bounds every attribute at once, so a search that names a date is normally answered in full and carries no warning whatever attributes accompany it.

  • A caller needing a longer history for a broad combination of attributes should page through it by date, a range at a time.

Unsupported query parameters

A query parameter this service does not match on is accepted, ignored, and announced. The response is 200 (OK) and carries a Warning header field naming every parameter that was ignored:

Warning: 299 {service}: The following query parameters are not supported and were ignored: PatientSex\StudyID

This applies to both search transactions, and to any parameter other than that level's matching attributes and the limit / offset controls — including an attribute the service returns but cannot match on, and a parameter it does not recognize at all. The result set is therefore wider than the request asked for: the ignored parameter narrowed nothing.

A 400 is not used here. PS3.18 reserves it for a query the service cannot parse, and PS3.4 §C.2.2.1.3 permits an Optional Key to be returned without being matched on — so a well-formed query the service can only partly honor is answered, with the shortfall stated.

Parameter names are separated by \, the DICOM multi-valued delimiter, rather than by a comma, because Warning is itself a comma-delimited list field. A name this service cannot repeat back is reported as (unprintable):

Warning: 299 {service}: The following query parameters are not supported and were ignored: PatientSex\(unprintable)

Both warnings are sent when both apply — a query naming an ignored attribute can still overflow its page — as two warn-values, the query's shortcoming before the response's:

Warning: 299 {service}: The following query parameters are not supported and were ignored: PatientSex
Warning: 299 {service}: There are more additional results that can be requested

Response

The response is an array of DICOM datasets in DICOM JSON format. Results are ordered by study date and time, most recent first. Two exceptions: a search on PatientName that names fewer components than the stored name — SMITH matching SMITH^JOHN — is ordered most-recent-first within each matching patient, but is not ordered by date across several patients sharing those leading components; and a starts-with search is not ordered by date — its order is not guaranteed, because the entries it reads are ordered by value before date.

Default study-level attributes:

Tag Attribute
(0020,000D) StudyInstanceUID
(0010,0020) PatientID
(0010,0010) PatientName
(0010,0030) PatientBirthDate
(0010,0040) PatientSex
(0020,0010) StudyID
(0008,0020) StudyDate
(0008,0030) StudyTime
(0008,0050) AccessionNumber
(0008,0061) ModalitiesInStudy
(0008,1030) StudyDescription
(0020,1206) NumberOfStudyRelatedSeries
(0020,1208) NumberOfStudyRelatedInstances

Default series-level attributes:

Tag Attribute
(0020,000D) StudyInstanceUID
(0020,000E) SeriesInstanceUID
(0020,0011) SeriesNumber
(0008,0005) SpecificCharacterSet
(0008,0060) Modality
(0008,0021) SeriesDate
(0008,0031) SeriesTime
(0008,103E) SeriesDescription
(0008,0070) Manufacturer
(0008,0080) InstitutionName
(0008,0090) ReferringPhysicianName
(0008,1090) ManufacturerModelName
(0018,0015) BodyPartExamined
(0018,1030) ProtocolName
(0020,1209) NumberOfSeriesRelatedInstances

Note: The includefield parameter, to return additional attributes beyond the defaults, is not currently supported.

Status codes

Code Description
200 (OK) The response payload contains all matching resources (an empty array when there are no matches)
400 (Bad Request) The query cannot be honored as written: a range that cannot match (a StudyDate or StudyTime range whose end precedes its start; a StudyTime range does not wrap past midnight), a limit or offset that is not a non-negative integer, an offset above 1000, a query parameter supplied more than once, an attribute named by both its keyword and its tag number, a wildcard construct other than a single trailing * (see Matching semantics), a request body that cannot be parsed, or a QUERY request refused under The QUERY method
401* (Unauthorized) Viewer-JWT verification is enabled and the request carries no valid bearer token
403* (Forbidden) A request for a study by UID, or for anything beneath it (series, instances, frames, metadata, etc.), names a Study Instance UID that is not in the token's scope
405 (Method Not Allowed) Deployment option: GET/HEAD are disabled on this server; use QUERY — see The QUERY method. The response carries Allow: QUERY
406 (Not Acceptable) The specified Accept header does not allow application/dicom+json
413 (Content Too Large) The request body is too large
415 (Unsupported Media Type) A QUERY request body is neither application/x-www-form-urlencoded nor application/json; the response carries Accept-Query — see The QUERY method
500 (Internal Server Error) The server encountered an unexpected error

* See above for an explanation of how to authorize using Viewer-JWT verification.

Response guarantees

  • An empty result set is returned with 200 (OK) and an empty JSON array — 204 (No Content) is not used.
  • A 200 (OK) always means the search ran to completion. A search that fails part-way through returns 500, and never a partial or empty array with 200 — a client must be able to distinguish "no studies match" from "the search could not be completed". A query the service cannot satisfy because of how it is written returns 400, so a caller can tell its own mistake from the server's.
  • A 200 (OK) does not by itself mean every parameter was applied. Two things narrow what the payload holds relative to what was asked, and both are stated in a Warning header field rather than left for the client to infer:
  • A parameter this service does not match on is ignored, so the result set is wider than the request.
  • Matches beyond limit are not returned, so the result set is narrower than the whole match set.

A response carrying no Warning header field is complete in every sense: every parameter was applied, no match was left behind, and no limit was placed on how far back the search reached.

Examples

Search studies by patient name and date

curl "http://localhost:3000/studies?PatientName=DOE^JOHN&StudyDate=20240101" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json"

The same search over QUERY

The identical search, with the PHI-bearing parameters in the request body rather than the URL — nothing reaches a proxy log or browser history:

curl -X QUERY "http://localhost:3000/studies" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "PatientName=DOE^JOHN" \
  --data-urlencode "StudyDate=20240101"

Search studies by date range

curl "http://localhost:3000/studies?StudyDate=20240101-20240131" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json"

Search studies by patient ID

curl "http://localhost:3000/studies?PatientID=PATIENT001" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json"

Search studies by starts-with wildcard

A single trailing * matches every value that begins with what precedes it, ignoring case. This returns studies whose PatientID begins with PAT and whose PatientName begins with DOE^JOH — such as DOE^JOHN^Q — within a date range:

curl "http://localhost:3000/studies?PatientID=PAT*&PatientName=DOE%5EJOH*&StudyDate=20240101-20241231" \
 [-H 'Authorization: ******' \ ]
  -H "Accept: application/dicom+json"

A leading, embedded or repeated *, or any ?, is rejected with 400 (Bad Request) rather than answered with a widened result set.

Direct lookup by study UID

curl "http://localhost:3000/studies?StudyInstanceUID=1.2.840.113619.2.55.3.604688119.868.1234567890.1" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json"

Skip the first 100 matches and return up to 100 more:

curl "http://localhost:3000/studies?PatientID=PATIENT001&offset=100&limit=100" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json"

Search series within a study

curl "http://localhost:3000/studies/1.2.840.113619.2.55.3.604688119.868.1234567890.1/series?Modality=CT" \
 [-H 'Authorization: Bearer <jwt-token>' \ ]
  -H "Accept: application/dicom+json"

Example response

[
  {
    "0020000D": {
      "vr": "UI",
      "Value": ["1.2.840.113619.2.55.3.604688119.868.1234567890.1"]
    },
    "00100020": {
      "vr": "LO",
      "Value": ["PATIENT001"]
    },
    "00100010": {
      "vr": "PN",
      "Value": [{ "Alphabetic": "DOE^JOHN" }]
    },
    "00080020": {
      "vr": "DA",
      "Value": ["20240101"]
    },
    "00080030": {
      "vr": "TM",
      "Value": ["120000"]
    },
    "00080050": {
      "vr": "SH",
      "Value": ["ACC001"]
    },
    "00080061": {
      "vr": "CS",
      "Value": ["CT"]
    },
    "00081030": {
      "vr": "LO",
      "Value": ["Example Study Description"]
    },
    "00201206": {
      "vr": "IS",
      "Value": [1]
    },
    "00201208": {
      "vr": "IS",
      "Value": [100]
    }
  }
]

Reading the Warning header

A search naming an unsupported parameter and more matches than fit on one page succeeds, but carries two warnings:

curl -i "http://localhost:3000/studies?PatientSex=F&StudyDate=20240101-20240131" [ \
  -H 'Authorization: Bearer <jwt-token>' ]
HTTP/1.1 200 OK
Content-Type: application/dicom+json
Warning: 299 kastoria-dicomweb: The following query parameters are not supported and were ignored: PatientSex
Warning: 299 kastoria-dicomweb: There are more additional results that can be requested

PatientSex is returned in the payload but cannot be matched on, so the result set is wider than the query asked for; and further pages remain.

Notes for client implementers

  • Do not treat 200 (OK) with an empty array as definitive without checking for a Warning header field. A search limited to a window returns the same empty payload whether nothing matches at all or nothing matches recently. The header is the only distinction.
  • Treat a 299 warning as information, not an error. It accompanies a successful response and does not indicate a failed or degraded search. A response may carry more than one — an ignored parameter, a limited window, and further pages available are independent conditions and can all apply at once.
  • To search a longer history, page by date rather than widening the range. Take the date the warning names, and issue the next request with a StudyDate range ending the day before it. Repeat until a response arrives without the warning, or until far enough back to stop. Each request is bounded, and together they cover the history without any single request being expensive.
  • Supply a StudyDate whenever one is known. It bounds every attribute at once, which is both faster and the surest way to receive a complete answer rather than a limited one.
  • Make a starts-with value as long as the identifier allows. The cost of a prefix is the number of studies sharing it, not the length of what was typed: PatientID=AA-12* reads a handful of entries where PatientID=A* may span most of the archive.
  • Prefer StudyInstanceUID when it is known. It is answered as a direct lookup, without reading any index.
  • Use QUERY rather than GET when the parameters might carry PHI. The transaction is identical; only the location of the parameters changes, and a QUERY body does not end up in access or proxy logs the way a URL does (see The QUERY method). A deployment configured to disable GET returns 405 (Method Not Allowed) with Allow: QUERY; the correct client behaviour is to send the same request over QUERY.

See also