Skip to main content

Custom Data

Carium supports the creation and management of custom data tables that are associated with all patient records in the system. This capability is often used to track information that's not a first class feature in the Carium system. The schema for the tables is fully customizable. The tables can be created and specified using the API or SDK CLI. The API or UI can then manage the table entries directly.

There are three tables that comprise the custom data feature.

caredb_custom_ext_table is the top level definition of a table and defines the internal name and display_name for the table. caredb_custom_ext_field captures the schema for the table, while caredb_custom_ext_entry captures the full content of a row in the table.

Entries contain a column labeled content that represent all fo the data contained in the row of the custom table. The content is a JSON object where the keys map to the caredb_custom_ext_field.name column and the values are the actual data entry. All values are stored as strings in the database. The field types specified in the schema determine the UI presentation and validation rules applied to the inputs.

An example of a content entry is given below.

{
"datetime_of_report": "2024-02-03T16:31:00Z",
"score": "7"
}

In this case, datetime_of_report and score would be found in the caredb_custom_ext_field.name column.

Examples

List all custom data tables configured in the system

SELECT
ctable.name AS name,
ctable.display_name AS display_name
FROM caredb_custom_ext_table AS ctable
WHERE ctable.is_active = true
LIMIT 50

List all entries in a single custom data table

SELECT
create_usr.email AS created_by_email,
entry.created_at AS created_at,
mod_usr.email AS last_modified_by_email,
entry.last_modified_at AS last_modified_at,
entry.content AS content
FROM caredb_custom_ext_table AS ctable
JOIN caredb_custom_ext_entry AS entry
ON ctable.id = entry.table_id
JOIN identity_core_user AS create_usr
ON entry.created_by = create_usr.id
JOIN identity_core_user AS mod_usr
ON entry.last_modified_by = mod_usr.id
WHERE ctable.name = 'table_name' -- enter your table name here
ORDER BY entry.created_at DESC
LIMIT 50

This query will list the content as a valid JSON string in the content column. For a specific use case, the values can be extracted individually using the JSON_EXTRACT_PATH_TEXT function or post-processed using standard JSON tools.