# coding: utf-8
from sqlalchemy import Column, DECIMAL, Date, DateTime, Index, String, text, LargeBinary
from sqlalchemy.dialects.mysql import BIT, CHAR, INTEGER, TINYINT, VARCHAR

from db import Base


class BdYljg(Base):
    __tablename__ = 'bd_yljg'

    pk_yljg = Column(INTEGER(11), primary_key=True, comment='医疗机构主键')
    code = Column(String(12), nullable=False, unique=True, comment='编码')
    name = Column(String(200), comment='名称')
    cpym = Column(String(40), comment='拼音码')
    pk_yldj = Column(INTEGER(11), comment='医疗机构等级')
    pk_father = Column(INTEGER(11), comment='上级医疗机构')
    address = Column(String(300), comment='地址')
    pk_region = Column(INTEGER(11), comment='行政区划主键')
    depiction = Column(String(100), comment='备注')
    creator = Column(String(20), comment='创建人')
    creationtime = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    modifier = Column(String(20), comment='最后修改人')
    modifiedtime = Column(DateTime, comment='最后修改时间')
    enablestate = Column(TINYINT(4), server_default=text("'1'"), comment='启用状态')
    create_by = Column(String(100), comment='创建人')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    update_by = Column(String(100), comment='更新人')
    update_time = Column(DateTime, comment='更新时间')
    del_flag = Column(TINYINT(1), server_default=text("'0'"), comment='删除标记')


class BdYlks(Base):
    __tablename__ = 'bd_ylks'

    pk_ylks = Column(INTEGER(11), primary_key=True, comment='科室主键')
    code = Column(String(12), nullable=False, index=True, comment='编码')
    name = Column(String(200), comment='名称')
    cpym = Column(String(40), comment='拼音码')
    pk_father = Column(INTEGER(11))
    cIsBottom = Column(CHAR(1), comment='是否底层')
    depiction = Column(String(100), comment='备注')
    creator = Column(String(20), comment='创建人')
    creationtime = Column(DateTime, comment='创建时间')
    modifier = Column(String(20), comment='最后修改人')
    modifiedtime = Column(DateTime, comment='最后修改时间')
    enablestate = Column(TINYINT(4), server_default=text("'1'"), comment='启用状态')
    create_by = Column(String(100), comment='创建人')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    update_by = Column(String(100), comment='更新人')
    update_time = Column(DateTime, comment='更新时间')
    del_flag = Column(TINYINT(1), server_default=text("'0'"), comment='删除标记')


class ZxIeCost(Base):
    __tablename__ = 'zx_ie_cost'

    pk_ie_cost = Column(INTEGER(11), primary_key=True, comment='费用明细信息抽取主键')
    pk_phhd = Column(INTEGER(11), nullable=False, unique=True, comment='报销案子主键')
    name = Column(String(30), comment='患者姓名')
    admission_date_str = Column(String(255), comment='入院日期字符串')
    admission_date = Column(Date, comment='入院日期')
    discharge_date_str = Column(String(255), comment='出院日期字符串')
    discharge_date = Column(Date, comment='出院日期')
    medical_expenses_str = Column(String(255), comment='费用总额字符串')
    medical_expenses = Column(DECIMAL(18, 2), comment='费用总额')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    creator = Column(String(255), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
                         comment='修改时间')
    updater = Column(String(255), comment='修改人')


class ZxIeCostDetail(Base):
    __tablename__ = 'zx_ie_cost_detail'

    pk_ie_cost_detail = Column(INTEGER(11), primary_key=True, comment='费用明细详情主键')
    pk_ie_cost = Column(INTEGER(11), nullable=False, comment='费用明细信息抽取主键')
    pk_phhd = Column(INTEGER(11), nullable=False, comment='报销案子主键')
    _class = Column('class', String(255), comment='类别')
    name = Column(String(255), comment='名称')
    specification = Column(String(255), comment='规格')
    price = Column(DECIMAL(18, 2), comment='单价')
    quantity = Column(INTEGER(11), comment='数量')
    amount = Column(DECIMAL(18, 2), comment='金额(单价 * 数量)')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    creator = Column(String(30), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
                         comment='修改时间')
    updater = Column(String(30), comment='修改人')


