Browse Source

门诊预约以及代码优化

xiaochan 2 years ago
parent
commit
00448463f2

+ 54 - 0
src/main/java/thyyxxk/webserver/controller/outpatientBooking/OutpatientBookingController.java

@@ -0,0 +1,54 @@
+package thyyxxk.webserver.controller.outpatientBooking;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.Post;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.service.outpatientBooking.OutpatientBookingService;
+
+@RestController
+@RequestMapping("/outpatientBooking")
+public class OutpatientBookingController {
+    private final OutpatientBookingService service;
+
+    public OutpatientBookingController(OutpatientBookingService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/getAmpmByDateAndDeptCode")
+    public ResultVo<JSONArray> getAmpmByDateAndDeptCode(@RequestParam("date") String date,
+                                                        @RequestParam("deptCode") String deptCode) {
+        return service.getAmpmByDateAndDeptCode(date, deptCode);
+    }
+
+    @GetMapping("/getChargeTypeByRequestDayAndDoctor")
+    public ResultVo<JSONArray> getChargeTypeByRequestDayAndDoctor(@RequestParam("unitCode") String unitCode,
+                                                                  @RequestParam("ampm") String ampm,
+                                                                  @RequestParam("date") String date,
+                                                                  @RequestParam("apTime") String apTime) {
+        return service.getChargeTypeByRequestDayAndDoctor(unitCode, ampm, date, apTime);
+    }
+
+    @GetMapping("/getDoctorCodeByRequestDayAndDoctor")
+    public ResultVo<JSONArray> getDoctorCodeByRequestDayAndDoctor(@RequestParam("unitCode") String unitCode,
+                                                                  @RequestParam("ampm") String ampm,
+                                                                  @RequestParam("date") String date,
+                                                                  @RequestParam("apTime") String apTime,
+                                                                  @RequestParam("chargeType") String chargeType) {
+        return service.getDoctorCodeByRequestDayAndDoctor(unitCode, ampm, date, apTime, chargeType);
+    }
+
+    @GetMapping("/getMzChargeTypeByMzyRequestId")
+    public ResultVo<JSONObject> getMzChargeTypeByMzyRequestId(@RequestParam("mzyRequestId") String mzyRequestId,
+                                                              @RequestParam("birthDay") String birthDay,
+                                                              @RequestParam("patientId") String patientId) {
+        return service.getMzChargeTypeByMzyRequestId(mzyRequestId, birthDay, patientId);
+    }
+
+    @PostMapping("/saveMzyReqrec")
+    public ResultVo<String> saveMzyReqrec(@RequestBody JSONObject req) {
+        return service.saveMzyReqrec(req);
+    }
+
+}

+ 2 - 1
src/main/java/thyyxxk/webserver/dao/his/inpatient/PatientDao.java

@@ -45,8 +45,9 @@ public interface PatientDao {
 
     @Select("<script>" +
             "select inpatientNo=rtrim(a.inpatient_no),a.admiss_times,a.med_type,b.social_no,dis_date," +
+            "mz_no = (select rtrim(mz_no) from a_patient_mi where a_patient_mi.inpatient_no  = a.inpatient_no)," +
             "zk_ward,zk_ward_name = (select rtrim(name) from zd_unit_code where code=zk_ward), " +
-            "name=rtrim(a.name),sex=isnull(a.sex, b.sex),act_ipt_days=(datediff(day, admiss_date, getdate())), " +
+            "name=rtrim(a.name),sex=isnull(a.sex, b.sex),act_ipt_days=(datediff(day, admiss_date, isnull(dis_date,getdate()))), " +
             "birthDate=(convert(varchar(10), birth_date, 21)),home_tel=rtrim(b.home_tel), " +
             "admissPhysician=rtrim(a.admiss_physician),b.psn_cert_type, " +
             "insutype=(select top 1 insutype from t_si_pat_info with(nolock) where pat_no=#{inpatientNo} and " +

+ 3 - 1
src/main/java/thyyxxk/webserver/dao/his/inpatient/TransferInOfExpensesDao.java

@@ -124,7 +124,9 @@ public interface TransferInOfExpensesDao {
             "  and a.receipt_no = b.receipt_no " +
             "  and a.serial_no = b.serial_no " +
             "  and a.charge_item_code = c.charge_code " +
-            "  and a.serial = c.serial")
+            "  and a.serial = c.serial" +
+            "  and a.group_no = c.group_no " +
+            "  and isnull(a.group_no, '00') <> '00' ")
     List<MzChargeDetail> getSerialNo(@Param("mzTableName") String mzTableName,
                                      @Param("tableName") String tableName,
                                      @Param("serialNo") Integer serialNo);

+ 13 - 16
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/JianYanJianChaDao.java

@@ -316,7 +316,7 @@ public interface JianYanJianChaDao {
             "values " +
             "<foreach collection='list' item='item' separator=','>" +
             "(#{item.reqNo}, #{inpatientNo}, #{name}, #{age}, #{admissTimes}, #{bedNo}, #{item.orderName}, " +
-            "        #{item.actOrderNo}, #{item.orderCode}, #{item.orderName}, #{item.reqNo}, #{item.reqComment}, #{userCode}, " +
+            "        #{item.actOrderNo}, #{item.orderCode}, cast(#{item.orderName} as varchar(60)) , #{item.reqNo}, #{item.reqComment}, #{userCode}, " +
             "        #{deptCode}, #{wardCode}, #{item.execDept}, #{reqDate}, '1', #{reqType}, #{reqDate}, #{item.startTime},#{item.diagCode},#{item.diagText}, " +
             "        (select class from ${orderTypeTable} where zy_order_code = #{item.orderCode})," +
             "       #{item.jzFlag},#{item.reqTzComment},#{item.reqOtherResult}," +
@@ -483,21 +483,18 @@ public interface JianYanJianChaDao {
      *
      * @return
      */
-    @Select("select distinct        rtrim(zy_order_code) as code, " +
-            "                       rtrim(name)          as name, " +
-            "                       rtrim(class)         as classes, " +
-            "                       exec_unit, " +
-            "    exec_unit_name   = (select name from zd_unit_code where zd_unit_code.code = exec_unit), " +
-            "                       '2'                  as type, " +
-            "                       inspect_stuff        as inspectStuff, " +
-            "    inspectStuffName = (select rtrim(name) from jy_zd_sample with (NOLOCK) where code = inspect_stuff) " +
-            "from jy_zd_item a, " +
-            "     zy_tc_detail_yj b " +
-            "where isnull(del_flag, '0') = '0' " +
-            "  and isnull(zy_flag, '0') = '0' " +
-            "  and a.zy_order_code = b.order_code " +
-            "  and inspect_stuff is not null " +
-            "  and nullif(exec_unit, '') is not null")
+    @Select("select distinct        rtrim(zy_order_code) as code,  " +
+            "                       rtrim(name)          as name,  " +
+            "                       rtrim(class)         as classes,  " +
+            "                       exec_unit,  " +
+            "    exec_unit_name   = (select name from zd_unit_code where zd_unit_code.code = exec_unit),  " +
+            "                       '2'                  as type,  " +
+            "                       inspect_stuff        as inspectStuff,  " +
+            "    inspectStuffName = (select rtrim(name) from jy_zd_sample with (NOLOCK) where code = inspect_stuff)  " +
+            "from jy_zd_item a  " +
+            "         left join zy_tc_detail_yj b on (a.zy_order_code = b.order_code)  " +
+            "where isnull(del_flag, '0') = '0'  " +
+            "  and isnull(zy_flag, '0') = '0'")
     List<JyJcItem> getJyDetailedItems();
 
 

+ 1 - 1
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -433,7 +433,7 @@ public interface YiZhuLuRuDao {
             "inpatient_no = #{patNo} and " +
             "admiss_times = #{times} and " +
             "act_order_no = #{orderNo} and " +
-            "charge_status = '1'")
+            "charge_status = '3'")
     Integer getADoctorSOrderWithADefiniteFee(String patNo,
                                              Integer times,
                                              String orderNo);

+ 1 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/patient/Patient.java

@@ -25,6 +25,7 @@ public class Patient {
     private String staffId;
     private String psnCertType;
     private String socialNo;
+    private String mzNo;
     private String name;
     private Integer sex;
     @DateTimeFormat(pattern = "yyyy-MM-dd")

+ 25 - 1
src/main/java/thyyxxk/webserver/scheduled/FetchAccessTokenTask.java

@@ -7,6 +7,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import thyyxxk.webserver.entity.WeComTokens;
 import thyyxxk.webserver.service.externalhttp.CorpWxSrvc;
+import thyyxxk.webserver.service.externalhttp.OutpatientBookingHttp;
 import thyyxxk.webserver.utils.Md5Util;
 import thyyxxk.webserver.utils.TokenUtil;
 
@@ -15,16 +16,20 @@ import thyyxxk.webserver.utils.TokenUtil;
 @Component
 public class FetchAccessTokenTask {
     private final CorpWxSrvc srvc;
+    private final OutpatientBookingHttp outpatientBookingHttp;
+
     private static final String USERINFO_SECRET = "wpHuNePfiDyotmpXjy5hUYGF0w8Ks5OPHSQp22z8oBk";
     private static final String CLOCKIN_SECRET = "_DodO23wewvESf-Lt-K46O2OsZ_nwrNhCbGaj0gbFjQ";
     private static final String HRG_SECRET = "xYHIiJldL1cn5-RbsyV2VIq505_22_3JY-U_gYpQ4hE";
     private final static String LIS_DOCK_APP_ID = "jkzd5e26bf01c5a0d79";
     private final static String LIS_DOCK_SECRET = "957a642f1dae09fd226a3517a465";
     private static volatile boolean TOKEN_SYNCED = false;
+    public static String THMZ_TOKEN = "";
 
     @Autowired
-    public FetchAccessTokenTask(CorpWxSrvc srvc) {
+    public FetchAccessTokenTask(CorpWxSrvc srvc, OutpatientBookingHttp outpatientBookingHttp) {
         this.srvc = srvc;
+        this.outpatientBookingHttp = outpatientBookingHttp;
     }
 
     @Scheduled(fixedRate = 6900 * 1000)
@@ -60,4 +65,23 @@ public class FetchAccessTokenTask {
         sign[1] = Md5Util.encrypt(Md5Util.encrypt(ori));
         TokenUtil.setLisDockSign(sign);
     }
+
+    @Scheduled(fixedRate = 30 * 60 * 1000)
+    public void getThmzToken() {
+        JSONObject param = new JSONObject();
+        param.put("userCode", "9995");
+        param.put("password", "1");
+        JSONObject js = outpatientBookingHttp.getToken(param);
+
+        if (js.getInteger("code").equals(0)) {
+            THMZ_TOKEN = js.getString("token");
+        }
+        log.info("门诊登录:{} ", js);
+
+        JSONObject re = outpatientBookingHttp.getAmpmByDateAndDeptCode(FetchAccessTokenTask.THMZ_TOKEN, "2023-06-01", "1002030");
+        log.info("测试:{}", re);
+
+    }
+
+
 }

+ 43 - 0
src/main/java/thyyxxk/webserver/service/externalhttp/OutpatientBookingHttp.java

@@ -0,0 +1,43 @@
+package thyyxxk.webserver.service.externalhttp;
+
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.*;
+
+
+//@BaseRequest(baseURL = "http://172.16.30.33:8089/thmz")
+@BaseRequest(baseURL = "http://webhis.thyy.cn:81/thmz")
+public interface OutpatientBookingHttp {
+
+    @Post("/login")
+    JSONObject getToken(@JSONBody JSONObject js);
+
+    @Get("/getAmpmByDateAndDeptCode?date={date}&deptCode={deptCode}")
+    JSONObject getAmpmByDateAndDeptCode(@Header("Authorization") String Authorization,
+                                        @Var("date") String date,
+                                        @Var("deptCode") String deptCode);
+
+    @Get("/getChargeTypeByRequestDayAndDoctor?unitCode={unitCode}&ampm={ampm}&date={date}&apTime={apTime}&doctorCode={}")
+    JSONObject getChargeTypeByRequestDayAndDoctor(@Header("Authorization") String Authorization,
+                                                  @Var("unitCode") String unitCode,
+                                                  @Var("ampm") String ampm,
+                                                  @Var("date") String date,
+                                                  @Var("apTime") String apTime);
+
+    @Get("/getDoctorCodeByRequestDayAndDoctor?unitCode={unitCode}&ampm={ampm}&chargeType={chargeType}&date={date}&apTime={apTime}")
+    JSONObject getDoctorCodeByRequestDayAndDoctor(@Header("Authorization") String Authorization,
+                                                  @Var("unitCode") String unitCode,
+                                                  @Var("ampm") String ampm,
+                                                  @Var("date") String date,
+                                                  @Var("apTime") String apTime,
+                                                  @Var("chargeType") String chargeType);
+
+    @Get("/getMzChargeTypeByMzyRequestId?mzyRequestId={mzyRequestId}&birthDay={birthDay}&patientId={patientId}")
+    JSONObject getMzChargeTypeByMzyRequestId(@Header("Authorization") String Authorization,
+                                             @Var("mzyRequestId") String mzyRequestId,
+                                             @Var("birthDay") String birthDay,
+                                             @Var("patientId") String patientId);
+
+    @Post("/saveMzyReqrec")
+    JSONObject saveMzyReqrec(@Header("Authorization") String Authorization, @JSONBody JSONObject jsonObject);
+
+}

+ 100 - 0
src/main/java/thyyxxk/webserver/service/outpatientBooking/OutpatientBookingService.java

@@ -0,0 +1,100 @@
+package thyyxxk.webserver.service.outpatientBooking;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.Var;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.scheduled.FetchAccessTokenTask;
+import thyyxxk.webserver.service.externalhttp.OutpatientBookingHttp;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+
+@Service
+public class OutpatientBookingService {
+    private final OutpatientBookingHttp http;
+
+    public OutpatientBookingService(OutpatientBookingHttp http) {
+        this.http = http;
+    }
+
+    /**
+     * 获取上午下午的号段
+     *
+     * @param date     时间
+     * @param deptCode 科室
+     * @return
+     */
+    public ResultVo<JSONArray> getAmpmByDateAndDeptCode(String date, String deptCode) {
+        JSONObject js = http.getAmpmByDateAndDeptCode(FetchAccessTokenTask.THMZ_TOKEN, date, deptCode);
+        if (js.getInteger("code").equals(0)) {
+            return ResultVoUtil.success(js.getJSONArray("data"));
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, js.getString("message"));
+    }
+
+    /**
+     * 获取 号别
+     *
+     * @param unitCode
+     * @param ampm
+     * @param date
+     * @param apTime
+     * @return
+     */
+    public ResultVo<JSONArray> getChargeTypeByRequestDayAndDoctor(String unitCode, String ampm, String date, String apTime) {
+        JSONObject js = http.getChargeTypeByRequestDayAndDoctor(FetchAccessTokenTask.THMZ_TOKEN, unitCode, ampm, date, apTime);
+        if (js.getInteger("code").equals(0)) {
+            return ResultVoUtil.success(js.getJSONArray("data"));
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, js.getString("message"));
+    }
+
+    /**
+     * 获取医生
+     *
+     * @param unitCode
+     * @param ampm
+     * @param date
+     * @param apTime
+     * @param chargeType
+     * @return
+     */
+    public ResultVo<JSONArray> getDoctorCodeByRequestDayAndDoctor(String unitCode, String ampm, String date, String apTime, String chargeType) {
+        JSONObject js = http.getDoctorCodeByRequestDayAndDoctor(FetchAccessTokenTask.THMZ_TOKEN, unitCode, ampm, date, apTime, chargeType);
+        if (js.getInteger("code").equals(0)) {
+            return ResultVoUtil.success(js.getJSONArray("data"));
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, js.getString("message"));
+    }
+
+    /**
+     * 获取费用接口
+     *
+     * @param mzyRequestId
+     * @param birthDay
+     * @param patientId
+     * @return
+     */
+    public ResultVo<JSONObject> getMzChargeTypeByMzyRequestId(String mzyRequestId,
+                                                              String birthDay,
+                                                              String patientId) {
+        JSONObject js = http.getMzChargeTypeByMzyRequestId(FetchAccessTokenTask.THMZ_TOKEN, mzyRequestId, birthDay, patientId);
+        if (js.getInteger("code").equals(0)) {
+            return ResultVoUtil.success(js.getJSONObject("data"));
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, js.getString("message"));
+    }
+
+
+    public ResultVo<String> saveMzyReqrec(JSONObject req) {
+        JSONObject js = http.saveMzyReqrec(FetchAccessTokenTask.THMZ_TOKEN, req);
+        if (js.getInteger("code").equals(0)) {
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "预约成功。");
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, js.getString("message"));
+    }
+
+
+}