<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.emr.dao.CommomMapper">
    <resultMap id="BaseResultMap" type="com.emr.vo.commomSearch.CommomVo">
        <!--<result column="patient_id" property="patientId" jdbcType="VARCHAR" />
        <result column="admiss_times" property="admissTimes" jdbcType="SMALLINT" />
        <result column="inpatient_no" property="inpatientNo" jdbcType="VARCHAR" />
        <result column="name" property="name" jdbcType="VARCHAR" />
        <result column="admiss_id" property="admissId" jdbcType="VARCHAR" />
        <result column="sex" property="sex" jdbcType="NVARCHAR" />
        <result column="age" property="age" jdbcType="SMALLINT" />
        <result column="age_month" property="ageMonth" jdbcType="SMALLINT" />
        <result column="age_day" property="ageDay" jdbcType="SMALLINT" />
        <result column="home_addr" property="homeAddr" jdbcType="NVARCHAR" />
        <result column="name_cym" property="nameCym" jdbcType="CHAR" />
        <result column="admiss_date" property="admissDate" jdbcType="TIMESTAMP" />
        <result column="dis_date" property="disDate" jdbcType="TIMESTAMP" />
        <result column="admiss_days" property="admissDays" jdbcType="INTEGER" />
        <result column="dis_dept" property="disDept" jdbcType="NVARCHAR" />
        <result column="is_oper" property="isOper" jdbcType="VARCHAR" />
        <result column="attending" property="attending" jdbcType="VARCHAR" />
        <result column="main_diag_name" property="mainDiagName" jdbcType="VARCHAR" />
        <result column="main_dis_thing" property="mainDisThing" jdbcType="NVARCHAR" />
        <result column="country" property="country" jdbcType="NVARCHAR" />
        <result column="birth_addr" property="birthAddr" jdbcType="NVARCHAR" />
        <result column="id_card" property="idCard" jdbcType="NVARCHAR" />
        <result column="job" property="job" jdbcType="NVARCHAR" />
        <result column="marriage" property="marriage" jdbcType="NVARCHAR" />
        <result column="home_tel" property="homeTel" jdbcType="NVARCHAR" />
        <result column="home_zip" property="homeZip" jdbcType="NVARCHAR" />
        <result column="work_addr" property="workAddr" jdbcType="NVARCHAR" />
        <result column="work_tel" property="workTel" jdbcType="NVARCHAR" />
        <result column="work_zip" property="workZip" jdbcType="NVARCHAR" />
        <result column="linkman" property="linkman" jdbcType="NVARCHAR" />
        <result column="relation" property="relation" jdbcType="NVARCHAR" />
        <result column="rel_addr" property="relAddr" jdbcType="VARCHAR" />
        <result column="rel_tel" property="relTel" jdbcType="NVARCHAR" />
        <result column="pay_type" property="payType" jdbcType="NVARCHAR" />
        <result column="birthday" property="birthday" jdbcType="TIMESTAMP" />
        <result column="avoirdupois" property="avoirdupois" jdbcType="DECIMAL" />
        <result column="admiss_type" property="admissType" jdbcType="NVARCHAR" />
        <result column="admiss_dept" property="admissDept" jdbcType="NVARCHAR" />
        <result column="admiss_ward" property="admissWard" jdbcType="NVARCHAR" />
        <result column="change_dept" property="changeDept" jdbcType="NVARCHAR" />
        <result column="dis_ward" property="disWard" jdbcType="NVARCHAR" />
        <result column="clinic_diag" property="clinicDiag" jdbcType="VARCHAR" />
        <result column="clinic_name" property="clinicName" jdbcType="VARCHAR" />
        <result column="admiss_thing" property="admissThing" jdbcType="NVARCHAR" />
        <result column="medicine" property="medicine" jdbcType="VARCHAR" />
        <result column="is_medicine" property="isMedicine" jdbcType="VARCHAR" />
        <result column="emit_pathology" property="emitPathology" jdbcType="NVARCHAR" />
        <result column="dept_director" property="deptDirector" jdbcType="VARCHAR" />
        <result column="director" property="director" jdbcType="VARCHAR" />
        <result column="admiss_doctor" property="admissDoctor" jdbcType="VARCHAR" />
        <result column="refresher" property="refresher" jdbcType="VARCHAR" />
        <result column="praxis" property="praxis" jdbcType="VARCHAR" />
        <result column="coding" property="coding" jdbcType="VARCHAR" />
        <result column="quality" property="quality" jdbcType="NVARCHAR" />
        <result column="control" property="control" jdbcType="VARCHAR" />
        <result column="nurses" property="nurses" jdbcType="VARCHAR" />
        <result column="quality_date" property="qualityDate" jdbcType="TIMESTAMP" />
        <result column="blood_type" property="bloodType" jdbcType="NVARCHAR" />
        <result column="RH" property="rh" jdbcType="VARCHAR" />-->
    </resultMap>
    <!--查询树接收集合-->
    <resultMap id="BaseResultMap1" type="com.emr.vo.commomSearch.CommomTree">
        <result column="patient_id" property="patientId" jdbcType="VARCHAR"/>
        <result column="assort_id" property="assortId" jdbcType="VARCHAR"/>
        <result column="assort_name" property="assortName" jdbcType="VARCHAR"/>
        <result column="assortCount" property="assortCount" jdbcType="INTEGER"/>
        <result column="scan_page" property="scanPage" jdbcType="INTEGER"/>
    </resultMap>
    <resultMap id="BaseResultMap2" type="com.emr.vo.FontVo.FontCommom">
        <result column="patient_id" property="patientId" jdbcType="VARCHAR"/>
        <result column="inpatient_no" property="inpatientNo" jdbcType="VARCHAR"/>
        <result column="admiss_id" property="admissId" jdbcType="VARCHAR"/>
        <result column="admiss_times" property="admissTimes" jdbcType="SMALLINT"/>
        <result column="dis_date" property="disDate" jdbcType="TIMESTAMP"/>
        <result column="dis_dept" property="disDept" jdbcType="NVARCHAR"/>
        <result column="id_card" property="idCard" jdbcType="NVARCHAR"/>
        <result column="clinic_id" property="clinicId" jdbcType="NVARCHAR"/>
        <result column="bed_no" property="bedNo" jdbcType="NVARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="sex" property="sex" jdbcType="NVARCHAR"/>
        <result column="age" property="age" jdbcType="SMALLINT"/>
        <result column="age_month" property="ageMonth" jdbcType="SMALLINT"/>
        <result column="age_day" property="ageDay" jdbcType="SMALLINT"/>
        <result column="birthday" property="birthday" jdbcType="TIMESTAMP"/>
        <result column="marriage" property="marriage" jdbcType="NVARCHAR"/>
        <result column="admiss_dept" property="admissDept" jdbcType="NVARCHAR"/>
        <result column="admiss_date" property="admissDate" jdbcType="TIMESTAMP"/>
        <result column="checked_datetime" property="checkedDatetime" jdbcType="NVARCHAR"/>
    </resultMap>

    <!--查询集合-->
    <select id="selectAll" resultMap="BaseResultMap" parameterType="java.lang.String">
        ${sql}
    </select>
    <!--根据patientIds查询集合-->
    <select id="selectAllByPatients" resultMap="BaseResultMap" parameterType="java.lang.String">
        SELECT
            patient_id,
            admiss_id,
            inpatient_no,
            admiss_times,
            dis_date
        FROM
            commomtable
        WHERE
            patient_id in (${patientIds})
    </select>
    <select id="selectAllInfo" resultType="com.emr.vo.commomSearch.CommomVo">
        select
            inpatient_no,
            name
        from commomtable
    </select>
    <!--根据住院次数和病案号和姓名查询patientId-->
    <select id="selectPatientIdByAdmissTimesAndInpatientNoAndName" resultType="java.lang.String"
            parameterType="java.lang.String">
        SELECT
        patient_id
        FROM
        commomtable
        WHERE
        inpatient_no = #{inpatientNo}
        <if test="admissTimes != null">
            AND admiss_times = #{admissTimes}
        </if>
        AND name = #{name}
        <if test="startTime2 != null and startTime2 != '' and endTime2 != null and endTime2 != ''">
            AND dis_date between #{startTime2} + ' 00:00:00' and #{endTime2} + ' 23:59:59'
        </if>
    </select>

    <!--根据patientId查询病案分类个数-->
    <select id="selectScanCountByPatientId" resultMap="BaseResultMap1" parameterType="java.lang.String">
        SELECT
        dbo.commomtable.patient_id,
        dbo.t_scan_assort.assort_id,
        dbo.zd_assort.assort_name,
        COUNT(dbo.zd_assort.assort_name) assortCount
        FROM
        dbo.commomtable
        LEFT JOIN
        dbo.t_scan_assort
        ON
        dbo.commomtable.patient_id = dbo.t_scan_assort.patient_id
        INNER JOIN
        dbo.zd_assort
        ON
        dbo.t_scan_assort.assort_id = dbo.zd_assort.assort_id
        <if test="userId != null">
            INNER JOIN (
            SELECT DISTINCT
            assort_id
            FROM
            zd_assort
            LEFT JOIN (
            SELECT
            record_id
            FROM
            emr_role_reader
            WHERE
            role_id = ${roleId}
            AND record_id NOT IN (
            SELECT
            record_id
            FROM
            emr_user_reader
            WHERE
            user_id = ${userId}
            AND flag = 0
            )
            UNION ALL
            SELECT
            record_id
            FROM
            emr_user_reader
            WHERE
            user_id = ${userId}
            AND flag = 1
            ) emr_user_reader ON assort_id = emr_user_reader.record_id
            WHERE
            emr_user_reader.record_id IS NOT NULL
            ) a
            ON dbo.zd_assort.assort_id = a.assort_id
        </if>
        WHERE
        dbo.commomtable.patient_id = #{patientId}
        AND
        dbo.zd_assort.print_flag = 0
        GROUP BY
        dbo.t_scan_assort.assort_id,dbo.zd_assort.assort_name,dbo.commomtable.patient_id,dbo.zd_assort.assort_sort
        ORDER BY
        dbo.zd_assort.assort_sort
    </select>

    <!--脐血库根据patientId查询病案-->
    <select id="selectScanPathByPatientId" resultMap="BaseResultMap1" parameterType="java.lang.String">
        SELECT
        dbo.commomtable.patient_id,
        dbo.t_scan_assort.assort_id,
        dbo.zd_assort.assort_name,
        t_scan_assort.scan_page
        FROM
        dbo.commomtable
        LEFT JOIN
        dbo.t_scan_assort
        ON
        dbo.commomtable.patient_id = dbo.t_scan_assort.patient_id
        INNER JOIN
        dbo.zd_assort
        ON
        dbo.t_scan_assort.assort_id = dbo.zd_assort.assort_id
        <if test="userId != null">
            INNER JOIN (
            SELECT DISTINCT
            assort_id
            FROM
            zd_assort
            LEFT JOIN (
            SELECT
            record_id
            FROM
            emr_role_reader
            WHERE
            role_id = ${roleId}
            AND record_id NOT IN (
            SELECT
            record_id
            FROM
            emr_user_reader
            WHERE
            user_id = ${userId}
            AND flag = 0
            )
            UNION ALL
            SELECT
            record_id
            FROM
            emr_user_reader
            WHERE
            user_id = ${userId}
            AND flag = 1
            ) emr_user_reader ON assort_id = emr_user_reader.record_id
            WHERE
            emr_user_reader.record_id IS NOT NULL
            ) a
            ON dbo.zd_assort.assort_id = a.assort_id
        </if>
        WHERE
        dbo.commomtable.patient_id = #{patientId}
        ORDER BY
        dbo.zd_assort.assort_sort
    </select>
    <!--根据patientId查询归档病案分类个数-->
    <select id="selectScanCountByMedicalPatientId" resultMap="BaseResultMap1" parameterType="java.lang.String">
        SELECT
        archive_detail.MasterID patient_id,
        zd_assort.assort_id,
        zd_assort.assort_name,
        COUNT(dbo.zd_assort.assort_name) assortCount from archive_detail
        LEFT JOIN
        zd_assort
        ON
        archive_detail.AssortID = zd_assort.assort_id and zd_assort.print_flag = 0
        <if test="userId != null">
            INNER JOIN (
            SELECT DISTINCT
            assort_id
            FROM
            zd_assort
            LEFT JOIN (
            SELECT
            record_id
            FROM
            emr_role_reader
            WHERE
            role_id = ${roleId}
            AND record_id NOT IN (
            SELECT
            record_id
            FROM
            emr_user_reader
            WHERE
            user_id = ${userId}
            AND flag = 0
            )
            UNION ALL
            SELECT
            record_id
            FROM
            emr_user_reader
            WHERE
            user_id = ${userId}
            AND flag = 1
            ) emr_user_reader ON assort_id = emr_user_reader.record_id
            WHERE
            emr_user_reader.record_id IS NOT NULL
            ) a
            ON dbo.zd_assort.assort_id = a.assort_id
        </if>
        WHERE
        archive_detail.MasterID = #{patientId} AND archive_detail.flag != 1
        GROUP BY
        dbo.zd_assort.assort_id,dbo.zd_assort.assort_name,archive_detail.MasterID,zd_assort.assort_sort
        ORDER BY zd_assort.assort_sort
    </select>
    <!--根据patientId查询其他诊断-->
    <select id="selectOtherDiagByPatientId" resultMap="BaseResultMap" parameterType="java.lang.String">
        SELECT
            dbo.commomtable.patient_id,
            dbo.commomtable.admiss_id,
            dbo.commomtable.inpatient_no,
            dbo.commomtable.name,
            dbo.commomtable.admiss_times,
            dbo.commomtable.main_diag_name,
            dbo.commomtable.main_dis_thing,
            dbo.commomtable.dis_dept,
            dbo.commomtable.dis_date,
            (select stuff((select '，' + diag_name
                           from dbo.t_diag
                           where diag.patient_id = patient_id
                             and diag_no > '1' for xml path('')),
                    1,
                    1,
                    '')
            ) as
            otherDiagName
        FROM
            dbo
            .
            commomtable
            LEFT
            JOIN
            dbo
            .
            t_diag
            diag
        ON
            dbo
            .
            commomtable
            .
            patient_id =
            diag
            .
            patient_id
        WHERE
            dbo.commomtable.patient_id = #{patientId}
    </select>
    <!--根据名字病案号查询住院次数集合-->
    <select id="selectAdmissTimesByNameAndNo" resultMap="BaseResultMap" parameterType="java.lang.String">
        SELECT
            admiss_times
        FROM
            commomtable
        WHERE
            dbo.commomtable.name = #{name}
          AND
            inpatient_no = #{inpatientNo}
        ORDER BY
            admiss_times
    </select>

    <!--模糊搜索病案号集合-->
    <select id="getInpatientNosByName" resultMap="BaseResultMap" parameterType="java.lang.String">
        SELECT
        inpatient_no,name
        FROM
        commomtable
        WHERE
        inpatient_no LIKE '%${inpatientNo}%'
        <if test="name != '' and name != null">
            AND name LIKE '%${name}%'
        </if>
    </select>
    <select id="getInpatientList" resultMap="BaseResultMap2">
        SELECT
        dbo.commomtable.patient_id,
        dbo.commomtable.inpatient_no,
        dbo.commomtable.admiss_id,
        dbo.commomtable.admiss_times,
        dbo.commomtable.dis_dept,
        (CASE WHEN dbo.commomtable.dis_date is not null and dbo.commomtable.dis_date != '' THEN
        CONVERT(varchar(100),dbo.commomtable.dis_date, 23) ELSE null end) dis_date,
        dbo.commomtable1.id_card,
        dbo.t_basic.clinic_id,
        dbo.t_basic.bed_no,
        dbo.commomtable.name,
        dbo.commomtable.sex,
        dbo.commomtable.age,
        dbo.commomtable.age_month,
        dbo.commomtable.age_day,
        (CASE WHEN dbo.commomtable1.birthday is not null and dbo.commomtable1.birthday != '' THEN
        CONVERT(varchar(100),dbo.commomtable1.birthday, 23) ELSE null end) birthday,
        dbo.commomtable1.marriage,
        dbo.commomtable1.admiss_dept,
        (CASE WHEN dbo.commomtable.admiss_date is not null and dbo.commomtable.admiss_date != '' THEN
        CONVERT(varchar(100),dbo.commomtable.admiss_date, 23) ELSE null end) admiss_date
        FROM
        dbo.commomtable
        INNER JOIN dbo.commomtable1 ON dbo.commomtable.patient_id = dbo.commomtable1.patient_id
        INNER JOIN dbo.t_basic ON dbo.commomtable.patient_id = dbo.t_basic.patient_id
        <where>
            <if test="patientId != null and patientId != ''">
                dbo.commomtable.patient_id = #{patientId}
            </if>
            <if test="name != null and name != ''">
                dbo.commomtable.name = #{name}
            </if>
            <if test="inpatientNo != null and inpatientNo != ''">
                AND dbo.commomtable.inpatient_no = #{inpatientNo}
            </if>
            <if test="admissId != null and admissId != ''">
                AND dbo.commomtable.admiss_id = #{admissId}
            </if>
            <if test="admissTimes != null and admissTimes != ''">
                AND dbo.commomtable.admiss_times = #{admissTimes}
            </if>
            <if test="disDate != null and disDate != ''">
                AND dbo.commomtable.dis_date BETWEEN #{disDate} AND #{disDate}
            </if>
            <if test="idCard != null and idCard != ''">
                AND dbo.commomtable1.id_card = #{idCard}
            </if>
        </where>
    </select>


    <sql id="Base_Column_List">
        patient_id
        ,
        admiss_times,
        inpatient_no,
        NAME,
        admiss_id,
        sex,
        age,
        age_month,
        age_day,
        home_addr,
        name_cym,
        admiss_date,
        dis_date,
        admiss_days,
        dis_dept,
        is_oper,
        attending,
        main_diag_name,
        main_dis_thing
    </sql>
    <select id="selectByPrimaryKey" resultType="com.emr.vo.commomSearch.CommomVo" parameterType="java.lang.String">
        select
            *
        from commomtable
        where patient_id = #{patientId,jdbcType=VARCHAR}
    </select>
    <select id="selectByPrimaryKeyPath" resultType="com.emr.vo.commomSearch.CommomVo" parameterType="java.lang.String">
        select
            patient_id,
            file_path
        from commomtable
        where patient_id = #{patientId,jdbcType=VARCHAR}
    </select>
    <!--插入commomtable表-->
    <insert id="insertSelective" parameterType="com.emr.vo.commomSearch.CommomVo">
        insert into commomtable
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patientId != null">
                patient_id,
            </if>
            <if test="admissTimes != null">
                admiss_times,
            </if>
            <if test="inpatientNo != null">
                inpatient_no,
            </if>
            <if test="name != null">
                NAME,
            </if>
            <if test="admissId != null">
                admiss_id,
            </if>
            <if test="sex != null">
                sex,
            </if>
            <if test="age != null">
                age,
            </if>
            <if test="ageMonth != null">
                age_month,
            </if>
            <if test="ageDay != null">
                age_day,
            </if>
            <if test="homeAddr != null">
                home_addr,
            </if>
            <if test="nameCym != null">
                name_cym,
            </if>
            <if test="admissDate != null">
                admiss_date,
            </if>
            <if test="disDate != null">
                dis_date,
            </if>
            <if test="admissDays != null">
                admiss_days,
            </if>
            <if test="disDept != null">
                dis_dept,
            </if>
            <if test="isOper != null">
                is_oper,
            </if>
            <if test="attending != null">
                attending,
            </if>
            <if test="mainDiagName != null">
                main_diag_name,
            </if>
            <if test="mainDisThing != null">
                main_dis_thing,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patientId != null">
                #{patientId,jdbcType=VARCHAR},
            </if>
            <if test="admissTimes != null">
                #{admissTimes,jdbcType=SMALLINT},
            </if>
            <if test="inpatientNo != null">
                #{inpatientNo,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="admissId != null">
                #{admissId,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                #{sex,jdbcType=NVARCHAR},
            </if>
            <if test="age != null">
                #{age,jdbcType=SMALLINT},
            </if>
            <if test="ageMonth != null">
                #{ageMonth,jdbcType=SMALLINT},
            </if>
            <if test="ageDay != null">
                #{ageDay,jdbcType=SMALLINT},
            </if>
            <if test="homeAddr != null">
                #{homeAddr,jdbcType=NVARCHAR},
            </if>
            <if test="nameCym != null">
                #{nameCym,jdbcType=CHAR},
            </if>
            <if test="admissDate != null">
                #{admissDate,jdbcType=TIMESTAMP},
            </if>
            <if test="disDate != null">
                #{disDate,jdbcType=TIMESTAMP},
            </if>
            <if test="admissDays != null">
                #{admissDays,jdbcType=INTEGER},
            </if>
            <if test="disDept != null">
                #{disDept,jdbcType=NVARCHAR},
            </if>
            <if test="isOper != null">
                #{isOper,jdbcType=VARCHAR},
            </if>
            <if test="attending != null">
                #{attending,jdbcType=VARCHAR},
            </if>
            <if test="mainDiagName != null">
                #{mainDiagName,jdbcType=VARCHAR},
            </if>
            <if test="mainDisThing != null">
                #{mainDisThing,jdbcType=NVARCHAR},
            </if>
        </trim>
    </insert>

    <!--更新commomtable表-->
    <update id="updateByPrimaryKeySelective" parameterType="com.emr.vo.commomSearch.CommomVo">
        update commomtable
        <set>
            <if test="admissTimes != null">
                admiss_times = #{admissTimes,jdbcType=SMALLINT},
            </if>
            <if test="inpatientNo != null">
                inpatient_no = #{inpatientNo,jdbcType=VARCHAR},
            </if>
            <if test="name != null">
                NAME = #{name,jdbcType=VARCHAR},
            </if>
            <if test="admissId != null">
                admiss_id = #{admissId,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                sex = #{sex,jdbcType=NVARCHAR},
            </if>
            <if test="age != null">
                age = #{age,jdbcType=SMALLINT},
            </if>
            <if test="ageMonth != null">
                age_month = #{ageMonth,jdbcType=SMALLINT},
            </if>
            <if test="ageDay != null">
                age_day = #{ageDay,jdbcType=SMALLINT},
            </if>
            <if test="homeAddr != null">
                home_addr = #{homeAddr,jdbcType=NVARCHAR},
            </if>
            <if test="nameCym != null">
                name_cym = #{nameCym,jdbcType=CHAR},
            </if>
            <if test="admissDate != null">
                admiss_date = #{admissDate,jdbcType=TIMESTAMP},
            </if>
            <if test="disDate != null">
                dis_date = #{disDate,jdbcType=TIMESTAMP},
            </if>
            <if test="admissDays != null">
                admiss_days = #{admissDays,jdbcType=INTEGER},
            </if>
            <if test="disDept != null">
                dis_dept = #{disDept,jdbcType=NVARCHAR},
            </if>
            <if test="isOper != null">
                is_oper = #{isOper,jdbcType=VARCHAR},
            </if>
            <if test="attending != null">
                attending = #{attending,jdbcType=VARCHAR},
            </if>
            <if test="mainDiagName != null">
                main_diag_name = #{mainDiagName,jdbcType=VARCHAR},
            </if>
            <if test="mainDisThing != null">
                main_dis_thing = #{mainDisThing,jdbcType=NVARCHAR},
            </if>
        </set>
        where patient_id = #{patientId,jdbcType=VARCHAR}
    </update>


    <sql id="Base_Column_List1">
        patient_id
        ,
        country,
        birth_addr,
        id_card,
        job,
        marriage,
        home_tel,
        home_zip,
        work_name,
        work_addr,
        work_tel,
        work_zip,
        linkman,
        relation,
        rel_addr,
        rel_tel,
        pay_type,
        birthday,
        avoirdupois,
        admiss_type,
        admiss_dept,
        admiss_ward,
        change_dept,
        dis_ward,
        clinic_diag,
        clinic_name,
        pathology_code,
        pathology_no,
        pathology_name,
        medicine,
        is_medicine,
        emit_pathology,
        dept_director,
        director,
        admiss_doctor,
        refresher,
        praxis,
        coding,
        quality,
        control,
        nurses,
        quality_date,
        input_name,
        input_createTime,
        blood_type,
        RH
    </sql>
    <select id="selectByPrimaryKey1" resultType="com.emr.vo.commomSearch.CommomVo" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List1"/>
        from commomtable1
        where patient_id = #{patientId,jdbcType=VARCHAR}
    </select>
    <!--插入commomtable1表-->
    <insert id="insertSelective1" parameterType="com.emr.vo.commomSearch.CommomVo">
        insert into commomtable1 (patient_id, country, birth_addr,
                                  id_card, job, marriage,
                                  home_tel, home_zip, work_addr,
                                  work_tel, work_zip, linkman,
                                  relation, rel_addr, rel_tel,
                                  pay_type, birthday, admiss_type,
                                  admiss_dept, admiss_ward, change_dept,
                                  dis_ward, clinic_diag, clinic_name,
                                  medicine, is_medicine, emit_pathology,
                                  dept_director, director, admiss_doctor,
                                  refresher, praxis, coding,
                                  quality, control, nurses,
                                  quality_date, blood_type, RH,
                                  native_place, addr, telphone,
                                  zip, change_date1, change_date2,
                                  change_date3, change_dept1, change_dept2,
                                  change_dept3, is_hospitalization, hospitalization_objective,
                                  is_medical_record_path, responsible_nurse,
                                  tumor_staging_type, radiotherapy_type, radiotherapy_program,
                                  radiotherapy_device, primary_tumor_day, primary_tumor_times,
                                  primary_tumor_dose, primary_tumor_starttime,
                                  primary_tumor_endtime, chemotherapy_type,
                                  chemotherapy_method, case_type, total_charge,
                                  charge_02, charge_03, charge_04,
                                  charge_05, charge_09, charge_10,
                                  charge_14, charge_19, charge_20,
                                  charge_22, charge_25, other,
                                  charge_29, charge_30, charge_31,
                                  charge_32, charge_33, charge_34,
                                  charge_35, charge_36, charge_37,
                                  charge_38, charge_39, charge_40,
                                  charge_41, charge_42, charge_43,
                                  charge_44, charge_45, nation,
                                  home_addr, clinic_doctor, dis_type,
                                  birthbaby_weight, healthy_card, save_times,
                                  save_success_times, avoirdupois, admiss_thing,
                                  work_name, pathology_code, pathology_no,
                                  pathology_name, input_name, input_createTime,
                                  ryqhm_days, ryqhm_hours, ryqhm_mins,
                                  ryhm_days, ryhm_hours, ryhm_mins,
                                  transfer_hospital_name, transfer_healcenter_name)
        values (#{patientId,jdbcType=VARCHAR}, #{country,jdbcType=NVARCHAR}, #{birthAddr,jdbcType=NVARCHAR},
                #{idCard,jdbcType=NVARCHAR}, #{job,jdbcType=NVARCHAR}, #{marriage,jdbcType=NVARCHAR},
                #{homeTel,jdbcType=NVARCHAR}, #{homeZip,jdbcType=NVARCHAR}, #{workAddr,jdbcType=NVARCHAR},
                #{workTel,jdbcType=NVARCHAR}, #{workZip,jdbcType=NVARCHAR}, #{linkman,jdbcType=NVARCHAR},
                #{relation,jdbcType=NVARCHAR}, #{relAddr,jdbcType=VARCHAR}, #{relTel,jdbcType=NVARCHAR},
                #{payType,jdbcType=NVARCHAR}, #{birthday,jdbcType=TIMESTAMP}, #{admissType,jdbcType=NVARCHAR},
                #{admissDept,jdbcType=NVARCHAR}, #{admissWard,jdbcType=NVARCHAR}, #{changeDept,jdbcType=NVARCHAR},
                #{disWard,jdbcType=NVARCHAR}, #{clinicDiag,jdbcType=VARCHAR}, #{clinicName,jdbcType=VARCHAR},
                #{medicine,jdbcType=VARCHAR}, #{isMedicine,jdbcType=VARCHAR}, #{emitPathology,jdbcType=NVARCHAR},
                #{deptDirector,jdbcType=VARCHAR}, #{director,jdbcType=VARCHAR}, #{admissDoctor,jdbcType=VARCHAR},
                #{refresher,jdbcType=VARCHAR}, #{praxis,jdbcType=VARCHAR}, #{coding,jdbcType=VARCHAR},
                #{quality,jdbcType=NVARCHAR}, #{control,jdbcType=VARCHAR}, #{nurses,jdbcType=VARCHAR},
                #{qualityDate,jdbcType=TIMESTAMP}, #{bloodType,jdbcType=NVARCHAR}, #{rh,jdbcType=VARCHAR},
                #{nativePlace,jdbcType=NVARCHAR}, #{addr,jdbcType=NVARCHAR}, #{telphone,jdbcType=NVARCHAR},
                #{zip,jdbcType=NVARCHAR}, #{changeDate1,jdbcType=NVARCHAR}, #{changeDate2,jdbcType=NVARCHAR},
                #{changeDate3,jdbcType=NVARCHAR}, #{changeDept1,jdbcType=NVARCHAR}, #{changeDept2,jdbcType=NVARCHAR},
                #{changeDept3,jdbcType=NVARCHAR}, #{isHospitalization,jdbcType=NVARCHAR},
                #{hospitalizationObjective,jdbcType=NVARCHAR},
                #{isMedicalRecordPath,jdbcType=NVARCHAR}, #{responsibleNurse,jdbcType=NVARCHAR},
                #{tumorStagingType,jdbcType=NVARCHAR}, #{radiotherapyType,jdbcType=NVARCHAR},
                #{radiotherapyProgram,jdbcType=NVARCHAR},
                #{radiotherapyDevice,jdbcType=NVARCHAR}, #{primaryTumorDay,jdbcType=INTEGER},
                #{primaryTumorTimes,jdbcType=INTEGER},
                #{primaryTumorDose,jdbcType=NVARCHAR}, #{primaryTumorStarttime,jdbcType=NVARCHAR},
                #{primaryTumorEndtime,jdbcType=NVARCHAR}, #{chemotherapyType,jdbcType=NVARCHAR},
                #{chemotherapyMethod,jdbcType=NVARCHAR}, #{caseType,jdbcType=VARCHAR}, #{totalCharge,jdbcType=DECIMAL},
                #{charge02,jdbcType=DECIMAL}, #{charge03,jdbcType=DECIMAL}, #{charge04,jdbcType=DECIMAL},
                #{charge05,jdbcType=DECIMAL}, #{charge09,jdbcType=DECIMAL}, #{charge10,jdbcType=DECIMAL},
                #{charge14,jdbcType=DECIMAL}, #{charge19,jdbcType=DECIMAL}, #{charge20,jdbcType=DECIMAL},
                #{charge22,jdbcType=DECIMAL}, #{charge25,jdbcType=DECIMAL}, #{other,jdbcType=DECIMAL},
                #{charge29,jdbcType=DECIMAL}, #{charge30,jdbcType=DECIMAL}, #{charge31,jdbcType=DECIMAL},
                #{charge32,jdbcType=DECIMAL}, #{charge33,jdbcType=DECIMAL}, #{charge34,jdbcType=DECIMAL},
                #{charge35,jdbcType=DECIMAL}, #{charge36,jdbcType=DECIMAL}, #{charge37,jdbcType=DECIMAL},
                #{charge38,jdbcType=DECIMAL}, #{charge39,jdbcType=DECIMAL}, #{charge40,jdbcType=DECIMAL},
                #{charge41,jdbcType=DECIMAL}, #{charge42,jdbcType=DECIMAL}, #{charge43,jdbcType=DECIMAL},
                #{charge44,jdbcType=DECIMAL}, #{charge45,jdbcType=DECIMAL}, #{nation,jdbcType=NVARCHAR},
                #{homeAddr,jdbcType=NVARCHAR}, #{clinicDoctor,jdbcType=NVARCHAR}, #{disType,jdbcType=NVARCHAR},
                #{birthbabyWeight,jdbcType=DECIMAL}, #{healthyCard,jdbcType=NVARCHAR}, #{saveTimes,jdbcType=NVARCHAR},
                #{saveSuccessTimes,jdbcType=NVARCHAR}, #{avoirdupois,jdbcType=DECIMAL},
                #{admissThing,jdbcType=NVARCHAR},
                #{workName,jdbcType=NVARCHAR}, #{pathologyCode,jdbcType=VARCHAR}, #{pathologyNo,jdbcType=VARCHAR},
                #{pathologyName,jdbcType=VARCHAR}, #{inputName,jdbcType=NVARCHAR}, #{inputCreatetime,jdbcType=NVARCHAR},
                #{ryqhmDays,jdbcType=INTEGER}, #{ryqhmHours,jdbcType=INTEGER}, #{ryqhmMins,jdbcType=INTEGER},
                #{ryhmDays,jdbcType=INTEGER}, #{ryhmHours,jdbcType=INTEGER}, #{ryhmMins,jdbcType=INTEGER},
                #{transferHospitalName,jdbcType=NVARCHAR}, #{transferHealcenterName,jdbcType=NVARCHAR})
    </insert>

    <!--更新commomtable1表-->
    <update id="updateByPrimaryKeySelective1" parameterType="com.emr.vo.commomSearch.CommomVo">
        update commomtable1
        <set>
            <if test="country != null">
                country = #{country,jdbcType=NVARCHAR},
            </if>
            <if test="birthAddr != null">
                birth_addr = #{birthAddr,jdbcType=NVARCHAR},
            </if>
            <if test="idCard != null">
                id_card = #{idCard,jdbcType=NVARCHAR},
            </if>
            <if test="job != null">
                job = #{job,jdbcType=NVARCHAR},
            </if>
            <if test="marriage != null">
                marriage = #{marriage,jdbcType=NVARCHAR},
            </if>
            <if test="homeTel != null">
                home_tel = #{homeTel,jdbcType=NVARCHAR},
            </if>
            <if test="homeZip != null">
                home_zip = #{homeZip,jdbcType=NVARCHAR},
            </if>
            <if test="workAddr != null">
                work_addr = #{workAddr,jdbcType=NVARCHAR},
            </if>
            <if test="workTel != null">
                work_tel = #{workTel,jdbcType=NVARCHAR},
            </if>
            <if test="workZip != null">
                work_zip = #{workZip,jdbcType=NVARCHAR},
            </if>
            <if test="linkman != null">
                linkman = #{linkman,jdbcType=NVARCHAR},
            </if>
            <if test="relation != null">
                relation = #{relation,jdbcType=NVARCHAR},
            </if>
            <if test="relAddr != null">
                rel_addr = #{relAddr,jdbcType=VARCHAR},
            </if>
            <if test="relTel != null">
                rel_tel = #{relTel,jdbcType=NVARCHAR},
            </if>
            <if test="payType != null">
                pay_type = #{payType,jdbcType=NVARCHAR},
            </if>
            <if test="birthday != null">
                birthday = #{birthday,jdbcType=TIMESTAMP},
            </if>
            <if test="admissType != null">
                admiss_type = #{admissType,jdbcType=NVARCHAR},
            </if>
            <if test="admissDept != null">
                admiss_dept = #{admissDept,jdbcType=NVARCHAR},
            </if>
            <if test="admissWard != null">
                admiss_ward = #{admissWard,jdbcType=NVARCHAR},
            </if>
            <if test="changeDept != null">
                change_dept = #{changeDept,jdbcType=NVARCHAR},
            </if>
            <if test="disWard != null">
                dis_ward = #{disWard,jdbcType=NVARCHAR},
            </if>
            <if test="clinicDiag != null">
                clinic_diag = #{clinicDiag,jdbcType=VARCHAR},
            </if>
            <if test="clinicName != null">
                clinic_name = #{clinicName,jdbcType=VARCHAR},
            </if>
            <if test="medicine != null">
                medicine = #{medicine,jdbcType=VARCHAR},
            </if>
            <if test="isMedicine != null">
                is_medicine = #{isMedicine,jdbcType=VARCHAR},
            </if>
            <if test="emitPathology != null">
                emit_pathology = #{emitPathology,jdbcType=NVARCHAR},
            </if>
            <if test="deptDirector != null">
                dept_director = #{deptDirector,jdbcType=VARCHAR},
            </if>
            <if test="director != null">
                director = #{director,jdbcType=VARCHAR},
            </if>
            <if test="admissDoctor != null">
                admiss_doctor = #{admissDoctor,jdbcType=VARCHAR},
            </if>
            <if test="refresher != null">
                refresher = #{refresher,jdbcType=VARCHAR},
            </if>
            <if test="praxis != null">
                praxis = #{praxis,jdbcType=VARCHAR},
            </if>
            <if test="coding != null">
                coding = #{coding,jdbcType=VARCHAR},
            </if>
            <if test="quality != null">
                quality = #{quality,jdbcType=NVARCHAR},
            </if>
            <if test="control != null">
                control = #{control,jdbcType=VARCHAR},
            </if>
            <if test="nurses != null">
                nurses = #{nurses,jdbcType=VARCHAR},
            </if>
            <if test="qualityDate != null">
                quality_date = #{qualityDate,jdbcType=TIMESTAMP},
            </if>
            <if test="bloodType != null">
                blood_type = #{bloodType,jdbcType=NVARCHAR},
            </if>
            <if test="rh != null">
                RH = #{rh,jdbcType=VARCHAR},
            </if>
            <if test="nativePlace != null">
                native_place = #{nativePlace,jdbcType=NVARCHAR},
            </if>
            <if test="addr != null">
                addr = #{addr,jdbcType=NVARCHAR},
            </if>
            <if test="telphone != null">
                telphone = #{telphone,jdbcType=NVARCHAR},
            </if>
            <if test="zip != null">
                zip = #{zip,jdbcType=NVARCHAR},
            </if>
            <if test="changeDate1 != null">
                change_date1 = #{changeDate1,jdbcType=NVARCHAR},
            </if>
            <if test="changeDate2 != null">
                change_date2 = #{changeDate2,jdbcType=NVARCHAR},
            </if>
            <if test="changeDate3 != null">
                change_date3 = #{changeDate3,jdbcType=NVARCHAR},
            </if>
            <if test="changeDept1 != null">
                change_dept1 = #{changeDept1,jdbcType=NVARCHAR},
            </if>
            <if test="changeDept2 != null">
                change_dept2 = #{changeDept2,jdbcType=NVARCHAR},
            </if>
            <if test="changeDept3 != null">
                change_dept3 = #{changeDept3,jdbcType=NVARCHAR},
            </if>
            <if test="isHospitalization != null">
                is_hospitalization = #{isHospitalization,jdbcType=NVARCHAR},
            </if>
            <if test="hospitalizationObjective != null">
                hospitalization_objective = #{hospitalizationObjective,jdbcType=NVARCHAR},
            </if>
            <if test="isMedicalRecordPath != null">
                is_medical_record_path = #{isMedicalRecordPath,jdbcType=NVARCHAR},
            </if>
            <if test="responsibleNurse != null">
                responsible_nurse = #{responsibleNurse,jdbcType=NVARCHAR},
            </if>
            <if test="tumorStagingType != null">
                tumor_staging_type = #{tumorStagingType,jdbcType=NVARCHAR},
            </if>
            <if test="radiotherapyType != null">
                radiotherapy_type = #{radiotherapyType,jdbcType=NVARCHAR},
            </if>
            <if test="radiotherapyProgram != null">
                radiotherapy_program = #{radiotherapyProgram,jdbcType=NVARCHAR},
            </if>
            <if test="radiotherapyDevice != null">
                radiotherapy_device = #{radiotherapyDevice,jdbcType=NVARCHAR},
            </if>
            <if test="primaryTumorDay != null">
                primary_tumor_day = #{primaryTumorDay,jdbcType=INTEGER},
            </if>
            <if test="primaryTumorTimes != null">
                primary_tumor_times = #{primaryTumorTimes,jdbcType=INTEGER},
            </if>
            <if test="primaryTumorDose != null">
                primary_tumor_dose = #{primaryTumorDose,jdbcType=NVARCHAR},
            </if>
            <if test="primaryTumorStarttime != null">
                primary_tumor_starttime = #{primaryTumorStarttime,jdbcType=NVARCHAR},
            </if>
            <if test="primaryTumorEndtime != null">
                primary_tumor_endtime = #{primaryTumorEndtime,jdbcType=NVARCHAR},
            </if>
            <if test="chemotherapyType != null">
                chemotherapy_type = #{chemotherapyType,jdbcType=NVARCHAR},
            </if>
            <if test="chemotherapyMethod != null">
                chemotherapy_method = #{chemotherapyMethod,jdbcType=NVARCHAR},
            </if>
            <if test="caseType != null">
                case_type = #{caseType,jdbcType=VARCHAR},
            </if>
            <if test="totalCharge != null">
                total_charge = #{totalCharge,jdbcType=DECIMAL},
            </if>
            <if test="charge02 != null">
                charge_02 = #{charge02,jdbcType=DECIMAL},
            </if>
            <if test="charge03 != null">
                charge_03 = #{charge03,jdbcType=DECIMAL},
            </if>
            <if test="charge04 != null">
                charge_04 = #{charge04,jdbcType=DECIMAL},
            </if>
            <if test="charge05 != null">
                charge_05 = #{charge05,jdbcType=DECIMAL},
            </if>
            <if test="charge09 != null">
                charge_09 = #{charge09,jdbcType=DECIMAL},
            </if>
            <if test="charge10 != null">
                charge_10 = #{charge10,jdbcType=DECIMAL},
            </if>
            <if test="charge14 != null">
                charge_14 = #{charge14,jdbcType=DECIMAL},
            </if>
            <if test="charge19 != null">
                charge_19 = #{charge19,jdbcType=DECIMAL},
            </if>
            <if test="charge20 != null">
                charge_20 = #{charge20,jdbcType=DECIMAL},
            </if>
            <if test="charge22 != null">
                charge_22 = #{charge22,jdbcType=DECIMAL},
            </if>
            <if test="charge25 != null">
                charge_25 = #{charge25,jdbcType=DECIMAL},
            </if>
            <if test="other != null">
                other = #{other,jdbcType=DECIMAL},
            </if>
            <if test="charge29 != null">
                charge_29 = #{charge29,jdbcType=DECIMAL},
            </if>
            <if test="charge30 != null">
                charge_30 = #{charge30,jdbcType=DECIMAL},
            </if>
            <if test="charge31 != null">
                charge_31 = #{charge31,jdbcType=DECIMAL},
            </if>
            <if test="charge32 != null">
                charge_32 = #{charge32,jdbcType=DECIMAL},
            </if>
            <if test="charge33 != null">
                charge_33 = #{charge33,jdbcType=DECIMAL},
            </if>
            <if test="charge34 != null">
                charge_34 = #{charge34,jdbcType=DECIMAL},
            </if>
            <if test="charge35 != null">
                charge_35 = #{charge35,jdbcType=DECIMAL},
            </if>
            <if test="charge36 != null">
                charge_36 = #{charge36,jdbcType=DECIMAL},
            </if>
            <if test="charge37 != null">
                charge_37 = #{charge37,jdbcType=DECIMAL},
            </if>
            <if test="charge38 != null">
                charge_38 = #{charge38,jdbcType=DECIMAL},
            </if>
            <if test="charge39 != null">
                charge_39 = #{charge39,jdbcType=DECIMAL},
            </if>
            <if test="charge40 != null">
                charge_40 = #{charge40,jdbcType=DECIMAL},
            </if>
            <if test="charge41 != null">
                charge_41 = #{charge41,jdbcType=DECIMAL},
            </if>
            <if test="charge42 != null">
                charge_42 = #{charge42,jdbcType=DECIMAL},
            </if>
            <if test="charge43 != null">
                charge_43 = #{charge43,jdbcType=DECIMAL},
            </if>
            <if test="charge44 != null">
                charge_44 = #{charge44,jdbcType=DECIMAL},
            </if>
            <if test="charge45 != null">
                charge_45 = #{charge45,jdbcType=DECIMAL},
            </if>
            <if test="nation != null">
                nation = #{nation,jdbcType=NVARCHAR},
            </if>
            <if test="homeAddr != null">
                home_addr = #{homeAddr,jdbcType=NVARCHAR},
            </if>
            <if test="clinicDoctor != null">
                clinic_doctor = #{clinicDoctor,jdbcType=NVARCHAR},
            </if>
            <if test="disType != null">
                dis_type = #{disType,jdbcType=NVARCHAR},
            </if>
            <if test="birthbabyWeight != null">
                birthbaby_weight = #{birthbabyWeight,jdbcType=DECIMAL},
            </if>
            <if test="healthyCard != null">
                healthy_card = #{healthyCard,jdbcType=NVARCHAR},
            </if>
            <if test="saveTimes != null">
                save_times = #{saveTimes,jdbcType=NVARCHAR},
            </if>
            <if test="saveSuccessTimes != null">
                save_success_times = #{saveSuccessTimes,jdbcType=NVARCHAR},
            </if>
            <if test="avoirdupois != null">
                avoirdupois = #{avoirdupois,jdbcType=DECIMAL},
            </if>
            <if test="admissThing != null">
                admiss_thing = #{admissThing,jdbcType=NVARCHAR},
            </if>
            <if test="workName != null">
                work_name = #{workName,jdbcType=NVARCHAR},
            </if>
            <if test="pathologyCode != null">
                pathology_code = #{pathologyCode,jdbcType=VARCHAR},
            </if>
            <if test="pathologyNo != null">
                pathology_no = #{pathologyNo,jdbcType=VARCHAR},
            </if>
            <if test="pathologyName != null">
                pathology_name = #{pathologyName,jdbcType=VARCHAR},
            </if>
            <if test="inputName != null">
                input_name = #{inputName,jdbcType=NVARCHAR},
            </if>
            <if test="inputCreatetime != null">
                input_createTime = #{inputCreatetime,jdbcType=NVARCHAR},
            </if>
            <if test="ryqhmDays != null">
                ryqhm_days = #{ryqhmDays,jdbcType=INTEGER},
            </if>
            <if test="ryqhmHours != null">
                ryqhm_hours = #{ryqhmHours,jdbcType=INTEGER},
            </if>
            <if test="ryqhmMins != null">
                ryqhm_mins = #{ryqhmMins,jdbcType=INTEGER},
            </if>
            <if test="ryhmDays != null">
                ryhm_days = #{ryhmDays,jdbcType=INTEGER},
            </if>
            <if test="ryhmHours != null">
                ryhm_hours = #{ryhmHours,jdbcType=INTEGER},
            </if>
            <if test="ryhmMins != null">
                ryhm_mins = #{ryhmMins,jdbcType=INTEGER},
            </if>
            <if test="transferHospitalName != null">
                transfer_hospital_name = #{transferHospitalName,jdbcType=NVARCHAR},
            </if>
            <if test="transferHealcenterName != null">
                transfer_healcenter_name = #{transferHealcenterName,jdbcType=NVARCHAR},
            </if>
        </set>
        where patient_id = #{patientId,jdbcType=VARCHAR}
    </update>
    <select id="isExistInpatientOrAdmissId" resultType="java.lang.Integer">
        SELECT
        count(1)
        FROM
        commomtable
        <where>
            <if test="inpatientNo != null and inpatientNo != ''">
                AND inpatient_no like '%${inpatientNo}%'
            </if>
            <if test="admissId != null and admissId != ''">
                AND admiss_id = #{admissId}
            </if>
            <if test="patientId != null and patientId != ''">
                AND patient_id = #{patientId}
            </if>
        </where>
    </select>
    <!--根据条件查询该病案是否存在-->
    <select id="isExistInpatient" resultType="java.lang.Integer">
        SELECT
        count(1)
        FROM
        commomtable
        LEFT JOIN
        commomtable1
        ON
        commomtable.patient_id = commomtable1.patient_id
        <where>
            <if test="patientId != null and patientId != ''">
                AND commomtable.patient_id = #{patientId}
            </if>
            <if test="inpatientNo != null and inpatientNo != ''">
                AND commomtable.inpatient_no = #{inpatientNo}
            </if>
            <if test="admissId != null and admissId != ''">
                AND commomtable.admiss_id = #{admissId}
            </if>
            <if test="admissTimes != null">
                AND commomtable.admiss_times = #{admissTimes}
            </if>
            <if test="idCard != null and idCard != ''">
                AND commomtable1.id_card = #{idCard}
            </if>
            <if test="disDate != null and disDate != ''">
                AND commomtable.dis_date between #{disDate} and #{disDate}
            </if>
        </where>
    </select>
    <!--查询表字段数-->
    <select id="selectColByTableName" resultType="java.lang.Integer">
        select count(*)
        from syscolumns s
        where s.id = object_id(#{tableName});
    </select>
    <!--查commomtable1表的肿瘤信息-->
    <select id="selectTumourByPatientId" resultType="com.emr.vo.commomSearch.CommomVo">
        select
            tumor_staging_type,
            radiotherapy_type,
            radiotherapy_program,
            radiotherapy_device,
            primary_tumor_day,
            primary_tumor_times,
            primary_tumor_dose,
            primary_tumor_starttime,
            primary_tumor_endtime,
            chemotherapy_type,
            chemotherapy_method
        from commomtable1
        where patient_id = #{patientId}
    </select>
    <!--根据病案号查询-->
    <select id="selectCommomByInpatientNo" resultMap="BaseResultMap">
        select patient_id,inpatient_no,name,admiss_id,admiss_times,dis_date,dis_dept
        from commomtable
        where inpatient_no like '%${inpatientNo}%'
    </select>
</mapper>