class ZxIeDischarge(Base):
    __tablename__ = 'zx_ie_discharge'

    pk_ie_discharge = Column(INTEGER(11), primary_key=True, comment='出院记录信息抽取主键')
    pk_phhd = Column(INTEGER(11), nullable=False, unique=True, comment='报销案子主键')
    content = Column(String(5000), comment='详细内容')
    hospital = Column(String(255), comment='医院')
    pk_yljg = Column(INTEGER(11), comment='医院主键')
    department = Column(String(255), comment='科室')
    pk_ylks = Column(INTEGER(11), comment='科室主键')
    name = Column(String(30), comment='患者姓名')
    age = Column(INTEGER(3), comment='年龄')
    admission_date_str = Column(String(255), comment='入院日期字符串')
    admission_date = Column(Date, comment='入院日期')
    discharge_date_str = Column(String(255), comment='出院日期字符串')
    discharge_date = Column(Date, comment='出院日期')
    doctor = Column(String(30), comment='主治医生')
    admission_id = Column(String(50), comment='住院号')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    creator = Column(String(255), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
                         comment='修改时间')
    updater = Column(String(255), comment='修改人')


class ZxIeResult(Base):
    __tablename__ = 'zx_ie_result'

    pk_ocr = Column(INTEGER(11), primary_key=True, comment='图片OCR识别主键')
    pk_phhd = Column(INTEGER(11), nullable=False, comment='报销单主键')
    pk_phrec = Column(INTEGER(11), nullable=False, comment='图片主键')
    id = Column(INTEGER(11), nullable=False, comment='识别批次')
    cfjaddress = Column(String(200), nullable=False, comment='云存储文件名')
    content = Column(String(5000), comment='OCR识别内容')
    rotation_angle = Column(INTEGER(11), comment='旋转角度')
    x_offset = Column(INTEGER(11), comment='x轴偏移量')
    y_offset = Column(INTEGER(11), comment='y轴偏移量')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    creator = Column(String(30), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
                         comment='修改时间')
    updater = Column(String(30), comment='修改人')


class ZxIeSettlement(Base):
    __tablename__ = 'zx_ie_settlement'

    pk_ie_settlement = Column(INTEGER(11), primary_key=True, comment='结算清单信息抽取主键')
    pk_phhd = Column(INTEGER(11), nullable=False, unique=True, comment='报销案子主键')
    name = Column(String(30), comment='患者姓名')
    admission_date_str = Column(String(255), comment='入院日期字符串')
    admission_date = Column(Date, comment='入院日期')
    discharge_date_str = Column(String(255), comment='出院日期字符串')
    discharge_date = Column(Date, comment='出院日期')
    medical_expenses_str = Column(String(255), comment='费用总额字符串')
    medical_expenses = Column(DECIMAL(18, 2), comment='费用总额')
    personal_cash_payment_str = Column(String(255), comment='个人现金支付字符串')
    personal_cash_payment = Column(DECIMAL(18, 2), comment='个人现金支付')
    personal_account_payment_str = Column(String(255), comment='个人账户支付字符串')
    personal_account_payment = Column(DECIMAL(18, 2), comment='个人账户支付')
    personal_funded_amount_str = Column(String(255), comment='自费金额字符串')
    personal_funded_amount = Column(DECIMAL(18, 2), comment='自费金额')
    medical_insurance_type_str = Column(String(255), comment='医保类型字符串')
    medical_insurance_type = Column(String(40), comment='医保类型')
    admission_id = Column(String(50), comment='住院号')
    settlement_id = Column(String(50), comment='医保结算单号码')
    create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    creator = Column(String(255), comment='创建人')
    update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
                         comment='修改时间')
    updater = Column(String(255), comment='修改人')


