Initial commit
This commit is contained in:
1
alembic/README
Normal file
1
alembic/README
Normal file
@@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
||||
93
alembic/env.py
Normal file
93
alembic/env.py
Normal file
@@ -0,0 +1,93 @@
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
# Import our models for autogenerate support
|
||||
from pipeline_mco_pmsi.database.base import Base
|
||||
from pipeline_mco_pmsi.database.models import (
|
||||
AuditRecordDB,
|
||||
ClinicalDocumentDB,
|
||||
ClinicalFactDB,
|
||||
CodeDB,
|
||||
EvidenceDB,
|
||||
GroupageResultDB,
|
||||
QuestionDB,
|
||||
ReferentielVersionDB,
|
||||
StayDB,
|
||||
TIMCorrectionDB,
|
||||
ValidationIssueDB,
|
||||
VerificationResultDB,
|
||||
)
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
target_metadata = Base.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(
|
||||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection, target_metadata=target_metadata
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
26
alembic/script.py.mako
Normal file
26
alembic/script.py.mako
Normal file
@@ -0,0 +1,26 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
${downgrades if downgrades else "pass"}
|
||||
380
alembic/versions/8ea1f9d0a13b_initial_schema_with_all_tables.py
Normal file
380
alembic/versions/8ea1f9d0a13b_initial_schema_with_all_tables.py
Normal file
@@ -0,0 +1,380 @@
|
||||
"""Initial schema with all tables
|
||||
|
||||
Revision ID: 8ea1f9d0a13b
|
||||
Revises:
|
||||
Create Date: 2026-02-10 16:47:05.255764
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '8ea1f9d0a13b'
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('referentiel_versions',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('type', sa.String(length=20), nullable=False),
|
||||
sa.Column('version', sa.String(length=50), nullable=False),
|
||||
sa.Column('import_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('file_hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('chunk_count', sa.Integer(), nullable=False),
|
||||
sa.Column('index_hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('active', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('file_hash'),
|
||||
sa.UniqueConstraint('type', 'version', name='uq_referentiel_type_version')
|
||||
)
|
||||
op.create_index('idx_referentiel_active', 'referentiel_versions', ['active'], unique=False)
|
||||
op.create_index('idx_referentiel_type', 'referentiel_versions', ['type'], unique=False)
|
||||
op.create_index('idx_referentiel_version', 'referentiel_versions', ['version'], unique=False)
|
||||
op.create_index(op.f('ix_referentiel_versions_active'), 'referentiel_versions', ['active'], unique=False)
|
||||
op.create_index(op.f('ix_referentiel_versions_type'), 'referentiel_versions', ['type'], unique=False)
|
||||
op.create_index(op.f('ix_referentiel_versions_version'), 'referentiel_versions', ['version'], unique=False)
|
||||
op.create_table('stays',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('stay_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('admission_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('discharge_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('specialty', sa.String(length=100), nullable=False),
|
||||
sa.Column('unit', sa.String(length=100), nullable=True),
|
||||
sa.Column('age', sa.Integer(), nullable=True),
|
||||
sa.Column('sex', sa.String(length=1), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_stays_admission_date', 'stays', ['admission_date'], unique=False)
|
||||
op.create_index('idx_stays_specialty', 'stays', ['specialty'], unique=False)
|
||||
op.create_index(op.f('ix_stays_specialty'), 'stays', ['specialty'], unique=False)
|
||||
op.create_index(op.f('ix_stays_stay_id'), 'stays', ['stay_id'], unique=True)
|
||||
op.create_table('audit_records',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('record_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('timestamp', sa.DateTime(), nullable=False),
|
||||
sa.Column('event_type', sa.String(length=50), nullable=False),
|
||||
sa.Column('actor', sa.String(length=100), nullable=False),
|
||||
sa.Column('data', sa.JSON(), nullable=False),
|
||||
sa.Column('model_name', sa.String(length=100), nullable=False),
|
||||
sa.Column('model_digest', sa.String(length=64), nullable=False),
|
||||
sa.Column('prompt_version', sa.String(length=50), nullable=False),
|
||||
sa.Column('prompt_hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('rules_version', sa.String(length=50), nullable=False),
|
||||
sa.Column('rules_hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('groupage_version', sa.String(length=50), nullable=True),
|
||||
sa.Column('referentiels_versions', sa.JSON(), nullable=False),
|
||||
sa.Column('inference_params', sa.JSON(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_audit_actor', 'audit_records', ['actor'], unique=False)
|
||||
op.create_index('idx_audit_event_type', 'audit_records', ['event_type'], unique=False)
|
||||
op.create_index('idx_audit_stay_id', 'audit_records', ['stay_id'], unique=False)
|
||||
op.create_index('idx_audit_timestamp', 'audit_records', ['timestamp'], unique=False)
|
||||
op.create_index(op.f('ix_audit_records_actor'), 'audit_records', ['actor'], unique=False)
|
||||
op.create_index(op.f('ix_audit_records_event_type'), 'audit_records', ['event_type'], unique=False)
|
||||
op.create_index(op.f('ix_audit_records_record_id'), 'audit_records', ['record_id'], unique=True)
|
||||
op.create_index(op.f('ix_audit_records_stay_id'), 'audit_records', ['stay_id'], unique=False)
|
||||
op.create_index(op.f('ix_audit_records_timestamp'), 'audit_records', ['timestamp'], unique=False)
|
||||
op.create_table('clinical_documents',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('document_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('document_type', sa.String(length=50), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('creation_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('author', sa.String(length=200), nullable=True),
|
||||
sa.Column('priority', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_documents_stay_id', 'clinical_documents', ['stay_id'], unique=False)
|
||||
op.create_index('idx_documents_type', 'clinical_documents', ['document_type'], unique=False)
|
||||
op.create_index(op.f('ix_clinical_documents_document_id'), 'clinical_documents', ['document_id'], unique=True)
|
||||
op.create_index(op.f('ix_clinical_documents_document_type'), 'clinical_documents', ['document_type'], unique=False)
|
||||
op.create_index(op.f('ix_clinical_documents_stay_id'), 'clinical_documents', ['stay_id'], unique=False)
|
||||
op.create_table('clinical_facts',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('fact_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('type', sa.String(length=50), nullable=False),
|
||||
sa.Column('text', sa.Text(), nullable=False),
|
||||
sa.Column('qualifier_certainty', sa.String(length=20), nullable=False),
|
||||
sa.Column('qualifier_markers', sa.JSON(), nullable=False),
|
||||
sa.Column('qualifier_confidence', sa.Float(), nullable=False),
|
||||
sa.Column('temporality', sa.String(length=20), nullable=False),
|
||||
sa.Column('confidence', sa.Float(), nullable=False),
|
||||
sa.Column('evidence_document_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('evidence_span_start', sa.Integer(), nullable=False),
|
||||
sa.Column('evidence_span_end', sa.Integer(), nullable=False),
|
||||
sa.Column('evidence_text', sa.Text(), nullable=False),
|
||||
sa.Column('evidence_context', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_facts_certainty', 'clinical_facts', ['qualifier_certainty'], unique=False)
|
||||
op.create_index('idx_facts_stay_id', 'clinical_facts', ['stay_id'], unique=False)
|
||||
op.create_index('idx_facts_temporality', 'clinical_facts', ['temporality'], unique=False)
|
||||
op.create_index('idx_facts_type', 'clinical_facts', ['type'], unique=False)
|
||||
op.create_index(op.f('ix_clinical_facts_fact_id'), 'clinical_facts', ['fact_id'], unique=True)
|
||||
op.create_index(op.f('ix_clinical_facts_qualifier_certainty'), 'clinical_facts', ['qualifier_certainty'], unique=False)
|
||||
op.create_index(op.f('ix_clinical_facts_stay_id'), 'clinical_facts', ['stay_id'], unique=False)
|
||||
op.create_index(op.f('ix_clinical_facts_temporality'), 'clinical_facts', ['temporality'], unique=False)
|
||||
op.create_index(op.f('ix_clinical_facts_type'), 'clinical_facts', ['type'], unique=False)
|
||||
op.create_table('codes',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('code', sa.String(length=50), nullable=False),
|
||||
sa.Column('label', sa.String(length=500), nullable=False),
|
||||
sa.Column('type', sa.String(length=10), nullable=False),
|
||||
sa.Column('confidence', sa.Float(), nullable=False),
|
||||
sa.Column('reasoning', sa.Text(), nullable=False),
|
||||
sa.Column('referentiel_version', sa.String(length=50), nullable=False),
|
||||
sa.Column('status', sa.String(length=20), nullable=False),
|
||||
sa.Column('model_name', sa.String(length=100), nullable=False),
|
||||
sa.Column('model_digest', sa.String(length=64), nullable=False),
|
||||
sa.Column('prompt_version', sa.String(length=50), nullable=False),
|
||||
sa.Column('ccam_realization_date', sa.DateTime(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_codes_code', 'codes', ['code'], unique=False)
|
||||
op.create_index('idx_codes_referentiel_version', 'codes', ['referentiel_version'], unique=False)
|
||||
op.create_index('idx_codes_status', 'codes', ['status'], unique=False)
|
||||
op.create_index('idx_codes_stay_id', 'codes', ['stay_id'], unique=False)
|
||||
op.create_index('idx_codes_type', 'codes', ['type'], unique=False)
|
||||
op.create_index(op.f('ix_codes_code'), 'codes', ['code'], unique=False)
|
||||
op.create_index(op.f('ix_codes_referentiel_version'), 'codes', ['referentiel_version'], unique=False)
|
||||
op.create_index(op.f('ix_codes_status'), 'codes', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_codes_stay_id'), 'codes', ['stay_id'], unique=False)
|
||||
op.create_index(op.f('ix_codes_type'), 'codes', ['type'], unique=False)
|
||||
op.create_table('groupage_results',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('ghm', sa.String(length=20), nullable=True),
|
||||
sa.Column('ghs', sa.String(length=20), nullable=True),
|
||||
sa.Column('groupage_errors', sa.JSON(), nullable=False),
|
||||
sa.Column('ccam_date_errors', sa.JSON(), nullable=False),
|
||||
sa.Column('groupage_version', sa.String(length=50), nullable=False),
|
||||
sa.Column('groupage_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_groupage_ghm', 'groupage_results', ['ghm'], unique=False)
|
||||
op.create_index('idx_groupage_stay_id', 'groupage_results', ['stay_id'], unique=False)
|
||||
op.create_index('idx_groupage_version', 'groupage_results', ['groupage_version'], unique=False)
|
||||
op.create_index(op.f('ix_groupage_results_ghm'), 'groupage_results', ['ghm'], unique=False)
|
||||
op.create_index(op.f('ix_groupage_results_ghs'), 'groupage_results', ['ghs'], unique=False)
|
||||
op.create_index(op.f('ix_groupage_results_groupage_version'), 'groupage_results', ['groupage_version'], unique=False)
|
||||
op.create_index(op.f('ix_groupage_results_stay_id'), 'groupage_results', ['stay_id'], unique=False)
|
||||
op.create_table('questions',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('question_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('text', sa.Text(), nullable=False),
|
||||
sa.Column('priority', sa.Integer(), nullable=False),
|
||||
sa.Column('category', sa.String(length=50), nullable=False),
|
||||
sa.Column('context', sa.Text(), nullable=False),
|
||||
sa.Column('suggested_answers', sa.JSON(), nullable=False),
|
||||
sa.Column('answered', sa.Boolean(), nullable=False),
|
||||
sa.Column('answer', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_questions_answered', 'questions', ['answered'], unique=False)
|
||||
op.create_index('idx_questions_priority', 'questions', ['priority'], unique=False)
|
||||
op.create_index('idx_questions_stay_id', 'questions', ['stay_id'], unique=False)
|
||||
op.create_index(op.f('ix_questions_answered'), 'questions', ['answered'], unique=False)
|
||||
op.create_index(op.f('ix_questions_category'), 'questions', ['category'], unique=False)
|
||||
op.create_index(op.f('ix_questions_priority'), 'questions', ['priority'], unique=False)
|
||||
op.create_index(op.f('ix_questions_question_id'), 'questions', ['question_id'], unique=True)
|
||||
op.create_index(op.f('ix_questions_stay_id'), 'questions', ['stay_id'], unique=False)
|
||||
op.create_table('validation_issues',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('issue_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('severity', sa.String(length=20), nullable=False),
|
||||
sa.Column('category', sa.String(length=50), nullable=False),
|
||||
sa.Column('message', sa.Text(), nullable=False),
|
||||
sa.Column('affected_codes', sa.JSON(), nullable=False),
|
||||
sa.Column('suggested_action', sa.Text(), nullable=False),
|
||||
sa.Column('resolved', sa.Boolean(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_issues_category', 'validation_issues', ['category'], unique=False)
|
||||
op.create_index('idx_issues_resolved', 'validation_issues', ['resolved'], unique=False)
|
||||
op.create_index('idx_issues_severity', 'validation_issues', ['severity'], unique=False)
|
||||
op.create_index('idx_issues_stay_id', 'validation_issues', ['stay_id'], unique=False)
|
||||
op.create_index(op.f('ix_validation_issues_category'), 'validation_issues', ['category'], unique=False)
|
||||
op.create_index(op.f('ix_validation_issues_issue_id'), 'validation_issues', ['issue_id'], unique=True)
|
||||
op.create_index(op.f('ix_validation_issues_resolved'), 'validation_issues', ['resolved'], unique=False)
|
||||
op.create_index(op.f('ix_validation_issues_severity'), 'validation_issues', ['severity'], unique=False)
|
||||
op.create_index(op.f('ix_validation_issues_stay_id'), 'validation_issues', ['stay_id'], unique=False)
|
||||
op.create_table('verification_results',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('stay_id', sa.Integer(), nullable=False),
|
||||
sa.Column('decision', sa.String(length=20), nullable=False),
|
||||
sa.Column('dim_errors', sa.JSON(), nullable=False),
|
||||
sa.Column('contradictions', sa.JSON(), nullable=False),
|
||||
sa.Column('alternatives', sa.JSON(), nullable=False),
|
||||
sa.Column('reasoning', sa.Text(), nullable=False),
|
||||
sa.Column('model_name', sa.String(length=100), nullable=False),
|
||||
sa.Column('model_digest', sa.String(length=64), nullable=False),
|
||||
sa.Column('prompt_version', sa.String(length=50), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['stay_id'], ['stays.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_verification_decision', 'verification_results', ['decision'], unique=False)
|
||||
op.create_index('idx_verification_stay_id', 'verification_results', ['stay_id'], unique=False)
|
||||
op.create_index(op.f('ix_verification_results_decision'), 'verification_results', ['decision'], unique=False)
|
||||
op.create_index(op.f('ix_verification_results_stay_id'), 'verification_results', ['stay_id'], unique=False)
|
||||
op.create_table('evidences',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('code_id', sa.Integer(), nullable=False),
|
||||
sa.Column('document_id', sa.Integer(), nullable=False),
|
||||
sa.Column('span_start', sa.Integer(), nullable=False),
|
||||
sa.Column('span_end', sa.Integer(), nullable=False),
|
||||
sa.Column('text', sa.Text(), nullable=False),
|
||||
sa.Column('context', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['code_id'], ['codes.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['document_id'], ['clinical_documents.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_evidences_code_id', 'evidences', ['code_id'], unique=False)
|
||||
op.create_index(op.f('ix_evidences_code_id'), 'evidences', ['code_id'], unique=False)
|
||||
op.create_table('tim_corrections',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('original_code_id', sa.Integer(), nullable=False),
|
||||
sa.Column('corrected_code', sa.String(length=50), nullable=False),
|
||||
sa.Column('corrected_label', sa.String(length=500), nullable=False),
|
||||
sa.Column('corrected_type', sa.String(length=10), nullable=False),
|
||||
sa.Column('user_id', sa.String(length=100), nullable=False),
|
||||
sa.Column('comment', sa.Text(), nullable=True),
|
||||
sa.Column('timestamp', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['original_code_id'], ['codes.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_corrections_original_code_id', 'tim_corrections', ['original_code_id'], unique=False)
|
||||
op.create_index('idx_corrections_timestamp', 'tim_corrections', ['timestamp'], unique=False)
|
||||
op.create_index('idx_corrections_user_id', 'tim_corrections', ['user_id'], unique=False)
|
||||
op.create_index(op.f('ix_tim_corrections_original_code_id'), 'tim_corrections', ['original_code_id'], unique=False)
|
||||
op.create_index(op.f('ix_tim_corrections_timestamp'), 'tim_corrections', ['timestamp'], unique=False)
|
||||
op.create_index(op.f('ix_tim_corrections_user_id'), 'tim_corrections', ['user_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_tim_corrections_user_id'), table_name='tim_corrections')
|
||||
op.drop_index(op.f('ix_tim_corrections_timestamp'), table_name='tim_corrections')
|
||||
op.drop_index(op.f('ix_tim_corrections_original_code_id'), table_name='tim_corrections')
|
||||
op.drop_index('idx_corrections_user_id', table_name='tim_corrections')
|
||||
op.drop_index('idx_corrections_timestamp', table_name='tim_corrections')
|
||||
op.drop_index('idx_corrections_original_code_id', table_name='tim_corrections')
|
||||
op.drop_table('tim_corrections')
|
||||
op.drop_index(op.f('ix_evidences_code_id'), table_name='evidences')
|
||||
op.drop_index('idx_evidences_code_id', table_name='evidences')
|
||||
op.drop_table('evidences')
|
||||
op.drop_index(op.f('ix_verification_results_stay_id'), table_name='verification_results')
|
||||
op.drop_index(op.f('ix_verification_results_decision'), table_name='verification_results')
|
||||
op.drop_index('idx_verification_stay_id', table_name='verification_results')
|
||||
op.drop_index('idx_verification_decision', table_name='verification_results')
|
||||
op.drop_table('verification_results')
|
||||
op.drop_index(op.f('ix_validation_issues_stay_id'), table_name='validation_issues')
|
||||
op.drop_index(op.f('ix_validation_issues_severity'), table_name='validation_issues')
|
||||
op.drop_index(op.f('ix_validation_issues_resolved'), table_name='validation_issues')
|
||||
op.drop_index(op.f('ix_validation_issues_issue_id'), table_name='validation_issues')
|
||||
op.drop_index(op.f('ix_validation_issues_category'), table_name='validation_issues')
|
||||
op.drop_index('idx_issues_stay_id', table_name='validation_issues')
|
||||
op.drop_index('idx_issues_severity', table_name='validation_issues')
|
||||
op.drop_index('idx_issues_resolved', table_name='validation_issues')
|
||||
op.drop_index('idx_issues_category', table_name='validation_issues')
|
||||
op.drop_table('validation_issues')
|
||||
op.drop_index(op.f('ix_questions_stay_id'), table_name='questions')
|
||||
op.drop_index(op.f('ix_questions_question_id'), table_name='questions')
|
||||
op.drop_index(op.f('ix_questions_priority'), table_name='questions')
|
||||
op.drop_index(op.f('ix_questions_category'), table_name='questions')
|
||||
op.drop_index(op.f('ix_questions_answered'), table_name='questions')
|
||||
op.drop_index('idx_questions_stay_id', table_name='questions')
|
||||
op.drop_index('idx_questions_priority', table_name='questions')
|
||||
op.drop_index('idx_questions_answered', table_name='questions')
|
||||
op.drop_table('questions')
|
||||
op.drop_index(op.f('ix_groupage_results_stay_id'), table_name='groupage_results')
|
||||
op.drop_index(op.f('ix_groupage_results_groupage_version'), table_name='groupage_results')
|
||||
op.drop_index(op.f('ix_groupage_results_ghs'), table_name='groupage_results')
|
||||
op.drop_index(op.f('ix_groupage_results_ghm'), table_name='groupage_results')
|
||||
op.drop_index('idx_groupage_version', table_name='groupage_results')
|
||||
op.drop_index('idx_groupage_stay_id', table_name='groupage_results')
|
||||
op.drop_index('idx_groupage_ghm', table_name='groupage_results')
|
||||
op.drop_table('groupage_results')
|
||||
op.drop_index(op.f('ix_codes_type'), table_name='codes')
|
||||
op.drop_index(op.f('ix_codes_stay_id'), table_name='codes')
|
||||
op.drop_index(op.f('ix_codes_status'), table_name='codes')
|
||||
op.drop_index(op.f('ix_codes_referentiel_version'), table_name='codes')
|
||||
op.drop_index(op.f('ix_codes_code'), table_name='codes')
|
||||
op.drop_index('idx_codes_type', table_name='codes')
|
||||
op.drop_index('idx_codes_stay_id', table_name='codes')
|
||||
op.drop_index('idx_codes_status', table_name='codes')
|
||||
op.drop_index('idx_codes_referentiel_version', table_name='codes')
|
||||
op.drop_index('idx_codes_code', table_name='codes')
|
||||
op.drop_table('codes')
|
||||
op.drop_index(op.f('ix_clinical_facts_type'), table_name='clinical_facts')
|
||||
op.drop_index(op.f('ix_clinical_facts_temporality'), table_name='clinical_facts')
|
||||
op.drop_index(op.f('ix_clinical_facts_stay_id'), table_name='clinical_facts')
|
||||
op.drop_index(op.f('ix_clinical_facts_qualifier_certainty'), table_name='clinical_facts')
|
||||
op.drop_index(op.f('ix_clinical_facts_fact_id'), table_name='clinical_facts')
|
||||
op.drop_index('idx_facts_type', table_name='clinical_facts')
|
||||
op.drop_index('idx_facts_temporality', table_name='clinical_facts')
|
||||
op.drop_index('idx_facts_stay_id', table_name='clinical_facts')
|
||||
op.drop_index('idx_facts_certainty', table_name='clinical_facts')
|
||||
op.drop_table('clinical_facts')
|
||||
op.drop_index(op.f('ix_clinical_documents_stay_id'), table_name='clinical_documents')
|
||||
op.drop_index(op.f('ix_clinical_documents_document_type'), table_name='clinical_documents')
|
||||
op.drop_index(op.f('ix_clinical_documents_document_id'), table_name='clinical_documents')
|
||||
op.drop_index('idx_documents_type', table_name='clinical_documents')
|
||||
op.drop_index('idx_documents_stay_id', table_name='clinical_documents')
|
||||
op.drop_table('clinical_documents')
|
||||
op.drop_index(op.f('ix_audit_records_timestamp'), table_name='audit_records')
|
||||
op.drop_index(op.f('ix_audit_records_stay_id'), table_name='audit_records')
|
||||
op.drop_index(op.f('ix_audit_records_record_id'), table_name='audit_records')
|
||||
op.drop_index(op.f('ix_audit_records_event_type'), table_name='audit_records')
|
||||
op.drop_index(op.f('ix_audit_records_actor'), table_name='audit_records')
|
||||
op.drop_index('idx_audit_timestamp', table_name='audit_records')
|
||||
op.drop_index('idx_audit_stay_id', table_name='audit_records')
|
||||
op.drop_index('idx_audit_event_type', table_name='audit_records')
|
||||
op.drop_index('idx_audit_actor', table_name='audit_records')
|
||||
op.drop_table('audit_records')
|
||||
op.drop_index(op.f('ix_stays_stay_id'), table_name='stays')
|
||||
op.drop_index(op.f('ix_stays_specialty'), table_name='stays')
|
||||
op.drop_index('idx_stays_specialty', table_name='stays')
|
||||
op.drop_index('idx_stays_admission_date', table_name='stays')
|
||||
op.drop_table('stays')
|
||||
op.drop_index(op.f('ix_referentiel_versions_version'), table_name='referentiel_versions')
|
||||
op.drop_index(op.f('ix_referentiel_versions_type'), table_name='referentiel_versions')
|
||||
op.drop_index(op.f('ix_referentiel_versions_active'), table_name='referentiel_versions')
|
||||
op.drop_index('idx_referentiel_version', table_name='referentiel_versions')
|
||||
op.drop_index('idx_referentiel_type', table_name='referentiel_versions')
|
||||
op.drop_index('idx_referentiel_active', table_name='referentiel_versions')
|
||||
op.drop_table('referentiel_versions')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user