hurugang 5 rokov pred
rodič
commit
34bb2906d2

+ 265 - 11
src/main/java/cn/hnthyy/thmz/controller/api/MedicalViewApiController.java

@@ -5,19 +5,26 @@ import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.MzPatientMi;
 import cn.hnthyy.thmz.enums.YesNoEnum;
 import cn.hnthyy.thmz.service.his.MzPatientMiService;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 @RestController
 @RequestMapping("/api/v1")
+@Slf4j
 public class MedicalViewApiController {
     @Autowired
     private MzPatientMiService mzPatientMiService;
@@ -39,7 +46,7 @@ public class MedicalViewApiController {
      */
     @UserLoginToken
     @RequestMapping(value="/queryPatientInfo/{itemType}/{itemNo}",method = {RequestMethod.GET})
-    public Map<String,Object> queryGkh(@PathVariable String itemType,@PathVariable String itemNo) {
+    public Map<String,Object> queryPatientInfo(@PathVariable String itemType,@PathVariable String itemNo) {
         Map<String,Object> results = new HashMap<>();
         if(StringUtils.isBlank(itemType)){
             results.put("resultCode",-1);
@@ -83,8 +90,8 @@ public class MedicalViewApiController {
      * @return
      */
     @UserLoginToken
-    @RequestMapping(value="/tjlb/{gkh}",method = {RequestMethod.POST})
-    public Map<String,Object> tjlbView(Haicipat haicipat) {
+    @RequestMapping(value="/savePatientInfo",method = {RequestMethod.POST})
+    public Map<String,Object> savePatientInfo(Haicipat haicipat) {
         Map<String,Object> results = new HashMap<>();
         if(haicipat==null){
             results.put("resultCode",-1);
@@ -106,12 +113,12 @@ public class MedicalViewApiController {
             results.put("resultMessage","患者性别不能为空");
             return results;
         }
-        if(StringUtils.isBlank(haicipat.getPatAge())){
+        if(haicipat.getPatAge()==null){
             results.put("resultCode",-1);
             results.put("resultMessage","患者年龄不能为空");
             return results;
         }
-        if(StringUtils.isBlank(haicipat.getPatBirth())){
+        if(haicipat.getPatBirth()==null){
             results.put("resultCode",-1);
             results.put("resultMessage","患者出生日期不能为空");
             return results;
@@ -151,13 +158,249 @@ public class MedicalViewApiController {
             results.put("resultMessage","患者监护人证件号码不能为空");
             return results;
         }
+        List<MzPatientMi> mzPatientMis=mzPatientMiService.queryBySocialNo(haicipat.getPatIdNo(),null);
+        if(mzPatientMis!=null && mzPatientMis.size()>0){
+            results.put("resultCode", -1);
+            results.put("resultMessage", "保存病人信息失败,已经存在相同的身份证号码记录");
+            return results;
+        }
+        MzPatientMi mzPatientMi = new MzPatientMi();
+        mzPatientMi.setName(haicipat.getPatName());
+        mzPatientMi.setSex(MAN.equals(haicipat.getPatSex())?YesNoEnum.YES.code:2);
+        mzPatientMi.setAge(haicipat.getPatAge());
+        mzPatientMi.setBirthDay(haicipat.getPatBirth());
+        mzPatientMi.setAddress(haicipat.getPatAddress());
+        mzPatientMi.setPhoneNo(haicipat.getPatMobile());
+        mzPatientMi.setSocialNo(haicipat.getPatIdNo());
+        mzPatientMi.setContractHz(haicipat.getGuardIdNo());
+        try {
+            int num=mzPatientMiService.saveMzPatientMi(mzPatientMi);
+            if(num==1){
+                results.put("resultCode", 0);
+                results.put("resultMessage", "保存病人信息成功");
+                results.put("patCardType",1);
+                results.put("data",mzPatientMi.getPatientId());
+                return results;
+            }
+            results.put("resultCode", -1);
+            results.put("resultMessage", "保存病人信息失败");
+            return results;
+        }catch (Exception e){
+            if (e instanceof DataIntegrityViolationException){
+                if(e.getMessage().contains("将截断字符串或二进制数据")){
+                    results.put("resultCode", -1);
+                    results.put("resultMessage", "病人地址信息超长");
+                    log.error("系统异常,错误信息{病人地址信息超长}");
+                    return results;
+                }
+            }
+            e.printStackTrace();
+            results.put("resultCode", -1);
+            results.put("resultMessage", StringUtils.isBlank(e.getMessage())?"系统出错,请联系管理员":e.getMessage());
+            log.error("系统异常,错误信息{}", e.getMessage());
+            return results;
+        }
+    }
 
-        results.put("code",0);
-        //results.put("data",medicalViewService.listByGkh(gkh));
-        return results;
+
+
+
+    /**
+     * 绑定通知
+     * @param haicipat
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value="/boundPatCardNoInfo",method = {RequestMethod.POST})
+    public Map<String,Object> boundPatCardNoInfo(Haicipat haicipat) {
+        Map<String,Object> results = new HashMap<>();
+        if(haicipat==null){
+            results.put("resultCode",-1);
+            results.put("resultMessage","建档参数为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatType())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者类型不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatName())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者姓名不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatSex())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者性别不能为空");
+            return results;
+        }
+        if(haicipat.getPatAge()==null){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者年龄不能为空");
+            return results;
+        }
+        if(haicipat.getPatBirth()==null){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者出生日期不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatAddress())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者地址不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatMobile())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者电话不能为空");
+            return results;
+        }
+        if(PERSON.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getPatIdType())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者证件类型不能为空");
+            return results;
+        }
+        if(PERSON.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getPatIdNo())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者证件号码不能为空");
+            return results;
+        }
+        if(CHILD.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getGuardName())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者监护人姓名不能为空");
+            return results;
+        }
+        if(CHILD.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getGuardIdType())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者监护人证件类型不能为空");
+            return results;
+        }
+        if(CHILD.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getGuardIdNo())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者监护人证件号码不能为空");
+            return results;
+        }
+
+        MzPatientMi mzPatientMi = new MzPatientMi();
+        mzPatientMi.setPatientId(haicipat.getPatCardNo());
+        mzPatientMi.setIcCardNo(haicipat.getPatCardNo());
+        try {
+            int num=mzPatientMiService.modifyMzPatientMi(mzPatientMi);
+            if(num==1){
+                results.put("resultCode", 0);
+                results.put("resultMessage", "绑定病人信息成功");
+                return results;
+            }
+            results.put("resultCode", -1);
+            results.put("resultMessage", "绑定病人信息失败");
+            return results;
+        }catch (Exception e){
+            e.printStackTrace();
+            results.put("resultCode", -1);
+            results.put("resultMessage", StringUtils.isBlank(e.getMessage())?"系统出错,请联系管理员":e.getMessage());
+            log.error("系统异常,错误信息{}", e.getMessage());
+            return results;
+        }
     }
 
 
+
+    /**
+     * 取消绑定通知
+     * @param haicipat
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value="/cancelBoundPatCardNoInfo",method = {RequestMethod.POST})
+    public Map<String,Object> cancelBoundPatCardNoInfo(Haicipat haicipat) {
+        Map<String,Object> results = new HashMap<>();
+        if(haicipat==null){
+            results.put("resultCode",-1);
+            results.put("resultMessage","建档参数为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatType())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者类型不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatName())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者姓名不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatSex())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者性别不能为空");
+            return results;
+        }
+        if(haicipat.getPatAge()==null){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者年龄不能为空");
+            return results;
+        }
+        if(haicipat.getPatBirth()==null){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者出生日期不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatAddress())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者地址不能为空");
+            return results;
+        }
+        if(StringUtils.isBlank(haicipat.getPatMobile())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者电话不能为空");
+            return results;
+        }
+        if(PERSON.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getPatIdType())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者证件类型不能为空");
+            return results;
+        }
+        if(PERSON.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getPatIdNo())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者证件号码不能为空");
+            return results;
+        }
+        if(CHILD.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getGuardName())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者监护人姓名不能为空");
+            return results;
+        }
+        if(CHILD.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getGuardIdType())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者监护人证件类型不能为空");
+            return results;
+        }
+        if(CHILD.equals(haicipat.getPatType()) && StringUtils.isBlank(haicipat.getGuardIdNo())){
+            results.put("resultCode",-1);
+            results.put("resultMessage","患者监护人证件号码不能为空");
+            return results;
+        }
+        try {
+            int num=mzPatientMiService.clearIcCardNo(haicipat.getPatCardNo());
+            if(num==1){
+                results.put("resultCode", 0);
+                results.put("resultMessage", "取消绑定成功");
+                return results;
+            }
+            results.put("resultCode", -1);
+            results.put("resultMessage", "取消绑定失败");
+            return results;
+        }catch (Exception e){
+            e.printStackTrace();
+            results.put("resultCode", -1);
+            results.put("resultMessage", StringUtils.isBlank(e.getMessage())?"系统出错,请联系管理员":e.getMessage());
+            log.error("系统异常,错误信息{}", e.getMessage());
+            return results;
+        }
+    }
+
+
+
+
+
     /**
      * 海慈参数类
      */
@@ -170,9 +413,11 @@ public class MedicalViewApiController {
         //性别 M:男,F:女
         private String patSex;
         //年龄
-        private String patAge;
+        private Integer patAge;
         //出生日期
-        private String patBirth;
+        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+        private Date patBirth;
         //地址
         private String patAddress;
         //电话
@@ -187,8 +432,17 @@ public class MedicalViewApiController {
         private String guardIdType;
         //监护人证件号码 患者类型为“2”儿童时,该项必输
         private String guardIdNo;
+        //诊疗卡类型  1:院内诊疗卡 2:社保卡 3:医保卡 4:区域健康卡
+        private Integer patCardType;
+        //诊疗卡号码
+        private String patCardNo;
+        //绑定渠道类型  WX:微信公众服务号 ZFB:支付宝钱包服务窗
+        private String channelType;
+        //渠道用户 ID 唯一标识微信公众服务号或者支付宝钱包 服务窗用户的 id,医院如需存储,需要保留 200 位的字段
+        private String openId;
+    }
+
 
 
-    }
 
 }

+ 2 - 1
src/main/java/cn/hnthyy/thmz/entity/his/MzPatientMi.java

@@ -52,7 +52,8 @@ public class MzPatientMi {
     private String relName;
     //借用为紧急联系人电话
     private String contractName;
-
+    //借用为紧急联系人身份证号码
+    private String contractHz;
     //最后一次访问日期 字符串
     private String lvDateStr;
     //出生日期 字符串

+ 10 - 6
src/main/java/cn/hnthyy/thmz/mapper/his/MzPatientMiMapper.java

@@ -53,10 +53,10 @@ public interface MzPatientMiMapper {
      * @param mzPatientMi
      * @return
      */
-    @Insert("INSERT INTO mz_patient_mi(social_no,name,sex,lv_date,patient_id,response_type,charge_type,times,age,birth_day,ic_card_no,phone_no,adress,rel_name,contract_name) " +
+    @Insert("INSERT INTO mz_patient_mi(social_no,name,sex,lv_date,patient_id,response_type,charge_type,times,age,birth_day,ic_card_no,phone_no,adress,rel_name,contract_name,contract_hz) " +
             "VALUES(#{socialNo,jdbcType=CHAR},#{name,jdbcType=CHAR},#{sex,jdbcType=CHAR},#{lvDate,jdbcType=TIMESTAMP},#{patientId,jdbcType=CHAR},#{responseType,jdbcType=CHAR}," +
             "#{chargeType,jdbcType=CHAR},#{times,jdbcType=INTEGER},#{age,jdbcType=TINYINT},#{birthDay,jdbcType=TIMESTAMP},#{icCardNo,jdbcType=CHAR},#{phoneNo,jdbcType=CHAR}," +
-            "#{address,jdbcType=CHAR},#{relName,jdbcType=VARCHAR},#{contractName,jdbcType=VARCHAR}) ")
+            "#{address,jdbcType=CHAR},#{relName,jdbcType=VARCHAR},#{contractName,jdbcType=VARCHAR},#{contractHz,jdbcType=VARCHAR}) ")
     int insertMzPatientMi(MzPatientMi mzPatientMi);
 
 
@@ -131,7 +131,8 @@ public interface MzPatientMiMapper {
     @Select({"<script>",
             "select rtrim(social_no) social_no,rtrim(hic_no) hic_no,rtrim(name) name,rtrim(sex) sex,lv_date,rtrim(patient_id) patient_id,rtrim(p_bar_code) p_bar_code," ,
             "rtrim(baddebt_mark) baddebt_mark,rtrim(response_type) response_type,rtrim(charge_type) charge_type,times,rtrim(reqdel_mark) reqdel_mark,age,birth_day," ,
-            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name,rtrim(contract_name) contract_name from mz_patient_mi  where  social_no =#{socialNo}",
+            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name," +
+                    "rtrim(contract_name) contract_name,rtrim(contract_hz) contract_hz from mz_patient_mi  where  social_no =#{socialNo}",
                "<when test='patientId!=null'>",
                    " and patient_id <![CDATA[<>]]> #{patientId,jdbcType=CHAR}",
                "</when>",
@@ -147,7 +148,8 @@ public interface MzPatientMiMapper {
     @Select({"<script>",
             "select rtrim(social_no) social_no,rtrim(hic_no) hic_no,rtrim(name) name,rtrim(sex) sex,lv_date,rtrim(patient_id) patient_id,rtrim(p_bar_code) p_bar_code," ,
             "rtrim(baddebt_mark) baddebt_mark,rtrim(response_type) response_type,rtrim(charge_type) charge_type,times,rtrim(reqdel_mark) reqdel_mark,age,birth_day," ,
-            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name,rtrim(contract_name) contract_name from mz_patient_mi  where  patient_id in",
+            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name," +
+                    "rtrim(contract_name) contract_name,rtrim(contract_hz) contract_hz from mz_patient_mi  where  patient_id in",
             "<foreach item='item' index='index' collection='patientIds' open='(' separator=',' close=')'>",
             "#{item}",
             "</foreach>",
@@ -162,7 +164,8 @@ public interface MzPatientMiMapper {
      */
     @Select("select rtrim(social_no) social_no,rtrim(hic_no) hic_no,rtrim(name) name,rtrim(sex) sex,lv_date,rtrim(patient_id) patient_id,rtrim(p_bar_code) p_bar_code," +
             "rtrim(baddebt_mark) baddebt_mark,rtrim(response_type) response_type,rtrim(charge_type) charge_type,times,rtrim(reqdel_mark) reqdel_mark,age,birth_day," +
-            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name,rtrim(contract_name) contract_name from mz_patient_mi  where  phone_no =#{phoneNo}")
+            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name," +
+            "rtrim(contract_name) contract_name,rtrim(contract_hz) contract_hz from mz_patient_mi  where  phone_no =#{phoneNo}")
     List<MzPatientMi> selectByPhoneNo(@Param("phoneNo") String phoneNo);
 
 
@@ -174,7 +177,8 @@ public interface MzPatientMiMapper {
      */
     @Select("select rtrim(social_no) social_no,rtrim(hic_no) hic_no,rtrim(name) name,rtrim(sex) sex,lv_date,rtrim(patient_id) patient_id,rtrim(p_bar_code) p_bar_code," +
             "rtrim(baddebt_mark) baddebt_mark,rtrim(response_type) response_type,rtrim(charge_type) charge_type,times,rtrim(reqdel_mark) reqdel_mark,age,birth_day," +
-            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name,rtrim(contract_name) contract_name from mz_patient_mi  where  ic_card_no like #{commonParams} or patient_id like #{commonParams} or name like #{commonParams}")
+            "rtrim(ic_card_no) ic_card_no,rtrim(phone_no) phone_no,rtrim(adress) address,rtrim(yb_card_no) yb_card_no,first_date,rtrim(rel_name) rel_name," +
+            "rtrim(contract_name) contract_name,rtrim(contract_hz) contract_hz from mz_patient_mi  where  ic_card_no like #{commonParams} or patient_id like #{commonParams} or name like #{commonParams}")
     List<MzPatientMi> selectByCommonParams(@Param("commonParams") String commonParams);
 
 }