package thyyxxk.webserver.dao.his.inpatient; import org.apache.ibatis.annotations.*; import org.springframework.web.bind.annotation.RequestParam; import thyyxxk.webserver.entity.dictionary.CodeName; import thyyxxk.webserver.entity.inpatient.ZyActpatient; import thyyxxk.webserver.entity.inpatient.dismiss.ZyDisYbDiag; import thyyxxk.webserver.entity.inpatient.patient.*; import java.util.Date; import java.util.List; @Mapper public interface PatientDao { @Select("select " + "RTRIM(a.bed_no) bedNo, " + "RTRIM(a.inpatient_no) inpatientNo, " + "a.admiss_times, " + "RTRIM(a.name) as name, " + "sex=isnull(a.sex, 9), " + "mdtrtId=(select b.mdtrt_id from t_si_pat_info b where b.pat_no=a.inpatient_no " + "and b.times=a.admiss_times and b.ledger_sn=a.times_billed), " + "injurySerialNo=(select serial_no from t_injury_si_pat_info where pat_no=a.inpatient_no " + "and times=a.admiss_times and ledger_sn=a.times_billed), " + "medType=a.med_type, " + "dismissOrder=(select count(1) from yz_act_order b where b.inpatient_no=a.inpatient_no " + "and b.admiss_times=a.admiss_times and status_flag > '1' and isnull(group_no,'00')='00' " + "and order_code in (select order_code from yz_zd_order_item_confirm where item_name in (N'出院',N'死亡')))," + "orderNoCount = (select count(1) " + " from yz_act_order c " + " where a.inpatient_no = c.inpatient_no " + " and c.admiss_times = a.admiss_times " + " and c.status_flag = '1' " + " and c.enter_oper = #{userCode}), " + " rtrim(refer_physician) refer_physician, " + " (select rtrim(name) from a_employee_mi where code = refer_physician) as refer_physician_name, " + " rtrim(consult_physician) consult_physician, " + " (select rtrim(name) from a_employee_mi where code = consult_physician) as consult_physician_name, " + " rtrim(dept_director) dept_director, " + " (select rtrim(name) from a_employee_mi where code = dept_director) as dept_director_name, " + " total_charge, " + " balance, " + " rtrim(admiss_diag) as admiss_diag, " + " rtrim(admiss_diag_str) as admiss_diag_str, " + " rtrim(clinic_diag_str) as clinic_diag_str, " + " responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type)," + " admiss_date,zkys," + " zkys_name =(select rtrim(name) from a_employee_mi where code = zkys) " + "from zy_actpatient a left join batj_ba2 ba on (a.inpatient_no = ba.zyh and a.admiss_times = ba.zycs) " + "where a.bed_status <> '0' and a.ward like #{ward} ${sql} " + "ORDER BY cast(a.bed_no AS int)") List getOverView(@Param("ward") String ward, @Param("userCode") String userCode, @Param("sql") String sql); @Select("") Patient getPatientInfo(@Param("inpatientNo") String inpatientNo, @Param("table") String table, @Param("times") Integer times); @Select("select max(insuplc_admdvs) from t_si_pat_info where pat_no=#{patNo} " + "and times=#{times} and ledger_sn=#{ledgerSn}") Integer getPatAdmdvs(String patNo, int times, int ledgerSn); @Select("select parent_code from t_region where code=#{code}") Integer selectParentRegion(Integer code); @Select("select dis_diag_no, " + "rtrim(dis_diag) disDiag, " + "rtrim(dis_diag_comment) disDiagComment, " + "dis_diag_status, " + "opName=(select rtrim(name) from a_employee_mi where code=op_id_code) " + "from zy_dis_diag_yb where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}") List getYibaoDisDiags(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select * from zy_dis_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}") List getZyDisYbDiags(@Param("patNo") String patNo, @Param("times") Integer times); @Select("SELECT dis_diag_no, " + "rtrim(dis_diag) disDiag, " + "rtrim(dis_diag_comment) disDiagComment, " + "disDiagStatusName=(select rtrim(name) from zd_dis_diag_status WHERE code=dis_diag_status), " + "opName=(select rtrim(name) from a_employee_mi where code=op_id_code) " + "from ba_first_page1 where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}") List getBingliDisDiags(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select rtrim(inpatient_no) from a_patient_mi where social_no=#{idCard}") List getInpatientNo(@Param("idCard") String idCard); @Select("SELECT item_no, inpatient_no, admiss_times, agency, expirestart, file_sfz " + "FROM zy_xnh_record_sfz WHERE inpatient_no=#{inpatientNo} AND admiss_times=#{admissTimes}") List getIdCard(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select agency, expirestart, sfz_image as fileSfz " + "from patient_mi_sfz where social_no=#{socialNo}") List selectIdCard(@Param("socialNo") String socialNo); @Select("SELECT item_no,inpatient_no,admiss_times,file_xnh AS file_sfz FROM zy_xnh_record " + "WHERE inpatient_no=#{inpatientNo} AND admiss_times=#{admissTimes}") List getScanFile(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select settle_type from zy_ledger_file where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} " + "and ledger_sn=(select isnull(max ( ledger_sn ), min ( ledger_sn )) from zy_ledger_file where " + "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes})") Integer getSettleType(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select count(id) from zy_retract_yb where inpatientNo=#{inpatientNo} " + "and admissTimes=#{admissTimes} and requestType=#{requestType}") Integer getRequestCount(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("requestType") Integer requestType); @Select("select * from zy_retract_yb where inpatientNo=#{inpatientNo} and " + "admissTimes=#{admissTimes} and requestType=#{requestType}") List getRetractRequests(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("requestType") Integer requestType); @Insert("insert into zy_retract_yb (inpatientNo, admissTimes, name, sex, responceType, ybType, treatType, " + "remark, inputId, inputName, inputTimes, statusFlag, requestType) values (#{inpatientNo}, #{admissTimes}, " + "#{name}, #{sex}, #{responceType}, #{ybType}, #{treatType}, #{remark}, #{inputId}, #{inputName}," + "#{inputTimes}, 1, #{requestType})") void submitNewRequest(ToYbkRequest indata); @Select("select isnull(max ( ledger_sn ), isnull(min ( ledger_sn ), 1)) from zy_ledger_file where " + "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}") Integer getLedgerSn(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Update("update zy_actpatient set yb_register_date=#{ybRegisterDate},med_type=#{medType},responce_type=#{responceType}, " + "admdvs=#{admdvs},refer_physician=#{referPhysician},matn_type=#{matnType},latechb_flag=#{latechbFlag}," + "pret_flag=#{pretFlag},dise_code=#{diseCode},dise_name=#{diseName},exp_content=#{expContent},name=#{name}, " + "sex=#{sex} where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}") void updateZyActpatient(Patient param); @Select("select count(1) from batj_ba2 with(nolock) where bah=#{bah} and zycs=#{times}") int isBatjBa2Exist(@Param("bah") String bah, @Param("times") int times); @Insert("insert into batj_ba2 (bah, zyh, zycs, job_nurse) values (#{bah}, #{bah}, #{times}, #{dutyNurse})") void createBatjBa2(@Param("bah") String bah, @Param("times") int times, @Param("dutyNurse") String dutyNurse); @Update("update batj_ba2 set job_nurse=#{dutyNurse} where zyh=#{bah} and zycs=#{times}") void updateBatjBa2(@Param("bah") String bah, @Param("times") int times, @Param("dutyNurse") String dutyNurse); @Update("update a_patient_mi set psn_cert_type=#{psnCertType},social_no=#{socialNo}," + "country=#{country},nation_code=#{nation},relation_name=#{contactName}," + "relation_code=#{contactRelation},relation_street=#{contactAddrName},sex=#{sex}, " + "relation_tel=#{contactPhone},home_tel=#{homeTel} where inpatient_no=#{inpatientNo}") void updateAPatientMi(Patient patient); @Select("select * from zy_in_diag_yb where inpatient_no=#{inpatientNo} and admiss_times=#{times} order by diag_no") List getZyInYbDiag(@Param("inpatientNo") String inpatientNo, @Param("times") Integer times); @Delete("delete from zy_in_diag_yb where inpatient_no=#{inpatientNo} and admiss_times=#{times}") void deleteOldZyInYbDiag(@Param("inpatientNo") String inpatientNo, @Param("times") Integer times); @Insert("") void insertNewZyInYbDiag(@Param("operId") String operId, @Param("list") List list); @Insert("") void insertSiZyInYbDiag(SaveSiZyDiags param); @Select("select convert (varchar(12),dateadd (day,0,start_time),111) from yz_act_order where " + "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and status_flag > '1' " + "and isnull(group_no,'00')='00' and order_code in " + "(select order_code from yz_zd_order_item_confirm where item_name in (N'出院',N'死亡')) ") String getActOrderDisDate(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select act_order_no from yz_sequence") float getActOrderNo(); @Update("update yz_sequence set act_order_no=#{no}") void updateActorOrderNo(float no); @Insert("insert into yz_act_order " + "(act_order_no, inpatient_no, admiss_times, order_code, order_time, frequ_code, enter_time, " + "enter_oper, start_time, end_time, infant_flag, drug_flag, performance_time, " + "physician, confirm_time, signer, status_flag, status_time,drug_specification,order_name,discription, " + "ward_code,dept_code,exec_unit) " + "values (#{actOrderNo}, #{inpatientNo}, #{admissTimes}, " + "(select top 1 order_code from yz_zd_order_item_confirm where item_name=N'出院'), " + "#{dismissOrderDate}, 'ONCE', #{dismissOrderDate},#{staffId}, #{dismissOrderDate}, #{dismissOrderDate}, " + "0, 0, #{dismissOrderDate}, #{staffId},#{dismissOrderDate}, #{staffId}, 5, #{dismissOrderDate}," + "'诊疗项目','今日结账出院','0.00 本项目不包含费用'," + "#{admissWard},#{admissWard},#{admissWard})") void insertNewDismissActOrder(@Param("actOrderNo") float actOrderNo, @Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("dismissOrderDate") Date dismissOrderDate, @Param("staffId") String staffId, @Param("admissWard") String admissWard); @Select("select * from zy_dis_diag_yb where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}") List getDisDiags(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Select("select rtrim(admiss_diag) code,rtrim(admiss_diag_str) name from zy_actpatient where " + "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}") CodeName getAdmissDiag(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes); @Insert("insert into zy_dis_diag_yb (inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, " + "dis_diag_comment, op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, si_diag_type) " + "values (#{inpatientNo}, #{admissTimes}, 1, 13, #{code}, #{name}, #{staffId}, getDate(), '普通', 0, 1)") void insertDisDiag(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("code") String code, @Param("name") String name, @Param("staffId") String staffId); @Insert("") void insertDisDiags(@Param("staffId") String staffId, @Param("list") List list); @Update("update zy_detail_charge set charge_date=#{newDate} where inpatient_no=#{zyh} " + "and admiss_times=#{times} and CONVERT(varchar(20), charge_date, 20) <= #{admdate}") void correctFeeChargeTimeBeforeAdmiss(@Param("zyh") String zyh, @Param("times") int times, @Param("admdate") Date admdate, @Param("newDate") Date newDate); @Select("select start_time from yz_act_order where inpatient_no=#{patNo} and admiss_times=#{times} " + "and status_flag > '1' and isnull(group_no, '00')='00' and order_code in " + "(select order_code from yz_zd_order_item_confirm where item_name in (N'出院',N'死亡'))") Date selectActOrderDisDate(@Param("patNo") String patNo, @Param("times") Integer times); @Update("update zy_detail_charge set charge_date=#{disdate} where inpatient_no=#{zyh} " + "and admiss_times=#{times} and charge_date>#{disdate}") void correctFeeChargeTimeAfterDismiss(@Param("zyh") String zyh, @Param("times") int times, @Param("disdate") Date disdate); @Update("update zy_ledger_file set deposit=(select isnull(sum(depo_amount),0) from zy_deposit_file f with(nolock) " + "where f.inpatient_no=#{zyh} and f.admiss_times=#{times} and f.ledger_sn=#{ledger} and f.status in ('1','2') ) " + "where inpatient_no=#{zyh} and admiss_times=#{times} and ledger_sn=#{ledger} and account_date is null") void recountDeposit(@Param("zyh") String zyh, @Param("times") int times, @Param("ledger") int ledger); @Update("execute zy_receive_drug #{zyh},#{times},#{zyh},#{infant} ") void zyReceiveDrug(@Param("zyh") String zyh, @Param("times") int times, @Param("infant") int infant); @Update("execute zy_receive_one #{zyh},#{times},#{zyh},#{infant} ") void zyReceiveOne(@Param("zyh") String zyh, @Param("times") int times, @Param("infant") int infant); @Update("execute dbo.zy_cngl_fyjs_list_yz #{zyh},#{times} ") void zyCnglFyjsListYz(@Param("zyh") String zyh, @Param("times") int times); @Update("update zy_detail_charge set charge_status='2' where " + "inpatient_no=#{zyh} and admiss_times=#{times} and ledger_sn=#{ledger} ") void updateZyDetailCharge(@Param("zyh") String zyh, @Param("times") int times, @Param("ledger") int ledger); @Update("execute zy_calc_detail_again_new #{zyh},#{times},#{ledger},1,1") void zyCalcDetailAgainNew(@Param("zyh") String zyh, @Param("times") int times, @Param("ledger") int ledger); @Update("update zy_ledger_file set balance=(deposit+isnull(charge_yb,0)-total_charge) where " + "inpatient_no=#{zyh} and admiss_times=#{times} and ledger_sn=#{ledger}") void updateBalance(@Param("zyh") String zyh, @Param("times") int times, @Param("ledger") int ledger); @Select("select balance from zy_ledger_file where inpatient_no=#{zyh} and admiss_times=#{times} and ledger_sn=#{ledger}") String selectLedgerBalance(@Param("zyh") String zyh, @Param("times") int times, @Param("ledger") int ledger); @Update("update zy_actpatient set balance=#{balance} where inpatient_no=#{zyh}") void updateZyActPatientBalance(@Param("zyh") String zyh, @Param("balance") String balance); @Select("select chronic_disease_type " + "from crm_patient_mi " + "where social_no = #{socialNo} ") String getCrmBySocialNo(String socialNo); @Select("select name " + "from crm_zd_visit_type " + "where code in (${typeList})") List getCrmTypeName(String typeList); /** * 查询患者的医保参保地行政区划 * * @param patNo 住院号 * @param times 住院次数 * @param ledgerSn 账页号 * @return 医保参保地行政区划 */ @Select("select insuplc_admdvs from t_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}") String selectInsuplcAdmdvs(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn); /** * 查询患者的取消入院登记次数 * * @param patNo 住院号 * @param times 住院次数 * @param ledgerSn 账页号 * @return 取消入院登记次数 */ @Select("select cance_admiss_count from t_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}") String selectCanceAdmissCount(@Param("patNo") String patNo, @Param("times") Integer times, @Param("ledgerSn") Integer ledgerSn); @Select("select * from zy_actpatient z left join a_patient_mi a on a.inpatient_no=z.inpatient_no where a.social_no=#{socialNo}") ZyActpatient getZyActpatient(@Param("socialNo") String socialNo); }