class ZxPhhd(Base):
    __tablename__ = 'zx_phhd'
    __table_args__ = (
        Index('zx_phhd_idx3', 'pk_yljg', 'cjsd_id'),
    )

    pk_phhd = Column(INTEGER(11), primary_key=True, comment='病案主键')
    cPhhd_id = Column(VARCHAR(20), index=True, comment='拍一拍单据号')
    billdate = Column(DateTime)
    pk_person = Column(INTEGER(11), server_default=text("'0'"), comment='人员主键')
    pk_corp = Column(INTEGER(11), index=True, server_default=text("'0'"), comment='单位主键')
    cRyid = Column(VARCHAR(20), comment='人员编码')
    cJBH = Column(VARCHAR(20), comment='结报号')
    cXm = Column(String(12), comment='姓名')
    cSfzh = Column(VARCHAR(20), index=True, comment='身份证号')
    czh = Column(VARCHAR(20), comment='小组')
    cXb = Column(VARCHAR(2), comment='性别')
    dCsny = Column(Date, comment='出身时间')
    fAge = Column(INTEGER(4), server_default=text("'0'"), comment='年龄')
    pk_yljg = Column(INTEGER(11), server_default=text("'0'"), comment='医院pk')
    pk_ylks = Column(INTEGER(11), server_default=text("'0'"), comment='科室pk')
    cDoctor = Column(VARCHAR(20), comment='医生')
    dZYRQ = Column(DateTime, comment='入院日期')
    dCYRQ = Column(DateTime)
    cZYH = Column(VARCHAR(20), comment='住院号')
    iMZTS = Column(INTEGER(4), server_default=text("'0'"), comment='住院天数')
    fFSYLFY = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='发生医疗费用')
    fZcfwfy = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='政策范围内费用')
    fxnhbcje = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='新农合补助金额')
    fqtbcje = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='其它补助金额')
    fBCJE = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='补偿金额')
    fgrzfje1 = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='个人支付金额1')
    fgezfje2 = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='个人支付金额2')
    fgrzfje = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='个人自费金额')
    fZfje = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='自付金额')
    fXianje = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='限额')
    fMaxbcje = Column(DECIMAL(18, 2), server_default=text("'0.00'"), comment='最高支付')
    cJBBM = Column(VARCHAR(20), server_default=text("'-'"), comment='疾病编码')
    cJbbm_cyzd = Column(VARCHAR(20), comment='疾病编码出院诊断')
    cSsczmc = Column(VARCHAR(100), comment='手术操作名称')
    problem_note = Column(String(400))
    depiction = Column(VARCHAR(300), comment='备注')
    creator = Column(VARCHAR(30), comment='创建人')
    creationtime = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    modifier = Column(VARCHAR(30), comment='最后修改人')
    modifiedtime = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='最后修改时间')
    cStatus = Column(CHAR(1), index=True, server_default=text("'0'"), comment='状态')
    vercode = Column(VARCHAR(4), comment='版本编码')
    drg_groups_id = Column(String(6), server_default=text("'2017'"), comment='drg分组器版本号')
    cSource_flag = Column(VARCHAR(4), server_default=text("'1'"), comment='病案来源')
    ref_id1 = Column(VARCHAR(20))
    ref_id2 = Column(VARCHAR(20))
    ref_pk1 = Column(INTEGER(11))
    checker = Column(VARCHAR(30), comment='创建人')
    checktime = Column(DateTime, comment='创建时间')
    paint_flag = Column(CHAR(1), index=True, server_default=text("'0'"))
    paint_user = Column(VARCHAR(30))
    paint_date = Column(DateTime)
    filetype_id = Column(VARCHAR(10), comment='文件类型id')
    cMphone = Column(VARCHAR(11), comment='移动电话')
    cmiss_rectype = Column(VARCHAR(10), comment='遗漏记录类型')
    cmiss_remark = Column(VARCHAR(200), comment='遗漏备注 ')
    bhg_remark = Column(VARCHAR(200), comment='不合格原因')
    cmis_jsd_flag = Column(BIT(1))
    cmis_jsd_page = Column(VARCHAR(40), comment='结算单遗漏页码')
    cmis_cyjl_flag = Column(BIT(1))
    cmis_cyjl_page = Column(VARCHAR(40), comment='出院记录遗漏页码')
    cmis_fyqd_flag = Column(BIT(1))
    cmis_fyqd_page = Column(VARCHAR(40), comment='费用清单遗漏页码')
    cmis_evidence = Column(VARCHAR(60), comment='相关证明材料')
    del_reason = Column(CHAR(1), server_default=text("'0'"), comment='删除原因')
    deln_reason = Column(VARCHAR(2), comment='删除原因')
    train_flag = Column(VARCHAR(10), server_default=text("'0'"), comment='培训标志')
    cjsd_id = Column(VARCHAR(30), comment='结算单号码')
    sms_content = Column(String(1000), comment='短信内容')
    judge_backup = Column(VARCHAR(100))
    remind_num = Column(INTEGER(11), server_default=text("'0'"), comment='提醒次数')
    input_cxm = Column(String(20), comment='姓名核对')
    yb_type = Column(VARCHAR(10), comment='医保类别')
    bucode = Column(VARCHAR(4), server_default=text("'1'"), comment='业务单元')
    subcorpname = Column(VARCHAR(80), comment='子公司')
    deptname = Column(VARCHAR(80), comment='部门')
    psncode = Column(VARCHAR(16), comment='工号')
    period_code = Column(VARCHAR(10), comment='会计期间')
    cbznote = Column(VARCHAR(500))
    corp_list = Column(VARCHAR(200), comment='其它补助单位及年度')
    perjudge_flag = Column(CHAR(1), server_default=text("'0'"), comment='人员信息判断标志')
    priority_num = Column(TINYINT(4), server_default=text("'0'"), comment='优先领取')
    addin_xybz = Column(BIT(1))
    addin_tybz = Column(BIT(1))
    finish_flag = Column(BIT(1))
    exsuccess_flag = Column(CHAR(1), index=True, server_default=text("'0'"), comment='交换成功标志')
    pk_soncorp = Column(INTEGER(11), server_default=text("'0'"), comment='镇下村单位pk值')
    return_times = Column(INTEGER(11), server_default=text("'0'"), comment='退回次数')
    phuser_type = Column(CHAR(1), server_default=text("'1'"), comment='拍传人类型')
    examine_note = Column(VARCHAR(400), comment='抽查意见')
    examine_user = Column(VARCHAR(30), comment='抽查人')
    examine_date = Column(DateTime, comment='抽查时间')
    channel_code = Column(VARCHAR(10), comment='上传渠道')
    einvoice_flag = Column(BIT(1))
    drgs_flag = Column(CHAR(1), server_default=text("'0'"), comment='病种类型(0-无,1-单病种,2-drg)')
    applyDate = Column(DateTime)
    admissionDate = Column(Date, comment='入院日期')
    dischargeDate = Column(Date, comment='出院日期')
    reapplyDate = Column(Date, comment='重新上传日期')
    exreq_times = Column(INTEGER(11), index=True, server_default=text("'0'"), comment='请求次数')
    drug_source = Column(CHAR(1), server_default=text("'0'"), comment='药品来源(1-外购药,0--没有）')
    addin_passpaydate = Column(BIT(1))
    apply_classid = Column(CHAR(1), server_default=text("'0'"), comment='申请人员类别(1-农民工,0-默认)')


