Sfoglia il codice sorgente

住院服务满意度调查扫码入口与逻辑优化

lighter 11 mesi fa
parent
commit
e091bc9e3a

+ 3 - 3
src/main/java/thyyxxk/wxservice_server/controller/WeChatRedirectController.java

@@ -60,12 +60,12 @@ public class WeChatRedirectController {
     }
 
     @PassToken
-    @GetMapping("/selectAssessmentPatient")
-    public void selectAssessmentPatient(HttpServletResponse response) {
+    @GetMapping("/inpatientQrEntry")
+    public void inpatientQrEntry(HttpServletResponse response) {
         try {
             response.sendRedirect("https://open.weixin.qq.com/connect/oauth2/authorize?" +
                     "appid=wxbde6b16acad84204&redirect_uri=http://staticweb.hnthyy.cn/wxserver/redirect/page2?" +
-                    "to=selectAssessmentPatient&response_type=code&scope=snsapi_base&state=1#wechat_redirect");
+                    "to=inpatientQrEntry&response_type=code&scope=snsapi_base&state=1#wechat_redirect");
         } catch (IOException e) {
             throw new RuntimeException(e);
         }

+ 10 - 0
src/main/java/thyyxxk/wxservice_server/dao/AssessmentDao.java

@@ -34,6 +34,9 @@ public interface AssessmentDao {
     @Select("select rtrim(isnull(zk_ward,dis_dept)) from zy_inactpatient where inpatient_no=#{patNo} and admiss_times=#{times}")
     String getDismissDept(String patNo, int times);
 
+    @Select("select rtrim(zk_ward) from zy_actpatient where inpatient_no=#{patNo} and admiss_times=#{times}")
+    String getDismissDept2(String patNo, int times);
+
     @Select("select frequency from t_questionnaire_frequency where code=#{code} ")
     int selectQuestionnaireFrequency(String code);
 
@@ -60,4 +63,11 @@ public interface AssessmentDao {
     @Update("update zy_inactpatient set inpatient_satisfied_questionnaire=getdate() where " +
             "inpatient_no=#{inpatientNo} and admiss_times=#{times}")
     void updateQuestionnaireTime2(String inpatientNo, int times);
+
+    @Select("select top 1 rtrim(inpatient_no) from a_patient_mi " +
+            "where mz_no=#{patientId} and inpatient_no not like 'JT%'")
+    String getInpatientNo(String patientId);
+
+    @Select("select isnull(max(admiss_times),0) from zy_ledger_file where inpatient_no=#{patNo} ")
+    int getAdmissTimes(String patNo);
 }

+ 17 - 0
src/main/java/thyyxxk/wxservice_server/service/AssessmentService.java

@@ -13,6 +13,7 @@ import thyyxxk.wxservice_server.entity.assessment.ComplaintsAndSuggestions;
 import thyyxxk.wxservice_server.entity.assessment.DepressionQuestionnaire;
 import thyyxxk.wxservice_server.entity.assessment.InpatientQuestionnaire;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.StringUtil;
 import thyyxxk.wxservice_server.utils.TokenUtil;
 
 import java.util.Objects;
@@ -59,7 +60,13 @@ public class AssessmentService {
 
     public ResultVo<String> submitInpatientQuestionnaire(InpatientQuestionnaire questionnaire) {
         log.info("住院服务满意度调查:{}", questionnaire);
+        if (Objects.equals(questionnaire.getInpatientNo(), "unknown")) {
+            fillInpatientNo(questionnaire);
+        }
         String deptCode = dao.getDismissDept(questionnaire.getInpatientNo(), questionnaire.getTimes());
+        if (StringUtil.isBlank(deptCode)) {
+            deptCode = dao.getDismissDept2(questionnaire.getInpatientNo(), questionnaire.getTimes());
+        }
         questionnaire.setDeptCode(deptCode);
         inpatientQuestionnaireDao.insert(questionnaire);
         return ResultVoUtil.success();
@@ -71,4 +78,14 @@ public class AssessmentService {
         dao.insertComplaintsAndSuggestions(suggestions);
         return ResultVoUtil.success();
     }
+
+    private void fillInpatientNo(InpatientQuestionnaire questionnaire) {
+        String patNo = dao.getInpatientNo(questionnaire.getPatientId());
+        if (StringUtil.notBlank(patNo)) {
+            int times = dao.getAdmissTimes(patNo);
+            questionnaire.setInpatientNo(patNo);
+            questionnaire.setTimes(times);
+        }
+    }
+
 }