HealthTable: Tables.jl Interface (General)
The HealthTable Struct
The core of the interface is the HealthTable struct.
HealthBase.HealthTable — TypeHealthTable{T}A lightweight, schema-aware wrapper for OMOP CDM tables, providing a standardized Tables.jl interface and metadata tracking.
The HealthTable struct is designed to wrap OMOP CDM-compliant data sources (such as DataFrames), ensuring that all columns conform to the OMOP CDM specification for a given version. It attaches the OMOP CDM version as metadata and enables seamless integration with the Julia Tables.jl ecosystem.
Fields
source::T: The underlying data source (typically aDataFrame) containing the OMOP CDM table data.
Examples
person_df = DataFrame(
person_id=1:3,
gender_concept_id=[8507, 8532, 8507],
year_of_birth=[1990, 1985, 2000]
)
ht = HealthTable(person_df; omop_cdm_version="v5.4.1")
Tables.schema(ht) # Get the schema
DataFrame(ht) # Materialize as DataFrameTables.jl API Implementation
The HealthTable wrapper types will implement key Tables.jl methods:
HealthTable implements the Tables.jl interface to ensure compatibility with the Julia data ecosystem:
Tables.istable — MethodTables.istable(::Type{<:HealthTable})Signal that HealthTable is a table according to the Tables.jl interface.
This function is part of the Tables.jl interface and is used to identify types that can be treated as tabular data.
Returns
Bool: Always returnstruefor theHealthTabletype.
Tables.rowaccess — MethodTables.rowaccess(::Type{<:HealthTable})Signal that HealthTable supports row-based iteration.
This function is part of the Tables.jl interface. A true return value indicates that Tables.rows can be called on an instance of HealthTable.
Returns
Bool: Always returnstruefor theHealthTabletype.
Tables.rows — MethodTables.rows(ht::HealthTable)Return an iterator over the rows of the HealthTable.
This function implements the row-access part of the Tables.jl interface by delegating to the underlying source object.
Arguments
ht::HealthTable: TheHealthTableinstance.
Returns
- An iterator object that yields each row of the table.
Tables.columnaccess — MethodTables.columnaccess(::Type{<:HealthTable})Signal that HealthTable supports column-based access.
This function is part of the Tables.jl interface. A true return value indicates that Tables.columns can be called on an instance of HealthTable.
Returns
Bool: Always returnstruefor theHealthTabletype.
Tables.columns — MethodTables.columns(ht::HealthTable)Return the HealthTable's data as a set of columns.
This function implements the column-access part of the Tables.jl interface by delegating to the underlying source object.
Arguments
ht::HealthTable: TheHealthTableinstance.
Returns
- A column-accessible object that represents the table's data.
Tables.schema — MethodTables.schema(ht::HealthTable)Get the schema of the HealthTable.
The schema includes the names and types of the columns. This function delegates the call to the underlying source.
Arguments
ht::HealthTable: TheHealthTableinstance.
Returns
Tables.Schema: An object describing the column names and their Julia types.
Tables.materializer — MethodTables.materializer(::Type{<:HealthTable})Specify the default type to use when materializing a HealthTable.
This function is part of the Tables.jl interface. It allows other packages to convert a HealthTable into a concrete table type like a DataFrame by calling DataFrame(ht).
Returns
Type: TheDataFrametype, indicating it as the preferred materialization format.
Source: https://tables.juliadata.org/stable/implementing-the-interface/