emtellipro_db package

Submodules

emtellipro_db.exc module

This module contains exceptions raised within the emtellipro_db module

exception emtellipro_db.exc.EmtelliproDBException

Bases: Exception

Base exception which is subclassed by more specific exceptions

exception emtellipro_db.exc.MissingFullTextSupport

Bases: emtellipro_db.exc.EmtelliproDBException

Raised when SQL Server is missing full-text support

emtellipro_db.models module

This module contains all the ORM models, implemented using SQLAlchemy.

The attributes of each object are documented as being either ‘column’ or ‘dynamic’; ‘column’ means they’re actual columns in the database table, and ‘dynamic’ means they’re only convenience attributes created by the ORM to handle relationships.

Note that the actual data types used when creating tables depends on the SQL dialect used (i.e. which database it’s connected to). To check the exact data types, one can refer to SQLAlchemy’s documentation, or inspect the schema of the tables that were created using this tool.

NOTE: back-references may not always be documented.

class emtellipro_db.models.AssumedEntity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing assumed entities.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

document

instance of Document

Type

dynamic

document_id

uuid foreign key pointing to document.id

Type

column

id

uuid primary key

Type

column

value

unicode string of max length 255

Type

column

class emtellipro_db.models.Concept(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing information about a specific column, with the primary keys being the concept_id and ontology.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

concept_id

unicode string of max length 255, part of primary key

Type

column

description

unicode text

Type

column

documents

list of Document objects containing this concept

Type

dynamic

found_entities

list of FoundEntity objects containing this concept

Type

dynamic

ontology

unicode string of max length 255, part of primary key

Type

column

class emtellipro_db.models.Document(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing details specific the the overall document that was processed.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

category

unicode string of max length 255

Type

column

concepts

list of Concept objects found in this document

Type

dynamic

entities

list of Entity objects found in this document

Type

dynamic

filename

unicode text field

Type

column

id

uuid primary key

Type

column

json_representation

unicode text field, containing the JSON returned by the server for this document

Type

column

locations

list of Location objects found in this document

Type

dynamic

processing_details

instance of ProcessingDetails which is associated with this document

Type

dynamic

processing_details_id

uuid foreign key pointing to processingdetails.id

Type

column

processing_status

unicode string of max length 255

Type

column

relations

list of Relation objects found in this document

Type

dynamic

section_label

unicode text field

Type

column

subcategory

unicode string of max length 255

Type

column

text

unicode text field, containing the document text or NULL if it was not saved

Type

column

class emtellipro_db.models.DocumentConcept(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking documents to concepts.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

concept_id

unicode string of max length 255, foreign key pointing to concept.concept_id, part of primary key

Type

column

concept_ontology

unicode string of max length 255, foreign key pointing to concept.ontology, part of primary key

Type

column

document_id

uuid foreign key pointing to document.id, part of primary key.

Type

column

class emtellipro_db.models.DocumentMetadata(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing arbitrary metadata for each document.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

author_name

author name

Type

column

chartdate

chart date

Type

column

description

description

Type

column

document

instance of Document

Type

dynamic

document_id

uuid foreign key pointing to document.id

Type

column

hadm_id

hadm ID

Type

column

id

uuid primary key

Type

column

institution

institution

Type

column

original_category

unicode string of max length 255

Type

column

original_subcategory

unicode string of max length 255

Type

column

static parse_dates(metadata, parse_dates=False)

Optionally parse dates in the metadata.

Parameters
  • metadata (dict) – a metadata dictionary

  • parse_dates (bool) – whether to actually parse the dates in the metadata dict. Parsing dates is only relevant for certain database types.

requestor

requestor

Type

column

source_document_id

the primary key of the document in the source database

Type

column

subject_dob

date of birth of subject

Type

column

subject_gender

subject gender

Type

column

subject_id

subject ID

Type

column

subject_name

subject name

Type

column

class emtellipro_db.models.DocumentStructuredMetadata(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing arbitrary metadata for each document.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

document

instance of Document

Type

dynamic

document_id

uuid foreign key pointing to document.id

Type

column

id

uuid primary key

Type

column

key

unicode text field

Type

column

value

unicode text field

Type

column

class emtellipro_db.models.Entity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table of entities stored in a specific document. The entity information is stored in different tables depending on entity type. The type_` column can be used along with the ``entity_id to determine which exact entity is referred to.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

document_id

uuid foreign key pointing to document.id

Type

column

entity_id

uuid reffering to the id column of one of the *Entity tables.

Type

column

id

uuid primary key

Type

column

type_

unicode string of max length 255, describing the type of the entity.

Type

column

class emtellipro_db.models.ExperiencerRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing experience relation information.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

experienced

Entity instance

Type

dynamic

experienced_id

uuid foreign key pointing to entity.id

Type

column

experiencer

Entity instance

Type

dynamic

experiencer_id

uuid foreign key pointing to entity.id

Type

column

id

uuid primary key

Type

column

polarity

unicode string of max lenght 255

Type

column

class emtellipro_db.models.FollowupRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containign follow-up relation information.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

uuid primary key

Type

column

polarity

unicode string of max length 255

Type

column

procedures

Entity instance

Type

dynamic

reasons

Entity instance

Type

dynamic

time_expression

Entity instance

Type

dynamic

time_expression_id

uuid foreign key pointing to entity.id

Type

column

class emtellipro_db.models.FollowupRelationProcedure(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking followup relations to entities specified as procedures.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

uuid foreign key pointing to entity.id, part of primary key

Type

column

followup_id

uuid foreign key pointing to followuprelation.id, part of primary key

Type

column

class emtellipro_db.models.FollowupRelationReason(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking followup relations to entities specified as reasons.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

uuid foreign key pointing to entity.id, part of primary key

Type

column

followup_id

uuid foreign key pointing to followuprelation.id, part of primary key

Type

column

class emtellipro_db.models.FoundEntity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing found entities.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

concepts

list of Concept instances associated with this entity

Type

dynamic

document

instance of Document

Type

dynamic

document_id

uuid foreign key pointing to document.id

Type

column

guidance

unicode text field

Type

column

id

uuid primary key

Type

column

known_ambiguity

unicode text field

Type

column

locations

list of Location objects associated with this entity

Type

dynamic

measurement_units

list of FoundEntityMeasurementUnit objects assocated with this entity

Type

dynamic

polarity

unicode string of max length 255

Type

column

question_status

unicode text field

Type

column

section_name

unicode text field

Type

column

spans

list of FoundEntitySpan objects associated with this entity

Type

dynamic

type_names

list of FoundEntityType objects associated with this entity

Type

dynamic

uncertainty

unicode string of max length 255

Type

column

class emtellipro_db.models.FoundEntityConcept(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking found entities to concepts.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

concept_id

unicode string of max length 255, foreign key pointing to concept.concept_id, part of primary key

Type

column

concept_ontology

unicode string of max length 255, foreign key pointing to concept.ontology, part of primary key

Type

column

found_entity_id

uuid foreign key pointing to foundentity.id, part of primary key

Type

column

class emtellipro_db.models.FoundEntityLocation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking found entities to locations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

found_entity_id

uuid foreign key pointing to foundentity.id, part of primary key

Type

column

location_id

uuid foreign key pointing to location.id, part of primary key

Type

column

class emtellipro_db.models.FoundEntityMeasurementUnit(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing the measurement units for a found entity

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

found_entity_id

uuid foreign key pointing to foundentity.id

Type

column

id

uuid primary key

Type

column

text

unicode string of max length 255

Type

column

class emtellipro_db.models.FoundEntitySpan(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containging spans contained in found entities.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

end

integer end position

Type

column

found_entity_id

uuid foreign key pointing to foundentity.id

Type

column

id

uuid primary key

Type

column

start

integer start position

Type

column

text

unicode text contained in this span

Type

column

class emtellipro_db.models.FoundEntityType(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing the type_name information from found entities.

Note that all 3 columns form the primary key since there is a unique type name per ontology per found entity.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

found_entity_id

uuid foreign key pointing to foundentity.id

Type

column

ontology

unicode string of max length 255

Type

column

type_name

unicode string of max length 255

Type

column

class emtellipro_db.models.GUID(*args, **kwargs)

Bases: sqlalchemy.sql.type_api.TypeDecorator

Platform-independent GUID type.

Uses PostgreSQL’s UUID type, otherwise uses CHAR(36), storing as stringified hex values.

impl

alias of sqlalchemy.sql.sqltypes.Integer

load_dialect_impl(dialect)

Return the data type implementation based on the dialect used.

This means UUID for postgresql, UNIQUEIDENTIFIER for MSSQL, and CHAR(36) everywhere else.

class emtellipro_db.models.ImageLinkRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing image link relation information.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

uuid primary key

Type

column

image_findings

list of Entity objects which were the image findings

Type

dynamic

references

list of Entity objects which were the image references

Type

dynamic

class emtellipro_db.models.ImageLinkRelationImageFinding(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking image link relations to entities specified as image findings.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

uuid foreign key pointing to entity.id, part of primary key

Type

column

uuid foreign key pointing to imagelinkrelation.id, part of primary key

Type

column

class emtellipro_db.models.ImageLinkRelationReference(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking image link relations to entities specified as references.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

uuid foreign key pointing to entity.id, part of primary key

Type

column

uuid foreign key pointing to imagelinkrelation.id, part of primary key

Type

column

class emtellipro_db.models.Location(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing links to all the different kinds of locations. Use the type_ and location_id fields to find the actual location in one of the other *Location tables.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

document_id

uuid foreign key pointing to document.id

Type

column

id

uuid primary key

Type

column

location_id

uuid referring to the id column of another *Location table

Type

column

type_

unicode string of max length 255, containing the type of location

Type

column

class emtellipro_db.models.MeasurementRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing measurement relations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

uuid primary key

Type

column

subject

Entity instance

Type

dynamic

subject_id

uuid foreign key pointing to entity.id

Type

column

value

Entity instance

Type

dynamic

value_id

uuid foreign key pointing to entity.id

Type

column

class emtellipro_db.models.MedicationRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing medication relations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

date_times

list of Entity objects which are datetimes

Type

dynamic

dosages

list of Entity objects which were dosages

Type

dynamic

drug

Entity instance

Type

dynamic

drug_entity_id

uuid foreign key pointing to entity.id

Type

column

durations

list of Entity objects which were durations

Type

dynamic

frequencies

list of Entity objects which were frequencies

Type

dynamic

id

uuid primary key

Type

column

indications

list of Entity objects which were indications

Type

dynamic

modes

list of Entity objects which were modes

Type

dynamic

modifiers

list of Entity objects which were modifier

Type

dynamic

necessities

list of Entity objects which were necessities

Type

dynamic

quantities

list of Entity objects which were quantities

Type

dynamic

routes

list of Entity objects which were routes

Type

dynamic

class emtellipro_db.models.MedicationRelationDatetime(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as datetimes.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

GUID() foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationDosage(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as dosage

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

uuid foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationDuration(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as duration

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationFrequency(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as frequency

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationIndication(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as indication

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationMode(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as mode

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationModifier(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as route

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationNecessity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as route

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationQuantity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as quantity

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.MedicationRelationRoute(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking medication relations to entities specified as route

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

GUID() foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

medication_id

uuid foreign key pointing to medicationrelation.id, part of primary key

Type

column

class emtellipro_db.models.OntologyVersion(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table of ontology versions for each document.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

document

instance of Document

Type

dynamic

document_id

uuid foreign key pointing to document.id

Type

column

ontology

unicode string of max length 255, part of primary key

Type

column

release_version

unicode string of max length 255

Type

column

class emtellipro_db.models.ProcessingDetails(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing details about the job submitted for processing.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

engine_version

the engine version, if provided

Type

column

id

uuid primary key

Type

column

job_id

a user-provided (or generated) string ID for the overall processing job. This is different than the task ID which is generated by the server and which is per-shard. Max length is 255.

Type

column

sdk_version

the SDK version

Type

column

submit_timestamp

a datetime field

Type

column

task_id

unicode string of max length 255, generated by the server

Type

column

class emtellipro_db.models.QualifierRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing qualifier relations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

uuid primary key

Type

column

qualifier

Entity instance

Type

dynamic

qualifier_id

uuid foreign key pointing to entity.id

Type

column

qualifier_type

unicode string of max length 255

Type

column

qualifies

Entity instance

Type

dynamic

qualifies_id

uuid foreign key pointing to entity.id

Type

column

class emtellipro_db.models.Relation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing links to all the different kinds of relations. Use the type_ and relation_id fields to find the actual relation in one of the other *Relation tables.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

document_id

uuid foreign key pointing to document.id

Type

column

id

uuid primary key

Type

column

relation_id

uuid referring to the id column of another *Relation table

Type

column

type_

unicode string of max length 255, containing the type of the relation

Type

column

class emtellipro_db.models.ReportedEventRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing reported event relations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

category

unicode string of max length 255

Type

column

from_entities

list of Entity objects

Type

dynamic

id

uuid/integer primary key

Type

column

methods

list of Entity objects

Type

dynamic

polarity

unicode string of max length 255

Type

column

subject

Entity instance

Type

dynamic

subject_id

foreign key poinging to entity.id

Type

column

time_expressions

list of Entity objects

Type

dynamic

to_entities

list of Entity objects

Type

dynamic

class emtellipro_db.models.ReportedEventRelationFromEntity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking reported-event relations to entities which were sources of the communication.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

foreign key pointing to entity.id, part of primary key

Type

column

reported_event_id

foreign key pointing to reportedeventrelation.id, part of primary key

Type

column

class emtellipro_db.models.ReportedEventRelationMethod(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking reported-event relations to entities which were the methods of communication

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

foreign key pointing to entity.id, part of primary key

Type

column

reported_event_id

foreign key pointing to reportedeventrelation.id, part of primary key

Type

column

class emtellipro_db.models.ReportedEventRelationTimeExpression(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking reported-event relations to entities which were the time expressions that indicate when the communication took place

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

foreign key pointing to entity.id, part of primary key

Type

column

reported_event_id

foreign key pointing to reportedeventrelation.id, part of primary key

Type

column

class emtellipro_db.models.ReportedEventRelationToEntity(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking reported-event relations to entities which were recipients of the communication.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

foreign key pointing to entity.id, part of primary key

Type

column

reported_event_id

foreign key pointing to reportedeventrelation.id, part of primary key

Type

column

class emtellipro_db.models.SectionLocation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containg section locations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

children

list of SectionLocation objects

Type

dynamic

id

uuid primary key

Type

column

level

integer

Type

column

name

unicode string of max length 255

Type

column

parent_id

uuid foreign key pointing to this table

Type

column

spans

list of SectionLocationSpan objects

Type

dynamic

text

entire text of the section

Type

column

class emtellipro_db.models.SectionLocationSpan(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing sentence location span information.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

end

integer end position

Type

column

id

uuid primary key

Type

column

section_location_id

uuid foreign key pointing to sectionlocation.id

Type

column

start

integer start position

Type

column

class emtellipro_db.models.SentenceLocation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing sentence locations. It exists mainly as a link between the locations table and the spans.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

id

uuid primary key

Type

column

spans

list of SentenceLocationSpan objects

Type

dynamic

text

entire text of the sentence

Type

column

class emtellipro_db.models.SentenceLocationSpan(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing sentence location spans

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

end

integer end position

Type

column

id

uuid primary key

Type

column

sentence_location_id

uuid foreign key pointing to sentencelocation.id

Type

column

start

integer start position

Type

column

class emtellipro_db.models.SentenceSection(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing links between sentences and section, with a composite primary key of sentence_id and section_id.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

section

SectionLocation instance

Type

dynamic

section_id

uuid foreign key pointing to sectionlocation.id, part of primary key

Type

column

sentence

SentenceLocation instance

Type

dynamic

sentence_id

uuid foreign key pointing to sentencelocation.id, part of primary key.

Type

column

class emtellipro_db.models.TemporalityRelation(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Table containing temporality relations.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

category

unicode string of max length 255

Type

column

id

uuid primary key

Type

column

modifiers

list of Entity objects which were modifiers

Type

dynamic

polarity

unicode string of max length 255

Type

column

subject

Entity instance

Type

dynamic

subject_id

foreign key pointing to entity.id

Type

column

temporal_entity

Entity instance

Type

dynamic

temporal_entity_id

foreign key pointing to entity.id

Type

column

class emtellipro_db.models.TemporalityRelationModifier(**kwargs)

Bases: sqlalchemy.orm.decl_api.Base

Association table linking temporality relations to entities specified as modifiers

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

entity_id

foreign key pointing to entity.id, part of primary key

Type

column

id

uuid primary key

Type

column

temporality_id

foreign key pointing to temporalityrelation.id, part of primary key

Type

column

class emtellipro_db.models.UnicodeLongText(*args, **kwargs)

Bases: sqlalchemy.sql.type_api.TypeDecorator

This is a semi-custom type which is used to allow compiling UnicodeText as LONGTEXT on MySQL. It’ll compile using the default dialect implementations for other databases.

impl

alias of sqlalchemy.sql.sqltypes.UnicodeText

class emtellipro_db.models.XUnicode(*args, **kwargs)

Bases: sqlalchemy.sql.type_api.TypeDecorator

A custom Unicode type which is identical to SQLAlchemy’s Unicode type, except it skips processing the result from the driver.

Snowflake’s Python db connector supports unicode natively, but doesn’t define the Unicode type.

impl

alias of sqlalchemy.sql.sqltypes.Unicode

result_processor(dialect, coltype)

Provide a result value processing function for the given Dialect.

This is the method that fulfills the TypeEngine contract for bound value conversion which normally occurs via the _types.TypeEngine.result_processor() method.

Note

User-defined subclasses of _types.TypeDecorator should not implement this method, and should instead implement _types.TypeDecorator.process_result_value() so that the “inner” processing provided by the implementing type is maintained.

Parameters
  • dialect – Dialect instance in use.

  • coltype – A SQLAlchemy data type

class emtellipro_db.models.XUnicodeText(*args, **kwargs)

Bases: sqlalchemy.sql.type_api.TypeDecorator

A custom UnicodeText type which is identical to SQLAlchemy’s UnicodeText type, except it skips processing the result from the driver.

Snowflake’s Python db connector supports unicode natively, but doesn’t define the Unicode type.

impl

alias of sqlalchemy.sql.sqltypes.UnicodeText

result_processor(dialect, coltype)

Provide a result value processing function for the given Dialect.

This is the method that fulfills the TypeEngine contract for bound value conversion which normally occurs via the _types.TypeEngine.result_processor() method.

Note

User-defined subclasses of _types.TypeDecorator should not implement this method, and should instead implement _types.TypeDecorator.process_result_value() so that the “inner” processing provided by the implementing type is maintained.

Parameters
  • dialect – Dialect instance in use.

  • coltype – A SQLAlchemy data type

emtellipro_db.models.recreate_indexes(connection)

Re-create all the indexes.

This is normally executed by the migrate and create-db commands

Parameters

connection – this is an SQLAlchemy connection object

Returns

number of indexes created

emtellipro_db.rowtypes module

This module contains enums that define the values of the type_ columns in the tables that have them.

class emtellipro_db.rowtypes.EntityRowType(value)

Bases: enum.Enum

Enumeration of valid values for the type_ column in the entity table.

class emtellipro_db.rowtypes.LocationRowType(value)

Bases: enum.Enum

Enumeration of valid values for the type_ column in the location table.

class emtellipro_db.rowtypes.RelationRowType(value)

Bases: enum.Enum

Enumeration of valid values for the type_ column in the relation table.

emtellipro_db.save module

This module contains code for saving all models to a database.

emtellipro_db.save.exec_insert(conn, cls, values, fill_in_defaults=False)

Execute INSERT statements for the given table, using the provided values.

Parameters
  • conn – SQLAlchemy Connection object

  • cls – The Model class representing the table to insert into

  • values (list) – list of dictionaries containing the values to be inserted; these must all have the same set of keys, unless fill_in_defaults is enabled.

  • fill_in_defaults (bool) – if True, fill in None for missing keys in values. When inserting multiple values, they must all have the same set of keys to match the list of columns in the INSERT; if values come from variable JSON objects, this constraint may not hold, so you can use this parameter to add the missing keys with values of None.

emtellipro_db.save.exec_insert_default_returning_id(conn, cls)

For these tables, there are no columns other than the ID, so we have no values to insert.

emtellipro_db.save.save_doc(session, annotated_doc, filename, concepts_created, original_doc, job_id, job_timestamp, task_id, metadata, store_doc_text=False, store_json=False, store_sections_and_sentences=False, processing_details_rows=None, engine_version=None)

Saves an annotated document to a database.

emtellipro_db.save.save_multiple(docs, job_id, job_timestamp, task_id, engine, store_json, store_sections_and_sentences, engine_version, processing_details_id=None)

Save multiple documents at once

Parameters

docs – list of dictionaries with keys: {‘annotated_doc’, ‘metadata’, ‘filename’, ‘original_doc’}

emtellipro_db.save.save_relation_argument_association(connection, *, relations, relation_ids, entities, table, argument, rel_column)

This is a generic argument association saving method for the relations which have many-to-many relationships between the relation and arguments of the same type.

Module contents

This is a package for storing data returned by the Emtellipro API through the SDK to a database.

USAGE

For usage information, run

emtellipro-db-client –help