<filename>src/core/db/models/pdf_models.py
# coding: utf-8
from sqlalchemy import (
    BigInteger,
    Column,
    Date,
    DateTime,
    ForeignKey,
    Integer,
    JSON,
    String,
    Text,
    text,
)
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata


class DocumentType(Base):
    __tablename__ = "document_type"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    name = Column(String, nullable=False)


class Migration(Base):
    __tablename__ = "migrations"

    id = Column(Integer, primary_key=True)
    timestamp = Column(BigInteger, nullable=False)
    name = Column(String, nullable=False)


class ParsingStrategyType(Base):
    __tablename__ = "parsing_strategy_type"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    name = Column(String, nullable=False)
    created_at = Column(DateTime, nullable=False, server_default=text("now()"))
    updated_at = Column(DateTime, nullable=False, server_default=text("now()"))
    deleted_at = Column(DateTime)


class IngestionEvent(Base):
    __tablename__ = "ingestion_event"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    s3_bucket = Column(String, nullable=False)
    s3_key = Column(String, nullable=False)
    created_at = Column(DateTime, nullable=False, server_default=text("now()"))
    updated_at = Column(DateTime, nullable=False, server_default=text("now()"))
    parsing_strategy_type_id = Column(ForeignKey("parsing_strategy_type.id"))

    parsing_strategy_type = relationship("ParsingStrategyType")


class PdfConfigMappingActive(Base):
    __tablename__ = "pdf_config_mapping_active"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    mappingJson = Column(JSON, nullable=False)
    createdAt = Column(DateTime, nullable=False, server_default=text("now()"))
    updatedAt = Column(DateTime, nullable=False, server_default=text("now()"))
    documentTypeId = Column(ForeignKey("document_type.id"), nullable=False, unique=True)

    document_type = relationship("DocumentType", uselist=False)


class ApisDh(Base):
    __tablename__ = "apis_dhs"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    tecs_id_passenger = Column(String)
    name_passenger = Column(String)
    gender_passenger = Column(String)
    passenger_type_passenger = Column(String)
    citizenship_country_passenger = Column(String)
    embarkation_passenger = Column(String)
    debarkation_passenger = Column(String)
    first_arrival_passenger = Column(String)
    cbp_embarkation_passenger = Column(String)
    cbp_debarkation_passenger = Column(String)
    cbp_first_arrival_passenger = Column(String)
    record_locator_passenger = Column(String)
    tecs_id_travel = Column(String)
    vessel_name_travel = Column(String)
    vessel_type_travel = Column(String)
    vessel_identifier_travel = Column(String)
    vessel_registration_country_travel = Column(String)
    vessel_voyage_number_travel = Column(String)
    carrier_and_flight_number_travel = Column(String)
    origin_travel = Column(String)
    destination_travel = Column(String)
    site_code_travel = Column(String)
    flight_type_travel = Column(String)
    flight_estimated_departure_travel = Column(String)
    time_travel = Column(String)
    fight_estimated_arrival_time_travel = Column(String)
    document_type = Column(String)
    document_number = Column(String)
    document_issuance_country = Column(String)
    document_address_type = Column(String)
    document_address = Column(String)
    document_residence_country = Column(String)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))
    date_of_birth_passenger = Column(Date)
    flight_date_travel = Column(Date)
    document_expiration_date = Column(Date)
    document_issuance_date = Column(Date)

    ingestion_event = relationship("IngestionEvent")


