Browse Source

中医病案首页保存功能

lighter 5 months ago
parent
commit
4c977fdbbc

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/inpatient/casefrontsheet/TcmSheetController.java

@@ -30,4 +30,9 @@ public class TcmSheetController {
         }
         return ResultVoUtil.success(response);
     }
+
+    @PostMapping("/saveTcmSheet")
+    public ResultVo<String> saveTcmSheet(@RequestBody TcmFrontSheetMain sheet) {
+        return ResultVoUtil.success(mainService.saveTcmSheet(sheet));
+    }
 }

+ 12 - 0
src/main/java/thyyxxk/webserver/dao/his/inpatient/casefrontsheet/tcmsheet/TcmFrontSheetDisdiagDao.java

@@ -0,0 +1,12 @@
+package thyyxxk.webserver.dao.his.inpatient.casefrontsheet.tcmsheet;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Mapper;
+import thyyxxk.webserver.entity.casefrontsheet.tcmsheet.TcmFrontSheetDisdiag;
+
+@Mapper
+public interface TcmFrontSheetDisdiagDao extends BaseMapper<TcmFrontSheetDisdiag> {
+    @Delete("delete from tcm_front_sheet_disdiag where sheet_id=#{sheetId}")
+    void delOldDiag(String sheetId);
+}

+ 5 - 292
src/main/java/thyyxxk/webserver/dao/his/inpatient/casefrontsheet/tcmsheet/TcmFrontSheetMainDao.java

