Browse Source

根据身份证号码查询病人信息

hurugang 6 years ago
parent
commit
cbe4e71a0b

+ 37 - 0
src/main/java/cn/hnthyy/thmz/controller/MzPatientMiController.java

@@ -112,6 +112,43 @@ public class MzPatientMiController {
     }
 
 
+
+    /**
+     * 根据病人身份证号码查询病人信息
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getBySocialNo", method = {RequestMethod.GET})
+    public Map<String, Object> getBySocialNo(@RequestParam("socialNo") String socialNo) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (StringUtils.isBlank(socialNo)) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "病人身份证号码不能为空");
+                return resultMap;
+            }
+            List<MzPatientMi> mzPatientMis=mzPatientMiService.queryBySocialNo(socialNo,null);
+            MzPatientMi mzPatientMi = null;
+            if(mzPatientMis!=null && mzPatientMis.size()>0){
+                mzPatientMi=mzPatientMis.get(0);
+            }
+            resultMap.put("code", 0);
+            resultMap.put("message", "根据病人身份证号码查询病人信息成功");
+            resultMap.put("data", mzPatientMi);
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            resultMap.put("code", -1);
+            resultMap.put("message", "系统出错,请联系管理员");
+            log.error("系统异常,错误信息{}", e.getMessage());
+            return resultMap;
+        }
+    }
+
+
+
+
     /**
      * 新增病人信息
      *

+ 84 - 1
src/main/resources/static/js/jBox/common.js

@@ -48,6 +48,7 @@ function setCertificateData(result)
     var returnAge=jsGetAge($("#birthDay").val());
     $("#age").val(returnAge);
 	$("#idCard").val(result.Certificate.IDNumber);
+    queryUserInfoBySocialNo();
 	//$("#idIssued").val(result.Certificate.IDIssued);
 	//$("#issuedValidDate").val(result.Certificate.IssuedData+"-"+result.Certificate.ValidDate);
 	
@@ -238,4 +239,86 @@ function jsGetAge(strBirthday) {
         }
     }
     return returnAge;//返回周岁年龄
-}
+}
+
+
+
+
+
+
+/**
+ * 身份证号有变化后查询病人信息
+ */
+function queryUserInfoBySocialNo() {
+    var idCard = $("#idCard").val();
+    if (idCard.length == 18) {
+        $.ajax({
+            type: "GET",
+            url: '/thmz/getBySocialNo?socialNo=' + idCard,
+            contentType: "application/json;charset=UTF-8",
+            dataType: "json",
+            headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+            success: function (res) {
+                if (res == '401' || res == 401) {
+                    window.location.href = '/thmz/login/view'
+                    return;
+                }
+                if (res.code == 0) {
+                    if (res.data != null) {
+                        $("#cardNo").blur();
+                        $("#userName").val(res.data.name);
+                        $("#userName").blur();
+                        $("#userNameReadOnly").val(res.data.name);
+                        $("#age").val(res.data.age);
+                        $("#age").blur();
+                        $("#gender").selectpicker('val', res.data.sex);
+                        $("#gender").selectpicker('refresh');
+                        $("#gender").blur();
+                        $("#birthDayReadonly").val(res.data.birthDayStr);
+                        $("#birthDayReadonly").attr("title", res.data.birthDayStr);
+                        $("#birthDay").val(res.data.birthDayStr);
+                        $("#birthDay").blur();
+                        $("#phoneNum").val(res.data.phoneNo);
+                        $("#phoneNum").attr("title", res.data.phoneNo);
+                        $("#phoneNum").blur();
+                        $("#patientsNature").selectpicker('val', res.data.responseType);//默认选中
+                        $('#patientsNature').selectpicker('refresh');
+                        $("#patientsNature").blur();
+                        $("#idCard").val(res.data.socialNo);
+                        $("#idCard").attr("title", res.data.socialNo);
+                        $("#idCard").blur();
+                        $("#address").val(res.data.address);
+                        $("#address").blur();
+                        $("#patientId").val(res.data.patientId);
+                        if (res.data.name != null && res.data.name != "") {
+                            $("#editUser").show();
+                        }
+
+                        $("#cardNo").attr("readonly", "readonly");
+                        $("#userName").attr("readonly", "readonly");
+                        $("#age").attr("readonly", "readonly");
+                        $("#gender").attr("disabled", "disabled");
+                        $("#phoneNum").attr("readonly", "readonly");
+                        $("#patientsNature").attr("disabled", "disabled");
+                        $("#idCard").attr("readonly", "readonly");
+                        $("#address").attr("readonly", "readonly");
+                        $("#birthDayReadonly").removeClass("hide").addClass("in");
+                        $("#birthDayGroup").removeClass("in").addClass("hide");
+                        $("#userName").removeClass("in").addClass("hide");
+                        $("#userNameReadOnly").removeClass("hide").addClass("in");
+                        $("#webuiPopover0").css("display", "none");
+                    }
+                } else {
+                    new PNotify({
+                        title: '错误提示',
+                        text: res.message,
+                        type: 'error',
+                        hide: true,
+                        styling: 'bootstrap3'
+                    });
+                }
+            }
+        });
+
+    }
+}

+ 4 - 0
src/main/resources/static/js/registration.js

@@ -239,6 +239,10 @@ $(function () {
         var returnAge=jsGetAge($("#birthDay").val());
         $("#age").val(returnAge);
     });
+
+    $("#idCard").change(function(e){
+        queryUserInfoBySocialNo();
+    });
 });