> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clinia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Base Data Types

> Explore the primitive and composite types that power Clinia schemas

Clinia defines a comprehensive set of base types that model everything from simple strings to complex nested objects. These primitives guarantee consistent validation, indexing behavior, and processor compatibility across the registry.

<Note>
  Choosing the right base type impacts validation, query performance, and downstream processors. Use the tables and examples below to align schema design with your use cases.
</Note>

## Primitive Types

Primitive types represent atomic values with specific validation patterns and search capabilities.

### Text and String Types

#### Symbol (`symbol`)

A sequence of Unicode characters for general text content.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "name": "Dr. Sarah Wilson",
      "description": "Board-certified cardiologist specializing in interventional procedures"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^[\s\S]+$
    ```
  </Tab>
</Tabs>

**Best for**: Names, descriptions, free-text fields, search content

#### Code (`code`)

A string with specific formatting rules—no leading/trailing whitespace, single spaces only.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "status": "active",
      "type": "outpatient"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^[^\s]+( [^\s]+)*$
    ```
  </Tab>
</Tabs>

**Best for**: Status values, controlled vocabularies, coded identifiers, filter values

#### Markdown (`markdown`)

GitHub Flavored Markdown syntax for rich text content.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "instructions": "## Pre-procedure Instructions\n\n- Fast for **12 hours**\n- Take medications as prescribed"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^[\s\S]+$
    ```
  </Tab>
</Tabs>

**Best for**: Documentation, clinical notes, formatted instructions

#### URI (`uri`)

String used to identify a name or a resource within a namespace.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
      "namespace": "urn:uuid:53fefa32-fcbb-4ff8-8a92-55ee120877b7"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^\S*$
    ```
  </Tab>
</Tabs>

**Best for**: System identifiers, namespace identifiers, resource identifiers

#### URL (`url`)

A URI that is a literal web reference.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "profileUrl": "https://example.com/patient-profile",
      "resourceLink": "https://clinia.com/resource/1234567890"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^\S*$
    ```
  </Tab>
</Tabs>

**Best for**: Web resources, external references, literal resource links

### Numerical Types

#### Integer (`integer`)

Whole numbers with pattern validation.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "age": 45,
      "bedCount": 250
    }
    ```
  </Tab>

  <Tab title="Pattern & Format">
    ```regex theme={null}
    ^[0]|[-+]?[1-9][0-9]*$
    Format: int32
    ```
  </Tab>
</Tabs>

#### Decimal (`decimal`)

Rational numbers with implicit precision for financial and measurement data.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "dosage": 2.5,
      "temperature": 98.6,
      "cost": 125.50
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^-?(0|[1-9][0-9]{0,17})(\.[0-9]{1,17})?([eE][+-]?[0-9]{1,9})?$
    ```
  </Tab>
</Tabs>

### Temporal Types

#### Date (`date`)

Date or partial date without timezone information.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "birthDate": "1978-03-15",
      "appointmentDate": "2024-08"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?$
    ```
  </Tab>
</Tabs>

**Supported formats**: Year, year-month, full date (YYYY, YYYY-MM, YYYY-MM-DD)

#### DateTime (`datetime`)

Date and time with optional timezone specification.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "scheduledTime": "2024-08-15T14:30:00Z",
      "createdAt": "2024-08-15T14:30:00-05:00"
    }
    ```
  </Tab>
</Tabs>

Supports partial dates through full datetime with timezone offsets.

#### Time (`time`)

Time of day without date information.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "openingTime": "08:00:00",
      "procedureTime": "14:30:00.500"
    }
    ```
  </Tab>

  <Tab title="Pattern">
    ```regex theme={null}
    ^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]{1,9})?$
    ```
  </Tab>
</Tabs>

#### Instant (`instant`)

Precise moment in time, known at least to the second.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "timestamp": "2024-08-15T14:30:45.123Z",
      "timestampWithTimezoneOffset": "2024-08-15T14:30:12-5:00"
    }
    ```
  </Tab>
</Tabs>

<Warning>
  Always include timezone information for absolute precision.
</Warning>

### Other Primitive Types

#### Boolean (`boolean`)

Simple true/false values for binary states.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "isActive": true,
      "hasAllergies": false
    }
    ```
  </Tab>
