<?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.lemon.lifecenter.mapper.PatientMemoMapper">
	<insert id="insertMemo" parameterType="PatientMemoDTO" useGeneratedKeys="true">
	<![CDATA[
	    INSERT INTO patient_phr_history (patient_idx, contents, written_by, create_date)
       	VALUE (#{patientIdx}, #{contents}, #{writtenBy}, NOW())
	]]>
	</insert>
	 <select id="selectMemoCount" parameterType="PatientMemoDTO" resultType="int">
	<![CDATA[
	    SELECT count(*) AS total
		FROM patient_memo
		WHERE patient_idx = #{patientIdx}
	]]>
    </select>
    <select id="selectMemoList" parameterType="PatientMemoDTO" resultType="PatientMemoDTO">
    <![CDATA[
	    SELECT	create_date			AS createDate,
	    		contents			AS contents,
	    		written_by			AS writtenBy
		FROM patient_memo
		WHERE 
			patient_idx = #{patientIdx}
		AND
			phr_type = #{phrType}
		ORDER BY create_date DESC
	]]>
    </select>
</mapper>