<?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.lymsh.mommybaby.earlydata.dao.MommyMapper">
    <resultMap id="MommyExamineInfoResultMap" type="com.lymsh.mommybaby.earlydata.model.MommyExamineInfo">
        <result column="EI_ID" property="eiId" jdbcType="VARCHAR"/>
        <result column="EI_NAME" property="eiName" jdbcType="VARCHAR"/>
        <result column="EI_VALUEMODEID" property="eiValuemodeid" jdbcType="VARCHAR"/>
        <result column="EI_VALUEUNITID" property="eiValueunitid" jdbcType="VARCHAR"/>
        <result column="EI_DATATYPEID" property="eiDatatypeid" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="MommyExamineInfoColumns">
        EI_ID,EI_NAME,EI_VALUEMODEID,EI_VALUEUNITID,EI_DATATYPEID
    </sql>
    <select id="selectMommyExamineInfo" resultMap="MommyExamineInfoResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select
        <include refid="MommyExamineInfoColumns"/>
        from (select<include refid="MommyExamineInfoColumns"/>,rownum r
        from (
        select
        <include refid="MommyExamineInfoColumns"/>
        from MOMMY_EXAMINEINFO t
        where EI_OPERTIME >= #{startTime}
        ) h where
        <![CDATA[ rownum <= #{endRow} ]]>
        )
        where
        <![CDATA[ r >= #{startRow} ]]>
    </select>
    <resultMap id="MommyEmployeeResultMap" type="com.lymsh.mommybaby.earlydata.model.MommyEmployee">
        <result column="E_ID" property="eId" jdbcType="VARCHAR"/>
        <result column="E_NAME" property="eName" jdbcType="VARCHAR"/>
        <result column="E_SEX" property="eSex" jdbcType="INTEGER"/>
        <result column="E_HOSPITALID" property="eHospitalid" jdbcType="VARCHAR"/>
        <result column="E_JOBTITLEID" property="eJobtitleid" jdbcType="VARCHAR"/>
        <result column="E_DEPTID" property="eDeptid" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="MommyEmployeeColumns">
        E_ID,E_NAME,E_SEX,E_HOSPITALID,E_JOBTITLEID,E_DEPTID
    </sql>
    <select id="selectMommyEmployee" resultMap="MommyEmployeeResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select
        <include refid="MommyEmployeeColumns"/>
        from (select<include refid="MommyEmployeeColumns"/>,rownum r
        from (
        select
        <include refid="MommyEmployeeColumns"/>
        from MOMMY_EMPLOYEE t
        where E_OPERTIME >= #{startTime}
        ) h where
        <![CDATA[ rownum <= #{endRow} ]]>
        )
        where
        <![CDATA[ r >= #{startRow} ]]>
    </select>
    <resultMap id="MommyPatientResultMap" type="com.lymsh.mommybaby.earlydata.model.MommyPatient">
        <result column="P_NO" property="pNo" jdbcType="VARCHAR"/>
        <result column="P_OPERUSER" property="pOperuser" jdbcType="VARCHAR"/>
        <result column="P_TYPE" property="pType" jdbcType="INTEGER"/>
        <result column="P_ISVALID" property="isValid" jdbcType="INTEGER"/>
        <result column="P_PLATPATIENTID" property="pPatientid" jdbcType="VARCHAR"/>
        <result column="P_LASTMENSTRUALPERIOD" property="pLastmenstrualperiod" jdbcType="TIMESTAMP"/>
        <result column="P_SERVICETYPE" property="serviceType" jdbcType="INTEGER"/>
        <result column="P_ISVIP" property="vip" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="MommyPatientColumns">
        P_NO,P_OPERUSER,P_TYPE,P_PLATPATIENTID,P_LASTMENSTRUALPERIOD,P_ISVALID,P_SERVICETYPE,P_ISVIP
    </sql>
    <select id="selectMommyPatient" resultMap="MommyPatientResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select
        <include refid="MommyPatientColumns"/>
        from (select<include refid="MommyPatientColumns"/>,rownum r
        from (
        select
        <include refid="MommyPatientColumns"/>
        from MOMMY_PATIENT t
        where P_OPERTIME >= #{startTime} <if test="hospitalForeignId != null and hospitalForeignId != ''">  and p_hospitalid = #{hospitalForeignId} </if>
        ) h where
        <![CDATA[ rownum <= #{endRow} ]]>
        )
        where
        <![CDATA[ r >= #{startRow} ]]>
    </select>
    <resultMap id="MommyPatientinfoResultMap" type="com.lymsh.mommybaby.earlydata.model.MommyPatientinfo">
        <result column="PI_ID" property="piId" jdbcType="VARCHAR"/>
        <result column="PI_NAME" property="piName" jdbcType="VARCHAR"/>
        <result column="PI_SEX" property="piSex" jdbcType="INTEGER"/>
        <result column="PI_ISDELETE" property="isDeleted" jdbcType="INTEGER"/>
        <result column="PI_KIDSTYPE" property="piKidstype" jdbcType="INTEGER"/>
        <result column="PI_BIRTHDAY" property="piBirthday" jdbcType="TIMESTAMP"/>
        <result column="PI_MOTHERPHONE" property="piMotherphone" jdbcType="VARCHAR"/>
        <result column="PI_OPERUSER" property="piOperuser" jdbcType="VARCHAR"/>
        <result column="PI_PLATPATIENTID" property="piPatientid" jdbcType="VARCHAR"/>
        <result column="PI_SERVICETYPE" property="serviceType" jdbcType="INTEGER"/>
        <result column="PI_ISVIP" property="vip" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="MommyPatientinfoColumns">
        PI_ID,PI_NAME,PI_SEX,PI_KIDSTYPE,PI_BIRTHDAY,PI_MOTHERPHONE,PI_OPERUSER,PI_PLATPATIENTID,PI_ISDELETE,PI_SERVICETYPE,PI_ISVIP
    </sql>
    <select id="selectMommyPatientinfo" resultMap="MommyPatientinfoResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select
        <include refid="MommyPatientinfoColumns"/>
        from (select<include refid="MommyPatientinfoColumns"/>,rownum r
        from (
        select
        <include refid="MommyPatientinfoColumns"/>
        from MOMMY_PATIENTINFO t
        where PI_OPERTIME >= #{startTime} <if test="hospitalForeignId != null and hospitalForeignId != ''"> and pi_bookbuildinghospitalid = #{hospitalForeignId} </if>
        ) h where
        <![CDATA[ rownum <= #{endRow} ]]>
        )
        where
        <![CDATA[ r >= #{startRow} ]]>
    </select>
    <resultMap id="MommyChildexaminerecordResultMap" type="com.lymsh.mommybaby.earlydata.model.MommyChildexaminerecord">
        <result column="CER_ID" property="cerId" jdbcType="VARCHAR"/>
        <result column="CER_PATIENTID" property="cerPatientid" jdbcType="VARCHAR"/>
        <result column="CER_EXAMINDATE" property="cerExaminedate" jdbcType="TIMESTAMP"/>
        <result column="CER_EXAMINHOSPITAL" property="cerExaminehospital" jdbcType="VARCHAR"/>
        <result column="CER_MODIFIEDOPERATOR" property="cerOperator" jdbcType="VARCHAR"/>
        <result column="CER_REMARKS" property="cerRemarks" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="MommyChildexaminerecordColumns">
        CER_ID,CER_PATIENTID,CER_EXAMINDATE,CER_EXAMINHOSPITAL,CER_MODIFIEDOPERATOR,CER_REMARKS
    </sql>
    <select id="selectMommyChildexaminerecord" resultMap="MommyChildexaminerecordResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select
        <include refid="MommyChildexaminerecordColumns"/>
        from (select<include refid="MommyChildexaminerecordColumns"/>,rownum r
        from (
        select
        <include refid="MommyChildexaminerecordColumns"/>
        from MOMMY_CHILDEXAMINRECORD t
        where CER_MODIFIEDTIME >= #{startTime} <if test="condition != null and condition != ''"> and ${condition} </if>
        ) h where
        <![CDATA[ rownum <= #{endRow} ]]>
        )
        where
        <![CDATA[ r >= #{startRow} ]]>
    </select>
    <resultMap id="MommyExamineResultMap" type="com.lymsh.mommybaby.earlydata.model.MommyExamine">
        <result column="E_ID" property="eId" jdbcType="VARCHAR"/>
        <result column="E_CHILDEXAMINID" property="eChildexamineid" jdbcType="VARCHAR"/>
        <result column="E_EXAMINEID" property="eExamineid" jdbcType="VARCHAR"/>
        <result column="E_RESULT" property="eResult" jdbcType="VARCHAR"/>
        <result column="E_UNIT" property="eUnit" jdbcType="VARCHAR"/>
        <result column="E_EVALUATION" property="eEvaluation" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="MommyExamineColumns">
        E_ID,E_CHILDEXAMINID,E_EXAMINEID,E_RESULT,E_UNIT,E_EVALUATION
    </sql>
    <select id="selectMommyExamine" resultMap="MommyExamineResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select
        <include refid="MommyExamineColumns"/>
        from (select<include refid="MommyExamineColumns"/>,rownum r
        from (
        select
        <include refid="MommyExamineColumns"/>
        from MOMMY_EXAMINE t
        where E_CHILDEXAMINID = #{ext1}
        ) h where
        <![CDATA[ rownum <= #{endRow} ]]>
        )
        where
        <![CDATA[ r >= #{startRow} ]]>
    </select>
    <select id="selectExamineDiagnosis" resultType="java.lang.String" parameterType="java.lang.String">
        select ED_DIAGNOSISCONTENT FROM Mommy_ExamineDiagnosis WHERE ED_TRIAGEORDERNO = #{triageOrderNo} and ED_ISVALID = 1
    </select>
    <resultMap id="GuideTheWomenResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatDataContent">
        <result column="DC_NAME" property="dcId" jdbcType="VARCHAR"/>
        <result column="ER_CONTENT" property="dcName" jdbcType="VARCHAR"/>
        <result column="ES_PREGNANCYWEEK" property="week" jdbcType="INTEGER"/>
    </resultMap>
    <select id="selectGuideTheWomen" resultMap="GuideTheWomenResultMap" parameterType="java.lang.Integer">
        select ES_PREGNANCYWEEK,DC_NAME,ER_CONTENT FROM V_GUIDETHEWOMEN
        <if test="week != null">
            WHERE ES_PREGNANCYWEEK = #{week}
        </if>
    </select>
    <resultMap id="DcIdNameResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatDataContent">
        <result column="DC_ID" property="dcId" jdbcType="VARCHAR"/>
        <result column="DC_NAME" property="dcName" jdbcType="VARCHAR"/>
    </resultMap>
    <select id="selectDcIdName" resultMap="DcIdNameResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
        select DC_ID,DC_NAME FROM ${tableName}
    </select>
    <resultMap id="DiagnosisViewResultMap" type="com.lymsh.mommybaby.earlydata.model.DiagnosisView">
        <result column="dh_pasthistoryid" property="storyId" jdbcType="VARCHAR"/>
        <result column="dh_name" property="dhName" jdbcType="VARCHAR"/>
        <result column="dh_historyinfo" property="historyInfo" jdbcType="VARCHAR"/>
        <result column="dh_historytypeid" property="historyTypeId" jdbcType="VARCHAR"/>
    </resultMap>
    <select id="selectDiagnosisView" resultMap="DiagnosisViewResultMap" parameterType="java.lang.String">
        select dh_pasthistoryid,decode(dh_name,'',(select dc_name  from plat_datacontent where dc_id=dh_pasthistoryid),dh_name) as dh_name
,dh_historyinfo,dh_historytypeid from mommy_diseasehistory where dh_historytypeid in('77','d0b47bdc-c516-4f86-95fa-176a33ca73bf') and DH_TRIAGEORDERNO=#{triageOrderNo}
    </select>
</mapper>