class ZxPhrec(Base):
    __tablename__ = 'zx_phrec'

    pk_phrec = Column(INTEGER(11), primary_key=True, comment='病案清主键')
    pk_phhd = Column(INTEGER(11), index=True, comment='病案主键')
    cRectype = Column(CHAR(1), comment='记录类型（1-入院小结，2--出院小结，3--手术记录 4清单）')
    rowno = Column(TINYINT(4), server_default=text("'1'"), comment='序号')
    cfjaddress = Column(String(200), comment='附件地址')
    cfjaddress2 = Column(String(500), comment='附件地址2')
    cfjaddress3 = Column(String(500), comment='附件地址3')
    cfjblob = Column(LargeBinary, comment='附件')
    cfjblob2 = Column(LargeBinary, comment='附件2')
    cfjblob3 = Column(LargeBinary, comment='附件3')
    subsys_id = Column(String(4), comment='分系统代码')
    depiction = Column(String(100), comment='备注')
    isreupload = Column(CHAR(1), server_default=text("'0'"))
    checker = Column(String(10), comment='创建人')
    checktime = Column(DateTime, comment='创建时间')
    creator = Column(String(30), comment='创建人')
    creationtime = Column(DateTime, index=True, comment='创建时间')
    modifier = Column(String(30), comment='最后修改人')
    modifiedtime = Column(DateTime, comment='最后修改时间')
    cSource_flag = Column(String(4), server_default=text("'1'"), comment='病案来源')
    cStatus = Column(CHAR(1), server_default=text("'0'"), comment='状态')
    link_flag = Column(CHAR(1), server_default=text("'1'"), comment='是否采用链接')
    filetype_id = Column(String(10), server_default=text("'jpg'"), comment='文件类型id')
    cmiss_flag = Column(INTEGER(4), server_default=text("'0'"), comment='遗漏补拍标记')
    paint_flag = Column(CHAR(1), server_default=text("'0'"), comment='涂抹标志')
    paint_user = Column(String(30))
    paint_date = Column(DateTime)
    byz_xmbz_flag = Column(BIT(1))
    byz_zyrqcyjl_flag = Column(BIT(1))
    byz_zyhcyjl_flag = Column(BIT(1))
    byz_ftyccyjl_flag = Column(BIT(1))
    byz_ftycfyqd_flag = Column(BIT(1))
    byz_ftycjsd_flag = Column(BIT(1))
    unsharp_flag = Column(BIT(1))
    judge_backup = Column(String(40))
    ps_flag = Column(CHAR(1), server_default=text("'0'"), comment='图片是否ps过(0-无，1-ps过)')


