# DMSQuery XML Format

The DMSQuery format is the XML request format for search queries to the enaio® server.
It describes which archives and object types to search, which fields should appear in the result
and under what conditions objects should be returned.

The corresponding schema file is `DMSQuery.xsd`. The result of a DMSQuery request is returned in
[DMSContent XML format](DMSContent.md).

## Usage

The DMSQuery format is used as input by the following jobs:

| Job | Description |
|---|---|
| [dms.GetResultList](../dms.md#dms.GetResultList) | Primary research job — executes the query and returns hits in DMSContent format |
| [dms.GetDeletedObjects](../dms.md#dms.GetDeletedObjects) | Search in the trash — query in DMSQuery format |
| [dms.AddStoredQuery](../dms.md#dms.AddStoredQuery) | Create stored search — stores a DMSQuery on the server |
| [dms.UpdateStoredQuery](../dms.md#dms.UpdateStoredQuery) | Update stored search — replaces an existing DMSQuery |
| [dms.GetStoredQuery](../dms.md#dms.GetStoredQuery) | Retrieve stored search — returns the stored DMSQuery |
| [dms.ConvertQuery](../dms.md#dms.ConvertQuery) | Converts a DMSQuery to another query format (or vice versa) |
| [dms.ExecuteStoredQuery](../dms.md#dms.ExecuteStoredQuery) | Execute a stored search — internally uses the stored DMSQuery |

## Request Types (requesttype)

The `requesttype` attribute on the `<DMSQuery>` element determines the structure of the returned
[DMSContent](DMSContent.md):

| Value | Name | Result |
|---|---|---|
| `LOL` | Linear Object List | Tabular hit list (`<Rowset>` in DMSContent). Standard and most performant option. |
| `HOL` | Hierarchical Object List | Hierarchical object list (`<ObjectList>` in DMSContent) with complete field data,<br>optionally with BaseParams, rights, child and parent objects. |
| `MIX` | Mixed | HOL data for the requested object combined with LOL data for parents and children. |
| `DTL` | Detail (deprecated) | No longer use — use `MIX` instead. |

## Quick Start — Common Query Patterns

### Simple Field Search (LOL)

Search all documents of a type where a field has a specific value:

```xml
<DMSQuery requesttype="LOL" pagesize="20" offset="0">
  <Archive internal_name="patient">
    <ObjectType type="DOCUMENT" internal_name="medical_letter">
      <Fields>
        <Field internal_name="date"/>
        <Field internal_name="subject"/>
        <Field internal_name="physician"/>
      </Fields>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="medical_letter">
          <FieldCondition internal_name="physician" operator="=">
            <Value>Dr. Müller</Value>
          </FieldCondition>
        </ConditionObject>
      </Conditions>
    </ObjectType>
  </Archive>
</DMSQuery>
```

### Complete HOL Query with Base Parameters

```xml
<DMSQuery requesttype="HOL" baseparams="1" pagesize="10" offset="0">
  <Archive internal_name="patient">
    <ObjectType type="DOCUMENT" internal_name="medical_letter">
      <Fields field_schema="ALL"/>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="medical_letter">
          <FieldCondition internal_name="date" operator="BETWEEN">
            <Value>2024-01-01</Value>
            <Value>2024-12-31</Value>
          </FieldCondition>
        </ConditionObject>
      </Conditions>
    </ObjectType>
  </Archive>
</DMSQuery>
```

## XML Structure (Overview)

```xml
<DMSQuery requesttype="LOL|HOL|MIX"
          pagesize="20" offset="0" maxhits="-1"
          baseparams="0" variants="0" rights="0"
          combined="0" sql="0" icons="0"
          disablesearchgroups="1" narrowsearch="0"
          status="0" fileinfo="0" object_inserts="0"
          registercontext="0" outputformat="0">

  <!-- Optional parameter definitions for parametrized queries -->
  <Params>
    <Param name="myParam"><Value>Search term</Value></Params>
  </Params>

  <!-- One or more archives -->
  <Archive internal_name="archive1">

    <!-- Object type query -->
    <ObjectType type="DOCUMENT" internal_name="invoice" alias="Invoice">
      <Fields field_schema="DEF">
        <Field internal_name="date" sortpos="1" sortorder="DESC"/>
        <Field internal_name="amount"/>
      </Fields>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="invoice">
          <FieldCondition internal_name="status" operator="=" bool_op="AND">
            <Value>approved</Value>
          </FieldCondition>
          <FieldCondition internal_name="amount" operator=">=" bool_op="AND">
            <Value>1000</Value>
          </FieldCondition>
        </ConditionObject>
      </Conditions>
      <!-- HOL: Request child objects -->
      <ChildObjects child_schema="DEF" export_depth="1">
        <ChildObjectType type="REGISTER" internal_name="invoice_items">
          <Fields field_schema="ALL"/>
        </ChildObjectType>
      </ChildObjects>
      <!-- HOL: Request path to parent objects -->
      <ParentObjects parent_schema="DEF">
        <SubObjectType type="FOLDER" internal_name="company"/>
      </ParentObjects>
      <!-- Linked objects from another archive -->
      <ExternalObjects>
        <ExternalArchive internal_name="contacts">
          <ExternalObjectType internal_name="contact_person">
            <Fields field_schema="MIN"/>
          </ExternalObjectType>
        </ExternalArchive>
      </ExternalObjects>
    </ObjectType>

    <!-- Search by base parameters (folders) -->
    <FolderBaseParams>
      <Creator><Value>admin</Value></Creator>
      <Created><From>2024-01-01</From><To>2024-12-31</To></Created>
    </FolderBaseParams>

    <!-- Full-text search -->
    <FulltextQuery>
      <Fulltext MODE="PATTERN">
        <Value>Discharge letter</Value>
      </Fulltext>
    </FulltextQuery>

  </Archive>
</DMSQuery>
```

## Elements and Attributes

### `<DMSQuery>` (root element)

#### Result Control

| Attribute | Type | Default | Description |
|---|---|---|---|
| `requesttype` | <<requesttypes,requesttypes>> | `LOL` | Request type: `LOL`, `HOL`, `MIX` or `DTL` (deprecated) |
| `pagesize` | xs:long | `0` | Maximum number of hits per response (`0` = all) |
| `offset` | xs:long | `0` | 0-based start index for pagination |
| `maxhits` | xs:long | `-1` | Absolute hit limit (`-1` = no limit) |
| `baseparams` | xs:short | `0` | `1` = return base parameters (creator, date, archiving status etc.) |
| `variants` | xs:short | `0` | `1` = return document variant information (HOL only) |
| `combined` | xs:short | `0` | `1` = return information about combined documents (HOL only) |
| `rights` | xs:short | `0` | `1` = return access rights per object instance |
| `fileinfo` | xs:short | `0` | `1` = return file information (MIME type, size, page count) |
| `object_inserts` | xs:short | `0` | `1` = return allowed child object types and counts |
| `icons` | xs:short | `0` | `1` = return icon ID per object |
| `sql` | xs:short | `0` | `1` = write executed SQL statement in result document (LOL only) |

#### Search Behavior

| Attribute | Type | Default | Description |
|---|---|---|---|
| `disablesearchgroups` | xs:short | `1` | `1` = disable search groups; `0` = apply user search groups |
| `narrowsearch` | xs:short | `0` | `0` (broad) = for register clauses, objects directly below folder level are also returned. +<br>`1` (narrow) = only objects in explicitly specified registers. |
| `registercontext` | xs:short | `0` | `0` = register clauses are ignored in HOL; only objects in registers are requested |
| `status` | xs:short | `0` | Status filter for objects (reserved) |
| `outputformat` | xs:short | — | Numeric output format code (supplementary to `requesttype`) |

### `<Params>` / `<Param>`

Optional parameter definitions for **parametrized queries**. Parameters allow storing
a DMSQuery template and filling it with values at runtime
(e.g. for stored searches via [dms.ExecuteStoredQuery](../dms.md#dms.ExecuteStoredQuery)).

> **Note:** The `name` attribute on `<Param>` is not formally defined in the XSD, but required in practice, as `<FieldCondition>` refers to it via `<ParamValue ref="name">`.

Each `<Param>` contains exactly one of the following value types:

| Child element | Meaning |
|---|---|
| `<Value>Value</Value>` | Fixed standard value |
| `<NULL/>` | Parameter is empty (NULL) |
| `<LinkedValue ref="link_name"/>` | Value is taken from the field with the specified `link_name` at runtime |
```xml
<DMSQuery requesttype="LOL">
  <Params>
    <Param name="doctor"><Value>Dr. Müller</Value></Param>
    <Param name="dateFrom"><Value>2024-01-01</Value></Param>
    <Param name="dateTo"><Value>2024-12-31</Value></Param>
  </Params>
  <Archive internal_name="patient">
    <ObjectType type="DOCUMENT" internal_name="medical_letter">
      <Fields><Field internal_name="subject"/></Fields>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="medical_letter">
          <FieldCondition internal_name="physician" operator="=">
            <ParamValue ref="doctor"/>
          </FieldCondition>
          <FieldCondition internal_name="date" operator="BETWEEN">
            <ParamValue ref="dateFrom"/>
            <ParamValue ref="dateTo"/>
          </FieldCondition>
        </ConditionObject>
      </Conditions>
    </ObjectType>
  </Archive>
</DMSQuery>
```

### `<Archive>`

Defines the archive to be searched. At least one of the attributes `id`, `name`, `internal_name`
or `osguid` must be specified. Multiple `<Archive>` elements are allowed (cross-archive search).

> **Note:** `internal_name` is only required for cross-archive queries (multiple `<Archive>` elements)
— assuming the contained `<ObjectType>` elements also use `internal_name`. For single-archive queries,
the attribute can be omitted.

| Attribute | Type | Default | Description |
|---|---|---|---|
| `id` | xs:long | `0` | Numeric archive ID |
| `name` | xs:string | — | Display name |
| `internal_name` | xs:string | — | Internal name (recommended) |
| `osguid` | xs:string | — | GUID |
Child elements (any combination, multiple allowed):

* `<ObjectType>` — typed object search
* `<FolderBaseParams>` — folder search by base parameters
* `<RegisterBaseParams>` — register search by base parameters
* `<DocumentBaseParams>` — document search by base parameters
* `<FulltextQuery>` — full-text search

### `<ObjectType>`

Defines the searched object type and the desired output fields and search conditions.

| Attribute | Type | Default | Description |
|---|---|---|---|
| `type` | <<objecttypes,objecttypes>> | — | `FOLDER`, `REGISTER` or `DOCUMENT` (recommended for disambiguation with same names) |
| `id` | xs:long | `0` | Numeric ID of the object type |
| `name` | xs:string | — | Display name |
| `internal_name` | xs:string | — | Internal name (recommended) |
| `osguid` | xs:string | — | GUID |
| `table` | xs:string | — | Database table name |
| `alias` | xs:string | — | Alias name that appears in hit list (faster access for multiple object types) |
Child elements:

| Element | Purpose |
|---|---|
| `<Fields>` (optional) | Which fields should appear in the result |
| `<Conditions>` (optional) | Filter conditions — which objects should be returned |
| `<ChildObjects>` (optional, HOL only) | Child objects that should be returned hierarchically |
| `<ParentObjects>` (optional, HOL only) | Parent path (folders/register) that should be returned |
| `<ExternalObjects>` (optional) | Linked objects from other archives |

### `<Fields>` / `<Field>`

`<Fields>` lists the fields that should appear in the result.

| Attribute on `<Fields>` | Type | Default | Description |
|---|---|---|---|
| `field_schema` | <<field_schema,field_schema>> | `DEF` | Predefined selection of fields to return (overridable by individual `<Field>` elements) |
The `field_schema` attribute on `<Fields>` controls which fields are **defaultly** included — individual `<Field>` elements supplement or override this selection.

| Attribute on `<Field>` | Type | Default | Description |
|---|---|---|---|
| `name` | xs:string | — | Display name of the field |
| `internal_name` | xs:string | — | Internal name (recommended) |
| `dbname` | xs:string | — | Database column name |
| `osguid` | xs:string | — | GUID |
| `system` | xs:short | `0` | `1` = system field (e.g. `OBJECT_ID`, `folder_id`) |
| `sortpos` | xs:long | `0` | Sorting position in the result (`0` = no sorting, `1` = primary sort field, …) |
| `sortorder` | xs:string | — | Sorting direction: `ASC` (ascending) or `DESC` (descending) |
| `link_name` | xs:string | — | Alias name for the field value — enables use as condition value in `<ExternalObjectType>` via `<LinkedValue ref="link_name">` |
> **Tip:** System fields for position information (only in relation tables): `folder_id`, `register_id`, `register_type`.

### `<Conditions>` / `<ConditionObject>`

`<Conditions>` contains either a list of `<ConditionObject>` elements **or** a list
of `<ObjectID>` elements (direct retrieval by ID).

#### Variant 1 — Field-based Conditions (`<ConditionObject>`)

Each `<ConditionObject>` carries the same identification attributes as `<ObjectType>` and
contains any number of condition elements:

* [`<FieldCondition>`](#fieldcondition) — condition on a simple field
* [`<FieldGroup>`](#fieldgroup) — logical group of conditions (AND/OR)
* [`<TableCondition>`](#tablecondition) — condition on a table field
* `<Fulltext>` — full-text condition

Multiple `<ConditionObject>` elements are connected with AND.

#### Variant 2 — Direct Retrieval by ID (`<ObjectID>`)

```xml
<Conditions>
  <ObjectID>9823</ObjectID>
  <ObjectID>9824</ObjectID>
</Conditions>
```

### `<FieldCondition>`

The central condition for an index field.

| Attribute | Type | Default | Description |
|---|---|---|---|
| `internal_name` | xs:string | — | Internal field name (recommended) |
| `dbname` | xs:string | — | Database column name |
| `name` | xs:string | — | Display name |
| `system` | xs:short | `0` | `1` = system field |
| `operator` | <<ComparisonOperators,ComparisonOperators>> | `=` | Comparison operator |
| `bool_op` | <<BooleanOperators,BooleanOperators>> | `AND` | Connection with the previous condition: `AND` or `OR` |
As a child element (condition value), exactly one of the following types must be specified — for
`BETWEEN`, `IN` and `NOT IN`, **two or more** `<Value>` elements are required:

| Child element | Meaning |
|---|---|
| `<Value>text</Value>` | Literal comparison value |
| `<Value special="1">#USER#</Value>` | Placeholder value (see <<specialvalues,Placeholders>>) |
| `<ParamValue ref="paramname"/>` | Reference to a declared `<Param>` parameter |
| `<LinkedValue ref="link_name"/>` | Reference to the field value of a field in the main object (for `<ExternalObjectType>`) |
| `<NULL/>` | Check for NULL (no value) |
| `<SpecialValue>text</SpecialValue>` | Internal special value |
```xml
<!-- Equality -->
<FieldCondition internal_name="status" operator="="><Value>approved</Value></FieldCondition>

<!-- Date range -->
<FieldCondition internal_name="date" operator="BETWEEN">
  <Value>2024-01-01</Value>
  <Value>2024-12-31</Value>
</FieldCondition>

<!-- List of values -->
<FieldCondition internal_name="category" operator="IN">
  <Value>A</Value>
  <Value>B</Value>
  <Value>C</Value>
</FieldCondition>

<!-- NULL check -->
<FieldCondition internal_name="archived_by" operator="="><NULL/></FieldCondition>

<!-- Current logged-in user -->
<FieldCondition internal_name="owner" operator="=">
  <Value special="1">#USER#</Value>
</FieldCondition>

<!-- OR connection with previous condition -->
<FieldCondition internal_name="type" operator="=" bool_op="OR"><Value>letter</Value></FieldCondition>
```

### `<FieldGroup>`

Groups multiple conditions into a logical unit. Enables nested AND/OR expressions.

| Attribute | Type | Required | Description |
|---|---|---|---|
| `operator` | <<BooleanOperators,BooleanOperators>> | Yes | `AND` or `OR` — connects all elements within the group |
Child elements: `<FieldCondition>`, `<TableCondition>`, date conditions, `<FieldGroup>` (recursive).

```xml
<!-- (status = "open" OR status = "pending") AND amount >= 500 -->
<ConditionObject type="DOCUMENT" internal_name="invoice">
  <FieldGroup operator="OR">
    <FieldCondition internal_name="status" operator="="><Value>open</Value></FieldCondition>
    <FieldCondition internal_name="status" operator="="><Value>pending</Value></FieldCondition>
  </FieldGroup>
  <FieldCondition internal_name="amount" operator=">=" bool_op="AND">
    <Value>500</Value>
  </FieldCondition>
</ConditionObject>
```

### `<TableCondition>`

Condition for a table field (Grid control). Each `<TableColumn>` corresponds to a column
of the table field and carries the same attributes and child elements as `<FieldCondition>`.

| Attribute | Type | Default | Description |
|---|---|---|---|
| `name` / `internal_name` / `dbname` | xs:string | — | Identification of the table field |
| `row` | xs:long | `0` | Row number (`0` = any row) |
```xml
<!-- Search for invoices that contain a position with amount > 1000 -->
<TableCondition internal_name="positions">
  <TableColumn internal_name="pos_amount" operator=">">
    <Value>1000</Value>
  </TableColumn>
</TableCondition>
```

### `<ChildObjects>`

Only for HOL queries. Defines which child objects should be returned hierarchically.

| Attribute | Type | Default | Description |
|---|---|---|---|
| `child_schema` | <<object_schema,object_schema>> | `DEF` | `DEF` = only explicitly listed types; `ALL` = all object types of the archive |
| `export_depth` | xs:short | `0` | Depth of hierarchy (`0` = one level, `1` = two levels, …) |
| `field_schema` | <<field_schema,field_schema>> | — | Standard field selection for all children |
Child elements: `<ChildObjectType>` (one element per requested child type) or `<SubObjectType>`.

`<ChildObjectType>` carries the same identification attributes as `<ObjectType>` plus:
- `alias` — alias name for the hit list
- `<Fields>` — desired fields
- `<SubConditions>` — additional filter conditions for child objects (HOL only)
- `<ExternalObjects>` — linked foreign archive objects of children

### `<ParentObjects>`

Only for HOL queries. Returns the path to parent objects (folders, registers).

| Attribute | Type | Default | Description |
|---|---|---|---|
| `parent_schema` | <<object_schema,object_schema>> | `DEF` | Which parent types should be returned |
| `field_schema` | <<field_schema,field_schema>> | — | Standard field selection for parent objects |
Child elements:
- `<ParentObjectType>+` — explicit parent types
- `<SubObjectType>` — the target object in the path

### `<ExternalObjects>`

Linked objects from other archives — enables cross-archive joins.
Each `<ExternalArchive>` identifies a foreign archive (via `archive_ident` attributes)
and optionally contains an `<ExternalObjectType>` element that defines the foreign object type
and its fields/conditions.

Field values of the main object can be used as condition values:

1. In the main object, set the `<Field>` element with `link_name="myAlias"`.
2. In the `<ExternalObjectType>`, formulate the condition with `<LinkedValue ref="myAlias"/>`.

```xml
<ObjectType type="DOCUMENT" internal_name="invoice">
  <Fields>
    <Field internal_name="customer_id" link_name="cust_ref"/>
  </Fields>
  <ExternalObjects>
    <ExternalArchive internal_name="contacts">
      <ExternalObjectType internal_name="company">
        <Fields>
          <Field internal_name="company_name"/>
        </Fields>
        <SubConditions>
          <FieldCondition internal_name="id" operator="=">
            <LinkedValue ref="cust_ref"/>
          </FieldCondition>
        </SubConditions>
      </ExternalObjectType>
    </ExternalArchive>
  </ExternalObjects>
</ObjectType>
```

### Base Parameter Search

Search by base parameters (metadata) allows filtering without knowing the index fields.

#### `<FolderBaseParams>` / `<RegisterBaseParams>`

Search for folders or registers by metadata. Contains the child elements:

| Element | Description |
|---|---|
| `<Creator><Value>name</Value></Creator>` | Created by (up to 2 values; implicitly OR-connected) |
| `<Created><From>date</From><To>date</To></Created>` | Creation date range |
| `<Modifier><Value>name</Value>…</Modifier>` | Last modified by |
| `<Modified><From>date</From><To>date</To></Modified>` | Modification date range |
| `<Owner operator="=" bool_op="OR"><Value>name</Value>…</Owner>` | Owner (always OR-connected) |
| `<ChildObjects>…</ChildObjects>` | Request child objects of found parent objects (HOL) |

#### `<DocumentBaseParams>`

Like `<FolderBaseParams>`, additionally:

| Element | Description |
|---|---|
| `<ArchiveState><ArchiveStateValue>ARCHIVED</ArchiveStateValue></ArchiveState>` | Filter by archiving status (one or more values; implicitly OR) |
| `<Locked><LockStateValue>UNLOCKED</LockStateValue></Locked>` | Filter by checkout status |

### `<FulltextQuery>`

Full-text search over all documents of the archive.

```xml
<FulltextQuery>
  <Fulltext MODE="PATTERN">
    <Value>discharge* AND Müller</Value>
  </Fulltext>
</FulltextQuery>
```
Optional control attributes (for the RetrievalWare full-text engine):

| Attribute | Type | Default | Description |
|---|---|---|---|
| `MODE` | <<fulltextsearchmode,FullTextSearchModeType>> | `PATTERN` | Search mode |
| `EXPANSION_LEVEL_PROPERTY` | xs:short | `4` | Expansion level for synonyms |
| `FUZZY_SPELL_HALF_WORDS` | xs:boolean | `false` | Fuzzy search for half words |
| `FUZZY_SPELL_THRESHOLD` | xs:short | `0` | Threshold for fuzzy spell correction |
| `MAX_FUZZY_SPELL_PROPERTY` | xs:short | `15` | Maximum fuzzy alternatives |
| `MAX_REG_EXPR_PROPERTY` | xs:short | `4` | Maximum regex expansions |
| `WORD_EXPANSION_LIMIT_PROPERTY` | xs:short | `20` | Limit for word expansions |

## Enumeration Types

### `requesttypes`

| Value | Result Format | Description |
|---|---|---|
| `LOL` | DMSContent `<Rowset>` | Linear Object List — tabular format |
| `HOL` | DMSContent `<ObjectList>` | Hierarchical Object List — complete object data |
| `MIX` | DMSContent `<ObjectList>` | Mixed — HOL data + optional LOL data for parents/children |
| `DTL` | — | Deprecated — use `MIX` instead |

### `field_schema`

| Value | Description |
|---|---|
| `DEF` | Standard fields according to object type configuration |
| `ALL` | All fields of the object type |
| `ALLREL` | All fields including relational (linked) fields |
| `MIN` | Minimal field set (only ID and required fields) |

### `object_schema`

| Value | Description |
|---|---|
| `DEF` | Only explicitly listed types |
| `ALL` | All object types of the archive |
| `REGISTER` | Only register types |
| `DOCUMENTS` | Only document types |

### `objecttypes`

| Value | Meaning |
|---|---|
| `FOLDER` | Folder |
| `REGISTER` | Register |
| `DOCUMENT` | Document |

### `ComparisonOperators`

| Operator | Meaning |
|---|---|
| `=` | Equal |
| `<>` / `!=` | Not equal |
| `<` | Less than |
| `&lt;=` | Less than or equal |
| `>` | Greater than |
| `&gt;=` | Greater than or equal |
| `IN` | Value is in a list — specify multiple `<Value>` elements |
| `NOT IN` | Value is not in a list |
| `BETWEEN` | Value lies between two limits — specify exactly two `<Value>` elements |
| `NOT BETWEEN` | Value does not lie between two limits |

### `BooleanOperators`

| Value | Meaning |
|---|---|
| `AND` | Connection with AND (default) |
| `OR` | Connection with OR |

### `FullTextSearchModeType`

| Value | Meaning |
|---|---|
| `PATTERN` | Pattern recognition with wildcards (`*`, `?`) |
| `BOOLEAN` | Boolean expressions (`AND`, `OR`, `NOT`) |
| `CONCEPT` | Conceptual search (semantic similarity) |

### Placeholders (`special="1"`)

Special values are used in `<Value special="1">` and resolved by the server at runtime:

| Placeholder | Resolved Value |
|---|---|
| `#USER#` | Login name of the current user |
| `#OWNER#` | Owner of the current user |
| `#DATE#` | Current date |
| `#CREATOR#` | Creator (login name) |
| `#CREATION_DATE#` | Creation date |
| `#ARCHIVIST#` | Archivist (login name) |
| `#ARCHIVE_DATE#` | Archiving date |
| `#COMPUTER_NAME#` | Client computer name |
| `#COMPUTER_IP#` | Client IP address |
| `#COMPUTER_GUID#` | Client GUID |

## Complete Examples

### Multi-level Search with FieldGroup (OR/AND Combination)

Search for documents that are **(open OR pending)** AND **amount ≥ 500**:

```xml
<DMSQuery requesttype="LOL" pagesize="50" offset="0" baseparams="0">
  <Archive internal_name="accounting">
    <ObjectType type="DOCUMENT" internal_name="invoice">
      <Fields>
        <Field internal_name="invoice_number" sortpos="1" sortorder="DESC"/>
        <Field internal_name="date"/>
        <Field internal_name="status"/>
        <Field internal_name="amount"/>
      </Fields>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="invoice">
          <FieldGroup operator="OR">
            <FieldCondition internal_name="status" operator="=">
              <Value>open</Value>
            </FieldCondition>
            <FieldCondition internal_name="status" operator="=">
              <Value>pending</Value>
            </FieldCondition>
          </FieldGroup>
          <FieldCondition internal_name="amount" operator=">=" bool_op="AND">
            <Value>500</Value>
          </FieldCondition>
        </ConditionObject>
      </Conditions>
    </ObjectType>
  </Archive>
</DMSQuery>
```

### HOL Query with BaseParams and Rights

All documents of the current user from 2024, with base parameters and rights:

```xml
<DMSQuery requesttype="HOL" baseparams="1" rights="1" pagesize="20" offset="0">
  <Archive internal_name="patient">
    <ObjectType type="DOCUMENT" internal_name="medical_letter">
      <Fields field_schema="ALL"/>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="medical_letter">
          <FieldCondition internal_name="date" operator="BETWEEN">
            <Value>2024-01-01</Value>
            <Value>2024-12-31</Value>
          </FieldCondition>
        </ConditionObject>
      </Conditions>
    </ObjectType>
    <DocumentBaseParams>
      <Owner operator="=">
        <Value special="1">#USER#</Value>
      </Owner>
      <ArchiveState>
        <ArchiveStateValue>ARCHIVED</ArchiveStateValue>
        <ArchiveStateValue>ARCHIVABLE</ArchiveStateValue>
      </ArchiveState>
    </DocumentBaseParams>
  </Archive>
</DMSQuery>
```

### Search by Table Field

Invoices with a position over 1000 €, sorted by invoice number:

```xml
<DMSQuery requesttype="LOL" pagesize="20" offset="0">
  <Archive internal_name="accounting">
    <ObjectType type="DOCUMENT" internal_name="invoice">
      <Fields>
        <Field internal_name="invoice_number" sortpos="1" sortorder="ASC"/>
        <Field internal_name="date"/>
      </Fields>
      <Conditions>
        <ConditionObject type="DOCUMENT" internal_name="invoice">
          <TableCondition internal_name="positions">
            <TableColumn internal_name="pos_amount" operator=">">
              <Value>1000</Value>
            </TableColumn>
          </TableCondition>
        </ConditionObject>
      </Conditions>
    </ObjectType>
  </Archive>
</DMSQuery>
```

### Full-text Search with Child Objects (HOL)

Full-text search in the archive and hierarchical return with sub-registers:

```xml
<DMSQuery requesttype="HOL" baseparams="0" pagesize="10" offset="0">
  <Archive internal_name="patient">
    <FulltextQuery>
      <ChildObjects child_schema="DEF">
        <ChildObjectType type="DOCUMENT" internal_name="medical_letter">
          <Fields field_schema="DEF"/>
        </ChildObjectType>
      </ChildObjects>
      <Fulltext MODE="PATTERN">
        <Value>discharge letter*</Value>
      </Fulltext>
    </FulltextQuery>
  </Archive>
</DMSQuery>
```