class BankruptcyTransunion(Base):
    __tablename__ = "bankruptcy_transunion"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    namesreported = Column(String)
    ssn = Column(String)
    status = Column(String)
    qualifier = Column(String)
    address = Column(String)
    employer = Column(String)
    occupation = Column(String)
    date_on_file_since = Column(String)
    subscriber = Column(String)
    portfolio_type = Column(String)
    account_number = Column(String)
    ecoa_designator = Column(String)
    current_balance = Column(String)
    high_credit = Column(String)
    credit_limit = Column(String)
    account_rating = Column(String)
    terms = Column(String)
    account = Column(String)
    past_due = Column(String)
    most_recent_payment_date_update_method = Column(String)
    collection_industry_code = Column(String)
    collection_member_code = Column(String)
    collection_portfolio_type = Column(String)
    collection_account_number = Column(String)
    collection_ecoa_designator = Column(String)
    collection_account = Column(String)
    collection_date_opened = Column(String)
    collection_date_effective = Column(String)
    collection_date_closed = Column(String)
    collection_closed_indicator = Column(String)
    collection_current_balance = Column(String)
    collection_creditor_classification = Column(String)
    collection_balance = Column(String)
    collection_high_credit = Column(String)
    collection_account_rating = Column(String)
    collection_remark = Column(String)
    collection_type = Column(String)
    collection_past_due = Column(String)
    collection_code = Column(String)
    collection_update_method = Column(String)
    avderseinfo_subscriber_industry_code = Column(String)
    avderseinfo_subscriber_member_code = Column(String)
    avderseinfo_docket_number = Column(String)
    avderseinfo_attorney = Column(String)
    avderseinfo_date_filed = Column(String)
    avderseinfo_date_paid = Column(String)
    avderseinfo_ecoa_designator = Column(String)
    avderseinfo_source_type = Column(String)
    account_review_inq_ecoa_designator = Column(String)
    account_review_inq_industry_code = Column(String)
    account_review_inq_member_code = Column(String)
    account_review_inq_subscriber_prefix_code = Column(String)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))
    date_reported = Column(Date)
    date_hired = Column(Date)
    effective_date = Column(Date)
    date_opened = Column(Date)
    date_effective = Column(Date)
    most_recent_payment_date = Column(Date)
    collection_date = Column(Date)

    ingestion_event = relationship("IngestionEvent")


class BciDh(Base):
    __tablename__ = "bci_dhs"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    tecs_id = Column(String)
    name = Column(String)
    gender = Column(String)
    citizenship_country = Column(String)
    location_code = Column(String)
    mode_of_transportation_code = Column(String)
    travel_direction_code = Column(String)
    secondary_examination_status = Column(String)
    terminal = Column(String)
    lane_number = Column(String)
    visa_admission_class_code = Column(String)
    rfid = Column(String)
    document_type_code = Column(String)
    document_number = Column(String)
    issuance_country_code = Column(String)
    carrier_and_route_number = Column(String)
    vessel_official_number = Column(String)
    arrival_port_code = Column(String)
    departure_port_code = Column(String)
    license_plate_number = Column(String)
    license_plate_state_code = Column(String)
    foreign_country_indicator_code = Column(String)
    api_onboard_status_code = Column(String)
    api_confirmation_status_code = Column(String)
    process_result_code = Column(String)
    package_result_code1 = Column(String)
    package_result_code2 = Column(String)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))
    date_of_birth = Column(Date)
    crossing_date_time = Column(DateTime)
    visa_admit_until_date = Column(Date)

    ingestion_event = relationship("IngestionEvent")


class CmirFincen(Base):
    __tablename__ = "cmir_fincen"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    type_of_report = Column(String)
    filing_date = Column(Date)
    received_date = Column(Date)
    entry_date = Column(Date)
    rcn = Column(String)
    submission_method = Column(String)
    person_involved_type = Column(String)
    ind_org = Column(String)
    last_name_entity_name = Column(String)
    first_name = Column(String)
    middle_initial = Column(String)
    date_of_birth = Column(Date)
    tin = Column(String)
    identification_type = Column(String)
    identification_number = Column(String)
    citizenship = Column(String)
    address_type = Column(String)
    street_address = Column(String)
    city = Column(String)
    state = Column(String)
    zip_code = Column(String)
    country = Column(String)
    city_departed = Column(String)
    country_departed = Column(String)
    city_arrived = Column(String)
    state_arrived = Column(String)
    country_arrived = Column(String)
    currency = Column(String)
    coin = Column(String)
    other_monetary_instruments_amount = Column(String)
    total_amount = Column(String)
    foreign_currency_total = Column(String)
    port_code = Column(String)
    cbp_date = Column(Date)
    count_verified = Column(String)
    voluntary_report = Column(String)
    airline_flight = Column(String)
    legal_name_of_financial_institution = Column(String)
    signature_date = Column(Date)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))

    ingestion_event = relationship("IngestionEvent")


