Additional Topics > Medical Imaging in IDL > Using IDL DICOM Network Services > Build or Modify a Custom Query

## Build or Modify a Custom Query

You can create a custom query to return patient or study files that match specific patient-, study-, or series-level characteristics. To create a custom query, complete the following steps:

1. Click the Build Query button on the Query Retrieve SCU tab to open the Query Fields dialog.
2. In the Query Model area, select Patient Root or Study Root. This indicates the highest level of information that can be retrieved. For instance, if you select Study Root, you cannot retrieve the study by selecting the associated patient. You must select a study, series or image to be retrieved.
3. To check what query models are supported by the remote node, use the Echo SCU service on the Configuration tab. Select the Query SCP entity in the droplist and click Echo. If the echo is successful, query model information is printed following echo results in the Status window.
4. In the Query Level area, select Patient Level, Study Level or Series Level to define patient, study or series characteristics against which files are matched.
5. Changing the query model or query level makes some query fields active and others insensitive. Any values shown in insensitive fields are not applied to the current query.
6. Click Apply to store the query or Ok to store the query and close the dialog. The specified query fields are applied to subsequent queries. If you select Clear, the query will be performed at the Query Model level. Select Cancel to clear changes and revert to the last used query. Click the Help button for information on using wildcards in attribute matching, and information on DICOM date formats.

### Attribute Matching Using Wildcards

The implementation of the Query/Retrieve SCP service on the remote node determines the quality of attribute matching. All attribute matching is performed by the remote service. In addition to case sensitivity, matching can include one or more of the following:

Single Value Matching | Matches single values.
Wildcard Matching | Use * to match zero or more characters. Use ? to match any single character. For example, to return patients with a name beginning with HA, use HA*. To return a list of patients whose names vary by one or more instances of a single value, use the ? character to indicate the wildcard value as in M?NROE.
Range Matching | Use the - character in between date or time values to return any matches within that range. For example, to match any date in the first six months of the year, use 20050101-20050630.

The following table indicates the value representation (VR) and what wildcards are supported in each query field. An "x" in the column indicates the wildcard is supported.

Field | VR | * | ? | -
Patient Name | PN | x | x |
Family Name | PN | x | x |
Given Name | PN | x | x |
Middle Name | PN | x | x |
Prefix | PN | x | x |
Suffix | PN | x | x |
Patient ID | LO | x | x |
Study Date | DA |  |  | x
Study Time | TM |  |  | x
Accession Number | SH | x | x |
Study ID | SH | x | x |
Modality | CS |  |  |