|
@@ -37,62 +37,55 @@ public interface YfDrugApplyMapper {
|
|
|
" location=b.location," +
|
|
|
" b.max_stock_amount," +
|
|
|
" b.mini_stock_amount," +
|
|
|
- " three_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)," +
|
|
|
- " seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 7 then 0 else quantity end),2),0)," +
|
|
|
- " fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end),2),0)," +
|
|
|
- " thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 30 then 0 else quantity end),2),0)," +
|
|
|
+ " three_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 3 then 0 else quantity end),2),0)," +
|
|
|
+ " seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 7 then 0 else quantity end),2),0)," +
|
|
|
+ " fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 14 then 0 else quantity end),2),0)," +
|
|
|
+ " thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 30 then 0 else quantity end),2),0)," +
|
|
|
" available_day=" +
|
|
|
- " case when max(isnull(b.stock_amount,0))=0 or isnull(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),0)=0" +
|
|
|
+ " case when max(isnull(b.stock_amount,0))=0 or isnull(sum(case when datediff(day,confirm_time,getdate()) > 3 then 0 else quantity end),0)=0" +
|
|
|
" then 0 " +
|
|
|
- " else round(max(isnull(b.stock_amount,0))/(isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 3 then 0 else quantity end),2),0)/3),2) end" +
|
|
|
- " FROM yp_zd_dict a WITH(NOLOCK) ,yp_base_yf b WITH(NOLOCK),yp_base dd WITH(NOLOCK)," +
|
|
|
- " (select c.name,a.charge_item_code code,c.serial,a.confirm_time," +
|
|
|
- " round(sum(case when a.serial <![CDATA[<]]> c.serial then quantity*cy_fy/pack_size else quantity*cy_fy end),2) quantity" +
|
|
|
+ " else round(max(isnull(b.stock_amount,0))/(isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 3 then 0 else quantity end),2),0)/3),2) end" +
|
|
|
+ " FROM yp_zd_dict a WITH(NOLOCK) inner join yp_base_yf b WITH(NOLOCK) " +
|
|
|
+ " on a.code=b.charge_code and a.serial=b.serial and b.group_no=#{groupNo} " +
|
|
|
+ " left join yp_base dd WITH(NOLOCK) " +
|
|
|
+ " on a.code =dd.charge_code and a.serial =dd.serial and dd.group_no = case when b.group_no='81' then '22' else '11' end " +
|
|
|
+ " left join (select c.name,a.charge_item_code code,c.serial,a.confirm_time," +
|
|
|
+ " round(sum(case when a.serial < c.serial then quantity*cy_fy/pack_size else quantity*cy_fy end),2) quantity" +
|
|
|
" from yp_mz_fytj a WITH(NOLOCK)," +
|
|
|
" (select a.name,a.code,a.serial,a.specification,a.pack_size" +
|
|
|
" from yp_zd_dict a WITH(NOLOCK),(select code,max(serial) serial" +
|
|
|
" from yp_zd_dict WITH(NOLOCK) group by code) b" +
|
|
|
" where a.code=b.code and a.serial=b.serial) c" +
|
|
|
- " where a.charge_item_code=c.code and datediff(day,confirm_time,getdate()) <![CDATA[<]]> 61 and group_no =#{groupNo}" +
|
|
|
+ " where a.charge_item_code=c.code and datediff(day,confirm_time,getdate()) < 61 and group_no =#{groupNo}" +
|
|
|
" group by c.name,a.charge_item_code,c.serial,a.confirm_time" +
|
|
|
" union all" +
|
|
|
" select" +
|
|
|
" c.name,a.charge_code code,c.serial,a.confirm_time," +
|
|
|
- " round(sum(case when a.serial <![CDATA[<]]> c.serial then amount/pack_size else amount end),2) quantity" +
|
|
|
+ " round(sum(case when a.serial < c.serial then amount/pack_size else amount end),2) quantity" +
|
|
|
" from yp_zy_patient a WITH(NOLOCK)," +
|
|
|
" (select a.name,a.code,a.serial,a.specification,a.pack_size" +
|
|
|
" from yp_zd_dict a WITH(NOLOCK),(select code,max(serial) serial" +
|
|
|
" from yp_zd_dict WITH(NOLOCK) group by code) b" +
|
|
|
" where a.code=b.code and a.serial=b.serial) c" +
|
|
|
- " where a.charge_code=c.code and datediff(day,confirm_time,getdate()) <![CDATA[<]]> 61 and acct_sign=2 and group_no =#{groupNo}" +
|
|
|
- " group by c.name,a.charge_code,c.serial,a.confirm_time) aa," +
|
|
|
- " (select c.name,a.charge_code,c.serial," +
|
|
|
+ " where a.charge_code=c.code and datediff(day,confirm_time,getdate()) < 61 and acct_sign=2 and group_no =#{groupNo}" +
|
|
|
+ " group by c.name,a.charge_code,c.serial,a.confirm_time) aa " +
|
|
|
+ " on a.code = aa.code and a.serial = aa.serial " +
|
|
|
+ " left join (select c.name,a.charge_code,c.serial," +
|
|
|
" case when a.group_no='81' then '22' else '11' end group_no," +
|
|
|
- " round(sum(case when a.serial <![CDATA[<]]> c.serial then stock_amount/pack_size else stock_amount end),2) stock_amount" +
|
|
|
+ " round(sum(case when a.serial < c.serial then stock_amount/pack_size else stock_amount end),2) stock_amount" +
|
|
|
" from yp_base_yf a WITH(NOLOCK)," +
|
|
|
" (select a.name,a.code,a.serial,a.specification,a.pack_size" +
|
|
|
" from yp_zd_dict a WITH(NOLOCK),(select code,max(serial) serial" +
|
|
|
" from yp_zd_dict WITH(NOLOCK) group by code) b" +
|
|
|
" where a.code=b.code and a.serial=b.serial) c" +
|
|
|
- " where a.charge_code=c.code and a.group_no <![CDATA[<>]]> '91' and a.group_no =#{groupNo}" +
|
|
|
+ " where a.charge_code=c.code and a.group_no <> '91' and a.group_no =#{groupNo}" +
|
|
|
" group by c.name,a.charge_code,c.serial,(case when a.group_no='81' then '22' else'11' end)) bb" +
|
|
|
- " where a.code=b.charge_code and" +
|
|
|
- " a.serial=b.serial and" +
|
|
|
- " b.group_no=#{groupNo} and" +
|
|
|
- " a.code*=aa.code and" +
|
|
|
- " a.serial*=aa.serial and" +
|
|
|
- " a.code*=dd.charge_code and" +
|
|
|
- " a.serial*=dd.serial and" +
|
|
|
- " dd.group_no = case when b.group_no='81' then '22' else '11' end and" +
|
|
|
- " a.code*=bb.charge_code and" +
|
|
|
- " a.serial*=bb.serial and" +
|
|
|
- " (a.py_code like '${searchText}%' or" +
|
|
|
- " a.d_code like '${searchText}%' or" +
|
|
|
- " a.code like '${searchText}%' or" +
|
|
|
- " a.name like '${searchText}%') and" +
|
|
|
- " isnull(a.visible_flag,'0') <![CDATA[<>]]> '1' and" +
|
|
|
- " isnull(a.del_flag,'0') <![CDATA[<>]]> '1'" +
|
|
|
- " and (isnull(b.visible_flag_mz,'0') <![CDATA[<>]]> '1' and isnull(b.visible_flag_zy,'0') <![CDATA[<>]]> '1')" +
|
|
|
+ " on a.code = bb.charge_code and a.serial = bb.serial " +
|
|
|
+ " where (a.py_code like '${searchText}%' or a.d_code like '${searchText}%' " +
|
|
|
+ " or a.code like '${searchText}%' or a.name like '${searchText}%') " +
|
|
|
+ " and isnull(a.visible_flag,'0') <> '1' " +
|
|
|
+ " and isnull(a.del_flag,'0') <> '1' " +
|
|
|
+ " and (isnull(b.visible_flag_mz,'0') <> '1' and isnull(b.visible_flag_zy,'0') <> '1') " +
|
|
|
" group by b.charge_code," +
|
|
|
" a.name," +
|
|
|
" b.serial," +
|
|
@@ -151,7 +144,7 @@ public interface YfDrugApplyMapper {
|
|
|
" b.charge_code =#{chargeCode} and " +
|
|
|
" </when>" +
|
|
|
" <when test='beyondFlag==1'>"+
|
|
|
- " b.mini_stock_amount <![CDATA[>]]> b.stock_amount and " +
|
|
|
+ " b.mini_stock_amount > b.stock_amount and " +
|
|
|
" </when>" +
|
|
|
" b.group_no=#{groupNo} and" +
|
|
|
" isnull(b.visible_flag,'0')=#{visibleFlag} and" +
|
|
@@ -178,7 +171,7 @@ public interface YfDrugApplyMapper {
|
|
|
" b.charge_code =#{chargeCode} and " +
|
|
|
" </when>" +
|
|
|
" <when test='beyondFlag==1'>"+
|
|
|
- " b.mini_stock_amount <![CDATA[>]]> b.stock_amount and " +
|
|
|
+ " b.mini_stock_amount > b.stock_amount and " +
|
|
|
" </when>" +
|
|
|
" b.group_no=#{groupNo} and " +
|
|
|
" isnull(b.visible_flag,'0')=#{visibleFlag} and " +
|
|
@@ -194,10 +187,10 @@ public interface YfDrugApplyMapper {
|
|
|
*/
|
|
|
@Select("<script>" +
|
|
|
"select\n" +
|
|
|
- " seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 7 then 0 else quantity end),2),0),\n" +
|
|
|
- " fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 14 then 0 else quantity end),2),0),\n" +
|
|
|
- " thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 30 then 0 else quantity end),2),0),\n" +
|
|
|
- " sixty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) <![CDATA[>]]> 60 then 0 else quantity end),2),0)\n" +
|
|
|
+ " seven_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 7 then 0 else quantity end),2),0),\n" +
|
|
|
+ " fourteen_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 14 then 0 else quantity end),2),0),\n" +
|
|
|
+ " thirty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 30 then 0 else quantity end),2),0),\n" +
|
|
|
+ " sixty_day_dosage=isnull(round(sum(case when datediff(day,confirm_time,getdate()) > 60 then 0 else quantity end),2),0)\n" +
|
|
|
"from (\n" +
|
|
|
"select\n" +
|
|
|
" (case\n" +
|
|
@@ -213,7 +206,7 @@ public interface YfDrugApplyMapper {
|
|
|
" and d.serial='99'\n" +
|
|
|
" where\n" +
|
|
|
" p.charge_code=#{chargeCode}\n" +
|
|
|
- " and datediff(day,confirm_time,getdate()) <![CDATA[<=]]> 60\n" +
|
|
|
+ " and datediff(day,confirm_time,getdate()) <= 60\n" +
|
|
|
" union all\n" +
|
|
|
"select\n" +
|
|
|
" (case\n" +
|
|
@@ -229,7 +222,7 @@ public interface YfDrugApplyMapper {
|
|
|
" and d.serial='99'\n" +
|
|
|
" where\n" +
|
|
|
" f.charge_item_code=#{chargeCode}\n" +
|
|
|
- " and datediff(day,confirm_time,getdate()) <![CDATA[<=]]> 60)a" +
|
|
|
+ " and datediff(day,confirm_time,getdate()) <= 60)a" +
|
|
|
"</script>")
|
|
|
YpBaseBoundVo selectSumQuantity(@Param("chargeCode") String chargeCode);
|
|
|
}
|