class ZxIeOcrerror(Base):
    __tablename__ = 'zx_ie_ocrerror'
    __table_args__ = (
        Index('imp_zx_phrec_idx1', 'pk_phhd', 'cfjaddress'),
    )

    pk_phrec = Column(INTEGER(11), primary_key=True, comment='病案清主键')
    pk_phhd = Column(INTEGER(11), comment='病案主键')
    cRectype = Column(CHAR(1), comment='记录类型（1-入院小结，2--出院小结，3--手术记录 4清单）')
    rowno = Column(TINYINT(4), server_default=text("'1'"), comment='序号')
    cXm = Column(VARCHAR(12), comment='姓名')
    cSfzh = Column(String(20), comment='身份证号')
    cfjaddress = Column(String(200), comment='附件地址')
    cfjaddress2 = Column(String(500), comment='附件地址2')
    cfjaddress3 = Column(String(500), comment='附件地址3')
    cfjblob = Column(LargeBinary, comment='附件')
    cfjblob2 = Column(LargeBinary, comment='附件2')
    cfjblob3 = Column(LargeBinary, comment='附件3')
    subsys_id = Column(String(4), comment='分系统代码')
    depiction = Column(String(100), comment='备注')
    isreupload = Column(CHAR(1), server_default=text("'0'"))
    checker = Column(String(10), comment='创建人')
    checktime = Column(DateTime, comment='创建时间')
    creator = Column(String(30), comment='创建人')
    creationtime = Column(DateTime, index=True, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
    modifier = Column(String(30), comment='最后修改人')
    modifiedtime = Column(DateTime, comment='最后修改时间')
    cSource_flag = Column(String(4), server_default=text("'1'"), comment='病案来源')
    cStatus = Column(CHAR(1), server_default=text("'0'"), comment='状态')
    link_flag = Column(CHAR(1), server_default=text("'1'"), comment='是否采用链接')
    filetype_id = Column(String(10), server_default=text("'jpg'"), comment='文件类型id')
    cmiss_flag = Column(INTEGER(4), server_default=text("'0'"), comment='遗漏补拍标记')
    paint_flag = Column(CHAR(1), server_default=text("'0'"), comment='涂抹标志')
    paint_user = Column(String(30))
    paint_date = Column(DateTime)
    byz_xmbz_flag = Column(BIT(1))
    byz_zyrqcyjl_flag = Column(BIT(1))
    byz_zyhcyjl_flag = Column(BIT(1))
    byz_ftyccyjl_flag = Column(BIT(1))
    byz_ftycfyqd_flag = Column(BIT(1))
    byz_ftycjsd_flag = Column(BIT(1))
    unsharp_flag = Column(BIT(1))
    judge_backup = Column(String(40))
    ps_flag = Column(CHAR(1), server_default=text("'0'"), comment='图片是否ps过(0-无，1-ps过)')
    cPhhd_id = Column(String(20), comment='拍一拍单据号')
