Просмотр исходного кода

处方分析(新都)- 拼接

guowei 2 лет назад
Родитель
Сommit
79bbfd171e

+ 2 - 2
cbkj_web_api/src/main/resources/mappers/formula/TFormulaMapper.xml

@@ -399,8 +399,8 @@
 
                kc.KUCUNSL,
                kc.LINGSHOUJIA as MAT_XSJ,
-               (select map.YPDM_HIS from t_center_his_mapping map where map.IS_DEL = '0' AND map.YAOPINDM_TY = i.YAOPINDM_TY AND map.YPML_ID_HIS = #{ypmlHis}) YPDM_HIS,
-               (select sum(a.PRE_STOCK) from t_formula_auth a where a.FORMULA_ID = f.FORMULA_ID and a.APP_ID = #{appId} and a.INS_CODE in (#{insCode}, '000000')) PRE_STOCK
+               (select map.YPDM_HIS from t_center_his_mapping map where map.IS_DEL = '0' AND map.YAOPINDM_TY = i.YAOPINDM_TY AND map.YPML_ID_HIS = #{ypmlHis} limit 1) YPDM_HIS,
+               (select sum(a.PRE_STOCK) from t_formula_auth a where a.FORMULA_ID = f.FORMULA_ID ) PRE_STOCK
 
         from t_formula f
         join t_formula_item i on i.FORMULA_ID = f.FORMULA_ID

+ 31 - 12
cbkj_web_api/src/main/resources/mappers/statistics/PrescriptionStatisticsMapper.xml

@@ -63,7 +63,7 @@
         r.PATIENT_ID,
         r.REC_NAME,
         case r.REC_GENDER when 'F' then '女' when 'M' then '男' end REC_GENDER,
-        concat(r.REC_AGE1, r.REC_AGEUNIT1, r.REC_AGE2, r.REC_AGEUNIT2) REC_AGE,
+        CONCAT_WS('', r.REC_AGE1, r.REC_AGEUNIT1, r.REC_AGE2, r.REC_AGEUNIT2) REC_AGE,
         date_format(p.PRE_TIME, '%Y-%m-%d %H:%i:%s') PRE_TIME,
         p.REC_ID,
         p.PRE_ID,
@@ -96,13 +96,13 @@
             when '4' then '适宜技术方'
             when '5' then '制剂'
             end PRE_TYPE,
-<!--        p.PRE_MAT_TYPE,-->
+        p.PRE_MAT_TYPE,
         p.STORE_ID,
         (select DISPLAY_NAME from t_display d where d.STORE_ID = p.STORE_ID limit 1) STORE_NAME,
         case r.REC_TRE_TYPE when '1' then '门诊' when '2' then '住院' end REC_TRE_TYPE,
         CASE p.PRE_TYPE
-            WHEN '1' THEN CONCAT(p.PRE_DESCRIPTION, ',', PRE_FREQUENCY, '每次', PRE_N_ML, 'ml')
-            WHEN '2' THEN CONCAT(p.PRE_SMOKE_TYPE, ',', PRE_FREQUENCY, '每袋', PRE_N_ML, 'ml')
+            WHEN '1' THEN CONCAT_WS(',', p.PRE_DESCRIPTION, PRE_FREQUENCY, CONCAT('每次', PRE_N_ML, 'ml'))
+            WHEN '2' THEN CONCAT_WS(',', p.PRE_SMOKE_TYPE, PRE_FREQUENCY, CONCAT('每袋', PRE_N_ML, 'ml'))
         END PRE_DESCRIPTION,
         p.PRE_NUM,
         p.MAT_TOL_MONEY,
@@ -111,7 +111,7 @@
         i.MAT_DOSE,
         i.BZDW_HIS,
         i.YFMC_HIS,
-        GROUP_CONCAT(i.YPMC_HIS, 0+CAST(i.MAT_DOSE AS CHAR), i.BZDW_HIS, IF(i.YFMC_HIS=NULL OR i.YFMC_HIS='', '', CONCAT('(',i.YFMC_HIS,')'))) mats
+        GROUP_CONCAT(CONCAT_WS('', i.YPMC_HIS, 0+CAST(i.MAT_DOSE AS CHAR), i.BZDW_HIS, CONCAT('(',i.YFMC_HIS,')'))) mats
 
         from t_prescription p
         left join t_record r on r.REC_ID = p.REC_ID
@@ -119,6 +119,7 @@
         left join t_prescription_item i on i.PRE_ID = p.PRE_ID
         <include refid="detailedWhere"/>
         GROUP BY p.PRE_ID
+        order by p.pre_time
         <if test="limit != null">
             limit #{offset}, #{limit}
         </if>
@@ -126,7 +127,7 @@
 
     <sql id="detailedWhere">
         <where>
-            p.is_del = '0'
+            p.is_del = '0' and p.REC_EXT_TYPE >= 50 and p.REC_EXT_TYPE != 110
             <if test="appId != null and appId != ''">
                 and r.APP_ID = #{appId}
             </if>
@@ -184,18 +185,12 @@
             <if test="preOrigin != null and preOrigin != ''">
                 and p.PRE_ORIGIN = #{preOrigin}
             </if>
-            <if test="preType != null and preType != ''">
-                and locate(p.PRE_TYPE, #{preType}) > 0
-            </if>
             <if test="recTreType != null and recTreType != ''">
                 and r.REC_TRE_TYPE = #{recTreType}
             </if>
             <if test="storeId != null and storeId != ''">
                 and p.STORE_ID = #{storeId}
             </if>
-            <if test="preDescription != null and preDescription != ''">
-                and p.PRE_DESCRIPTION like CONCAT('%', #{preDescription}, '%')
-            </if>
             <if test="preNumStart != null and preNumStart != ''">
                 and p.PRE_NUM &gt;= #{preNumStart}
             </if>
@@ -220,6 +215,30 @@
                 or i.YFMC_HIS = #{mats}
                 )
             </if>
+            <choose>
+                <when test="preType != null and preType == '1'.toString()">
+                    and p.PRE_TYPE = '1'
+                    <if test="preDescription != null and preDescription != ''">
+                        and (p.PRE_DESCRIPTION like CONCAT('%', #{preDescription}, '%')
+                        or p.PRE_FREQUENCY like CONCAT('%', #{preDescription}, '%'))
+                    </if>
+                </when>
+                <when test="preType != null and preType == '2'.toString()">
+                    and p.PRE_TYPE = '2'
+                    <if test="preDescription != null and preDescription != ''">
+                        and (p.PRE_SMOKE_TYPE like CONCAT('%', #{preDescription}, '%')
+                        or p.PRE_FREQUENCY like CONCAT('%', #{preDescription}, '%'))
+                    </if>
+                </when>
+                <otherwise>
+                    and locate(p.PRE_TYPE, #{preType}) > 0
+                    <if test="preDescription != null and preDescription != ''">
+                        and (p.PRE_DESCRIPTION like CONCAT('%', #{preDescription}, '%')
+                        or p.PRE_SMOKE_TYPE like CONCAT('%', #{preDescription}, '%')
+                        or p.PRE_FREQUENCY like CONCAT('%', #{preDescription}, '%'))
+                    </if>
+                </otherwise>
+            </choose>
         </where>
     </sql>
 </mapper>