YpTracCodgDao.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. package thyyxxk.webserver.dao.his.medicine;
  2. import org.apache.ibatis.annotations.Mapper;
  3. import org.apache.ibatis.annotations.Param;
  4. import org.apache.ibatis.annotations.Select;
  5. import org.apache.ibatis.annotations.Update;
  6. import thyyxxk.webserver.entity.datamodify.YpInDetl;
  7. import thyyxxk.webserver.entity.datamodify.YpOutDetl;
  8. import thyyxxk.webserver.entity.medicalinsurance.manage.inventory.InvinfoUpload;
  9. import thyyxxk.webserver.entity.medicalinsurance.manage.inventory.PurcinfoBought;
  10. import thyyxxk.webserver.entity.medicalinsurance.manage.inventory.SelinfoSold;
  11. import thyyxxk.webserver.entity.medicine.YpCodgUpload;
  12. import thyyxxk.webserver.entity.medicine.YpInvinfoModify;
  13. import thyyxxk.webserver.entity.medicine.YpPurcinfoBought;
  14. import thyyxxk.webserver.entity.medicine.YpSelinfoSold;
  15. import java.util.List;
  16. import java.util.Map;
  17. @Mapper
  18. public interface YpTracCodgDao {
  19. @Select(" select group_no as value, group_name as label from yp_zd_group_name where yf_flag = '1' order by group_no ")
  20. List<Map<String, String>> selectGroupNoInfoYf();
  21. @Select(" select group_no as value, group_name as label from yp_zd_group_name where yf_flag = '0' order by group_no ")
  22. List<Map<String, String>> selectGroupNoInfoYk();
  23. @Select(" select ltrim(code) as value, ltrim(name) as label, supply_code as code from yp_zd_supply where isnull(del_flag, '0') = '0' ")
  24. List<Map<String, String>> selectSupplyType();
  25. @Select("<script> " +
  26. " select rtrim(zd.national_code) as medListCodg, rtrim(zd.national_code) as fixmedinsHilistId, rtrim(zd.name) as fixmedinsHilistName, " +
  27. " rtrim(de.in_docu_no) + '_' + cast(de.in_seri as varchar(4)) as fixmedinsBchno, " +
  28. " rtrim(gys.name) as splerName, rtrim(de.manu_no) as manuLotnum, rtrim(cj.name) as prodentpName, rtrim(de.license_no) as aprvno, " +
  29. " convert(varchar(100), de.producing_date, 23) as manuDate, convert(varchar(100), de.eff_date, 23) as expyEnd, de.buy_price as finlTrnsPric, " +
  30. " de.buy_amt as purcRetnCnt, de.fp_no as purcInvoNo, zd.rx_flag as rxFlag, rtrim(zd.name) as chargeName, " +
  31. " convert(varchar(100), de.in_date, 20) as purcRetnStoinTime, rtrim(mi.name) as purcRetnOpterName, " +
  32. " rtrim(de.in_docu_no) as inDocuNo, de.in_seri as inSeri, de.serial, de.group_no " +
  33. " from yp_in_detl de " +
  34. " left join yp_zd_dict zd on de.charge_code = zd.code and de.serial = zd.serial " +
  35. " left join yp_zd_manufactory cj on de.manu_code = cj.code " +
  36. " left join yp_zd_supply gys on de.supply_code = gys.code " +
  37. " left join a_employee_mi mi on de.purchaser = mi.code " +
  38. " where not exists (select 1 from yp_purcinfo_bought bo where bo.upload_flag = '1' " +
  39. " and de.in_docu_no = bo.in_docu_no and de.in_seri = bo.in_seri) " +
  40. " and de.in_docu_no not like 'T%' " +
  41. " and de.in_date &gt;= #{dto.startTime} " +
  42. " and de.in_date &lt;= #{dto.endTime} " +
  43. " and de.group_no = #{dto.groupNo} " +
  44. " <if test=\"dto.docuNo != null and dto.docuNo != ''\"> " +
  45. " and de.in_docu_no = #{dto.inDocuNo} " +
  46. " </if> " +
  47. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  48. " and de.charge_code = #{dto.chargeCode} " +
  49. " </if> " +
  50. " order by de.in_docu_no, de.in_seri " +
  51. "</script>")
  52. List<YpPurcinfoBought> selectYpPurchaseGoodsDetail(@Param("dto") YpCodgUpload dto);
  53. @Select("<script> " +
  54. " select rtrim(zd.national_code) as medListCodg, rtrim(zd.national_code) as fixmedinsHilistId, rtrim(zd.name) as fixmedinsHilistName, " +
  55. " rtrim(de.in_docu_no) + '_' + cast(de.in_seri as varchar(4)) as fixmedinsBchno, " +
  56. " rtrim(gys.name) as splerName, rtrim(de.manu_no) as manuLotnum, rtrim(cj.name) as prodentpName, rtrim(de.license_no) as aprvno, " +
  57. " convert(varchar(100), de.producing_date, 23) as manuDate, convert(varchar(100), de.eff_date, 23) as expyEnd, de.buy_price as finlTrnsPric, " +
  58. " -de.buy_amt as purcRetnCnt, de.fp_no as purcInvoNo, zd.rx_flag as rxFlag, rtrim(zd.name) as chargeName, " +
  59. " convert(varchar(100), de.in_date, 20) as purcRetnStoinTime, rtrim(mi.name) as purcRetnOpterName, " +
  60. " rtrim(de.in_docu_no) as inDocuNo, de.in_seri as inSeri, de.serial, de.group_no " +
  61. " from yp_in_detl de " +
  62. " left join yp_zd_dict zd on de.charge_code = zd.code and de.serial = zd.serial " +
  63. " left join yp_zd_manufactory cj on de.manu_code = cj.code " +
  64. " left join yp_zd_supply gys on de.supply_code = gys.code " +
  65. " left join a_employee_mi mi on de.purchaser = mi.code " +
  66. " where not exists (select 1 from yp_purcinfo_bought bo where bo.upload_flag = '1' " +
  67. " and de.in_docu_no = bo.in_docu_no and de.in_seri = bo.in_seri) " +
  68. " and de.in_docu_no like 'T%' " +
  69. " and de.in_date &gt;= #{dto.startTime} " +
  70. " and de.in_date &lt;= #{dto.endTime} " +
  71. " and de.group_no = #{dto.groupNo} " +
  72. " <if test=\"dto.docuNo != null and dto.docuNo != ''\"> " +
  73. " and de.in_docu_no = #{dto.docuNo} " +
  74. " </if> " +
  75. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  76. " and de.charge_code = #{dto.chargeCode} " +
  77. " </if> " +
  78. " order by de.in_docu_no, de.in_seri " +
  79. "</script>")
  80. List<YpPurcinfoBought> selectYpPurchaseGoodsTkDetail(@Param("dto") YpCodgUpload dto);
  81. @Select(" select count(*) c from yp_in_detl where in_docu_no = #{inDocuNo} and in_seri = #{inSeri} and charge_code = #{chargeCode} and serial = #{serial} ")
  82. int selectYpInvoiceData(@Param("inDocuNo") String inDocuNo, @Param("inSeri") String inSeri, @Param("chargeCode") String chargeCode, @Param("serial") String serial);
  83. @Update(" update yp_in_detl set fp_no = #{fpNo} where in_docu_no = #{inDocuNo} and in_seri = #{inSeri} and charge_code = #{chargeCode} and serial = #{serial} ")
  84. int updateYpInvoice(@Param("inDocuNo") String inDocuNo, @Param("inSeri") String inSeri,
  85. @Param("chargeCode") String chargeCode, @Param("serial") String serial, @Param("fpNo") String fpNo);
  86. @Select(" select top 10 * from yp_in_detl ")
  87. List<SelinfoSold> selectYpSaleGoodsData(@Param("inDocuNo") String inDocuNo, @Param("hisId") String hisId, @Param("hisName") String hisName);
  88. @Select("<script> " +
  89. "select case when yp.national_code = '' then 'NMLC999' else rtrim(isnull(yp.national_code, 'NMLC999')) end as medListCodg, " +
  90. " case when yp.national_code = '' then 'NMLC999' else rtrim(isnull(yp.national_code, 'NMLC999')) end as fixmedinsHilistId, " +
  91. " rtrim(yp.name) as fixmedinsHilistName, " +
  92. " rtrim(fy.patient_id) + '_' + cast(fy.times as varchar(4)) + '_' + cast(fy.receipt_no as varchar(4)) " +
  93. " + cast(fy.order_no as varchar(4)) + cast(fy.item_no as varchar(4)) as fixmedinsBchno, " +
  94. " fy.doctor_name as prscDrName, fy.confirm_name as pharName, mi.yb_code as pharPracCertNo, mi.yb_code as pharNo, " +
  95. " isnull(si.setl_id, (rtrim(fy.patient_id) + '_' + cast(fy.times as varchar(4)))) as setlId, isnull(si.mdtrt_id, (rtrim(fy.patient_id) + '_' + cast(fy.times as varchar(4)))) as mdtrtSn, " +
  96. " case when si.setl_id is null then '2' else '1' end as mdtrtSetlType, mi1.yb_code as prscDrNo, rtrim(fy.patient_id) as rxno, " +
  97. " '' as manuLotnum, '' as manuDate, '' as expyEnd, isnull(yp.rx_flag, '1') as rxFlag, '' as trdnFlag, rtrim(fy.charge_item_code) as chargeCode, " +
  98. " yp.retprice as finlTrnsPric, fy.real_no as rtalDocno, '' as drugTracCodg, isnull(yp.bar_code, 'NDPB999') as drugProdBarc, fy.manu_no as manuNo, " +
  99. " fy.quantity as selRetnCnt, convert(varchar(100), fy.charge_date, 20) as selRetnTime, fy.confirm_name as selRetnOpterName, " +
  100. " rtrim(yp.code) as chargeCode, rtrim(yp.name) as chargeName, fy.serial, rtrim(fy.patient_id) as patNo, fy.times, fy.group_no as groupNo, " +
  101. " fy.receipt_no as receiptNo, fy.order_no as orderNo, fy.item_no as itemNo, fy.serial_no as serialNo, fy.real_no as realNo " +
  102. "from yp_mz_fytj as fy " +
  103. "left join yp_zd_dict as yp on fy.charge_item_code = yp.code and fy.serial = yp.serial " +
  104. "left join a_employee_mi as mi on fy.confirm_id = mi.code " +
  105. "left join a_employee_mi as mi1 on fy.doctor_id = mi1.code " +
  106. "left join t_si_setlinfo as si on si.revoked = '0' and fy.patient_id = si.pat_no and fy.times = si.times " +
  107. "inner join (select distinct patient_id, times, receipt_no, order_no, item_no from mz_drug_trac_codg where flag = '0') as cd " +
  108. " on fy.patient_id = cd.patient_id and fy.times = cd.times " +
  109. "and fy.receipt_no = cd.receipt_no and fy.order_no = cd.order_no and fy.item_no = cd.item_no " +
  110. "where not exists ( select 1 from yp_selinfo_sold so " +
  111. " where so.is_ty = '0' and so.upload_flag = '1' and fy.patient_id = so.pat_no and fy.times = so.times" +
  112. " and fy.receipt_no = so.receipt_no and fy.order_no = so.order_no and fy.item_no = so.item_no )" +
  113. " and fy.confirm_flag in (1, 2) " +
  114. " and fy.charge_date &gt;= #{dto.startTime} " +
  115. " and fy.charge_date &lt;= #{dto.endTime} " +
  116. " and fy.group_no = #{dto.groupNo} " +
  117. " <if test=\"dto.patNo != null and dto.patNo != ''\"> " +
  118. " and fy.patient_id = #{dto.patNo} " +
  119. " </if> " +
  120. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  121. " and fy.charge_item_code = #{dto.chargeCode} " +
  122. " </if> " +
  123. " <if test=\"dto.setlId != null and dto.setlId != ''\"> " +
  124. " and si.setl_id = #{dto.setlId} " +
  125. " </if> " +
  126. " order by fy.charge_date " +
  127. "</script>")
  128. List<YpSelinfoSold> selectYpSelinfoSoldDetailByXyf(@Param("dto") YpCodgUpload dto);
  129. @Select("<script> " +
  130. "select so.* " +
  131. "from yp_selinfo_sold as so, yp_mz_fytj as fy " +
  132. "inner join (select distinct patient_id, times, receipt_no, order_no, item_no from mz_drug_trac_codg_ty where flag = '0') as cd " +
  133. " on fy.patient_id = cd.patient_id and fy.times = cd.times " +
  134. "and fy.receipt_no = -cd.receipt_no and fy.order_no = cd.order_no and fy.item_no = cd.item_no " +
  135. " where so.pat_no = fy.patient_id " +
  136. " and so.times = fy.times " +
  137. " and fy.receipt_no = -so.receipt_no " +
  138. " and fy.order_no = so.order_no " +
  139. " and fy.item_no = so.item_no " +
  140. " and fy.confirm_flag = 3 " +
  141. " and fy.confirm_time &gt;= #{dto.startTime} " +
  142. " and fy.confirm_time &lt;= #{dto.endTime} " +
  143. " and fy.group_no = #{dto.groupNo} " +
  144. " <if test=\"dto.patNo != null and dto.patNo != ''\"> " +
  145. " and so.pat_no = #{dto.patNo} " +
  146. " </if> " +
  147. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  148. " and so.charge_code = #{dto.chargeCode} " +
  149. " </if> " +
  150. " <if test=\"dto.setlId != null and dto.setlId != ''\"> " +
  151. " and so.setl_id = #{dto.setlId} " +
  152. " </if> " +
  153. " order by fy.confirm_time " +
  154. "</script>")
  155. List<YpSelinfoSold> selectYpSelinfoSoldThDetailByXyf(@Param("dto") YpCodgUpload dto);
  156. @Select("<script> " +
  157. "select case when yp.national_code = '' then 'NMLC999' else rtrim(isnull(yp.national_code, 'NMLC999')) end as medListCodg, " +
  158. " case when yp.national_code = '' then 'NMLC999' else rtrim(isnull(yp.national_code, 'NMLC999')) end as fixmedinsHilistId, " +
  159. " rtrim(yp.name) as fixmedinsHilistName, " +
  160. " rtrim(fy.patient_id) + '_' + cast(fy.times as varchar(4)) + '_' + cast(fy.receipt_no as varchar(4)) " +
  161. " + cast(fy.order_no as varchar(4)) + cast(fy.item_no as varchar(4)) as fixmedinsBchno, rtrim(fy.patient_id) as rxno, " +
  162. " fy.doctor_name as prscDrName, fy.confirm_name as pharName, mi.yb_code as pharPracCertNo, mi.yb_code as pharNo, " +
  163. " isnull(si.setl_id, rtrim(fy.patient_id)) as setlId, isnull(si.mdtrt_id, (rtrim(fy.patient_id) + '_' + cast(fy.times as varchar(4)))) as mdtrtSn, " +
  164. " '' as manuLotnum, '' as manuDate, '' as expyEnd, isnull(yp.rx_flag, '1') as rxFlag, '' as trdnFlag, rtrim(fy.charge_item_code) as chargeCode, " +
  165. " yp.retprice as finlTrnsPric, fy.real_no as rtalDocno, '' as drugTracCodg, isnull(yp.bar_code, 'NDPB999') as drugProdBarc, fy.manu_no as manuNo, " +
  166. " fy.quantity as selRetnCnt, convert(varchar(100), fy.charge_date, 20) as selRetnTime, fy.confirm_name as selRetnOpterName, " +
  167. " rtrim(yp.code) as chargeCode, rtrim(yp.name) as chargeName, fy.serial, rtrim(fy.patient_id) as patNo, fy.times, fy.group_no as groupNo, " +
  168. " fy.receipt_no as receiptNo, fy.order_no as orderNo, fy.item_no as itemNo, fy.serial_no as serialNo, fy.real_no as realNo " +
  169. "from yp_mz_fytj as fy " +
  170. "left join yp_zd_dict as yp on fy.charge_item_code = yp.code and fy.serial = yp.serial " +
  171. "left join a_employee_mi as mi on fy.confirm_id = mi.code " +
  172. "left join t_si_setlinfo as si on si.revoked = '0' and fy.patient_id = si.pat_no and fy.times = si.times " +
  173. "inner join (select distinct patient_id, times, receipt_no, order_no, item_no from mz_drug_trac_codg_ty where flag = '0') as cd " +
  174. " on fy.patient_id = cd.patient_id and fy.times = cd.times " +
  175. "and fy.receipt_no = -cd.receipt_no and fy.order_no = cd.order_no and fy.item_no = cd.item_no " +
  176. " where not exists ( select 1 from yp_selinfo_sold so " +
  177. " where so.is_ty = '1' and so.upload_flag = '1' and fy.patient_id = so.pat_no and fy.times = so.times" +
  178. " and fy.receipt_no = so.receipt_no and fy.order_no = so.order_no and fy.item_no = so.item_no )" +
  179. " and fy.confirm_flag = 3 " +
  180. " and fy.confirm_time &gt;= #{dto.startTime} " +
  181. " and fy.confirm_time &lt;= #{dto.endTime} " +
  182. " and fy.group_no = #{dto.groupNo} " +
  183. " <if test=\"dto.patNo != null and dto.patNo != ''\"> " +
  184. " and fy.patient_id = #{dto.patNo} " +
  185. " </if> " +
  186. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  187. " and fy.charge_item_code = #{dto.chargeCode} " +
  188. " </if> " +
  189. " order by fy.confirm_time " +
  190. "</script>")
  191. List<YpSelinfoSold> selectYpSelinfoSoldThDetailByXyfOld(@Param("dto") YpCodgUpload dto);
  192. @Select(" select drug_trac_codg as ypCodg, charge_item_code as chargeCode, convert(varchar(100), confirm_time, 20) as confirmTime from ${tableName} " +
  193. " where flag = '0' and patient_id = #{patNo} and times = #{times} and charge_item_code = #{chargeCode} and serial = #{serial} ")
  194. List<Map<String, String>> selectCodgInfoById(@Param("tableName") String tableName, @Param("patNo") String patNo, @Param("times") Integer times,
  195. @Param("chargeCode") String chargeCode, @Param("serial") String serial);
  196. @Select(" select top 1 * from yp_out_detl where confirm_flag = '1' and out_type = '0' and charge_code = #{chargeCode} and group_no_out = #{groupNo} order by out_date desc ")
  197. YpOutDetl selectCodgInfoManu(@Param("chargeCode") String chargeCode, @Param("groupNo") String groupNo);
  198. @Select(" select top 1 * from yp_in_detl where confirm_flag = '1' and in_type in ('0', '1') and charge_code = #{chargeCode} " +
  199. "and serial = #{serial} and manu_no = #{manuNo} and in_date <= #{confirmTime} order by in_date desc ")
  200. YpInDetl selectCodgInfoProdTime(@Param("chargeCode") String chargeCode, @Param("serial") String serial, @Param("manuNo") String manuNo, @Param("confirmTime") String confirmTime);
  201. @Select("<script> " +
  202. " select case when zd.national_code = '' then 'NMLC999' else rtrim(isnull(zd.national_code, 'NMLC999')) end as medListCodg, " +
  203. " case when zd.national_code = '' then 'NMLC999' else rtrim(isnull(zd.national_code, 'NMLC999')) end as fixmedinsHilistId, " +
  204. " rtrim(zd.name) as fixmedinsHilistName, " +
  205. " rtrim(de.in_docu_no) + '_' + cast(de.in_seri as varchar(4)) as fixmedinsBchno, isnull(de.in_type, '0') as type, " +
  206. " de.buy_price as pric, de.buy_amt as cnt, isnull(zd.rx_flag, '1') as rxFlag, rtrim(zd.name) as chargeName, " +
  207. " convert(varchar(100), de.in_date, 20) as invChgTime, rtrim(mi.name) as invChgOpterName, rtrim(zd.code) as chargeCode, " +
  208. " '0' as trdnFlag, rtrim(de.in_docu_no) as docuNo, de.in_seri as seri, de.serial, de.group_no as groupNo," +
  209. " rtrim(de.manu_no) as manuNo, convert(varchar(100), de.producing_date, 23) as producingDate, " +
  210. " convert(varchar(100), de.eff_date, 23) as effDate " +
  211. " from yp_in_detl as de " +
  212. " left join yp_zd_dict as zd on de.charge_code = zd.code and de.serial = zd.serial " +
  213. " left join a_employee_mi as mi on de.confirm_id = mi.code " +
  214. " where not exists (" +
  215. " select 1 from yp_invinfo_modify mo where mo.upload_flag = '1' " +
  216. " and de.in_docu_no = mo.docu_no and de.in_seri = mo.seri )" +
  217. " and de.confirm_flag = '1' and de.in_type in ('0', '1') " +
  218. " and de.group_no = #{dto.groupNo} " +
  219. " <if test=\"dto.startTime != null and dto.startTime != ''\"> " +
  220. " and de.in_date &gt;= #{dto.startTime} " +
  221. " </if> " +
  222. " <if test=\"dto.endTime != null and dto.endTime != ''\"> " +
  223. " and de.in_date &lt;= #{dto.endTime} " +
  224. " </if> " +
  225. " <if test=\"dto.docuNo != null and dto.docuNo != ''\"> " +
  226. " and de.in_docu_no = #{dto.docuNo} " +
  227. " </if> " +
  228. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  229. " and de.charge_code = #{dto.chargeCode} " +
  230. " </if> " +
  231. " order by de.in_docu_no, de.in_seri " +
  232. "</script>")
  233. List<YpInvinfoModify> selectYpInvinfoModifyDetailRk(@Param("dto") YpCodgUpload dto);
  234. @Select("<script> " +
  235. " select case when zd.national_code = '' then 'NMLC999' else rtrim(isnull(zd.national_code, 'NMLC999')) end as medListCodg, " +
  236. " case when zd.national_code = '' then 'NMLC999' else rtrim(isnull(zd.national_code, 'NMLC999')) end as fixmedinsHilistId, " +
  237. " rtrim(zd.name) as fixmedinsHilistName, " +
  238. " rtrim(de.draw_no) + '_' + cast(de.out_seri as varchar(4)) as fixmedinsBchno, isnull(de.out_type, '0') as type, " +
  239. " de.buy_price as pric, de.out_amt as cnt, isnull(zd.rx_flag, '1') as rxFlag, rtrim(zd.name) as chargeName, " +
  240. " convert(varchar(100), de.out_date, 20) as invChgTime, rtrim(mi.name) as invChgOpterName, rtrim(zd.code) as chargeCode, " +
  241. " '0' as trdnFlag, rtrim(de.draw_no) as docuNo, de.in_seri as seri, de.serial, de.group_no as groupNo " +
  242. " from yp_out_detl as de " +
  243. " left join yp_zd_dict as zd on de.charge_code = zd.code and de.serial = zd.serial " +
  244. " left join a_employee_mi as mi on de.confirm_id = mi.code " +
  245. " where de.confirm_flag = '1' " +
  246. " and de.out_date &gt;= #{dto.startTime} " +
  247. " and de.out_date &lt;= #{dto.endTime} " +
  248. " and de.group_no = #{dto.groupNo} " +
  249. " <if test=\"dto.docuNo != null and dto.docuNo != ''\"> " +
  250. " and de.draw_no = #{dto.docuNo} " +
  251. " </if> " +
  252. " <if test=\"dto.chargeCode != null and dto.chargeCode != ''\"> " +
  253. " and de.charge_code = #{dto.chargeCode} " +
  254. " </if> " +
  255. " order by de.draw_no, de.out_seri " +
  256. "</script>")
  257. List<YpInvinfoModify> selectYpInvinfoModifyDetailCk(@Param("dto") YpCodgUpload dto);
  258. }