@@ -19,7 +19,7 @@ import java.util.Map;
 
 @Mapper
 public interface TcmFrontSheetMainDao extends BaseMapper<TcmFrontSheetMain> {
-    @Select("select admiss_date from $table with(nolock) " +
+    @Select("select admiss_date from ${table} with(nolock) " +
             "where inpatient_no=#{patNo} and admiss_times=#{times}")
     Date getAdmDate(String table, String patNo, int times);
 
@@ -52,7 +52,6 @@ public interface TcmFrontSheetMainDao extends BaseMapper<TcmFrontSheetMain> {
             "from ${table} with(nolock) where inpatient_no=#{patNo} and admiss_times=#{times}")
     TcmFrontSheetMain getZyActPatient(String table, String patNo, int times);
 
-
     @Select("select payWay=rtrim(pay_method),infAge=rtrim(age_days),nbWeight1=rtrim(new_born_weight)," +
             "nbAdmWeight=rtrim(new_born_admiss_weight),zyAdmWay=rtrim(rytj)," +
             "conAddr=rtrim(lxdz),conName=rtrim(lxdz2),hpZipCode=rtrim(hkyb) " +
@@ -120,295 +119,9 @@ public interface TcmFrontSheetMainDao extends BaseMapper<TcmFrontSheetMain> {
             "from batj_ba4 with(nolock) where bah=#{patNo} and zycs=#{times} order by ssxh")
     List<TcmFrontSheetSurgery> getSurgeries(String patNo, int times);
 
+    @Select("select * from tcm_front_sheet_disdiag where sheet_id=#{sheetId} ")
+    List<TcmFrontSheetDisdiag> selectSignedSheetDiags(String sheetId);
 
-
-
-
-    @Update("update a_patient_mi set name=#{name}, " +
-            "sex=#{sex}, " +
-            "health_card_no=#{healthCardNo}," +
-            "birth_date=#{birthDate}, " +
-            "country=#{country}, " +
-            "birth_place=#{birthPlace}, " +
-            "nation_code=#{nation}, " +
-            "social_no=#{socialNo}, " +
-            "occupation_code=#{occupation}, " +
-            "marry_code=#{marriage}, " +
-            "home_street=#{livePlace}, " + // max 32 char
-            "home_tel=#{phone}, " +
-            "home_zipcode=#{addrZipCode}, " +
-            "account_street=#{hkPlaceName}, " + // max 20 char
-            "account_zipcode=#{hkZipCode}, " +
-            "employer_name=#{unitName}, " +
-            "employer_street=#{unitPlace}, " + // max 32 char
-            "employer_tel=#{unitPhone}, " +
-            "employer_zipcode=#{unitZipCode}, " +
-            "relation_name=#{contactName}, " +
-            "relation_code=#{contactRelation}, " +
-            "relation_street=#{contactAddrName}, " + // max 32 char
-            "relation_tel=#{contactPhone} " +
-            "where inpatient_no=#{patNo}")
-    void updateAPatientMi(TcmFrontSheetMain sheet);
-
-    @Update("update zy_actpatient set autopsy_mark=#{autopsy},clinic_diag_str=#{clinicDiagStr}, " +
-            "diagnose_conform1=#{dc1},diagnose_conform2=#{dc2},diagnose_conform3=#{dc3}," +
-            "diagnose_conform4=#{dc4}, diagnose_conform5=#{dc5}, operation=#{hasSurgery}," +
-            "pathology_diag_comment=#{pathologicDiagStr},pathology_diag=#{pathologicDiagCode}, " +
-            "clinic_diag=#{clinicDiagCode} where inpatient_no=#{patNo} and admiss_times=#{times}")
-    void updateZyActPatient(String patNo, int times, String autopsy, String dc1, String dc2,
-                            String dc3, String dc4, String dc5, String hasSurgery,
-                            String pathologicDiagStr, String pathologicDiagCode,
-                            String clinicDiagCode, String clinicDiagStr);
-
-    @Update("update zy_inactpatient set autopsy_mark=#{autopsy},clinic_diag_str=#{clinicDiagStr}, " +
-            "diagnose_conform1=#{dc1},diagnose_conform2=#{dc2},diagnose_conform3=#{dc3}," +
-            "diagnose_conform4=#{dc4}, diagnose_conform5=#{dc5}, operation=#{hasSurgery}," +
-            "pathology_diag_comment=#{pathologicDiagStr},pathology_diag=#{pathologicDiagCode}, " +
-            "clinic_diag=#{clinicDiagCode} where inpatient_no=#{patNo} and admiss_times=#{times}")
-    void updateZyInActPatient(String patNo, int times, String autopsy, String dc1, String dc2,
-                              String dc3, String dc4, String dc5, String hasSurgery,
-                              String pathologicDiagStr, String pathologicDiagCode,
-                              String clinicDiagCode, String clinicDiagStr);
-
-
-    @Select("select count(1) from batj_ba2 with(nolock) where bah=#{patNo} and zycs=#{times}")
-    int isBatjBa2Exist(String patNo, int times);
-
-    @Insert("insert into batj_ba1 (bah, zyh, zycs, xm, ryrq, ryks, rybf) values " +
-            "(#{patNo}, #{patNo}, #{times}, #{name}, #{ryrq}, " +
-            "(select code from zd_unit_code with(nolock) where name=#{dept} and isnull(del_flag,'')!='1'), " +
-            "(select code from zd_unit_code with(nolock) where name=#{ward} and isnull(del_flag,'')!='1'))")
-    void createBatjBa1(String patNo, int times, String name, Date ryrq, String dept, String ward);
-
-    @Insert("insert into batj_ba2 (bah, zyh, zycs) values (#{patNo}, #{patNo}, #{times})")
-    void createBatjBa2(String patNo, int times);
-
-    @Insert("insert into t_frontsheet_supplement (bah, times) values (#{patNo}, #{times})")
-    void createSheetSupplement(String patNo, int times);
-
-    @Update("update batj_ba1 set " +
-            "pay_method=#{payMethod}," +
-            "age_days=#{ageDays}," +
-            "jg=#{nativePlace}," +
-            "new_born_weight=#{newBornWeight}," +
-            "new_born_admiss_weight=#{newBornAdmissWeight}," +
-            "xm=#{name}, " +
-            "xb=#{sex}, " +
-            "csrq=#{birthDate}, " +
-            "hyzk=#{marriage}, " +
-            "zy=#{occupation}, " +
-            "csd=#{birthPlace}, " +
-            "mz=#{nation}, " +
-            "gj=#{country}, " +
-            "sfzh=#{socialNo}, " +
-            "gzdw=#{unitName}, " +
-            "gzdh=#{unitPhone}, " +
-            "gzyb=#{unitZipCode}, " +
-            "hkdz=#{hkPlace}, " +
-            "hkdz2=#{hkPlaceName}," +
-            "hkyb=#{hkZipCode}, " +
-            "lxr=#{contactName}, " +
-            "lxrgx=#{contactRelation}, " +
-            "lxdh=#{contactPhone}, " +
-            "lxdz=#{contactAddr}, " +
-            "lxdz2=#{contactAddrName}," +
-            "rytj=#{zyAdmissWay}, " +
-            "xzz=#{livePlace}, " +
-            "xdh=#{phone} " +
-            "where bah=#{patNo} and zycs=#{admissTimes}")
-    void updateBatjBa1(TcmFrontSheetMain info);
-
-    @Update("update batj_ba2 set " +
-            "blzd_qph=#{blh}," +
-            "gm_flag=#{allergy}," +
-            "gmwy=#{allergicMedicine}," +
-            "hbsag=#{hbsAg}," +
-            "hcv_vb=#{hcvAb}," +
-            "hiv_vb=#{hivAb}," +
-            "tp_ab=#{tpAb}," +
-            "xx=#{bloodType}," +
-            "xx_rh=#{rh}," +
-            "kzr=#{deptLeader}," +
-            "zrys=#{leaderDoctor}," +
-            "zzys=#{mainDoctor}," +
-            "zyys=#{admissDoctor}," +
-            "job_nurse=#{dutyNurse}," +
-            "jxys=#{studyDoctor}," +
-            "sxys=#{internshipDoctor}," +
-            "bmy=#{coder}," +
-            "bazl=#{qualityControlLevel}," +
-            "zkys=#{qualityControlDoctor}," +
-            "zkhs=#{qualityControlNurse}," +
-            "barq=#{qualityControlDate}," +
-            "lyfs=#{zyDismissWay}," +
-            "jsjg=#{dismissDestination}," +
-            "zzy_flag=#{admissAgainInOneMonth}," +
-            "zzy_md=#{admissAgainPurpose}," +
-            "ryq_hmsj_day=#{comaDaysBeforeAdmiss}," +
-            "ryq_hmsj_hour=#{comaHoursBeforeAdmiss}," +
-            "ryq_hmsj_min=#{comaMinutesBeforeAdmiss}," +
-            "ryh_hmsj_day=#{comaDaysAfterAdmiss}," +
-            "ryh_hmsj_hour=#{comaHoursAfterAdmiss}," +
-            "ryh_hmsj_min=#{comaMinutesAfterAdmiss}," +
-            "qjcs=#{rescueTimes}," +
-            "cgcs=#{rescueSuccessTimes}," +
-            "blfx=#{caseClassification}," +
-            "zzjh=#{hasIcu}," +
-            "zzjh_day=#{icuDays}," +
-            "zzjh_hour=#{icuHours}," +
-            "dbz=#{monopathyManagement}," +
-            "lclj=#{clinicalPathwayManagement}," +
-            "drgs=#{drgsManagement}," +
-            "kss=#{useAntibiotic}," +
-            "xjpy=#{bacilliculture}," +
-            "fdcrb=#{statutoryEpidemic}," +
-            "hurt_reason_name=#{hurtReasonName}," +
-            "hurt_reason_code=#{hurtReasonCode}," +
-            "tumor_level_t=#{tumorLevelT}," +
-            "tumor_level_n=#{tumorLevelN}," +
-            "tumor_level_m=#{tumorLevelM}," +
-            "tumor_level=#{tumorLevel}, " +
-            "apgar=#{xxeApgar} " +
-            "where bah=#{patNo} and zycs=#{admissTimes}")
-    void updateBatjBa2(TcmFrontSheetMain info);
-
-    @Delete("delete from ba_first_page1 where inpatient_no=#{patNo} and admiss_times=#{times}")
-    void deleteOldDisdiag(String patNo, int times);
-
-    @Delete("delete from batj_ba4 where bah=#{patNo} and zycs=#{times}")
-    void deleteOldSurgeryRecord(String patNo, int times);
-
-    @Insert("insert into ba_op_log (op_type, op_id, op_time, inpatient_no, admiss_times) values " +
-            "(#{opType}, #{staffId}, getDate(), #{patNo}, #{times})")
-    void writeBaOpLog(int opType, String staffId, String patNo, int times);
-
-    @Select("select rtrim(dis_diag_no) no, rtrim(dis_diag) code, " +
-            "rtrim(dis_diag_comment) name, rtrim(dis_diag_status) cyzg, " +
-            "rtrim(op_id_code) operId, convert(varchar(19), op_diag_date, 21) opDate, " +
-            "diagType='13',si_diag_type,bzfx='普通', admiss_cond " +
-            "from zy_dis_diag_yb with(nolock) where inpatient_no=#{patNo} and admiss_times=#{times}")
-    List<YiBaoDisdiag> getYbDiags(String patNo, int times);
-
-    @Delete("delete from zy_dis_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}")
-    void deleteOldYbDiag(String patNo, int times);
-
-    @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, admiss_cond) " +
-            "values (#{patNo},#{times},#{no},13,#{code},#{name},#{operId},#{opDate},'普通',#{cyzg},#{siDiagType},#{admissCond})    ")
-    void insertNewYbDiag(YiBaoDisdiag diag);
-
-
-    @Select("select file_status from t_case_frontsheet_main with(nolock) where bah=#{patNo} and admiss_times=#{times}")
-    Integer selectFileStatus(String patNo, int times);
-
-    @Select("select min(op_time) from ba_op_log with(nolock) where " +
-            "inpatient_no=#{patNo} and admiss_times=#{times} and op_type=2")
-    Date selectFirstSignDate(String patNo, int times);
-
-    @Select("select sign_staff from t_case_frontsheet_main with(nolock) where bah=#{patNo} and admiss_times=#{times}")
-    String selectSignStaff(String patNo, int times);
-
-    @Select("select role_id from dj_user_role where user_code=#{code}")
-    List<Integer> getUserRoles(String code);
-
-    @Select("select count(1) from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times}")
-    Integer selectModified(String patNo, int times);
-
-    @Select("select top 1 * from t_si_disefamily_diagnose with(nolock) where dise_code=#{code} ")
-    DisefamilyGrade selectDisefamilyGrade(String code);
-
-    @Select("select yb_code from zd_icd9_cm3 where code in " +
-            "(select ssbm from ${table} with(nolock) where zyh=#{patNo} and zycs=#{times} and isnull(ssbm,'')!='') " +
-            "union select ssbm from ${table} with(nolock) where zyh=#{patNo} and zycs=#{times} and isnull(ssbm,'')!=''")
-    List<String> selectPatientSurgeryCodes(String patNo, int times, String table);
-
-    @Select("select *, " +
-            "duplicated=(select count(1) from t_case_frontsheet_duplicate where bah=#{patNo} and times=#{times})," +
-            "lendout=(select count(1) from t_case_frontsheet_lendout where bah=#{patNo} and times=#{times} and state='LEND_OUT')," +
-            "closedown=(select count(1) from t_case_frontsheet_closedown where bah=#{patNo} and times=#{times}) " +
-            "from t_case_frontsheet_main where bah=#{patNo} and admiss_times=#{times} and file_status=1")
-    TcmFrontSheetMain selectStoredSheetMain(String patNo, int times);
-
-    @Select("select * from tcm_front_sheet_disdiag where bah=#{patNo} and times=#{times} ")
-    List<TcmFrontSheetDisdiag> selectSignedSheetDiags(String patNo, int times);
-
-    @Select("select * from tcm_front_sheet_surgery where bah=#{patNo} and times=#{times} ")
-    List<TcmFrontSheetSurgery> selectSignedSheetSurgeries(String patNo, int times);
-
-    @Update("update t_case_frontsheet_main set age_days=#{agedays} where bah=#{patNo} and admiss_times=#{times}")
-    void updateNewBornAge(String patNo, int times, Integer agedays);
-
-    @Select("select rtrim(yb_code) as code, rtrim(yb_name) as name from zd_icd_code_new where code=#{code} and del_flag=0")
-    CodeName selectSiDiagByBaDiag(String code);
-
-    @Select("select province_code,city_code,district_code," +
-            "provinceName=(select name from t_region where code=province_code), " +
-            "cityName=(select name from t_region where code=city_code), " +
-            "districtName=(select name from t_region where code=district_code) " +
-            "from a_patient_mi where inpatient_no=#{patNo}")
-    StandardAddressMember selectStandardAddressMember(String patNo);
-
-    @Select("select rtrim(social_no) from a_patient_mi where inpatient_no=#{patNo}")
-    String selectSocialNo(String patNo);
-
-    @Select("select parent_code as code, name=(select t.name from t_region t where t.code=a.parent_code) " +
-            "from t_region a where code=#{region}")
-    Region selectParentRegion(Integer region);
-
-    @Select("select name from t_region where code=#{region}")
-    String selectRegionName(Integer region);
-
-    @Select("select name from zd_district_code where code=#{code}")
-    String getDistrictName(String code);
-
-    @Select("select top 1 med_type from t_si_pat_info where pat_no=#{patNo} and times=#{times} order by " +
-            "ledger_sn desc")
-    String selectMedType(String patNo, int times);
-
-    @Select("select provinceName=(select name from t_region where code=#{province}), " +
-            "cityName=(select name from t_region where code=#{city}), " +
-            "districtName=(select name from t_region where code=#{district}) ")
-    StandardAddressMember selectStandardAddressMember2(int province, int city, int district);
-
-    @Select("select audit_flag from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times} ")
-    Integer qualityPass(String patNo, int times);
-
-    @Select("<script>" +
-            "select rtrim(yb_code) as code,rtrim(yb_name) as name,charge_code as wjwCode," +
-            "charge_name as wjwName from zd_icd9_cm3 where yb_code in " +
-            "<foreach collection='surgeries' item='surgery' open='(' separator=',' close=')'>" +
-            "#{surgery.code}" +
-            "</foreach>" +
-            "</script>")
-    List<HisWjwMatchEntity> selectSurgeryChargeCode(List<CaseFrontsheetSurgery> surgeries);
-
-    @Select("<script>" +
-            "select sum(charge_amount) from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} " +
-            "and charge_code_mx in " +
-            "<foreach collection='list' item='code' open='(' separator=',' close=')'>" +
-            "#{code}" +
-            "</foreach>" +
-            "</script>")
-    Integer selectChargeSumamt(String patNo, int times, String[] list);
-
-    @Select("select code,yb_name as name,yb_code from zd_anaesthesia where yb_code is not null")
-    List<CodeName> selectZdAnstWays();
-
-    @Select("select code,rtrim(name) as name,si_code as ybCode from zd_country_code where si_code is not null")
-    List<CodeName> selectZdCountries();
-
-    @Select("select code,rtrim(name) as name,code2 as ybCode from zd_nation_code where code2 is not null ")
-    List<CodeName> selectZdNations();
-
-    @Select("select top 1 insuplc_admdvs from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
-    String selectSetlInsuplcAdmdvs(String patNo, int times);
-
-    @Select("select top 1 isnull(op_type,9) from zd_icd9_cm3 where yb_code=#{code}")
-    Integer selectOperationType(String code);
-
-    int selectAntibiotics(String patNo, int times);
-
-    @Select("select top 1 audit_state from t_frontsheet_quality_verification " +
-            "where pat_no=#{patNo} and times=#{times} order by application_time desc ")
-    AuditState selectStates(String patNo, int times);
+    @Select("select * from tcm_front_sheet_surgery where sheet_id=#{sheetId} ")
+    List<TcmFrontSheetSurgery> selectSignedSheetSurgeries(String sheetId);
 }

+ 12 - 0
src/main/java/thyyxxk/webserver/dao/his/inpatient/casefrontsheet/tcmsheet/TcmFrontSheetSurgeryDao.java

@@ -0,0 +1,12 @@
+package thyyxxk.webserver.dao.his.inpatient.casefrontsheet.tcmsheet;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Mapper;
+import thyyxxk.webserver.entity.casefrontsheet.tcmsheet.TcmFrontSheetSurgery;
+
+@Mapper
+public interface TcmFrontSheetSurgeryDao extends BaseMapper<TcmFrontSheetSurgery> {
+    @Delete("delete from tcm_front_sheet_surgery where sheet_id=#{sheetId}")
+    void delOldSurgery(String sheetId);
+}

+ 12 - 4
src/main/java/thyyxxk/webserver/dao/his/search/SearchDao.java

@@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 
-
 @Mapper
 public interface SearchDao {
     @Select("select rtrim(code) as code,rtrim(name) as name, " +
@@ -21,9 +20,6 @@ public interface SearchDao {
     @Select("select distinct rtrim(yb_code) as code, rtrim(yb_name) as name from zd_icd_code_new where ${method} like #{content} and del_flag=0")
     IPage<CodeName> searchSiDiagnose(IPage<CodeName> iPage, String method, String content);
 
-    @Select("select rtrim(yb_code) as code, rtrim(yb_name) as name from zd_icd9_cm3 where ${method} like #{content} and del_flag=0")
-    IPage<CodeName> searchYbSurgeries(IPage<CodeName> iPage, String method, String content);
-
     @Select("select distinct rtrim(code) as code, rtrim(name) as name from zd_icd_code_new where ${method} like #{content} and del_flag=0")
     IPage<CodeName> searchIcd10Diagnose(IPage<CodeName> iPage, String method, String content);
 
@@ -33,6 +29,14 @@ public interface SearchDao {
     @Select("select distinct code,name from t_zd_injury_icd where ${method} like #{content}")
     IPage<CodeName> searchInjurydiag(IPage<CodeName> iPage, String method, String content);
 
+    @Select("select rtrim(code) as code, rtrim(name) as name from zd_icd_code_new with(nolock) " +
+            "where PATINDEX('%[V-Y]%',code)=1 and ${method} like #{content} ")
+    IPage<CodeName> searchHurtReason(IPage<CodeName> iPage, String method, String content);
+
+    @Select("select rtrim(code) as code, rtrim(name) as name from zd_icd_m_code with(nolock) " +
+            "where ${method} like #{content} ")
+    IPage<CodeName> searchPthDiag(IPage<CodeName> iPage, String method, String content);
+
     @Select("SELECT RTRIM(code) as code,rtrim(name) as name," +
             "gender_restriction,min_age_restriction,max_age_restriction " +
             "from ${table} where isnull(del_flag,0)!=1 and isnull(mz_flag,0)!=1 " +
@@ -48,4 +52,8 @@ public interface SearchDao {
             "opTypeName=(select rtrim(d.name) from zd_operation_type d where d.code=op_type) " +
             "from zd_icd9_cm3 where del_flag!=1 and ${method} like #{content}")
     IPage<CodeName> searchIcd9Cm3(IPage<CodeName> iPage, String method, String content);
+
+    @Select("select rtrim(yb_code) as code, rtrim(yb_name) as name " +
+            "from zd_icd9_cm3 where ${method} like #{content} and del_flag=0")
+    IPage<CodeName> searchYbSurgeries(IPage<CodeName> iPage, String method, String content);
 }

+ 5 - 5
src/main/java/thyyxxk/webserver/entity/casefrontsheet/tcmsheet/TcmFrontSheetMain.java

@@ -324,15 +324,15 @@ public class TcmFrontSheetMain {
     // 抢救成功次数
     private Integer rescueSuccessTimes;
     // 同城互认 - 无
-    private String tchrw;
+    private Boolean tchrw;
     // 同城互认 - 影像检查
-    private String tchryxjc;
+    private Boolean tchryxjc;
     // 同城互认 - 检验检查
-    private String tchrjyjc;
+    private Boolean tchrjyjc;
     // 同城互认 - 病理检查
-    private String tchrbljc;
+    private Boolean tchrbljc;
     // 同城互认 - 其他
-    private String tchrqt;
+    private Boolean tchrqt;
 
     @TableField(exist = false)
     private List<TcmFrontSheetDisdiag> disdiagList;

+ 106 - 26
src/main/java/thyyxxk/webserver/service/inpatient/casefrontsheet/tcm/TcmSheetMainService.java

@@ -7,16 +7,21 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.BizException;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.inpatient.casefrontsheet.CaseFrontSheetDao;
+import thyyxxk.webserver.dao.his.inpatient.casefrontsheet.tcmsheet.TcmFrontSheetDisdiagDao;
 import thyyxxk.webserver.dao.his.inpatient.casefrontsheet.tcmsheet.TcmFrontSheetMainDao;
+import thyyxxk.webserver.dao.his.inpatient.casefrontsheet.tcmsheet.TcmFrontSheetSurgeryDao;
 import thyyxxk.webserver.entity.casefrontsheet.request.SheetOverview;
 import thyyxxk.webserver.entity.casefrontsheet.state.State;
 import thyyxxk.webserver.entity.casefrontsheet.tcmsheet.TcmFrontSheetDisdiag;
+import thyyxxk.webserver.entity.casefrontsheet.tcmsheet.TcmFrontSheetIcuinfo;
 import thyyxxk.webserver.entity.casefrontsheet.tcmsheet.TcmFrontSheetMain;
 import thyyxxk.webserver.entity.casefrontsheet.tcmsheet.TcmFrontSheetSurgery;
 import thyyxxk.webserver.entity.dictionary.CodeName;
+import thyyxxk.webserver.service.hutoolcache.DeptCache;
 import thyyxxk.webserver.utils.*;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -25,17 +30,23 @@ import java.util.List;
 public class TcmSheetMainService {
     private final CaseFrontSheetDao wstSheetDao;
     private final TcmFrontSheetMainDao tcmSheetDao;
+    private final TcmFrontSheetDisdiagDao diagDao;
+    private final TcmFrontSheetSurgeryDao surgeryDao;
+    private final DeptCache deptCache;
 
     @Autowired
-    public TcmSheetMainService(CaseFrontSheetDao wstSheetDao, TcmFrontSheetMainDao tcmSheetDao) {
+    public TcmSheetMainService(CaseFrontSheetDao wstSheetDao, TcmFrontSheetMainDao tcmSheetDao, TcmFrontSheetDisdiagDao diagDao, TcmFrontSheetSurgeryDao surgeryDao, DeptCache deptCache) {
         this.wstSheetDao = wstSheetDao;
         this.tcmSheetDao = tcmSheetDao;
+        this.diagDao = diagDao;
+        this.surgeryDao = surgeryDao;
+        this.deptCache = deptCache;
     }
 
     public TcmFrontSheetMain getSheetInfo(SheetOverview ov) {
         QueryWrapper<TcmFrontSheetMain> wrapper = new QueryWrapper<>();
         wrapper.eq("pat_no", ov.getPatNo());
-        wrapper.eq("ov.getTimes()", ov.getTimes());
+        wrapper.eq("times", ov.getTimes());
         TcmFrontSheetMain sheet = tcmSheetDao.selectOne(wrapper);
 
         Date admdate = tcmSheetDao.getAdmDate("zy_actpatient", ov.getPatNo(), ov.getTimes());
@@ -46,21 +57,13 @@ public class TcmSheetMainService {
         if (null != sheet) {
             sheet.setDisdiagList(getSheetDisDiags(sheet.getId(), ov));
             sheet.setSurgeryList(getSheetSurgeries(sheet.getId(), ov));
+            sheet.setIcuInfoList(getSheetIcuinfos(sheet.getId(), ov));
             if (null == sheet.getDismissDay()) {
                 Date disdate = wstSheetDao.getDismissDateFromYzActOrder("yz_act_order", ov.getPatNo(), ov.getTimes());
                 if (null == disdate) {
                     disdate = wstSheetDao.getDismissDateFromYzActOrder("yz_inact_order", ov.getPatNo(), ov.getTimes());
                 }
-                if (null != disdate) {
-                    int days = DateUtil.daysBetween(disdate, admdate);
-                    sheet.setInHospDays(0 == days ? 1 : days);
-                    String disdateStr = DateUtil.formatDatetime(disdate, "yyyy-MM-dd-HH-mm-ss");
-                    String[] disdateArr = disdateStr.split("-");
-                    sheet.setDismissYear(Integer.parseInt(disdateArr[0]));
-                    sheet.setDismissMonth(Integer.parseInt(disdateArr[1]));
-                    sheet.setDismissDay(Integer.parseInt(disdateArr[2]));
-                    sheet.setDismissHour(Integer.parseInt(disdateArr[3]));
-                }
+                fillDisdate(sheet, admdate, disdate);
             }
             return sheet;
         }
@@ -100,16 +103,7 @@ public class TcmSheetMainService {
             final Date disdate = inHospital == State.InHospital.YES ?
                     wstSheetDao.getDismissDateFromYzActOrder("yz_inact_order", ov.getPatNo(), ov.getTimes())
                     : wstSheetDao.getDismissDateFromYzActOrder("yz_act_order", ov.getPatNo(), ov.getTimes());
-            if (null != disdate) {
-                int days = DateUtil.daysBetween(disdate, admdate);
-                sheet.setInHospDays(0 == days ? 1 : days);
-                String disdateStr = DateUtil.formatDatetime(disdate, "yyyy-MM-dd-HH-mm-ss");
-                String[] disdateArr = disdateStr.split("-");
-                sheet.setDismissYear(Integer.parseInt(disdateArr[0]));
-                sheet.setDismissMonth(Integer.parseInt(disdateArr[1]));
-                sheet.setDismissDay(Integer.parseInt(disdateArr[2]));
-                sheet.setDismissHour(Integer.parseInt(disdateArr[3]));
-            }
+            fillDisdate(sheet, admdate, disdate);
         }
         TcmFrontSheetMain sheet2 = tcmSheetDao.getBatjBa1(ov.getPatNo(), ov.getTimes());
         if (sheet2 == null && wstSheetDao.isBatjBa1Exist(ov.getPatNo(), ov.getTimes()) == 0) {
@@ -134,11 +128,28 @@ public class TcmSheetMainService {
         FrontSheetUtil.mergeObject(sheet2, sheet);
         FrontSheetUtil.mergeObject(sheet3, sheet);
 
+        if (null == sheet.getAdmissYear()) {
+            String admdateStr = DateUtil.formatDatetime(admdate, "yyyy-MM-dd-HH-mm-ss");
+            String[] admdateArr = admdateStr.split("-");
+            sheet.setAdmissYear(Integer.parseInt(admdateArr[0]));
+            sheet.setAdmissMonth(Integer.parseInt(admdateArr[1]));
+            sheet.setAdmissDay(Integer.parseInt(admdateArr[2]));
+            sheet.setAdmissHour(Integer.parseInt(admdateArr[3]));
+        }
+
+        sheet.setAdmissDeptName(deptCache.getDeptName(sheet.getAdmissDept()));
+        sheet.setAdmissWardName(deptCache.getDeptName(sheet.getAdmissWard()));
+        sheet.setTransDeptName(deptCache.getDeptName(sheet.getTransDept()));
+        sheet.setDismissDeptName(deptCache.getDeptName(sheet.getDismissDept()));
+        sheet.setDismissWardName(deptCache.getDeptName(sheet.getDismissWard()));
+
         sheet.setDisdiagList(getSheetDisDiags(null, ov));
         sheet.setSurgeryList(getSheetSurgeries(null, ov));
+        sheet.setIcuInfoList(getSheetIcuinfos(null, ov));
         List<CodeName> patCharges = tcmSheetDao.selectPatCharges(ov.getPatNo(), ov.getTimes());
         for (CodeName item : patCharges) {
-            String code = String.valueOf(item.getCode().charAt(0)).toUpperCase() + item.getCode().substring(1);
+            String fst = String.valueOf(item.getCode().charAt(0)).toUpperCase();
+            String code = fst + item.getCode().substring(1);
             try {
                 Method m = sheet.getClass().getMethod("set" + code, String.class);
                 m.invoke(sheet, item.getName());
@@ -150,9 +161,22 @@ public class TcmSheetMainService {
         return sheet;
     }
 
+    private void fillDisdate(TcmFrontSheetMain sheet, Date admdate, Date disdate) {
+        if (null != disdate) {
+            int days = DateUtil.daysBetween(disdate, admdate);
+            sheet.setInHospDays(0 == days ? 1 : days);
+            String disdateStr = DateUtil.formatDatetime(disdate, "yyyy-MM-dd-HH-mm-ss");
+            String[] disdateArr = disdateStr.split("-");
+            sheet.setDismissYear(Integer.parseInt(disdateArr[0]));
+            sheet.setDismissMonth(Integer.parseInt(disdateArr[1]));
+            sheet.setDismissDay(Integer.parseInt(disdateArr[2]));
+            sheet.setDismissHour(Integer.parseInt(disdateArr[3]));
+        }
+    }
+
     private List<TcmFrontSheetDisdiag> getSheetDisDiags(String sheetId, SheetOverview ov) {
         List<TcmFrontSheetDisdiag> disdiags = null != sheetId ?
-                tcmSheetDao.selectSignedSheetDiags(ov.getPatNo(), ov.getTimes()) :
+                tcmSheetDao.selectSignedSheetDiags(sheetId) :
                 tcmSheetDao.getDisdiags(ov.getPatNo(), ov.getTimes());
         while (disdiags.size() < 6) {
             disdiags.add(new TcmFrontSheetDisdiag());
@@ -161,12 +185,68 @@ public class TcmSheetMainService {
     }
 
     private List<TcmFrontSheetSurgery> getSheetSurgeries(String sheetId, SheetOverview ov) {
-        List<TcmFrontSheetSurgery> surgeries = null == sheetId ?
-                tcmSheetDao.selectSignedSheetSurgeries(ov.getPatNo(), ov.getTimes()) :
+        List<TcmFrontSheetSurgery> surgeries = null != sheetId ?
+                tcmSheetDao.selectSignedSheetSurgeries(sheetId) :
                 tcmSheetDao.getSurgeries(ov.getPatNo(), ov.getTimes());
         while (surgeries.size() < 7) {
             surgeries.add(new TcmFrontSheetSurgery());
         }
         return surgeries;
     }
+
+    private List<TcmFrontSheetIcuinfo> getSheetIcuinfos(String sheetId, SheetOverview ov) {
+        List<TcmFrontSheetIcuinfo> icuinfos = new ArrayList<>();
+        while (icuinfos.size() < 3) {
+            icuinfos.add(new TcmFrontSheetIcuinfo());
+        }
+        return icuinfos;
+    }
+
+    public String saveTcmSheet(TcmFrontSheetMain sheet) {
+        if (StringUtil.isBlank(sheet.getId())) {
+            sheet.setId(SnowFlakeId.instance().nextId());
+            tcmSheetDao.insert(sheet);
+        } else {
+            tcmSheetDao.updateById(sheet);
+        }
+        dealDisdiags(sheet);
+        dealSurgeries(sheet);
+        return sheet.getId();
+    }
+
+    private void dealDisdiags(TcmFrontSheetMain sheet) {
+        List<TcmFrontSheetDisdiag> rawDiagList = sheet.getDisdiagList();
+        List<TcmFrontSheetDisdiag> tmpDiagList = new ArrayList<>();
+        for (int i = 0; i < rawDiagList.size(); i++) {
+            TcmFrontSheetDisdiag diag = rawDiagList.get(i);
+            if (StringUtil.isBlank(diag.getTcmCode()) && StringUtil.isBlank(diag.getWstCode())) {
+                break;
+            }
+            diag.setId(SnowFlakeId.instance().nextId());
+            diag.setSheetId(sheet.getId());
+            tmpDiagList.add(diag);
+        }
+        diagDao.delOldDiag(sheet.getId());
+        if (!tmpDiagList.isEmpty()) {
+            diagDao.insert(tmpDiagList);
+        }
+    }
+
+    private void dealSurgeries(TcmFrontSheetMain sheet) {
+        List<TcmFrontSheetSurgery> rawSurgeries = sheet.getSurgeryList();
+        List<TcmFrontSheetSurgery> tmpSurgeries = new ArrayList<>();
+        for (int i = 0; i < rawSurgeries.size(); i++) {
+            TcmFrontSheetSurgery surgery = rawSurgeries.get(i);
+            if (StringUtil.isBlank(surgery.getCode())) {
+                break;
+            }
+            surgery.setId(SnowFlakeId.instance().nextId());
+            surgery.setSheetId(sheet.getId());
+            tmpSurgeries.add(surgery);
+        }
+        surgeryDao.delOldSurgery(sheet.getId());
+        if (!tmpSurgeries.isEmpty()) {
+            surgeryDao.insert(tmpSurgeries);
+        }
+    }
 }

+ 30 - 2
src/main/java/thyyxxk/webserver/service/search/SearchService.java

@@ -32,11 +32,14 @@ public class SearchService {
             case "icd10":
                 iPage = deepinIcd10Diag(params.getMethod(), params.getContent(), iPage);
                 break;
+            case "tcmDiag":
+                iPage = deepinTcmDiag(params.getMethod(), params.getContent(), iPage);
+                break;
             case "diag":
                 iPage = deepinSiDiag(params.getMethod(), params.getContent(), iPage);
                 break;
             case "surgery":
-                iPage = deepinSurgery(params.getMethod(), params.getContent(), iPage);
+                iPage = deepinYbSurgery(params.getMethod(), params.getContent(), iPage);
                 break;
             case "slwspcdiag":
                 iPage = deepinSlwSpcDiag(params.getContent(), params.getPerstype(), iPage);
@@ -59,6 +62,12 @@ public class SearchService {
             case "dept":
                 iPage = deepinDept(params.getMethod(), params.getContent(), iPage);
                 break;
+            case "hurtReason":
+                iPage = deepinHurtReason(params.getMethod(), params.getContent(), iPage);
+                break;
+            case "pthDiag":
+                iPage = deepinPthDiag(params.getMethod(), params.getContent(), iPage);
+                break;
         }
         if (iPage.getTotal() > 0) {
             Map<String, Object> map = new HashMap<>();
@@ -115,7 +124,7 @@ public class SearchService {
         return dao.searchSiDiagnose(iPage, column, content);
     }
 
-    private IPage<CodeName> deepinSurgery(String method, String content, IPage<CodeName> iPage) {
+    private IPage<CodeName> deepinYbSurgery(String method, String content, IPage<CodeName> iPage) {
         content = '%' + content.toUpperCase() + '%';
         String column = filterCommonColumn(method);
         return dao.searchYbSurgeries(iPage, column, content);
@@ -127,6 +136,13 @@ public class SearchService {
         return dao.searchIcd10Diagnose(iPage, column, content);
     }
 
+    private IPage<CodeName> deepinTcmDiag(String method, String content, IPage<CodeName> iPage) {
+        content = '%' + content.toUpperCase() + '%';
+        String column = filterCommonColumn(method);
+        // todo 换成 查询中医诊断表
+        return dao.searchIcd10Diagnose(iPage, column, content);
+    }
+
     private IPage<CodeName> deepinSlwSpcDiag(String content, Integer perstype, IPage<CodeName> iPage) {
         content = "%" + content + "%";
         if (null == perstype) {
@@ -143,6 +159,18 @@ public class SearchService {
         return dao.searchInjurydiag(iPage, column, content);
     }
 
+    private IPage<CodeName> deepinHurtReason(String method, String content, IPage<CodeName> iPage) {
+        content = '%' + content.toUpperCase() + '%';
+        String column = filterCommonColumn(method);
+        return dao.searchHurtReason(iPage, column, content);
+    }
+
+    private IPage<CodeName> deepinPthDiag(String method, String content, IPage<CodeName> iPage) {
+        content = '%' + content.toUpperCase() + '%';
+        String column = filterCommonColumn(method);
+        return dao.searchPthDiag(iPage, column, content);
+    }
+
     private String filterCommonColumn(String method) {
         switch (method) {
             case "alpha":