<?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.PlatMapper">
<resultMap id="PlatDataTypeResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatDataType">
<result column="DT_ID" property="dtId" jdbcType="VARCHAR"/>
<result column="DT_NAME" property="dtName" jdbcType="VARCHAR"/>
</resultMap>
<sql id="PlatDataTypeColumns">
DT_ID,DT_NAME
</sql>
<select id="selectPlatDataType" resultMap="PlatDataTypeResultMap">
select
<include refid="PlatDataTypeColumns"/>
from PLAT_DATATYPE
</select>
<resultMap id="PlatDataContentResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatDataContent">
<result column="DC_ID" property="dcId" jdbcType="VARCHAR"/>
<result column="DC_NAME" property="dcName" jdbcType="VARCHAR"/>
<result column="DC_NO" property="dcNo" jdbcType="VARCHAR"/>
<result column="DC_PARENTID" property="dcParentid" jdbcType="VARCHAR"/>
<result column="DC_DATATYPEID" property="dcDatatypeid" jdbcType="VARCHAR"/>
</resultMap>
<sql id="PlatDataContentColumns">
DC_ID,DC_NAME,DC_PARENTID,DC_DATATYPEID,DC_NO
</sql>
<select id="selectPlatDataContent" resultMap="PlatDataContentResultMap">
select
<include refid="PlatDataContentColumns"/>
from PLAT_DATACONTENT
</select>
<resultMap id="PlatHospitalResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatHospital">
<result column="H_ID" property="hId" jdbcType="VARCHAR"/>
<result column="H_NAME" property="hName" jdbcType="VARCHAR"/>
</resultMap>
<sql id="PlatHospitalColumns">
H_ID,H_NAME
</sql>
<select id="selectPlatHospital" resultMap="PlatHospitalResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
select
<include refid="PlatHospitalColumns"/>
from (select<include refid="PlatHospitalColumns"/>,rownum r
from (
select
<include refid="PlatHospitalColumns"/>
from PLAT_HOSPITAL t
) h where
<![CDATA[ rownum <= #{endRow} ]]>
)
where
<![CDATA[ r >= #{startRow} ]]>
</select>
<resultMap id="PlatUsersResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatUsers">
<result column="U_ID" property="uId" jdbcType="VARCHAR"/>
<result column="U_USERNAME" property="uUsername" jdbcType="VARCHAR"/>
<result column="U_USERPWD" property="uUserpwd" jdbcType="VARCHAR"/>
<result column="U_EMPLOYEEID" property="uEmployeeid" jdbcType="VARCHAR"/>
<result column="U_LOGINNUM" property="uLoginnum" jdbcType="VARCHAR"/>
<result column="U_ISVALID" property="uIsvalid" jdbcType="INTEGER"/>
</resultMap>
<sql id="PlatUsersColumns">
U_ID,U_USERNAME,U_USERPWD,U_EMPLOYEEID,U_LOGINNUM,U_ISVALID
</sql>
<select id="selectPlatUsers" resultMap="PlatUsersResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
select
<include refid="PlatUsersColumns"/>
from (select<include refid="PlatUsersColumns"/>,rownum r
from (
select
<include refid="PlatUsersColumns"/>
from PLAT_USERS t
where U_OPERTIME >= #{startTime}
) h where
<![CDATA[ rownum <= #{endRow} ]]>
)
where
<![CDATA[ r >= #{startRow} ]]>
</select>
<resultMap id="PlatPatientResultMap" type="com.lymsh.mommybaby.earlydata.model.PlatPatient">
<result column="P_ID" property="pId" jdbcType="VARCHAR"/>
<result column="P_NAME" property="pName" jdbcType="VARCHAR"/>
<result column="P_SEX" property="pSex" jdbcType="INTEGER"/>
<result column="P_ISVALID" property="pIsvalid" jdbcType="INTEGER"/>
<result column="P_BIRTHDAY" property="pBirthday" jdbcType="TIMESTAMP"/>
<result column="P_MOBILEPHONE" property="pMobilephone" jdbcType="VARCHAR"/>
</resultMap>
<sql id="PlatPatientColumns">
P_ID,P_NAME,P_SEX,P_BIRTHDAY,P_MOBILEPHONE,P_ISVALID
</sql>
<select id="selectPlatPatient" resultMap="PlatPatientResultMap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
select
<include refid="PlatPatientColumns"/>
from (select<include refid="PlatPatientColumns"/>,rownum r
from (
select
<include refid="PlatPatientColumns"/>
from PLAT_PATIENT t
where P_OPERTIME >= #{startTime}
) h where
<![CDATA[ rownum <= #{endRow} ]]>
)
where
<![CDATA[ r >= #{startRow} ]]>
</select>
<select id="selectTable" resultType="hashmap" parameterType="com.lymsh.mommybaby.earlydata.model.OracleCommonQuery">
select
*
from (select h.* ,rownum r
from (
select
t.*
from ${tableName} t
where ${timeColumnName} >= #{startTime} <if test="condition != null and condition != ''"> and ${condition} </if>
) h where
<![CDATA[ rownum <= #{endRow} ]]>
)
where
<![CDATA[ r >= #{startRow} ]]>
</select>
<select id="selectAllByHospitalId" resultType="hashmap" parameterType="map">
select
pp.P_ID,pp.P_NAME,pp.P_SEX,pp.P_BIRTHDAY,pp.P_MOBILEPHONE,pp.P_ISVALID, mp.P_NO,mp.P_OPERUSER,mp.P_TYPE,mp.P_PLATPATIENTID,mp.P_LASTMENSTRUALPERIOD,mp.P_ISVALID,mp.P_SERVICETYPE,mp.P_ISVIP,mp.P_FILINGOPER,
vp.DC_NAME as V_DC_NAME,vp.ME_COLORNAME as V_ME_COLORNAME,vp.FENSHU as V_FENSHU,vp.PI_AGEMONTH,first.*,result.*,pd.dc_name,pd.dc_no,me.me_colorname
from plat_patient pp left join mommy_patient mp on pp.p_id = mp.p_platpatientid left join V_GETALLPATIENT vp on pp.p_id = vp.P_PLATPATIENTID
left join MOMMY_FIRSTEXAMINE first on first.fe_triageorderno = mp.P_NO left join MOMMY_EXAMINERESULT result on result.er_triageorderno = mp.P_NO left join MOMMY_EXAMINWARNING me on (me.me_examinid = first.fe_id or me.me_examinid = result.er_id)
left join PLAT_DATACONTENT pd on me.ME_WORNINGID = pd.DC_Id
where mp.p_hospitalid = #{hospitalId}
<if test="startTime != null">
and (mp.p_opertime >= #{startTime} or first.fe_opertime >= #{startTime} or result.er_opertime >= #{startTime} )
</if>
order by pp.p_id,first.fe_id,result.er_id
</select>
<resultMap id="ViewPatientResultMap" type="com.lymsh.mommybaby.earlydata.model.ViewPatient">
<result column="DC_NAME" property="dcName" jdbcType="VARCHAR"/>
<result column="ME_COLORNAME" property="meColorname" jdbcType="VARCHAR"/>
<result column="PI_AGEMONTH" property="ageMonth" jdbcType="VARCHAR"/>
<result column="FENSHU" property="fenshu" jdbcType="INTEGER"/>
</resultMap>
<select id="selectViewPatient" resultMap="ViewPatientResultMap" parameterType="java.lang.String">
select DC_NAME,ME_COLORNAME,FENSHU,PI_AGEMONTH FROM V_GETALLPATIENT WHERE P_PLATPATIENTID = #{patientId}
</select>
<resultMap id="RiskDetailsResultMap" type="com.lymsh.mommybaby.earlydata.model.ViewPatient">
<result column="DC_NAME" property="dcName" jdbcType="VARCHAR"/>
<result column="ME_COLORNAME" property="meColorname" jdbcType="VARCHAR"/>
<result column="FENSHU" property="fenshu" jdbcType="INTEGER"/>
</resultMap>
<select id="selectRiskDetails" resultMap="RiskDetailsResultMap" parameterType="java.lang.String">
SELECT pd.dc_name as DC_NAME,pd.dc_no as FENSHU,me.me_colorname as ME_COLORNAME FROM MOMMY_EXAMINWARNING ME
LEFT JOIN PLAT_DATACONTENT PD
ON ME.ME_WORNINGID = PD.DC_ID where me.me_examinid = #{examineId}
</select>
<select id="selectOtherRiskDetails" resultMap="RiskDetailsResultMap" parameterType="java.lang.String">
select id as ME_COLORNAME,mo_content as DC_NAME,mo_values as FENSHU from MOMMY_OTHERWORNING where id = #{examineId}
</select>
<select id="selectAllUserByHospitalId" resultType="hashmap" parameterType="map">
select
h.h_id,h.h_name,h.h_helpcode,h.h_introduce,h.h_servicesuffix,h.h_isvalid,h.h_operuser,h.h_des,h.h_provinceno,h.h_cityno,h.h_countyno,h.h_township,h.h_street,h.h_type,h.h_level,h.h_isleader,
d.*,
e.E_ID,e.E_NAME,e.E_SEX,e.E_HOSPITALID,e.E_JOBTITLEID,e.E_DEPTID ,
u.*,
wmsys.wm_concat(r.r_name) over (partition by u.u_id) ur_roleids
from plat_hospital h
left join mommy_dept d on h.h_id = d.d_hospitalid
left join mommy_employee e on e.e_deptid = d.d_id
left join plat_users u on u.u_employeeid = e.e_id
left join plat_userrole ur on ur.ur_userid = u.u_id and ur.ur_roleid is not null and ur.ur_isvalid =1
left join plat_role r on r.r_id = ur.ur_roleid
where u.u_id is not null and h.h_name is not null
<if test="hospitalId != null">
and h.h_id = #{hospitalId}
</if>
<if test="startTime != null">
and (u.u_opertime >= #{startTime} or e.e_opertime >= #{startTime} or d.d_opertime >= #{startTime} )
</if>
order by h.h_id,d.d_id,u.u_id
</select>
<select id="selectAllPuerperaByHospitalId" resultType="hashmap" parameterType="map">
select
ppt.*,mp.*,card.*
from
mommy_patient mp,plat_patient ppt, mommy_visitcard card
where
mp.p_platpatientid = ppt.p_id and card.vc_patientno = mp.p_no
and mp.p_hospitalid is not null and ppt.p_id is not null and mp.p_no is not null and ppt.p_name is not null and mp.P_MOBILEPHONE is not null
and ( floor((sysdate - P_LASTMENSTRUALPERIOD+1)/7) > 41 or ( SELECT COUNT(0) FROM mommy_pregDeliveryrecord pp WHERE pp.PDR_PATIENTID =mp.p_platpatientid)>0 )
<if test="hospitalId != null">
and mp.p_hospitalid = #{hospitalId}
</if>
<if test="startTime != null">
and (mp.p_opertime >= #{startTime} or ppt.p_opertime >= #{startTime} or card.vc_opertime >= #{startTime} )
</if>
order by mp.p_hospitalid,ppt.p_id,mp.p_no
</select>
</mapper>