Skip to contents

Creates a template that serves as a base definition for related concepts. Templates can contain parameter placeholders (e.g., {{age_threshold}}) that variants can customize when inheriting.

Usage

ont_define_template(
  template_id,
  template_name,
  object_type,
  base_sql_expr,
  parameters = NULL,
  description = NULL,
  source_standard = NULL,
  owner_domain = NULL,
  created_by = NULL,
  con = NULL
)

Arguments

template_id

Character. Unique identifier for the template.

template_name

Character. Human-readable name.

object_type

Character. The object type this template applies to.

base_sql_expr

Character. SQL expression with optional {{placeholder}} parameters that variants can customize.

parameters

Named list. Parameter definitions with default values. Each parameter can be a simple default value or a list with default, type, and description fields.

description

Character. Description of the template.

source_standard

Character. Source standard (e.g., "ILO", "OECD").

owner_domain

Character. Domain that owns this template.

created_by

Character. Who created this template.

con

A DBI connection. If NULL, uses the active connection.

Value

Invisibly returns the template_id.

Examples

if (FALSE) { # \dontrun{
ont_connect(":memory:")
ont_register_object("Person", "persons", "person_id")

# Define ILO unemployed template
ont_define_template(
    template_id = "ilo_unemployed",
    template_name = "ILO Unemployed Definition",
    object_type = "Person",
    base_sql_expr = "
        age >= {{min_age}} AND age <= {{max_age}}
        AND NOT employed_last_week
        AND actively_seeking_work
        AND available_to_start_within_{{availability_weeks}}_weeks
    ",
    parameters = list(
        min_age = list(default = 15, type = "integer", description = "Minimum age"),
        max_age = list(default = 74, type = "integer", description = "Maximum age"),
        availability_weeks = list(default = 2, type = "integer", description = "Weeks to availability")
    ),
    source_standard = "ILO",
    description = "International Labour Organization standard unemployment definition"
)
} # }