</Tabs>

#### Geopoint (`geopoint`)

Geographic coordinates for location-based data.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "facilityLocation": {
        "latitude": 45.5017,
        "longitude": -73.5673
      }
    }
    ```
  </Tab>
</Tabs>

#### XHTML (`xhtml`)

Escaped HTML content following XHTML specifications.

<Tabs>
  <Tab title="Example Usage">
    ```json theme={null}
    {
      "formattedReport": "<p>Patient shows <strong>significant improvement</strong></p>"
    }
    ```
  </Tab>
</Tabs>

## Composite Types

Composite types assemble primitives into reusable structures.

### Array (`array`)

Ordered collections of items of the same type.

<Tabs>
  <Tab title="Profile Definition">
    ```json theme={null}
    {
      "specialties": {
        "type": "array",
        "items": {
          "type": "symbol"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Usage Example">
    ```json theme={null}
    {
      "specialties": ["Cardiology", "Internal Medicine"]
    }
    ```
  </Tab>
</Tabs>

**Best for**: Lists of similar items like specialties, tags, or categories.

### Object (`object`)

Custom structures that bundle multiple properties.

<Tabs>
  <Tab title="Profile Definition">
    ```json theme={null}
    {
      "vitals": {
        "type": "object",
        "properties": {
          "bloodPressure": {
            "type": "object",
            "properties": {
              "systolic": {"type": "integer"},
              "diastolic": {"type": "integer"},
              "unit": {"type": "symbol"}
            }
          },
          "heartRate": {"type": "integer"},
          "temperature": {"type": "decimal"}
        }
      }
    }
    ```
  </Tab>

  <Tab title="Resource Example">
    ```json theme={null}
    {
      "vitals": {
        "bloodPressure": {
          "systolic": 120,
          "diastolic": 80,
          "unit": "mmHg"
        },
        "heartRate": 72,
        "temperature": 98.6
      }
    }
    ```
  </Tab>
</Tabs>

**When to use**: Create custom objects for domain-specific data that is not covered by Clinia’s opinionated complex types.

## Type usage in practice

### Profile definition

Use base types in profiles to define the shape of your resources:

```json theme={null}
{
  "properties": {
    "patientId": {"type": "identifier"},
    "birthDate": {"type": "date"},
    "address": {
      "type": "array",
      "items": {"type": "address"}
    },
    "active": {"type": "boolean"}
  }
}
```

### Search compatibility

Different types support different [search operators](/explanation/operator):

| Type Category        | Types                                 | Supported Operators            | Use Cases                                   |
| -------------------- | ------------------------------------- | ------------------------------ | ------------------------------------------- |
| **Text Types**       | `symbol`, `code`, `markdown`          | `eq`, `match`, `any`, `all`    | Full-text search and exact matching         |
| **Numeric Types**    | `integer`, `decimal`                  | `eq`, `lt`, `gt`, `any`, `all` | Range queries and numerical comparisons     |
| **Temporal Types**   | `date`, `datetime`, `time`, `instant` | `eq`, `lt`, `gt`               | Date range filtering and temporal queries   |
| **Geographic Types** | `geopoint`                            | `geoDistance`                  | Location-based search and proximity queries |

<Info>
  Arrays inherit operators from their item type. An array of `symbol` supports text operators (`eq`, `match`, `any`, `all`), while an array of `integer` supports numeric operators (`eq`, `lt`, `gt`, `any`, `all`).
</Info>

### Processing pipelines

Types determine processor compatibility:

| Processor       | Compatible Types                         | Purpose                                                           | Documentation                                                                   |
| --------------- | ---------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| **Vectorizers** | `symbol`, `markdown`, arrays of `symbol` | Transform text content into vector embeddings for semantic search | [Vectorizers →](/explanation/ingestion-pipeline/built-in-processors#vectorizer) |

## Related concepts

<CardGroup cols={2}>
  <Card title="Clinia Complex Types" icon="layer-group" href="/explanation/data-types/clinia-types">
    Learn how higher-level healthcare concepts build on top of these base types.
  </Card>

  <Card title="Field Validation" icon="shield-check" href="/explanation/field-validation/basic">
    See how rules and cardinality interact with base types during ingestion.
  </Card>
</CardGroup>
