| |
| |
| |
| CREATE TABLE |
| jurisdictions ( |
| jurisdiction_id SERIAL PRIMARY KEY, |
| jurisdiction_code VARCHAR(10) NOT NULL UNIQUE, |
| |
| region_name VARCHAR(100) NOT NULL |
| ); |
| CREATE TABLE |
| facilities ( |
| facility_id SERIAL PRIMARY KEY, |
| facility_code VARCHAR(50) NOT NULL UNIQUE, |
| |
| facility_name VARCHAR(150) NOT NULL |
| ); |
| CREATE TABLE |
| specialties ( |
| specialty_id SERIAL PRIMARY KEY, |
| specialty_name VARCHAR(100) NOT NULL UNIQUE |
| |
| ); |
| CREATE TABLE |
| personnel ( |
| personnel_id SERIAL PRIMARY KEY, |
| personnel_description TEXT, |
| auth_provider_uid VARCHAR(100) NOT NULL UNIQUE |
| |
| ); |
| |
| |
| |
| CREATE TABLE |
| concept_namespaces ( |
| namespace_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| standard_type VARCHAR(50) NOT NULL, |
| |
| public_standard BOOLEAN DEFAULT TRUE, |
| |
| is_external_private BOOLEAN DEFAULT FALSE, |
| |
| external_private_source VARCHAR(100), |
| |
| about TEXT, |
| link VARCHAR(500), |
| |
| |
| api_url VARCHAR(8192), |
| |
| api_url_params JSONB, |
| |
| api_request_body JSONB, |
| |
| api_response_display_path VARCHAR(500), |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| |
| CONSTRAINT uq_namespace_authority UNIQUE ( |
| standard_type, is_external_private, |
| external_private_source |
| ) |
| ); |
| CREATE TABLE |
| canonical_concepts ( |
| concept_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| namespace_id UUID NOT NULL REFERENCES concept_namespaces(namespace_id) ON DELETE RESTRICT, |
| standard_code VARCHAR(100) NOT NULL, |
| |
| display VARCHAR(150) NOT NULL, |
| |
| concept_date_designation TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| |
| |
| CONSTRAINT uq_versioned_concept UNIQUE ( |
| namespace_id, standard_code, concept_date_designation |
| ) |
| ); |
| CREATE INDEX |
| idx_concepts_traversal_speed ON canonical_concepts ( |
| namespace_id, standard_code, concept_date_designation DESC |
| ); CREATE TYPE concept_translator_relation ENUM ( |
| 'EQUIVALENT', 'NARROWER_THAN', 'WIDER_THAN' |
| ); |
| CREATE TABLE |
| concept_translator ( |
| link_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| concept_id UUID NOT NULL REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| linked_id UUID NOT NULL REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| |
| relationship_type concept_translator_relation NOT NULL DEFAULT 'EQUIVALENT', |
| active BOOLEAN DEFAULT TRUE, |
| |
| mapping_date_designation TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| CONSTRAINT chk_prevent_self_loop CHECK (concept_id <> linked_id), |
| |
| UNIQUE( |
| concept_id, linked_id, relationship_type, |
| mapping_date_designation |
| ) |
| ); |
| CREATE INDEX |
| idx_concept_translator_temporal ON concept_translator ( |
| concept_id, mapping_date_designation, |
| active |
| ); |
| CREATE TABLE |
| concept_translator_cache ( |
| cache_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| |
| ancestor_concept_id UUID NOT NULL REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| |
| descendant_concept_id UUID NOT NULL REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| |
| link_depth INTEGER NOT NULL CHECK (link_depth >= 1), |
| |
| |
| inferred_relationship_type concept_translator_relation NOT NULL DEFAULT 'EQUIVALENT', |
| |
| mapping_date_designation TIMESTAMP |
| WITH |
| TIME ZONE NOT NULL, |
| active BOOLEAN DEFAULT TRUE, |
| |
| UNIQUE( |
| ancestor_concept_id, descendant_concept_id, |
| inferred_relationship_type, mapping_date_designation |
| ) |
| ); |
| |
| CREATE INDEX |
| idx_concept_cache_traversal ON concept_translator_cache ( |
| ancestor_concept_id, mapping_date_designation, |
| active |
| ) INCLUDE ( |
| descendant_concept_id, link_depth, |
| inferred_relationship_type |
| ); |
| CREATE TABLE |
| concept_display_registry ( |
| display_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| concept_id UUID NOT NULL REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| |
| language_code VARCHAR(10) NOT NULL DEFAULT 'en', |
| |
| display_string TEXT NOT NULL, |
| |
| reference_standard BOOLEAN DEFAULT FALSE, |
| reference_code BOOLEAN DEFAULT FALSE, |
| |
| scope_tier VARCHAR(30) NOT NULL DEFAULT 'GLOBAL', |
| |
| |
| preference_weight INTEGER DEFAULT 1, |
| active BOOLEAN DEFAULT TRUE |
| ); |
| |
| |
| |
| CREATE TABLE |
| concept_jurisdictional_displays ( |
| display_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| concept_id UUID REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| jurisdiction_id INTEGER REFERENCES jurisdictions(jurisdiction_id), |
| preferred_display TEXT NOT NULL, |
| fully_specified_name TEXT NOT NULL, |
| UNIQUE(concept_id, jurisdiction_id) |
| ); |
| |
| |
| |
| CREATE TYPE expression_target_assignment AS ENUM ( |
| 'MAIN_TERM', 'ATTRIBUTE_MODIFIER', |
| 'BOTH' |
| ); |
| CREATE TABLE |
| custom_expressions ( |
| expression_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| personnel_id INTEGER REFERENCES personnel(personnel_id), |
| expression_name VARCHAR(100) NOT NULL, |
| |
| regex_pattern TEXT NOT NULL, |
| |
| is_case_insensitive BOOLEAN DEFAULT TRUE, |
| |
| |
| |
| |
| target_assignment expression_target_assignment NOT NULL DEFAULT 'MAIN_TERM', |
| concept_id UUID REFERENCES canonical_concepts(concept_id), |
| facility_id INTEGER REFERENCES facilities(facility_id), |
| specialty_id INTEGER REFERENCES specialties(specialty_id), |
| priority_weight INTEGER DEFAULT 1, |
| active BOOLEAN DEFAULT TRUE, |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW() |
| ); |
| CREATE INDEX |
| idx_expressions_parser_route ON custom_expressions ( |
| expression_name, target_assignment, |
| active |
| ); |
| |
| |
| |
| CREATE TABLE |
| expression_tags ( |
| tag_id VARCHAR(50) PRIMARY KEY, |
| |
| description TEXT |
| ); |
| CREATE TABLE |
| expression_tag_matrix ( |
| expression_id UUID REFERENCES custom_expressions(expression_id) ON DELETE CASCADE, |
| tag_id VARCHAR(50) REFERENCES expression_tags(tag_id), |
| PRIMARY KEY (expression_id, tag_id) |
| ); |
| |
| |
| |
| CREATE TABLE |
| expression_resolution_counters ( |
| counter_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| expression_id UUID NOT NULL REFERENCES custom_expressions(expression_id) ON DELETE CASCADE, |
| concept_id UUID NOT NULL REFERENCES canonical_concepts(concept_id) ON DELETE CASCADE, |
| |
| facility_id INTEGER REFERENCES facilities(facility_id) ON DELETE |
| SET |
| NULL, |
| specialty_id INTEGER REFERENCES specialties(specialty_id) ON DELETE |
| SET |
| NULL, |
| personnel_id INTEGER REFERENCES personnel(personnel_id) ON DELETE |
| SET |
| NULL, |
| |
| usage_count BIGINT NOT NULL DEFAULT 0 CHECK (usage_count >= 0), |
| |
| last_resolved_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| |
| CONSTRAINT uq_resolution_context_metric UNIQUE( |
| expression_id, concept_id, facility_id, |
| specialty_id, personnel_id |
| ) |
| ); |
| |
| CREATE INDEX |
| idx_resolution_weights_speed ON expression_resolution_counters ( |
| expression_id, specialty_id, facility_id, |
| usage_count DESC |
| ) INCLUDE (concept_id); |
| |
| CREATE TYPE ledger_level1_channel AS ENUM ( |
| 'assessment', 'vitals_measurement', |
| 'observation', 'exposure_profile', |
| 'device_diagnostic_report', 'clinical_evaluation_report', |
| 'procedure_order', 'medication_order', |
| 'insurance_cost_evaluation', 'clinical_location_followup', |
| 'patient_refusal', 'static_context', |
| 'temporal_context' |
| ); |
| |
| CREATE TYPE ledger_level2_context AS ENUM ( |
| |
| 'temporal_location', |
| |
| 'environmental_weather', |
| |
| |
| 'protective_equipment', |
| |
| |
| 'subject_of_record', |
| |
| 'session_variables_log', |
| |
| 'merge_resolution_topology', |
| |
| 'algorithmic_evaluation', |
| |
| |
| 'nutritional_exposure', |
| |
| 'biological_exposure', |
| |
| 'mechanical_injury', |
| |
| 'ballistic_profile', |
| |
| 'injury_fall_details', |
| |
| |
| 'clinical_rule_conflict', |
| |
| 'insurance_financial_breakdown', |
| |
| 'insurance_accumulator' |
| |
| ); |
| |
| CREATE TYPE ledger_level3_def AS ENUM ( |
| 'source_type', 'certainty', 'status', |
| 'associated_agent', 'temporal_boundary', |
| 'time', 'date_range', 'single_measurement', |
| 'measurement', 'product_identifiers', |
| 'anatomy_locations', 'vehicle', |
| 'pharmaceutical' |
| ); CREATE TYPE expression_tier_level AS ENUM ( |
| 'LEVEL_1', 'LEVEL_2', 'LEVEL_3', 'LEVEL_4', |
| 'LEVEL_5' |
| ); |
| CREATE TABLE |
| expression_hierarchical_routes ( |
| route_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| expression_id UUID NOT NULL REFERENCES custom_expressions(expression_id) ON DELETE CASCADE, |
| |
| tier_level expression_tier_level NOT NULL, |
| |
| target_level1 ledger_level1_channel, |
| target_level2 ledger_level2_context, |
| target_level3 ledger_level3_def, |
| |
| target_level4 VARCHAR(512), |
| target_level5 VARCHAR(512), |
| active BOOLEAN DEFAULT TRUE, |
| ); |
| |
| |
| CREATE INDEX |
| idx_expression_compiler_path ON expression_hierarchical_routes ( |
| expression_id, active, tier_level |
| ) INCLUDE ( |
| target_level1, target_level2, target_level3, |
| target_level4, target_level5 |
| ); |
|
|
| |
| |
| |
|
|
| CREATE TYPE configuration_data_type AS ENUM ( |
| 'int', 'float', 'string', 'bool', 'json', 'uuid' |
| ); |
|
|
| CREATE TABLE hierarchical_configuration_registry ( |
| config_key VARCHAR(100) NOT NULL, |
| config_type configuration_data_type NOT NULL, |
| config_value TEXT NOT NULL, |
| |
| |
| jurisdiction_id INTEGER REFERENCES jurisdictions(jurisdiction_id) ON DELETE CASCADE, |
| facility_id INTEGER REFERENCES facilities(facility_id) ON DELETE CASCADE, |
| specialty_id INTEGER REFERENCES specialties(specialty_id) ON DELETE CASCADE, |
| |
| description TEXT, |
| updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), |
| |
| |
| CONSTRAINT uq_scoped_config_coordinate UNIQUE ( |
| config_key, jurisdiction_id, facility_id, specialty_id |
| ) |
| ); |
|
|
| |
| CREATE INDEX idx_config_inheritance_speed ON hierarchical_configuration_registry ( |
| config_key, specialty_id, facility_id, jurisdiction_id |
| ); |
| |
| |
| |
| CREATE TABLE |
| note_templates ( |
| template_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| template_code VARCHAR(100) NOT NULL UNIQUE, |
| |
| description TEXT, |
| specialty_id INTEGER REFERENCES specialties(specialty_id), |
| |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW() |
| ); |
| |
| |
| |
| CREATE TABLE |
| template_versions ( |
| version_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| template_id UUID REFERENCES note_templates(template_id) ON DELETE CASCADE, |
| semantic_version VARCHAR(20) NOT NULL, |
| |
| is_active BOOLEAN DEFAULT FALSE, |
| |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| UNIQUE(template_id, semantic_version) |
| ); |
| |
| |
| |
| CREATE TABLE |
| template_slots ( |
| slot_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| language_id VARCHAR(5) DEFAULT 'en', |
| version_id UUID REFERENCES template_versions(version_id) ON DELETE CASCADE, |
| document_location VARCHAR(50) NOT NULL, |
| |
| slot_key VARCHAR(50) NOT NULL, |
| |
| jinja_template_text TEXT NOT NULL, |
| |
| UNIQUE(version_id, slot_key) |
| ); |
| CREATE TABLE |
| template_expression_matrix ( |
| version_id UUID REFERENCES template_versions(version_id) ON DELETE CASCADE, |
| expression_id UUID REFERENCES custom_expressions(expression_id) ON DELETE CASCADE, |
| PRIMARY KEY (version_id, expression_id) |
| ); |
| |
| |
| |
| CREATE TABLE |
| macro_registry ( |
| macro_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| personnel_id INTEGER REFERENCES personnel(personnel_id), |
| macro_name VARCHAR(100) NOT NULL, |
| |
| macro_template TEXT NOT NULL, |
| |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| UNIQUE(macro_name) |
| ); |
| |
| |
| |
| CREATE TABLE |
| parser_syntax_profiles ( |
| profile_id UUID PRIMARY KEY, |
| personnel_id INTEGER REFERENCES personnel(personnel_id), |
| |
| tag_token VARCHAR(5) DEFAULT '#' |
| |
| state_delimiter VARCHAR(5) DEFAULT '||', |
| |
| |
| state_start_delimiter VARCHAR(5) DEFAULT '|', |
| |
| state_end_delimiter VARCHAR(5) DEFAULT '|', |
| |
| |
| |
| comment_start_token VARCHAR(5) DEFAULT '//', |
| comment_end_token VARCHAR(5) DEFAULT ';', |
| |
| macro_start_token VARCHAR(5) DEFAULT '^', |
| |
| macro_placeholder VARCHAR(5) DEFAULT '[__]', |
| |
| |
| variable_start_token VARCHAR(5) DEFAULT '{', |
| |
| variable_end_token VARCHAR(5) DEFAULT '}', |
| |
| variable_delimiter VARCHAR(5) DEFAULT ',', |
| |
| |
| |
| |
| |
| |
| |
| |
| start_term_code_delimiter VARCHAR(5) DEFAULT '@@', |
| |
| start_term_display_delimiter VARCHAR(5) DEFAULT '@#', |
| |
| start_term_code_separator VARCHAR(5) DEFAULT '#', |
| |
| start_term_delimiter VARCHAR(5) DEFAULT '@', |
| |
| end_term_delimiter VARCHAR(5) DEFAULT ';', |
| |
| |
| attribute_delimiter VARCHAR(5) DEFAULT ',', |
| |
| |
| is_active BOOLEAN DEFAULT TRUE, |
| |
| CONSTRAINT chk_bulletproof_lexer_boundaries CHECK ( |
| |
| state_delimiter <> state_start_delimiter |
| AND state_delimiter <> state_end_delimiter |
| |
| |
| AND state_start_delimiter <> start_term_delimiter |
| AND variable_start_token <> state_start_delimiter |
| AND start_term_code_delimiter <> start_term_delimiter |
| AND start_term_display_delimiter <> start_term_delimiter |
| AND start_term_code_delimiter <> start_term_display_delimiter |
| |
| |
| AND variable_start_token <> state_start_delimiter |
| AND variable_end_token <> state_end_delimiter |
| |
| |
| AND comment_start_token <> macro_start_token |
| ) |
| ); |
| |
| |
| |
| CREATE TABLE |
| parser_stop_words ( |
| stop_word_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| |
| word_token VARCHAR(100) NOT NULL, |
| |
| jurisdiction_id INTEGER REFERENCES jurisdictions(jurisdiction_id) ON DELETE CASCADE, |
| facility_id INTEGER REFERENCES facilities(facility_id) ON DELETE CASCADE, |
| specialty_id INTEGER REFERENCES specialties(specialty_id) ON DELETE CASCADE, |
| personnel_id INTEGER REFERENCES personnel(personnel_id) ON DELETE CASCADE, |
| is_active BOOLEAN DEFAULT TRUE, |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW(), |
| |
| CONSTRAINT uq_stop_word_context UNIQUE ( |
| word_token, jurisdiction_id, facility_id, |
| specialty_id, personnel_id |
| ) |
| ); |
| |
| CREATE INDEX |
| idx_stop_words_session_load ON parser_stop_words ( |
| personnel_id, specialty_id, facility_id, |
| jurisdiction_id |
| ) |
| WHERE |
| is_active = TRUE; |
| |
| |
| |
| CREATE TYPE organism_domain AS ENUM ('human', 'animal', 'plant'); CREATE TYPE agent_lifecycle_status AS ENUM ( |
| 'active', 'deceased', 'inactive_archived' |
| ); CREATE TYPE gender_classification AS ENUM ( |
| 'male', 'female', 'undetermined', |
| 'not_applicable' |
| ); CREATE TYPE date_precision_tier AS ENUM ( |
| 'exact_timestamp', 'day', 'month', |
| 'year', 'estimated_epoch' |
| ); CREATE TYPE ledger_mutation_operation AS ENUM ( |
| 'add', 'update', 'remove', 'merge', |
| 'branch', 'archive' |
| ); CREATE TYPE clinical_doc_section AS ENUM ( |
| 'initial_context', 'subjective', |
| 'objective', 'assessment', 'plan', |
| 'other' |
| ); CREATE TYPE clinical_workflow_stage AS ENUM ( |
| 'history_taking', 'observation_gathering', |
| 'measurement_recording', 'assessment_reasoning', |
| 'plan_formulation', 'intervention_ordering', |
| 'disposition_planning', 'other' |
| ); |
| CREATE TABLE |
| registry_agents ( |
| agent_id VARCHAR(2048) PRIMARY KEY, |
| initial_state_id VARCHAR(2048) DEFAULT NULL, |
| organism_type organism_domain NOT NULL, |
| status agent_lifecycle_status NOT NULL DEFAULT 'active', |
| registration_timestamp TIMESTAMP |
| WITH |
| TIME ZONE NOT NULL DEFAULT NOW(), |
| created_at TIMESTAMP |
| WITH |
| TIME ZONE DEFAULT NOW() |
| ); |
| CREATE INDEX |
| idx_agents_cohort_lookup ON registry_agents (organism_type, status); |
| CREATE TABLE |
| agent_demographics ( |
| agent_id VARCHAR(2048) PRIMARY KEY REFERENCES registry_agents(agent_id) ON DELETE CASCADE, |
| administrative_gender gender_classification NOT NULL DEFAULT 'undetermined', |
| origination_date TIMESTAMP |
| WITH |
| TIME ZONE NOT NULL, |
| origination_precision date_precision_tier NOT NULL DEFAULT 'exact_timestamp', |
| is_origination_date_estimated BOOLEAN NOT NULL DEFAULT FALSE, |
| legal_name_json JSONB NOT NULL, |
| organism_attributes JSONB NOT NULL, |
| organism_type organism_domain NOT NULL, |
| FOREIGN KEY (agent_id, organism_type) REFERENCES registry_agents(agent_id, organism_type) ON DELETE CASCADE, |
| CONSTRAINT chk_strict_organism_payloads CHECK ( |
| ( |
| organism_type = 'plant' |
| AND organism_attributes ? 'taxonomy' |
| AND organism_attributes ? 'propagation_method' |
| ) |
| OR ( |
| organism_type IN ('human', 'animal') |
| AND administrative_gender IS NOT NULL |
| ) |
| ) |
| ); |
| |
| |
| |
| CREATE TABLE |
| medical_event_ledger ( |
| state_id VARCHAR(2048) PRIMARY KEY, |
| previous_state_id VARCHAR(2048) REFERENCES medical_event_ledger(state_id), |
| mutation_parent_ids VARCHAR(2048) [] DEFAULT '{}', |
| |
| operation ledger_mutation_operation NOT NULL, |
| |
| state_context TEXT, |
| state_timestamp_utc TIMESTAMP |
| WITH |
| TIME ZONE NOT NULL DEFAULT NOW(), |
| agent_id VARCHAR(2048) NOT NULL REFERENCES registry_agents(agent_id), |
| personnel_id INTEGER REFERENCES personnel(personnel_id), |
| facility_id INTEGER REFERENCES facilities(facility_id), |
| clinical_document_location clinical_doc_section NOT NULL DEFAULT 'other', |
| clinical_workflow_phase clinical_workflow_stage NOT NULL DEFAULT 'other', |
| state_metadata_session_variables JSONB DEFAULT NULL, |
| merge_resolution JSONB DEFAULT NULL, |
| static_context JSONB DEFAULT NULL, |
| temporal_context JSONB DEFAULT NULL, |
| |
| assessment JSONB DEFAULT NULL, |
| vitals_measurement JSONB DEFAULT NULL, |
| observation JSONB DEFAULT NULL, |
| exposure_profile JSONB DEFAULT NULL, |
| device_diagnostic_report JSONB DEFAULT NULL, |
| clinical_evaluation_report JSONB DEFAULT NULL, |
| procedure_order JSONB DEFAULT NULL, |
| medication_order JSONB DEFAULT NULL, |
| insurance_cost_evaluation JSONB DEFAULT NULL, |
| clinical_location_followup JSONB DEFAULT NULL, |
| patient_refusal JSONB DEFAULT NULL, |
| |
| |
| |
| |
| CONSTRAINT chk_merge_data_integrity CHECK ( |
| ( |
| operation = 'merge' |
| AND merge_resolution IS NOT NULL |
| ) |
| OR ( |
| operation <> 'merge' |
| AND merge_resolution IS NULL |
| ) |
| ), |
| |
| CONSTRAINT chk_update_requires_previous CHECK ( |
| ( |
| operation = 'update' |
| AND previous_state_id IS NOT NULL |
| AND array_length(mutation_parent_ids, 1) > 0 |
| ) |
| OR (operation <> 'update') |
| ), |
| |
| CONSTRAINT chk_remove_requires_previous_and_null_context CHECK ( |
| ( |
| operation = 'remove' |
| AND previous_state_id IS NOT NULL |
| AND array_length(mutation_parent_ids, 1) > 0 |
| ) |
| OR (operation <> 'remove') |
| ) |
| ); |
| CREATE INDEX |
| idx_ledger_agent_timeline ON medical_event_ledger ( |
| agent_id, state_timestamp_utc DESC |
| ); |
| ALTER TABLE |
| registry_agents |
| ADD |
| CONSTRAINT fk_initial_state_ledger FOREIGN KEY (initial_state_id) REFERENCES medical_event_ledger(state_id); |
|
|