class CmrFincen(Base):
    __tablename__ = "cmr_fincen"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    type_of_report = Column(String)
    rcn = Column(String)
    submission_method = Column(String)
    person_involved_type = Column(String)
    ind_org = Column(String)
    last_name_entity_name = Column(String)
    first_name = Column(String)
    middle_initial = Column(String)
    tin = Column(String)
    identification_type = Column(String)
    identification_number = Column(String)
    citizenship = Column(String)
    address_type = Column(String)
    street_address = Column(String)
    city = Column(String)
    state = Column(String)
    zip_code = Column(String)
    country = Column(String)
    city_departed = Column(String)
    country_departed = Column(String)
    city_arrived = Column(String)
    state_arrived = Column(String)
    country_arrived = Column(String)
    currency = Column(String)
    coin = Column(String)
    other_monetary_instruments_amount = Column(String)
    total_amount = Column(String)
    foreign_currency_total = Column(String)
    port_code = Column(String)
    count_verified = Column(String)
    voluntary_report = Column(String)
    airline_flight = Column(String)
    legal_name_of_financial_institution = Column(String)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))
    filing_date = Column(Date)
    received_date = Column(Date)
    entry_date = Column(Date)
    date_of_birth = Column(Date)
    cbp_date = Column(Date)
    signature_date = Column(Date)

    ingestion_event = relationship("IngestionEvent")


class CriminalLexisNexi(Base):
    __tablename__ = "criminal_lexis_nexis"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    name = Column(String)
    ssn = Column(String)
    gender = Column(String)
    dob = Column(String)
    deceased = Column(String)
    dod = Column(String)
    address = Column(String)
    name_aka = Column(String)
    is_current_name = Column(String)
    gender_aka = Column(String)
    ssn_aka = Column(String)
    ssn_valid_aka = Column(String)
    ssn_issued_loc_aka = Column(String)
    dob_aka = Column(String)
    is_correct_dob_aka = Column(String)
    dod_aka = Column(String)
    age_aka = Column(String)
    subj_ssn_ind_aka = Column(String)
    prop_data_source = Column(String)
    prop_source_record_id = Column(String)
    prop_record_type = Column(String)
    prop_record_type_desc = Column(String)
    deed_county = Column(String)
    deed_parcel_id = Column(String)
    deed_document_type_code = Column(String)
    deed_document_type_desc = Column(String)
    deed_property_use_code = Column(String)
    lien_judgment_tms_id = Column(String)
    lien_judgment_origin_filing_number = Column(String)
    lien_judgment_amount = Column(String)
    lien_judgment_filing_jurisdiction = Column(String)
    lien_judgment_filing_jurisdiction_name = Column(String)
    lien_judgment_multiple_defendant = Column(String)
    lien_judgment_eviction = Column(String)
    address_bpsr = Column(String)
    subject_name_bpsr = Column(String)
    location_id_bpsr = Column(String)
    bps_report_address_location_id = Column(String)
    bankrupt_corp_flag = Column(String)
    bankrupt_filing_type = Column(String)
    bankrupt_filer_type = Column(String)
    bankrupt_filing_jurisdiction = Column(String)
    bankrupt_case_type = Column(String)
    bankrupt_case_number = Column(String)
    bankrupt_chapter = Column(String)
    bankrupt_original_chapter = Column(String)
    bankrupt_court_name = Column(String)
    bankrupt_court_location = Column(String)
    bankrupt_judge_name = Column(String)
    bankrupt_judge_id = Column(String)
    bankrupt_claims_deadline = Column(String)
    bankrupt_complaint_deadline = Column(String)
    bankrupt_filing_status = Column(String)
    bankrupt_court_code = Column(String)
    bankrupt_disposition = Column(String)
    bankrupt_self_represented = Column(String)
    bankrupt_assets_for_unsecured = Column(String)
    bankrupt_time = Column(String)
    bankrupt_address = Column(String)
    criminal_offender_id = Column(String)
    criminal_case_number = Column(String)
    criminal_height = Column(String)
    criminal_weight = Column(String)
    criminal_race = Column(String)
    criminal_sex = Column(String)
    criminal_data_source = Column(String)
    criminal_ssn = Column(String)
    criminal_state_of_origin = Column(String)
    criminal_address = Column(String)
    criminal_name = Column(String)
    criminal_dob = Column(String)
    criminal_status = Column(String)
    criminal_case_type_desc = Column(String)
    flag_has_criminal_conviction = Column(String)
    is_sexual_offender = Column(String)
    has_concealed_weapon = Column(String)
    has_bankruptcy = Column(String)
    has_property = Column(String)
    has_corp_affiliation = Column(String)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))
    ssn_issued_start_date_aka = Column(Date)
    ssn_issued_end_date_aka = Column(Date)
    prop_assmnt_tape_cut_date = Column(Date)
    prop_assmnt_certification_date = Column(Date)
    prop_assmnt_recording_date = Column(Date)
    prop_assmnt_prior_recording_date = Column(Date)
    prop_assmnt_transfer_date = Column(Date)
    prop_assmnt_prior_transfer_date = Column(Date)
    prop_assmnt_sale_date = Column(Date)
    deed_contract_date = Column(Date)
    deed_recording_date = Column(Date)
    deed_arm_reset_date = Column(Date)
    lien_judgment_origin_filing_date = Column(Date)
    lien_judgment_judge_satisfied_date = Column(Date)
    lien_judgment_suit_date = Column(Date)
    lien_judgment_judge_vacated_date = Column(Date)
    lien_judgment_release_date = Column(Date)
    date_last_seen_bpsr1 = Column(Date)
    date_first_seen_bpsr1 = Column(Date)
    date_last_seen_bpsr2 = Column(Date)
    date_first_seen_bpsr2 = Column(Date)
    bankrupt_filing_date = Column(Date)
    bankrupt_original_filing_date = Column(Date)
    bankrupt_closed_date = Column(Date)
    bankrupt_reopen_date = Column(Date)
    bankrupt_converted_date = Column(Date)
    bankrupt_discharge_date = Column(Date)
    bankrupt_date = Column(Date)
    criminal_case_filing_date = Column(Date)

    ingestion_event = relationship("IngestionEvent")


