<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.business.dao.MedicalRecordsDAO">
	<resultMap id="MedicalRecordsMap" type="com.jpsoft.shinestar.modules.business.entity.MedicalRecords">
		<id property="id" column="id_" />
			<result property="popedomId" column="popedom_id" />
			<result property="hospitalName" column="hospital_name" />
			<result property="hospitalTime" column="hospital_time" />
			<result property="pathogeny" column="pathogeny_" />
			<result property="result" column="result_" />
			<result property="resultImg" column="result_img" />
			<result property="drugs" column="drugs_" />
			<result property="drugsImg" column="drugs_img" />
			<result property="cost" column="cost_" />
			<result property="costImg" column="cost_img" />
			<result property="delFlag" column="del_flag" />
			<result property="createBy" column="create_by" />
			<result property="createTime" column="create_time" />
			<result property="updateBy" column="update_by" />
			<result property="updateTime" column="update_time" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.business.entity.MedicalRecords">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into business_medical_records
	    (id_,popedom_id,hospital_name,hospital_time,pathogeny_,result_,result_img,drugs_,drugs_img,cost_,cost_img,del_flag,create_by,create_time,update_by,update_time)
		values
		(
#{id,jdbcType=VARCHAR}
,#{popedomId,jdbcType=VARCHAR}
,#{hospitalName,jdbcType=VARCHAR}
,#{hospitalTime,jdbcType= TIMESTAMP }
,#{pathogeny,jdbcType=VARCHAR}
,#{result,jdbcType=VARCHAR}
,#{resultImg,jdbcType=VARCHAR}
,#{drugs,jdbcType=VARCHAR}
,#{drugsImg,jdbcType=VARCHAR}
,#{cost,jdbcType= NUMERIC }
,#{costImg,jdbcType=VARCHAR}
,#{delFlag,jdbcType= NUMERIC }
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from business_medical_records where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.business.entity.MedicalRecords">
		update business_medical_records
		<set>
				<if test="popedomId!=null">
					popedom_id=#{popedomId,jdbcType=VARCHAR},
		</if>
				<if test="hospitalName!=null">
		hospital_name=#{hospitalName,jdbcType=VARCHAR},
		</if>
				<if test="hospitalTime!=null">
		hospital_time=#{hospitalTime,jdbcType= TIMESTAMP },
		</if>
				<if test="pathogeny!=null">
		pathogeny_=#{pathogeny,jdbcType=VARCHAR},
		</if>
				<if test="result!=null">
		result_=#{result,jdbcType=VARCHAR},
		</if>
				<if test="resultImg!=null">
		result_img=#{resultImg,jdbcType=VARCHAR},
		</if>
				<if test="drugs!=null">
		drugs_=#{drugs,jdbcType=VARCHAR},
		</if>
				<if test="drugsImg!=null">
		drugs_img=#{drugsImg,jdbcType=VARCHAR},
		</if>
				<if test="cost!=null">
		cost_=#{cost,jdbcType= NUMERIC },
		</if>
				<if test="costImg!=null">
		cost_img=#{costImg,jdbcType=VARCHAR},
		</if>
				<if test="delFlag!=null">
		del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
				<if test="createBy!=null">
		create_by=#{createBy,jdbcType=VARCHAR},
		</if>
				<if test="createTime!=null">
		create_time=#{createTime,jdbcType= TIMESTAMP },
		</if>
				<if test="updateBy!=null">
		update_by=#{updateBy,jdbcType=VARCHAR},
		</if>
				<if test="updateTime!=null">
		update_time=#{updateTime,jdbcType= TIMESTAMP },
		</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="MedicalRecordsMap">
		select 
id_,popedom_id,hospital_name,hospital_time,pathogeny_,result_,result_img,drugs_,drugs_img,cost_,cost_img,del_flag,create_by,create_time,update_by,update_time		from business_medical_records where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from business_medical_records where id_=#{0}
	</select>
	<select id="list" resultMap="MedicalRecordsMap">
		select * from business_medical_records
	</select>
	<select id="search" parameterType="hashmap" resultMap="MedicalRecordsMap">
		<![CDATA[
			select * from business_medical_records
		]]>
		<where>
			del_flag = false
			<if test="searchParams.popedomId != null">
				and popedom_id = #{searchParams.popedomId}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
</mapper>