SOPTemplateSchema Reference¶
Overview¶
The SOPTemplateSchema is the meta-schema that defines the structure and validation rules for all SOPs in the system. This reference provides complete documentation of all schema elements, properties, and validation rules.
Schema Version¶
Current version: 2.0
# Schema declaration
'@context': https://schema.org
'@type': SoftwareApplication
additionalProperties: false # Strict mode - no extra properties allowed
Root Properties¶
Required Metadata Properties¶
Property |
Type |
Required |
Description |
Validation |
|---|---|---|---|---|
|
string |
Yes |
Unique identifier for the SOP |
Must be unique across system |
|
string |
Yes |
Short name for the SOP |
Max 100 characters |
|
string |
Yes |
Full descriptive title |
Max 255 characters |
|
string |
Yes |
Version number |
Semantic versioning recommended |
|
string |
Yes |
SOP author name |
- |
|
string |
Yes |
SOP approver name |
- |
|
string |
Yes |
Publication date |
ISO format: YYYY-MM-DD |
|
enum |
Yes |
Current status |
|
Bioschemas Properties¶
Property |
Type |
Required |
Description |
Default |
|---|---|---|---|---|
|
string |
Yes |
SOP URL |
Format: valid URI |
|
string |
Yes |
License type |
e.g., “MIT”, “Apache-2.0” |
|
array |
Yes |
Search keywords |
Array of strings |
|
string |
Yes |
Protocol category |
e.g., “Laboratory Protocol” |
|
enum |
No |
Bioschemas type |
|
|
string |
No |
Schema profile URI |
Bioschemas profile URL |
Optional Metadata Properties¶
Property |
Type |
Required |
Description |
|---|---|---|---|
|
string |
No |
Detailed description |
|
string |
No |
Deployment date (YYYY-MM-DD) |
|
array |
No |
Dependencies/requirements |
Task Structure¶
TaskGroups¶
Top-level container for organizing tasks. Rendered as cards in CLAIRE.
taskgroups:
- id: string # Required, unique
name: string # Display name
title: string # Full title
description: string # Description text
ordinal: number # Display order (1-n)
ui_config: object # UI configuration
children: array # Array of Tasks
Properties:
Property |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Unique identifier |
|
string |
No |
Short display name |
|
string |
No |
Full title |
|
string |
No |
Help text |
|
number |
No |
Sort order (1-based) |
|
object |
No |
UI customization |
|
array |
Yes |
Child Task objects |
Tasks¶
Container for fields and nested tasks. Immediate children of TaskGroups render as tabs.
'@type': Task
id: string
name: string
title: string
description: string
ordinal: number
parents: array # Parent references
children: array # Fields or nested Tasks
ui_config: object
Properties:
Property |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Must be “Task” |
|
string |
Yes |
Unique identifier |
|
string |
No |
Display name |
|
string |
No |
Full title |
|
string |
No |
Help text |
|
number |
No |
Sort order within parent |
|
array |
No |
Parent task IDs |
|
array |
No |
Child elements |
|
object |
No |
UI customization |
Field Types¶
Basic Field¶
Input element for data collection.
'@type': Field
id: string
name: string
title: string
description: string
type: string # Data type
required: boolean
default: any
validation: object
children: array # Configuration objects
Field Data Types¶
Type |
Description |
Additional Properties |
|---|---|---|
|
Text input |
|
|
Numeric input |
|
|
Checkbox |
- |
|
Multiple values |
|
|
Nested object |
|
|
File upload |
|
String Field Properties¶
type: "string"
format: "email|uri|date|time|datetime|uuid" # Optional format
minLength: number
maxLength: number
pattern: "regex" # Regular expression
enum: ["option1", "option2"] # Allowed values
default: "default value"
Number Field Properties¶
type: "number"
min: number # Minimum value
max: number # Maximum value
multipleOf: number # Step/increment
unit: "string" # Display unit (°C, mL, etc.)
precision: number # Decimal places
integer: boolean # Integer only
Boolean Field Properties¶
type: "boolean"
default: true|false
Array Field Properties¶
type: "array"
items:
type: "string|number|object" # Item type
enum: [...] # If restricted values
minItems: number # Minimum items
maxItems: number # Maximum items
uniqueItems: boolean # No duplicates
File Field Properties¶
type: "file"
file_config:
accept: ".pdf,.jpg" # Accepted file types
maxSize: 10485760 # Max size in bytes
multiple: boolean # Multiple files allowed
required: boolean # File required
Special Schema Objects¶
Table¶
For tabular data entry with defined columns.
'@type': Table
id: string
name: string
columns: # Column definitions
- id: string
name: string
type: string
required: boolean
validation: object
minRows: number # Minimum rows
maxRows: number # Maximum rows
Column Properties:
Property |
Type |
Description |
|---|---|---|
|
string |
Column identifier |
|
string |
Column header |
|
string |
Data type |
|
boolean |
Required field |
|
array |
Allowed values |
|
object |
Validation rules |
ImportTemplate¶
Defines structure for bulk data import.
'@type': ImportTemplate
format: "csv|xlsx|json"
columns:
- field: string # Field mapping
header: string # Column header
type: string # Data type
required: boolean
enum: array # Allowed values
Configuration Objects¶
ELNFilenameComponent¶
Marks fields for inclusion in generated filenames.
'@type': ELNFilenameComponent
id: string
order: number # Position in filename (1-n)
filename_component: true
Usage:
- id: patient_id_field
'@type': Field
name: "Patient ID"
type: "string"
children:
- id: patient_id_filename
'@type': ELNFilenameComponent
order: 1
filename_component: true
ExportConfiguration¶
Controls how fields are exported.
'@type': ExportConfiguration
id: string
enabled: boolean # Include in export
value_immutable: boolean # Cannot change value
default_immutable: boolean # Cannot change default
format: string # Export format
UI Configuration¶
UIConfiguration Object¶
ui_config:
component_type: "card|field|table" # Component type
variant: "default|outlined|elevated" # Style variant
icon: "string" # Icon name
collapsible: boolean # Can collapse
defaultCollapsed: boolean # Start collapsed
showBorder: boolean # Show border
className: "string" # CSS class
style: object # Inline styles
Available Icons¶
Common laboratory and UI icons:
Icon |
Usage |
|---|---|
|
General lab work |
|
Chemical procedures |
|
Microscopy |
|
Molecular biology |
|
Temperature |
|
Time-sensitive |
|
Date-related |
|
Documents |
|
Data storage |
|
Warnings |
|
Information |
|
Validation |
|
Errors |
|
Configuration |
|
User-related |
Validation Rules¶
Field Validation¶
validation:
required: boolean
min: number # Minimum value/length
max: number # Maximum value/length
minLength: number # String minimum length
maxLength: number # String maximum length
pattern: "regex" # Regular expression
enum: array # Allowed values
message: "string" # Custom error message
# Advanced
precision: number # Decimal places
multipleOf: number # Step value
unique: boolean # Unique value
immutable: boolean # Cannot change after set
Cross-Field Validation¶
schema_dependencies:
cross_field_validations:
- name: "validation_name"
fields: ["field1", "field2"]
condition:
type: "comparison|calculation|conditional"
operator: "equals|less_than|greater_than"
formula: "expression" # For calculations
error_message: "Custom error message"
Conditional Validation¶
conditional_validation:
- when:
field: "trigger_field"
equals: "value"
then:
field: "target_field"
required: true
validation:
min: 10
max: 100
Schema Extensions¶
Custom Properties¶
While additionalProperties: false prevents arbitrary properties, you can extend functionality through:
UI Config: Custom UI properties
Validation: Custom validation rules
Children: Configuration objects
Metadata: Using description fields
Annotations¶
Allow user comments on any field:
annotation: boolean # Enable annotations
annotation_required: boolean # Require annotation
annotation_maxLength: number # Max annotation length
JSON-LD Support¶
Context and Types¶
All schema objects support JSON-LD annotations:
'@context': "https://schema.org"
'@type': "SchemaType"
Important: The @type property is for development reference only. Do not use for application logic - use schema-driven approaches instead.
Best Practices¶
Schema Independence¶
✅ DO:
Use explicit type declarations
Define all properties needed
Use schema registry for type detection
Keep configuration in children arrays
❌ DON’T:
Parse field IDs for logic
Match on field names
Hardcode schema assumptions
Use @type for application logic
Performance Considerations¶
Limit nesting depth: Maximum 4-5 levels
Reasonable field counts: <100 fields per SOP
Optimize validation: Simple patterns preferred
Minimize cross-field validation: Performance impact
Maintainability¶
Use semantic IDs: Meaningful, descriptive
Version appropriately: Track all changes
Document thoroughly: Use descriptions
Follow conventions: Consistent patterns
Validation Examples¶
Email Validation¶
type: "string"
format: "email"
validation:
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
message: "Please enter a valid email address"
URL Validation¶
type: "string"
format: "uri"
validation:
pattern: "^https?://.+"
message: "URL must start with http:// or https://"
Phone Number¶
type: "string"
validation:
pattern: "^\\+?[1-9]\\d{1,14}$"
message: "Enter valid international phone number"
Custom Pattern¶
type: "string"
validation:
pattern: "^[A-Z]{3}-[0-9]{4}-[A-Z]{2}$"
message: "Format: ABC-1234-XY"
Error Messages¶
Standard Error Codes¶
Code |
Meaning |
Example |
|---|---|---|
|
Required field missing |
“This field is required” |
|
Wrong data type |
“Expected number, got string” |
|
Regex validation failed |
“Does not match required pattern” |
|
Value out of range |
“Value must be between X and Y” |
|
String length invalid |
“Must be at least X characters” |
|
Value not in allowed list |
“Must be one of: [values]” |
|
Duplicate value |
“This value already exists” |
Custom Messages¶
Always provide user-friendly error messages:
validation:
required: true
message: "Patient ID is required for all samples"
pattern: "^P[0-9]{6}$"
message: "Patient ID must be P followed by 6 digits (e.g., P123456)"
Migration Guide¶
From Version 1.x to 2.0¶
Key changes:
Strict mode enforced (
additionalProperties: false)Bioschemas properties required
@typeannotations addedUI config standardized
Migration steps:
Add required Bioschemas fields
Move custom properties to children
Update validation rules
Test thoroughly
Summary¶
The SOPTemplateSchema provides:
Strict validation: Ensures data integrity
Flexible structure: Supports complex protocols
UI customization: Rich presentation options
Schema independence: Future-proof design
Standards compliance: Bioschemas/JSON-LD support