class Fincen8300Rev4(Base):
    __tablename__ = "fincen8300_rev4"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    amends_prior_report = Column(String)
    suspicious_transaction = Column(String)
    multiple_individuals = Column(String)
    last_name = Column(String)
    first_name = Column(String)
    middle_initial = Column(String)
    tin = Column(String)
    address = Column(String)
    city = Column(String)
    state = Column(String)
    zip = Column(String)
    country = Column(String)
    occ_prof_bus = Column(String)
    identdoc_describe = Column(String)
    identdoc_issued_by = Column(String)
    identdoc_number = Column(String)
    multiple_behalf = Column(String)
    last_name_org_name_behalf = Column(String)
    first_name_behalf = Column(String)
    middle_initial_behalf = Column(String)
    tin_behalf = Column(String)
    dba_behalf = Column(String)
    address_behalf = Column(String)
    occ_prof_bus_behalf = Column(String)
    city_behalf = Column(String)
    state_behalf = Column(String)
    zip_behalf = Column(String)
    country_behalf = Column(String)
    identdoc_describe_behalf = Column(String)
    identdoc_issued_by_behalf = Column(String)
    identdoc_number_behalf = Column(String)
    total_cash_received = Column(String)
    cash_received_mult_pmts = Column(String)
    total_price = Column(String)
    usde_us_currency = Column(String)
    usde_amt_benj_higher = Column(String)
    usde_foreign_currency = Column(String)
    foreign_currency_country = Column(String)
    usde_cashiers_checks = Column(String)
    usde_money_orders = Column(String)
    usde_bank_drafts = Column(String)
    usde_travelers_checks = Column(String)
    type_ot_personal_prop = Column(String)
    type_ot_real_property = Column(String)
    type_ot_personal_services = Column(String)
    type_ot_business_services = Column(String)
    type_ot_intangible_property = Column(String)
    type_ot_debt_obligations_paid = Column(String)
    type_ot_exchange_of_cash = Column(String)
    type_ot_escrow_or_trust_funds = Column(String)
    type_ot_bail_received = Column(String)
    type_ot_other = Column(String)
    specific_description_of_property = Column(String)
    business_name_brc = Column(String)
    ein_brc = Column(String)
    address_brc = Column(String)
    city_brc = Column(String)
    state_brc = Column(String)
    zip_code_brc = Column(String)
    nature_of_business_brc = Column(String)
    signature_footer = Column(String)
    title_footer = Column(String)
    contact_name_printed_brc = Column(String)
    contact_phone_brc = Column(String)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))
    dob = Column(Date)
    date_cash_received = Column(Date)
    date_of_signature_footer = Column(Date)

    ingestion_event = relationship("IngestionEvent")


class UnstructuredDocument(Base):
    __tablename__ = "unstructured_document"

    id = Column(UUID, primary_key=True, server_default=text("uuid_generate_v4()"))
    name = Column(JSON)
    ssn = Column(JSON)
    dateOfBirth = Column(JSON)
    zipCode = Column(JSON)
    text = Column(Text)
    ingestion_event_id = Column(ForeignKey("ingestion_event.id"))

    ingestion_event = relationship("IngestionEvent")
